Java Code Examples for org.netbeans.api.visual.model.ObjectScene#findWidgets()
The following examples show how to use
org.netbeans.api.visual.model.ObjectScene#findWidgets() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: TableWidget.java From netbeans with Apache License 2.0 | 6 votes |
protected void notifyRemoved() { super.notifyRemoved(); if(getScene() instanceof ObjectScene && userObject!=null) { ObjectScene scene =(ObjectScene) getScene(); List<Widget> widgets = scene.findWidgets(userObject); if(widgets!=null && widgets.contains(this)) { if(widgets.size()==1) scene.removeObject(userObject); else { widgets = new ArrayList<Widget>(widgets); widgets.remove(this); scene.removeObject(userObject); scene.addObject(userObject, widgets.toArray(new Widget[widgets.size()])); } } } }
Example 2
Source File: DesignerWidgetIdentityCode.java From netbeans with Apache License 2.0 | 5 votes |
/** * Returns the index of visible widget represented by given object using depth first search. * Integer.MAX_VALUE if none found. */ private static int getIdentityCode(ObjectScene scene, Object object) { List<Widget> widgets = scene.findWidgets(object); Widget w = null; ArrayList<Widget> pathToRoot = new ArrayList<Widget>(); if(widgets!=null) { for(Widget w1:widgets) { pathToRoot = new ArrayList<Widget>(); if(!w1.isVisible()) continue; Widget parent = w1.getParentWidget(); while(parent!=null && parent.isVisible()) { pathToRoot.add(0,parent); parent = parent.getParentWidget(); } if(!pathToRoot.isEmpty()&&pathToRoot.get(0)==scene) { w = w1; pathToRoot.add(w); break; } } } if(w==null) return Integer.MAX_VALUE; int code = 0; for(int i=0;i<pathToRoot.size();) { Widget widgetOnPath=pathToRoot.get(i++); code++; if(i == pathToRoot.size()) break; int nextWidgetOnPathIndex = widgetOnPath.getChildren().indexOf(pathToRoot.get(i)); for(int j=0;j<nextWidgetOnPathIndex;j++) { code+=getTreeSize(widgetOnPath.getChildren().get(j)); } } return code; }
Example 3
Source File: TableWidget.java From netbeans with Apache License 2.0 | 5 votes |
protected void notifyAdded() { super.notifyAdded(); if(getScene() instanceof ObjectScene && userObject!=null) { ObjectScene scene =(ObjectScene) getScene(); List<Widget> widgets = scene.findWidgets(userObject); if(widgets==null|| widgets.isEmpty()) scene.addObject(userObject, this); else { scene.removeObject(userObject); widgets = new ArrayList<Widget>(widgets); widgets.add(this); scene.addObject(userObject, widgets.toArray(new Widget[widgets.size()])); } } }