Example usage for com.vaadin.ui HorizontalLayout removeComponent

List of usage examples for com.vaadin.ui HorizontalLayout removeComponent

Introduction

In this page you can find the example usage for com.vaadin.ui HorizontalLayout removeComponent.

Prototype

@Override
public void removeComponent(Component c) 

Source Link

Document

Removes the component from this container.

Usage

From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java

License:Open Source License

private void setCheck(HorizontalLayout row, boolean show) {
    Component c = row.getComponent(1); // second
    Component check = row.getComponent(0);
    if (!show) { // want to hide
        if (c instanceof Label)
            return; // I'm already hiding
        check.setVisible(false);//from ww w .  j  a va 2  s.co  m
        Label sp;
        row.addComponent(sp = new Label(), 1);
        sp.setWidth("12px");
    } else { // want to show
        if (!(c instanceof Label))
            return; //I'm already showing
        check.setVisible(true);
        row.removeComponent(c);
    }
}

From source file:org.jumpmind.vaadin.ui.sqlexplorer.QueryPanel.java

License:Open Source License

protected boolean execute(final boolean runAsScript, String sqlText, final int tabPosition,
        final boolean forceNewTab) {
    boolean scheduled = false;
    if (runnersInProgress == null) {
        runnersInProgress = new HashSet<SqlRunner>();
    }/*w  w  w.ja va  2 s.co m*/

    if (sqlText == null) {
        if (!runAsScript) {
            sqlText = selectSqlToRun();
        } else {
            sqlText = sqlArea.getValue();
        }

        sqlText = sqlText != null ? sqlText.trim() : null;
    }

    if (StringUtils.isNotBlank(sqlText)) {

        final HorizontalLayout executingLayout = new HorizontalLayout();
        executingLayout.setMargin(true);
        executingLayout.setSizeFull();
        final Label label = new Label("Executing:\n\n" + StringUtils.abbreviate(sqlText, 250),
                ContentMode.PREFORMATTED);
        label.setEnabled(false);
        executingLayout.addComponent(label);
        executingLayout.setComponentAlignment(label, Alignment.TOP_LEFT);

        final String sql = sqlText;
        final Tab executingTab;
        if (!forceNewTab && generalResultsTab != null) {
            replaceGeneralResultsWith(executingLayout, FontAwesome.SPINNER);
            executingTab = null;
        } else {
            executingTab = resultsTabs.addTab(executingLayout, StringUtils.abbreviate(sql, 20),
                    FontAwesome.SPINNER, tabPosition);
        }

        if (executingTab != null) {
            executingTab.setClosable(true);
            resultsTabs.setSelectedTab(executingTab);
        }

        final SqlRunner runner = new SqlRunner(sql, runAsScript, user, db, settingsProvider.get(), this,
                generalResultsTab != null);
        runnersInProgress.add(runner);
        runner.setConnection(connection);
        runner.setListener(new SqlRunner.ISqlRunnerListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void writeSql(String sql) {
                QueryPanel.this.appendSql(sql);
            }

            @Override
            public void reExecute(String sql) {
                QueryPanel.this.reExecute(sql);
            }

            public void finished(final FontAwesome icon, final List<Component> results,
                    final long executionTimeInMs, final boolean transactionStarted,
                    final boolean transactionEnded) {
                VaadinSession.getCurrent().access(new Runnable() {

                    @Override
                    public void run() {
                        try {
                            if (transactionEnded) {
                                transactionEnded();
                            } else if (transactionStarted) {
                                rollbackButtonValue = true;
                                commitButtonValue = true;
                                setButtonsEnabled();
                                sqlArea.setStyleName("transaction-in-progress");
                                connection = runner.getConnection();
                            }

                            addToSqlHistory(StringUtils.abbreviate(sql, 1024 * 8), runner.getStartTime(),
                                    executionTimeInMs, user);

                            for (Component resultComponent : results) {
                                resultComponent.setSizeFull();

                                if (forceNewTab || generalResultsTab == null || results.size() > 1) {
                                    if (resultComponent instanceof TabularResultLayout) {
                                        resultComponent = ((TabularResultLayout) resultComponent)
                                                .refreshWithoutSaveButton();
                                    }
                                    addResultsTab(resultComponent, StringUtils.abbreviate(sql, 20), icon,
                                            tabPosition);
                                } else {
                                    replaceGeneralResultsWith(resultComponent, icon);
                                    resultsTabs.setSelectedTab(generalResultsTab.getComponent());
                                }

                                String statusVal;
                                if (canceled) {
                                    statusVal = "Sql canceled after " + executionTimeInMs + " ms for "
                                            + db.getName() + ".  Finished at "
                                            + SimpleDateFormat.getTimeInstance().format(new Date());
                                } else {
                                    statusVal = "Sql executed in " + executionTimeInMs + " ms for "
                                            + db.getName() + ".  Finished at "
                                            + SimpleDateFormat.getTimeInstance().format(new Date());
                                }
                                status.setValue(statusVal);
                                resultStatuses.put(resultComponent, statusVal);
                                canceled = false;
                            }
                        } finally {
                            setButtonsEnabled();
                            if (executingTab != null) {
                                resultsTabs.removeTab(executingTab);
                            } else if (results.size() > 1) {
                                resetGeneralResultsTab();
                            }
                            runnersInProgress.remove(runner);
                            runner.setListener(null);
                        }
                    }
                });

            }

        });

        final Button cancel = new Button("Cancel");
        cancel.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                log.info("Canceling sql: " + sql);
                label.setValue("Canceling" + label.getValue().substring(9));
                executingLayout.removeComponent(cancel);
                canceled = true;
                new Thread(new Runnable() {
                    @Override
                    public void run() {
                        runner.cancel();
                    }
                }).start();
            }
        });
        executingLayout.addComponent(cancel);

        scheduled = true;
        runner.start();

    }
    setButtonsEnabled();
    return scheduled;
}

From source file:pl.exsio.ca.module.config.preachers.PriviledgesDataTable.java

License:Open Source License

@Override
protected HorizontalLayout decorateControls(HorizontalLayout controls) {
    controls.removeComponent(this.editButton);
    return super.decorateControls(controls);
}