1 package org
.argeo
.jcr
.ui
.explorer
.commands
;
5 import org
.argeo
.eclipse
.ui
.ErrorFeedback
;
6 import org
.argeo
.jcr
.JcrUtils
;
7 import org
.argeo
.jcr
.ui
.explorer
.JcrExplorerPlugin
;
8 import org
.argeo
.jcr
.ui
.explorer
.model
.SingleJcrNode
;
9 import org
.argeo
.jcr
.ui
.explorer
.model
.WorkspaceNode
;
10 import org
.argeo
.jcr
.ui
.explorer
.views
.GenericJcrBrowser
;
11 import org
.eclipse
.core
.commands
.AbstractHandler
;
12 import org
.eclipse
.core
.commands
.ExecutionEvent
;
13 import org
.eclipse
.core
.commands
.ExecutionException
;
14 import org
.eclipse
.jface
.dialogs
.MessageDialog
;
15 import org
.eclipse
.jface
.viewers
.ISelection
;
16 import org
.eclipse
.jface
.viewers
.IStructuredSelection
;
17 import org
.eclipse
.swt
.widgets
.Shell
;
18 import org
.eclipse
.ui
.handlers
.HandlerUtil
;
20 /** Opens the generic node editor. */
21 public class GetNodeSize
extends AbstractHandler
{
22 // private final static Log log = LogFactory.getLog(GetNodeSize.class);
24 public final static String ID
= "org.argeo.jcr.ui.explorer.getNodeSize";
25 public final static String DEFAULT_ICON_REL_PATH
= "icons/getSize.gif";
26 public final static String DEFAULT_LABEL
= JcrExplorerPlugin
27 .getMessage("getNodeSizeCmdLbl");
29 public Object
execute(ExecutionEvent event
) throws ExecutionException
{
30 // JcrUtils.getRepositoryByAlias(repositoryRegister,
31 // ArgeoJcrConstants.ALIAS_NODE);
33 ISelection selection
= HandlerUtil
.getActiveWorkbenchWindow(event
)
34 .getActivePage().getSelection();
35 GenericJcrBrowser view
= (GenericJcrBrowser
) HandlerUtil
36 .getActiveWorkbenchWindow(event
).getActivePage()
37 .findView(HandlerUtil
.getActivePartId(event
));
39 if (selection
!= null && !selection
.isEmpty()
40 && selection
instanceof IStructuredSelection
) {
43 IStructuredSelection iss
= (IStructuredSelection
) selection
;
45 ErrorFeedback
.show(JcrExplorerPlugin
46 .getMessage("warningInvalidMultipleSelection"), null);
50 if (iss
.getFirstElement() instanceof SingleJcrNode
)
51 node
= ((SingleJcrNode
) iss
.getFirstElement()).getNode();
52 else if (iss
.getFirstElement() instanceof WorkspaceNode
)
53 node
= ((WorkspaceNode
) iss
.getFirstElement()).getRootNode();
55 // unvalid object type
58 size
= JcrUtils
.getNodeApproxSize(node
);
60 String
[] labels
= { "OK" };
61 Shell shell
= HandlerUtil
.getActiveWorkbenchWindow(event
)
63 MessageDialog md
= new MessageDialog(shell
, "Node size", null,
64 "Node size is: " + size
/ 1024 + " KB",
65 MessageDialog
.INFORMATION
, labels
, 0);