1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.argeo.cms.ui.workbench.internal.jcr.commands;
17
18 import org.argeo.cms.ui.workbench.WorkbenchUiPlugin;
19 import org.argeo.cms.ui.workbench.jcr.JcrBrowserView;
20 import org.eclipse.core.commands.AbstractHandler;
21 import org.eclipse.core.commands.Command;
22 import org.eclipse.core.commands.ExecutionEvent;
23 import org.eclipse.core.commands.ExecutionException;
24 import org.eclipse.core.commands.State;
25 import org.eclipse.ui.PlatformUI;
26 import org.eclipse.ui.commands.ICommandService;
27 import org.eclipse.ui.handlers.HandlerUtil;
28
29
30 public class SortChildNodes extends AbstractHandler {
31 public final static String ID = WorkbenchUiPlugin.PLUGIN_ID
32 + ".sortChildNodes";
33
34 public Object execute(ExecutionEvent event) throws ExecutionException {
35 JcrBrowserView view = (JcrBrowserView) HandlerUtil
36 .getActiveWorkbenchWindow(event).getActivePage()
37 .findView(JcrBrowserView.ID);
38
39 ICommandService service = (ICommandService) PlatformUI.getWorkbench()
40 .getService(ICommandService.class);
41 Command command = service.getCommand(ID);
42 State state = command.getState(ID + ".toggleState");
43
44 boolean wasSorted = (Boolean) state.getValue();
45 view.setSortChildNodes(!wasSorted);
46 state.setValue(!wasSorted);
47 return null;
48 }
49 }