Package nextapp.echo2.app

Examples of nextapp.echo2.app.Row


       
        ButtonColumn controlsColumn = new ButtonColumn();
        controlsColumn.setStyleName("TestControlsColumn");
        add(controlsColumn);

        final Row testRow = new Row();
        testRow.setBorder(new Border(new Extent(1), Color.BLUE, Border.STYLE_SOLID));
        testRow.setLayoutData(insetLayoutData);
        add(testRow);
       
        controlsColumn.addButton("Add Item (at beginning)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.add(new Label("Added item [" + nextValue++ + "]"), 0);
            }
        });
        controlsColumn.addButton("Add Item (at end)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.add(new Label("Added item [" + nextValue++ + "]"));
            }
        });
        controlsColumn.addButton("Add-Remove-Add Item (at end)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Label label = new Label("Added item [" + nextValue++ + "]");
                testRow.add(label);
                testRow.remove(label);
                testRow.add(label);
            }
        });
        controlsColumn.addButton("Remove Last Item", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (testRow.getComponentCount() > 0) {
                    testRow.remove(testRow.getComponentCount() - 1);
                }
            }
        });
        controlsColumn.addButton("Add Some Items, Remove Some Items", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int count = 1 + ((int) (Math.random() * 10));
                for (int i = 0; i < count; ++i) {
                    int componentCount = testRow.getComponentCount();
                    if (componentCount > 0 && ((int) (Math.random() * 2)) == 0) {
                        // Perform remove.
                        int position = (int) (Math.random() * componentCount);
                        testRow.remove(position);
                    } else {
                        // Perform add.
                        int position = (int) (Math.random() * (componentCount + 1));
                        testRow.add(new Label("Added item [" + nextValue++ + "]"), position);
                    }
                }
            }
        });
        controlsColumn.addButton("Randomly Remove and Re-insert Item", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int itemCount = testRow.getComponentCount();
                if (itemCount == 0) {
                    return;
                }
                Component item = testRow.getComponent((int) (Math.random() * itemCount));
                testRow.remove(item);
                testRow.add(item, (int) (Math.random() * (itemCount - 1)));
            }
        });
        controlsColumn.addButton("Set Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setForeground(StyleUtil.randomColor());
            }
        });
        controlsColumn.addButton("Clear Foreground", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setForeground(null);
            }
        });
        controlsColumn.addButton("Set Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBackground(StyleUtil.randomColor());
            }
        });
        controlsColumn.addButton("Clear Background", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBackground(null);
            }
        });
        controlsColumn.addButton("Set Border (All Attributes)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBorder(StyleUtil.randomBorder());
            }
        });
        controlsColumn.addButton("Set Border Color", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                Border border = testRow.getBorder();
                if (border == null) {
                    border = new Border(new Extent(1), Color.BLUE, Border.STYLE_SOLID);
                }
                testRow.setBorder(new Border(border.getSize(), StyleUtil.randomColor(), border.getStyle()));
            }
        });
        controlsColumn.addButton("Set Border Size", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBorder(StyleUtil.nextBorderSize(testRow.getBorder()));
            }
        });
        controlsColumn.addButton("Set Border Style", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBorder(StyleUtil.nextBorderStyle(testRow.getBorder()));
            }
        });
        controlsColumn.addButton("Remove Border", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setBorder(null);
            }
        });
        controlsColumn.addButton("Cell Spacing -> 0px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setCellSpacing(new Extent(0, Extent.PX));
            }
        });
        controlsColumn.addButton("Cell Spacing -> 2px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setCellSpacing(new Extent(2, Extent.PX));
            }
        });
        controlsColumn.addButton("Cell Spacing -> 20px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setCellSpacing(new Extent(20, Extent.PX));
            }
        });
        controlsColumn.addButton("Insets -> null", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setInsets(null);
            }
        });
        controlsColumn.addButton("Insets -> 0px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setInsets(new Insets(0));
            }
        });
        controlsColumn.addButton("Insets -> 5px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setInsets(new Insets(5));
            }
        });
        controlsColumn.addButton("Insets -> 10/20/30/40px", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.setInsets(new Insets(10, 20, 30, 40));
            }
        });
        controlsColumn.addButton("Alignment -> Leading", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.LEADING, Alignment.DEFAULT));
            }
        });
        controlsColumn.addButton("Alignment -> Trailing", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.TRAILING, Alignment.DEFAULT));
            }
        });
        controlsColumn.addButton("Alignment -> Left", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
            }
        });
        controlsColumn.addButton("Alignment -> Center", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.CENTER, Alignment.DEFAULT));
            }
        });
        controlsColumn.addButton("Alignment -> Right", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.RIGHT, Alignment.DEFAULT));
            }
        });
        controlsColumn.addButton("Alignment -> Default", new ActionListener(){
            public void actionPerformed(ActionEvent e) {
                testRow.setAlignment(new Alignment(Alignment.DEFAULT, Alignment.DEFAULT));
            }
        });
       
        controlsColumn.addButton("Clear All LayoutData", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int componentCount = testRow.getComponentCount();
                for (int i = 0; i < componentCount; ++i) {
                    testRow.getComponent(i).setLayoutData(null);
                }
            }
        });

        controlsColumn.addButton("Set Layout Data of All Items to 100%/count Width", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int componentCount = testRow.getComponentCount();
                for (int i = 0; i < componentCount; ++i) {
                    RowLayoutData rowLayoutData = new RowLayoutData();
                    rowLayoutData.setWidth(new Extent(100 / componentCount, Extent.PERCENT));
                    rowLayoutData.setBackground(StyleUtil.randomBrightColor());
                    testRow.getComponent(i).setLayoutData(rowLayoutData);
                }
            }
        });
       
        controlsColumn.addButton("Set Layout Data (of random item)", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                int componentCount = testRow.getComponentCount();
                if (componentCount == 0) {
                    return;
                }
                Component component =  testRow.getComponent((int) (Math.random() * componentCount));
                RowLayoutData rowLayoutData = new RowLayoutData();
                rowLayoutData.setAlignment(StyleUtil.randomAlignmentHV());
                rowLayoutData.setBackground(StyleUtil.randomBrightColor());
                rowLayoutData.setInsets(new Insets((int) (Math.random() * 30)));
                switch((int) (Math.random() * 7)) {
                case 0:
                     rowLayoutData.setBackgroundImage(Styles.BG_SHADOW_DARK_BLUE);
                     break;
                case 1:
                     rowLayoutData.setBackgroundImage(Styles.BG_SHADOW_LIGHT_BLUE);
                     break;
                default:
                     rowLayoutData.setBackgroundImage(null);
                }
               
                component.setLayoutData(rowLayoutData);
            }
        });
        controlsColumn.addButton("Add Item, Randomize Column Insets", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                testRow.add(new Label("Added item [" + nextValue++ + "]"));
                testRow.setInsets(new Insets((int) (Math.random() * 50)));
            }
        });
        controlsColumn.addButton("Toggle Test Inset", new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                if (testRow.getLayoutData() == null) {
                    testRow.setLayoutData(insetLayoutData);
                } else {
                    testRow.setLayoutData(null);
                }
            }
        });
    }
View Full Code Here


     * @param rc the relevant <code>RenderContext</code>
     * @param update the update
     */
    private void renderAddChildren(RenderContext rc, ServerComponentUpdate update) {
        Element domAddElement = DomUpdate.renderElementAdd(rc.getServerMessage());
        Row row = (Row) update.getParent();
        String elementId = ContainerInstance.getElementId(row);
        String trElementId = elementId + "_tr";
       
        Component[] components = update.getParent().getVisibleComponents();
        Component[] addedChildren = update.getAddedChildren();
       
        for (int componentIndex = components.length - 1; componentIndex >= 0; --componentIndex) {
            boolean childFound = false;
            for (int addedChildrenIndex = 0; !childFound && addedChildrenIndex < addedChildren.length; ++addedChildrenIndex) {
                if (addedChildren[addedChildrenIndex] == components[componentIndex]) {
                    DocumentFragment htmlFragment = rc.getServerMessage().getDocument().createDocumentFragment();
                    renderChild(rc, update, htmlFragment, row, components[componentIndex]);
                    if (componentIndex == components.length - 1) {
                        DomUpdate.renderElementAddContent(rc.getServerMessage(), domAddElement, trElementId, htmlFragment);
                    } else {
                        DomUpdate.renderElementAddContent(rc.getServerMessage(), domAddElement, trElementId,
                                elementId + "_cell_" + ContainerInstance.getElementId(components[componentIndex + 1]),
                                htmlFragment);
                    }
                    childFound = true;
                }
            }
        }
       
        // Special case: Recall the child which was rendered at the last index of the row on the previous
        // rendering.  If this child is still present but is no longer at the last index, render a spacing
        // cell after it (if necessary).
        RowPeerRenderState renderState = (RowPeerRenderState) rc.getContainerInstance().getRenderState(row);
        if (renderState != null && renderState.lastChild != null) {
            int previousLastChildIndex = row.visibleIndexOf(renderState.lastChild);
            if (previousLastChildIndex != -1 && previousLastChildIndex != row.getVisibleComponentCount() - 1) {
                // At this point it is known that the child which was previously last is present, but is no longer last.

                // In the event the child was removed and re-added, the special case is unnecessary.
                boolean lastChildMoved = false;
                for (int i = 0; i < addedChildren.length; ++i) {
View Full Code Here

    /**
     * @see nextapp.echo2.webcontainer.DomUpdateSupport#renderHtml(nextapp.echo2.webcontainer.RenderContext,
     *      nextapp.echo2.app.update.ServerComponentUpdate, org.w3c.dom.Node, nextapp.echo2.app.Component)
     */
    public void renderHtml(RenderContext rc, ServerComponentUpdate update, Node parentNode, Component component) {
        Row row = (Row) component;
        Border border = (Border) row.getRenderProperty(Row.PROPERTY_BORDER);
        String elementId = ContainerInstance.getElementId(row);
        Document document = parentNode.getOwnerDocument();
       
        Element divElement = document.createElement("div");
        divElement.setAttribute("id", elementId);
        parentNode.appendChild(divElement);

        CssStyle divCssStyle = new CssStyle();
        BorderRender.renderToStyle(divCssStyle, border);
        ColorRender.renderToStyle(divCssStyle, (Color) row.getRenderProperty(Row.PROPERTY_FOREGROUND),
                (Color) row.getRenderProperty(Row.PROPERTY_BACKGROUND));
        FontRender.renderToStyle(divCssStyle, (Font) row.getRenderProperty(Row.PROPERTY_FONT));
        Insets insets = (Insets) row.getRenderProperty(Row.PROPERTY_INSETS);
        if (insets == null) {
            divCssStyle.setAttribute("padding", "0px");
        } else {
            InsetsRender.renderToStyle(divCssStyle, "padding", insets);
        }
        divElement.setAttribute("style", divCssStyle.renderInline());
       
        Element tableElement = document.createElement("table");
        tableElement.setAttribute("id", elementId + "_table");
        tableElement.setAttribute("style", "padding:0px;border-collapse:collapse;");
       
        AlignmentRender.renderToElement(divElement,
                ((Alignment) row.getRenderProperty(Row.PROPERTY_ALIGNMENT)), row);
       
        divElement.appendChild(tableElement);
       
        Element tbodyElement = document.createElement("tbody");
        tbodyElement.setAttribute("id", elementId + "_tbody");
        tableElement.appendChild(tbodyElement);
       
        Element trElement = document.createElement("tr");
        trElement.setAttribute("id", elementId + "_tr");
        tbodyElement.appendChild(trElement);
       
        Component[] children = row.getVisibleComponents();
        for (int i = 0; i < children.length; ++i) {
            renderChild(rc, update, trElement, component, children[i]);
        }
       
        storeRenderState(rc, row);
View Full Code Here

    }
   
    protected Row createPnButtons() {
        //ContentPane pnButtons = new ContentPane();
       
        Row mainRow = new Row();
        mainRow.setAlignment(new Alignment(Alignment.LEFT, Alignment.DEFAULT));
        mainRow.setInsets(new Insets(new JbsExtent(11), new JbsExtent(11)));
       
        btnSelectAll = new JbsButton(JbsL10N.getString("Generic.selectAll"));
        btnSelectAll.setAlignmentHorizontal(Alignment.CENTER);
        //btnSelectAll.setWidth(new JbsExtent(80));
        btnSelectAll.addActionListener(new ActionListener() {

            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent arg0) {
                for (int i=0; i<getDunningWizard().getMaxDunningLevel(); i++) {
                    TblMInvoicesForDunning model = (TblMInvoicesForDunning)getDunningWizard().getInvoicePanels().get(i).getTblInvoices().getModel();
                    model.selectAll();
                }
            }

        });
        mainRow.add(btnSelectAll);
       
        btnSelectNone = new JbsButton(JbsL10N.getString("Generic.selectNone"));
        btnSelectNone.setAlignmentHorizontal(Alignment.CENTER);
        //btnSelectNone.setWidth(new JbsExtent(80));
        btnSelectNone.addActionListener(new ActionListener() {

            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent arg0) {
                for (int i=0; i<getDunningWizard().getMaxDunningLevel(); i++) {
                    TblMInvoicesForDunning model = (TblMInvoicesForDunning)getDunningWizard().getInvoicePanels().get(i).getTblInvoices().getModel();
                    model.selectNone();
                }
            }

        });
        mainRow.add(btnSelectNone);
       
        btnSwapSelection = new JbsButton(JbsL10N.getString("Generic.swapSelection"));
        btnSwapSelection.setAlignmentHorizontal(Alignment.CENTER);
        //btnSwapSelection.setWidth(new JbsExtent(80));
        btnSwapSelection.addActionListener(new ActionListener() {

            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent arg0) {
                for (int i=0; i<getDunningWizard().getMaxDunningLevel(); i++) {
                    TblMInvoicesForDunning model = (TblMInvoicesForDunning)getDunningWizard().getInvoicePanels().get(i).getTblInvoices().getModel();
                    model.swapSelection();
                }
            }

        });
        mainRow.add(btnSwapSelection);
        return mainRow;
    }
View Full Code Here

        this.setMaximizable(false);
        this.setKeystrokeListener(this.createKeyStrokeListener());
        this.setPostOnEnterKey(true);
        this.setCancelOnEscKey(true);

        SplitPane spMain = new SplitPane(SplitPane.ORIENTATION_VERTICAL_BOTTOM_TOP, new JbsExtent(45));

        this.add(spMain);
        spMain.add(initPnButtons());

        pnMain = new JbsContentPane();
        spMain.add(pnMain);
    }
View Full Code Here

     */
    @Override
    protected void initForm() {
        super.initForm();

        ButtonGroup radioGroup = new ButtonGroup();
        Column colMain = new Column();
        Row row1 = new Row();
        row1.setAlignment(Alignment.ALIGN_TOP);
        rbNoDate = new JbsRadioButton();
        rbNoDate.setText(JbsL10N.getString("FmSelectDate.noDate"));
View Full Code Here

    protected void addAction(String actionCommand) {
        EventListener[] listeners = listenerList.getListeners(ActionListener.class);
        for (int i = 0; i < listeners.length; i++) {
            ActionListener actionListener = (ActionListener) listeners[i];
            try {
                actionListener.actionPerformed(new ActionEvent(JbsDialogWindow.this, actionCommand));
            } catch (Throwable t) {
                logger.error("Error adding action.",t);
            }
        }
    }
View Full Code Here

    protected void addAction(String actionCommand) {
        EventListener[] listeners = listenerList.getListeners(ActionListener.class);
        for (int i = 0; i < listeners.length; i++) {
            ActionListener actionListener = (ActionListener) listeners[i];
            try {
                actionListener.actionPerformed(new ActionEvent(PnEditJbsObject.this, actionCommand));
            } catch (Throwable t) {
                logger.error("Error adding action.",t);
            }
        }
    }
View Full Code Here

    protected final String IMG_DROPDOWN = Styles.IMAGE_PATH + "blank.gif";
   
    public JbsMenuLabel(String text) {
        super();
        this.setBtnMain(new JbsButton(""));
        this.getBtnMain().addActionListener(new ActionListener() {

            public void actionPerformed(ActionEvent arg0) {
                logger.debug("popup");
                setExpanded(!isExpanded());
                collapseAllOther();
View Full Code Here

        }
    }
   
    public void addMenuItem(MenuItem menuItem) {
        menuItem.setBorder(BorderEx.NONE);
        menuItem.addActionListener(new ActionListener() {

            private static final long serialVersionUID = 1L;

            public void actionPerformed(ActionEvent arg0) {
                setExpanded(false);
View Full Code Here

TOP

Related Classes of nextapp.echo2.app.Row

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.