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);
}
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()]);
}
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;
}
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);
}
}
Aggregations