Example usage for com.vaadin.ui Alignment MIDDLE_CENTER

List of usage examples for com.vaadin.ui Alignment MIDDLE_CENTER

Introduction

In this page you can find the example usage for com.vaadin.ui Alignment MIDDLE_CENTER.

Prototype

Alignment MIDDLE_CENTER

To view the source code for com.vaadin.ui Alignment MIDDLE_CENTER.

Click Source Link

Usage

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

License:Open Source License

public void addTab(Component component, String id, int level, String caption, String link, Resource resource) {
    if (!hasTab(id)) {
        final ButtonTabImpl button = new ButtonTabImpl(id, level, caption, link);

        button.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;

            @Override/*  w ww .j  a  va 2s  . c  o  m*/
            public void buttonClick(ClickEvent event) {
                if (!event.isCtrlKey() && !event.isMetaKey()) {
                    if (selectedButton != button) {
                        clearTabSelection(true);
                        selectedButton = button;
                        selectedButton.addStyleName(TAB_SELECTED_STYLENAME);
                        selectedComp = compMap.get(button.getTabId());
                    }
                    fireTabChangeEvent(new SelectedTabChangeEvent(VerticalTabsheet.this));
                } else {
                    Page.getCurrent().open(button.link, "_blank", false);
                }

            }
        });

        if (resource == null) {
            setDefaultButtonIcon(button, false);
        } else {
            button.setIcon(resource);
        }
        button.setStyleName(TAB_STYLENAME);
        button.addStyleName(UIConstants.TEXT_ELLIPSIS);
        button.setWidth("90%");

        if (button.getLevel() > 0) {
            int insertIndex = 0;
            for (int i = 0; i < navigatorContainer.getComponentCount(); i++) {
                ButtonTabImpl buttonTmp = (ButtonTabImpl) navigatorContainer.getComponent(i);
                if (buttonTmp.getLevel() > level) {
                    break;
                } else {
                    insertIndex++;
                }
            }
            navigatorContainer.addComponent(button, insertIndex);
            navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        } else {
            navigatorContainer.addComponent(button);
            navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        }

        TabImpl tabImpl = new TabImpl(id, caption, component);
        compMap.put(id, tabImpl);
    }
}

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

License:Open Source License

public Button addButtonOnNavigatorContainer(String id, String caption, Resource icon) {
    if (getButtonById(id) == null) {
        final ButtonTabImpl button = new ButtonTabImpl(id, 0, caption, "");
        navigatorContainer.addComponent(button);
        navigatorContainer.setComponentAlignment(button, Alignment.MIDDLE_CENTER);
        button.setStyleName(TAB_STYLENAME);
        button.addStyleName(UIConstants.TEXT_ELLIPSIS);
        button.setWidth("90%");
        button.setIcon(icon);//  w w w  .  j a  v a 2  s.co  m
        return button;
    }
    return null;
}

From source file:com.esofthead.mycollab.web.AdWindow.java

License:Open Source License

public AdWindow() {
    super("Buy MyCollab Pro edition");
    this.setWidth("700px");
    this.setModal(true);
    this.setResizable(false);
    RestTemplate restTemplate = new RestTemplate();
    MVerticalLayout content = new MVerticalLayout();
    try {/*w  ww  .jav  a  2 s.  com*/
        String result = restTemplate.getForObject("https://api.mycollab.com/api/storeweb", String.class);
        Label webPage = new Label(result, ContentMode.HTML);
        webPage.setHeight("600px");
        this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    } catch (Exception e) {
        Div informDiv = new Div()
                .appendText("Can not load the store page. You can check the online edition at ")
                .appendChild(new A("https://www.mycollab.com/pricing/download/", "_blank").appendText("here"));
        Label webPage = new Label(informDiv.write(), ContentMode.HTML);
        this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    }
    LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class);
    if (licenseResolver != null) {
        Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class);
                UI.getCurrent().addWindow(activateWindow);
                close();
            }
        });
        editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION);
        content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER);
    }
}

From source file:com.esofthead.mycollab.web.BuyPremiumSoftwareWindow.java

License:Open Source License

public BuyPremiumSoftwareWindow() {
    super("Buy MyCollab Pro edition");
    this.setWidth("700px");
    this.setModal(true);
    this.setResizable(false);
    RestTemplate restTemplate = new RestTemplate();
    MVerticalLayout content = new MVerticalLayout();
    try {// w ww  . ja  v a 2 s  .  com
        String result = restTemplate.getForObject("https://api.mycollab.com/api/linktobuy", String.class);
        Label webPage = new Label(result, ContentMode.HTML);
        webPage.setHeight("600px");
        this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    } catch (Exception e) {
        String result = FileUtils.readFileAsPlainString("buying.html");
        Label webPage = new Label(result, ContentMode.HTML);
        this.setContent(content.with(webPage).withAlign(webPage, Alignment.TOP_CENTER));
    }
    LicenseResolver licenseResolver = AppContextUtil.getSpringBean(LicenseResolver.class);
    if (licenseResolver != null) {
        Button editLicenseBtn = new Button("Enter license code", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent clickEvent) {
                Window activateWindow = ViewManager.getCacheComponent(AbstractLicenseActivationWindow.class);
                UI.getCurrent().addWindow(activateWindow);
                close();
            }
        });
        editLicenseBtn.addStyleName(UIConstants.BUTTON_ACTION);
        content.with(editLicenseBtn).withAlign(editLicenseBtn, Alignment.MIDDLE_CENTER);
    }
}

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  ww  w  .j  a  v a2 s .  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");
}

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

License:Open Source License

public TableDataView(final JdbcTable table, final Connection connection, final DataGenApplication dataApp) {
    log.debug("TableDataView - constructor start");
    setCaption("Data");
    dataGenApplication = dataApp;/*from w  w w. ja  va2  s .  c  o m*/
    VerticalLayout vl = new VerticalLayout();
    vl.setSizeFull();
    setCompositionRoot(vl);

    HorizontalLayout hBar = new HorizontalLayout();
    hBar.setWidth("98%");
    hBar.setHeight("40px");

    rows = new TextField();
    rows.setWidth("50px");
    rows.setImmediate(true);
    rows.addValidator(new IntegerValidator("Rows must be an Integer"));
    Label lbl = new Label("Generate ");

    content = new HorizontalLayout();
    content.setHeight("40px");
    content.setMargin(false, false, false, true);
    content.setSpacing(true);
    content.addComponent(lbl);
    content.setComponentAlignment(lbl, Alignment.MIDDLE_CENTER);
    content.addComponent(rows);
    content.setComponentAlignment(rows, Alignment.MIDDLE_CENTER);

    Button addDataButton = new Button("Row(S) Data", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Generate Data Button clicked");
            populateGenerator(table);
        }
    });
    addDataButton.addStyleName("small");
    addDataButton.setIcon(DataGenConstant.ADD_SMALL);
    content.addComponent(addDataButton);
    content.setComponentAlignment(addDataButton, Alignment.MIDDLE_CENTER);

    Button refreshButton = new Button("Refresh", new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            log.debug("TableDataView - Refresh Button clicked");
            refreshDataView(table, connection);
        }
    });
    refreshButton.addStyleName("small");
    refreshButton.setIcon(DataGenConstant.RESET);
    content.addComponent(refreshButton);
    content.setComponentAlignment(refreshButton, Alignment.MIDDLE_CENTER);

    //Tapas:10/08/2012 - Export feature implementation started
    HorizontalLayout expContainer = new HorizontalLayout();
    expContainer.setSpacing(true);

    PopupButton exportButton = new PopupButton("Export");
    exportButton.setComponent(new DataExportView());
    exportButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Export Button clicked!");
        }
    });
    exportButton.setIcon(DataGenConstant.DATAEXPORT_ICON);
    expContainer.addComponent(exportButton);
    expContainer.setComponentAlignment(exportButton, Alignment.MIDDLE_LEFT);

    //Tapas:10/08/2012 - Import feature implementation started
    PopupButton importButton = new PopupButton("Import");
    importButton.setComponent(new DataImportView());
    importButton.addListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            //dataApp.getMainWindow().showNotification("Import Button clicked!");
        }
    });
    importButton.setIcon(DataGenConstant.DATAIMPORT_ICON);
    expContainer.addComponent(importButton);
    expContainer.setComponentAlignment(importButton, Alignment.MIDDLE_RIGHT);

    tableContainer = new VerticalLayout();
    tableContainer.setSizeFull();
    hBar.addComponent(content);
    hBar.setComponentAlignment(content, Alignment.MIDDLE_LEFT);
    hBar.addComponent(expContainer);
    hBar.setComponentAlignment(expContainer, Alignment.MIDDLE_RIGHT);
    vl.addComponent(hBar);
    vl.addComponent(tableContainer);
    vl.setExpandRatio(tableContainer, 1f);

    refreshDataView(table, connection);
    log.debug("TableDataView - constructor end");
}

From source file:com.esspl.datagen.util.DataGenEventHandler.java

License:Open Source License

public void addSingleTextField(HorizontalLayout addBar, String promptText1) {
    log.debug("DataGenEventHandler - addSingleTextField() method start");
    TextField first = new TextField();
    first.setInputPrompt(promptText1);/*from w  w  w  .jav a 2s  .co  m*/
    first.setWidth("95px");
    first.setImmediate(true);
    if (promptText1.endsWith("Length") || promptText1.endsWith("Number")
            || promptText1.equals("Starting From")) {
        first.addValidator(new IntegerValidator(promptText1 + " must be an Integer"));
    }

    addBar.removeAllComponents();
    addBar.setSpacing(true);
    addBar.addComponent(first);
    addBar.setComponentAlignment(first, Alignment.MIDDLE_CENTER);
    log.debug("DataGenEventHandler - addSingleTextField() method end");
}

From source file:com.etest.view.notification.ViewCaseNotificationWindow.java

VerticalLayout buildForms() {
    VerticalLayout v = new VerticalLayout();
    v.setWidth("700px");
    v.setMargin(true);/*from w  w w.j av a  2s  .c  om*/
    v.setSpacing(true);

    Label cellCase = new Label();
    cellCase.setValue("<b>Case</b>: " + ccs.getCellCaseById(getCellCaseId()).getCaseTopic());
    cellCase.setContentMode(ContentMode.HTML);
    v.addComponent(cellCase);

    Label cellItem = new Label();
    cellItem.setContentMode(ContentMode.HTML);

    Button approvalBtn = new Button();
    approvalBtn.setCaption("Approve CASE");
    approvalBtn.setWidthUndefined();
    approvalBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approvalBtn.addClickListener(buttonClickListener);
    if (ccs.getCellCaseById(getCellCaseId()).getApprovalStatus() == 0) {
        approvalBtn.setVisible(true);
    } else {
        approvalBtn.setVisible(false);
    }
    v.addComponent(approvalBtn);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");

    approvalItemBtn.setVisible(false);
    approvalItemBtn.setWidthUndefined();
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_TINY);
    approvalItemBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);

    if (getCellItemId() != 0) {
        approvalBtn.setCaption("Approve ITEM");
        CellItem ci = cis.getCellItemById(getCellItemId());
        keyList = k.getAllItemKey(getCellItemId());
        keyIndexSize = keyList.size();

        if (keyList.isEmpty()) {
            ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
            return null;
        }

        stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");
        cellItem.setValue("<b>STEM</b>: " + getStem());
        OptionGroup options = new OptionGroup();
        options.addItems(cis.getCellItemById(getCellItemId()).getOptionA(),
                cis.getCellItemById(getCellItemId()).getOptionB(),
                cis.getCellItemById(getCellItemId()).getOptionC(),
                cis.getCellItemById(getCellItemId()).getOptionD());
        h1.addComponent(options);
        h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);

        if (cis.getCellItemById(getCellItemId()).getCellItemStatus() == 0) {
            approvalItemBtn.setVisible(true);
        } else {
            approvalItemBtn.setVisible(false);
        }
        approvalItemBtn.addClickListener(buttonClickListener);
        approvalItemBtn.setVisible(true);
    }
    v.addComponent(approvalBtn);
    v.addComponent(cellItem);
    v.addComponent(h1);
    v.addComponent(approvalItemBtn);

    Label separator = new Label("<HR>");
    separator.setContentMode(ContentMode.HTML);
    v.addComponent(separator);

    return v;
}

From source file:com.etest.view.testbank.cellitem.ViewStemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//from   w w w .  j  a v  a  2  s .c  o m
    form.setSpacing(true);

    CellItem ci = cis.getCellItemById(getCellItemId());
    if (ci.getCellItemId() == 0) {
        ci = hs.getCellItemById(getCellItemId());
    }

    keyList = k.getAllItemKey(getCellItemId());
    keyIndexSize = keyList.size();
    if (keyList.isEmpty()) {
        ShowErrorNotification.error("No Item Key was found for STEM: \n" + ci.getItem());
        return null;
    }
    stem = ci.getItem().replace("{key}", "<u>" + keyList.get(getKeyIndex()) + "</u>");

    label.setValue("<b>STEM</b>: " + getStem());
    label.setContentMode(ContentMode.HTML);
    form.addComponent(label);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setWidth("100%");

    OptionGroup options = new OptionGroup();
    options.addItems(ci.getOptionA(), ci.getOptionB(), ci.getOptionC(), ci.getOptionD());
    options.addValueChangeListener((Property.ValueChangeEvent event) -> {
        boolean result = k.isAnswerCorrect(getCellItemId(), getItemKey(),
                CommonUtilities.escapeSingleQuote(event.getProperty().getValue()));
        if (result) {
            Notification.show("Correct Answer!", Notification.Type.TRAY_NOTIFICATION);
        } else {
            Notification.show("Wrong Answer", Notification.Type.TRAY_NOTIFICATION);
        }
    });
    h1.addComponent(options);
    h1.setComponentAlignment(options, Alignment.MIDDLE_CENTER);
    form.addComponent(h1);

    GridLayout g = new GridLayout(2, 2);
    g.setWidth("100%");
    g.setSpacing(true);

    prev = new Button();
    prev.setWidth("50px");
    prev.setIcon(FontAwesome.ANGLE_DOUBLE_LEFT);
    prev.addStyleName(ValoTheme.BUTTON_PRIMARY);
    prev.addStyleName(ValoTheme.BUTTON_SMALL);
    prev.addClickListener(prevBtnClickListener);
    g.addComponent(prev, 0, 0);
    g.setComponentAlignment(prev, Alignment.MIDDLE_LEFT);

    next = new Button();
    next.setWidth("50px");
    next.setIcon(FontAwesome.ANGLE_DOUBLE_RIGHT);
    next.addStyleName(ValoTheme.BUTTON_PRIMARY);
    next.addStyleName(ValoTheme.BUTTON_SMALL);
    next.addClickListener(nextBtnClickListener);
    g.addComponent(next, 1, 0);
    g.setComponentAlignment(next, Alignment.MIDDLE_RIGHT);

    if (getKeyIndexSize() == 1) {
        prev.setEnabled(false);
        next.setEnabled(false);
    }

    populateDataTable();
    g.addComponent(table, 0, 1, 1, 1);
    g.setComponentAlignment(table, Alignment.MIDDLE_CENTER);
    form.addComponent(g);

    return form;
}

From source file:com.expressui.sample.view.LoginPage.java

License:Open Source License

@PostConstruct
@Override// w ww . java 2 s  . com
public void postConstruct() {
    super.postConstruct();

    setSizeFull();

    LoginForm loginForm = new LoginForm();
    loginForm.addStyleName("border");
    loginForm.setSizeUndefined();
    loginForm.setLoginButtonCaption(uiMessageSource.getMessage("loginPage.button"));
    loginForm.setUsernameCaption(uiMessageSource.getMessage("loginPage.username"));
    loginForm.setPasswordCaption(uiMessageSource.getMessage("loginPage.password"));
    loginForm.addListener(new LoginHandler());

    Panel panel = new Panel();
    panel.addStyleName("loginPage");
    panel.addStyleName("border");
    panel.setSizeUndefined();
    panel.setCaption(uiMessageSource.getMessage("loginPage.caption"));
    panel.addComponent(loginForm);
    panel.addComponent(new Label(uiMessageSource.getMessage("loginPage.tip")));

    addComponent(panel);
    setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
}