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:com.klwork.explorer.ui.user.ProfilePanel.java

License:Apache License

protected void addProfileInputField(GridLayout layout, String name, AbstractField inputField,
        String inputFieldValue) {
    Label label = new Label(name + ": ");
    label.addStyleName(ExplorerLayout.STYLE_PROFILE_FIELD);
    label.setSizeUndefined();//from   w w w .j  a v a  2 s  .  c  om
    layout.addComponent(label);
    layout.setComponentAlignment(label, Alignment.MIDDLE_LEFT);

    if (inputFieldValue != null) {
        inputField.setValue(inputFieldValue);
    }
    layout.addComponent(inputField);
    layout.setComponentAlignment(inputField, Alignment.MIDDLE_LEFT);
}

From source file:com.klwork.explorer.ui.user.UserEventsPanel.java

License:Apache License

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

    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()));
        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);
}

From source file:com.klwork.explorer.ui.user.UserEventsPanel.java

License:Apache License

protected void addTaskEventText(final org.activiti.engine.task.Event taskEvent, final GridLayout eventGrid) {
    VerticalLayout layout = new VerticalLayout();
    layout.addStyleName(ExplorerLayout.STYLE_TASK_EVENT);
    layout.setWidth("100%");
    eventGrid.addComponent(layout);

    // Actual text
    Label text = taskEventTextResolver.resolveText(taskEvent);
    text.setWidth("100%");
    layout.addComponent(text);//from   w  w  w. j a va  2s  .c om

    // Time
    String humFormat = new HumanTime(i18nManager).format(taskEvent.getTime());
    Label time = new Label(humFormat + " (" + StringDateUtil.dateToString(taskEvent.getTime(), 4) + ")");
    time.setSizeUndefined();
    time.addStyleName(ExplorerLayout.STYLE_TASK_EVENT_TIME);
    layout.addComponent(time);

}

From source file:com.liferay.mail.vaadin.PreferencesView.java

License:Open Source License

private void updateAccountList() {

    try {/*ww w.j a  va  2 s .c  o  m*/
        accountPanel.removeAllComponents();

        List<Account> accounts = controller.getAccountManager().getAccounts(controller.getUser());
        if (accounts.size() > 0) {
            GridLayout grid = new GridLayout(3, accounts.size());
            grid.setSpacing(true);
            for (final Account account : accounts) {
                grid.addComponent(new Label(account.getAddress()));

                Button editButton = new Button(Lang.get("edit-account"));
                editButton.setStyleName("small");
                editButton.addListener(new ClickListener() {

                    public void buttonClick(ClickEvent event) {

                        editAccount(account);
                    }
                });
                grid.addComponent(editButton);

                Button deleteButton = new Button(Lang.get("delete-account"));
                deleteButton.setStyleName("small");
                deleteButton.addListener(new ClickListener() {

                    public void buttonClick(ClickEvent event) {

                        deleteAccount(account);
                    }
                });
                grid.addComponent(deleteButton);
            }
            accountPanel.addComponent(grid);
        }
    } catch (SystemException e) {
        // unable to read account information
        controller.showUnexpectedError(e);
    }
}

From source file:com.logicbomb.newschool.MyAppWidgetSet.core.DayWidget.java

public DayWidget() {

    //Creating Panel
    Panel iPanel = new Panel();
    iPanel.addStyleName("backColorWhite");
    iPanel.setWidth("876px");
    iPanel.setHeight("41px");

    ProgressBar iDayProgressBar = new ProgressBar();
    iDayProgressBar.setCaption("Period 3, 10th October");
    iDayProgressBar.setWidth("875px");
    iDayProgressBar.setValue(0.3f);/* w w w. ja  va 2s .  co  m*/
    addComponent(iDayProgressBar);

    //Adding Panel to Vertical Layout
    addComponent(iPanel);
    VerticalLayout iVerticalLayout = new VerticalLayout();

    GridLayout iGridLayout = new GridLayout(9, 1);
    iGridLayout.setWidth("1000px");
    iGridLayout.setHeight("40px");

    for (int i = 1; i <= 8; i++) {

        HourWidget iHourAtAGlanceWidget = new HourWidget(i, 8);
        iHourAtAGlanceWidget.setSizeFull();
        iGridLayout.addComponent(iHourAtAGlanceWidget);
        iGridLayout.setColumnExpandRatio(i, 1);
    }

    iVerticalLayout.addComponent(iGridLayout);
    iPanel.setContent(iVerticalLayout);

}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java

License:Open Source License

private Component createProcessInfo(LspsUI ui) {
    ModelInstanceInfo instance = processService.getModelInstanceInfo(todo.getModelInstanceId());

    GridLayout grid = new GridLayout(2, 10);
    grid.setMargin(true);/* w w w .j  a  va  2s.c  om*/
    grid.setSpacing(true);
    grid.setWidth("100%");
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);

    grid.addComponent(new Label(ui.getMessage("process.id")));
    grid.addComponent(new Label(String.valueOf(instance.getId())));

    grid.addComponent(new Label(ui.getMessage("process.model")));
    grid.addComponent(new Label(instance.getModelName() + " - " + instance.getModelVersion()));

    grid.addComponent(new Label(ui.getMessage("process.started")));
    grid.addComponent(new Label(
            new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getStartedDate())));

    grid.addComponent(new Label(ui.getMessage("process.finished")));
    grid.addComponent(new Label(instance.getFinishedDate() == null ? ""
            : new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(instance.getFinishedDate())));

    String status = "???";
    switch (instance.getState()) {
    case CREATED:
        status = ui.getMessage("process.statusCreated");
        break;
    case FINISHED:
        status = ui.getMessage("process.statusFinished");
        break;
    case RUNNING:
        status = ui.getMessage("process.statusRunning");
        break;
    case SUSPENDED:
        status = ui.getMessage("process.statusSuspended");
        break;
    case MODEL_UPDATE_PREPROCESSING:
        status = ui.getMessage("process.statusPreprocessing");
        break;
    case MODEL_UPDATE_PREPROCESSED:
        status = ui.getMessage("process.statusPreprocessed");
        break;
    case MODEL_UPDATE_TRANSFORMED:
        status = ui.getMessage("process.statusTransformed");
        break;
    case MODEL_UPDATE_POSTPROCESSING:
        status = ui.getMessage("process.statusPostprocessing");
        break;
    case MODEL_UPDATE_UPDATED:
        status = ui.getMessage("process.statusUpdated");
        break;
    case MODEL_UPDATE_ABORTED:
        status = ui.getMessage("process.statusUpdateAborted");
        break;
    }
    grid.addComponent(new Label(ui.getMessage("process.status")));
    grid.addComponent(new Label(status));

    return grid;
}

From source file:com.lst.deploymentautomation.vaadin.popup.TodoDetails.java

License:Open Source License

private Component createTodoInfo(LspsUI ui) {
    GridLayout grid = new GridLayout(2, 10);
    grid.setMargin(true);/*from  www .j a va  2s.  c o  m*/
    grid.setSpacing(true);
    grid.setWidth("100%");
    grid.setColumnExpandRatio(0, 1);
    grid.setColumnExpandRatio(1, 2);

    grid.addComponent(new Label(ui.getMessage("todo.id")));
    grid.addComponent(new Label(String.valueOf(todo.getId())));

    //      grid.addComponent(new Label(ui.getMessage("todo.process")));
    //      grid.addComponent(new Label(String.valueOf(todo.getModelInstanceId())));

    //      grid.addComponent(new Label(ui.getMessage("todo.title")));
    //      grid.addComponent(new Label(ui.localizeEngineText(todo.getTitle())));

    grid.addComponent(new Label(ui.getMessage("todo.task")));
    grid.addComponent(new Label(todo.getTaskNamespace()));

    grid.addComponent(new Label(ui.getMessage("todo.issued")));
    grid.addComponent(
            new Label(new SimpleDateFormat(ui.getMessage("app.dateTimeFormat")).format(todo.getIssuedDate())));

    String status = "???";
    switch (todo.getStatus()) {
    case ALIVE:
        status = ui.getMessage("todo.statusAlive");
        break;
    case ACCOMPLISHED:
        status = ui.getMessage("todo.statusAccomplished", todo.getSubmittedDate());
        break;
    case INTERRUPTED:
        status = ui.getMessage("todo.statusInterrupted", todo.getSubmittedDate(), todo.getInterruptionReason());
        break;
    case SUSPENDED:
        status = ui.getMessage("todo.statusSuspended");
        break;
    }
    grid.addComponent(new Label(ui.getMessage("todo.status")));
    grid.addComponent(new Label(status));

    try {
        TodoAuthorization authorization = todoService.getAuthorization(todo.getId(),
                ui.getUser().getPerson().getId());
        String authMsg;
        switch (authorization) {
        case INITIAL_PERFORMER:
            authMsg = ui.getMessage("todo.authorizationPerformer");
            break;
        case DELEGATE:
            authMsg = ui.getMessage("todo.authorizationDelegate");
            break;
        case SUBSTITUTE:
            authMsg = ui.getMessage("todo.authorizationSubstitute");
            break;
        case NOT_PERMITTED:
        default:
            authMsg = ui.getMessage("todo.authorizationUnknown");
            break;
        }
        grid.addComponent(new Label(ui.getMessage("todo.authorization")));
        grid.addComponent(new Label(authMsg));
    } catch (Exception e) {
        Utils.rethrow(e, "could not get authorization for " + todo.getId(), log);
    }

    //currently it's always the current user; no need to show him
    //      grid.addComponent(new Label(ui.getMessage("todo.responsible")));
    //      grid.addComponent(new Label(todo.getAllocatedToFullName()));

    return grid;
}

From source file:com.m4gik.views.component.LibraryScreen.java

/**
 * This method builds audio library for current filter.
 * /*from  w  w w  . j a v a  2 s .c  om*/
 * @param grid
 *            The object to locate the audio covers.
 * @param filter
 *            The filter to extract need music files.
 */
private void buildAudioLibrary(GridLayout grid, String filter) {
    AudioCollection audio = new AudioCollection();

    for (final AudioFile audioFile : audio.getAudioCollection(filter)) {

        CssLayout select = new CssLayout();
        select.addStyleName(Runo.CSSLAYOUT_SELECTABLE);

        CssLayout musicFile = new CssLayout();
        musicFile.addStyleName(Runo.CSSLAYOUT_SHADOW);
        musicFile.addComponent(createImageCover(audioFile.getCover()));
        select.addComponent(musicFile);

        musicFile.addLayoutClickListener(new LayoutClickListener() {

            private static final long serialVersionUID = 5789650754220216969L;

            @Override
            public void layoutClick(LayoutClickEvent event) {
                buildInformationPanel(audioFile);
            }
        });

        grid.addComponent(select);
        grid.setComponentAlignment(select, Alignment.MIDDLE_CENTER);
    }

    Label text = new Label("Note: This track are on Crative Common license.");
    text.addStyleName(Runo.LABEL_SMALL);
    text.setWidth("90%");
    grid.addComponent(text);
    grid.setComponentAlignment(text, Alignment.MIDDLE_CENTER);

}

From source file:com.mycollab.vaadin.web.ui.MailFormWindow.java

License:Open Source License

private void initUI() {
    GridLayout mainLayout = new GridLayout(1, 5);
    mainLayout.setWidth("100%");
    mainLayout.setMargin(true);/*from ww  w .j av  a 2  s . c o m*/
    mainLayout.setSpacing(true);

    CssLayout inputPanel = new CssLayout();
    inputPanel.setWidth("100%");
    inputPanel.setStyleName("mail-panel");

    inputLayout = new GridLayout(3, 4);
    inputLayout.setSpacing(true);
    inputLayout.setWidth("100%");
    inputLayout.setColumnExpandRatio(0, 1.0f);

    inputPanel.addComponent(inputLayout);

    mainLayout.addComponent(inputPanel);

    tokenFieldMailTo = new EmailTokenField();

    inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0);

    if (lstMail != null) {
        for (String mail : lstMail) {
            if (StringUtils.isNotBlank(mail)) {
                if (mail.indexOf("<") > -1) {
                    String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">"));
                    if (strMail != null && !strMail.equalsIgnoreCase("null")) {

                    }
                } else {

                }
            }
        }
    }

    final TextField subject = new TextField();
    subject.setRequired(true);
    subject.setWidth("100%");
    subjectField = createTextFieldMail("Subject:", subject);
    inputLayout.addComponent(subjectField, 0, 1);

    initButtonLinkCcBcc();

    ccField = createTextFieldMail("Cc:", tokenFieldMailCc);
    bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc);

    final RichTextArea noteArea = new RichTextArea();
    noteArea.setWidth("100%");
    noteArea.setHeight("200px");
    mainLayout.addComponent(noteArea, 0, 1);
    mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER);

    final AttachmentPanel attachments = new AttachmentPanel();
    attachments.setWidth("500px");

    MButton cancelBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            clickEvent -> close()).withStyleName(WebThemes.BUTTON_OPTION);

    MButton sendBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.ACTION_SEND_EMAIL), clickEvent -> {
        if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) {
            NotificationUtil.showErrorNotification(
                    "To Email field and Subject field must be not empty! Please fulfil them before sending email.");
            return;
        }
        if (UserUIContext.getUser().getEmail() != null && UserUIContext.getUser().getEmail().length() > 0) {
            ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class);

            List<File> listFile = attachments.files();
            List<AttachmentSource> attachmentSource = null;
            if (listFile != null && listFile.size() > 0) {
                attachmentSource = new ArrayList<>();
                for (File file : listFile) {
                    attachmentSource.add(new FileAttachmentSource(file));
                }
            }

            systemMailService.sendHTMLMail(UserUIContext.getUser().getEmail(),
                    UserUIContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(),
                    tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(),
                    subject.getValue(), noteArea.getValue(), attachmentSource, true);
            close();
        } else {
            NotificationUtil
                    .showErrorNotification("Your email is empty value, please fulfil it before sending email!");
        }
    }).withIcon(FontAwesome.SEND).withStyleName(WebThemes.BUTTON_ACTION);

    MHorizontalLayout controlsLayout = new MHorizontalLayout(attachments, cancelBtn, sendBtn)
            .expand(attachments).withFullWidth();
    mainLayout.addComponent(controlsLayout, 0, 2);
    this.setContent(mainLayout);
}

From source file:com.peergreen.webconsole.scope.deployment.internal.deployable.repository.RepositoryEntry.java

License:Open Source License

private void showDetailsView() {
    if (detailsView == null) {
        detailsView = new VerticalLayout();
        detailsView.setWidth("100%");

        Button hideDetails = new Button("Hide");
        hideDetails.addStyleName("link");
        hideDetails.addClickListener(new Button.ClickListener() {
            @Override//from  w w  w  . j a v  a 2  s .  c  o m
            public void buttonClick(Button.ClickEvent event) {
                showDefaultView();
            }
        });
        detailsView.addComponent(hideDetails);
        detailsView.setComponentAlignment(hideDetails, Alignment.TOP_RIGHT);

        GridLayout layout = new GridLayout(3, 1);
        layout.addComponent(new Label("<b>Name</b>", ContentMode.HTML));
        layout.addComponent(new Label("&nbsp;", ContentMode.HTML));
        layout.addComponent(new Label(repository.getName()));
        layout.newLine();

        layout.addComponent(new Label("<b>URL</b>", ContentMode.HTML));
        layout.addComponent(new Label("&nbsp;", ContentMode.HTML));
        layout.addComponent(new Label(repository.getUrl()));
        layout.newLine();

        layout.addComponent(new Label("<b>Type</b>", ContentMode.HTML));
        layout.addComponent(new Label("&nbsp;", ContentMode.HTML));
        layout.addComponent(new Label(repository.getType()));

        detailsView.addComponent(layout);
        detailsView.setComponentAlignment(layout, Alignment.TOP_LEFT);
    }

    removeAllComponents();
    addComponent(detailsView);
}