private void testWith(IGraphContentProvider contentProvider) { viewer.setContentProvider(contentProvider); viewer.setLabelProvider(new CustomLabelProvider()); viewer.setInput(new Object()); StringBuffer buffer = new StringBuffer(); for (int i = 0; i < viewer.getGraphControl().getNodes().size(); i++) { CGraphNode n = (CGraphNode) viewer.getGraphControl().getNodes().get(i); buffer.append(((Label) n.getNodeFigure().getChildren().get(0)).getText()); } String string = buffer.toString(); assertTrue("Label 1 should be in figure labels", string.indexOf("1") >= 0); assertTrue("Label 2 should be in figure labels", string.indexOf("2") >= 0); assertTrue("Label 3 should be in figure labels", string.indexOf("3") >= 0); }
@SuppressWarnings("restriction") private void updateViewer(ModelManagerEvent event) { // Use the setRedraw method to reduce flicker // when adding or removing multiple items in a table. viewer.getGraphControl().setRedraw(false); try { for (IChange change : event.getNewChanges()) { viewer.addNode((Change) change); } } finally { viewer.getGraphControl().setRedraw(true); viewer.refresh(); viewer.applyLayout(); } }