List of usage examples for com.vaadin.ui HorizontalLayout HorizontalLayout
public HorizontalLayout()
From source file:com.esofthead.mycollab.vaadin.ui.table.AbstractPagedBeanTable.java
License:Open Source License
private CssLayout createControls() { this.controlBarWrapper = new CssLayout(); this.controlBarWrapper.setStyleName("listControl"); this.controlBarWrapper.setWidth("100%"); final HorizontalLayout controlBar = new HorizontalLayout(); controlBar.setWidth("100%"); this.controlBarWrapper.addComponent(controlBar); this.pageManagement = new HorizontalLayout(); // defined layout here --------------------------- if (this.currentPage > 1) { final Button firstLink = new ButtonLink("1", new ClickListener() { private static final long serialVersionUID = 1L; @Override/*from w w w .j a va 2s . c o m*/ public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(1); } }, false); firstLink.addStyleName("buttonPaging"); this.pageManagement.addComponent(firstLink); } if (this.currentPage >= 5) { final Label ss1 = new Label("..."); ss1.addStyleName("buttonPaging"); this.pageManagement.addComponent(ss1); } if (this.currentPage > 3) { final Button previous2 = new ButtonLink("" + (this.currentPage - 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.currentPage - 2); } }, false); previous2.addStyleName("buttonPaging"); this.pageManagement.addComponent(previous2); } if (this.currentPage > 2) { final Button previous1 = new ButtonLink("" + (this.currentPage - 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.currentPage - 1); } }, false); previous1.addStyleName("buttonPaging"); this.pageManagement.addComponent(previous1); } // Here add current ButtonLink final Button current = new ButtonLink("" + this.currentPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.currentPage); } }, false); current.addStyleName("buttonPaging"); current.addStyleName("buttonPagingcurrent"); this.pageManagement.addComponent(current); final int range = this.totalPage - this.currentPage; if (range >= 1) { final Button next1 = new ButtonLink("" + (this.currentPage + 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.currentPage + 1); } }, false); next1.addStyleName("buttonPaging"); this.pageManagement.addComponent(next1); } if (range >= 2) { final Button next2 = new ButtonLink("" + (this.currentPage + 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.currentPage + 2); } }, false); next2.addStyleName("buttonPaging"); this.pageManagement.addComponent(next2); } if (range >= 4) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); this.pageManagement.addComponent(ss2); } if (range >= 3) { final Button last = new ButtonLink("" + this.totalPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractPagedBeanTable.this.pageChange(AbstractPagedBeanTable.this.totalPage); } }, false); last.addStyleName("buttonPaging"); this.pageManagement.addComponent(last); } this.pageManagement.setWidth(null); this.pageManagement.setSpacing(true); controlBar.addComponent(this.pageManagement); controlBar.setComponentAlignment(this.pageManagement, Alignment.MIDDLE_RIGHT); return this.controlBarWrapper; }
From source file:com.esofthead.mycollab.vaadin.ui.table.CustomizedTableWindow.java
License:Open Source License
public CustomizedTableWindow(final String viewId, final AbstractPagedBeanTable<?, ?> table) { super("Customize View"); this.viewId = viewId; this.addStyleName("customize-table-window"); this.setWidth("400px"); this.setResizable(false); this.setModal(true); this.center(); this.tableItem = table; customViewStoreService = ApplicationContextUtil.getSpringBean(CustomViewStoreService.class); final VerticalLayout contentLayout = new VerticalLayout(); contentLayout.setSpacing(true);/*from w ww .ja v a 2s . c o m*/ contentLayout.setMargin(true); this.setContent(contentLayout); this.listBuilder = new ListBuilder(); this.listBuilder.setImmediate(true); this.listBuilder.setColumns(0); this.listBuilder.setLeftColumnCaption("Available Columns"); this.listBuilder.setRightColumnCaption("View Columns"); this.listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE); this.listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT); final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class, this.getAvailableColumns()); this.listBuilder.setContainerDataSource(container); Iterator<TableViewField> iterator = getAvailableColumns().iterator(); while (iterator.hasNext()) { TableViewField field = iterator.next(); this.listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey())); } this.setSelectedViewColumns(); contentLayout.addComponent(this.listBuilder); contentLayout.setComponentAlignment(listBuilder, Alignment.MIDDLE_CENTER); Button restoreLink = new Button("Restore to default", new Button.ClickListener() { private static final long serialVersionUID = 1L; @SuppressWarnings("unchecked") @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>) CustomizedTableWindow.this.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); } } } CustomizedTableWindow.this.listBuilder.setValue(selectedColumns); } } }); restoreLink.setStyleName("link"); contentLayout.addComponent(restoreLink); contentLayout.setComponentAlignment(restoreLink, Alignment.MIDDLE_RIGHT); final HorizontalLayout buttonControls = new HorizontalLayout(); buttonControls.setSpacing(true); 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) { final List<TableViewField> selectedColumns = (List<TableViewField>) CustomizedTableWindow.this.listBuilder .getValue(); table.setDisplayColumns(selectedColumns); CustomizedTableWindow.this.close(); // Save custom table view def CustomViewStore viewDef = new CustomViewStore(); viewDef.setSaccountid(AppContext.getAccountId()); viewDef.setCreateduser(AppContext.getUsername()); viewDef.setViewid(viewId); viewDef.setViewinfo(XStreamJsonDeSerializer.toJson(new ArrayList<>(selectedColumns))); customViewStoreService.saveOrUpdateViewLayoutDef(viewDef); } }); saveBtn.setStyleName(UIConstants.THEME_GREEN_LINK); saveBtn.setIcon(FontAwesome.SAVE); buttonControls.addComponent(saveBtn); 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) { CustomizedTableWindow.this.close(); } }); cancelBtn.setStyleName(UIConstants.THEME_GRAY_LINK); buttonControls.addComponent(cancelBtn); contentLayout.addComponent(buttonControls); contentLayout.setComponentAlignment(buttonControls, Alignment.MIDDLE_CENTER); }
From source file:com.esofthead.mycollab.vaadin.web.ui.AbstractBeanBlockList.java
License:Open Source License
protected CssLayout createPageControls() { this.controlBarWrapper = new CssLayout(); this.controlBarWrapper.setWidth("100%"); final HorizontalLayout controlBar = new HorizontalLayout(); controlBar.setWidth("100%"); this.controlBarWrapper.addComponent(controlBar); pageManagement = new MHorizontalLayout(); // defined layout here --------------------------- if (currentPage > 1) { final Button firstLink = new Button("1", new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override//from w ww.j a va 2 s.co m public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(1); } }); firstLink.addStyleName("buttonPaging"); pageManagement.addComponent(firstLink); } if (currentPage >= 5) { final Label ss1 = new Label("..."); ss1.addStyleName("buttonPaging"); pageManagement.addComponent(ss1); } if (currentPage > 3) { final Button previous2 = new Button("" + (currentPage - 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(currentPage - 2); } }); previous2.addStyleName("buttonPaging"); pageManagement.addComponent(previous2); } if (currentPage > 2) { final Button previous1 = new Button("" + (currentPage - 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(currentPage - 1); } }); previous1.addStyleName("buttonPaging"); pageManagement.addComponent(previous1); } // Here add current ButtonLinkLegacy final Button current = new Button("" + currentPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(currentPage); } }); current.addStyleName("buttonPaging"); current.addStyleName("current"); pageManagement.addComponent(current); final int range = totalPage - currentPage; if (range >= 1) { final Button next1 = new Button("" + (currentPage + 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(currentPage + 1); } }); next1.addStyleName("buttonPaging"); pageManagement.addComponent(next1); } if (range >= 2) { final Button next2 = new Button("" + (currentPage + 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { AbstractBeanBlockList.this.pageChange(currentPage + 2); } }); next2.addStyleName("buttonPaging"); pageManagement.addComponent(next2); } if (range >= 4) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); pageManagement.addComponent(ss2); } if (range >= 3) { final Button last = new Button("" + totalPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(totalPage); } }); last.addStyleName("buttonPaging"); pageManagement.addComponent(last); } pageManagement.setWidth(null); controlBar.addComponent(pageManagement); controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT); return this.controlBarWrapper; }
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);//from www .j a v a 2s. c om 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.SplitButton.java
License:Open Source License
public SplitButton(Button parentButton) { this.setImmediate(true); HorizontalLayout contentLayout = new HorizontalLayout(); contentLayout.setStyleName("splitbutton"); this.parentButton = parentButton; parentButton.addStyleName("parent-button"); parentButton.setImmediate(true);//from w ww . j a va 2 s. com parentButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { fireEvent(new SplitButtonClickEvent(SplitButton.this)); } }); popupButton = new PopupButton(); popupButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { isPopupVisible = !isPopupVisible; fireEvent(new SplitButtonPopupVisibilityEvent(SplitButton.this, isPopupVisible)); } }); contentLayout.addComponent(parentButton); contentLayout.addComponent(popupButton); this.setCompositionRoot(contentLayout); }
From source file:com.esofthead.mycollab.vaadin.web.ui.StyleCalendarExp.java
License:Open Source License
public StyleCalendarExp() { this.setWidth("230px"); this.setHeightUndefined(); this.setSpacing(false); this.setStyleName("stylecalendar-ext"); this.setMargin(new MarginInfo(true, false, false, false)); styleCalendar.setRenderHeader(false); styleCalendar.setRenderWeekNumbers(false); styleCalendar.setImmediate(true);/*from w w w . ja v a2 s . c om*/ styleCalendar.setWidth("100%"); setDateOptionsGenerator(); btnShowNextYear = new Button(); btnShowNextYear.setIcon(new AssetResource("icons/16/cal_year_next.png")); btnShowNextYear.setStyleName(UIConstants.BUTTON_LINK); btnShowNextMonth = new Button(); btnShowNextMonth.setIcon(new AssetResource("icons/16/cal_month_next.png")); btnShowNextMonth.setStyleName(UIConstants.BUTTON_LINK); btnShowPreviousMonth = new Button(); btnShowPreviousMonth.setIcon(new AssetResource("icons/16/cal_month_pre.png")); btnShowPreviousMonth.setStyleName(UIConstants.BUTTON_LINK); btnShowPreviousYear = new Button(); btnShowPreviousYear.setIcon(new AssetResource("icons/16/cal_year_pre.png")); btnShowPreviousYear.setStyleName(UIConstants.BUTTON_LINK); lbSelectedDate.setValue(AppContext.formatDate(new Date())); lbSelectedDate.addStyleName("calendarDateLabel"); lbSelectedDate.setWidth("80"); HorizontalLayout layoutControl = new HorizontalLayout(); layoutControl.setStyleName("calendarHeader"); layoutControl.setWidth("100%"); layoutControl.setHeight("35px"); HorizontalLayout layoutButtonPrevious = new HorizontalLayout(); layoutButtonPrevious.setSpacing(true); layoutButtonPrevious.addComponent(btnShowPreviousYear); layoutButtonPrevious.setComponentAlignment(btnShowPreviousYear, Alignment.MIDDLE_LEFT); layoutButtonPrevious.addComponent(btnShowPreviousMonth); layoutButtonPrevious.setComponentAlignment(btnShowPreviousMonth, Alignment.MIDDLE_LEFT); layoutControl.addComponent(layoutButtonPrevious); layoutControl.setComponentAlignment(layoutButtonPrevious, Alignment.MIDDLE_LEFT); layoutControl.addComponent(lbSelectedDate); layoutControl.setComponentAlignment(lbSelectedDate, Alignment.MIDDLE_CENTER); MHorizontalLayout layoutButtonNext = new MHorizontalLayout(); layoutButtonNext.addComponent(btnShowNextMonth); layoutButtonNext.setComponentAlignment(btnShowNextMonth, Alignment.MIDDLE_RIGHT); layoutButtonNext.addComponent(btnShowNextYear); layoutButtonNext.setComponentAlignment(btnShowNextYear, Alignment.MIDDLE_RIGHT); layoutControl.addComponent(layoutButtonNext); layoutControl.setComponentAlignment(layoutButtonNext, Alignment.MIDDLE_RIGHT); this.addComponent(layoutControl); this.setComponentAlignment(layoutControl, Alignment.TOP_CENTER); this.addComponent(styleCalendar); this.setExpandRatio(styleCalendar, 1.0f); }
From source file:com.esofthead.mycollab.vaadin.web.ui.table.AbstractPagedBeanTable.java
License:Open Source License
private ComponentContainer createPagingControls() { controlBarWrapper = new HorizontalLayout(); controlBarWrapper.setWidth("100%"); controlBarWrapper.setStyleName("listControl"); pageManagement = new MHorizontalLayout(); // defined layout here --------------------------- if (currentPage > 1) { Button firstLink = new Button("1", new ClickListener() { private static final long serialVersionUID = 1L; @Override//from w w w . jav a2 s . c o m public void buttonClick(final ClickEvent event) { pageChange(1); } }); firstLink.addStyleName("buttonPaging"); pageManagement.addComponent(firstLink); } if (currentPage >= 5) { Label ss1 = new Label("..."); ss1.addStyleName("buttonPaging"); pageManagement.addComponent(ss1); } if (currentPage > 3) { Button previous2 = new Button("" + (currentPage - 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(currentPage - 2); } }); previous2.addStyleName("buttonPaging"); pageManagement.addComponent(previous2); } if (currentPage > 2) { Button previous1 = new Button("" + (currentPage - 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { pageChange(currentPage - 1); } }); previous1.addStyleName("buttonPaging"); pageManagement.addComponent(previous1); } // Here add current ButtonLinkLegacy Button current = new Button("" + currentPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(currentPage); } }); current.addStyleName("buttonPaging"); current.addStyleName("current"); pageManagement.addComponent(current); final int range = totalPage - currentPage; if (range >= 1) { Button next1 = new Button("" + (currentPage + 1), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(currentPage + 1); } }); next1.addStyleName("buttonPaging"); pageManagement.addComponent(next1); } if (range >= 2) { Button next2 = new Button("" + (currentPage + 2), new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(currentPage + 2); } }); next2.addStyleName("buttonPaging"); pageManagement.addComponent(next2); } if (range >= 4) { final Label ss2 = new Label("..."); ss2.addStyleName("buttonPaging"); pageManagement.addComponent(ss2); } if (range >= 3) { Button last = new Button("" + totalPage, new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final ClickEvent event) { pageChange(totalPage); } }); last.addStyleName("buttonPaging"); pageManagement.addComponent(last); } pageManagement.setWidth(null); controlBarWrapper.addComponent(pageManagement); controlBarWrapper.setComponentAlignment(pageManagement, Alignment.MIDDLE_RIGHT); return controlBarWrapper; }
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);/*from ww w . j a va 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.esspl.datagen.DataGenApplication.java
License:Open Source License
public void addRow(int noOfRow) { log.debug("DataGenApplication - addRow() start"); int maxSize = tableLength + noOfRow; for (int i = tableLength; i <= maxSize; i++) { log.info("DataGenApplication - addRow(): Adding row- " + i); Select dataType = new Select(); dataType.addItem("Name"); dataType.addItem("Title"); dataType.addItem("Phone/Fax"); dataType.addItem("Email"); dataType.addItem("Date"); dataType.addItem("Street Address"); dataType.addItem("City"); dataType.addItem("Postal/Zip"); dataType.addItem("State/Provience/County"); dataType.addItem("Country"); dataType.addItem("Random Text"); dataType.addItem("Fixed Text"); dataType.addItem("Incremental Number"); dataType.addItem("Number Range"); dataType.addItem("Alphanumeric"); dataType.addItem("Marital Status"); dataType.addItem("Department Name"); dataType.addItem("Company Name"); dataType.addItem("Boolean Flag"); dataType.addItem("Passport Number"); dataType.setWidth("100%"); dataType.setImmediate(true);//w w w. j av a 2 s .c o m dataType.setData(i); dataType.setCaption("DataType"); dataType.addListener(this); Select format = new Select(); format.setData(i); format.setCaption("Format"); format.setImmediate(true); format.setWidth("100%"); format.setEnabled(false); format.addListener(this); Label example = new Label("NA"); example.setWidth("100%"); TextField field = new TextField(""); HorizontalLayout addBar = new HorizontalLayout(); addBar.setWidth("100%"); addBar.addComponent(new Label("NA")); listing.addItem(new Object[] { i, field, dataType, format, example, addBar }, i); tableLength = i; } log.debug("DataGenApplication - addRow() end"); }
From source file:com.esspl.datagen.ui.ExecutorView.java
License:Open Source License
public ExecutorView(DataGenApplication application) { log.debug("ExecutorView - constructor start"); dataGenApplication = application;/*from w w w.j a v a2 s . c o m*/ setSizeFull(); VerticalLayout vl = new VerticalLayout(); vl.setSizeFull(); setCompositionRoot(vl); splitPanel = new VerticalSplitPanel(); splitPanel.setSizeFull(); //Script TextArea sqlScript = new TextArea(); sqlScript.setSizeFull(); sqlScript.setWordwrap(false); sqlScript.setStyleName("noResizeTextArea"); HorizontalLayout queryOptions = new HorizontalLayout(); queryOptions.setMargin(false, false, false, true); queryOptions.setSpacing(true); queryOptions.setWidth("100%"); queryOptions.setHeight("40px"); Button executeButton = new Button("Execute", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Execute Button clicked"); executeScript(sqlScript.getValue().toString()); } }); executeButton.addStyleName("small"); executeButton.setIcon(DataGenConstant.EXECUTOR_ICON); executeButton.setDescription("Press Ctrl+Enter to execute the query"); Button clearQueryButton = new Button("Clear SQL", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear SQL Button clicked"); sqlScript.setValue(""); } }); clearQueryButton.addStyleName("small"); clearQueryButton.setIcon(DataGenConstant.CLEAR_SMALL); clearQueryButton.setDescription("Clears the Sql"); Button clearConsoleButton = new Button("Clear Console", new ClickListener() { @Override public void buttonClick(ClickEvent event) { log.info("ExecutorView - Clear Console Button clicked"); logText.setValue(""); } }); clearConsoleButton.addStyleName("small"); clearConsoleButton.setIcon(DataGenConstant.CLEAR_SMALL); clearConsoleButton.setDescription("Clears the Console"); maxRowsBox = new ComboBox(null, Arrays.asList(10, 100, 500, 1000, 5000, 10000)); maxRowsBox.setDescription("Max number of rows to retrieve"); maxRowsBox.setWidth(100, UNITS_PIXELS); maxRowsBox.setNewItemsAllowed(false); maxRowsBox.setNullSelectionAllowed(false); maxRowsBox.setValue(100); //Bottom section components resultSheet = new TabSheet(); resultSheet.setSizeFull(); resultSheet.addStyleName(Runo.TABSHEET_SMALL); logText = new Label(); logText.setContentMode(Label.CONTENT_XHTML); logText.setSizeFull(); //Panel to add refresher logPanel = new Panel(); logPanel.setSizeFull(); logPanel.setScrollable(true); logPanel.setStyleName(Runo.PANEL_LIGHT); logPanel.addComponent(logText); //Refresher added to show instant log messages refresher = new Refresher(); logPanel.addComponent(refresher); //Loading image loadingImg = new Embedded("", DataGenConstant.LOADING_ICON); loadingImg.setVisible(false); logPanel.addComponent(loadingImg); resultSheet.addTab(logPanel, "Console"); resultTab = resultSheet.addTab(new Label(), "Results"); queryOptions.addComponent(executeButton); queryOptions.setComponentAlignment(executeButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearQueryButton); queryOptions.setComponentAlignment(clearQueryButton, Alignment.MIDDLE_LEFT); queryOptions.addComponent(clearConsoleButton); queryOptions.setComponentAlignment(clearConsoleButton, Alignment.MIDDLE_LEFT); queryOptions.setExpandRatio(clearConsoleButton, 1); queryOptions.addComponent(maxRowsBox); queryOptions.setComponentAlignment(maxRowsBox, Alignment.MIDDLE_RIGHT); splitPanel.setFirstComponent(sqlScript); splitPanel.setSecondComponent(resultSheet); vl.addComponent(queryOptions); vl.addComponent(splitPanel); vl.setExpandRatio(splitPanel, 1); sqlScript.addShortcutListener(new ShortcutListener("Execute Script", null, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.CTRL) { @Override public void handleAction(Object sender, Object target) { executeScript(sqlScript.getValue().toString()); } }); log.debug("ExecutorView - constructor end"); }