Example usage for com.vaadin.ui Alignment TOP_RIGHT

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

Introduction

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

Prototype

Alignment TOP_RIGHT

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

Click Source Link

Usage

From source file:com.esofthead.mycollab.shell.view.SetupNewInstanceView.java

License:Open Source License

public SetupNewInstanceView() {
    this.setDefaultComponentAlignment(Alignment.TOP_CENTER);
    MVerticalLayout content = new MVerticalLayout().withWidth("600px");
    this.with(content);
    content.with(ELabel.h2("Last step, you are almost there!").withWidthUndefined());
    content.with(ELabel.h3("All fields are required *").withStyleName("overdue").withWidthUndefined());
    content.with(// w w  w.  j  ava  2 s.  c  o m
            new ELabel(AppContext.getMessage(ShellI18nEnum.OPT_SUPPORTED_LANGUAGES_INTRO), ContentMode.HTML)
                    .withStyleName(UIConstants.META_COLOR));
    GridFormLayoutHelper formLayoutHelper = GridFormLayoutHelper.defaultFormLayoutHelper(2, 8, "200px");
    formLayoutHelper.getLayout().setWidth("600px");
    final TextField adminField = formLayoutHelper.addComponent(new TextField(), "Admin email", 0, 0);
    final PasswordField passwordField = formLayoutHelper.addComponent(new PasswordField(), "Admin password", 0,
            1);
    final PasswordField retypePasswordField = formLayoutHelper.addComponent(new PasswordField(),
            "Retype Admin password", 0, 2);
    final DateFormatField dateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_YYMMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 3);

    final DateFormatField shortDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_SHORT_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_MMDD_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 4);

    final DateFormatField longDateFormatField = formLayoutHelper.addComponent(
            new DateFormatField(SimpleBillingAccount.DEFAULT_LONG_DATE_FORMAT),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_HUMAN_DATE_FORMAT),
            AppContext.getMessage(GenericI18Enum.FORM_DATE_FORMAT_HELP), 0, 5);

    final TimeZoneSelectionField timeZoneSelectionField = formLayoutHelper.addComponent(
            new TimeZoneSelectionField(false), AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_TIMEZONE), 0,
            6);
    timeZoneSelectionField.setValue(TimeZone.getDefault().getID());
    final LanguageSelectionField languageBox = formLayoutHelper.addComponent(new LanguageSelectionField(),
            AppContext.getMessage(AdminI18nEnum.FORM_DEFAULT_LANGUAGE), 0, 7);
    languageBox.setValue(Locale.US.toLanguageTag());
    content.with(formLayoutHelper.getLayout());

    Button installBtn = new Button("Setup", new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            String adminName = adminField.getValue();
            String password = passwordField.getValue();
            String retypePassword = retypePasswordField.getValue();
            if (!StringUtils.isValidEmail(adminName)) {
                NotificationUtil.showErrorNotification("Invalid email value");
                return;
            }

            if (!password.equals(retypePassword)) {
                NotificationUtil.showErrorNotification("Password is not match");
                return;
            }

            String dateFormat = dateFormatField.getValue();
            String shortDateFormat = shortDateFormatField.getValue();
            String longDateFormat = longDateFormatField.getValue();
            if (!isValidDayPattern(dateFormat) || !isValidDayPattern(shortDateFormat)
                    || !isValidDayPattern(longDateFormat)) {
                NotificationUtil.showErrorNotification("Invalid date format");
                return;
            }
            String language = languageBox.getValue();
            String timezoneDbId = timeZoneSelectionField.getValue();
            BillingAccountMapper billingAccountMapper = AppContextUtil
                    .getSpringBean(BillingAccountMapper.class);
            BillingAccountExample ex = new BillingAccountExample();
            ex.createCriteria().andIdEqualTo(AppContext.getAccountId());
            List<BillingAccount> billingAccounts = billingAccountMapper.selectByExample(ex);
            BillingAccount billingAccount = billingAccounts.get(0);
            billingAccount.setDefaultlanguagetag(language);
            billingAccount.setDefaultyymmddformat(dateFormat);
            billingAccount.setDefaultmmddformat(shortDateFormat);
            billingAccount.setDefaulthumandateformat(longDateFormat);
            billingAccount.setDefaulttimezone(timezoneDbId);
            billingAccountMapper.updateByPrimaryKey(billingAccount);

            BillingAccountService billingAccountService = AppContextUtil
                    .getSpringBean(BillingAccountService.class);

            billingAccountService.createDefaultAccountData(adminName, password, timezoneDbId, language, true,
                    true, AppContext.getAccountId());
            ((DesktopApplication) UI.getCurrent()).doLogin(adminName, password, false);

        }
    });
    installBtn.addStyleName(UIConstants.BUTTON_ACTION);
    content.with(installBtn).withAlign(installBtn, Alignment.TOP_RIGHT);
}

From source file:com.esofthead.mycollab.vaadin.ui.Depot.java

License:Open Source License

public Depot(final Label titleLbl, final AbstractOrderedLayout headerElement,
        final ComponentContainer component, final String headerWidth, final String headerLeftWidth) {
    this.setStyleName("depotComp");
    this.setMargin(new MarginInfo(true, false, false, false));
    this.header = new HorizontalLayout();
    this.header.setStyleName("depotHeader");
    this.header.setWidth(headerWidth);
    this.bodyContent = component;
    if (headerElement != null) {
        this.headerContent = headerElement;
    } else {/*w  w  w  .j  a  va2  s.com*/
        this.headerContent = new HorizontalLayout();
        this.headerContent.setSpacing(true);
        this.headerContent.setMargin(true);
        this.headerContent.setDefaultComponentAlignment(Alignment.MIDDLE_LEFT);
        this.headerContent.setVisible(false);
    }

    this.headerContent.setStyleName("header-elements");
    this.headerContent.setWidthUndefined();
    this.headerContent.setSizeUndefined();

    this.addComponent(this.header);

    final HorizontalLayout headerLeft = new HorizontalLayout();
    headerLeft.setMargin(false);
    this.headerLbl = titleLbl;
    this.headerLbl.setStyleName("h2");
    this.headerLbl.setWidth("100%");
    headerLeft.addComponent(this.headerLbl);
    headerLeft.setStyleName("depot-title");
    headerLeft.addLayoutClickListener(new LayoutClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void layoutClick(final LayoutClickEvent event) {
            Depot.this.isOpenned = !Depot.this.isOpenned;
            if (Depot.this.isOpenned) {
                Depot.this.bodyContent.setVisible(true);
                Depot.this.removeStyleName("collapsed");
            } else {
                Depot.this.bodyContent.setVisible(false);
                Depot.this.addStyleName("collapsed");
            }
        }
    });
    final CssLayout headerWrapper = new CssLayout();
    headerWrapper.addComponent(headerLeft);
    headerWrapper.setStyleName("header-wrapper");
    headerWrapper.setWidth(headerLeftWidth);
    this.header.addComponent(headerWrapper);
    this.header.setComponentAlignment(headerWrapper, Alignment.MIDDLE_LEFT);
    this.header.addComponent(this.headerContent);
    this.header.setComponentAlignment(this.headerContent, Alignment.TOP_RIGHT);
    this.header.setExpandRatio(headerWrapper, 1.0f);

    final CustomComponent customComp = new CustomComponent(this.bodyContent);
    customComp.setWidth("100%");
    this.bodyContent.addStyleName("depotContent");

    this.addComponent(customComp);
    this.setComponentAlignment(customComp, Alignment.TOP_CENTER);
}

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

License:Open Source License

public void addHeaderRight(final ComponentContainer headerRight) {
    header.addComponent(headerRight);
    header.setComponentAlignment(headerRight, Alignment.TOP_RIGHT);
}

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);/* ww w  . j a v  a 2 s  .c o  m*/
    listBuilder.setColumns(0);
    listBuilder.setLeftColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_AVAILABLE_COLUMNS));
    listBuilder.setRightColumnCaption(AppContext.getMessage(GenericI18Enum.OPT_VIEW_COLUMNS));
    listBuilder.setWidth(100, Sizeable.Unit.PERCENTAGE);
    listBuilder.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
    final BeanItemContainer<TableViewField> container = new BeanItemContainer<>(TableViewField.class,
            this.getAvailableColumns());
    listBuilder.setContainerDataSource(container);
    Iterator<TableViewField> iterator = getAvailableColumns().iterator();
    while (iterator.hasNext()) {
        TableViewField field = iterator.next();
        listBuilder.setItemCaption(field, AppContext.getMessage(field.getDescKey()));
    }
    this.setSelectedViewColumns();
    contentLayout.with(listBuilder).withAlign(listBuilder, Alignment.TOP_CENTER);

    Button restoreLink = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_RESET),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(ClickEvent event) {
                    List<TableViewField> defaultSelectedColumns = tableItem.getDefaultSelectedColumns();
                    if (defaultSelectedColumns != null) {
                        final List<TableViewField> selectedColumns = new ArrayList<>();
                        final BeanItemContainer<TableViewField> container = (BeanItemContainer<TableViewField>) listBuilder
                                .getContainerDataSource();
                        final Collection<TableViewField> itemIds = container.getItemIds();

                        for (TableViewField column : defaultSelectedColumns) {
                            for (final TableViewField viewField : itemIds) {
                                if (column.getField().equals(viewField.getField())) {
                                    selectedColumns.add(viewField);
                                }
                            }
                        }

                        listBuilder.setValue(selectedColumns);
                    }

                }
            });
    restoreLink.setStyleName(UIConstants.BUTTON_LINK);
    contentLayout.with(restoreLink).withAlign(restoreLink, Alignment.TOP_RIGHT);

    final Button saveBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_SAVE),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @SuppressWarnings("unchecked")
                @Override
                public void buttonClick(final ClickEvent event) {
                    List<TableViewField> selectedColumns = (List<TableViewField>) listBuilder.getValue();
                    table.setDisplayColumns(selectedColumns);
                    // Save custom table view def
                    CustomViewStore viewDef = new CustomViewStore();
                    viewDef.setSaccountid(AppContext.getAccountId());
                    viewDef.setCreateduser(AppContext.getUsername());
                    viewDef.setViewid(viewId);
                    viewDef.setViewinfo(FieldDefAnalyzer.toJson(new ArrayList<>(selectedColumns)));
                    customViewStoreService.saveOrUpdateViewLayoutDef(viewDef);
                    close();
                }
            });
    saveBtn.setStyleName(UIConstants.BUTTON_ACTION);
    saveBtn.setIcon(FontAwesome.SAVE);

    final Button cancelBtn = new Button(AppContext.getMessage(GenericI18Enum.BUTTON_CANCEL),
            new Button.ClickListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void buttonClick(final ClickEvent event) {
                    close();
                }
            });
    cancelBtn.setStyleName(UIConstants.BUTTON_OPTION);

    MHorizontalLayout buttonControls = new MHorizontalLayout(cancelBtn, saveBtn);
    contentLayout.with(buttonControls).withAlign(buttonControls, Alignment.TOP_RIGHT);
}

From source file:com.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 av a2  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.etest.view.testbank.cellitem.CellItemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*from www. java 2  s .  co  m*/
    form.setSpacing(true);

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

    Button helpBtn = new Button("HELP");
    helpBtn.setWidthUndefined();
    helpBtn.setIcon(FontAwesome.TASKS);
    helpBtn.addStyleName(ValoTheme.BUTTON_PRIMARY);
    helpBtn.addStyleName(ValoTheme.BUTTON_SMALL);
    helpBtn.addClickListener((Button.ClickEvent event) -> {
        Window sub = new MultipleChoiceHelpViewer();
        if (sub.getParent() == null) {
            UI.getCurrent().addWindow(sub);
        }
    });
    hlayout.addComponent(helpBtn);
    hlayout.setComponentAlignment(helpBtn, Alignment.MIDDLE_RIGHT);
    form.addComponent(hlayout);

    bloomsTaxonomy.setCaption("Blooms Class: ");
    bloomsTaxonomy.setWidth("30%");
    form.addComponent(bloomsTaxonomy);

    stem = new TextArea("Stem: ");
    stem.setWidth("100%");
    stem.setRows(5);
    stem.setWordwrap(true);
    form.addComponent(stem);

    HorizontalLayout h1 = new HorizontalLayout();
    h1.setCaption("Option A:");
    h1.setWidth("100%");
    h1.setSpacing(true);

    optionA = new CommonTextField("add option A", null);
    optionA.setWidth("500px");
    h1.addComponent(optionA);

    Button optionABtn = new CommonButton("OPTION A");
    optionABtn.setWidth("120px");
    optionABtn.addClickListener(updateOptionAndKeyListerner);
    h1.addComponent(optionABtn);
    h1.setComponentAlignment(optionABtn, Alignment.MIDDLE_RIGHT);
    optionABtn.setVisible(isEdit());
    form.addComponent(h1);

    HorizontalLayout h2 = new HorizontalLayout();
    h2.setCaption("Key A:");
    h2.setWidth("100%");
    h2.setSpacing(true);

    keyA = new CommonTextField("Enter a Key for Option A", null);
    keyA.setWidth("500px");
    h2.addComponent(keyA);

    Button keyABtn = new CommonButton("KEY A");
    keyABtn.setWidth("120px");
    keyABtn.addClickListener(updateOptionAndKeyListerner);
    h2.addComponent(keyABtn);
    h2.setComponentAlignment(keyABtn, Alignment.MIDDLE_RIGHT);
    keyABtn.setVisible(isEdit());
    form.addComponent(h2);

    HorizontalLayout h3 = new HorizontalLayout();
    h3.setCaption("Option B:");
    h3.setWidth("100%");
    h3.setSpacing(true);

    optionB = new CommonTextField("add option B", null);
    optionB.setWidth("500px");
    h3.addComponent(optionB);

    Button optionBBtn = new CommonButton("OPTION B");
    optionBBtn.setWidth("120px");
    optionBBtn.addClickListener(updateOptionAndKeyListerner);
    h3.addComponent(optionBBtn);
    h3.setComponentAlignment(optionBBtn, Alignment.MIDDLE_RIGHT);
    optionBBtn.setVisible(isEdit());
    form.addComponent(h3);

    HorizontalLayout h4 = new HorizontalLayout();
    h4.setCaption("Key B:");
    h4.setWidth("100%");
    h4.setSpacing(true);

    keyB = new CommonTextField("Enter a Key for Option B", null);
    keyB.setWidth("500px");
    h4.addComponent(keyB);

    Button keyBBtn = new CommonButton("KEY B");
    keyBBtn.setWidth("120px");
    keyBBtn.addClickListener(updateOptionAndKeyListerner);
    h4.addComponent(keyBBtn);
    h4.setComponentAlignment(keyBBtn, Alignment.MIDDLE_RIGHT);
    keyBBtn.setVisible(isEdit());
    form.addComponent(h4);

    HorizontalLayout h5 = new HorizontalLayout();
    h5.setCaption("Option C:");
    h5.setWidth("100%");
    h5.setSpacing(true);

    optionC = new CommonTextField("add option C", null);
    optionC.setWidth("500px");
    h5.addComponent(optionC);

    Button optionCBtn = new CommonButton("OPTION C");
    optionCBtn.setWidth("120px");
    optionCBtn.addClickListener(updateOptionAndKeyListerner);
    h5.addComponent(optionCBtn);
    h5.setComponentAlignment(optionCBtn, Alignment.TOP_RIGHT);
    optionCBtn.setVisible(isEdit());
    form.addComponent(h5);

    HorizontalLayout h6 = new HorizontalLayout();
    h6.setCaption("Key C:");
    h6.setWidth("100%");
    h6.setSpacing(true);

    keyC = new CommonTextField("Enter a Key for Option C", null);
    keyC.setWidth("500px");
    h6.addComponent(keyC);

    Button keyCBtn = new CommonButton("KEY C");
    keyCBtn.setWidth("120px");
    keyCBtn.addClickListener(updateOptionAndKeyListerner);
    h6.addComponent(keyCBtn);
    h6.setComponentAlignment(keyCBtn, Alignment.MIDDLE_RIGHT);
    keyCBtn.setVisible(isEdit());
    form.addComponent(h6);

    HorizontalLayout h7 = new HorizontalLayout();
    h7.setCaption("Option D:");
    h7.setWidth("100%");
    h7.setSpacing(true);

    optionD = new CommonTextField("add option D", null);
    optionD.setWidth("500px");
    h7.addComponent(optionD);

    Button optionDBtn = new CommonButton("OPTION D");
    optionDBtn.setWidth("120px");
    optionDBtn.addClickListener(updateOptionAndKeyListerner);
    h7.addComponent(optionDBtn);
    h7.setComponentAlignment(optionDBtn, Alignment.MIDDLE_RIGHT);
    optionDBtn.setVisible(isEdit());
    form.addComponent(h7);

    HorizontalLayout h8 = new HorizontalLayout();
    h8.setCaption("Key D:");
    h8.setWidth("100%");
    h8.setSpacing(true);

    keyD = new CommonTextField("Enter a Key for Option D", null);
    keyD.setWidth("500px");
    h8.addComponent(keyD);

    Button keyDBtn = new CommonButton("KEY D");
    keyDBtn.setWidth("120px");
    keyDBtn.addClickListener(updateOptionAndKeyListerner);
    h8.addComponent(keyDBtn);
    h8.setComponentAlignment(keyDBtn, Alignment.MIDDLE_RIGHT);
    keyDBtn.setVisible(isEdit());
    form.addComponent(h8);

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

    Button save = new Button("SAVE");
    save.setWidth("200px");
    save.setIcon(FontAwesome.SAVE);
    save.addStyleName(ValoTheme.BUTTON_PRIMARY);
    save.addStyleName(ValoTheme.BUTTON_SMALL);
    save.addClickListener(buttonClickListener);

    Button remove = new Button("ARCHIVE/REMOVE ITEM?");
    remove.setWidth("200px");
    remove.setIcon(FontAwesome.ARCHIVE);
    remove.addStyleName(ValoTheme.BUTTON_PRIMARY);
    remove.addStyleName(ValoTheme.BUTTON_SMALL);
    remove.addClickListener(buttonClickListener);

    Button approve = new Button("APPROVE ITEM?");
    approve.setWidth("200px");
    approve.setIcon(FontAwesome.THUMBS_O_UP);
    approve.addStyleName(ValoTheme.BUTTON_PRIMARY);
    approve.addStyleName(ValoTheme.BUTTON_SMALL);
    approve.addClickListener(buttonClickListener);

    Button edit = new Button("UPDATE");
    edit.setWidth("200px");
    edit.setIcon(FontAwesome.SAVE);
    edit.addStyleName(ValoTheme.BUTTON_PRIMARY);
    edit.addStyleName(ValoTheme.BUTTON_SMALL);
    edit.addClickListener(buttonClickListener);

    if (getCellItemId() != 0) {
        CellItem ci = cis.getCellItemById(getCellItemId());
        bloomsTaxonomy.setValue(ci.getBloomsClassId());
        bloomsTaxonomy.addValueChangeListener((Property.ValueChangeEvent event) -> {
            isBloomsChanged = true;
        });

        stem.setValue(ci.getItem());
        stem.addTextChangeListener((FieldEvents.TextChangeEvent event) -> {
            if (!stem.getValue().trim().equals(event.getText().trim())) {
                isStemChanged = true;
            }
        });

        /**
         * OPTION A
         */
        optionA.setValue(ci.getOptionA());
        isOptionAKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionA());
        if (isOptionAKeyExist) {
            keyA.setValue(k.getItemKey(getCellItemId(), ci.getOptionA()));
        }
        keyA.setData(k.getItemKeyId(getCellItemId(), ci.getOptionA()));

        /**
         * OPTION B
         */
        optionB.setValue(ci.getOptionB());
        isOptionBKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionB());
        if (isOptionBKeyExist) {
            keyB.setValue(k.getItemKey(getCellItemId(), ci.getOptionB()));
        }
        keyB.setData(k.getItemKeyId(getCellItemId(), ci.getOptionB()));

        /**
         * OPTION C
         */
        optionC.setValue(ci.getOptionC());
        isOptionCKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionC());
        if (isOptionCKeyExist) {
            keyC.setValue(k.getItemKey(getCellItemId(), ci.getOptionC()));
        }
        keyC.setData(k.getItemKeyId(getCellItemId(), ci.getOptionC()));

        /**
         * OPTION D
         */
        optionD.setValue(ci.getOptionD());
        isOptionDKeyExist = k.isKeyExist(getCellItemId(), ci.getOptionD());
        if (isOptionDKeyExist) {
            keyD.setValue(k.getItemKey(getCellItemId(), ci.getOptionD()));
        }
        keyD.setData(k.getItemKeyId(getCellItemId(), ci.getOptionD()));

        h.addComponent(remove);
        h.setComponentAlignment(remove, Alignment.MIDDLE_RIGHT);

        h.addComponent(approve);
        h.setComponentAlignment(approve, Alignment.MIDDLE_RIGHT);

        h.addComponent(edit);
        h.setComponentAlignment(edit, Alignment.MIDDLE_RIGHT);
        form.addComponent(h);
    } else {
        h.addComponent(save);
        h.setComponentAlignment(save, Alignment.MIDDLE_RIGHT);
        form.addComponent(h);
    }

    return form;
}

From source file:com.expressui.core.view.form.layout.LeftLabelGridLayout.java

License:Open Source License

private void addFieldImpl(FormField formField) {
    Label label = formField.getFieldLabel();

    HorizontalLayout fieldLayout = new HorizontalLayout();
    String id = StringUtil.generateDebugId("e", this, fieldLayout, "fieldLayout");
    fieldLayout.setDebugId(id);//www. j  a v  a2  s  .  c  om
    fieldLayout.setSizeUndefined();
    Field field = formField.getField();
    fieldLayout.addComponent(field);

    Label spacer = new Label();
    spacer.setWidth("1em");

    if (formField.getColumnEnd() != null && formField.getRowEnd() != null) {
        addComponent(label, getLabelColumn(formField), getRowStart(formField), getLabelColumn(formField),
                getRowEnd(formField));

        addComponent(fieldLayout, getFieldColumn(formField), getRowStart(formField), getColumnEnd(formField),
                getRowEnd(formField));

        addComponent(spacer, getSpacerColumn(formField), getRowStart(formField), getSpacerColumn(formField),
                getRowEnd(formField));
    } else {
        addComponent(label, getLabelColumn(formField), getRowStart(formField));

        addComponent(fieldLayout, getFieldColumn(formField), getRowStart(formField));

        addComponent(spacer, getSpacerColumn(formField), getRowStart(formField));
    }
    setComponentAlignment(fieldLayout, Alignment.TOP_LEFT);
    setComponentAlignment(label, Alignment.TOP_RIGHT);
    setComponentAlignment(spacer, Alignment.TOP_LEFT);
}

From source file:com.expressui.core.view.form.ResultsConnectedEntityForm.java

License:Open Source License

private HorizontalLayout createNavigationFormLayout() {
    HorizontalLayout navigationFormLayout = new HorizontalLayout();
    String id = StringUtil.generateDebugId("e", this, navigationFormLayout, "navigationFormLayout");
    navigationFormLayout.setDebugId(id);
    navigationFormLayout.setSizeUndefined();

    VerticalLayout previousButtonLayout = new VerticalLayout();
    id = StringUtil.generateDebugId("e", this, previousButtonLayout, "previousButtonLayout");
    previousButtonLayout.setDebugId(id);

    previousButtonLayout.setSizeUndefined();
    previousButtonLayout.setMargin(false);
    previousButtonLayout.setSpacing(false);
    Label spaceLabel = new Label("</br></br></br>", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();/*from   w ww  .ja  v  a2s. c o m*/
    previousButtonLayout.addComponent(spaceLabel);

    Button previousButton = new Button(null, this, "previousItem");
    previousButton.setDescription(entityForm.uiMessageSource.getToolTip("entityForm.previous.toolTip"));
    previousButton.setSizeUndefined();
    previousButton.addStyleName("borderless");
    previousButton.setIcon(new ThemeResource("../expressui/icons/16/previous.png"));

    if (entityForm.getViewableToManyRelationships().size() == 0) {
        HorizontalLayout previousButtonHorizontalLayout = new HorizontalLayout();
        id = StringUtil.generateDebugId("e", this, previousButtonHorizontalLayout,
                "previousButtonHorizontalLayout");
        previousButtonHorizontalLayout.setDebugId(id);
        previousButtonHorizontalLayout.setSizeUndefined();
        Label horizontalSpaceLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", Label.CONTENT_XHTML);
        horizontalSpaceLabel.setSizeUndefined();
        previousButtonHorizontalLayout.addComponent(previousButton);
        previousButtonHorizontalLayout.addComponent(horizontalSpaceLabel);
        previousButtonLayout.addComponent(previousButtonHorizontalLayout);
    } else {
        previousButtonLayout.addComponent(previousButton);
    }

    navigationFormLayout.addComponent(previousButtonLayout);
    navigationFormLayout.setComponentAlignment(previousButtonLayout, Alignment.TOP_LEFT);

    navigationFormLayout.addComponent(entityForm);

    VerticalLayout nextButtonLayout = new VerticalLayout();
    id = StringUtil.generateDebugId("e", this, nextButtonLayout, "nextButtonLayout");
    nextButtonLayout.setDebugId(id);
    nextButtonLayout.setSizeUndefined();
    nextButtonLayout.setMargin(false);
    nextButtonLayout.setSpacing(false);
    spaceLabel = new Label("</br></br></br>", Label.CONTENT_XHTML);
    spaceLabel.setSizeUndefined();
    previousButtonLayout.addComponent(spaceLabel);
    nextButtonLayout.addComponent(spaceLabel);

    Button nextButton = new Button(null, this, "nextItem");
    nextButton.setDescription(entityForm.uiMessageSource.getToolTip("entityForm.next.toolTip"));
    nextButton.setSizeUndefined();
    nextButton.addStyleName("borderless");
    nextButton.setIcon(new ThemeResource("../expressui/icons/16/next.png"));

    HorizontalLayout nextButtonHorizontalLayout = new HorizontalLayout();
    id = StringUtil.generateDebugId("e", this, nextButtonHorizontalLayout, "nextButtonHorizontalLayout");
    nextButtonHorizontalLayout.setDebugId(id);
    nextButtonHorizontalLayout.setSizeUndefined();
    Label horizontalSpaceLabel = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", Label.CONTENT_XHTML);
    horizontalSpaceLabel.setSizeUndefined();
    nextButtonHorizontalLayout.addComponent(horizontalSpaceLabel);
    nextButtonHorizontalLayout.addComponent(nextButton);

    nextButtonLayout.addComponent(nextButtonHorizontalLayout);
    navigationFormLayout.addComponent(nextButtonLayout);
    navigationFormLayout.setComponentAlignment(nextButtonLayout, Alignment.TOP_RIGHT);

    navigationFormLayout.setSpacing(false);
    navigationFormLayout.setMargin(false);

    return navigationFormLayout;
}

From source file:com.foc.vaadin.gui.components.FVImageField.java

License:Apache License

public void reactToEditable() {
    if (isEditable()) {
        if (imageControlLayout != null) {
            imageControlLayout.setVisible(true);
        } else {/*from   ww  w.java 2  s  . c o m*/
            imageControlLayout = new HorizontalLayout();
            imageControlLayout.setSpacing(true);
            imageControlLayout.setWidth("100%");
            imageControlLayout.setHeight("-1px");
            addComponent(imageControlLayout);
            setComponentAlignment(imageControlLayout, Alignment.TOP_RIGHT);

            if (isEditable()) {
                FVUpload_Image uploader = new FVUpload_Image();
                uploader.setWidth("100px");
                imageControlLayout.addComponent(uploader);
                imageControlLayout.setComponentAlignment(uploader, Alignment.TOP_RIGHT);

                uploader.setImageReceiver(this);

                downloadButton = new Button("Download");//, FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_DOWNLOAD));
                if (ConfigInfo.isArabic()) {
                    downloadButton.setCaption("");//To hide the default ugly button we should set this to null
                }
                //               downloadButton.setIcon(FontAwesome.DOWNLOAD);
                downloadButton.setWidth("100px");
                //             downloadButton.setCaption(null);
                //             downloadButton.setStyleName(BaseTheme.BUTTON_LINK);
                downloadButton.addStyleName(FocXMLGuiComponentStatic.STYLE_NO_PRINT);
                downloadButton.addStyleName(FocXMLGuiComponentStatic.STYLE_HAND_POINTER_ON_HOVER);
                imageControlLayout.addComponent(downloadButton);
                imageControlLayout.setComponentAlignment(downloadButton, Alignment.TOP_LEFT);

                resource = new GenericFileResource(getFocData());
                FileDownloader downloader = new FileDownloader(resource);
                downloader.extend(downloadButton);
            }
        }
    } else {
        if (imageControlLayout != null)
            imageControlLayout.setVisible(false);
    }
}

From source file:com.foc.vaadin.gui.components.upload.FVUpload_Image.java

License:Apache License

public FVUpload_Image() {
    root = new VerticalLayout();
    root.setSpacing(false);/*from  ww w .  jav  a  2 s .co  m*/
    root.setMargin(false);
    setCompositionRoot(root);

    // Create the Upload component.
    upload = new Upload(null, this);
    upload.setImmediate(true);
    //      upload.addStyleName("focUpload");
    if (ConfigInfo.isArabic()) {
        upload.setButtonCaption("");//To hide the default ugly button we should set this to null
    } else {
        upload.setButtonCaption("Upload");//To hide the default ugly button we should set this to null
    }

    // Use a custom button caption instead of plain "Upload".
    //upload.setButtonCaption(null);
    /*
    uploadButton = new FVButton("", new Button.ClickListener() {
    public void buttonClick(ClickEvent event) {
       if(upload != null) upload.startUpload();
    }
    });
            
    uploadButton.setIcon(new ThemeResource("../runo/icons/32/document-add.png"));
    uploadButton.setStyleName(BaseTheme.BUTTON_LINK);
    */

    // Listen for events regarding the success of upload.
    upload.addSucceededListener((Upload.SucceededListener) this);
    upload.addFailedListener((Upload.FailedListener) this);
    upload.addStartedListener((Upload.StartedListener) this);

    root.addComponent(upload);
    root.setComponentAlignment(upload, Alignment.TOP_RIGHT);

    //      uploadButton = new Button();
    //      uploadButton.setIcon(FVIconFactory.getInstance().getFVIcon_24(FVIconFactory.ICON_UPLOAD));
    //      uploadButton.setDescription("Upload");
    //      uploadButton.addClickListener(new Button.ClickListener() {
    //         @Override
    //         public void buttonClick(ClickEvent event) {
    //            if(upload != null){
    //               upload.submitUpload();
    //            }
    //         }
    //      });
    //      root.addComponent(uploadButton);
}