]> git.argeo.org Git - lgpl/argeo-commons.git/blob - server/plugins/org.argeo.jcr.ui.explorer/src/main/java/org/argeo/jcr/ui/explorer/commands/SortChildNodes.java
fix a few bugs
[lgpl/argeo-commons.git] / server / plugins / org.argeo.jcr.ui.explorer / src / main / java / org / argeo / jcr / ui / explorer / commands / SortChildNodes.java
1 package org.argeo.jcr.ui.explorer.commands;
2
3 import org.argeo.jcr.ui.explorer.JcrExplorerPlugin;
4 import org.argeo.jcr.ui.explorer.views.GenericJcrBrowser;
5 import org.eclipse.core.commands.AbstractHandler;
6 import org.eclipse.core.commands.Command;
7 import org.eclipse.core.commands.ExecutionEvent;
8 import org.eclipse.core.commands.ExecutionException;
9 import org.eclipse.core.commands.State;
10 import org.eclipse.ui.PlatformUI;
11 import org.eclipse.ui.commands.ICommandService;
12 import org.eclipse.ui.handlers.HandlerUtil;
13
14 /**
15 * Change isSorted state of the JcrExplorer Browser
16 */
17 public class SortChildNodes extends AbstractHandler {
18 public final static String ID = JcrExplorerPlugin.ID + ".sortChildNodes";
19
20 public Object execute(ExecutionEvent event) throws ExecutionException {
21 GenericJcrBrowser view = (GenericJcrBrowser) HandlerUtil
22 .getActiveWorkbenchWindow(event).getActivePage()
23 .findView(GenericJcrBrowser.ID);
24
25 ICommandService service = (ICommandService) PlatformUI.getWorkbench()
26 .getService(ICommandService.class);
27 Command command = service.getCommand(ID);
28 State state = command.getState(ID + ".toggleState");
29
30 boolean wasSorted = (Boolean) state.getValue();
31 view.setSortChildNodes(!wasSorted);
32 state.setValue(!wasSorted);
33 return null;
34 }
35 }