Example usage for com.vaadin.ui VerticalLayout replaceComponent

List of usage examples for com.vaadin.ui VerticalLayout replaceComponent

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout replaceComponent.

Prototype

@Override
    public void replaceComponent(Component oldComponent, Component newComponent) 

Source Link

Usage

From source file:com.cavisson.gui.dashboard.components.controls.CommonParts.java

License:Apache License

Panel loadingIndicators() {
    Panel p = new Panel("Loading Indicator");
    final VerticalLayout content = new VerticalLayout();
    p.setContent(content);//www .j  a  v a  2  s.c  om
    content.setSpacing(true);
    content.setMargin(true);
    content.addComponent(new Label("You can test the loading indicator by pressing the buttons."));

    CssLayout group = new CssLayout();
    group.setCaption("Show the loading indicator for");
    group.addStyleName("v-component-group");
    content.addComponent(group);
    Button loading = new Button("0.8");
    loading.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(loading);

    Button delay = new Button("3");
    delay.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(delay);

    Button wait = new Button("15");
    wait.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
            }
        }
    });
    wait.addStyleName("last");
    group.addComponent(wait);
    Label label = new Label("   seconds", ContentMode.HTML);
    label.setSizeUndefined();
    group.addComponent(label);

    Label spinnerDesc = new Label(
            "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added.");
    spinnerDesc.addStyleName("small");
    spinnerDesc.setCaption("Spinner");
    content.addComponent(spinnerDesc);

    if (!ValoThemeUI.isTestMode()) {
        final Label spinner = new Label();
        spinner.addStyleName("spinner");

        Button showSpinnerButton = new Button("Show spinner", new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                content.replaceComponent(event.getComponent(), spinner);
            }
        });
        content.addComponent(showSpinnerButton);
    }

    return p;
}

From source file:com.etest.valo.CommonParts.java

License:Apache License

Panel loadingIndicators() {
    Panel p = new Panel("Loading Indicator");
    final VerticalLayout content = new VerticalLayout();
    p.setContent(content);/*w  w w.  j a  v  a2 s .c  o m*/
    content.setSpacing(true);
    content.setMargin(true);
    content.addComponent(new Label("You can test the loading indicator by pressing the buttons."));

    CssLayout group = new CssLayout();
    group.setCaption("Show the loading indicator for");
    group.addStyleName("v-component-group");
    content.addComponent(group);
    Button loading = new Button("0.8");
    loading.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(loading);

    Button delay = new Button("3");
    delay.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(delay);

    Button wait = new Button("15");
    wait.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
            }
        }
    });
    wait.addStyleName("last");
    group.addComponent(wait);
    Label label = new Label("   seconds", ContentMode.HTML);
    label.setSizeUndefined();
    group.addComponent(label);

    Label spinnerDesc = new Label(
            "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added.");
    spinnerDesc.addStyleName("small");
    spinnerDesc.setCaption("Spinner");
    content.addComponent(spinnerDesc);

    if (!MainUI.isTestMode()) {
        final Label spinner = new Label();
        spinner.addStyleName("spinner");

        Button showSpinnerButton = new Button("Show spinner", new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                content.replaceComponent(event.getComponent(), spinner);
            }
        });
        content.addComponent(showSpinnerButton);
    }

    return p;
}

From source file:com.rex.components.valo.CommonParts.java

License:Apache License

Panel loadingIndicators() {
    Panel p = new Panel("Loading Indicator");
    final VerticalLayout content = new VerticalLayout();
    p.setContent(content);/*from   w ww.  j  a va 2s.co  m*/
    content.setSpacing(true);
    content.setMargin(true);
    content.addComponent(new Label("You can test the loading indicator by pressing the buttons."));

    CssLayout group = new CssLayout();
    group.setCaption("Show the loading indicator for");
    group.addStyleName("v-component-group");
    content.addComponent(group);
    Button loading = new Button("0.8");
    loading.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(800);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(loading);

    Button delay = new Button("3");
    delay.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
            }
        }
    });
    group.addComponent(delay);

    Button wait = new Button("15");
    wait.addClickListener(new ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                Thread.sleep(15000);
            } catch (InterruptedException e) {
            }
        }
    });
    wait.addStyleName("last");
    group.addComponent(wait);
    Label label = new Label("   seconds", ContentMode.HTML);
    label.setSizeUndefined();
    group.addComponent(label);

    Label spinnerDesc = new Label(
            "The theme also provides a mixin that you can use to include a spinner anywhere in your application. The button below reveals a Label with a custom style name, for which the spinner mixin is added.");
    spinnerDesc.addStyleName("small");
    spinnerDesc.setCaption("Spinner");
    content.addComponent(spinnerDesc);

    if (!ReportEngineUI.isTestMode()) {
        final Label spinner = new Label();
        spinner.addStyleName("spinner");

        Button showSpinnerButton = new Button("Show spinner", new ClickListener() {
            @Override
            public void buttonClick(final ClickEvent event) {
                content.replaceComponent(event.getComponent(), spinner);
            }
        });
        content.addComponent(showSpinnerButton);
    }

    return p;
}

From source file:com.skysql.manager.ui.components.ParametersLayout.java

License:Open Source License

/**
 * Display backup info./* w  ww. j a v  a  2 s . co  m*/
 *
 * @param layout the layout
 * @param record the record
 */
final public void displayBackupInfo(VerticalLayout layout, BackupRecord record) {
    String value;
    String values[] = { (value = record.getNode()) != null ? value : NOT_AVAILABLE,
            (value = record.getLevelAsString()) != null ? value : NOT_AVAILABLE,
            ((record.getLevel() != null) && (record.getLevel().equals(BackupRecord.BACKUP_TYPE_INCREMENTAL))
                    && ((value = record.getParent()) != null)) ? value : "-",
            ((value = record.getState()) != null) && (value = BackupStates.getDescriptions().get(value)) != null
                    ? value
                    : "Invalid",
            (value = record.getSize()) != null ? value : NOT_AVAILABLE };

    GridLayout newBackupInfoGrid = new GridLayout(2, backupLabels.length);
    newBackupInfoGrid.setSpacing(true);

    for (int i = 0; i < backupLabels.length; i++) {
        newBackupInfoGrid.addComponent(new Label(backupLabels[i]), 0, i);
        newBackupInfoGrid.addComponent(new Label(values[i]), 1, i);
    }

    if (backupInfoGrid == null) {
        layout.addComponent(newBackupInfoGrid);
        backupInfoGrid = newBackupInfoGrid;
    } else {
        layout.replaceComponent(backupInfoGrid, newBackupInfoGrid);
        backupInfoGrid = newBackupInfoGrid;
    }

    //      SystemInfo systemInfo = VaadinSession.getCurrent().getAttribute(SystemInfo.class);
    //      LinkedHashMap<String, String> sysProperties = systemInfo.getCurrentSystem().getProperties();
    //      String EIP = sysProperties.get(SystemInfo.PROPERTY_EIP);
    //      if (EIP != null) {
    //         String url = "http://" + EIP + "/consoleAPI/" + record.getLog();
    //         Link newBackupLogLink = new Link("Backup Log", new ExternalResource(url));
    //         newBackupLogLink.setTargetName("_blank");
    //         newBackupLogLink.setDescription("Open backup log in a new window");
    //         newBackupLogLink.setIcon(new ThemeResource("img/externalLink.png"));
    //         newBackupLogLink.addStyleName("icon-after-caption");
    //         if (backupLogLink == null) {
    //            layout.addComponent(newBackupLogLink);
    //            backupLogLink = newBackupLogLink;
    //         } else {
    //            layout.replaceComponent(backupLogLink, newBackupLogLink);
    //            backupLogLink = newBackupLogLink;
    //         }
    //      }
}

From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java

License:Apache License

/**
 * @param aClass/*from w ww . ja v  a2  s  . c om*/
 */
public void showPanel(Class aClass) {
    Panel mainPanel = (Panel) this.mainWindow.getContent();
    HorizontalLayout appLayout = (HorizontalLayout) mainPanel.getContent();
    VerticalLayout mainLayout = (VerticalLayout) appLayout.getComponent(0); // the ApplicationLayout has one component which is the VerticalLayout 'mainLayout'
    IApplicationPanel panel = this.map.get(aClass);
    if (panel != null || !(aClass.equals(this.activePanel.getClass()))) {
        try {
            Log.info("Loading panel");
            /*
             * mainLayout.getComponent(0) = Title
             * mainLayout.getComponent(1) = Menubar
             * mainLayout.getComponent(2) = IApplicationPanel
             */
            ((IApplicationPanel) mainLayout.getComponent(2)).validate(); //make sure it's safe to navigate off the panel (opportunity to save data)
            panel.init(this.theSession, this);
            mainLayout.replaceComponent(mainLayout.getComponent(2), (Component) panel);
            this.activePanel = panel;
        } catch (Exception e) {
            this.mainWindow.getWindow().showNotification(e.getMessage(), e.getMessage(),
                    Notification.TYPE_ERROR_MESSAGE);
        }
    } else
        Log.warning("Panel does not exist");
}

From source file:org.escidoc.browser.ui.view.WikiPageView.java

License:Open Source License

private void buildContentSection(final VerticalLayout vlContentPanel) {
    String content;/*from   ww  w. j  a  v a2 s  . c o m*/
    // controller.getWikiPageContent();

    String[] arrayContent = controller.getWikiPageContent();
    String title = arrayContent[0];
    content = arrayContent[1];

    wikiContent = new Label(controller.parseCreole(content), Label.CONTENT_XHTML);
    controller.getWikiTitle(content);

    wikiContent.setWidth("100%");
    // wikiContent.setHeight("400px");
    wikiContent.addStyleName("wikiarticle");
    // Invisible resources
    txtWikiContent = new TextArea("Wiki Content", content);
    txtWikiContent.setWidth("100%");
    txtWikiContent.setHeight("400px");
    saveContent = new Button("Save");
    saveContent.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            if (txtWikiContent.getValue().toString() != "") {
                controller.getWikiTitle(txtWikiContent.getValue().toString());
                // Create content
                controller.createWikiContent(controller.getWikiTitle(txtWikiContent.getValue().toString()),
                        txtWikiContent.getValue().toString());
                // set Label Content
                wikiContent.setValue(controller.parseCreole(txtWikiContent.getValue().toString()));
                // Swap to Label
                vlContentPanel.replaceComponent(txtWikiContent, wikiContent);
                // Enable Edit Button
                lockPublicStatusbtn.setEnabled(true);
                saveContent.setVisible(false);
            }
        }
    });

    vlContentPanel.addComponent(wikiContent);
    vlContentPanel.addComponent(saveContent);
    saveContent.setVisible(false);

}

From source file:org.hip.vif.forum.register.ui.GroupListRegisterView.java

License:Open Source License

/** Constructor
 *
 * @param inGroups {@link GroupContainer} the groups to display in the table
 * @param inTask {@link RegisterShowListTask} */
public GroupListRegisterView(final GroupContainer inGroups, final RegisterShowListTask inTask) {
    final VerticalLayout lLayout = new VerticalLayout();
    setCompositionRoot(lLayout);/*www.j a  v a2  s.  c o  m*/

    final IMessages lMessages = Activator.getMessages();
    lLayout.setStyleName("vif-table"); //$NON-NLS-1$
    lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-title", //$NON-NLS-1$
            lMessages.getMessage("ui.register.view.title.page")), ContentMode.HTML)); //$NON-NLS-1$

    table = createTable(inGroups, lMessages);
    lLayout.addComponent(table);

    lLayout.addComponent(RiplaViewHelper.createSpacer());
    final Button lButton = new Button(lMessages.getMessage("ui.register.view.button")); //$NON-NLS-1$
    lButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            if (VIFViewHelper.processAction(inGroups)) {
                final Feedback lFeedback = inTask.saveRegisterings();
                // refresh the view, we do this to display the correct number of participants
                final Table lOld = table;
                table = createTable(lFeedback.groups, lMessages);
                lLayout.replaceComponent(lOld, table);
                table.markAsDirty();
                // give feedback
                Notification.show(lFeedback.message, lFeedback.notificationType);
            }
        }
    });
    lLayout.addComponent(lButton);
}