X-Git-Url: http://git.argeo.org/?a=blobdiff_plain;f=plugins%2Forg.argeo.slc.client.ui%2Fsrc%2Fmain%2Fjava%2Forg%2Fargeo%2Fslc%2Fclient%2Fui%2Fviews%2FJcrExecutionModulesView.java;h=3d73adc27a8f0eee7815acf975ae219bbfd2b660;hb=fd6362dda19f29ca746ecefae779694e6cb43dd4;hp=38336f4673e3cc7e7b471779154b075b92b6b15e;hpb=58e0e18d64a2080680a9f8397b0dfa2894519910;p=gpl%2Fargeo-slc.git diff --git a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java index 38336f467..3d73adc27 100644 --- a/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java +++ b/plugins/org.argeo.slc.client.ui/src/main/java/org/argeo/slc/client/ui/views/JcrExecutionModulesView.java @@ -74,18 +74,18 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, private final static Log log = LogFactory .getLog(JcrExecutionModulesView.class); - public static final String ID = "org.argeo.slc.client.ui.jcrExecutionModulesView"; + public static final String ID = ClientUiPlugin.ID + + ".jcrExecutionModulesView"; private TreeViewer viewer; + /* DEPENDENCY INJECTION */ private Session session; - private ExecutionModulesManager modulesManager; public void createPartControl(Composite parent) { viewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL); EclipseUiSpecificUtils.enableToolTipSupport(viewer); - ViewContentProvider contentProvider = new ViewContentProvider(session); viewer.setContentProvider(contentProvider); viewer.setComparer(new NodeElementComparer()); @@ -93,6 +93,9 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, viewer.setLabelProvider(viewLabelProvider); viewer.setInput(getViewSite()); viewer.addDoubleClickListener(new ViewDoubleClickListener()); + // context menu + // addContextMenu(viewer); + getViewSite().setSelectionProvider(viewer); Transfer[] tt = new Transfer[] { TextTransfer.getInstance() }; @@ -128,6 +131,7 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, viewer.setInput(getViewSite()); } + // Controllers class ViewContentProvider extends SimpleNodeContentProvider { public ViewContentProvider(Session session) { @@ -210,6 +214,25 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, } + // private void addContextMenu(TreeViewer flowsViewer) { + // + // final MenuManager menuMgr = new MenuManager(); + // menuMgr.setRemoveAllWhenShown(true); + // menuMgr.addMenuListener(new IMenuListener() { + // + // public void menuAboutToShow(IMenuManager manager) { + // menuMgr.add(new Action("Test") { + // public void run() { + // log.debug("do something"); + // } + // }); + // } + // }); + // Menu menu = menuMgr.createContextMenu(flowsViewer.getControl()); + // flowsViewer.getTree().setMenu(menu); + // getSite().registerContextMenu(menuMgr, flowsViewer); + // } + class VmAgentObserver extends AsyncUiEventListener { public VmAgentObserver(Display display) { @@ -343,22 +366,68 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, /** Listen to drags */ class ViewDragListener extends DragSourceAdapter { + + // Check if the drag action should start. + public void dragStart(DragSourceEvent event) { + // we only start drag if at least one of the selected elements is + // valid + boolean doIt = false; + IStructuredSelection selection = (IStructuredSelection) viewer + .getSelection(); + @SuppressWarnings("rawtypes") + Iterator it = selection.iterator(); + try { + while (it.hasNext()) { + Object obj = it.next(); + if (obj instanceof Node) { + Node node = (Node) obj; + if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW) + || node.isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) { + doIt = true; + } + } + } + } catch (RepositoryException e) { + throw new SlcException("Cannot read node to set drag data", e); + } + event.doit = doIt; + } + public void dragSetData(DragSourceEvent event) { IStructuredSelection selection = (IStructuredSelection) viewer .getSelection(); - if (selection.getFirstElement() instanceof Node) { - Node node = (Node) selection.getFirstElement(); - if (TextTransfer.getInstance().isSupportedType(event.dataType)) { - try { - event.data = node.getPath(); - } catch (RepositoryException e) { - throw new SlcException("Cannot read node", e); + StringBuilder buf = new StringBuilder(); + @SuppressWarnings("rawtypes") + Iterator it = selection.iterator(); + try { + + while (it.hasNext()) { + Object obj = it.next(); + + if (obj instanceof Node) { + Node node = (Node) obj; + if ((node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW) || node + .isNodeType(SlcTypes.SLC_EXECUTION_MODULE)) + && TextTransfer.getInstance().isSupportedType( + event.dataType)) { + buf.append(node.getPath()).append('\n'); + } } } + } catch (RepositoryException e) { + throw new SlcException("Cannot read node to set drag data", e); + } + + if (buf.length() > 0) { + if (buf.charAt(buf.length() - 1) == '\n') + buf.deleteCharAt(buf.length() - 1); + event.data = buf.toString(); + log.debug("data set to : " + buf.toString()); } } } + // DEPENDENCY INJECTION public void setSession(Session session) { this.session = session; } @@ -366,5 +435,4 @@ public class JcrExecutionModulesView extends ViewPart implements SlcTypes, public void setModulesManager(ExecutionModulesManager modulesManager) { this.modulesManager = modulesManager; } - } \ No newline at end of file