]> git.argeo.org Git - gpl/argeo-slc.git/blob - commands/SortChildNodes.java
Prepare next development cycle
[gpl/argeo-slc.git] / commands / SortChildNodes.java
1 package org.argeo.cms.ui.workbench.internal.jcr.commands;
2
3 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
4 import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
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 /** Change isSorted state of the DataExplorer Browser */
15 public class SortChildNodes extends AbstractHandler {
16 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
17 + ".sortChildNodes";
18
19 public Object execute(ExecutionEvent event) throws ExecutionException {
20 JcrBrowserView view = (JcrBrowserView) HandlerUtil
21 .getActiveWorkbenchWindow(event).getActivePage()
22 .findView(JcrBrowserView.ID);
23
24 ICommandService service = (ICommandService) PlatformUI.getWorkbench()
25 .getService(ICommandService.class);
26 Command command = service.getCommand(ID);
27 State state = command.getState(ID + ".toggleState");
28
29 boolean wasSorted = (Boolean) state.getValue();
30 view.setSortChildNodes(!wasSorted);
31 state.setValue(!wasSorted);
32 return null;
33 }
34 }