List of usage examples for com.vaadin.ui Button setStyleName
@Override public void setStyleName(String style)
From source file:com.esofthead.mycollab.vaadin.web.ui.DynamicQueryParamLayout.java
License:Open Source License
private HorizontalLayout createButtonControls() { MHorizontalLayout buttonControls = new MHorizontalLayout() .withMargin(new MarginInfo(false, true, false, true)); Button searchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override// w ww .j ava 2s.c o m public void buttonClick(final ClickEvent event) { callSearchAction(); } }); searchBtn.setStyleName(UIConstants.BUTTON_ACTION); searchBtn.setIcon(FontAwesome.SEARCH); buttonControls.with(searchBtn).withAlign(searchBtn, Alignment.MIDDLE_CENTER); Button clearBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLEAR), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { clearFields(); } }); clearBtn.setStyleName(UIConstants.BUTTON_OPTION); buttonControls.with(clearBtn).withAlign(clearBtn, Alignment.MIDDLE_CENTER); Button basicSearchBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_BASIC_SEARCH), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { ((DefaultGenericSearchPanel<S>) searchPanel).moveToBasicSearchLayout(); } }); basicSearchBtn.setStyleName(UIConstants.BUTTON_LINK); buttonControls.with(basicSearchBtn).withAlign(basicSearchBtn, Alignment.MIDDLE_CENTER); return buttonControls; }
From source file:com.esofthead.mycollab.vaadin.web.ui.EditFormControlsGenerator.java
License:Open Source License
public HorizontalLayout createButtonControls(boolean isSaveBtnVisible, boolean isSaveAndNewBtnVisible, boolean isCancelBtnVisible) { MHorizontalLayout layout = new MHorizontalLayout().withStyleName("addNewControl"); layout.setDefaultComponentAlignment(Alignment.MIDDLE_CENTER); layout.setSizeUndefined();//w w w . j a va2s. com if (isSaveBtnVisible) { final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (editForm.validateForm()) { editForm.fireSaveForm(); } } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); layout.addComponent(saveBtn); } if (isSaveAndNewBtnVisible) { Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { if (editForm.validateForm()) { editForm.fireSaveAndNewForm(); } } }); saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT); saveAndNewBtn.setStyleName(UIConstants.BUTTON_ACTION); layout.addComponent(saveAndNewBtn); } if (isCancelBtnVisible) { Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { editForm.fireCancelForm(); } }); cancelBtn.setIcon(FontAwesome.MINUS); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); layout.addComponent(cancelBtn); } return layout; }
From source file:com.esofthead.mycollab.vaadin.web.ui.MailFormWindow.java
License:Open Source License
private void initUI() { GridLayout mainLayout = new GridLayout(1, 5); mainLayout.setWidth("100%"); mainLayout.setMargin(true);/*ww w .j a v a 2s . c o m*/ mainLayout.setSpacing(true); CssLayout inputPanel = new CssLayout(); inputPanel.setWidth("100%"); inputPanel.setStyleName("mail-panel"); inputLayout = new GridLayout(3, 4); inputLayout.setSpacing(true); inputLayout.setWidth("100%"); inputLayout.setColumnExpandRatio(0, 1.0f); inputPanel.addComponent(inputLayout); mainLayout.addComponent(inputPanel); tokenFieldMailTo = new EmailTokenField(); inputLayout.addComponent(createTextFieldMail("To:", tokenFieldMailTo), 0, 0); if (lstMail != null) { for (String mail : lstMail) { if (StringUtils.isNotBlank(mail)) { if (mail.indexOf("<") > -1) { String strMail = mail.substring(mail.indexOf("<") + 1, mail.lastIndexOf(">")); if (strMail != null && !strMail.equalsIgnoreCase("null")) { } } else { } } } } final TextField subject = new TextField(); subject.setRequired(true); subject.setWidth("100%"); subjectField = createTextFieldMail("Subject:", subject); inputLayout.addComponent(subjectField, 0, 1); initButtonLinkCcBcc(); ccField = createTextFieldMail("Cc:", tokenFieldMailCc); bccField = createTextFieldMail("Bcc:", tokenFieldMailBcc); final RichTextArea noteArea = new RichTextArea(); noteArea.setWidth("100%"); noteArea.setHeight("200px"); mainLayout.addComponent(noteArea, 0, 1); mainLayout.setComponentAlignment(noteArea, Alignment.MIDDLE_CENTER); HorizontalLayout controlsLayout = new HorizontalLayout(); controlsLayout.setWidth("100%"); final AttachmentPanel attachments = new AttachmentPanel(); attachments.setWidth("500px"); MultiFileUploadExt uploadExt = new MultiFileUploadExt(attachments); uploadExt.addComponent(attachments); controlsLayout.addComponent(uploadExt); controlsLayout.setExpandRatio(uploadExt, 1.0f); controlsLayout.setSpacing(true); Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { MailFormWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); controlsLayout.addComponent(cancelBtn); controlsLayout.setComponentAlignment(cancelBtn, Alignment.MIDDLE_RIGHT); Button sendBtn = new Button("Send", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { if (tokenFieldMailTo.getListRecipient().size() <= 0 || subject.getValue().equals("")) { NotificationUtil.showErrorNotification( "To Email field and Subject field must be not empty! Please fulfil them before sending email."); return; } if (AppContext.getUser().getEmail() != null && AppContext.getUser().getEmail().length() > 0) { ExtMailService systemMailService = AppContextUtil.getSpringBean(ExtMailService.class); List<File> listFile = attachments.files(); List<EmailAttachmentSource> emailAttachmentSource = null; if (listFile != null && listFile.size() > 0) { emailAttachmentSource = new ArrayList<>(); for (File file : listFile) { emailAttachmentSource.add(new FileEmailAttachmentSource(file)); } } systemMailService.sendHTMLMail(AppContext.getUser().getEmail(), AppContext.getUser().getDisplayName(), tokenFieldMailTo.getListRecipient(), tokenFieldMailCc.getListRecipient(), tokenFieldMailBcc.getListRecipient(), subject.getValue(), noteArea.getValue(), emailAttachmentSource); MailFormWindow.this.close(); } else { NotificationUtil.showErrorNotification( "Your email is empty value, please fulfil it before sending email!"); } } }); sendBtn.setIcon(FontAwesome.SEND); sendBtn.setStyleName(UIConstants.BUTTON_ACTION); controlsLayout.addComponent(sendBtn); controlsLayout.setComponentAlignment(sendBtn, Alignment.MIDDLE_RIGHT); mainLayout.addComponent(controlsLayout, 0, 2); this.setContent(mainLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.MultiSelectComp.java
License:Open Source License
@Override protected Component initContent() { MHorizontalLayout content = new MHorizontalLayout().withSpacing(true).withWidth(widthVal) .with(componentsText).withAlign(componentsText, Alignment.MIDDLE_LEFT); componentPopupSelection.addStyleName(UIConstants.MULTI_SELECT_BG); componentPopupSelection.setDirection(Alignment.TOP_LEFT); MHorizontalLayout multiSelectComp = new MHorizontalLayout().withSpacing(false) .with(componentsText, componentPopupSelection).expand(componentsText); content.with(multiSelectComp);//ww w . ja v a 2s .c o m if (canAddNew) { Button newBtn = new Button("New", new Button.ClickListener() { @Override public void buttonClick(ClickEvent clickEvent) { requestAddNewComp(); } }); newBtn.setStyleName(UIConstants.BUTTON_LINK); newBtn.setWidthUndefined(); content.with(newBtn); } content.expand(multiSelectComp); return content; }
From source file:com.esofthead.mycollab.vaadin.web.ui.NotificationComponent.java
License:Open Source License
private Component buildComponentFromNotification(AbstractNotification item) { final MHorizontalLayout wrapper = new MHorizontalLayout(); wrapper.setData(item);//ww w . java 2 s . c om wrapper.setDefaultComponentAlignment(Alignment.TOP_LEFT); if (item instanceof NewUpdateAvailableNotification) { final NewUpdateAvailableNotification notification = (NewUpdateAvailableNotification) item; Span spanEl = new Span(); spanEl.appendText( AppContext.getMessage(ShellI18nEnum.OPT_HAVING_NEW_VERSION, notification.getVersion())); Label lbl = new Label(FontAwesome.INFO_CIRCLE.getHtml() + " " + spanEl.write(), ContentMode.HTML); lbl.setWidth("100%"); CssLayout lblWrapper = new CssLayout(); lblWrapper.addComponent(lbl); wrapper.addComponent(lblWrapper); wrapper.expand(lblWrapper); if (AppContext.isAdmin()) { Button upgradeBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPGRADE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().addWindow(new UpgradeConfirmWindow(notification.getVersion(), notification.getManualDownloadLink(), notification.getInstallerFile())); NotificationComponent.this.setPopupVisible(false); } }); upgradeBtn.addStyleName(UIConstants.BUTTON_BLOCK); wrapper.addComponent(upgradeBtn); } } else if (item instanceof RequestUploadAvatarNotification) { wrapper.addComponent(new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.OPT_REQUEST_UPLOAD_AVATAR), ContentMode.HTML)); Button uploadAvatarBtn = new Button(AppContext.getMessage(ShellI18nEnum.ACTION_UPLOAD_AVATAR), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "preview" })); NotificationComponent.this.setPopupVisible(false); } }); uploadAvatarBtn.setStyleName(UIConstants.BUTTON_BLOCK); wrapper.add(uploadAvatarBtn); } else if (item instanceof SmtpSetupNotification) { Button smtpBtn = new Button(AppContext.getMessage(GenericI18Enum.ACTION_SETUP), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new ShellEvent.GotoUserAccountModule(this, new String[] { "setup" })); NotificationComponent.this.setPopupVisible(false); } }); smtpBtn.setStyleName(UIConstants.BUTTON_BLOCK); Label lbl = new Label(FontAwesome.EXCLAMATION_TRIANGLE.getHtml() + " " + AppContext.getMessage(ShellI18nEnum.ERROR_NO_SMTP_SETTING), ContentMode.HTML); MCssLayout lblWrapper = new MCssLayout(lbl); wrapper.with(lblWrapper, smtpBtn).expand(lblWrapper); } else { LOG.error("Do not render notification " + item); } return wrapper; }
From source file:com.esofthead.mycollab.vaadin.web.ui.ProjectPreviewFormControlsGenerator.java
License:Open Source License
public HorizontalLayout createButtonControls(int buttonEnableFlags, String permissionItem) { optionBtn = new PopupButton(); optionBtn.addStyleName(UIConstants.BOX); optionBtn.setIcon(FontAwesome.ELLIPSIS_H); if (permissionItem != null) { boolean canWrite = CurrentProjectVariables.canWrite(permissionItem); boolean canAccess = CurrentProjectVariables.canAccess(permissionItem); boolean canRead = CurrentProjectVariables.canRead(permissionItem); if ((buttonEnableFlags & ASSIGN_BTN_PRESENTED) == ASSIGN_BTN_PRESENTED) { Button assignBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ASSIGN), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireAssignForm(item); }/* w ww .ja v a 2 s . c o m*/ }); assignBtn.setIcon(FontAwesome.SHARE); assignBtn.setStyleName(UIConstants.BUTTON_ACTION); editButtons.addComponent(assignBtn); assignBtn.setEnabled(canWrite); } if ((buttonEnableFlags & ADD_BTN_PRESENTED) == ADD_BTN_PRESENTED) { Button addBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_ADD), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireAddForm(item); } }); addBtn.setIcon(FontAwesome.PLUS); addBtn.setStyleName(UIConstants.BUTTON_ACTION); addBtn.setEnabled(canWrite); editButtons.addComponent(addBtn); } if ((buttonEnableFlags & EDIT_BTN_PRESENTED) == EDIT_BTN_PRESENTED) { Button editBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_EDIT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireEditForm(item); } }); editBtn.setIcon(FontAwesome.EDIT); editBtn.setStyleName(UIConstants.BUTTON_ACTION); editBtn.setEnabled(canWrite); editButtons.addComponent(editBtn); } if ((buttonEnableFlags & DELETE_BTN_PRESENTED) == DELETE_BTN_PRESENTED) { Button deleteBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_DELETE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireDeleteForm(item); } }); deleteBtn.setIcon(FontAwesome.TRASH_O); deleteBtn.setStyleName(UIConstants.BUTTON_DANGER); deleteBtn.setEnabled(canAccess); editButtons.addComponent(deleteBtn); } if ((buttonEnableFlags & PRINT_BTN_PRESENTED) == PRINT_BTN_PRESENTED) { final PrintButton printBtn = new PrintButton(); printBtn.addClickListener(new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.firePrintForm(printBtn, item); } }); printBtn.setStyleName(UIConstants.BUTTON_OPTION); printBtn.setDescription(AppContext.getMessage(GenericI18Enum.ACTION_PRINT)); printBtn.setEnabled(canRead); editButtons.addComponent(printBtn); } if ((buttonEnableFlags & CLONE_BTN_PRESENTED) == CLONE_BTN_PRESENTED) { Button cloneBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CLONE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { optionBtn.setPopupVisible(false); T item = previewForm.getBean(); previewForm.fireCloneForm(item); } }); cloneBtn.setIcon(FontAwesome.ROAD); cloneBtn.setEnabled(canWrite); popupButtonsControl.addOption(cloneBtn); } layout.with(editButtons); if ((buttonEnableFlags & NAVIGATOR_BTN_PRESENTED) == NAVIGATOR_BTN_PRESENTED) { ButtonGroup navigationBtns = new ButtonGroup(); Button previousItem = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoPrevious(item); } }); previousItem.setIcon(FontAwesome.CHEVRON_LEFT); previousItem.setCaptionAsHtml(true); previousItem.setStyleName(UIConstants.BUTTON_OPTION); previousItem.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_PREVIOUS_ITEM)); previousItem.setEnabled(canRead); navigationBtns.addButton(previousItem); Button nextItemBtn = new Button(null, new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { T item = previewForm.getBean(); previewForm.fireGotoNextItem(item); } }); nextItemBtn.setIcon(FontAwesome.CHEVRON_RIGHT); nextItemBtn.setStyleName(UIConstants.BUTTON_OPTION); nextItemBtn.setDescription(AppContext.getMessage(GenericI18Enum.TOOLTIP_SHOW_NEXT_ITEM)); nextItemBtn.setEnabled(canRead); navigationBtns.addButton(nextItemBtn); layout.addComponent(navigationBtns); } if (popupButtonsControl.getComponentCount() > 0) { optionBtn.setContent(popupButtonsControl); layout.addComponent(optionBtn); } } return layout; }
From source file:com.esofthead.mycollab.vaadin.web.ui.table.CustomizedTableWindow.java
License:Open Source License
public CustomizedTableWindow(final String viewId, final AbstractPagedBeanTable<?, ?> table) { super(AppContext.getMessage(GenericI18Enum.OPT_CUSTOMIZE_VIEW)); this.viewId = viewId; this.setWidth("400px"); this.setResizable(false); this.setModal(true); this.center(); this.tableItem = table; customViewStoreService = AppContextUtil.getSpringBean(CustomViewStoreService.class); final MVerticalLayout contentLayout = new MVerticalLayout(); this.setContent(contentLayout); listBuilder = new ListBuilder(); listBuilder.setImmediate(true);//from ww w . j ava2 s . c o m listBuilder.setColumns(0); listBuilder.setLeftColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS)); listBuilder.setRightColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS)); listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE); listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT); final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class, this.getAvailableColumns()); listBuilder.setContainerDataSource(container); Iterator<TableViewField> iterator = getAvailableColumns().iterator(); while (iterator.hasNext()) { TableViewField field = iterator.next(); listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey())); } this.setSelectedViewColumns(); contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER); Button restoreLink = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { List<TableViewField> defaultSelectedColumns = tableItem.getDefaultSelectedColumns(); if (defaultSelectedColumns != null) { final List<TableViewField> selectedColumns = new ArrayList<>(); final BeanItemContainer<TableViewField> container = (BeanItemContainer<TableViewField>) listBuilder .getContainerDataSource(); final Collection<TableViewField> itemIds = container.getItemIds(); for (TableViewField column : defaultSelectedColumns) { for (final TableViewField viewField : itemIds) { if (column.getField().equals(viewField.getField())) { selectedColumns.add(viewField); } } } listBuilder.setValue(selectedColumns); } } }); restoreLink.setStyleName(UIConstants.BUTTON_LINK); contentLayout.with(restoreLink).withAlign(restoreLink, Alignment.TOP_RIGHT); final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @Override public void buttonClick(final ClickEvent event) { List<TableViewField> selectedColumns = (List<TableViewField>) listBuilder.getValue(); table.setDisplayColumns(selectedColumns); // Save custom table view def CustomViewStore viewDef = new CustomViewStore(); viewDef.setSaccountid(AppContext.getAccountId()); viewDef.setCreateduser(AppContext.getUsername()); viewDef.setViewid(viewId); viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(selectedColumns))); customViewStoreService.saveOrUpdateViewLayoutDef(viewDef); close(); } }); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); saveBtn.setIcon(FontAwesome.SAVE); final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { close(); } }); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, saveBtn); contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT); }
From source file:com.esofthead.mycollab.vaadin.web.ui.utils.FormControlsGenerator.java
License:Open Source License
public static final <T> ComponentContainer generateEditFormControls(final AdvancedEditBeanForm<T> editForm, boolean isSaveBtnVisible, boolean isSaveAndNewBtnVisible, boolean isCancelBtnVisible) { MHorizontalLayout layout = new MHorizontalLayout(); if (isCancelBtnVisible) { Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override/* www .j a v a 2s. c o m*/ public void buttonClick(final Button.ClickEvent event) { editForm.fireCancelForm(); } }); cancelBtn.setIcon(FontAwesome.MINUS); cancelBtn.setStyleName(UIConstants.BUTTON_OPTION); layout.addComponent(cancelBtn); } if (isSaveAndNewBtnVisible) { Button saveAndNewBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE_NEW), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { if (editForm.validateForm()) { editForm.fireSaveAndNewForm(); } } }); saveAndNewBtn.setIcon(FontAwesome.SHARE_ALT); saveAndNewBtn.setStyleName(UIConstants.BUTTON_ACTION); layout.addComponent(saveAndNewBtn); } if (isSaveBtnVisible) { final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { if (editForm.validateForm()) { editForm.fireSaveForm(); } } }); saveBtn.setIcon(FontAwesome.SAVE); saveBtn.setStyleName(UIConstants.BUTTON_ACTION); layout.addComponent(saveBtn); } return layout; }
From source file:com.esspl.datagen.DataGenApplication.java
License:Open Source License
private void buildMainLayout() { log.debug("DataGenApplication - buildMainLayout() start"); VerticalLayout rootLayout = new VerticalLayout(); final Window root = new Window("DATA Gen", rootLayout); root.setStyleName("tData"); setMainWindow(root);/* w ww. ja v a 2 s . c o m*/ rootLayout.setSizeFull(); rootLayout.setMargin(false, true, false, true); // Top area, containing logo and header HorizontalLayout top = new HorizontalLayout(); top.setWidth("100%"); root.addComponent(top); // Create the placeholders for all the components in the top area HorizontalLayout header = new HorizontalLayout(); // Add the components and align them properly top.addComponent(header); top.setComponentAlignment(header, Alignment.TOP_LEFT); top.setStyleName("top"); top.setHeight("75px"); // Same as the background image height // header controls Embedded logo = new Embedded(); logo.setSource(DataGenConstant.LOGO); logo.setWidth("100%"); logo.setStyleName("logo"); header.addComponent(logo); header.setSpacing(false); //Show which connection profile is connected connectedString = new Label("Connected to - Oracle"); connectedString.setStyleName("connectedString"); connectedString.setWidth("500px"); connectedString.setVisible(false); top.addComponent(connectedString); //Toolbar toolbar = new ToolBar(this); top.addComponent(toolbar); top.setComponentAlignment(toolbar, Alignment.TOP_RIGHT); listing = new Table(); listing.setHeight("240px"); listing.setWidth("100%"); listing.setStyleName("dataTable"); listing.setImmediate(true); // turn on column reordering and collapsing listing.setColumnReorderingAllowed(true); listing.setColumnCollapsingAllowed(true); listing.setSortDisabled(true); // Add the table headers listing.addContainerProperty("Sl No.", Integer.class, null); listing.addContainerProperty("Column Name", TextField.class, null); listing.addContainerProperty("Data Type", Select.class, null); listing.addContainerProperty("Format", Select.class, null); listing.addContainerProperty("Examples", Label.class, null); listing.addContainerProperty("Additional Data", HorizontalLayout.class, null); listing.setColumnAlignments(new String[] { Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER, Table.ALIGN_CENTER }); //From the starting create 5 rows addRow(5); //Add different style for IE browser WebApplicationContext context = ((WebApplicationContext) getMainWindow().getApplication().getContext()); WebBrowser browser = context.getBrowser(); //Create a TabSheet tabSheet = new TabSheet(); tabSheet.setSizeFull(); if (!browser.isIE()) { tabSheet.setStyleName("tabSheet"); } //Generator Tab content start generator = new VerticalLayout(); generator.setMargin(true, true, false, true); generateTypeHl = new HorizontalLayout(); generateTypeHl.setMargin(false, false, false, true); generateTypeHl.setSpacing(true); List<String> generateTypeList = Arrays.asList(new String[] { "Sql", "Excel", "XML", "CSV" }); generateType = new OptionGroup("Generation Type", generateTypeList); generateType.setNullSelectionAllowed(false); // user can not 'unselect' generateType.select("Sql"); // select this by default generateType.setImmediate(true); // send the change to the server at once generateType.addListener(this); // react when the user selects something generateTypeHl.addComponent(generateType); //SQL Options sqlPanel = new Panel("SQL Options"); sqlPanel.setHeight("180px"); if (browser.isIE()) { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { sqlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl1 = new VerticalLayout(); vl1.setMargin(false); Label lb1 = new Label("DataBase"); database = new Select(); database.addItem("Oracle"); database.addItem("Sql Server"); database.addItem("My Sql"); database.addItem("Postgress Sql"); database.addItem("H2"); database.select("Oracle"); database.setWidth("160px"); database.setNullSelectionAllowed(false); HorizontalLayout dbBar = new HorizontalLayout(); dbBar.setMargin(false, false, false, false); dbBar.setSpacing(true); dbBar.addComponent(lb1); dbBar.addComponent(database); vl1.addComponent(dbBar); Label tblLabel = new Label("Table Name"); tblName = new TextField(); tblName.setWidth("145px"); tblName.setStyleName("mandatory"); HorizontalLayout tableBar = new HorizontalLayout(); tableBar.setMargin(true, false, false, false); tableBar.setSpacing(true); tableBar.addComponent(tblLabel); tableBar.addComponent(tblName); vl1.addComponent(tableBar); createQuery = new CheckBox("Include CREATE TABLE query"); createQuery.setValue(true); HorizontalLayout createBar = new HorizontalLayout(); createBar.setMargin(true, false, false, false); createBar.addComponent(createQuery); vl1.addComponent(createBar); sqlPanel.addComponent(vl1); generateTypeHl.addComponent(sqlPanel); generator.addComponent(generateTypeHl); //CSV Option csvPanel = new Panel("CSV Options"); csvPanel.setHeight("130px"); if (browser.isIE()) { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { csvPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } Label delimiter = new Label("Delimiter Character(s)"); VerticalLayout vl2 = new VerticalLayout(); vl2.setMargin(false); csvDelimiter = new TextField(); HorizontalLayout csvBar = new HorizontalLayout(); csvBar.setMargin(true, false, false, false); csvBar.setSpacing(true); csvBar.addComponent(delimiter); csvBar.addComponent(csvDelimiter); vl2.addComponent(csvBar); csvPanel.addComponent(vl2); //XML Options xmlPanel = new Panel("XML Options"); xmlPanel.setHeight("160px"); if (browser.isIE()) { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanelIE"); } else { xmlPanel.setStyleName(Runo.PANEL_LIGHT + " sqlPanel"); } VerticalLayout vl3 = new VerticalLayout(); vl3.setMargin(false); Label lb4 = new Label("Root node name"); rootNode = new TextField(); rootNode.setWidth("125px"); rootNode.setStyleName("mandatory"); HorizontalLayout nodeBar = new HorizontalLayout(); nodeBar.setMargin(true, false, false, false); nodeBar.setSpacing(true); nodeBar.addComponent(lb4); nodeBar.addComponent(rootNode); vl3.addComponent(nodeBar); Label lb5 = new Label("Record node name"); recordNode = new TextField(); recordNode.setWidth("112px"); recordNode.setStyleName("mandatory"); HorizontalLayout recordBar = new HorizontalLayout(); recordBar.setMargin(true, false, false, false); recordBar.setSpacing(true); recordBar.addComponent(lb5); recordBar.addComponent(recordNode); vl3.addComponent(recordBar); xmlPanel.addComponent(vl3); HorizontalLayout noOfRowHl = new HorizontalLayout(); noOfRowHl.setSpacing(true); noOfRowHl.setMargin(true, false, false, true); noOfRowHl.addComponent(new Label("Number of Results")); resultNum = new TextField(); resultNum.setImmediate(true); resultNum.setNullSettingAllowed(false); resultNum.setStyleName("mandatory"); resultNum.addValidator(new IntegerValidator("Number of Results must be an Integer")); resultNum.setWidth("5em"); resultNum.setMaxLength(5); resultNum.setValue(50); noOfRowHl.addComponent(resultNum); generator.addComponent(noOfRowHl); HorizontalLayout addRowHl = new HorizontalLayout(); addRowHl.setMargin(true, false, true, true); addRowHl.setSpacing(true); addRowHl.addComponent(new Label("Add")); rowNum = new TextField(); rowNum.setImmediate(true); rowNum.setNullSettingAllowed(true); rowNum.addValidator(new IntegerValidator("Row number must be an Integer")); rowNum.setWidth("4em"); rowNum.setMaxLength(2); rowNum.setValue(1); addRowHl.addComponent(rowNum); rowsBttn = new Button("Row(s)"); rowsBttn.setIcon(DataGenConstant.ADD); rowsBttn.addListener(ClickEvent.class, this, "addRowButtonClick"); // react to clicks addRowHl.addComponent(rowsBttn); generator.addComponent(addRowHl); //Add the Grid generator.addComponent(listing); //Generate Button Button bttn = new Button("Generate"); bttn.setDescription("Generate Gata"); bttn.addListener(ClickEvent.class, this, "generateButtonClick"); // react to clicks bttn.setIcon(DataGenConstant.VIEW); bttn.setStyleName("generate"); generator.addComponent(bttn); //Generator Tab content end //Executer Tab content start - new class created to separate execution logic executor = new ExecutorView(this); //Executer Tab content end //Explorer Tab content start - new class created to separate execution logic explorer = new ExplorerView(this, databaseSessionManager); //explorer.setMargin(true); //Explorer Tab content end //About Tab content start VerticalLayout about = new VerticalLayout(); about.setMargin(true); Label aboutRichText = new Label(DataGenConstant.ABOUT_CONTENT); aboutRichText.setContentMode(Label.CONTENT_XHTML); about.addComponent(aboutRichText); //About Tab content end //Help Tab content start VerticalLayout help = new VerticalLayout(); help.setMargin(true); Label helpText = new Label(DataGenConstant.HELP_CONTENT); helpText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpText); Embedded helpScreen = new Embedded(); helpScreen.setSource(DataGenConstant.HELP_SCREEN); help.addComponent(helpScreen); Label helpStepsText = new Label(DataGenConstant.HELP_CONTENT_STEPS); helpStepsText.setContentMode(Label.CONTENT_XHTML); help.addComponent(helpStepsText); //Help Tab content end //Add the respective contents to the tab sheet tabSheet.addTab(generator, "Generator", DataGenConstant.HOME_ICON); executorTab = tabSheet.addTab(executor, "Executor", DataGenConstant.EXECUTOR_ICON); explorerTab = tabSheet.addTab(explorer, "Explorer", DataGenConstant.EXPLORER_ICON); tabSheet.addTab(about, "About", DataGenConstant.ABOUT_ICON); tabSheet.addTab(help, "Help", DataGenConstant.HELP_ICON); HorizontalLayout content = new HorizontalLayout(); content.setSizeFull(); content.addComponent(tabSheet); rootLayout.addComponent(content); rootLayout.setExpandRatio(content, 1); log.debug("DataGenApplication - buildMainLayout() end"); }
From source file:com.expressui.core.view.util.CodePopup.java
License:Open Source License
/** * Creates a popup code button.// w ww. ja v a 2 s .co m * * @param classes classes for displaying related source code and Javadoc. If * class is within com.expressui.core or com.expressui.domain, * then Javadoc is displayed, otherwise source code. * @return popup code button */ public Button createPopupCodeButton(final Class... classes) { Button codeButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { open(classes); } }); codeButton.setIcon(new ThemeResource("../expressui/icons/32/java.png")); codeButton.setStyleName(BaseTheme.BUTTON_LINK); codeButton.setDescription(uiMessageSource.getToolTip("codePopup.toolTip")); return codeButton; }