Example usage for com.vaadin.ui CssLayout addStyleName

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

Introduction

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

Prototype

@Override
    public void addStyleName(String style) 

Source Link

Usage

From source file:fr.ortec.dsi.pointage.presentation.ihm.view.TextFields.java

License:Apache License

public TextFields() {
    setMargin(true);//from w  w  w .  j  a va2 s. c  o  m
    setSpacing(true);

    Label h1 = new Label("Text Fields");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    HorizontalLayout row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    TextField tf = new TextField("Normal");
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField("Custom color");
    tf.addStyleName("color1");
    row.addComponent(tf);

    tf = new TextField("User Color");
    tf.addStyleName("color2");
    row.addComponent(tf);

    tf = new TextField("Themed");
    tf.addStyleName("color3");
    row.addComponent(tf);

    tf = new TextField("Error");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    row.addComponent(tf);

    tf = new TextField("Error, borderless");
    tf.setValue("Somethings wrong");
    tf.setComponentError(new UserError("Fix it, now!"));
    tf.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    row.addComponent(tf);

    tf = new TextField("Small");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_SMALL);
    row.addComponent(tf);

    tf = new TextField("Large");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_LARGE);
    tf.setIcon(testIcon.get(true));
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Font, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get());
    row.addComponent(tf);

    tf = new TextField();
    tf.setValue("Image, no caption");
    tf.addStyleName(ValoTheme.TEXTFIELD_INLINE_ICON);
    tf.setIcon(testIcon.get(true, 16));
    row.addComponent(tf);

    CssLayout group = new CssLayout();
    group.addStyleName(ValoTheme.LAYOUT_COMPONENT_GROUP);
    row.addComponent(group);

    Button button = new Button("Do It");
    // button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    group.addComponent(button);

    tf = new TextField("Right-aligned");
    tf.setValue("1,234");
    tf.addStyleName(ValoTheme.TEXTFIELD_ALIGN_RIGHT);
    row.addComponent(tf);

    tf = new TextField("Tiny");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_TINY);
    row.addComponent(tf);

    tf = new TextField("Huge");
    tf.setValue("Field value");
    tf.addStyleName(ValoTheme.TEXTFIELD_HUGE);
    row.addComponent(tf);

    h1 = new Label("Text Areas");
    h1.addStyleName(ValoTheme.LABEL_H1);
    addComponent(h1);

    row = new HorizontalLayout();
    row.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(row);

    RichTextArea rta = new RichTextArea();
    rta.setValue("<b>Some</b> <i>rich</i> content");
    row.addComponent(rta);

    rta = new RichTextArea("Read-only");
    rta.setValue("<b>Some</b> <i>rich</i> content");
    rta.setReadOnly(true);
    row.addComponent(rta);
}

From source file:info.magnolia.messages.app.MessagesViewImpl.java

License:Open Source License

@Inject
public MessagesViewImpl(SimpleTranslator i18n) {

    this.i18n = i18n;

    // create form and data item
    final Message message = new Message(); // message POJO
    BeanItem<Message> messageItem = new BeanItem<Message>(message);

    final FieldGroup form = new FieldGroup();
    form.setItemDataSource(messageItem);

    Field<String> subjectField = createSubjectTextField();
    Field<String> messageBodyField = createMessageBodyTextField();
    Field<?> typeField = createTypeSelectionField();
    Field<?> scopeField = createScopeSelectionField();
    userOrGroupIdField = createUserOrGroupIdTextField();

    // disable user/group field if not necessary
    scopeField.addValueChangeListener(new ValueChangeListener() {

        @Override//from  ww  w  .j a v  a 2s  .c  o m
        public void valueChange(ValueChangeEvent event) {
            updateUserOrGroupField((String) event.getProperty().getValue());
        }
    });

    form.bind(subjectField, "title");
    form.bind(messageBodyField, "content");
    form.bind(typeField, "type");
    form.bind(scopeField, "scope");
    form.bind(userOrGroupIdField, "user");
    // FieldGroup overrides fields' own enabled property with its own.
    updateUserOrGroupField(message.getScope());

    FormLayout layout = new FormLayout();
    layout.addComponent(subjectField);
    layout.addComponent(messageBodyField);
    layout.addComponent(typeField);
    layout.addComponent(scopeField);
    layout.addComponent(userOrGroupIdField);

    layout.setSpacing(true);
    layout.setMargin(false);
    layout.setWidth("100%");

    // send button
    NativeButton sendButton = new NativeButton(i18n.translate("messages-app.app.button.sendMessage"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(Button.ClickEvent event) {
                    try {
                        form.commit();
                        String subject = message.getTitle();
                        String content = message.getContent();
                        MessageType type = message.getType();
                        String scope = message.getScope();

                        if (MESSAGE_SCOPE_LOCAL.equals(scope)) {
                            listener.handleLocalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GLOBAL.equals(scope)) {
                            listener.handleGlobalMessage(type, subject, content);
                        } else if (MESSAGE_SCOPE_GROUP.equals(scope)) {
                            // message is bound to FieldGroup - hence the group name is to be retrieved from the user field of the message
                            final String groupName = message.getUser();
                            listener.handleGroupMessage(groupName, type, subject, content);
                        } else {
                            // User...
                            final String userName = message.getUser();
                            listener.handleUserMessage(userName, type, subject, content);
                        }
                    } catch (CommitException e) {

                    }
                }
            });
    sendButton.addStyleName("btn-dialog");
    sendButton.addStyleName("commit");

    // reset button
    NativeButton resetButton = new NativeButton(i18n.translate("messages-app.app.button.reset"),
            new Button.ClickListener() {

                @Override
                public void buttonClick(ClickEvent event) {
                    message.reset();
                    form.discard();
                }
            });
    resetButton.addStyleName("btn-dialog");
    resetButton.addStyleName("cancel");

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.addStyleName("buttons");
    buttons.setSpacing(true);
    buttons.addComponent(sendButton);
    buttons.addComponent(resetButton);
    layout.addComponent(buttons);

    // intro text
    Label intro = new Label(i18n.translate("messages-app.app.label.intro"), ContentMode.HTML);
    intro.addStyleName("intro");

    CssLayout container = new CssLayout();
    container.setSizeFull();
    container.addStyleName("small-app-panel");
    container.addComponent(layout);

    CssLayout root = new CssLayout();
    root.setSizeFull();
    root.setWidth("900px");
    root.setStyleName("small-app");
    root.addComponent(intro);
    root.addComponent(container);

    component = root;
}

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// ww  w . j  a  va2s  . 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.form.field.upload.basic.BasicUploadProgressIndicator.java

License:Open Source License

public BasicUploadProgressIndicator(String inProgressCaption, String inProgressRatioCaption,
        SimpleTranslator i18n) {/*from  ww  w . jav  a2s.c o  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// ww  w.  j  a  v  a 2  s.  c o  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//  w  ww.  j a v  a2s .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//from   ww w  .  jav  a2 s. com
            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  w  w. j av 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
        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 www.ja va2s  .  com
            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);
    }
}