List of usage examples for com.vaadin.ui Button setWidth
@Override public void setWidth(String width)
From source file:com.mycollab.mobile.module.crm.ui.CrmPreviewFormControlsGenerator.java
License:Open Source License
public VerticalLayout createButtonControls(int buttonEnableFlags, final String permissionItem) { boolean canWrite = true; boolean canAccess = true; if (permissionItem != null) { canWrite = UserUIContext.canWrite(permissionItem); canAccess = UserUIContext.canAccess(permissionItem); }/*from www. ja va 2s . co m*/ if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { MButton editBtn = new MButton(UserUIContext.getMessage(GenericI18Enum.BUTTON_EDIT), clickEvent -> { final T item = previewForm.getBean(); previewForm.fireEditForm(item); }).withVisible(canWrite); editButtons.addComponent(editBtn); editButtons.setComponentAlignment(editBtn, Alignment.MIDDLE_CENTER); } if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) { Button deleteBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_DELETE), clickEvent -> { final T item = previewForm.getBean(); previewForm.fireDeleteForm(item); }); editButtons.addComponent(deleteBtn); editButtons.setComponentAlignment(deleteBtn, Alignment.MIDDLE_CENTER); deleteBtn.setEnabled(canAccess); } if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) { Button cloneBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_CLONE), clickEvent -> { T item = previewForm.getBean(); previewForm.fireCloneForm(item); }); cloneBtn.setWidth("100%"); editButtons.addComponent(cloneBtn); editButtons.setComponentAlignment(cloneBtn, Alignment.MIDDLE_CENTER); cloneBtn.setEnabled(canWrite); } return editButtons; }
From source file:com.mycollab.mobile.module.project.view.bug.BugReadViewImpl.java
License:Open Source License
private void displayWorkflowControl() { bugWorkFlowControl.removeAllComponents(); if (BugStatus.Open.name().equals(beanItem.getStatus()) || BugStatus.ReOpen.name().equals(beanItem.getStatus())) { final Button resolveBtn = new Button(UserUIContext.getMessage(BugI18nEnum.BUTTON_RESOLVED), clickEvent -> EventBusFactory.getInstance().post( new ShellEvent.PushView(this, new ResolvedInputView(BugReadViewImpl.this, beanItem)))); resolveBtn.setWidth("100%"); bugWorkFlowControl.addComponent(resolveBtn); } else if (BugStatus.Verified.name().equals(beanItem.getStatus())) { final Button reopenBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_REOPEN), clickEvent -> EventBusFactory.getInstance() .post(new ShellEvent.PushView(this, new ReOpenView(BugReadViewImpl.this, beanItem)))); reopenBtn.setWidth("100%"); bugWorkFlowControl.addComponent(reopenBtn); } else if (BugStatus.Resolved.name().equals(beanItem.getStatus())) { final Button reopenBtn = new Button(UserUIContext.getMessage(GenericI18Enum.BUTTON_REOPEN), clickEvent -> EventBusFactory.getInstance() .post(new ShellEvent.PushView(this, new ReOpenView(BugReadViewImpl.this, beanItem)))); reopenBtn.setWidth("100%"); bugWorkFlowControl.addComponent(reopenBtn); final Button approveNCloseBtn = new Button(UserUIContext.getMessage(BugI18nEnum.BUTTON_APPROVE_CLOSE), clickEvent -> EventBusFactory.getInstance().post( new ShellEvent.PushView(this, new ApproveInputView(BugReadViewImpl.this, beanItem)))); approveNCloseBtn.setWidth("100%"); bugWorkFlowControl.addComponent(approveNCloseBtn); }/* w ww .j av a 2s .c o m*/ bugWorkFlowControl.setEnabled(CurrentProjectVariables.canWrite(ProjectRolePermissionCollections.BUGS)); }
From source file:com.mycollab.mobile.shell.view.MainView.java
License:Open Source License
public MainView() { super();/*from w ww. ja va2 s. c om*/ this.setSizeFull(); MVerticalLayout contentLayout = new MVerticalLayout().withStyleName("content-wrapper").withFullWidth(); contentLayout.setDefaultComponentAlignment(Alignment.TOP_CENTER); Image mainLogo = new Image(null, new ThemeResource("icons/logo_m.png")); contentLayout.addComponent(mainLogo); Label introText = new Label( "MyCollab helps you do all your office jobs on the computers, phones and tablets you use"); introText.setStyleName("intro-text"); contentLayout.addComponent(introText); CssLayout welcomeTextWrapper = new CssLayout(); welcomeTextWrapper.setStyleName("welcometext-wrapper"); welcomeTextWrapper.setWidth("100%"); welcomeTextWrapper.setHeight("15px"); contentLayout.addComponent(welcomeTextWrapper); Button crmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null))); crmButton.addStyleName(MobileUIConstants.BUTTON_ACTION); crmButton.setWidth("100%"); contentLayout.addComponent(crmButton); Button pmButton = new Button(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), clickEvent -> EventBusFactory.getInstance().post(new ShellEvent.GotoProjectModule(this, null))); pmButton.setWidth("100%"); pmButton.addStyleName(MobileUIConstants.BUTTON_ACTION); contentLayout.addComponent(pmButton); this.addComponent(contentLayout); }
From source file:com.mycollab.mobile.ui.ConfirmDialog.java
License:Open Source License
private void constructUI(final String message, final String okCaption, final String cancelCaption) { VerticalLayout layout = new VerticalLayout(); layout.setWidth("100%"); layout.setHeightUndefined();// www .ja v a 2 s. com layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); VerticalLayout messageWrapper = new VerticalLayout(); messageWrapper.setStyleName("message-wrapper"); messageWrapper.setWidth("100%"); messageWrapper.setMargin(true); final Label messageDisplay = new Label(message); messageDisplay.setWidth("100%"); messageWrapper.addComponent(messageDisplay); layout.addComponent(messageWrapper); HorizontalLayout controlBtn = new HorizontalLayout(); controlBtn.setWidth("100%"); final Button okBtn = new Button(okCaption); okBtn.setWidth("100%"); okBtn.setHeight("35px"); final Button cancelBtn = new Button(cancelCaption); cancelBtn.setWidth("100%"); cancelBtn.setHeight("35px"); ClickListener listener = (clickEvent) -> { ConfirmDialog.this.setConfirmed(clickEvent.getButton() == okBtn); if (ConfirmDialog.this.getListener() != null) { ConfirmDialog.this.getListener().onClose(ConfirmDialog.this); } close(); }; okBtn.addClickListener(listener); cancelBtn.addClickListener(listener); controlBtn.addComponent(cancelBtn); controlBtn.addComponent(okBtn); layout.addComponent(controlBtn); this.setContent(layout); }
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 {// w w w.j a v a2 s. c om 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.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//from w ww . j a v a2s . com 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 w ww .j a va2s .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.openhris.administrator.ChangePassword.java
public ComponentContainer layout() { VerticalLayout vlayout = new VerticalLayout(); vlayout.setSpacing(true);/*from ww w . ja v a 2s . co m*/ vlayout.setMargin(true); vlayout.setSizeFull(); vlayout.setImmediate(true); final PasswordField currentPassword = createPasswordField("Current Password: "); vlayout.addComponent(currentPassword); final PasswordField newPassword = createPasswordField("New Password: "); vlayout.addComponent(newPassword); final PasswordField rePassword = createPasswordField("Re-enter Password: "); vlayout.addComponent(rePassword); Button changeBtn = new Button("UPDATE PASSWORD"); changeBtn.setWidth("100%"); changeBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!adminService.checkEnteredPasswordIfCorrect(getUserId(), currentPassword.getValue().toString().toLowerCase().trim())) { getWindow().showNotification("Incorrect Password, contact your Administrator!", Window.Notification.TYPE_WARNING_MESSAGE); return; } if (!newPassword.getValue().toString().toLowerCase().trim() .equals(rePassword.getValue().toString().toLowerCase().trim())) { getWindow().showNotification("Entered Password do not Match!", Window.Notification.TYPE_WARNING_MESSAGE); return; } boolean result = adminService.updateUserPassword(getUserId(), rePassword.getValue().toString().toLowerCase().trim()); if (result) { GlobalVariables.setLogoutAfterPasswordChange(true); close(); } else { GlobalVariables.setLogoutAfterPasswordChange(false); getWindow().showNotification("Change Password SQL Error!, Contact your DBA", Window.Notification.TYPE_ERROR_MESSAGE); return; } } }); vlayout.addComponent(changeBtn); return vlayout; }
From source file:com.openhris.administrator.SpecialAccessControl.java
public SpecialAccessControl() { setMargin(true);//from ww w .j a v a 2s . c o m setSpacing(true); addComponent(userList()); allowedBackwardInputAttendance.setCaption("Allow user to enter previous attendance."); allowedBackwardInputAttendance.addListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (event.getButton().booleanValue()) { val = 1; } else { val = 0; } } }); allowedBackwardInputAttendance.setImmediate(true); addComponent(allowedBackwardInputAttendance); Button button = new Button("UPDATE"); button.setWidth("200px"); button.addListener(new ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (users.getValue() == null) { getWindow().showNotification("Select a User!", Window.Notification.TYPE_WARNING_MESSAGE); return; } boolean isUserAllowed = service.updateUserAllowedToEnterPreviousAttendance( util.convertStringToInteger(users.getValue().toString()), isAllowed()); if (isUserAllowed) { getWindow().showNotification("User is allowed to Enter Previous Attendance!", Window.Notification.TYPE_TRAY_NOTIFICATION); } } }); button.setImmediate(true); addComponent(button); }
From source file:com.openhris.calendar.CalendarScheduleWindow.java
Window getDeleteWindow() { final Window sub = new Window("DELETE EVENT"); sub.setWidth("250px"); Button deleteBtn = new Button("DELETE EVENT?"); deleteBtn.setWidth("100%"); deleteBtn.addListener(new Button.ClickListener() { @Override/*from w ww .j ava2 s . com*/ public void buttonClick(Button.ClickEvent event) { boolean result = calendarService .removeEvent(utilities.convertStringToInteger(eventDataId.getValue().toString())); if (result) { getApplication().getMainWindow().removeWindow(sub); close(); getCalendar().removeEvent(getEvent().getCalendarEvent()); } } }); sub.addComponent(deleteBtn); return sub; }