@Override public void run(TaskMonitor tm) throws Exception { if (view instanceof DGraphView) { DGraphView dView = (DGraphView) view; CyAnnotator cyAnnotator = dView.getCyAnnotator(); GroupAnnotationImpl group = new GroupAnnotationImpl(cyAnnotator, dView); group.addComponent(null); // Need to add this first so we can update things appropriately cyAnnotator.addAnnotation(group); // Now, add all of the children for (DingAnnotation child : new ArrayList<DingAnnotation>(cyAnnotator.getSelectedAnnotations())) { group.addMember(child); child.setSelected(false); } // Finally, set ourselves to be the selected component group.setSelected(true); group.update(); } }