import java.util.List;
import javax.jcr.Node;
-import javax.jcr.NodeIterator;
import javax.jcr.Property;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
+import javax.jcr.nodetype.NodeType;
import javax.jcr.observation.Event;
import javax.jcr.observation.EventIterator;
-import javax.jcr.observation.EventListener;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
import org.argeo.ArgeoException;
+import org.argeo.eclipse.ui.jcr.AsyncUiEventListener;
import org.argeo.eclipse.ui.jcr.DefaultNodeLabelProvider;
-import org.argeo.eclipse.ui.jcr.NodesWrapper;
import org.argeo.eclipse.ui.jcr.SimpleNodeContentProvider;
-import org.argeo.eclipse.ui.jcr.WrappedNode;
import org.argeo.slc.SlcException;
import org.argeo.slc.client.ui.SlcImages;
import org.argeo.slc.client.ui.editors.ProcessEditor;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.part.ViewPart;
+/** JCR based view of the execution modules. */
public class JcrExecutionModulesView extends ViewPart implements SlcTypes,
SlcNames {
- private final static Log log = LogFactory
- .getLog(JcrExecutionModulesView.class);
+ // private final static Log log = LogFactory
+ // .getLog(JcrExecutionModulesView.class);
public static final String ID = "org.argeo.slc.client.ui.jcrExecutionModulesView";
new String[] { SlcJcrConstants.VM_AGENT_FACTORY_PATH });
}
- @Override
- protected Object[] getChildren(Node node) throws RepositoryException {
- if (node.isNodeType(SlcTypes.SLC_AGENT_PROXY)) {
- List<AgentNodesWrapper> wrappers = new ArrayList<AgentNodesWrapper>();
- for (NodeIterator nit = node.getNodes(); nit.hasNext();) {
- wrappers.add(new AgentNodesWrapper(nit.nextNode()));
- }
- return wrappers.toArray();
- }
- return super.getChildren(node);
- }
+ // @Override
+ // protected Object[] getChildren(Node node) throws RepositoryException
+ // {
+ // if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY)) {
+ // List<AgentNodesWrapper> wrappers = new
+ // ArrayList<AgentNodesWrapper>();
+ // for (NodeIterator nit = node.getNodes(); nit.hasNext();) {
+ // wrappers.add(new AgentNodesWrapper(nit.nextNode()));
+ // }
+ // return wrappers.toArray();
+ // }
+ // return super.getChildren(node);
+ // }
@Override
protected Object[] sort(Object parent, Object[] children) {
if (o1 instanceof Node && o2 instanceof Node) {
Node node1 = (Node) o1;
Node node2 = (Node) o2;
+
+ if (node1.getName().equals(SLC_EXECUTION_SPECS))
+ return -100;
+ if (node2.getName().equals(SLC_EXECUTION_SPECS))
+ return 100;
+
if (node1.isNodeType(SLC_EXECUTION_FLOW)
&& node2.isNodeType(SLC_EXECUTION_FLOW)) {
return node1.getName().compareTo(node2.getName());
}
- /** Wraps the execution modules of an agent. */
- static class AgentNodesWrapper extends NodesWrapper {
-
- public AgentNodesWrapper(Node node) {
- super(node);
- }
-
- protected List<WrappedNode> getWrappedNodes()
- throws RepositoryException {
- List<WrappedNode> children = new ArrayList<WrappedNode>();
- Node executionModules = getNode().getNode(
- SlcNames.SLC_EXECUTION_MODULES);
- for (NodeIterator nit = executionModules.getNodes(); nit.hasNext();) {
- for (NodeIterator nitVersions = nit.nextNode().getNodes(); nitVersions
- .hasNext();) {
- children.add(new WrappedNode(this, nitVersions.nextNode()));
- }
- }
- return children;
- }
-
- }
-
- class VmAgentObserver implements EventListener {
-
- public void onEvent(EventIterator events) {
+ // /** Wraps the execution modules of an agent. */
+ // static class AgentNodesWrapper extends NodesWrapper {
+ //
+ // public AgentNodesWrapper(Node node) {
+ // super(node);
+ // }
+ //
+ // protected List<WrappedNode> getWrappedNodes()
+ // throws RepositoryException {
+ // List<WrappedNode> children = new ArrayList<WrappedNode>();
+ // Node executionModules = getNode();
+ // for (NodeIterator nit = executionModules.getNodes(); nit.hasNext();) {
+ // for (NodeIterator nitVersions = nit.nextNode().getNodes(); nitVersions
+ // .hasNext();) {
+ // children.add(new WrappedNode(this, nitVersions.nextNode()));
+ // }
+ // }
+ // return children;
+ // }
+ //
+ // }
+
+ class VmAgentObserver extends AsyncUiEventListener {
+ protected void onEventInUiThread(EventIterator events) {
viewer.refresh();
}
-
}
class ViewLabelProvider extends DefaultNodeLabelProvider implements
ITableLabelProvider {
- public String getColumnText(Object obj, int index) {
- return getText(obj);
- }
- public Image getColumnImage(Object obj, int index) {
- return getImage(obj);
+ @Override
+ protected String getText(Node node) throws RepositoryException {
+ if (node.getName().equals(SLC_EXECUTION_SPECS))
+ return "Execution Specifications";
+ else if (node.getPath().equals(
+ SlcJcrConstants.VM_AGENT_FACTORY_PATH))
+ return "Internal Agents";
+ return super.getText(node);
}
+ @Override
public Image getImage(Node node) throws RepositoryException {
- if (node.getParent().isNodeType(SlcTypes.SLC_AGENT_PROXY))
- return SlcImages.AGENT;
- else if (node.isNodeType(SlcTypes.SLC_MODULE))
- return SlcImages.MODULE;
+ // we try to optimize a bit by putting deeper nodes first
+ if (node.getParent().isNodeType(
+ SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+ return SlcImages.CHOICES;
+ else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC_ATTRIBUTE))
+ return SlcImages.EXECUTION_SPEC_ATTRIBUTE;
+ else if (node.isNodeType(SlcTypes.SLC_EXECUTION_SPEC))
+ return SlcImages.EXECUTION_SPEC;
+ else if (node.getName().equals(SLC_EXECUTION_SPECS))
+ return SlcImages.EXECUTION_SPECS;
else if (node.isNodeType(SlcTypes.SLC_EXECUTION_FLOW))
return SlcImages.FLOW;
+ else if (node.isNodeType(SlcTypes.SLC_MODULE))
+ return SlcImages.MODULE;
+ else if (node.isNodeType(SlcTypes.SLC_AGENT))
+ return SlcImages.AGENT;
+ else if (node.isNodeType(SlcTypes.SLC_AGENT_FACTORY))
+ return SlcImages.AGENT_FACTORY;
else
return SlcImages.FOLDER;
}
public String getToolTipText(Node node) throws RepositoryException {
- if (node.isNodeType(SlcTypes.SLC_MODULE)
+ if (node.isNodeType(NodeType.MIX_TITLE)
&& node.hasProperty(Property.JCR_DESCRIPTION))
return node.getProperty(Property.JCR_DESCRIPTION).getString();
return super.getToolTipText(node);
}
+ public String getColumnText(Object obj, int index) {
+ return getText(obj);
+ }
+
+ public Image getColumnImage(Object obj, int index) {
+ return getImage(obj);
+ }
+
}
class ViewDoubleClickListener implements IDoubleClickListener {
}
class ViewDragListener extends DragSourceAdapter {
-
- public void dragStart(DragSourceEvent event) {
- if (log.isDebugEnabled())
- log.debug("Start Drag " + event);
- super.dragStart(event);
- }
-
public void dragSetData(DragSourceEvent event) {
-
- // System.out.println("dragSetData: " + event);
-
IStructuredSelection selection = (IStructuredSelection) viewer
.getSelection();
if (selection.getFirstElement() instanceof Node) {
}
}
}
-
- public void dragFinished(DragSourceEvent event) {
- if (log.isDebugEnabled())
- log.debug("Finished Drag " + event);
- }
-
}
public void setSession(Session session) {