org.netbeans.api.visual.model.ObjectScene Java Examples

The following examples show how to use org.netbeans.api.visual.model.ObjectScene. 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: GraphBiLayout.java    From Llunatic with GNU General Public License v3.0 6 votes vote down vote up
private List<GraphLocation> createRelativeLocations(ObjectScene scene, List<GraphNode> nodes, Align align) {
    List<GraphLocation> widgetLocations = new ArrayList<GraphLocation>();
    int startY = 0;
    for (GraphNode node : nodes) {
        Widget widget = scene.findWidget(node);
        if (widget == null) {
            continue;
        }
        Rectangle bounds = widget.getBounds();
        if (bounds == null) {
            continue;
        }
        int startX = 0;
        if ( align == Align.RIGHT){
            startX = -bounds.width;
        }
        widgetLocations.add(new GraphLocation(node, startX, startY,bounds));
        startY += bounds.height + verticalGap;
        
    }
    return widgetLocations;
}
 
Example #2
Source File: TableWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
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 #3
Source File: OperationWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Creates a new instance of OperationWidget
 * @param scene
 * @param operation
 */
public OperationWidget(ObjectScene scene, ServiceModel serviceModel, 
        ProjectService service, MethodModel operation) 
{
    super(scene,RADIUS,RADIUS,RADIUS/2,BORDER_COLOR);
    this.service = service;
    this.operation=operation;
    this.serviceModel = serviceModel;
    
    removeAction = new RemoveOperationAction(service);
    removeAction.setWorkingSet(Collections.singleton(operation));
    getActions().addAction(ActionFactory.createPopupMenuAction(
            new DesignViewPopupProvider(new Action [] {
        new GotoSourceAction(operation, serviceModel.getImplementationClass()),
        removeAction
    })));
    createContent();
}
 
Example #4
Source File: WsitWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
public void propertyChange(PropertyChangeEvent evt) {
    Object source = evt.getSource();
    ObjectScene scene = (ObjectScene) widget.getScene();
    String property = evt.getPropertyName();
    Object newValue = evt.getNewValue();
    if(source instanceof WSConfiguration) {
        Widget configWidget = scene.findWidget(source);
        if(WSConfiguration.PROPERTY.equals(property)) {
            if(configWidget instanceof CheckBoxWidget) {
                ((CheckBoxWidget)configWidget).setSelected((Boolean)newValue);
                scene.validate();
                widget.revalidate(true);
            }
        } else if(WSConfiguration.PROPERTY_ENABLE.equals(property)) {
            if(configWidget instanceof CheckBoxWidget) {
                ((CheckBoxWidget)configWidget).setVisible((Boolean)newValue);
                widget.determineVisibility();
                widget.revalidate();
            }
        }

    }
}
 
Example #5
Source File: GraphLayout.java    From netbeans with Apache License 2.0 6 votes vote down vote up
/**
 * Should be called to set a new resolved preferred location of a node.
 * @param graph the universal graph
 * @param node the node with resolved location
 * @param newPreferredLocation the new resolved location
 */
protected final void setResolvedNodeLocation (UniversalGraph<N,E> graph, N node, Point newPreferredLocation) {
    ObjectScene scene = graph.getScene ();

    Widget widget = scene.findWidget (node);
    if (widget == null)
        return;

    Point previousPreferredLocation = widget.getPreferredLocation ();

    if (animated)
        scene.getSceneAnimator ().animatePreferredLocation (widget, newPreferredLocation);
    else
        widget.setPreferredLocation (newPreferredLocation);

    GraphLayoutListener<N,E>[] listeners = createListenersCopy ();

    for (GraphLayoutListener<N,E> listener : listeners)
        listener.nodeLocationChanged (graph, node, previousPreferredLocation, newPreferredLocation);
}
 
Example #6
Source File: ParametersWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 
 * Creates a new instance of OperationWidget 
 * @param scene 
 * @param method 
 */
public ParametersWidget(ObjectScene scene, MethodModel method, boolean nameEditable) {
    super(scene,0,RADIUS,0,BORDER_COLOR);
    this.method = method;
    this.nameEditable = nameEditable;
    createContent();
}
 
Example #7
Source File: DesignerWidgetIdentityCode.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * 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 #8
Source File: WsitWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new instance of OperationWidget
 * @param scene
 * @param service
 * @param serviceModel
 */
public WsitWidget(ObjectScene scene, final Service service, 
        FileObject implementationClass, 
        Collection<WSConfiguration> wsConfigurations ) 
{
    super(scene,RADIUS,BORDER_COLOR);
    this.implementationClass = implementationClass;
    this.service=service;
    configurations = wsConfigurations;
    setOpaque(true);
    setBackground(TITLE_COLOR_PARAMETER);
    configListener = new WSConfigurationListener(this);
    createContent();
}
 
Example #9
Source File: DescriptionWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** Creates a new instance of Description
 * @param scene
 * @param method
 */
public DescriptionWidget(ObjectScene scene, MethodModel method) {
    super(scene,0,RADIUS,1,BORDER_COLOR);
    this.method = method;
    model = method.getJavadoc();
    listener = new DescriptionListener();
    createContent();
}
 
Example #10
Source File: SampleMessageWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/** 
 * Creates a new instance of SampleMessageWidget 
 * @param scene 
 * @param operation 
 * @param type 
 */
public SampleMessageWidget(ObjectScene scene, MethodModel operation, Type type) {
    super(scene,0,12,0,TITLE_COLOR);
    this.operation = operation;
    this.type = type;

    headerLabelWidget = new ImageLabelWidget(scene, null, operation.getOperationName()+": ",type.getTitle());
    headerLabelWidget.setLabelFont(scene.getFont().deriveFont(Font.BOLD));
    headerLabelWidget.setPaintAsDisabled(false);
    headerLabelWidget.setLabelForeground(type.getBorderColor());
    getHeaderWidget().addChild(new Widget(getScene()),1);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),1);

    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 8));
    getHeaderWidget().addChild(buttons);
    final ButtonWidget closeButton = new ButtonWidget(getScene(), (String)null);
    closeButton.setImage(new ExpanderImageWidget(scene,type.getBorderColor(),8));
    closeButton.setRoundedBorder(0, 4, 4,type.getBorderColor());
    closeButton.setAction(new AbstractAction() {
        public void actionPerformed(ActionEvent arg0) {
            SampleMessageWidget.this.removeFromParent();
        }
    });
    buttons.addChild(closeButton);

    paneWidget = new EditorPaneWidget(scene, 
            Utils.getFormatedDocument(type.getMessage(operation)),"text/xml");
    paneWidget.setEditable(false);
    getContentWidget().addChild(paneWidget);
    getContentWidget().setBorder(BorderFactory.createEmptyBorder(12, 6));
}
 
Example #11
Source File: AbstractTitledWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
     * Creates a new instance of RoundedRectangleWidget
     * with default rounded radius and gap and no gradient color
     * @param scene scene this widget belongs to
     * @param radius of the rounded arc
     * @param gap for header widget
     * @param gap for content widget
     * @param color color of the border and gradient title
     */
    public AbstractTitledWidget(ObjectScene scene, int radius, int hgap, int cgap, Color color) {
        super(scene);
        this.radius = radius;
        this.borderColor = color;
        //this.hgap = hgap;
        this.cgap = cgap;
        depth = radius/3;
        setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.JUSTIFY, 0));
        setBorder(new RoundedBorder3D(this,radius, depth, 0, 0, borderColor));
        headerWidget = new Widget(getScene());
        headerWidget.setBorder(BorderFactory.createEmptyBorder(hgap, hgap/2));
        headerWidget.setLayout(LayoutFactory.createHorizontalFlowLayout(LayoutFactory.SerialAlignment.CENTER, hgap));
//        headerWidget.setLayout(new BorderLayout(headerWidget));
        addChild(headerWidget);
        seperatorWidget = new SeparatorWidget(getScene(),SeparatorWidget.Orientation.HORIZONTAL);
        seperatorWidget.setForeground(borderColor);
        if(isExpandable()) {
            contentWidget = createContentWidget();
            expanded = ExpanderWidget.isExpanded(this, true);
            if(expanded) {
                expandWidget();
            } else {
                collapseWidget();
            }
            expander = new ExpanderWidget(getScene(), this, expanded);
        }
        getActions().addAction(scene.createSelectAction());
    }
 
Example #12
Source File: TableWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
RowWidget(Scene scene, int columns, Object userObject) {
    super(scene);
    setLayout(new TableLayout(columns, 0, 0,COLUMN_WIDTH));
    this.userObject = userObject;
    if(getScene() instanceof ObjectScene && userObject!=null) {
        getActions().addAction(((ObjectScene) getScene()).createSelectAction());
        setBorder(new LineBorder(1,0,0,0,BORDER_COLOR));
    }
}
 
Example #13
Source File: TableWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
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()]));
        }
    }
}
 
Example #14
Source File: ButtonWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void notifyAdded() {
    super.notifyAdded();
    Scene scene = getScene();
    if(scene instanceof ObjectScene) {
        ObjectScene objectScene = (ObjectScene)scene;
        objectScene.addObject(hashKey(), this);
    }
}
 
Example #15
Source File: ButtonWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
protected void notifyRemoved() {
    super.notifyRemoved();
    Scene scene = getScene();
    if(scene instanceof ObjectScene) {
        ((ObjectScene)scene).removeObject(hashKey());
    }
}
 
Example #16
Source File: FlushableWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FlushableWidget(ObjectScene scene, int radius, int hgap, int cgap, Color color) {
    super(scene,radius,hgap, cgap , color);
}
 
Example #17
Source File: FlushableWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public FlushableWidget(ObjectScene scene, int radius, Color color) {
    super(scene,radius,color);
}
 
Example #18
Source File: Highlighter.java    From jlibs with Apache License 2.0 4 votes vote down vote up
private Widget resolve(Widget widget){
    ObjectScene scene = (ObjectScene)widget.getScene();
    return scene.findWidget(scene.findObject(widget));
}
 
Example #19
Source File: FaultsWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/** 
 * Creates a new instance of OperationWidget 
 * @param scene
 * @param method  
 */
public FaultsWidget(ObjectScene scene, MethodModel method) {
    super(scene,0,RADIUS,0,BORDER_COLOR);
    this.method = method;
    createContent();
}
 
Example #20
Source File: Util.java    From jlibs with Apache License 2.0 4 votes vote down vote up
public static Object model(Widget widget){
    return ((ObjectScene)widget.getScene()).findObject(widget);
}
 
Example #21
Source File: AbstractTitledWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected ObjectScene getObjectScene() {
    return (ObjectScene)super.getScene();
}
 
Example #22
Source File: CycleObjectSceneFocusProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public boolean switchPreviousFocus (Widget widget) {
    Scene scene = widget.getScene ();
    return scene instanceof ObjectScene  &&  switchFocus ((ObjectScene) scene, false);
}
 
Example #23
Source File: OutputWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of OperationWidget
 * @param scene
 * @param method
 */
public OutputWidget(ObjectScene scene, MethodModel method) {
    super(scene,0,RADIUS,0,BORDER_COLOR);
    this.method = method;
    createContent();
}
 
Example #24
Source File: DesignView.java    From netbeans with Apache License 2.0 4 votes vote down vote up
/**
 * Creates a new instance of GraphView.
 * @param service
 * @param implementationClass
 */
public DesignView(ProjectService service, FileObject implementationClass) {
    super(new BorderLayout());
    
    this.service = service;
    this.implementationClass = implementationClass;
    
    scene = new ObjectScene() {
        @Override
        /**
         * Use our own traversal policy
         */
        public Comparable<DesignerWidgetIdentityCode> getIdentityCode(Object object) {
            return new DesignerWidgetIdentityCode(scene,object);
        }
    };
    zoomer = new ZoomManager(scene);

    scene.getActions().addAction(ActionFactory.createCycleObjectSceneFocusAction());
    scene.setKeyEventProcessingType (EventProcessingType.FOCUSED_WIDGET_AND_ITS_PARENTS);

    mainLayer = new LayerWidget(scene);
    mainLayer.setPreferredLocation(new Point(0, 0));
    mainLayer.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 12));
    scene.addChild(mainLayer);
    
    mainWidget = new Widget(scene);
    mainWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 12));
    
    headerWidget = new LabelWidget(scene);
    headerWidget.setFont(scene.getFont().deriveFont(Font.BOLD));
    headerWidget.setForeground(Color.GRAY);
    headerWidget.setBorder(BorderFactory.createEmptyBorder(6,28,0,0));
    mainWidget.addChild(headerWidget);
    
    separatorWidget = new SeparatorWidget(scene,
            SeparatorWidget.Orientation.HORIZONTAL);
    separatorWidget.setForeground(Color.ORANGE);
    mainWidget.addChild(separatorWidget);
    
    contentWidget = new Widget(scene);
    contentWidget.setBorder(BorderFactory.createEmptyBorder(0, 20, 0, 20));
    contentWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 16));
    mainWidget.addChild(contentWidget);
    
    JPanel panel = new JPanel(new FlowLayout(FlowLayout.CENTER){
        /* (non-Javadoc)
         * @see java.awt.FlowLayout#layoutContainer(java.awt.Container)
         */
        @Override
        public void layoutContainer( Container target ) {
            super.layoutContainer(target);
            Component[] components = target.getComponents();
            double height = target.getSize().getHeight()/2;
            for (Component component : components) {
                Point location = component.getLocation();
                component.setLocation( (int)location.getX(), (int)height );
            }
        }
    });
    panel.add(new JLabel(NbBundle.getMessage( DesignView.class, "LBL_Wait")));
    add( panel,BorderLayout.CENTER);
    
    mainLayer.addChild(mainWidget);

    messageWidget = new Widget(scene);
    messageWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 4));
    mainLayer.addChild(messageWidget);
    scene.addObject(messageLayerKey, messageWidget);
    
    initServiceModel();
}
 
Example #25
Source File: DesignerWidgetIdentityCode.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public DesignerWidgetIdentityCode(ObjectScene scene, Object object) {
    this.scene = scene;
    this.object = object;
}
 
Example #26
Source File: ObjectSceneRectangularSelectProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public ObjectSceneRectangularSelectProvider (ObjectScene scene) {
    this.scene = scene;
}
 
Example #27
Source File: CycleObjectSceneFocusProvider.java    From netbeans with Apache License 2.0 4 votes vote down vote up
public boolean switchNextFocus (Widget widget) {
    Scene scene = widget.getScene ();
    return scene instanceof ObjectScene  &&  switchFocus ((ObjectScene) scene, true);
}
 
Example #28
Source File: AbstractTitledWidget.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a new instance of RoundedRectangleWidget
 * with default rounded radius and gap and no gradient color
 * @param scene scene this widget belongs to
 * @param radius of the rounded arc
 * @param color color of the border and gradient title
 */
public AbstractTitledWidget(ObjectScene scene, int radius, Color color) {
    this(scene,radius,radius,radius,color);
}
 
Example #29
Source File: UniversalGraph.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Returns a related scene as a ObjectScene.
 * @return the related scene which is represented by the universal graph.
 */
public abstract ObjectScene getScene ();
 
Example #30
Source File: ActionFactory.java    From netbeans with Apache License 2.0 2 votes vote down vote up
/**
 * Creates a rectangular select provider which controls a selection of an object scene.
 * @param scene the object scene where an action is used
 * @return the rectangular select provider
 */
public static RectangularSelectProvider createObjectSceneRectangularSelectProvider (ObjectScene scene) {
    assert scene != null;
    return new ObjectSceneRectangularSelectProvider (scene);
}