Example usage for com.google.gwt.user.client.ui HorizontalPanel remove

List of usage examples for com.google.gwt.user.client.ui HorizontalPanel remove

Introduction

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

Prototype

@Override
    public boolean remove(Widget w) 

Source Link

Usage

From source file:org.drools.guvnor.client.explorer.navigation.qa.testscenarios.ScenarioWidget.java

License:Apache License

public Widget getRuleSelectionWidget(final String packageName, final RuleSelectionEvent selected) {
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    final TextBox ruleNameTextBox = scenarioWidgetComponentCreator.createRuleNameTextBox();
    horizontalPanel.add(ruleNameTextBox);
    if (availableRules != null) {
        final ListBox availableRulesBox = scenarioWidgetComponentCreator
                .createAvailableRulesBox(availableRules);
        availableRulesBox.setSelectedIndex(0);
        if (availableRulesHandlerRegistration != null) {
            availableRulesHandlerRegistration.removeHandler();
        }/*from  w ww .j  a va  2 s .  c  o  m*/
        final ChangeHandler ruleSelectionCL = scenarioWidgetComponentCreator
                .createRuleChangeHandler(ruleNameTextBox, availableRulesBox);

        availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
        horizontalPanel.add(availableRulesBox);

    } else {

        final Button showList = new Button(Constants.INSTANCE.showListButton());
        horizontalPanel.add(showList);
        showList.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                horizontalPanel.remove(showList);
                final Image busy = new Image(DroolsGuvnorImageResources.INSTANCE.searching());
                final Label loading = new SmallLabel(Constants.INSTANCE.loadingList1());
                horizontalPanel.add(busy);
                horizontalPanel.add(loading);

                Scheduler scheduler = Scheduler.get();
                scheduler.scheduleDeferred(new Command() {
                    public void execute() {
                        ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
                        moduleService.listRulesInPackage(packageName,
                                createGenericCallback(horizontalPanel, ruleNameTextBox, busy, loading));
                    }

                    private GenericCallback<String[]> createGenericCallback(
                            final HorizontalPanel horizontalPanel, final TextBox ruleNameTextBox,
                            final Image busy, final Label loading) {
                        return new GenericCallback<String[]>() {

                            public void onSuccess(String[] list) {
                                availableRules = (list);
                                final ListBox availableRulesBox = scenarioWidgetComponentCreator
                                        .createAvailableRulesBox(list);

                                final ChangeHandler ruleSelectionCL = new ChangeHandler() {
                                    public void onChange(ChangeEvent event) {
                                        ruleNameTextBox.setText(availableRulesBox
                                                .getItemText(availableRulesBox.getSelectedIndex()));
                                    }
                                };
                                availableRulesHandlerRegistration = availableRulesBox
                                        .addChangeHandler(ruleSelectionCL);
                                availableRulesBox.setSelectedIndex(0);
                                horizontalPanel.add(availableRulesBox);
                                horizontalPanel.remove(busy);
                                horizontalPanel.remove(loading);
                            }

                        };
                    }
                });

            }
        });

    }

    Button ok = scenarioWidgetComponentCreator.createOkButton(selected, ruleNameTextBox);
    horizontalPanel.add(ok);
    return horizontalPanel;
}

From source file:org.drools.guvnor.client.qa.testscenarios.ScenarioWidget.java

License:Apache License

public Widget getRuleSelectionWidget(final String packageName, final RuleSelectionEvent selected) {
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    final TextBox ruleNameTextBox = scenarioWidgetComponentCreator.createRuleNameTextBox();
    horizontalPanel.add(ruleNameTextBox);
    if (availableRules != null) {
        final ListBox availableRulesBox = scenarioWidgetComponentCreator
                .createAvailableRulesBox(availableRules);
        availableRulesBox.setSelectedIndex(0);
        if (availableRulesHandlerRegistration != null) {
            availableRulesHandlerRegistration.removeHandler();
        }//from ww  w.  j a v  a 2s.c  o  m
        final ChangeHandler ruleSelectionCL = scenarioWidgetComponentCreator
                .createRuleChangeHandler(ruleNameTextBox, availableRulesBox);

        availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
        horizontalPanel.add(availableRulesBox);

    } else {

        final Button showList = new Button(constants.showListButton());
        horizontalPanel.add(showList);
        showList.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                horizontalPanel.remove(showList);
                final Image busy = new Image(images.searching());
                final Label loading = new SmallLabel(constants.loadingList1());
                horizontalPanel.add(busy);
                horizontalPanel.add(loading);

                Scheduler scheduler = Scheduler.get();
                scheduler.scheduleDeferred(new Command() {
                    public void execute() {
                        RepositoryServiceFactory.getService().listRulesInPackage(packageName,
                                createGenericCallback(horizontalPanel, ruleNameTextBox, busy, loading));
                    }

                    private GenericCallback<String[]> createGenericCallback(
                            final HorizontalPanel horizontalPanel, final TextBox ruleNameTextBox,
                            final Image busy, final Label loading) {
                        return new GenericCallback<String[]>() {

                            public void onSuccess(String[] list) {
                                availableRules = (list);
                                final ListBox availableRulesBox = scenarioWidgetComponentCreator
                                        .createAvailableRulesBox(list);

                                final ChangeHandler ruleSelectionCL = new ChangeHandler() {
                                    public void onChange(ChangeEvent event) {
                                        ruleNameTextBox.setText(availableRulesBox
                                                .getItemText(availableRulesBox.getSelectedIndex()));
                                    }
                                };
                                availableRulesHandlerRegistration = availableRulesBox
                                        .addChangeHandler(ruleSelectionCL);
                                availableRulesBox.setSelectedIndex(0);
                                horizontalPanel.add(availableRulesBox);
                                horizontalPanel.remove(busy);
                                horizontalPanel.remove(loading);
                            }

                        };
                    }
                });

            }
        });

    }

    Button ok = scenarioWidgetComponentCreator.createOkButton(selected, ruleNameTextBox);
    horizontalPanel.add(ok);
    return horizontalPanel;
}

From source file:org.drools.workbench.screens.testscenario.client.ScenarioWidgetComponentCreator.java

License:Apache License

public Widget getRuleSelectionWidget(final RuleSelectionEvent selected) {
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    final TextBox ruleNameTextBox = createRuleNameTextBox();
    horizontalPanel.add(ruleNameTextBox);
    if (hasRules) {
        final ListBox availableRulesBox = createAvailableRulesBox();
        availableRulesBox.setSelectedIndex(0);
        if (availableRulesHandlerRegistration != null) {
            availableRulesHandlerRegistration.removeHandler();
        }// w  w w. ja  v  a2  s  .c  o m
        final ChangeHandler ruleSelectionCL = createRuleChangeHandler(ruleNameTextBox, availableRulesBox);

        availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
        horizontalPanel.add(availableRulesBox);

    } else {
        final Button showList = new Button(TestScenarioConstants.INSTANCE.showListButton());
        horizontalPanel.add(showList);
        showList.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                horizontalPanel.remove(showList);
                final Image busy = new Image(ImageResources.INSTANCE.searching());
                final Label loading = new SmallLabel(TestScenarioConstants.INSTANCE.loadingList1());
                horizontalPanel.add(busy);
                horizontalPanel.add(loading);

                final ListBox availableRulesBox = createAvailableRulesBox();

                final ChangeHandler ruleSelectionCL = new ChangeHandler() {
                    public void onChange(ChangeEvent event) {
                        ruleNameTextBox
                                .setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
                    }
                };
                availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
                availableRulesBox.setSelectedIndex(0);
                horizontalPanel.add(availableRulesBox);
                horizontalPanel.remove(busy);
                horizontalPanel.remove(loading);

            }
        });

    }

    Button ok = createOkButton(selected, ruleNameTextBox);
    horizontalPanel.add(ok);
    return horizontalPanel;
}

From source file:org.jbpm.formbuilder.client.effect.view.ScriptHelperListPanel.java

License:Apache License

private void renumber() {
    for (Widget widget : this) {
        HorizontalPanel panel = (HorizontalPanel) widget;
        int index = getWidgetIndex(panel) + 1;
        String number = String.valueOf(index);
        panel.remove(0);
        panel.insert(new Label(number), 0);
    }//from   ww  w. ja va2  s . c  o  m

}

From source file:org.kie.guvnor.testscenario.client.ScenarioWidgetComponentCreator.java

License:Apache License

public Widget getRuleSelectionWidget(final RuleSelectionEvent selected) {
    final HorizontalPanel horizontalPanel = new HorizontalPanel();
    final TextBox ruleNameTextBox = createRuleNameTextBox();
    horizontalPanel.add(ruleNameTextBox);
    if (availableRules != null) {
        final ListBox availableRulesBox = createAvailableRulesBox(availableRules);
        availableRulesBox.setSelectedIndex(0);
        if (availableRulesHandlerRegistration != null) {
            availableRulesHandlerRegistration.removeHandler();
        }//from  ww  w .  j a v  a 2 s .c  om
        final ChangeHandler ruleSelectionCL = createRuleChangeHandler(ruleNameTextBox, availableRulesBox);

        availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
        horizontalPanel.add(availableRulesBox);

    } else {

        final Button showList = new Button(TestScenarioConstants.INSTANCE.showListButton());
        horizontalPanel.add(showList);
        showList.addClickHandler(new ClickHandler() {

            public void onClick(ClickEvent event) {
                horizontalPanel.remove(showList);
                final Image busy = new Image(ImageResources.INSTANCE.searching());
                final Label loading = new SmallLabel(TestScenarioConstants.INSTANCE.loadingList1());
                horizontalPanel.add(busy);
                horizontalPanel.add(loading);

                //                    Scheduler scheduler = Scheduler.get();
                //                    scheduler.scheduleDeferred(new Command() {
                //                        public void execute() {
                //                            ModuleServiceAsync moduleService = GWT.create(ModuleService.class);
                //                            moduleService.listRulesInPackage(packageName,
                //                                    createGenericCallback(horizontalPanel,
                //                                            ruleNameTextBox,
                //                                            busy,
                //                                            loading));
                //                        }

                //                        private GenericCallback<String[]> createGenericCallback(final HorizontalPanel horizontalPanel,
                //                                                                                final TextBox ruleNameTextBox,
                //                                                                                final Image busy,
                //                                                                                final Label loading) {
                //                            return new GenericCallback<String[]>() {
                //
                //                                public void onSuccess(String[] list) {
                //                                    availableRules = (list);
                //                                    final ListBox availableRulesBox = scenarioWidgetComponentCreator.createAvailableRulesBox(list);
                //
                //                                    final ChangeHandler ruleSelectionCL = new ChangeHandler() {
                //                                        public void onChange(ChangeEvent event) {
                //                                            ruleNameTextBox.setText(availableRulesBox.getItemText(availableRulesBox.getSelectedIndex()));
                //                                        }
                //                                    };
                //                                    availableRulesHandlerRegistration = availableRulesBox.addChangeHandler(ruleSelectionCL);
                //                                    availableRulesBox.setSelectedIndex(0);
                //                                    horizontalPanel.add(availableRulesBox);
                //                                    horizontalPanel.remove(busy);
                //                                    horizontalPanel.remove(loading);
                //                                }
                //
                //                            };
                //                        }
                //                    });

            }
        });

    }

    Button ok = createOkButton(selected, ruleNameTextBox);
    horizontalPanel.add(ok);
    return horizontalPanel;
}

From source file:org.rstudio.core.client.widget.Toolbar.java

License:Open Source License

private void removeAllWidgets(HorizontalPanel panel) {
    for (int i = panel.getWidgetCount() - 1; i >= 0; i--)
        panel.remove(i);
}

From source file:org.unitime.timetable.gwt.client.curricula.CurriculaCourses.java

License:Apache License

public void assignGroup(String oldName, String name, int type) {
    Group g = null;/*from ww  w . j ava 2s. c o  m*/
    for (Group x : iGroups) {
        if (x.getName().equals(oldName == null ? name : oldName)) {
            g = x;
            break;
        }
    }
    if (g == null) {
        if (name == null || name.isEmpty())
            return;
        g = new Group(name, type);
        colors: for (String c : sColors) {
            for (Group x : iGroups) {
                if (x.getColor().equals(c))
                    continue colors;
            }
            g.setColor(c);
            break;
        }
        iGroups.add(g);
    } else {
        rows: for (int row = 1; row < iTable.getRowCount(); row++) {
            HorizontalPanel p = (HorizontalPanel) iTable.getWidget(row, 0);
            for (int i = 0; i < p.getWidgetCount(); i++) {
                Group x = (Group) p.getWidget(i);
                if (x.equals(g)) {
                    if (name == null || name.isEmpty()) {
                        p.remove(i);
                        continue rows;
                    } else {
                        x.setName(name);
                        x.setType(type);
                    }
                }
            }
        }
        if (name == null || name.isEmpty()) {
            iGroups.remove(g);
            return;
        } else {
            g.setName(name);
            g.setType(type);
        }
    }
    if (oldName != null)
        return;
    boolean nothing = true;
    boolean hasNoGroup = false;
    rows: for (int row = 1; row < iTable.getRowCount(); row++) {
        if (!iTable.isSelected(row))
            continue;
        nothing = false;
        HorizontalPanel p = (HorizontalPanel) iTable.getWidget(row, 0);
        for (int i = 0; i < p.getWidgetCount(); i++) {
            Group x = (Group) p.getWidget(i);
            if (x.equals(g))
                continue rows;
        }
        hasNoGroup = true;
        break;
    }
    if (nothing) {
        boolean select = false;
        for (int row = 1; row < iTable.getRowCount(); row++) {
            HorizontalPanel p = (HorizontalPanel) iTable.getWidget(row, 0);
            for (int i = 0; i < p.getWidgetCount(); i++) {
                Group x = (Group) p.getWidget(i);
                if (x.equals(g)) {
                    iTable.setSelected(row, true);
                    select = true;
                }
            }
        }
        if (select)
            return;
    }
    rows: for (int row = 1; row < iTable.getRowCount(); row++) {
        if (!iTable.isSelected(row))
            continue;
        iTable.setSelected(row, false);
        HorizontalPanel p = (HorizontalPanel) iTable.getWidget(row, 0);
        for (int i = 0; i < p.getWidgetCount(); i++) {
            Group x = (Group) p.getWidget(i);
            if (x.equals(g)) {
                if (!hasNoGroup)
                    p.remove(i);
                continue rows;
            }
        }
        p.add(g.cloneGroup());
    }
    boolean found = false;
    rows: for (int row = 1; row < iTable.getRowCount(); row++) {
        HorizontalPanel p = (HorizontalPanel) iTable.getWidget(row, 0);
        for (int i = 0; i < p.getWidgetCount(); i++) {
            Group x = (Group) p.getWidget(i);
            if (x.equals(g)) {
                found = true;
                break rows;
            }
        }
    }
    if (!found)
        iGroups.remove(g);
}

From source file:rocket.widget.client.SortableTable.java

License:Apache License

/**
 * Marks a particular column as not being sortable.
 * //from ww  w .j a v a2 s  .com
 * @param column
 */
public void makeColumnUnsortable(final int column) {
    this.checkColumn("parameter:column", column);

    this.getColumnComparators()[column] = null;

    final HorizontalPanel panel = (HorizontalPanel) this.getGrid().getWidget(0, column);
    if (panel.getWidgetCount() > 1) {
        panel.remove(panel.getWidget(1));
    }
    this.removeColumnStyle(column, this.getSortableColumnStyle());
}

From source file:rocket.widget.client.SortableTable.java

License:Apache License

protected void removeSortDirectionImage(final int column) {
    final HorizontalPanel panel = (HorizontalPanel) this.getGrid().getWidget(0, column);
    panel.remove(1);
}