Example usage for com.vaadin.ui GridLayout addComponent

List of usage examples for com.vaadin.ui GridLayout addComponent

Introduction

In this page you can find the example usage for com.vaadin.ui GridLayout addComponent.

Prototype

@Override
public void addComponent(Component component) 

Source Link

Document

Adds the component into this container to the cursor position.

Usage

From source file:io.subutai.plugin.accumulo.ui.manager.AddNodeWindow.java

public AddNodeWindow(final Accumulo accumulo, final ExecutorService executorService, final Tracker tracker,
        final AccumuloClusterConfig accumuloClusterConfig, Set<EnvironmentContainerHost> nodes,
        final NodeType nodeType) {
    super("Add New Node");
    setModal(true);// ww w  .j  a va2 s  .  c  o m

    setWidth(650, Unit.PIXELS);
    setHeight(450, Unit.PIXELS);

    GridLayout content = new GridLayout(1, 3);
    content.setSizeFull();
    content.setMargin(true);
    content.setSpacing(true);

    HorizontalLayout topContent = new HorizontalLayout();
    topContent.setSpacing(true);

    content.addComponent(topContent);
    topContent.addComponent(new Label("Nodes:"));

    final ComboBox hadoopNodes = new ComboBox();
    hadoopNodes.setId("HadoopNodesCb");
    hadoopNodes.setImmediate(true);
    hadoopNodes.setTextInputAllowed(false);
    hadoopNodes.setNullSelectionAllowed(false);
    hadoopNodes.setRequired(true);
    hadoopNodes.setWidth(200, Unit.PIXELS);
    for (EnvironmentContainerHost node : nodes) {
        hadoopNodes.addItem(node);
        hadoopNodes.setItemCaption(node, node.getHostname());
    }

    if (nodes.size() == 0) {
        return;
    }
    hadoopNodes.setValue(nodes.iterator().next());

    topContent.addComponent(hadoopNodes);

    final Button addNodeBtn = new Button("Add");
    addNodeBtn.setId("AddSelectedNode");
    topContent.addComponent(addNodeBtn);

    final Button ok = new Button("Ok");

    addNodeBtn.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            addNodeBtn.setEnabled(false);
            ok.setEnabled(false);
            showProgress();
            EnvironmentContainerHost containerHost = (EnvironmentContainerHost) hadoopNodes.getValue();
            final UUID trackID = accumulo.addNode(accumuloClusterConfig.getClusterName(),
                    containerHost.getHostname(), nodeType);
            executorService.execute(new Runnable() {
                public void run() {
                    while (track) {
                        TrackerOperationView po = tracker.getTrackerOperation(AccumuloClusterConfig.PRODUCT_KEY,
                                trackID);
                        if (po != null) {
                            setOutput(po.getDescription() + "\nState: " + po.getState() + "\nLogs:\n"
                                    + po.getLog());
                            if (po.getState() != OperationState.RUNNING) {
                                hideProgress();
                                ok.setEnabled(true);
                                break;
                            }
                        } else {
                            setOutput("Product operation not found. Check logs");
                            break;
                        }
                        try {
                            Thread.sleep(1000);
                        } catch (InterruptedException ex) {
                            break;
                        }
                    }
                }
            });
        }
    });

    outputTxtArea = new TextArea("Operation output");
    outputTxtArea.setId("outputTxtArea");
    outputTxtArea.setRows(13);
    outputTxtArea.setColumns(43);
    outputTxtArea.setImmediate(true);
    outputTxtArea.setWordwrap(true);

    content.addComponent(outputTxtArea);

    indicator = new Label();
    indicator.setId("indicator");
    indicator.setIcon(new ThemeResource("img/spinner.gif"));
    indicator.setContentMode(ContentMode.HTML);
    indicator.setHeight(11, Unit.PIXELS);
    indicator.setWidth(50, Unit.PIXELS);
    indicator.setVisible(false);

    ok.setId("btnOk");
    ok.setStyleName("default");
    ok.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            //close window
            track = false;
            close();
        }
    });

    HorizontalLayout bottomContent = new HorizontalLayout();
    bottomContent.addComponent(indicator);
    bottomContent.setComponentAlignment(indicator, Alignment.MIDDLE_RIGHT);
    bottomContent.addComponent(ok);

    content.addComponent(bottomContent);
    content.setComponentAlignment(bottomContent, Alignment.MIDDLE_RIGHT);

    setContent(content);
}

From source file:kn.uni.gis.ui.DownloadWindow.java

License:Apache License

private Component downloadComponent() {
    GridLayout layout = new GridLayout(2, 2);

    String baseUrl = getApplication().getURL().toString();
    StringBuilder b = new StringBuilder(getApplication().getURL().toString());
    b.replace(baseUrl.lastIndexOf("ui"), baseUrl.lastIndexOf("ui") + 2, "game");

    QRCode code = new QRCode("", b.toString());
    layout.addComponent(code);

    return layout;
}

From source file:module.pandabox.presentation.PandaBox.java

License:Open Source License

private void initView() {
    setCompositionRoot(root);/*from   ww w.  j  a  va 2 s.c o  m*/
    root.setSizeFull();
    root.setSplitPosition(15);
    root.setStyleName("small previews");

    previewArea.setWidth("100%");
    previewTabs = new VerticalLayout();
    previewTabs.setSizeFull();
    previewTabs.setHeight(null);

    compoundTabs = new VerticalLayout();
    compoundTabs.setSizeFull();
    compoundTabs.setHeight(null);

    bennuStylesTabs = new VerticalLayout();
    bennuStylesTabs.setSizeFull();
    bennuStylesTabs.setHeight(null);

    VerticalLayout menu = new VerticalLayout();
    menu.setSizeFull();
    menu.setStyleName("sidebar-menu");

    Button syncThemes = new Button("Sync Themes", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            syncThemes();
        }
    });
    menu.addComponent(syncThemes);
    menu.addComponent(new Label("Single Components"));
    menu.addComponent(previewTabs);
    menu.addComponent(new Label("Compound Styles"));
    menu.addComponent(compoundTabs);

    menu.addComponent(new Label("Bennu Styles"));
    menu.addComponent(bennuStylesTabs);

    root.setFirstComponent(menu);

    CssLayout toolbar = new CssLayout();
    toolbar.setWidth("100%");
    toolbar.setStyleName("toolbar");
    toolbar.addComponent(editorToggle);

    final Window downloadWindow = new Window("Download Theme");
    GridLayout l = new GridLayout(3, 2);
    l.setSizeUndefined();
    l.setMargin(true);
    l.setSpacing(true);
    downloadWindow.setContent(l);
    downloadWindow.setModal(true);
    downloadWindow.setResizable(false);
    downloadWindow.setCloseShortcut(KeyCode.ESCAPE, null);
    downloadWindow.addStyleName("opaque");
    Label caption = new Label("Theme Name");
    l.addComponent(caption);
    l.setComponentAlignment(caption, Alignment.MIDDLE_CENTER);
    final TextField name = new TextField();
    name.setValue("my-chameleon");
    name.addValidator(new RegexpValidator("[a-zA-Z0-9\\-_\\.]+", "Only alpha-numeric characters allowed"));
    name.setRequired(true);
    name.setRequiredError("Please give a name for the theme");
    downloadWindow.addComponent(name);
    Label info = new Label(
            "This is the name you will use to set the theme in your application code, i.e. <code>setTheme(\"my-cameleon\")</code>.",
            Label.CONTENT_XHTML);
    info.addStyleName("tiny");
    info.setWidth("200px");
    l.addComponent(info, 1, 1, 2, 1);

    Button download = new Button(null, new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            getApplication().getMainWindow().addWindow(downloadWindow);
            name.focus();
        }
    });
    download.setDescription("Donwload the current theme");
    download.setIcon(new ThemeResource("download.png"));
    download.setStyleName("icon-only");
    toolbar.addComponent(download);

    menu.addComponent(toolbar);
    menu.setExpandRatio(toolbar, 1);
    menu.setComponentAlignment(toolbar, Alignment.BOTTOM_CENTER);

}

From source file:org.abstractform.vaadin.VaadinFormToolkit.java

License:Apache License

private AbstractComponentContainer buildSubForm(SubForm subForm, Map<String, AbstractComponent> mapComponents,
        List<String> fieldIdList, Map<String, Object> extraObjects) {
    //panel.setCaption(formEditor.getName());
    GridLayout layout = new GridLayout(subForm.getColumns(), subForm.getRows());
    layout.setWidth("100%");
    layout.setSpacing(true);/*from www  . j  av  a 2  s.c  o  m*/
    for (int row = 0; row < subForm.getRows(); row++) {
        for (int column = 0; column < subForm.getColumns(); column++) {
            Component component = subForm.getField(row, column);
            if (component == null) {
                layout.addComponent(new Label("&nbsp;", Label.CONTENT_XHTML));
            } else if (component instanceof Field) {
                Field editor = (Field) component;
                if (editor != null) {
                    layout.addComponent(buildField(editor, mapComponents, fieldIdList, extraObjects));
                }
            } else {
                buildComponent(component, mapComponents, fieldIdList, extraObjects);
            }
        }
    }
    return layout;
}

From source file:org.activiti.explorer.ui.management.identity.UserDetailPanel.java

License:Apache License

protected void addUserDetail(GridLayout detailLayout, String detail, Component value) {
    Label label = new Label(detail + ": ");
    label.addStyleName(ExplorerLayout.STYLE_LABEL_BOLD);
    detailLayout.addComponent(label);
    detailLayout.addComponent(value);//from  w w  w.j a  va  2s  . c om
}

From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java

License:Apache License

protected void initNameField(GridLayout layout) {
    nameField = new TextField();
    nameField.setWriteThrough(true);//from w  ww  .ja  v a 2  s.com
    nameField.setImmediate(true);

    layout.addComponent(new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_NAME)));
    layout.addComponent(nameField);
    if (workflowName != null) {
        nameField.setValue(workflowName);
        workflowName = null;
    }
}

From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java

License:Apache License

protected void initDescriptionField(GridLayout layout) {
    descriptionField = new TextField();
    descriptionField.setRows(4);//from   www .  j  av a2s . com
    descriptionField.setColumns(35);
    descriptionField.addStyleName(ExplorerLayout.STYLE_TEXTAREA_NO_RESIZE);
    layout.addComponent(
            new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_DESCRIPTION)));
    layout.addComponent(descriptionField);

    if (description != null) {
        descriptionField.setValue(description);
        description = null;
    }
}

From source file:org.activiti.explorer.ui.process.simple.editor.SimpleTableEditor.java

License:Apache License

protected void initTaskTable(GridLayout layout) {
    taskTable = new TaskTable();

    // Add existing tasks in case we're editing
    if (workflowDefinition != null) {
        loadTaskRows(workflowDefinition, taskTable);
    } else {/*from   ww w . j  a v a  2s  . c  om*/
        taskTable.addDefaultTaskRow();
    }

    layout.addComponent(
            new Label(ExplorerApp.get().getI18nManager().getMessage(Messages.PROCESS_EDITOR_TASKS)));
    layout.addComponent(taskTable);
}

From source file:org.activiti.explorer.ui.profile.ProfilePanel.java

License:Apache License

protected void initContactSection() {
    Label header = createProfileHeader(infoPanelLayout, i18nManager.getMessage(Messages.PROFILE_CONTACT));
    header.addStyleName(ExplorerLayout.STYLE_H3);
    header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    infoPanelLayout.addComponent(header);

    GridLayout contactLayout = createInfoSectionLayout(2, 4);
    // Email/*from  w  ww.  j  av a  2s. c  om*/
    if (!editable && isDefined(user.getEmail())) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), user.getEmail());
    } else if (editable) {
        emailField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_EMAIL), emailField,
                user.getEmail());
    }

    // Phone
    if (!editable && isDefined(phone)) {
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phone);
    } else if (editable) {
        phoneField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_PHONE), phoneField, phone);
    }

    // Twitter
    if (!editable && isDefined(twitterName)) {
        Link twitterLink = new Link(twitterName, new ExternalResource("http://www.twitter.com/" + twitterName));
        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterLink);
    } else if (editable) {
        twitterField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_TWITTER), twitterField,
                twitterName);
    }

    // Skype
    if (!editable && isDefined(skypeId)) {
        // The skype entry shows the name + skype icon, laid out in a small grid
        GridLayout skypeLayout = new GridLayout(2, 1);
        skypeLayout.setSpacing(true);
        skypeLayout.setSizeUndefined();

        Label skypeIdLabel = new Label(skypeId);
        skypeIdLabel.setSizeUndefined();
        skypeLayout.addComponent(skypeIdLabel);

        addProfileEntry(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeLayout);
    } else if (editable) {
        skypeField = new TextField();
        addProfileInputField(contactLayout, i18nManager.getMessage(Messages.PROFILE_SKYPE), skypeField,
                skypeId);
    }
}

From source file:org.activiti.explorer.ui.task.TaskEventsPanel.java

License:Apache License

protected void addTaskEventPicture(final org.activiti.engine.task.Event taskEvent, GridLayout eventGrid) {
    final Picture userPicture = identityService.getUserPicture(taskEvent.getUserId());
    Embedded authorPicture = null;//from  w ww .ja v a  2  s  .c o  m

    if (userPicture != null) {
        StreamResource imageresource = new StreamResource(new StreamSource() {
            private static final long serialVersionUID = 1L;

            public InputStream getStream() {
                return userPicture.getInputStream();
            }
        }, "event_" + taskEvent.getUserId() + "."
                + Constants.MIMETYPE_EXTENSION_MAPPING.get(userPicture.getMimeType()), ExplorerApp.get());
        authorPicture = new Embedded(null, imageresource);
    } else {
        authorPicture = new Embedded(null, Images.USER_50);
    }

    authorPicture.setType(Embedded.TYPE_IMAGE);
    authorPicture.setHeight("48px");
    authorPicture.setWidth("48px");
    authorPicture.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_PICTURE);
    eventGrid.addComponent(authorPicture);
}