Example usage for com.vaadin.ui Layout addComponent

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

Introduction

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

Prototype

public void addComponent(Component c);

Source Link

Document

Adds the component into this container.

Usage

From source file:org.eclipse.skalli.view.ext.InfoBoxBase.java

License:Open Source License

protected void createLabel(Layout layout, String caption, String styleName) {
    Label label = new Label(caption, Label.CONTENT_XHTML);
    if (StringUtils.isNotBlank(styleName)) {
        label.addStyleName(styleName);//from ww  w . j  a  v a2  s.  c  o  m
    } else {
        label.addStyleName(STYLE_LABEL);
    }
    layout.addComponent(label);
}

From source file:org.eclipse.skalli.view.ext.InfoBoxBase.java

License:Open Source License

protected void createLink(Layout layout, String caption, Resource resource, String targetName,
        String styleName) {/*from w  w  w  .  j  a  v a2  s  .  com*/
    Link link = new Link(caption, resource);
    if (StringUtils.isNotBlank(targetName)) {
        link.setTargetName(targetName);
    } else {
        link.setTargetName(DEFAULT_TARGET);
    }
    if (StringUtils.isNotBlank(styleName)) {
        link.addStyleName(styleName);
    } else {
        link.addStyleName(STYLE_LINK);
    }
    layout.addComponent(link);
}

From source file:org.eclipse.skalli.view.ext.InfoBoxBase.java

License:Open Source License

protected void addLastModifiedInfo(Layout layout, String caption, String lastModified, String lastModifiedBy) {
    if (lastModified == null) {
        return;//from  w w  w  . j a  v  a2  s  .  co  m
    }

    StringBuilder sb = new StringBuilder();
    sb.append("<span style=\"font-size:x-small\">");

    if (StringUtils.isNotBlank(caption)) {
        sb.append(caption);
    } else {
        sb.append(LAST_MODIFIED);
    }
    sb.append(" ");
    sb.append(lastModified);
    if (StringUtils.isNotBlank(lastModifiedBy)) {
        sb.append(" by ").append(lastModifiedBy);
    }
    sb.append("</span>");

    Label label = asLabel(sb.toString());
    label.setStyleName("light");
    label.addStyleName(STYLE_LABEL);
    layout.addComponent(label);
}

From source file:org.eclipse.skalli.view.internal.window.ProjectDetailsPanel.java

License:Open Source License

private Component getInternalErrorContent() {
    Layout errorContent = new CssLayout();
    errorContent.setSizeFull();/*  www.java 2  s. c  o m*/
    Label label = new Label("Internal Error: The extension content cannot be displayed. "
            + "An internal error occurred. Please notify the administrator.", Label.CONTENT_XHTML);
    label.addStyleName("infobox-internalerror");
    errorContent.addComponent(label);
    return errorContent;
}

From source file:org.example.skalli.ext.helloworld.ui.ExtensionServiceProjectHelloWorldBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    HelloWorldProjectExt ext = project.getExtension(HelloWorldProjectExt.class);

    Layout layout = new CssLayout();
    layout.setSizeFull();/*from w ww.jav a  2 s  . co m*/

    layout.addComponent(new Label(ext.getName() + " greets the following friends: "));

    for (String friend : ext.getFriends()) {
        layout.addComponent(new Label("Hello " + friend + "!"));
    }

    return layout;
}

From source file:org.example.skalli.ext.simplehelloworld.ui.ExtensionServiceProjectHelloWorldBox.java

License:Open Source License

@Override
public Component getContent(Project project, ExtensionUtil util) {
    Layout layout = new CssLayout();
    layout.setSizeFull();/*  w w  w  .j a  v  a2  s. co  m*/
    layout.addComponent(new Label("The project you are viewing is called \"" + project.getName() + "\"."));

    return layout;
}

From source file:org.hip.vif.app.admin.AdminApplication.java

License:Open Source License

@Override
protected boolean beforeLogin(final IWorkflowListener inWorkflowListener, final Layout inBodyView, // NOPMD
        final IAppConfiguration inConfiguration) {
    final DBConnectionProber lProber = new DBConnectionProber();
    try {/*from  w w  w  . j av a 2  s.  co  m*/
        if (lProber.needsDBConfiguration()) {
            inBodyView.addComponent(getDftView(inConfiguration));
            DBAccessWorkflow.getInitialWorkflow(inWorkflowListener, getUserAdmin()).startWorkflow();
            return false;
        } else if (lProber.needsTableCreation()) {
            inBodyView.addComponent(getDftView(inConfiguration));
            DBAccessWorkflow.getInitialTblCreation(inWorkflowListener, getUserAdmin()).startWorkflow();
            return false;
        } else if (lProber.needsSUCreation()) {
            inBodyView.addComponent(getDftView(inConfiguration));
            DBAccessWorkflow.getCreateSUWorkflow(inWorkflowListener).startWorkflow();
            return false;
        } else if (lProber.isUndefined()) {
            LOG.error("Undefined problem encountered while trying to access the DB connection!"); //$NON-NLS-1$
            Notification.show(Activator.getMessages().getMessage("errmsg.init.dbaccess"), Type.ERROR_MESSAGE); //$NON-NLS-1$
        }
    } catch (BOMException | SQLException exc) {
        LOG.error("Error encountered while creating the SU record!", exc);
        Notification.show(Activator.getMessages().getMessage("errmsg.init.configuration"), Type.ERROR_MESSAGE); //$NON-NLS-1$
    } catch (final WorkflowException exc) {
        LOG.error("Error encountered during initial DB access configuration!", exc); //$NON-NLS-1$
        Notification.show(Activator.getMessages().getMessage("errmsg.init.configuration"), Type.ERROR_MESSAGE); //$NON-NLS-1$
    }
    return true;
}

From source file:org.jpos.qi.eeuser.UsersView.java

License:Open Source License

@Override
protected void addFields(Layout l) {
    super.addFields(l);
    selectedU = getInstance();//from  w  ww .  j ava  2s. c  om
    if (getInstance().getId() != null && getInstance().getId().equals(getApp().getUser().getId())) {
        changePassBtn = createChangePasswordButton();
        l.addComponents(changePassBtn, createPasswordPanel());
    }
    if (getInstance().hasPermission("sysadmin") && !isNewView()) {
        resetPassBtn = createResetPasswordButton();
        l.addComponent(resetPassBtn);
    }
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

public void showSpecificView(final String parameter) {
    Object o = null;/*from   w ww  .  ja  v a  2s  . com*/
    String[] params = parameter.split("/|\\?");
    if (params.length > 0) {
        if ("new".equals(params[0]) && canAdd()) {
            o = createNewEntity();
            newView = true;
        } else {
            o = getEntityByParam(params[0]);
        }
        if (parameter.contains("?")) {
            //Has query params.
            String[] queryParams = params[params.length - 1].split(",");
            for (String queryParam : queryParams) {
                String[] keyValue = queryParam.split("=");
                if (keyValue.length > 0 && "back".equals(keyValue[0])) {
                    setGeneralRoute("/" + keyValue[1].replace(".", "/"));
                }
            }
        }
    }
    if (o == null) {
        getApp().getNavigator().navigateTo("");
        getApp().displayNotification(getApp().getMessage("errorMessage.notExists",
                "<strong>" + getEntityName().toUpperCase() + "</strong>: " + params[0]));
        return;
    }
    Layout header = createHeader(title + ": " + getHeaderSpecificTitle(o));
    addComponent(header);
    Panel panel = new Panel();
    panel.setSizeFull();
    addComponent(panel);
    final Layout formLayout = createForm(o, params, "new".equals(params[0]));
    panel.setContent(formLayout);
    setExpandRatio(panel, 1);
    if (!"new".equals(params[0]) && isShowRevisionHistoryButton()) {
        final Button showRevision = new Button(getApp().getMessage("showRevisionHistory"));
        showRevision.setStyleName(ValoTheme.BUTTON_LINK);
        showRevision.addClickListener(event -> {
            if (getApp().getMessage("showRevisionHistory").equals(event.getButton().getCaption())) {
                event.getButton().setCaption(getApp().getMessage("hideRevisionHistory"));
                loadRevisionHistory(formLayout, getEntityName().toLowerCase() + "." + params[0]);
            } else {
                event.getButton().setCaption(getApp().getMessage("showRevisionHistory"));
                formLayout.removeComponent(revisionsPanel);
            }
        });
        formLayout.addComponent(showRevision);
    }
}

From source file:org.jpos.qi.QIEntityView.java

License:Open Source License

public Layout createForm(final Object entity, String[] params, boolean isNew) {
    VerticalLayout profileLayout = new VerticalLayout();
    profileLayout.setMargin(true);//from w  w  w.  j  a v  a  2  s .co  m
    profileLayout.setSpacing(true);

    //Add Back Button
    if (params.length <= 1 || !"profile".equals(params[1])) {
        Button back = new Button(getApp().getMessage("back"));
        back.addStyleName("borderless-colored");
        back.setIcon(VaadinIcons.ARROW_LEFT);
        back.addClickListener(event -> app.getNavigator().navigateTo(getGeneralRoute()));
        profileLayout.addComponent(back);
        profileLayout.setComponentAlignment(back, Alignment.MIDDLE_LEFT);
    }

    binder = new Binder<T>(clazz) {
        @Override
        public void setReadOnly(boolean readOnly) {
            super.setReadOnly(readOnly);
            if (readOnlyFields != null) {
                for (String fieldId : readOnlyFields) {
                    if (binder.getBinding(fieldId).isPresent()) {
                        HasValue field = binder.getBinding(fieldId).get().getField();
                        if ((field != null && !field.isEmpty()) || !field.isRequiredIndicatorVisible()) {
                            field.setReadOnly(true);
                            binder.bind(field, fieldId);
                        }
                    }

                }
            }
        }
    };
    bean = (T) entity;
    final Layout formLayout = createLayout();
    getHelper().setOriginalEntity(bean);
    binder.readBean((T) entity);
    binder.setReadOnly(true);
    profileLayout.addComponent(formLayout);

    HorizontalLayout footer = new HorizontalLayout();
    footer.addStyleName("footer");
    footer.setMargin(new MarginInfo(true, false, false, false));
    footer.setSpacing(true);
    formLayout.addComponent(footer);

    //Add Save, Remove & Cancel Buttons
    editBtn = new Button(app.getMessage("edit"));
    removeBtn = new Button(app.getMessage("remove"));
    saveBtn = new Button(app.getMessage("save"));
    cancelBtn = new Button(app.getMessage("cancel"));

    editBtn.addClickListener(event -> editClick(event, formLayout));
    editBtn.addStyleName("icon-edit");

    saveBtn.addClickListener(event -> saveClick(event, formLayout));
    saveBtn.setVisible(false);
    saveBtn.setStyleName("icon-ok");
    saveBtn.setClickShortcut(ShortcutAction.KeyCode.ENTER);

    removeBtn.addClickListener(event -> app.addWindow(new ConfirmDialog(app.getMessage("confirmTitle"),
            app.getMessage("removeConfirmationMessage"), confirm -> {
                if (confirm) {
                    removeEntity();
                }
            })));
    removeBtn.addStyleName("icon-trash");

    cancelBtn.addClickListener(event -> {
        if (isNew) {
            app.getNavigator().navigateTo(getGeneralRoute());
        } else {
            cancelClick(event, formLayout);
        }
    });

    cancelBtn.setClickShortcut(ShortcutAction.KeyCode.ESCAPE);
    cancelBtn.setVisible(false);
    cancelBtn.addStyleName("icon-cancel");

    if (canEdit()) {
        footer.addComponent(editBtn);
        footer.addComponent(saveBtn);
        footer.addComponent(cancelBtn);
        footer.setComponentAlignment(editBtn, Alignment.MIDDLE_RIGHT);
        footer.setComponentAlignment(saveBtn, Alignment.MIDDLE_RIGHT);
        footer.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT);
    }
    if (canRemove()) {
        footer.addComponent(removeBtn);
        footer.setComponentAlignment(removeBtn, Alignment.MIDDLE_RIGHT);
    }
    if (isNew) {
        editBtn.click();
    }
    errorLabel = new Label();
    errorLabel.setVisible(false);
    errorLabel.setStyleName(ValoTheme.LABEL_FAILURE);
    profileLayout.addComponent(errorLabel);
    return profileLayout;
}