Example usage for com.vaadin.ui CssLayout setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(float width, Unit unit) 

Source Link

Usage

From source file:com.hybridbpm.ui.MainMenu.java

License:Apache License

protected void addMenuItemComponent(final ViewDefinition viewDefinition, String parameters) {
    CssLayout dashboardWrapper = new CssLayout();
    dashboardWrapper.addStyleName("badgewrapper");
    dashboardWrapper.addStyleName(ValoTheme.MENU_ITEM);
    dashboardWrapper.setWidth(100.0f, Sizeable.Unit.PERCENTAGE);

    Label notificationsBadge = new Label();
    notificationsBadge.addStyleName(ValoTheme.MENU_BADGE);
    notificationsBadge.setWidthUndefined();
    notificationsBadge.setVisible(false);

    if (viewDefinition != null) {
        dashboardWrapper.addComponents(new ValoMenuItemButton(viewDefinition, parameters), notificationsBadge);
        menuItemsLayout.addComponent(dashboardWrapper);
    } else if (HybridbpmUI.getDeveloperMode()) {
        dashboardWrapper.addComponents(new ValoMenuAddViewButton(), notificationsBadge);
        menuItemsLayout.addComponent(dashboardWrapper);
    }//from   ww w .java2  s .c  o m
}

From source file:com.klwork.explorer.ui.task.HistoricTaskDetailPanel.java

License:Apache License

protected void initDescription() {
    CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK);
    descriptionLayout.setWidth(100, UNITS_PERCENTAGE);

    if (historicTask.getDescription() != null) {
        Label descriptionLabel = new Label(historicTask.getDescription());
        descriptionLayout.addComponent(descriptionLabel);
    }//from   w  ww . j  av a  2s. c  om

    centralLayout.addComponent(descriptionLayout);
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initDescription(HorizontalLayout layout) {
    final CssLayout descriptionLayout = new CssLayout();
    descriptionLayout.setWidth(100, Unit.PERCENTAGE);
    layout.addComponent(descriptionLayout);
    layout.setExpandRatio(descriptionLayout, 1.0f);
    layout.setComponentAlignment(descriptionLayout, Alignment.MIDDLE_LEFT);

    String descriptionText = null;
    if (task.getDescription() != null && !"".equals(task.getDescription())) {
        descriptionText = task.getDescription();
    } else {//??
        descriptionText = i18nManager.getMessage(Messages.TASK_NO_DESCRIPTION);
    }//w  w w.j av  a 2 s.co m
    final Label descriptionLabel = new Label(descriptionText);
    descriptionLabel.addStyleName(ExplorerLayout.STYLE_CLICKABLE);
    descriptionLayout.addComponent(descriptionLabel);

    descriptionLayout.addLayoutClickListener(new LayoutClickListener() {
        public void layoutClick(LayoutClickEvent event) {
            if (event.getClickedComponent() != null && event.getClickedComponent().equals(descriptionLabel)) {
                // layout for textarea + ok button
                final VerticalLayout editLayout = new VerticalLayout();
                editLayout.setSpacing(true);

                // textarea
                final TextArea descriptionTextArea = new TextArea();
                //
                descriptionTextArea.setNullRepresentation("");
                descriptionTextArea.setWidth(100, Unit.PERCENTAGE);
                descriptionTextArea.setValue(task.getDescription());
                editLayout.addComponent(descriptionTextArea);

                // ok button
                Button okButton = new Button(i18nManager.getMessage(Messages.BUTTON_OK));
                editLayout.addComponent(okButton);
                editLayout.setComponentAlignment(okButton, Alignment.BOTTOM_RIGHT);

                // replace
                descriptionLayout.replaceComponent(descriptionLabel, editLayout);

                // When OK is clicked -> update task data + ui
                okButton.addClickListener(new ClickListener() {
                    public void buttonClick(ClickEvent event) {
                        // Update data
                        task.setDescription(descriptionTextArea.getValue().toString());
                        taskService.saveTask(task);

                        // Update UI
                        descriptionLabel.setValue(task.getDescription());
                        descriptionLayout.replaceComponent(editLayout, descriptionLabel);
                    }
                });
            }
        }
    });
}

From source file:com.klwork.explorer.ui.task.TaskDetailPanel.java

License:Apache License

protected void initTaskForm() {
    // Check if task requires a form
    //task.getT//from  w  w  w. ja  v  a2s  . c o  m
    TaskFormData formData = formService.getTaskFormData(task.getId());

    if (formData != null && StringTool.judgeBlank(formData.getFormKey())) {
        TaskForm c = TaskFormFactory.create(formData.getFormKey(), task);
        centralLayout.addComponent(c);
        c.addListener(new SubmitEventListener() {
            private static final long serialVersionUID = -3893467157397686736L;

            @Override
            protected void submitted(SubmitEvent event) {
                //??????
                Map<String, Object> properties = (Map<String, Object>) event.getData();
                System.out.println(properties);
                taskService.complete(task.getId(), properties);
                notificationManager.showInformationNotification(Messages.TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }

            @Override
            protected void cancelled(SubmitEvent event) {
                taskForm.clear();
            }
        });

        return;
    }
    //formService.getS
    if (formData != null && formData.getFormProperties() != null && formData.getFormProperties().size() > 0) {
        taskForm = new FormPropertiesForm();
        taskForm.setSubmitButtonCaption(i18nManager.getMessage(Messages.TASK_COMPLETE));
        taskForm.setCancelButtonCaption(i18nManager.getMessage(Messages.TASK_RESET_FORM));
        taskForm.setFormHelp(i18nManager.getMessage(Messages.TASK_FORM_HELP));
        taskForm.setFormProperties(formData.getFormProperties());
        //WW_TODO form?
        taskForm.addListener(new FormPropertiesEventListener() {
            private static final long serialVersionUID = -3893467157397686736L;

            @Override
            protected void handleFormSubmit(FormPropertiesEvent event) {
                //??????
                Map<String, String> properties = event.getFormProperties();
                formService.submitTaskFormData(task.getId(), properties);
                notificationManager.showInformationNotification(Messages.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(ExplorerLayout.STYLE_DETAIL_BLOCK);
        buttonLayout.setWidth(100, Unit.PERCENTAGE);
        centralLayout.addComponent(buttonLayout);

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

        completeButton.addClickListener(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(Messages.TASK_COMPLETED, task.getName());
                taskPage.refreshSelectNext();
            }
        });

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

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//from w ww .  j  a va  2  s  .co m
        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  ava 2 s .  co  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/*from ww w .j a  va2  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());
                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 ww  w . j  a  v  a  2s .  co  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//from  w w w .j av a 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);
                    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/*from   w w w. jav a2  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
        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);
    }
}