Example usage for com.vaadin.ui Button setIcon

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

Introduction

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

Prototype

@Override
public void setIcon(Resource icon) 

Source Link

Document

Sets the component's icon.

Usage

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  w  w w  .j av a  2  s  .  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.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 w w .j a v a2s. c  om*/
                    });
            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.ServiceMenu.java

License:Open Source License

public Button addService(String serviceName, Resource linkIcon, ClickListener listener) {
    Button serviceBtn = new Button(serviceName, listener);
    serviceBtn.setIcon(linkIcon);
    this.addButton(serviceBtn);
    return serviceBtn;
}

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  w ww.  j av a2s.com*/
    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/*  w  ww .jav  a 2 s. com*/
                    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);/*from w w w.j  a  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.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 v a2s.  co  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 www.  j a  v a2 s .co  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.esspl.datagen.ui.ExecutorView.java

License:Open Source License

public ExecutorView(DataGenApplication application) {
    log.debug("ExecutorView - constructor start");
    dataGenApplication = application;//ww  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");
}

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

License:Open Source License

public ResultView(final DataGenApplication dataGenApplication, ArrayList<GeneratorBean> rowList) {
    log.debug("ResultView constructor start");
    VerticalLayout layout = (VerticalLayout) this.getContent();
    layout.setMargin(false);//from  w ww .  j ava2s  .c  o  m
    layout.setSpacing(false);
    layout.setHeight("500px");
    layout.setWidth("600px");

    Button close = new Button("Close", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Close Button clicked");
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    close.setIcon(DataGenConstant.CLOSE_ICON);

    String dataOption = dataGenApplication.generateType.getValue().toString();
    Generator genrator = null;
    if (dataOption.equalsIgnoreCase("xml")) {
        genrator = new XmlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("sql")) {
        genrator = new SqlDataGenerator();
    } else if (dataOption.equalsIgnoreCase("csv")) {
        genrator = new CsvDataGenerator();
    }

    if (genrator == null) {
        log.info("ResultView - genrator object is null");
        dataGenApplication.getMainWindow().removeWindow(this);
        return;
    }

    //Data generated from respective command class and shown in the modal window
    final TextArea message = new TextArea();
    message.setSizeFull();
    message.setHeight("450px");
    message.setWordwrap(false);
    message.setStyleName("noResizeTextArea");
    message.setValue(genrator.generate(dataGenApplication, rowList));
    layout.addComponent(message);

    Button copy = new Button("Copy", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Copy Button clicked");
            //As on Unix environment, it gives headless exception we need to handle it
            try {
                //StringSelection stringSelection = new StringSelection(message.getValue().toString());
                Transferable tText = new StringSelection(message.getValue().toString());
                Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
                clipboard.setContents(tText, null);
            } catch (HeadlessException e) {
                dataGenApplication.getMainWindow()
                        .showNotification("Due to some problem Text could not be copied.");
                e.printStackTrace();
            }
        }
    });
    copy.setIcon(DataGenConstant.COPY_ICON);

    Button execute = new Button("Execute", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Execute Button clicked");
            dataGenApplication.tabSheet.setSelectedTab(dataGenApplication.executor);
            dataGenApplication.executor.setScript(message.getValue().toString());
            dataGenApplication.getMainWindow().removeWindow(event.getButton().getWindow());
        }
    });
    execute.setIcon(DataGenConstant.EXECUTOR_ICON);

    Button export = new Button("Export to File", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            log.info("ResultView - Export to File Button clicked");
            String dataOption = dataGenApplication.generateType.getValue().toString();
            DataGenStreamUtil resource = null;
            try {
                if (dataOption.equalsIgnoreCase("xml")) {
                    File tempFile = File.createTempFile("tmp", ".xml");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.xml", "text/xml", tempFile);
                } else if (dataOption.equalsIgnoreCase("csv")) {
                    File tempFile = File.createTempFile("tmp", ".csv");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.csv", "text/csv", tempFile);
                } else if (dataOption.equalsIgnoreCase("sql")) {
                    File tempFile = File.createTempFile("tmp", ".sql");
                    BufferedWriter out = new BufferedWriter(new FileWriter(tempFile));
                    out.write(message.getValue().toString());
                    out.close();
                    resource = new DataGenStreamUtil(dataGenApplication, "data.sql", "text/plain", tempFile);
                }
                getWindow().open(resource, "_self");
            } catch (FileNotFoundException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (IOException e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            } catch (Exception e) {
                log.info("ResultView - Export to File Error - " + e.getMessage());
                e.printStackTrace();
            }
        }
    });
    export.setIcon(DataGenConstant.EXPORT_ICON);

    HorizontalLayout bttnBar = new HorizontalLayout();
    if (dataOption.equalsIgnoreCase("sql")) {
        bttnBar.addComponent(execute);
    }
    bttnBar.addComponent(export);
    bttnBar.addComponent(copy);
    bttnBar.addComponent(close);
    layout.addComponent(bttnBar);
    layout.setComponentAlignment(bttnBar, Alignment.MIDDLE_CENTER);
    log.debug("ResultView constructor end");
}