]> git.argeo.org Git - lgpl/argeo-commons.git/blob - security/eclipse/plugins/org.argeo.security.ui/src/main/java/org/argeo/security/ui/commands/SaveArgeoUser.java
Improve Security
[lgpl/argeo-commons.git] / security / eclipse / plugins / org.argeo.security.ui / src / main / java / org / argeo / security / ui / commands / SaveArgeoUser.java
1 package org.argeo.security.ui.commands;
2
3 import org.eclipse.core.commands.AbstractHandler;
4 import org.eclipse.core.commands.ExecutionEvent;
5 import org.eclipse.core.commands.ExecutionException;
6 import org.eclipse.jface.dialogs.MessageDialog;
7 import org.eclipse.swt.widgets.Display;
8 import org.eclipse.ui.IEditorPart;
9 import org.eclipse.ui.IWorkbenchPart;
10 import org.eclipse.ui.handlers.HandlerUtil;
11
12 /** Save the currently edited Argeo user. */
13 public class SaveArgeoUser extends AbstractHandler {
14 public final static String COMMAND_ID = "org.argeo.security.ui.saveArgeoUser";
15
16 public Object execute(ExecutionEvent event) throws ExecutionException {
17 try {
18 IWorkbenchPart iwp = HandlerUtil.getActiveWorkbenchWindow(event)
19 .getActivePage().getActivePart();
20
21 if (!(iwp instanceof IEditorPart))
22 return null;
23 IEditorPart editor = (IEditorPart) iwp;
24 editor.doSave(null);
25 } catch (Exception e) {
26 MessageDialog.openError(Display.getDefault().getActiveShell(),
27 "Error", "Cannot save user: " + e.getMessage());
28 }
29 return null;
30 }
31
32 }