Java Code Examples for org.netbeans.api.visual.widget.Widget#setLayout()

The following examples show how to use org.netbeans.api.visual.widget.Widget#setLayout() . 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: OutputWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createContent() {
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle());
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);
    
    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));
    buttons.addChild(getExpanderWidget());
    getHeaderWidget().addChild(buttons);
    
    LabelWidget returnWidget = new LabelWidget(getScene(), method.isOneWay()?
        NbBundle.getMessage(OperationWidget.class, "LBL_ReturnTypeNone"):
        NbBundle.getMessage(OperationWidget.class, "LBL_ReturnType", method.getResult().getResultType()));
    returnWidget.setAlignment(LabelWidget.Alignment.CENTER);
    getContentWidget().addChild(returnWidget);
    
}
 
Example 2
Source File: FaultsWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createContent() {
    model = new FaultsTableModel(method);
    populateContentWidget(getContentWidget());
    getContentWidget().setBorder(BorderFactory.createEmptyBorder(0,1,1,1));
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle(), 
            "("+method.getFaults().size()+")");
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);

    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));

    buttons.addChild(getExpanderWidget());

    getHeaderWidget().addChild(buttons);
}
 
Example 3
Source File: ParametersWidget.java    From netbeans with Apache License 2.0 6 votes vote down vote up
private void createContent() {
    model = new ParametersTableModel(method, nameEditable);
    populateContentWidget(getContentWidget());
    getContentWidget().setBorder(BorderFactory.createEmptyBorder(0,1,1,1));
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle(), 
            "("+method.getParams().size()+")");
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);

    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));

    buttons.addChild(getExpanderWidget());
    buttons.setOpaque(true);
    buttons.setBackground(TITLE_COLOR_BRIGHT);

    getHeaderWidget().addChild(buttons);

}
 
Example 4
Source File: FlowLayout105400Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFlowLayoutInsets () {
    Scene scene = new Scene ();
    Widget parent = new Widget (scene);
    parent.setBorder (BorderFactory.createResizeBorder (10));
    parent.setLayout (LayoutFactory.createVerticalFlowLayout ());
    scene.addChild (parent);

    Widget child = new Widget (scene);
    child.setBackground (Color.BLUE);
    child.setOpaque (true);
    child.setPreferredBounds (new Rectangle (-50, -30, 30, 20));
    parent.addChild (child);

    assertScene (scene, Color.WHITE, new Rectangle (-1, -1, 52, 42));
}
 
Example 5
Source File: FlowLayoutWeightOverflow108052Test.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void testFlowLayoutWeightOverflow () {
    Scene scene = new Scene ();
    LayerWidget layer = new LayerWidget (scene);
    layer.setMinimumSize (new Dimension (300, 200));
    scene.addChild (layer);

    Widget vbox = new Widget (scene);
    vbox.setBorder (BorderFactory.createLineBorder (1, Color.BLACK));
    vbox.setLayout (LayoutFactory.createVerticalFlowLayout (LayoutFactory.SerialAlignment.JUSTIFY, 0));
    layer.addChild (vbox);

    Widget hbox1 = new Widget (scene);
    hbox1.setBorder (BorderFactory.createLineBorder (1, Color.BLUE));
    hbox1.setLayout (LayoutFactory.createHorizontalFlowLayout ());
    vbox.addChild (hbox1);

    Widget item1 = new LabelWidget (scene, "Item1");
    item1.setBorder (BorderFactory.createLineBorder (1, Color.GREEN));
    hbox1.addChild (item1);

    Widget item2 = new LabelWidget (scene, "Item2");
    item2.setBorder (BorderFactory.createLineBorder (1, Color.YELLOW));
    hbox1.addChild (item2, 1000);

    Widget item3 = new LabelWidget (scene, "Item3");
    item3.setBorder (BorderFactory.createLineBorder (1, Color.RED));
    hbox1.addChild (item3);

    Widget hbox2 = new Widget (scene);
    hbox2.setBorder (BorderFactory.createLineBorder (1, Color.BLUE));
    hbox2.setPreferredSize (new Dimension (200, 20));
    vbox.addChild (hbox2);
    
    Color color = (Color) (new DefaultLookFeel()).getBackground();
    assertScene (scene, color, new Rectangle (-5, -5, 210, 100));
}
 
Example 6
Source File: WsitWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createContent() {
    headerLabelWidget = new ImageLabelWidget(getScene(), null,
            NbBundle.getMessage(WsitWidget.class, "LBL_Wsit"));
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),1);
    
    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, 8));
    
    buttons.addChild(getExpanderWidget());
    
    getHeaderWidget().addChild(buttons);

    getContentWidget().setBorder(BorderFactory.createEmptyBorder(RADIUS));

    configButtons = new Widget(getScene());
    configButtons.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.LEFT_TOP, RADIUS));
    getContentWidget().addChild(configButtons);
    populateConfigWidget();

    Widget advancedButtonContainer = new Widget(getScene());
    advancedButtonContainer.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.RIGHT_BOTTOM, RADIUS));
    advancedButton = new ButtonWidget(getScene(),
            new AdvancedAction(service,implementationClass));
    advancedButton.setOpaque(true);
    advancedButton.setRoundedBorder(ButtonWidget.BORDER_RADIUS, 4, 0, null);
    advancedButtonContainer.addChild(advancedButton);
    getContentWidget().addChild(advancedButtonContainer);
}
 
Example 7
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 8
Source File: AbstractTitledWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected final Widget createContentWidget() {
    Widget widget = new Widget(getScene());
    widget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, cgap));
    widget.setBorder(BorderFactory.createEmptyBorder(cgap));
    return widget;
}
 
Example 9
Source File: TabbedPaneWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
/**
 *
 * @param scene
 */
public TabbedPaneWidget(Scene scene) {
    super(scene);
    setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.JUSTIFY, 1));
    tabs = new Widget(scene);
    addChild(tabs);
    contentWidget = new Widget(scene);
    contentWidget.setLayout(LayoutFactory.createOverlayLayout());
    contentWidget.setBorder(javax.swing.BorderFactory.createMatteBorder(0, 1, 1, 1, TAB_BORDER_COLOR));
    addChild(contentWidget);
}
 
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: DescriptionWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createContent() {
    populateContentWidget(getContentWidget());
    headerLabelWidget = new ImageLabelWidget(getScene(), getIcon(), getTitle());
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(new Widget(getScene()),5);
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),4);
    
    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));
    buttons.addChild(getExpanderWidget());
    getHeaderWidget().addChild(buttons);
}
 
Example 12
Source File: OperationsWidget.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void createContent(ProjectService service) {
    if (serviceModel==null) {
        return;
    }
    
    headerLabelWidget = new ImageLabelWidget(getScene(), null,
            NbBundle.getMessage(OperationWidget.class, "LBL_Operations"));
    headerLabelWidget.setLabelFont(getScene().getFont().deriveFont(Font.BOLD));
    getHeaderWidget().addChild(headerLabelWidget);
    getHeaderWidget().addChild(new Widget(getScene()),1);
    updateHeaderLabel();
    
    buttons = new Widget(getScene());
    buttons.setLayout(LayoutFactory.createHorizontalFlowLayout(
            LayoutFactory.SerialAlignment.CENTER, 8));
    
    ButtonWidget addButton = new ButtonWidget(getScene(), addAction);
    addButton.setOpaque(true);
    addButton.setRoundedBorder(addButton.BORDER_RADIUS, 4, 0, null);
    
    removeAction = new RemoveOperationAction(service);
    ButtonWidget removeButton = new ButtonWidget(getScene(), removeAction);
    removeButton.setOpaque(true);
    removeButton.setRoundedBorder(removeButton.BORDER_RADIUS, 4, 0, null);
    
    buttons.addChild(addButton);
    buttons.addChild(removeButton);
    buttons.addChild(getExpanderWidget());
    
    getHeaderWidget().addChild(buttons);
    
    getContentWidget().setBorder(BorderFactory.createEmptyBorder(RADIUS));
    if(serviceModel.getOperations()!=null) {
        for(MethodModel operation:serviceModel.getOperations()) {
            OperationWidget operationWidget = new OperationWidget(getObjectScene(), 
                    serviceModel, service, operation);
            getContentWidget().addChild(operationWidget);
        }
    }
}
 
Example 13
Source File: NodeWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
@Messages("ACT_FixVersionConflict=Fix Version Conflict...")
private void initContent (DependencyGraphScene scene, GraphNodeImplementation impl, Icon icon) {
    contentW = new LevelOfDetailsWidget(scene, 0.05, 0.1, Double.MAX_VALUE, Double.MAX_VALUE);
    contentW.setBorder(BorderFactory.createLineBorder(10));
    contentW.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.JUSTIFY, 1));

    //Artifact name (with optional project icon on the left)
    nodeW = new IconNodeWidget(scene, TextOrientation.RIGHT_CENTER);
    nodeW.setLabel(node.getImpl().getQualifiedName() + "  ");

    if (null != icon) {
        nodeW.setImage(ImageUtilities.icon2Image(icon));
    }

    nodeW.getLabelWidget().setUseGlyphVector(true);

    if (node.isRoot()) {
        Font defF = scene.getDefaultFont();
        nodeW.getLabelWidget().setFont(defF.deriveFont(Font.BOLD, defF.getSize() + 3f));
    }
    contentW.addChild(nodeW);
    
    if(getDependencyGraphScene().supportsVersions()) {
        Widget versionDetW = new LevelOfDetailsWidget(scene, 0.5, 0.7, Double.MAX_VALUE, Double.MAX_VALUE);
        versionDetW.setLayout(LayoutFactory.createHorizontalFlowLayout(LayoutFactory.SerialAlignment.CENTER, 2));
        contentW.addChild(versionDetW);
        versionW = new LabelWidget(scene);
        versionW.setLabel(scene.getVersion(node.getImpl()));
        versionW.setUseGlyphVector(true);
        int mngState = node.getManagedState();
        if (mngState != GraphNode.UNMANAGED) { 
             lockW = new ImageWidget(scene,
                    mngState == GraphNode.MANAGED ? ImageUtilities.loadImage(LOCK_ICON) : ImageUtilities.loadImage(LOCK_BROKEN_ICON));
        }
        versionDetW.addChild(versionW);
        if (lockW != null) {
            versionDetW.addChild(lockW);
        }
    }

    // fix hint
    if (fixConflictAction != null) {
        Widget rootW = new Widget(scene);
        rootW.setLayout(LayoutFactory.createOverlayLayout());
        fixHintW = new ImageWidget(scene, ImageUtilities.loadImage(BULB_ICON));
        fixHintW.setVisible(false);
        fixHintW.setToolTipText(ACT_FixVersionConflict());
        fixHintW.getActions().addAction(sceneHoverActionAction);
        fixHintW.getActions().addAction(fixConflictAction);
        Widget panelW = new Widget(scene);
        panelW.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.LEFT_TOP, 0));
        panelW.setBorder(BorderFactory.createEmptyBorder(0, 3));
        panelW.addChild(fixHintW);
        rootW.addChild(panelW);
        rootW.addChild(contentW);
        addChild(rootW);
    } else {
        addChild(contentW);
    }

}
 
Example 14
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 15
Source File: AbstractTitledWidget.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected final Widget createHeaderWidget() {
    Widget widget = new Widget(getScene());
    widget.setLayout(LayoutFactory.createVerticalFlowLayout(
            LayoutFactory.SerialAlignment.JUSTIFY, radius));
    return widget;
}