Example usage for com.vaadin.ui Button setWidth

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

Introduction

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

Prototype

@Override
    public void setWidth(String width) 

Source Link

Usage

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

License:Open Source License

public TaskKanbanviewImpl() {
    this.setSizeFull();
    this.withSpacing(true).withMargin(new MarginInfo(false, true, true, true));
    searchPanel = new TaskSearchPanel();
    MHorizontalLayout groupWrapLayout = new MHorizontalLayout();
    groupWrapLayout.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
    searchPanel.addHeaderRight(groupWrapLayout);

    Button addNewColumnBtn = new Button("New column", new Button.ClickListener() {
        @Override/*  w ww. ja  va  2 s . co m*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            UI.getCurrent()
                    .addWindow(new AddNewColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    addNewColumnBtn.setIcon(FontAwesome.PLUS);
    addNewColumnBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    addNewColumnBtn.setStyleName(UIConstants.BUTTON_ACTION);
    groupWrapLayout.addComponent(addNewColumnBtn);

    Button deleteColumBtn = new Button("Delete columns", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            UI.getCurrent()
                    .addWindow(new DeleteColumnWindow(TaskKanbanviewImpl.this, ProjectTypeConstants.TASK));
        }
    });
    deleteColumBtn.setIcon(FontAwesome.TRASH_O);
    deleteColumBtn.setEnabled(CurrentProjectVariables.canAccess(ProjectRolePermissionCollections.TASKS));
    deleteColumBtn.setStyleName(UIConstants.BUTTON_DANGER);

    Button advanceDisplayBtn = new Button("List", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            EventBusFactory.getInstance().post(new TaskEvent.GotoDashboard(TaskKanbanviewImpl.this, null));
        }
    });
    advanceDisplayBtn.setWidth("100px");
    advanceDisplayBtn.setIcon(FontAwesome.SITEMAP);
    advanceDisplayBtn.setDescription("Advance View");

    Button kanbanBtn = new Button("Kanban");
    kanbanBtn.setWidth("100px");
    kanbanBtn.setDescription("Kanban View");
    kanbanBtn.setIcon(FontAwesome.TH);

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

    kanbanLayout = new DDHorizontalLayout();
    kanbanLayout.setHeight("100%");
    kanbanLayout.addStyleName("kanban-layout");
    kanbanLayout.setSpacing(true);
    kanbanLayout.setMargin(new MarginInfo(true, false, true, false));
    kanbanLayout.setComponentHorizontalDropRatio(0.3f);
    kanbanLayout.setDragMode(LayoutDragMode.CLONE_OTHER);

    //      Enable dropping components
    kanbanLayout.setDropHandler(new DropHandler() {
        @Override
        public void drop(DragAndDropEvent event) {
            LayoutBoundTransferable transferable = (LayoutBoundTransferable) event.getTransferable();

            DDHorizontalLayout.HorizontalLayoutTargetDetails details = (DDHorizontalLayout.HorizontalLayoutTargetDetails) event
                    .getTargetDetails();
            Component dragComponent = transferable.getComponent();
            if (dragComponent instanceof KanbanBlock) {
                KanbanBlock kanbanItem = (KanbanBlock) dragComponent;
                int newIndex = details.getOverIndex();
                if (details.getDropLocation() == HorizontalDropLocation.RIGHT) {
                    kanbanLayout.addComponent(kanbanItem);
                } else if (newIndex == -1) {
                    kanbanLayout.addComponent(kanbanItem, 0);
                } else {
                    kanbanLayout.addComponent(kanbanItem, newIndex);
                }

                //Update options index for this project
                List<Map<String, Integer>> indexMap = new ArrayList<>();
                for (int i = 0; i < kanbanLayout.getComponentCount(); i++) {
                    KanbanBlock blockItem = (KanbanBlock) kanbanLayout.getComponent(i);
                    Map<String, Integer> map = new HashedMap(2);
                    map.put("id", blockItem.optionVal.getId());
                    map.put("index", i);
                    indexMap.add(map);
                }
                if (indexMap.size() > 0) {
                    optionValService.massUpdateOptionIndexes(indexMap, AppContext.getAccountId());
                }
            }
        }

        @Override
        public AcceptCriterion getAcceptCriterion() {
            return new Not(VerticalLocationIs.MIDDLE);
        }
    });
    this.setWidth("100%");
    this.with(searchPanel, kanbanLayout).expand(kanbanLayout);
}

From source file:com.esofthead.mycollab.module.project.view.user.ProjectActivityStreamPagedList.java

License:Open Source License

@Override
protected CssLayout createPageControls() {
    this.controlBarWrapper = new CssLayout();
    this.controlBarWrapper.setWidth("100%");
    this.controlBarWrapper.setStyleName("page-controls");
    ButtonGroup controlBtns = new ButtonGroup();
    controlBtns.setStyleName(UIConstants.THEME_GREEN_LINK);
    Button prevBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_NEWER),
            new Button.ClickListener() {
                private static final long serialVersionUID = -94021599166105307L;

                @Override/*from  w  w  w.  j a va 2 s .com*/
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage - 1);
                }
            });
    if (currentPage == 1) {
        prevBtn.setEnabled(false);
    }
    prevBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    prevBtn.setWidth("64px");

    Button nextBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_NAV_OLDER),
            new Button.ClickListener() {
                private static final long serialVersionUID = 3095522916508256018L;

                @Override
                public void buttonClick(ClickEvent event) {
                    ProjectActivityStreamPagedList.this
                            .pageChange(ProjectActivityStreamPagedList.this.currentPage + 1);
                }
            });
    if (currentPage == totalPage) {
        nextBtn.setEnabled(false);
    }
    nextBtn.setStyleName(UIConstants.THEME_GREEN_LINK);
    nextBtn.setWidth("64px");

    controlBtns.addButton(prevBtn);
    controlBtns.addButton(nextBtn);

    this.controlBarWrapper.addComponent(controlBtns);

    return this.controlBarWrapper;
}

From source file:com.esofthead.mycollab.module.project.view.user.ProjectListComponent.java

License:Open Source License

public ProjectListComponent() {
    super();//from w w w  .j a v  a  2 s. c om
    withSpacing(true).withMargin(false).withWidth("100%").withStyleName("project-list-comp");

    MHorizontalLayout headerBar = new MHorizontalLayout();

    headerPopupButton = new PopupButton();
    headerPopupButton.setStyleName("project-list-comp-hdr");
    headerPopupButton.setWidth("100%");

    Label componentHeader = new Label();
    componentHeader.setStyleName("h2");

    headerPopupButton.setIcon(ProjectAssetsManager.getAsset(ProjectTypeConstants.PROJECT));
    headerBar.with(headerPopupButton);

    if (AppContext.canBeYes(RolePermissionCollections.CREATE_NEW_PROJECT)) {
        final Button createProjectBtn = new Button("+", new Button.ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(final Button.ClickEvent event) {
                final ProjectAddWindow projectNewWindow = new ProjectAddWindow();
                UI.getCurrent().addWindow(projectNewWindow);
            }
        });
        createProjectBtn.setStyleName("add-project-btn");
        createProjectBtn.setDescription("New Project");
        createProjectBtn.setWidth("20px");
        createProjectBtn.setHeight("20px");

        headerBar.with(createProjectBtn).withAlign(createProjectBtn, Alignment.MIDDLE_RIGHT);
    }

    headerBar.withWidth("100%").withSpacing(true).expand(headerPopupButton);

    this.addComponent(headerBar);

    contentLayout = new MVerticalLayout().withStyleName("project-list-comp-content").withWidth("205px");

    projectList = new ProjectPagedList();
    headerPopupButton.setContent(projectList);

    projectDesc = new Label("", ContentMode.HTML);
    projectDesc.setStyleName("project-description");
    addComponent(projectDesc);
}

From source file:com.esofthead.mycollab.vaadin.web.ui.OptionPopupContent.java

License:Open Source License

public void addOption(Button btn) {
    CssLayout wrap = new CssLayout();
    btn.setWidth("100%");
    btn.setDescription(btn.getCaption());
    btn.addStyleName("action");
    wrap.addStyleName("action-wrap");
    wrap.addComponent(btn);/*from   w ww  .  j av a2  s .co m*/
    ((ComponentContainer) this.getCompositionRoot()).addComponent(wrap);
}

From source file:com.esspl.datagen.ui.DataExportView.java

License:Open Source License

public DataExportView() {
    log.debug("DataExportView-> Loading Constructor.");

    setWidth("95px");
    Button excelButton = new Button("Excel");
    excelButton.setIcon(DataGenConstant.DATAIMPORT_EXCEL_ICON);
    excelButton.setWidth("95px");
    addComponent(excelButton);//from  w w  w .j  a  va2 s .c o m
    excelButton.addListener(ClickEvent.class, this, "excelExportButtonClick");

    Button sqlButton = new Button("Sql");
    sqlButton.setIcon(DataGenConstant.DATAEXPORT_SQL_ICON);
    sqlButton.setWidth("95px");
    addComponent(sqlButton);
    sqlButton.addListener(ClickEvent.class, this, "sqlExportButtonClick");

}

From source file:com.esspl.datagen.ui.DataImportView.java

License:Open Source License

public DataImportView() {
    log.debug("DataExportView-> Loading Constructor.");

    setWidth("95px");
    Button excelButton = new Button("Excel");
    excelButton.setIcon(DataGenConstant.DATAIMPORT_EXCEL_ICON);
    excelButton.setWidth("95px");
    addComponent(excelButton);/*from w w w .j  av a 2s  .  c o m*/
    excelButton.addListener(ClickEvent.class, this, "excelImportButtonClick");

    Button sqlButton = new Button("Sql");
    sqlButton.setIcon(DataGenConstant.DATAEXPORT_SQL_ICON);
    sqlButton.setWidth("95px");
    addComponent(sqlButton);
    sqlButton.addListener(ClickEvent.class, this, "sqlImportButtonClick");

}

From source file:com.etest.view.systemadministration.curriculum.CurriculumFormWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setMargin(true);/*from  w  w  w  .j a  v a2s  .  c  o  m*/

    yearLevel.setWidth("75%");
    form.addComponent(yearLevel);

    subjectField.setWidth("75%");
    form.addComponent(subjectField);

    normCourseOffering.setWidth("75%");
    form.addComponent(normCourseOffering);

    descriptiveTitleField.setWidth("100%");
    descriptiveTitleField.setRows(3);
    descriptiveTitleField.setInputPrompt("Descriptive Title..");
    form.addComponent(descriptiveTitleField);

    Button save = new Button("SAVE");
    save.setWidth("100%");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button update = new Button("UPDATE");
    update.setWidth("100%");
    update.setIcon(FontAwesome.ADJUST);
    update.addStyleName(ValoTheme.BUTTON_PRIMARY);
    update.addStyleName(ValoTheme.BUTTON_SMALL);
    update.addClickListener(buttonClickListener);

    Button delete = new Button("DELETE");
    delete.setWidth("100%");
    delete.setIcon(FontAwesome.ERASER);
    delete.addStyleName(ValoTheme.BUTTON_PRIMARY);
    delete.addStyleName(ValoTheme.BUTTON_SMALL);
    delete.addClickListener(buttonClickListener);

    HorizontalLayout hlayout = new HorizontalLayout();
    hlayout.setWidth("100%");
    hlayout.setSpacing(true);

    if (getCurriculumId() != 0) {
        hlayout.addComponent(update);
        hlayout.addComponent(delete);
        Curriculum c = cs.getCurriculumById(getCurriculumId());
        yearLevel.setValue(c.getYearLevel());
        subjectField.setValue(c.getSubject());
        normCourseOffering.setValue(c.getNormCourseOffering());
        descriptiveTitleField.setValue(c.getDescriptiveTitle());

        if (getButtonCaption().equals("edit")) {
            delete.setVisible(false);
        } else {
            update.setVisible(false);
        }
    } else {
        hlayout.addComponent(save);
    }

    form.addComponent(hlayout);

    return form;
}

From source file:com.etest.view.systemadministration.CurriculumMainUI.java

public CurriculumMainUI() {
    setSizeFull();//from w  w w .j  a va  2 s .c o m
    setMargin(true);
    setSpacing(true);

    //        addComponent(buildForms());
    //        populateDataGrid();

    Button newBtn = new Button("ADD NEW CURRICULUM");
    newBtn.setWidth("220px");
    newBtn.setIcon(FontAwesome.OPENID);
    newBtn.addStyleName(ValoTheme.BUTTON_LINK);
    newBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    newBtn.addClickListener(buttonClickListener);

    addComponent(newBtn);
    addComponent(dataGridPanel());
}

From source file:com.etest.view.systemadministration.FacultyMainUI.java

public FacultyMainUI() {
    setSizeFull();//from   w  w  w . j av a 2 s  . co  m
    setSpacing(true);
    setMargin(true);

    Button formBtn = new Button("NEW FACULTY FORM");
    formBtn.setWidth("230px");
    formBtn.setIcon(FontAwesome.OPENID);
    formBtn.addStyleName(ValoTheme.BUTTON_LINK);
    formBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    formBtn.addClickListener(formBtnClickListener);
    addComponent(formBtn);

    addComponent(getDataTablePanel());
}

From source file:com.etest.view.systemadministration.FacultyMainUI.java

Table populateDataTable() {
    table.removeAllItems();/*www .  j  a  v  a2  s  . c o  m*/
    int i = 0;
    for (Users u : fs.getAllFaculty()) {
        HorizontalLayout hlayout = new HorizontalLayout();
        hlayout.setWidth("100%");

        Button edit = new Button("edit");
        edit.setWidth("100%");
        edit.setData(u.getFacultyId());
        edit.setIcon(FontAwesome.PENCIL);
        edit.addStyleName(ValoTheme.BUTTON_LINK);
        edit.addStyleName(ValoTheme.BUTTON_TINY);
        edit.addStyleName("button-container");
        edit.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(edit);

        Button delete = new Button("del");
        delete.setWidth("100%");
        delete.setData(u.getFacultyId());
        delete.setIcon(FontAwesome.TRASH_O);
        delete.addStyleName(ValoTheme.BUTTON_LINK);
        delete.addStyleName(ValoTheme.BUTTON_TINY);
        delete.addStyleName("button-container");
        delete.addClickListener(modifyBtnClickListener);
        hlayout.addComponent(delete);

        table.addItem(new Object[] { u.getName().toUpperCase(), u.getUsername_(), u.getUserType(), hlayout },
                new Integer(i));
        i++;
    }
    table.setPageLength(table.size());

    //        table.getListeners(ItemClickEvent.class).stream().forEach((listener) -> {
    //            table.removeListener(ItemClickEvent.class, listener);
    //        });

    //        table.addItemClickListener((ItemClickEvent event) -> {
    //            Property itemProperty = event.getItem().getItemProperty("name");
    //            facultyId = fs.getFacultyIdByName(itemProperty.getValue().toString());
    //            
    //            Window sub = new FacultyFormWindow(facultyId);
    //            if(sub.getParent() == null){
    //                UI.getCurrent().addWindow(sub);
    //            }
    //        });

    return table;
}