Search in sources :

Example 1 with GraphItem

use of org.eclipse.zest.core.widgets.GraphItem in project linuxtools by eclipse.

the class MouseListenerTest method test.

@Test
public void test() {
    StapGraphParser parse = new StapGraphParser();
    parse.setSourcePath(Activator.getPluginLocation() + "eag.graph");
    parse.testRun(new NullProgressMonitor(), true);
    CallgraphView cView = (CallgraphView) ViewFactory.createView("org.eclipse.linuxtools.callgraph.callgraphview");
    StapUIJob j = new StapUIJob("Test Graph UI Job", parse, CallGraphConstants.VIEW_ID);
    j.runInUIThread(new NullProgressMonitor());
    StapGraphMouseListener mListener = cView.getGraph().getMouseListener();
    StapGraph g = cView.getGraph();
    g.setProject(parse.project);
    GraphItem[] nodes = { g.getNode(g.getFirstUsefulNode()) };
    g.setSelection(nodes);
    mListener.mouseDownEvent(0, 0);
    g.draw(StapGraph.CONSTANT_DRAWMODE_TREE, StapGraph.CONSTANT_ANIMATION_FASTEST, g.getFirstUsefulNode());
    mListener.mouseUp(null);
}
Also used : StapGraphParser(org.eclipse.linuxtools.internal.callgraph.StapGraphParser) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) StapGraphMouseListener(org.eclipse.linuxtools.internal.callgraph.graphlisteners.StapGraphMouseListener) CallgraphView(org.eclipse.linuxtools.internal.callgraph.CallgraphView) GraphItem(org.eclipse.zest.core.widgets.GraphItem) StapUIJob(org.eclipse.linuxtools.internal.callgraph.core.StapUIJob) StapGraph(org.eclipse.linuxtools.internal.callgraph.StapGraph) Test(org.junit.Test)

Example 2 with GraphItem

use of org.eclipse.zest.core.widgets.GraphItem in project archi by archimatetool.

the class AbstractStructuredGraphViewer method findItems.

protected GraphItem[] findItems(List l) {
    if (l == null) {
        return new GraphItem[0];
    }
    ArrayList list = new ArrayList();
    Iterator iterator = l.iterator();
    while (iterator.hasNext()) {
        GraphItem w = (GraphItem) findItem(iterator.next());
        list.add(w);
    }
    return (GraphItem[]) list.toArray(new GraphItem[list.size()]);
}
Also used : ArrayList(java.util.ArrayList) Iterator(java.util.Iterator) GraphItem(org.eclipse.zest.core.widgets.GraphItem)

Example 3 with GraphItem

use of org.eclipse.zest.core.widgets.GraphItem in project archi by archimatetool.

the class AbstractStructuredGraphViewer method getSelectionFromWidget.

/*
     * (non-Javadoc)
     * 
     * @see org.eclipse.jface.viewers.StructuredViewer#getSelectionFromWidget()
     */
@Override
protected List getSelectionFromWidget() {
    List internalSelection = getWidgetSelection();
    LinkedList externalSelection = new LinkedList();
    for (Iterator i = internalSelection.iterator(); i.hasNext(); ) {
        Object data = ((GraphItem) i.next()).getData();
        if (data != null) {
            externalSelection.add(data);
        }
    }
    return externalSelection;
}
Also used : Iterator(java.util.Iterator) GraphItem(org.eclipse.zest.core.widgets.GraphItem) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) LinkedList(java.util.LinkedList)

Example 4 with GraphItem

use of org.eclipse.zest.core.widgets.GraphItem in project archi by archimatetool.

the class AbstractStructuredGraphViewer method filterVisuals.

protected void filterVisuals() {
    if (getGraphControl() == null) {
        return;
    }
    Object[] filtered = getFilteredChildren(getInput());
    SimpleGraphComparator comparator = new SimpleGraphComparator();
    TreeSet filteredElements = new TreeSet(comparator);
    TreeSet unfilteredElements = new TreeSet(comparator);
    List connections = getGraphControl().getConnections();
    List nodes = getGraphControl().getNodes();
    if (filtered.length == 0) {
        // the nodes?
        for (Iterator i = connections.iterator(); i.hasNext(); ) {
            GraphConnection c = (GraphConnection) i.next();
            c.setVisible(false);
        }
        for (Iterator i = nodes.iterator(); i.hasNext(); ) {
            GraphNode n = (GraphNode) i.next();
            n.setVisible(false);
        }
        return;
    }
    for (Iterator i = connections.iterator(); i.hasNext(); ) {
        GraphConnection c = (GraphConnection) i.next();
        if (c.getExternalConnection() != null) {
            unfilteredElements.add(c);
        }
    }
    for (Iterator i = nodes.iterator(); i.hasNext(); ) {
        GraphNode n = (GraphNode) i.next();
        if (n.getData() != null) {
            unfilteredElements.add(n);
        }
    }
    for (int i = 0; i < filtered.length; i++) {
        Object modelElement = connectionsMap.get(filtered[i]);
        if (modelElement == null) {
            modelElement = nodesMap.get(filtered[i]);
        }
        if (modelElement != null) {
            filteredElements.add(modelElement);
        }
    }
    unfilteredElements.removeAll(filteredElements);
    // all the elements that passed to visible.
    while (unfilteredElements.size() > 0) {
        GraphItem i = (GraphItem) unfilteredElements.first();
        i.setVisible(false);
        unfilteredElements.remove(i);
    }
    while (filteredElements.size() > 0) {
        GraphItem i = (GraphItem) filteredElements.first();
        i.setVisible(true);
        filteredElements.remove(i);
    }
}
Also used : TreeSet(java.util.TreeSet) GraphConnection(org.eclipse.zest.core.widgets.GraphConnection) Iterator(java.util.Iterator) GraphItem(org.eclipse.zest.core.widgets.GraphItem) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) GraphNode(org.eclipse.zest.core.widgets.GraphNode) CGraphNode(org.eclipse.zest.core.widgets.CGraphNode)

Aggregations

GraphItem (org.eclipse.zest.core.widgets.GraphItem)4 ArrayList (java.util.ArrayList)3 Iterator (java.util.Iterator)3 LinkedList (java.util.LinkedList)2 List (java.util.List)2 TreeSet (java.util.TreeSet)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 CallgraphView (org.eclipse.linuxtools.internal.callgraph.CallgraphView)1 StapGraph (org.eclipse.linuxtools.internal.callgraph.StapGraph)1 StapGraphParser (org.eclipse.linuxtools.internal.callgraph.StapGraphParser)1 StapUIJob (org.eclipse.linuxtools.internal.callgraph.core.StapUIJob)1 StapGraphMouseListener (org.eclipse.linuxtools.internal.callgraph.graphlisteners.StapGraphMouseListener)1 CGraphNode (org.eclipse.zest.core.widgets.CGraphNode)1 GraphConnection (org.eclipse.zest.core.widgets.GraphConnection)1 GraphNode (org.eclipse.zest.core.widgets.GraphNode)1 Test (org.junit.Test)1