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

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

Introduction

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

Prototype

@Override
    public void removeRow(int row) 

Source Link

Usage

From source file:net.s17fabu.vip.gwt.showcase.client.content.tables.CwFlexTable.java

License:Apache License

/**
 * Remove a row from the flex table.// w ww . j a v  a2 s .  c om
 */
private void removeRow(FlexTable flexTable) {
    int numRows = flexTable.getRowCount();
    if (numRows > 1) {
        flexTable.removeRow(numRows - 1);
        flexTable.getFlexCellFormatter().setRowSpan(0, 1, numRows - 1);
    }
}

From source file:org.dataconservancy.dcs.access.client.ui.SeadAdvancedSearchWidget.java

License:Apache License

private Button createNewRemoveButton(final FlexTable table) {

    Button remove = new Button("<image src='images/remove.png'>");
    remove.addStyleName("addRemoveButton");

    remove.addClickHandler(new ClickHandler() {

        public void onClick(ClickEvent event) {
            int rowIndex = table.getCellForEvent(event).getRowIndex();
            int count = table.getRowCount();
            table.removeRow(rowIndex);
            if (rowIndex == (count - 1)) {
                // Make sure last row has an add button (if we
                // removed the old last row)

                table.setWidget(rowIndex - 1, 4, createNewAddButton(table));
            }//from   w ww  .  j av a  2 s  . c o m
            if (count == 2) {
                // Don't allow the last row to be removed
                table.setWidget(0, 3, null);
            }
        }
    });
    return remove;
}

From source file:org.dataconservancy.dcs.access.ui.client.Application.java

License:Apache License

private Widget createAdvancedSearchWidget(Search.UserField[] userfields, String[] userqueries) {
    FlowPanel panel = new FlowPanel();

    Button search = new Button("Search");

    final FlexTable table = new FlexTable();

    Button add = new Button("Add field");

    panel.add(table);//from   w w w . j  a v a 2  s  . co m

    // Called to search filled in query

    final ClickHandler searchlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            // Build up search history token

            String[] data = new String[(table.getRowCount() * 2) + 1];
            int dataindex = 0;
            boolean emptyquery = true;

            for (int i = 0; i < table.getRowCount(); i++) {
                ListBox lb = (ListBox) table.getWidget(i, 0);
                TextBox tb = (TextBox) table.getWidget(i, 1);

                int sel = lb.getSelectedIndex();

                if (sel != -1) {
                    String userquery = tb.getText().trim();
                    String userfield = Search.UserField.values()[sel].name();

                    if (userquery.isEmpty()) {
                        userfield = null;
                        userquery = null;
                    } else {
                        emptyquery = false;
                    }

                    data[dataindex++] = userfield;
                    data[dataindex++] = userquery;
                }
            }

            data[dataindex] = "0";

            if (!emptyquery) {
                History.newItem(State.SEARCH.toToken(data));
            }
        }
    };

    ClickHandler addlistener = new ClickHandler() {

        public void onClick(ClickEvent event) {
            int row = table.getRowCount();

            table.setWidget(row, 0, createAdvancedSearchFieldSelector());

            TextBox tb = new TextBox();
            table.setWidget(row, 1, tb);

            tb.addKeyDownHandler(new KeyDownHandler() {

                public void onKeyDown(KeyDownEvent event) {
                    if (event.getNativeKeyCode() == KeyCodes.KEY_ENTER) {
                        searchlistener.onClick(null);
                    }
                }
            });

            final Button remove = new Button("Remove");

            table.setWidget(row, 2, remove);

            remove.addClickHandler(new ClickHandler() {

                public void onClick(ClickEvent event) {
                    for (int row = 0; row < table.getRowCount(); row++) {
                        if (table.getWidget(row, 2) == remove) {
                            table.removeRow(row);
                        }
                    }
                }
            });
        }
    };

    add.addClickHandler(addlistener);

    if (userfields != null) {
        for (int i = 0; i < userfields.length; i++) {
            if (userfields[i] == null) {
                continue;
            }

            int row = table.getRowCount();
            addlistener.onClick(null);

            ListBox lb = (ListBox) table.getWidget(row, 0);
            lb.setItemSelected(userfields[i].ordinal(), true);
            TextBox tb = (TextBox) table.getWidget(row, 1);
            tb.setText(userqueries[i]);
        }
    } else {
        addlistener.onClick(null);
    }

    HorizontalPanel hp = new HorizontalPanel();
    hp.setSpacing(5);
    hp.add(add);
    hp.add(search);

    panel.add(hp);

    search.addClickHandler(searchlistener);

    return panel;
}

From source file:org.freemedsoftware.gwt.client.screen.CallInScreen.java

License:Open Source License

public void showCallinInfo(Integer callinId) {
    tabPanel.selectTab(0);//  w ww.ja  v  a  2s.c o  m
    if (Util.getProgramMode() == ProgramMode.STUBBED) {
        // TODO STUBBED MODE STUFF
    } else if (Util.getProgramMode() == ProgramMode.JSONRPC) {
        String[] params = { JsonUtil.jsonify(callinId) };
        RequestBuilder builder = new RequestBuilder(RequestBuilder.POST,
                URL.encode(Util.getJsonRequest("org.freemedsoftware.module.Callin.GetDetailedRecord", params)));
        try {
            builder.sendRequest(null, new RequestCallback() {
                public void onError(Request request, Throwable ex) {
                }

                @SuppressWarnings("unchecked")
                public void onResponseReceived(Request request, Response response) {
                    if (Util.checkValidSessionResponse(response.getText())) {
                        if (200 == response.getStatusCode()) {
                            HashMap<String, String> data = (HashMap<String, String>) JsonUtil.shoehornJson(
                                    JSONParser.parseStrict(response.getText()), "HashMap<String,String>");
                            if (data != null) {
                                Popup callinDetailPopup = new Popup();
                                callinDetailPopup.setPixelSize(500, 20);
                                FlexTable callinPatientDetail = new FlexTable();
                                while (callinPatientDetail.getRowCount() > 0)
                                    callinPatientDetail.removeRow(0);
                                int row = 0;
                                callinPatientDetail.setWidget(row, 0, new Label(_("Name") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("name")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Date of Birth") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("dob")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Complaint") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("complaint")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Home Phone") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("phone_home")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Work Phone") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("phone_work")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Facility") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("facility")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Provider") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("physician")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Call Date") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("call_date")));

                                callinPatientDetail.setWidget(row, 0, new Label(_("Took Call") + ":"));
                                callinPatientDetail.setWidget(row++, 1, new Label(data.get("took_call")));

                                PopupView viewInfo = new PopupView(callinPatientDetail);
                                callinDetailPopup.setNewWidget(viewInfo);
                                callinDetailPopup.initialize();

                            }
                        } else {
                        }
                    }
                }
            });
        } catch (RequestException e) {
        }
    } else {
        // TODO NORMAL MODE STUFF
    }
}

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);
    }//w  w  w  .  ja v  a 2  s .c o  m
    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.kaaproject.avro.ui.gwt.client.widget.ArrayFieldWidget.java

License:Apache License

private void setRow(final FlexTable table, FormField field, int row,
        List<HandlerRegistration> handlerRegistrations,
        final Map<FormField, List<HandlerRegistration>> rowHandlerRegistrationMap, final boolean hasHeader) {
    if (hasHeader) {
        row++;/*from  ww w .  java 2s  . c o m*/
    }
    if (field.getFieldType() == FieldType.RECORD) {
        RecordField record = (RecordField) field;
        List<FormField> recordFields = record.getFieldsWithAccess(FieldAccess.EDITABLE, FieldAccess.READ_ONLY);
        for (int column = 0; column < recordFields.size(); column++) {
            FormField cellField = recordFields.get(column);
            constructAndPlaceWidget(table, cellField, row, column, handlerRegistrations);
        }
    } else {
        constructAndPlaceWidget(table, field, row, 0, handlerRegistrations);
    }

    if (!readOnly) {
        final Button delButton = new Button("");
        Image img = new Image(Utils.resources.remove());
        img.getElement().getStyle().setVerticalAlign(Style.VerticalAlign.MIDDLE);
        delButton.getElement().appendChild(img.getElement());
        delButton.addStyleName(style.cellButton());
        delButton.addStyleName(style.cellButtonSmall());
        delButton.getElement().getStyle().setMarginLeft(3, Unit.PX);
        HandlerRegistration handlerRegistration = delButton.addClickHandler(new ClickHandler() {
            @Override
            public void onClick(ClickEvent event) {
                int tableRow = table.getCellForEvent(event).getRowIndex();
                int rowIndex = hasHeader ? tableRow - 1 : tableRow;
                FormField toDelete = value.getValue().get(rowIndex);
                List<HandlerRegistration> registrations = rowHandlerRegistrationMap.remove(toDelete);
                if (registrations != null) {
                    for (HandlerRegistration registration : registrations) {
                        registration.removeHandler();
                    }
                    registrations.clear();
                }
                table.removeRow(tableRow);
                value.getValue().remove(rowIndex);
                fireChanged();
            }
        });
        handlerRegistrations.add(handlerRegistration);
        table.setWidget(row, table.getCellCount(row), delButton);
    }
}

From source file:org.openremote.modeler.client.widget.propertyform.GridPropertyForm.java

License:Open Source License

private void updateGrid() {
    FlexTable screenTable = gridContainer.getGridlayoutContainer().getScreenTable();
    int rowNums = screenTable.getRowCount();
    for (int i = rowNums - 1; i >= 0; i--) {
        screenTable.removeRow(i);
    }//from w ww. jav  a  2 s  .c  om

    gridContainer.update();
}

From source file:sk.seges.acris.widget.client.form.select.TextButtonPanel.java

License:Apache License

public void display() {
    FlexTable layout = getLayout();
    while (layout.getRowCount() > 0)
        layout.removeRow(layout.getRowCount() - 1);

    addComponentListeners();/*www. j a v a 2s  .c o m*/

    layout.setWidget(0, 0, getSelectedValue());
    layout.setWidget(0, 1, getChoiceButton());

    prepareSelectedValue();
    if (isChoiceButtonVisible())
        prepareChoiceButton();

    setStyleName("advanced-TextButtonPanel");
    setWidget(layout);
}