Example usage for com.google.gwt.user.client.ui FlexTable insertRow

List of usage examples for com.google.gwt.user.client.ui FlexTable insertRow

Introduction

In this page you can find the example usage for com.google.gwt.user.client.ui FlexTable insertRow.

Prototype

@Override
public int insertRow(int beforeRow) 

Source Link

Document

Inserts a row into the FlexTable.

Usage

From source file:com.risevision.ui.client.common.dnd.FlexTableUtil.java

License:Apache License

/**
 * Move an entire FlexTable from one FlexTable to another. Elements are moved by attempting to
 * call {@link FlexTable#getWidget(int, int)} on the source table. If no widget is found (because
 * <code>null</code> is returned), a new {@link HTML} is created instead by calling
 * {@link FlexTable#getHTML(int, int)} on the source table.
 * //from  www  . j av  a2 s .  c o m
 * @param sourceTable the FlexTable to move a row from
 * @param targetTable the FlexTable to move a row to
 * @param sourceRow the index of the source row
 * @param targetRow the index before which to insert the moved row
 */
public static void moveRow(FlexTable sourceTable, FlexTable targetTable, int sourceRow, int targetRow) {
    if (sourceTable == targetTable && sourceRow >= targetRow) {
        sourceRow++;
    }
    targetTable.insertRow(targetRow);
    for (int col = 0; col < sourceTable.getCellCount(sourceRow); col++) {
        Widget w = sourceTable.getWidget(sourceRow, col);
        if (w != null) {
            targetTable.setWidget(targetRow, col, w);
        } else {
            HTML html = new HTML(sourceTable.getHTML(sourceRow, col));
            targetTable.setWidget(targetRow, col, html);
        }
        copyCellStyle(sourceTable, targetTable, sourceRow, col, targetRow, col);
    }
    copyRowStyle(sourceTable, targetTable, sourceRow, targetRow);
    sourceTable.removeRow(sourceRow);
}

From source file:org.jbpm.form.builder.ng.model.client.form.items.MIGLayoutFormItem.java

License:Apache License

private void populate(FlexTable grid) {
    if (this.borderWidth != null && this.borderWidth > 0) {
        grid.setBorderWidth(this.borderWidth);
    }/*from  www  . j a  v a2s .c om*/
    if (this.cellpadding != null && this.cellpadding >= 0) {
        grid.setCellPadding(this.cellpadding);
    }
    if (this.cellspacing != null && this.cellspacing >= 0) {
        grid.setCellSpacing(this.cellspacing);
    }
    if (getHeight() != null) {
        grid.setHeight(getHeight());
    }
    if (getWidth() != null) {
        grid.setWidth(getWidth());
    }
    if (this.title != null) {
        grid.setTitle(this.title);
    }
    if (this.rows != null && this.rows > 0) {
        while (this.rows > grid.getRowCount()) {
            grid.insertRow(grid.getRowCount());
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(grid.getRowCount() - 1); cell++) {
                columnCount += formatter.getColSpan(grid.getRowCount() - 1, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(grid.getRowCount() - 1); //at least one cell per column. Modified later by colspans
                columnCount++;
            }
        }
        while (this.rows < grid.getRowCount()) {
            grid.removeRow(grid.getRowCount() - 1);
        }
    }
    if (this.columns != null && this.columns > 0) {
        for (int row = 0; row < grid.getRowCount(); row++) {
            int columnCount = 0;
            FlexCellFormatter formatter = grid.getFlexCellFormatter();
            for (int cell = 0; cell < grid.getCellCount(row); cell++) {
                columnCount += formatter.getColSpan(row, cell);
            }
            while (this.columns > columnCount) {
                grid.addCell(row);
                columnCount++;
            }
            while (this.columns < columnCount) {
                int cellCount = grid.getCellCount(row);
                if (cellCount > 0) {
                    int cellColumns = formatter.getColSpan(row, cellCount - 1);
                    if (cellColumns > 1 && columnCount - cellColumns >= this.columns) {
                        grid.removeCell(row, cellCount - 1);
                    } else {
                        grid.removeCell(row, cellCount - 1);
                    }
                }
                columnCount--;
            }
        }
    }
}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addHTMLLabelRow(FlexTable target, String label, String value) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setText(target.getRowCount() - 1, 1, value);

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addWidgetRow(FlexTable target, String label, Widget widget) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setWidget(target.getRowCount() - 1, 1, widget);

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 2, "visibility");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addContactRow(FlexTable target, Widget avatar, Widget details) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setWidget(target.getRowCount() - 1, 0, avatar);
    target.setWidget(target.getRowCount() - 1, 1, details);

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "avatar");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "details");

}

From source file:org.onesocialweb.gwt.client.util.FormLayoutHelper.java

License:Apache License

public static void addWidgetRowHeader(FlexTable target, String label, Widget widget, String visibility) {

    target.insertRow(target.getRowCount());
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.addCell(target.getRowCount() - 1);
    target.setText(target.getRowCount() - 1, 0, label);
    target.setWidget(target.getRowCount() - 1, 1, widget);

    // if relevant show the visibility settings for this field
    if (visibility != null && visibility.length() > 0) {
        // TooltipPushButton btnVisibility = new TooltipPushButton(new
        // Image(OswClient.getInstance().getPreference("theme_folder") +
        // "assets/i-visibility.png"), "Visible to: " + visibility);
        // Button btnVisibility = new Button("Friends");
        PrivacySelectorHeader selectorheader = new PrivacySelectorHeader();
        target.setWidget(target.getRowCount() - 1, 2, selectorheader);
    }//from w  w w .  java2 s .  c  o m

    target.addStyleName("fields");

    // add styling
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 0, "label");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 1, "value");
    target.getCellFormatter().addStyleName(target.getRowCount() - 1, 2, "visibility");

}

From source file:org.openelis.modules.favorites.client.FavoritesScreen.java

License:Open Source License

protected void startEditing() {
    int i;//w ww. ja va 2 s  .  c om
    Widget w;
    CheckBox cb;
    VerticalPanel vp;
    FlexTable layout;
    ArrayList<Item> tmpList;

    vp = (VerticalPanel) panel.getWidget();
    vp.clear();

    // get all the menuitem widgets, sort them
    tmpList = new ArrayList<Item>();
    for (String key : def.getWidgets().keySet()) {
        w = def.getWidget(key);
        if (w instanceof MenuItem && ((MenuItem) w).isEnabled())
            tmpList.add(new Item(key, (MenuItem) w));
    }
    Collections.sort(tmpList);

    // build a new menu list with check box for selection
    i = 0;
    layout = new FlexTable();
    for (Item item : tmpList) {
        final Item checkItem = item;

        cb = new CheckBox();
        if (list.contains(item)) {
            item.isChecked = true;
            cb.setState(CheckBox.CHECKED);
        }
        cb.addValueChangeHandler(new ValueChangeHandler<String>() {
            public void onValueChange(ValueChangeEvent<String> event) {
                checkItem.isChecked = event.getValue() == CheckBox.CHECKED;
            }
        });

        layout.insertRow(i);
        layout.setWidget(i, 0, cb);
        layout.setWidget(i, 1, new MenuItem(null, item.menuItem.labelText, null));
        i++;
    }
    vp.add(layout);
    list = tmpList;

    resize();
}

From source file:org.pentaho.pat.client.util.dnd.impl.SimplePanelDropControllerImpl.java

License:Open Source License

@Override
public void onDrop(final DragContext context) {
    MeasureLabel originalLabel = ((MeasureLabel) context.draggable.getParent().getParent());
    DimensionTreeWidget dtw = (DimensionTreeWidget) originalLabel.getParentNode().getTree().getParent()
            .getParent().getParent();/*w  w w.  j  a  v a2 s  .  co  m*/
    /*
     * If the widget is dropped on the trash can.
     * 
     */
    if (trash) {
        DimensionSimplePanel panel = (DimensionSimplePanel) originalLabel.getParent();
        context.draggable.removeFromParent();

        originalLabel.makeDraggable();

        /*
         * Remove the widget.
         */
        if (originalLabel.getType() == ObjectType.DIMENSION) {
            SimplePanelUtil.clearDimension(context, originalLabel, panel.getCoord(), panel.getAxis());
        } else if (originalLabel.getType() == ObjectType.HIERARCHY) {
            SimplePanelUtil.clearHierarchy(context, originalLabel, panel.getCoord(), panel.getAxis());
        } else if (originalLabel.getType() == ObjectType.LEVEL) {
            SimplePanelUtil.clearLevel(context, originalLabel, panel.getCoord(), panel.getAxis());
        } else if (originalLabel.getType() == ObjectType.MEMBER) {
            SimplePanelUtil.clearMember(context, originalLabel, panel.getCoord(), panel.getAxis());
        } else if (originalLabel.getType() == ObjectType.MEASURE) {
            SimplePanelUtil.clearMember(context, originalLabel, panel.getCoord(), panel.getAxis());
        }

        dtw.setDimensionLocation(dropTarget.getAxis(), originalLabel.getDimensionName());
    }
    /*
     * If the widget is dropped and the target axis != the widgets current axis. IE move dimension from rows to columns.
     */
    else if (originalLabel.getParent() instanceof DimensionSimplePanel
            && (((MeasureLabel) context.draggable.getParent().getParent())
                    .getAxis() != ((DimensionSimplePanel) this.dropTarget).getAxis())) {
        DimensionSimplePanel dp = null;
        boolean createdrop = true;
        DimensionSimplePanel panel = (DimensionSimplePanel) originalLabel.getParent();
        /*
         * If the drop target does not contain a widget then add the original label.
         */
        if (dropTarget.getWidget() == null) {
            dropTarget.setWidget(originalLabel);
        }
        /*
         * Else create a new drop target.
         */
        else {
            FlexTable ft = ((FlexTable) ((DimensionSimplePanel) context.finalDropController.getDropTarget())
                    .getParent());
            int row = dropTarget.getCoord()[0];
            int col = dropTarget.getCoord()[1];

            if (dropTarget.getAxis().equals(IAxis.ROWS) || dropTarget.getAxis().equals(IAxis.FILTER)) {
                for (int i = 0; i < ft.getRowCount(); i++) {
                    ft.insertCell(i, col);
                }
                dp = new DimensionSimplePanel(false, dropTarget.getAxis());
                dp.setWidget(originalLabel);
                ft.setWidget(row, col, dp);
                createdrop = false;
            } else if (dropTarget.getAxis().equals(IAxis.COLUMNS)) {
                ft.insertRow(row);
                dp = new DimensionSimplePanel(false, dropTarget.getAxis());
                dp.setWidget(originalLabel);
                ft.setWidget(row, col, dp);
                createdrop = false;
            }
        }

        /*
         * If the widget is a Dimension.
         */
        if (originalLabel.getType() == ObjectType.DIMENSION) {
            originalLabel.setAxis(((DimensionSimplePanel) this.dropTarget).getAxis());
            SimplePanelUtil.moveDimension(context, originalLabel, originalLabel, false, panel.getCoord(),
                    panel.getAxis(), createdrop);
            if (dp != null) {
                if (dp.getCoord()[0] < dropTarget.getCoord()[0]
                        || dp.getCoord()[1] < dropTarget.getCoord()[1]) {
                    SimplePanelUtil.pullUp(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                } else {
                    SimplePanelUtil.pushDown(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                }
            }
        }
        /*
         * If the widget is a hierarchy.
         */
        else if (originalLabel.getType() == ObjectType.HIERARCHY) {
            originalLabel.setAxis(((DimensionSimplePanel) this.dropTarget).getAxis());
            SimplePanelUtil.moveHierarchy(context, originalLabel, false, panel.getCoord(), panel.getAxis(),
                    createdrop);
            if (dp != null) {
                if (dp.getCoord()[0] < dropTarget.getCoord()[0]
                        || dp.getCoord()[1] < dropTarget.getCoord()[1]) {
                    SimplePanelUtil.pullUp(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                } else {
                    SimplePanelUtil.pushDown(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                }
            }
        }
        /*
         * If the widget is a level.
         */
        else if (originalLabel.getType() == ObjectType.LEVEL) {
            originalLabel.setAxis(((DimensionSimplePanel) this.dropTarget).getAxis());
            SimplePanelUtil.moveLevel(context, originalLabel, false, panel.getCoord(), panel.getAxis(), false);
            if (dp != null) {
                if (dp.getCoord()[0] < dropTarget.getCoord()[0]
                        || dp.getCoord()[1] < dropTarget.getCoord()[1]) {
                    SimplePanelUtil.pullUp(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                } else {
                    SimplePanelUtil.pushDown(context, originalLabel, dropTarget.getCoord(), dp.getCoord(),
                            dropTarget.getAxis(), false);
                }
            }
        }
        /*
         * If the widget is a Member.
         */
        else if (originalLabel.getType() == ObjectType.MEMBER) {
            originalLabel.setAxis(((DimensionSimplePanel) this.dropTarget).getAxis());
            SimplePanelUtil.moveMember(context, originalLabel, false, panel.getCoord(), panel.getAxis(),
                    createdrop);
            if (dp != null) {
                if (dp.getCoord()[0] < dropTarget.getCoord()[0]
                        || dp.getCoord()[1] < dropTarget.getCoord()[1]) {
                    SimplePanelUtil.pullUpMeasember(context, originalLabel, dropTarget.getCoord(),
                            dp.getCoord(), dropTarget.getAxis(), false);
                } else {
                    SimplePanelUtil.pushdownMeasember(context, originalLabel, dropTarget.getCoord(),
                            dp.getCoord(), dropTarget.getAxis(), false);
                }
            }
        }
        /*
         * if the widget is a measure.
         */
        else if (originalLabel.getType() == ObjectType.MEASURE) {
            originalLabel.setAxis(((DimensionSimplePanel) this.dropTarget).getAxis());
            //dtw.setMeasureAxis(dropTarget.getAxis());
            SimplePanelUtil.moveMeasure(context, originalLabel, false, panel.getCoord(), panel.getAxis(),
                    createdrop);
            if (dp != null) {
                if (dp.getCoord()[0] < dropTarget.getCoord()[0]
                        || dp.getCoord()[1] < dropTarget.getCoord()[1]) {
                    SimplePanelUtil.pullUpMeasember(context, originalLabel, dropTarget.getCoord(),
                            dp.getCoord(), dropTarget.getAxis(), false);
                } else {
                    SimplePanelUtil.pushdownMeasember(context, originalLabel, dropTarget.getCoord(),
                            dp.getCoord(), dropTarget.getAxis(), false);
                }
            }
        }

        dtw.setDimensionLocation(dropTarget.getAxis(), originalLabel.getDimensionName());

    }
    /*
     * If the drop is on the same axis, then pushdown or pull up.
     */
    else if (originalLabel.getParent() instanceof DimensionSimplePanel
            && (((MeasureLabel) context.draggable.getParent().getParent()).getAxis() == this.dropTarget
                    .getAxis())) {
        DimensionSimplePanel panel = ((DimensionSimplePanel) originalLabel.getParent());
        /*
         * For Columns.
         */
        if (panel.getAxis().equals(IAxis.COLUMNS)) {
            if (panel.getCoord()[0] > ((DimensionSimplePanel) this.dropTarget).getCoord()[0]) {
                if (originalLabel.getType().equals(ObjectType.MEASURE)
                        || originalLabel.getType().equals(ObjectType.MEMBER)) {
                    SimplePanelUtil.pullUpMeasember(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.COLUMNS, true);
                } else {
                    //pushup
                    SimplePanelUtil.pullUp(context, originalLabel, panel.getCoord(), this.dropTarget.getCoord(),
                            IAxis.COLUMNS, true);
                }
            } else {
                if (originalLabel.getType().equals(ObjectType.MEASURE)
                        || originalLabel.getType().equals(ObjectType.MEMBER)) {
                    SimplePanelUtil.pushdownMeasember(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.COLUMNS, true);
                } else {
                    //pulldown
                    SimplePanelUtil.pushDown(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.COLUMNS, true);
                }
            }
        }
        /*
         * For Rows.
         */
        else if (panel.getAxis().equals(IAxis.ROWS)) {
            if (panel.getCoord()[0] > ((DimensionSimplePanel) this.dropTarget).getCoord()[0]) {
                if (originalLabel.getType().equals(ObjectType.MEASURE)
                        || originalLabel.getType().equals(ObjectType.MEMBER)) {
                    SimplePanelUtil.pullUpMeasember(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.ROWS, true);
                } else {
                    //pushup
                    SimplePanelUtil.pullUp(context, originalLabel, panel.getCoord(), this.dropTarget.getCoord(),
                            IAxis.ROWS, true);
                }
            } else {
                if (originalLabel.getType().equals(ObjectType.MEASURE)
                        || originalLabel.getType().equals(ObjectType.MEMBER)) {
                    SimplePanelUtil.pushdownMeasember(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.ROWS, true);
                } else {
                    //pulldown
                    SimplePanelUtil.pushDown(context, originalLabel, panel.getCoord(),
                            this.dropTarget.getCoord(), IAxis.ROWS, true);
                }
            }
        }
    }
    /*
     * If a standard widget is dropped on an empty drop target.
     */
    else {

        MeasureLabel label = new MeasureLabel(originalLabel.getActualName(), originalLabel.getText(),
                originalLabel.getType(), originalLabel.getParentNode(), originalLabel.isUniqueName());
        label.setDragController(originalLabel.getDragController());
        label.makeDraggable();
        label.setDownButtonVisible(true);
        dropTarget.setWidget(label);

        originalLabel.makeNotDraggable();

        if (originalLabel.getType() == ObjectType.DIMENSION) {
            SimplePanelUtil.moveDimension(context, label, originalLabel, true, null, null, true);
        } else if (originalLabel.getType() == ObjectType.HIERARCHY) {
            SimplePanelUtil.moveHierarchy(context, label, true, null, null, true);
        } else if (originalLabel.getType() == ObjectType.LEVEL) {
            SimplePanelUtil.moveLevel(context, label, true, null, null, true);
        } else if (originalLabel.getType() == ObjectType.MEMBER) {
            SimplePanelUtil.moveMember(context, label, true, null, null, true);
        } else if (originalLabel.getType() == ObjectType.MEASURE) {

            //dtw.setMeasureAxis(dropTarget.getAxis());
            SimplePanelUtil.moveMeasure(context, label, true, null, null, true);
        }

        dtw.setDimensionLocation(dropTarget.getAxis(), originalLabel.getDimensionName());
    }
    super.onDrop(context);
}

From source file:org.sonatype.nexus.gwt.ui.client.repository.RepositoryPage.java

License:Open Source License

protected void addRow(FlexTable table) {
    table.insertRow(table.getRowCount());
}

From source file:us.softoption.gwt.proofs.client.Proofs.java

License:Open Source License

FlexTable createTable() {
    FlexTable t = new FlexTable();

    t.insertRow(0);
    t.insertRow(0);/*  www.j a v a2s. c  om*/
    t.insertRow(0);

    for (int i = 0; i < 3; i++) {
        t.addCell(i);
        t.addCell(i);
        t.addCell(i);

    }

    t.setBorderWidth(1);

    return t;
}