Search in sources :

Example 11 with GraphConnection

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

the class AbstractStructuredGraphViewer method unReveal.

public void unReveal(Object element) {
    Widget[] items = this.findItems(element);
    for (int i = 0; i < items.length; i++) {
        Widget item = items[i];
        if (item instanceof GraphNode) {
            GraphNode graphModelNode = (GraphNode) item;
            graphModelNode.unhighlight();
        } else if (item instanceof GraphConnection) {
            GraphConnection graphModelConnection = (GraphConnection) item;
            graphModelConnection.unhighlight();
        }
    }
}
Also used : GraphConnection(org.eclipse.zest.core.widgets.GraphConnection) Widget(org.eclipse.swt.widgets.Widget) GraphNode(org.eclipse.zest.core.widgets.GraphNode) CGraphNode(org.eclipse.zest.core.widgets.CGraphNode)

Example 12 with GraphConnection

use of org.eclipse.zest.core.widgets.GraphConnection 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)

Example 13 with GraphConnection

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

the class AbstractStructuredGraphViewer method reveal.

/**
 */
@Override
public void reveal(Object element) {
    Widget[] items = this.findItems(element);
    for (int i = 0; i < items.length; i++) {
        Widget item = items[i];
        if (item instanceof GraphNode) {
            GraphNode graphModelNode = (GraphNode) item;
            graphModelNode.highlight();
        } else if (item instanceof GraphConnection) {
            GraphConnection graphModelConnection = (GraphConnection) item;
            graphModelConnection.highlight();
        }
    }
}
Also used : GraphConnection(org.eclipse.zest.core.widgets.GraphConnection) Widget(org.eclipse.swt.widgets.Widget) GraphNode(org.eclipse.zest.core.widgets.GraphNode) CGraphNode(org.eclipse.zest.core.widgets.CGraphNode)

Aggregations

GraphConnection (org.eclipse.zest.core.widgets.GraphConnection)13 GraphNode (org.eclipse.zest.core.widgets.GraphNode)10 Iterator (java.util.Iterator)7 CGraphNode (org.eclipse.zest.core.widgets.CGraphNode)6 LinkedList (java.util.LinkedList)4 List (java.util.List)4 ArrayList (java.util.ArrayList)3 Graph (org.eclipse.zest.core.widgets.Graph)3 Widget (org.eclipse.swt.widgets.Widget)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 TreeSet (java.util.TreeSet)1 IFigure (org.eclipse.draw2d.IFigure)1 IColorProvider (org.eclipse.jface.viewers.IColorProvider)1 IFontProvider (org.eclipse.jface.viewers.IFontProvider)1 ILabelProvider (org.eclipse.jface.viewers.ILabelProvider)1 IConnectionStyleProvider (org.eclipse.zest.core.viewers.IConnectionStyleProvider)1 IEntityConnectionStyleProvider (org.eclipse.zest.core.viewers.IEntityConnectionStyleProvider)1 IEntityStyleProvider (org.eclipse.zest.core.viewers.IEntityStyleProvider)1 IFigureProvider (org.eclipse.zest.core.viewers.IFigureProvider)1