Example usage for com.vaadin.ui CssLayout addComponent

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

Introduction

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

Prototype

@Override
public void addComponent(Component c) 

Source Link

Document

Add a component into this container.

Usage

From source file:info.magnolia.ui.admincentral.shellapp.favorites.FavoritesForm.java

License:Open Source License

private void init() {
    addStyleName("favorites-form");
    final VerticalLayout favoriteForm = new VerticalLayout();
    favoriteEntryForm = new InternalFavoriteEntryForm();
    favoriteGroupForm = new InternalFavoriteGroupForm();

    tabsheet = new TabSheet();
    tabsheet.addStyleName("favorites-tabs");
    tabsheet.addTab(favoriteEntryForm, i18n.translate("favorites.form.favorite.add"));
    tabsheet.addTab(favoriteGroupForm, i18n.translate("favorites.form.group.add"));

    tabsheet.addSelectedTabChangeListener(new SelectedTabChangeListener() {

        @Override//from  ww w. j  a va  2s .  c  o m
        public void selectedTabChange(SelectedTabChangeEvent event) {
            if (event.getTabSheet().getSelectedTab() instanceof InternalFavoriteEntryForm) {
                favoriteGroupForm.removeEnterKeyShortcutListener();
                favoriteEntryForm.addEnterKeyShortcutListener();
            } else {
                favoriteEntryForm.removeEnterKeyShortcutListener();
                favoriteGroupForm.addEnterKeyShortcutListener();
            }
        }
    });

    final CssLayout header = new CssLayout();
    header.addStyleName("dialog-header");
    header.setSizeFull();
    header.addLayoutClickListener(new LayoutClickListener() {
        @Override
        public void layoutClick(LayoutClickEvent event) {
            // change the visibility of the group- and favorite-items
            if (event.getClickedComponent() == editIcon || event.getChildComponent() == editLabel) {
                if (!listener.hasItems() || listener.itemsAreEditable()) {
                    listener.setToInitialState();
                } else {
                    listener.setItemsEditable(true);
                }
            } else {
                // just open || close the FavoritesForm
                if (isOpen()) {
                    close();
                } else {
                    open();
                }
            }
        }
    });

    // add
    final Label addNewIcon = new Label();
    addNewIcon.setSizeUndefined();
    addNewIcon.addStyleName("icon");
    addNewIcon.addStyleName("icon-add-fav");
    final Label addNewLabel = new Label(i18n.translate("favorites.form.add"));
    addNewLabel.setSizeUndefined();
    addNewLabel.addStyleName("title");

    // edit
    editIcon = new Label();
    editIcon.setSizeUndefined();
    editIcon.addStyleName(EDIT_ACTION_STYLENAME);
    editIcon.addStyleName("icon");
    editIcon.addStyleName("icon-edit");

    editLabel = new Label(i18n.translate("favorites.form.favorite.edit"));
    editLabel.setSizeUndefined();
    editLabel.addStyleName("title");
    editLabel.addStyleName(EDIT_ACTION_STYLENAME);

    // arrow
    arrowIcon = new Label();
    arrowIcon.setSizeUndefined();
    arrowIcon.addStyleName("icon");
    arrowIcon.addStyleName("arrow");
    arrowIcon.addStyleName("icon-arrow2_n");

    // assemble
    header.addComponent(addNewIcon);
    header.addComponent(addNewLabel);
    header.addComponent(editIcon);
    header.addComponent(editLabel);
    header.addComponent(arrowIcon);
    favoriteForm.addComponent(header);
    favoriteForm.addComponent(tabsheet);

    // form is closed initially
    close();
    setCompositionRoot(favoriteForm);
}

From source file:info.magnolia.ui.dialog.formdialog.FormBuilder.java

License:Open Source License

public View buildView(FormDefinition formDefinition, Item item) {

    final CssLayout view = new CssLayout();
    view.setSizeFull();//from   w ww  .ja v  a  2  s .  c om

    for (TabDefinition tabDefinition : formDefinition.getTabs()) {
        List<FieldDefinition> fields = tabDefinition.getFields();
        if (fields.size() == 0) { // skip empty tabs
            continue;
        }
        for (final FieldDefinition fieldDefinition : fields) {
            final FieldFactory formField = fieldFactoryFactory.createFieldFactory(fieldDefinition, item);
            if (formField == null) {
                continue;
            }
            formField.setComponentProvider(componentProvider);

            final View fieldView = formField.getView();

            view.addComponent(fieldView.asVaadinComponent());

        }
    }
    return new View() {
        @Override
        public Component asVaadinComponent() {
            return view;
        }
    };
}

From source file:info.magnolia.ui.form.field.factory.AbstractFieldFactory.java

License:Open Source License

@Override
public View getView() {
    final CssLayout fieldView = new CssLayout();
    fieldView.setStyleName("field-view");

    Label label = new Label();
    label.setSizeUndefined();//w ww.  j  a va 2  s  .co m
    label.setCaption(getFieldDefinition().getLabel());

    if (getFieldDefinition().getClass().isAssignableFrom(TextFieldDefinition.class)) {
        final TextFieldDefinition textFieldDefinition = (TextFieldDefinition) getFieldDefinition();
        if (textFieldDefinition.getRows() > 0) {
            label.addStyleName("textarea");
        }
    }
    if (definition.getConverterClass() != null) {
        Converter converter = initializeConverter(definition.getConverterClass());
        label.setConverter(converter);
    }

    Property<?> property = initializeProperty();

    label.setPropertyDataSource(property);

    fieldView.addComponent(label);

    return new View() {
        @Override
        public Component asVaadinComponent() {
            return fieldView;
        }
    };
}

From source file:info.magnolia.ui.form.field.upload.basic.BasicUploadProgressIndicator.java

License:Open Source License

public BasicUploadProgressIndicator(String inProgressCaption, String inProgressRatioCaption,
        SimpleTranslator i18n) {/*from  www  .j a va2s.  co m*/
    this.inProgressCaption = inProgressCaption;
    this.inProgressRatioCaption = inProgressRatioCaption;
    this.i18n = i18n;

    uploadFileLocation = new Label("");
    uploadFileLocation.setSizeUndefined();
    uploadFileLocation.addStyleName("uploading-file");

    uploadFileRatio = new Label("");
    uploadFileRatio.setSizeUndefined();
    uploadFileRatio.addStyleName("uploaded-file");

    uploadFileProgress = new Label("");
    uploadFileProgress.setSizeUndefined();
    uploadFileProgress.addStyleName("uploading-file-progress");

    progressIndicator = new ProgressBar();
    progressIndicator.setVisible(false);
    progressIndicator.setWidth("100%");

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();

    mainLayout.addComponent(uploadFileLocation);

    CssLayout progressLayout = new CssLayout();
    progressLayout.addStyleName("progress-layout");
    progressLayout.addComponent(progressIndicator);
    progressLayout.addComponent(uploadFileProgress);
    progressLayout.setWidth("100%");
    mainLayout.addComponent(progressLayout);
    mainLayout.addComponent(uploadFileRatio);

    Iterator<Component> it = mainLayout.iterator();
    while (it.hasNext()) {
        Component c = it.next();
        mainLayout.setComponentAlignment(c, Alignment.MIDDLE_CENTER);
    }
    mainLayout.setMargin(new MarginInfo(false, true, false, true));

    setCompositionRoot(mainLayout);
    addStyleName("uploading-progress-indicator");

}

From source file:info.magnolia.ui.framework.overlay.OverlayPresenter.java

License:Open Source License

private void addOkHandler(BaseDialog dialog, String okButtonText, final OverlayCloser overlayCloser,
        final AlertCallback cb) {
    CssLayout footer = new CssLayout();
    footer.setWidth(100, Unit.PERCENTAGE);
    footer.addStyleName("v-align-right");
    Button okButton = new Button(okButtonText, new ClickListener() {
        @Override// w  w  w .  j  a v a 2  s  .c  om
        public void buttonClick(ClickEvent event) {
            cb.onOk();
            overlayCloser.close();
        }
    });
    okButton.focus();
    footer.addComponent(okButton);
    dialog.setFooterToolbar(footer);
}

From source file:info.magnolia.ui.vaadin.dialog.ConfirmationDialog.java

License:Open Source License

public void init(String confirmLabel, String cancelLabel, boolean cancelIsDefault) {
    CssLayout footer = new CssLayout();
    footer.addStyleName("v-align-right");

    confirmButton = new Button(confirmLabel, new ClickListener() {
        @Override/*from  w  w w  .j  a  v a 2 s.  c  o m*/
        public void buttonClick(ClickEvent event) {
            confirm();
        }
    });
    confirmButton.setDisableOnClick(true);

    cancelButton = new Button(cancelLabel, new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            cancel();
        }
    });
    cancelButton.setDisableOnClick(true);

    footer.addComponent(cancelButton);
    footer.addComponent(confirmButton);

    cancelButton.addStyleName("btn-dialog");
    cancelButton.addStyleName("cancel");
    confirmButton.addStyleName("btn-dialog");
    confirmButton.addStyleName("commit");

    footer.setWidth(100, Unit.PERCENTAGE);
    setFooterToolbar(footer);

    // Add a class to the default button
    if (cancelIsDefault) {
        cancelButton.focus();
    } else {
        confirmButton.focus();
    }
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.admin.letturafiltri.LetturaFiltriPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    TaskFormData formData = formService.getTaskFormData(task.getId());
    if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) {
        taskForm = new GreenareaFormPropertiesForm();
        taskForm.setMainTitle(taskPage.getMainTitle());
        if (task.getTaskDefinitionKey().equals("elencoFiltri"))
            ((Form) ((FormPropertiesComponent) taskForm.getComponent(1)).getComponent(0))
                    .setLayout(new GreenareaFormLayout());
        taskForm.setFormProperties(formData.getFormProperties());

        final LetturaFiltriPanel letturaFiltriPanel = this;
        taskForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = -3893467157397686736L;

            @Override/*  w  ww  . ja  va  2  s  . co m*/
            protected void handleFormSubmit(FormPropertiesEvent event) {
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                List<Task> tasks = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
                        .active().list();
                if (tasks.size() == 1) {
                    task = tasks.get(0);
                    letturaFiltriPanel.setTask(task);
                    letturaFiltriPanel.attach();
                } else
                    taskPage.refreshSelectNext();
            }

            @Override
            protected void handleFormCancel(FormPropertiesEvent event) {
                // Clear the form values
                taskForm.clear();
            }
        });
        // Only if current user is task's assignee
        taskForm.setEnabled(isCurrentUserAssignee());

        // Add component to page
        centralLayout.addComponent(taskForm);
    } else {
        // Just add a button to complete the task
        // TODO: perhaps move to a better place

        CssLayout buttonLayout = new CssLayout();
        buttonLayout.addStyleName(STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, UNITS_PERCENTAGE);
        centralLayout.addComponent(buttonLayout);

        completeButton = new Button(i18nManager.getMessage(TASK_COMPLETE));

        completeButton.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                // If no owner, make assignee owner (will go into archived
                // then)
                if (task.getOwner() == null) {
                    task.setOwner(task.getAssignee());
                    taskService.setOwner(task.getId(), task.getAssignee());
                }

                taskService.complete(task.getId());
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

        completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
        buttonLayout.addComponent(completeButton);
    }
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.DettaglioPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    TaskFormData formData = formService.getTaskFormData(task.getId());
    if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) {
        taskForm = new GreenareaFormPropertiesForm();
        taskForm.setMainTitle(taskPage.getMainTitle());
        taskForm.setFormProperties(formData.getFormProperties());

        taskForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = -3893467157397686736L;

            @Override//from  w  ww.  ja va 2  s  .c o m
            protected void handleFormSubmit(FormPropertiesEvent event) {
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }

            @Override
            protected void handleFormCancel(FormPropertiesEvent event) {
                // Clear the form values
                taskForm.clear();
            }
        });
        // Only if current user is task's assignee
        taskForm.setEnabled(isCurrentUserAssignee());

        // Add component to page
        addComponent(taskForm);
    } else {
        // Just add a button to complete the task
        // TODO: perhaps move to a better place

        CssLayout buttonLayout = new CssLayout();
        buttonLayout.addStyleName(STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, UNITS_PERCENTAGE);
        addComponent(buttonLayout);

        completeButton = new Button(i18nManager.getMessage(TASK_COMPLETE));

        completeButton.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                // If no owner, make assignee owner (will go into archived
                // then)
                if (task.getOwner() == null) {
                    task.setOwner(task.getAssignee());
                    taskService.setOwner(task.getId(), task.getAssignee());
                }

                taskService.complete(task.getId());
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

        completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
        buttonLayout.addComponent(completeButton);
    }
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.operatorelogistico.anagrafeveicoli.AnagrafeVeicoliOpPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    TaskFormData formData = formService.getTaskFormData(task.getId());
    if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) {
        taskForm = new GreenareaFormPropertiesForm();
        taskForm.setMainTitle(taskPage.getMainTitle());
        if (task.getTaskDefinitionKey().equals("elencoParametri")
                || task.getTaskDefinitionKey().equals("elencoVeicoli"))
            ((Form) ((FormPropertiesComponent) taskForm.getComponent(1)).getComponent(0))
                    .setLayout(new GreenareaFormLayout());
        taskForm.setFormProperties(formData.getFormProperties());

        final AnagrafeVeicoliOpPanel aggiornaStatoVeicoliOpPanel = this;
        taskForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = -3893467157397686736L;

            @Override/* w  w  w. j  a  va2s  .  c o  m*/
            protected void handleFormSubmit(FormPropertiesEvent event) {
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                List<Task> tasks = taskService.createTaskQuery().processInstanceId(task.getProcessInstanceId())
                        .active().list();
                if (tasks.size() == 1) {
                    task = tasks.get(0);
                    aggiornaStatoVeicoliOpPanel.setTask(task);
                    aggiornaStatoVeicoliOpPanel.attach();
                } else
                    taskPage.refreshSelectNext();
            }

            @Override
            protected void handleFormCancel(FormPropertiesEvent event) {
                // Clear the form values
                taskForm.clear();
            }
        });
        // Only if current user is task's assignee
        taskForm.setEnabled(isCurrentUserAssignee());

        // Add component to page
        centralLayout.addComponent(taskForm);
    } else {
        // Just add a button to complete the task
        // TODO: perhaps move to a better place

        CssLayout buttonLayout = new CssLayout();
        buttonLayout.addStyleName(STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, UNITS_PERCENTAGE);
        centralLayout.addComponent(buttonLayout);

        completeButton = new Button(i18nManager.getMessage(TASK_COMPLETE));

        completeButton.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                // If no owner, make assignee owner (will go into archived
                // then)
                if (task.getOwner() == null) {
                    task.setOwner(task.getAssignee());
                    taskService.setOwner(task.getId(), task.getAssignee());
                }

                taskService.complete(task.getId());
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

        completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
        buttonLayout.addComponent(completeButton);
    }
}

From source file:it.vige.greenarea.bpm.custom.ui.dettaglio.operatorelogistico.richiedireportmissioni.RichiediReportMissioniOpPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    TaskFormData formData = formService.getTaskFormData(task.getId());
    if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) {
        taskForm = new GreenareaFormPropertiesForm();
        taskForm.setMainTitle(taskPage.getMainTitle());
        if (task.getTaskDefinitionKey().equals("visualizzaReportDettaglioConsegne")
                || task.getTaskDefinitionKey().equals("visualizzaReportSintesiMissioni")
                || task.getTaskDefinitionKey().equals("visualizzaReportDettaglioMissioni"))
            ((Form) ((FormPropertiesComponent) taskForm.getComponent(1)).getComponent(0))
                    .setLayout(new GreenareaFormLayout());
        taskForm.setFormProperties(formData.getFormProperties());

        taskForm.addListener(new FormPropertiesEventListener() {

            private static final long serialVersionUID = -3893467157397686736L;

            @Override//w  ww. j  a  v a  2  s  . c  om
            protected void handleFormSubmit(FormPropertiesEvent event) {
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }

            @Override
            protected void handleFormCancel(FormPropertiesEvent event) {
                // Clear the form values
                taskForm.clear();
            }
        });
        // Only if current user is task's assignee
        taskForm.setEnabled(isCurrentUserAssignee());

        // Add component to page
        centralLayout.addComponent(taskForm);
    } else {
        // Just add a button to complete the task
        // TODO: perhaps move to a better place

        CssLayout buttonLayout = new CssLayout();
        buttonLayout.addStyleName(STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, UNITS_PERCENTAGE);
        centralLayout.addComponent(buttonLayout);

        completeButton = new Button(i18nManager.getMessage(TASK_COMPLETE));

        completeButton.addListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            public void buttonClick(ClickEvent event) {
                // If no owner, make assignee owner (will go into archived
                // then)
                if (task.getOwner() == null) {
                    task.setOwner(task.getAssignee());
                    taskService.setOwner(task.getId(), task.getAssignee());
                }

                taskService.complete(task.getId());
                notificationManager.showInformationNotification(TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

        completeButton.setEnabled(isCurrentUserAssignee() || isCurrentUserOwner());
        buttonLayout.addComponent(completeButton);
    }
}