Example usage for com.vaadin.ui Button setDescription

List of usage examples for com.vaadin.ui Button setDescription

Introduction

In this page you can find the example usage for com.vaadin.ui Button setDescription.

Prototype

public void setDescription(String description) 

Source Link

Document

Sets the component's description.

Usage

From source file:com.mycollab.module.file.view.components.FileBreadcrumb.java

License:Open Source License

private void displayMyCollabFolder(final Folder folder) {
    String folderPath = folder.getPath();
    if (!folderPath.startsWith(rootFolderPath)) {
        throw new MyCollabException("Invalid path " + rootFolderPath + "---" + folderPath);
    }//from  www .  j av  a2 s  .  c  om

    String remainPath = folderPath.substring(rootFolderPath.length());
    if (remainPath.startsWith("/")) {
        remainPath = remainPath.substring(1);
    }

    Button btn1, btn2 = null;
    int index;
    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        remainPath = newPath;
        btn2 = new Button(StringUtils.trim(pathName, 25, true), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(rootFolderPath + "/" + newPath);
                criteria.setRootFolder(rootFolderPath);
                notifySearchHandler(criteria);
            }
        });
        btn2.setDescription(pathName);
    }

    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        btn1 = new Button(StringUtils.trim(pathName, 25, true), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(rootFolderPath + "/" + newPath);
                criteria.setRootFolder(rootFolderPath);
                notifySearchHandler(criteria);
            }
        });
        btn1.setDescription(pathName);
    } else {
        final String newPath = remainPath;
        btn1 = new Button(StringUtils.trim(newPath, 25, true), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(rootFolderPath + "/" + newPath);
                criteria.setRootFolder(rootFolderPath);
                notifySearchHandler(criteria);
            }
        });
        btn1.setDescription(newPath);
    }

    if (btn1 != null) {
        addLink(btn1);
    }

    if (btn2 != null) {
        addLink(btn2);
        select(btn2);
    }
}

From source file:com.mycollab.module.file.view.components.FileBreadcrumb.java

License:Open Source License

private void displayExternalFolder(final ExternalFolder folder) {
    String remainPath = folder.getPath();

    Button btn1 = null, btn2 = null;
    int index;/*  ww  w  .j  a va  2 s  . c o  m*/
    if ((index = remainPath.lastIndexOf('/')) != -1) {
        if (index == 0) {
            btn1 = new Button(StringUtils.trim(folder.getExternalDrive().getFoldername(), 25, true),
                    new ClickListener() {
                        @Override
                        public void buttonClick(ClickEvent clickEvent) {
                            FileSearchCriteria criteria = new FileSearchCriteria();
                            criteria.setBaseFolder("/");
                            criteria.setRootFolder("/");
                            criteria.setStorageName(StorageNames.DROPBOX);
                            criteria.setExternalDrive(folder.getExternalDrive());
                            notifySearchHandler(criteria);
                        }
                    });
        }
        String pathName = remainPath.substring(index + 1);
        if (StringUtils.isNotBlank(pathName)) {
            final String newPath = remainPath.substring(0, index);
            remainPath = newPath;
            btn2 = new Button(StringUtils.trim(pathName, 25, true), new ClickListener() {
                @Override
                public void buttonClick(ClickEvent clickEvent) {
                    FileSearchCriteria criteria = new FileSearchCriteria();
                    criteria.setBaseFolder(newPath);
                    criteria.setRootFolder("/");
                    criteria.setStorageName(StorageNames.DROPBOX);
                    criteria.setExternalDrive(folder.getExternalDrive());
                    notifySearchHandler(criteria);
                }
            });
            btn2.setDescription(pathName);
        } else {
            remainPath = "";
        }
    }

    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        btn1 = new Button(StringUtils.trim(pathName, 25, true), new ClickListener() {
            @Override
            public void buttonClick(ClickEvent clickEvent) {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(newPath);

                criteria.setRootFolder("/");
                criteria.setStorageName(StorageNames.DROPBOX);
                criteria.setExternalDrive(folder.getExternalDrive());
                notifySearchHandler(criteria);
            }
        });
        btn1.setDescription(pathName);
    }

    if (btn1 != null) {
        addLink(btn1);
    }

    if (btn2 != null) {
        addLink(btn2);
        select(btn2);
    }
}

From source file:com.mycollab.module.file.view.FileBreadcrumb.java

License:Open Source License

private void displayMyCollabFolder(final Folder folder) {
    String folderPath = folder.getPath();
    if (!folderPath.startsWith(rootFolderPath)) {
        throw new MyCollabException("Invalid path " + rootFolderPath + "---" + folderPath);
    }//from w w  w  . ja va2 s  . c o m

    String remainPath = folderPath.substring(rootFolderPath.length());
    if (remainPath.startsWith("/")) {
        remainPath = remainPath.substring(1);
    }

    Button btn1, btn2 = null;
    int index;
    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        remainPath = newPath;
        btn2 = new Button(StringUtils.trim(pathName, 25, true), clickEvent -> {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(rootFolderPath + "/" + newPath);
            criteria.setRootFolder(rootFolderPath);
            notifySearchHandler(criteria);
        });
        btn2.setDescription(pathName);
    }

    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        btn1 = new Button(StringUtils.trim(pathName, 25, true), clickEvent -> {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(rootFolderPath + "/" + newPath);
            criteria.setRootFolder(rootFolderPath);
            notifySearchHandler(criteria);
        });
        btn1.setDescription(pathName);
    } else {
        final String newPath = remainPath;
        btn1 = new Button(StringUtils.trim(newPath, 25, true), clickEvent -> {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(rootFolderPath + "/" + newPath);
            criteria.setRootFolder(rootFolderPath);
            notifySearchHandler(criteria);
        });
        btn1.setDescription(newPath);
    }

    addLink(btn1);

    if (btn2 != null) {
        addLink(btn2);
        select(btn2);
    }
}

From source file:com.mycollab.module.file.view.FileBreadcrumb.java

License:Open Source License

private void displayExternalFolder(final ExternalFolder folder) {
    String remainPath = folder.getPath();

    Button btn1 = null, btn2 = null;
    int index;//w w w  .j  a v a2 s .  c  o m
    if ((index = remainPath.lastIndexOf('/')) != -1) {
        if (index == 0) {
            btn1 = new Button(StringUtils.trim(folder.getExternalDrive().getFoldername(), 25, true),
                    clickEvent -> {
                        FileSearchCriteria criteria = new FileSearchCriteria();
                        criteria.setBaseFolder("/");
                        criteria.setRootFolder("/");
                        criteria.setStorageName(StorageNames.DROPBOX);
                        criteria.setExternalDrive(folder.getExternalDrive());
                        notifySearchHandler(criteria);
                    });
        }
        String pathName = remainPath.substring(index + 1);
        if (StringUtils.isNotBlank(pathName)) {
            final String newPath = remainPath.substring(0, index);
            remainPath = newPath;
            btn2 = new Button(StringUtils.trim(pathName, 25, true), clickEvent -> {
                FileSearchCriteria criteria = new FileSearchCriteria();
                criteria.setBaseFolder(newPath);
                criteria.setRootFolder("/");
                criteria.setStorageName(StorageNames.DROPBOX);
                criteria.setExternalDrive(folder.getExternalDrive());
                notifySearchHandler(criteria);
            });
            btn2.setDescription(pathName);
        } else {
            remainPath = "";
        }
    }

    if ((index = remainPath.lastIndexOf('/')) != -1) {
        String pathName = remainPath.substring(index + 1);
        final String newPath = remainPath.substring(0, index);
        btn1 = new Button(StringUtils.trim(pathName, 25, true), clickEvent -> {
            FileSearchCriteria criteria = new FileSearchCriteria();
            criteria.setBaseFolder(newPath);

            criteria.setRootFolder("/");
            criteria.setStorageName(StorageNames.DROPBOX);
            criteria.setExternalDrive(folder.getExternalDrive());
            notifySearchHandler(criteria);
        });
        btn1.setDescription(pathName);
    }

    if (btn1 != null) {
        addLink(btn1);
    }

    if (btn2 != null) {
        addLink(btn2);
        select(btn2);
    }
}

From source file:com.mycollab.module.project.view.bug.BugListViewImpl.java

License:Open Source License

public BugListViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    searchPanel = new BugSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    groupWrapLayout.addComponent(new Label("Sort"));
    final ComboBox sortCombo = new ValueComboBox(false,
            AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.addValueChangeListener(valueChangeEvent -> {
        String sortValue = (String) sortCombo.getValue();
        if (AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
            sortDirection = SearchCriteria.ASC;
        } else {//from w  w  w  . j  av a  2s  .  c o m
            sortDirection = SearchCriteria.DESC;
        }
        queryAndDisplayBugs();
    });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new Label("Group by"));
    final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, GROUP_CREATED_DATE,
            PLAIN_LIST, GROUP_USER);
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = (String) groupCombo.getValue();
        queryAndDisplayBugs();
    });
    groupByState = GROUP_DUE_DATE;
    groupWrapLayout.addComponent(groupCombo);

    searchPanel.addHeaderRight(groupWrapLayout);

    MButton printBtn = new MButton("", clickEvent -> {
        UI.getCurrent().addWindow(new BugCustomizeReportOutputWindow(new LazyValueInjector() {
            @Override
            protected Object doEval() {
                return baseCriteria;
            }
        }));
    }).withIcon(FontAwesome.PRINT).withStyleName(UIConstants.BUTTON_OPTION);
    printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    groupWrapLayout.addComponent(printBtn);

    MButton newBugBtn = new MButton(AppContext.getMessage(BugI18nEnum.NEW), clickEvent -> {
        SimpleBug bug = new SimpleBug();
        bug.setProjectid(CurrentProjectVariables.getProjectId());
        bug.setSaccountid(AppContext.getAccountId());
        bug.setLogby(AppContext.getUsername());
        UI.getCurrent().addWindow(new BugAddWindow(bug));
    }).withIcon(FontAwesome.PLUS).withStyleName(UIConstants.BUTTON_ACTION)
            .withDescription(AppContext.getMessage(BugI18nEnum.NEW))
            .withVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS));
    groupWrapLayout.addComponent(newBugBtn);

    Button advanceDisplayBtn = new Button("List");
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Detail");

    MButton kanbanBtn = new MButton("Kanban", clickEvent -> displayKanbanView()).withIcon(FontAwesome.TH)
            .withWidth("100px");
    kanbanBtn.setDescription("Kanban View");

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.withDefaultButton(advanceDisplayBtn);
    groupWrapLayout.addComponent(viewButtons);

    MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth();
    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false));

    rightColumn = new MVerticalLayout().withWidth("370px").withMargin(new MarginInfo(true, false, true, false));

    mainLayout.with(wrapBody, rightColumn).expand(wrapBody);
    this.with(searchPanel, mainLayout);
}

From source file:com.mycollab.module.project.view.milestone.ToggleGenericTaskSummaryField.java

License:Open Source License

ToggleGenericTaskSummaryField(final ProjectGenericTask genericTask) {
    this.genericTask = genericTask;
    this.setWidth("100%");
    titleLinkLbl = ELabel.html(buildGenericTaskLink())
            .withStyleName(ValoTheme.LABEL_NO_MARGIN, UIConstants.LABEL_WORD_WRAP).withWidthUndefined();
    this.addComponent(titleLinkLbl);
    if ((genericTask.isTask() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS))
            || (genericTask.isBug() && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS))
            || (genericTask.isRisk()/*w w  w .j  a  va 2 s .  c  om*/
                    && CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.RISKS))) {
        this.addStyleName("editable-field");
        buttonControls = new MHorizontalLayout().withStyleName("toggle").withSpacing(false);
        Button instantEditBtn = new Button(null, new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                if (isRead) {
                    removeComponent(titleLinkLbl);
                    removeComponent(buttonControls);
                    final TextField editField = new TextField();
                    editField.setValue(genericTask.getName());
                    editField.setWidth("100%");
                    editField.focus();
                    addComponent(editField);
                    removeStyleName("editable-field");
                    editField.addValueChangeListener(new Property.ValueChangeListener() {
                        @Override
                        public void valueChange(Property.ValueChangeEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    editField.addBlurListener(new FieldEvents.BlurListener() {
                        @Override
                        public void blur(FieldEvents.BlurEvent event) {
                            updateFieldValue(editField);
                        }
                    });
                    isRead = !isRead;
                }
            }
        });
        instantEditBtn.setDescription("Edit task name");
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        instantEditBtn.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        instantEditBtn.setIcon(FontAwesome.EDIT);
        buttonControls.with(instantEditBtn);

        this.addComponent(buttonControls);
    }
}

From source file:com.mycollab.module.project.view.task.TaskDashboardViewImpl.java

License:Open Source License

public TaskDashboardViewImpl() {
    this.withMargin(new MarginInfo(false, true, true, true));
    taskSearchPanel = new TaskSearchPanel();

    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);

    groupWrapLayout.addComponent(new Label("Sort"));
    final ComboBox sortCombo = new ValueComboBox(false,
            AppContext.getMessage(GenericI18Enum.OPT_SORT_DESCENDING),
            AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING));
    sortCombo.addValueChangeListener(new Property.ValueChangeListener() {
        @Override/*  w  w  w  .ja v a  2  s.c o  m*/
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            String sortValue = (String) sortCombo.getValue();
            if (AppContext.getMessage(GenericI18Enum.OPT_SORT_ASCENDING).equals(sortValue)) {
                sortDirection = SearchCriteria.ASC;
            } else {
                sortDirection = SearchCriteria.DESC;
            }
            queryAndDisplayTasks();
        }
    });
    sortDirection = SearchCriteria.DESC;
    groupWrapLayout.addComponent(sortCombo);

    groupWrapLayout.addComponent(new Label("Group by"));
    final ComboBox groupCombo = new ValueComboBox(false, GROUP_DUE_DATE, GROUP_START_DATE, GROUP_CREATED_DATE,
            PLAIN_LIST, GROUP_USER);
    groupCombo.addValueChangeListener(valueChangeEvent -> {
        groupByState = (String) groupCombo.getValue();
        queryAndDisplayTasks();
    });
    groupByState = GROUP_DUE_DATE;
    groupWrapLayout.addComponent(groupCombo);

    taskSearchPanel.addHeaderRight(groupWrapLayout);

    MButton printBtn = new MButton("", clickEvent -> {
        UI.getCurrent().addWindow(new TaskCustomizeReportOutputWindow(new LazyValueInjector() {
            @Override
            protected Object doEval() {
                return baseCriteria;
            }
        }));
    }).withIcon(FontAwesome.PRINT).withStyleName(UIConstants.BUTTON_OPTION)
            .withDescription(AppContext.getMessage(GenericI18Enum.ACTION_EXPORT));
    groupWrapLayout.addComponent(printBtn);

    MButton newTaskBtn = new MButton(AppContext.getMessage(TaskI18nEnum.NEW), clickEvent -> {
        if (CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS)) {
            SimpleTask newTask = new SimpleTask();
            newTask.setProjectid(CurrentProjectVariables.getProjectId());
            newTask.setSaccountid(AppContext.getAccountId());
            newTask.setLogby(AppContext.getUsername());
            UI.getCurrent().addWindow(new TaskAddWindow(newTask));
        }
    }).withIcon(FontAwesome.PLUS).withStyleName(UIConstants.BUTTON_ACTION);
    newTaskBtn.setVisible(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.TASKS));
    groupWrapLayout.addComponent(newTaskBtn);

    Button advanceDisplayBtn = new Button("List");
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    MButton kanbanBtn = new MButton("Kanban", clickEvent -> displayKanbanView()).withWidth("100px")
            .withIcon(FontAwesome.TH).withDescription("Kanban view");

    ToggleButtonGroup viewButtons = new ToggleButtonGroup();
    viewButtons.addButton(advanceDisplayBtn);
    viewButtons.addButton(kanbanBtn);
    viewButtons.withDefaultButton(advanceDisplayBtn);
    groupWrapLayout.addComponent(viewButtons);

    MHorizontalLayout mainLayout = new MHorizontalLayout().withFullHeight().withFullWidth();
    wrapBody = new MVerticalLayout().withMargin(new MarginInfo(false, true, true, false));
    rightColumn = new MVerticalLayout().withWidth("370px")
            .withMargin(new MarginInfo(true, false, false, false));
    mainLayout.with(wrapBody, rightColumn).expand(wrapBody);
    this.with(taskSearchPanel, mainLayout);
}

From source file:com.oodrive.nuage.webui.component.VvrOperationComponent.java

License:Apache License

@Override
public final AbstractComponent createComponent(final VvrModel model, final ModelCreator handler) {

    final HorizontalLayout operationLayout = new HorizontalLayout();
    operationLayout.setMargin(true);/*from  ww w . j a v  a2 s.c o  m*/
    operationLayout.setSpacing(true);
    operationLayout.setWidth("100%");

    // Start and description buttons
    // START/STOP
    final Button startStop = new Button();
    startStop.setWidth(BUTTON_WIDTH);
    startStop.addStyleName(Runo.BUTTON_BIG);

    final Resource iconStartStop;
    final String description;
    if (!model.isVvrStarted()) {
        iconStartStop = WebUiResources.getStartIcon();
        description = "Start";
    } else {
        iconStartStop = WebUiResources.getStopIcon();
        description = "Stop";
    }
    startStop.setIcon(iconStartStop);
    startStop.setDescription(description);

    operationLayout.addComponent(startStop);
    operationLayout.setExpandRatio(startStop, 1f);
    operationLayout.setComponentAlignment(startStop, Alignment.MIDDLE_LEFT);

    final UUID vvrUuid = model.getItemUuid();
    startStop.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            final boolean started = model.isVvrStarted();
            // Start/Stop are done in background
            if (!started) {
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.startVvr();
                    }

                    @Override
                    public void postProcessing() {
                        startStop.setIcon(WebUiResources.getStopIcon());
                        startStop.setDescription("Stop");
                        Notification.show("VVR started ", vvrUuid.toString(),
                                Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            } else {
                WaitingComponent.executeBackground(model, new Background() {
                    @Override
                    public void processing() {
                        model.stopVvr();
                    }

                    @Override
                    public void postProcessing() {
                        startStop.setIcon(WebUiResources.getStartIcon());
                        startStop.setDescription("Start");
                        Notification.show("VVR stopped ", vvrUuid.toString(),
                                Notification.Type.TRAY_NOTIFICATION);
                    }
                });
            }
        }
    });

    // ATTRIBUTES
    final Button attributes = new Button();
    attributes.addStyleName(Runo.BUTTON_BIG);
    attributes.setWidth(BUTTON_WIDTH);

    operationLayout.addComponent(attributes);
    operationLayout.setExpandRatio(attributes, 1f);
    operationLayout.setComponentAlignment(attributes, Alignment.MIDDLE_LEFT);
    attributes.setIcon(WebUiResources.getSettingsIcon());
    attributes.setDescription("Settings");

    attributes.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final VvrAttributesWindow attributesWindow = new VvrAttributesWindow(vvrUuid);
                attributesWindow.add(model);
            } catch (final Exception e) {
                LOGGER.error("Can not get VVR attributes: ", e);
                final ErrorWindow err = new ErrorWindow("Can not display VVR Attributes: " + e.getMessage());
                err.add(model);
            }
        }
    });

    // DELETE
    final Button delete = new Button();
    delete.addStyleName(Runo.BUTTON_BIG);
    delete.setWidth(BUTTON_WIDTH);
    delete.setIcon(WebUiResources.getTrashIcon());
    delete.setDescription("Delete");

    operationLayout.addComponent(delete);
    operationLayout.setExpandRatio(delete, 12f);
    operationLayout.setComponentAlignment(delete, Alignment.MIDDLE_RIGHT);

    delete.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent event) {
            try {
                final VvrDeleteWindow deleteWindow = new VvrDeleteWindow(vvrUuid);
                deleteWindow.add(vvrManagerModel);
            } catch (final Exception e) {
                LOGGER.error("Can not delete VVR: ", e);
                final ErrorWindow err = new ErrorWindow("Can not delete VVR: " + e.getMessage());
                err.add(model);
            }
        }
    });
    return operationLayout;
}

From source file:com.purebred.core.view.EntityForm.java

License:Open Source License

/**
 * Created the footer buttons: cancel, refresh, save
 *
 * @param footerLayout horizontal layout containing buttons
 *///  www . j  av  a 2  s.  c om
@Override
protected void createFooterButtons(HorizontalLayout footerLayout) {
    footerLayout.setSpacing(true);
    footerLayout.setMargin(true);

    Button cancelButton = new Button(uiMessageSource.getMessage("entityForm.cancel"), this, "cancel");
    cancelButton.setDescription(uiMessageSource.getMessage("entityForm.cancel.description"));
    cancelButton.setIcon(new ThemeResource("icons/16/cancel.png"));
    cancelButton.addStyleName("small default");
    footerLayout.addComponent(cancelButton);

    refreshButton = new Button(uiMessageSource.getMessage("entityForm.refresh"), this, "refresh");
    refreshButton.setDescription(uiMessageSource.getMessage("entityForm.refresh.description"));
    refreshButton.setIcon(new ThemeResource("icons/16/refresh.png"));
    refreshButton.addStyleName("small default");
    footerLayout.addComponent(refreshButton);

    saveAndStayOpenButton = new Button(uiMessageSource.getMessage("entityForm.saveAndStayOpen"), this,
            "saveAndStayOpen");
    saveAndStayOpenButton.setDescription(uiMessageSource.getMessage("entityForm.save.description"));
    saveAndStayOpenButton.setIcon(new ThemeResource("icons/16/save.png"));
    saveAndStayOpenButton.addStyleName("small default");
    footerLayout.addComponent(saveAndStayOpenButton);

    saveAndCloseButton = new Button(uiMessageSource.getMessage("entityForm.saveAndClose"), this,
            "saveAndClose");
    saveAndCloseButton.setDescription(uiMessageSource.getMessage("entityForm.save.description"));
    saveAndCloseButton.setIcon(new ThemeResource("icons/16/save.png"));
    saveAndCloseButton.addStyleName("small default");
    footerLayout.addComponent(saveAndCloseButton);
}

From source file:com.purebred.core.view.Results.java

License:Open Source License

private HorizontalLayout createNavigationLine() {

    HorizontalLayout resultCountDisplay = new HorizontalLayout();
    Label showingLabel = new Label(uiMessageSource.getMessage("entityResults.showing") + " &nbsp ",
            Label.CONTENT_XHTML);
    showingLabel.setSizeUndefined();//from w w  w.j  av  a 2 s. c  om
    showingLabel.addStyleName("small");
    resultCountDisplay.addComponent(showingLabel);
    firstResultTextField = createFirstResultTextField();
    firstResultTextField.addStyleName("small");
    firstResultTextField.setSizeUndefined();
    resultCountDisplay.addComponent(firstResultTextField);
    resultCountLabel = new Label("", Label.CONTENT_XHTML);
    resultCountLabel.setSizeUndefined();
    resultCountLabel.addStyleName("small");
    resultCountDisplay.addComponent(resultCountLabel);

    Label spaceLabel = new Label("   ", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();
    resultCountDisplay.addComponent(spaceLabel);

    Button refreshButton = new Button(null, getResultsTable(), "refresh");
    refreshButton.setDescription(uiMessageSource.getMessage("entityResults.refresh.description"));
    refreshButton.setSizeUndefined();
    refreshButton.addStyleName("borderless");
    refreshButton.setIcon(new ThemeResource("icons/16/refresh-blue.png"));
    resultCountDisplay.addComponent(refreshButton);

    HorizontalLayout navigationButtons = new HorizontalLayout();
    navigationButtons.setMargin(false, true, false, false);
    navigationButtons.setSpacing(true);

    String perPageText = uiMessageSource.getMessage("entityResults.pageSize");
    pageSizeMenu = new Select();
    pageSizeMenu.addStyleName("small");
    pageSizeMenu.addItem(5);
    pageSizeMenu.setItemCaption(5, "5 " + perPageText);
    pageSizeMenu.addItem(10);
    pageSizeMenu.setItemCaption(10, "10 " + perPageText);
    pageSizeMenu.addItem(25);
    pageSizeMenu.setItemCaption(25, "25 " + perPageText);
    pageSizeMenu.addItem(50);
    pageSizeMenu.setItemCaption(50, "50 " + perPageText);
    pageSizeMenu.addItem(100);
    pageSizeMenu.setItemCaption(100, "100 " + perPageText);
    pageSizeMenu.setFilteringMode(Select.FILTERINGMODE_OFF);
    pageSizeMenu.setNewItemsAllowed(false);
    pageSizeMenu.setNullSelectionAllowed(false);
    pageSizeMenu.setImmediate(true);
    pageSizeMenu.setWidth(8, UNITS_EM);
    navigationButtons.addComponent(pageSizeMenu);

    firstButton = new Button(null, getResultsTable(), "firstPage");
    firstButton.setDescription(uiMessageSource.getMessage("entityResults.first.description"));
    firstButton.setSizeUndefined();
    firstButton.addStyleName("borderless");
    firstButton.setIcon(new ThemeResource("icons/16/first.png"));
    navigationButtons.addComponent(firstButton);

    previousButton = new Button(null, getResultsTable(), "previousPage");
    previousButton.setDescription(uiMessageSource.getMessage("entityResults.previous.description"));
    previousButton.setSizeUndefined();
    previousButton.addStyleName("borderless");
    previousButton.setIcon(new ThemeResource("icons/16/previous.png"));
    navigationButtons.addComponent(previousButton);

    nextButton = new Button(null, getResultsTable(), "nextPage");
    nextButton.setDescription(uiMessageSource.getMessage("entityResults.next.description"));
    nextButton.setSizeUndefined();
    nextButton.addStyleName("borderless");
    nextButton.setIcon(new ThemeResource("icons/16/next.png"));
    navigationButtons.addComponent(nextButton);

    lastButton = new Button(null, getResultsTable(), "lastPage");
    lastButton.setDescription(uiMessageSource.getMessage("entityResults.last.description"));
    lastButton.setSizeUndefined();
    lastButton.addStyleName("borderless");
    lastButton.setIcon(new ThemeResource("icons/16/last.png"));
    navigationButtons.addComponent(lastButton);

    HorizontalLayout navigationLine = new HorizontalLayout();
    navigationLine.setWidth("100%");
    navigationLine.setMargin(true, true, true, false);

    navigationLine.addComponent(resultCountDisplay);
    navigationLine.setComponentAlignment(resultCountDisplay, Alignment.BOTTOM_LEFT);

    navigationLine.addComponent(navigationButtons);
    navigationLine.setComponentAlignment(navigationButtons, Alignment.BOTTOM_RIGHT);

    return navigationLine;
}