Example usage for com.vaadin.ui Alignment MIDDLE_RIGHT

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

Introduction

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

Prototype

Alignment MIDDLE_RIGHT

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

Click Source Link

Usage

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

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

    CellCase cc = ccs.getCellCaseById(getCellCaseId());
    Panel panel = new Panel();
    panel.setWidth("100%");
    panel.addStyleName(ValoTheme.PANEL_BORDERLESS);

    Label caseLabel = new Label();
    caseLabel.setCaption("CASE: ");
    caseLabel.setStyleName("bold-font-style");
    caseLabel.setWidth("80px");

    Label caseTopic = new Label();
    caseTopic.setValue(caseLabel.getCaption() + cc.getCaseTopic());
    caseTopic.setContentMode(ContentMode.RAW);
    caseTopic.addStyleName("wrapline");

    panel.setContent(caseTopic);
    form.addComponent(panel);

    form.addComponent(table);

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

    Button create = new Button("CREATE NEW STEM");
    create.setWidthUndefined();
    create.addStyleName(ValoTheme.BUTTON_LINK);
    create.addStyleName(ValoTheme.BUTTON_TINY);
    create.addStyleName(ValoTheme.BUTTON_QUIET);
    create.addClickListener(modifyBtnClickListener);
    v.addComponent(create);
    v.setComponentAlignment(create, Alignment.MIDDLE_RIGHT);
    form.addComponent(v);

    return form;
}

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

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);//from  www . j  ava  2s .  c o  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.etest.view.testbank.cellitem.ViewStemWindow.java

FormLayout buildForms() {
    FormLayout form = new FormLayout();
    form.setWidth("100%");
    form.setMargin(true);/*w w w  .j  a  v  a  2s .  co 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.etest.view.tq.TQCoverageUI.java

public TQCoverageUI() {
    setSizeFull();/*  ww w  . j av  a  2  s  .  c o m*/

    addComponent(buildTQCoverageForms());
    addComponent(grid);

    footer = grid.appendFooterRow();

    grid.addItemClickListener((ItemClickEvent event) -> {
        Object itemId = event.getItemId();
        Item item = grid.getContainerDataSource().getItem(itemId);

        if (event.getPropertyId().toString().equals("Topic")) {
            Window sub = getTopicWindow(item);
            if (sub.getParent() == null) {
                UI.getCurrent().addWindow(sub);
            }
        }

        Window sub;
        if (event.getPropertyId().toString().contains("Pick")) {
            boolean isValueInTBNotZero = tq.isValueInTBNotZero(item,
                    CommonUtilities.replaceStringPickToTB(event.getPropertyId()));
            if (!isValueInTBNotZero) {
                Notification.show("There are no Items in Test Bank!", Notification.Type.ERROR_MESSAGE);
                return;
            } else {
                sub = getPickWindow(item, CommonUtilities.replaceStringPickToTB(event.getPropertyId()));
                if (sub.getParent() == null) {
                    UI.getCurrent().addWindow(sub);
                }
                sub.addCloseListener((Window.CloseEvent e) -> {
                    if (tq.calculateTotalPickItemsPerTopic(grid, itemId) > CommonUtilities
                            .convertStringToDouble(item.getItemProperty("Max Items").getValue().toString())) {
                        item.getItemProperty(event.getPropertyId()).setValue(0);
                        ShowErrorNotification.error("Running Total is greater than Max Items");
                    } else {
                        item.getItemProperty("Running Total")
                                .setValue(tq.calculateTotalPickItemsPerTopic(grid, itemId));
                        footer.getCell("Running Total").setText(String.valueOf(tq.calculateRunningTotal(grid)));
                    }
                });
            }
        }

        if (event.getPropertyId().toString().equals("Max Items")) {
            double value = (double) item.getItemProperty("Max Items").getValue();
            sub = getMaxItemsWindow(item, value);
            if (sub.getParent() == null) {
                UI.getCurrent().addWindow(sub);
            }
        }
    });

    grid.getColumn("remove")
            .setRenderer(new DeleteButtonValueRenderer((ClickableRenderer.RendererClickEvent event) -> {
                grid.getContainerDataSource().removeItem(event.getItemId());
                populateGridFooter();
                footer.getCell("Running Total").setText(String.valueOf(tq.calculateRunningTotal(grid)));
            })).setWidth(100);

    footer.getCell("Topic").setText("Total");
    footer.setStyleName("align-center");

    Button generateTQ = new Button("Generate TQ");
    generateTQ.setWidth("300px");
    generateTQ.addClickListener(buttonClickListener);

    addComponent(new Label("\n"));
    addComponent(generateTQ);
    setComponentAlignment(generateTQ, Alignment.MIDDLE_RIGHT);
}

From source file:com.etest.view.tq.TQCoverageUI.java

Window getTopicWindow(Item item) {
    Window sub = new Window("TOPIC: ");
    sub.setWidth("500px");
    sub.setModal(true);/*  w w  w. j ava  2  s. c om*/
    sub.center();
    sub.setResizable(false);

    VerticalLayout v = new VerticalLayout();
    v.setWidth("100%");
    v.setMargin(true);
    v.setSpacing(true);

    topic.setInputPrompt("Select a Topic..");
    topic.addStyleName(ValoTheme.COMBOBOX_SMALL);
    topic.setWidth("100%");
    topic.addValueChangeListener((Property.ValueChangeEvent event) -> {
        if (event.getProperty().getValue() == null) {
        } else {
            syllabusId = (int) event.getProperty().getValue();
            topicStr = topic.getItem(topic.getValue()).toString();
        }
    });
    v.addComponent(topic);

    Button button = new Button("CLOSE");
    button.setWidth("50%");
    button.setIcon(FontAwesome.TASKS);
    button.addStyleName(ValoTheme.BUTTON_PRIMARY);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    button.addClickListener((Button.ClickEvent event) -> {
        if (topic.getValue() == null) {
            Notification.show("Select a Topic!", Notification.Type.WARNING_MESSAGE);
        } else {
            populateGridRow(item);
            populateGridFooter();
        }
        sub.close();
    });
    v.addComponent(button);
    v.setComponentAlignment(button, Alignment.MIDDLE_RIGHT);

    sub.setContent(v);
    sub.getContent().setHeightUndefined();

    return sub;
}

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

License:Open Source License

@PostConstruct
@Override//from   w w w. ja v a 2 s. c  o m
public void postConstruct() {
    super.postConstruct();

    String typeName = domainMessageSource.getMessage(getType().getName(), getType().getSimpleName());
    labelRegistry.putTypeLabel(getType().getName(), typeName);

    List<ToManyRelationship> toManyRelationships = getViewableToManyRelationships();
    if (toManyRelationships.size() > 0) {
        toManyRelationshipTabs = new TabSheet();
        setDebugId(toManyRelationshipTabs, "toManyRelationshipTabs");
        toManyRelationshipTabs.setSizeUndefined();
        for (ToManyRelationship toManyRelationship : toManyRelationships) {
            toManyRelationshipTabs.addTab(toManyRelationship);
            toManyRelationship.getResultsTable().addExecuteQueryListener(this, "requestRepaintAll");
            labelRegistry.putFieldLabel(getType().getName(), toManyRelationship.getChildPropertyId(),
                    "Relationship", toManyRelationship.getTypeCaption());
        }

        HorizontalLayout toManyRelationshipLayout = new HorizontalLayout();
        setDebugId(toManyRelationshipLayout, "toManyRelationshipLayout");
        toManyRelationshipLayout.setSizeUndefined();
        Label label = new Label("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", Label.CONTENT_XHTML);
        toManyRelationshipLayout.addComponent(label);
        toManyRelationshipLayout.addComponent(toManyRelationshipTabs);
        addComponent(toManyRelationshipLayout);
    }

    addCodePopupButtonIfEnabled(Alignment.MIDDLE_RIGHT, EntityForm.class);
}

From source file:com.expressui.core.view.menu.MainMenuBar.java

License:Open Source License

/**
 * Refreshes the menu bar, useful when security permissions change, for example when user logs in and
 * is no longer anonymous.// w w w  .j  a v  a  2s  .c om
 */
public void refresh() {
    removeAllComponents();
    MenuBar leftMenuBar = leftMenuBarRoot.createMenuBar();
    addComponent(leftMenuBar);

    MenuBar rightMenuBar = rightMenuBarRoot.createMenuBar();
    addComponent(rightMenuBar);
    setComponentAlignment(rightMenuBar, Alignment.MIDDLE_RIGHT);

    if (leftMenuBar.getSize() == 0 && rightMenuBar.getSize() == 0) {
        if (getCurrentUser().getRoles().isEmpty()) {
            getMainApplication().showError(
                    "Menu bar contains no viewable items because current user is not assigned any roles.");
        } else {
            getMainApplication()
                    .showError("Menu bar contains no viewable items, either because none have been coded"
                            + " or assigned roles do not allow any to be viewed.");
        }
    }

    addPopupCodeIfEnabled();
}

From source file:com.foc.vaadin.gui.FocXMLGuiComponentStatic.java

License:Apache License

public static void applyAlignment(AbstractOrderedLayout layout, Component component, String alignment) {
    alignment = alignment.toLowerCase();
    if (alignment.equals("right") || alignment.equals("middle_right")) {
        layout.setComponentAlignment(component, Alignment.MIDDLE_RIGHT);
    } else if (alignment.equals("left") || alignment.equals("middle_left")) {
        layout.setComponentAlignment(component, Alignment.MIDDLE_LEFT);
    } else if (alignment.equals("center") || alignment.equals("middle_center")) {
        layout.setComponentAlignment(component, Alignment.MIDDLE_CENTER);
    } else if (alignment.equals("top_right")) {
        layout.setComponentAlignment(component, Alignment.TOP_RIGHT);
    } else if (alignment.equals("top_left")) {
        layout.setComponentAlignment(component, Alignment.TOP_LEFT);
    } else if (alignment.equals("top_center")) {
        layout.setComponentAlignment(component, Alignment.TOP_CENTER);
    } else if (alignment.equals("bottom_right")) {
        layout.setComponentAlignment(component, Alignment.BOTTOM_RIGHT);
    } else if (alignment.equals("bottom_left")) {
        layout.setComponentAlignment(component, Alignment.BOTTOM_LEFT);
    } else if (alignment.equals("bottom_center")) {
        layout.setComponentAlignment(component, Alignment.BOTTOM_CENTER);
    }//  w ww  .j  ava  2s . c  o m
}

From source file:com.foc.vaadin.gui.layouts.FVWrapperLayout.java

License:Apache License

@Override
public void setAttributes(Attributes attributes) {
    if (attributes != null) {
        if (field != null)
            field.setAttributes(attributes);

        caption.setValue(attributes.getValue(FXML.ATT_CAPTION));
        //setSpacing(true);
        String captionWidth = attributes.getValue(FXML.ATT_CAPTION_WIDTH);
        if (captionWidth != null) {
            caption.setWidth(captionWidth);
        } else {/*  w w  w  .  j  av  a 2s.c om*/
            caption.setWidth("75px");
        }

        String captionPosition = attributes.getValue(FXML.ATT_CAPTION_POSITION);
        if (captionPosition.equals(FXML.VAL_CAPTION_POS__RIGHT)) {
            removeAllComponents();
            addComponent((Component) field);
            setComponentAlignment((Component) field, Alignment.MIDDLE_LEFT);
            addComponent(this.caption);
            setComponentAlignment(this.caption, Alignment.MIDDLE_RIGHT);
            setSpacing(true);
            FocXMLGuiComponentStatic.applyStyle(this.caption, "f16,bold,text-left");
        } else if (captionPosition.equals(FXML.VAL_CAPTION_POS__LEFT)) {
            removeAllComponents();
            addComponent(this.caption);
            setComponentAlignment(this.caption, Alignment.MIDDLE_RIGHT);
            addComponent((Component) field);
            setComponentAlignment((Component) field, Alignment.MIDDLE_LEFT);
            setSpacing(true);
            FocXMLGuiComponentStatic.applyStyle(this.caption, "f12,bold,text-right");
        }
        FocXMLGuiComponentStatic.applyStyle(caption, attributes.getValue(FXML.ATT_CAPTION_STYLE));
    }
}

From source file:com.foc.vaadin.gui.layouts.validationLayout.FVValidationLayout.java

License:Apache License

public void addApplyDiscardButtons(boolean showBackButton) {
    boolean showValidationAndSave = validationSettings != null && validationSettings.isWithApply();
    boolean showSave = validationSettings != null && validationSettings.isWithSave();
    boolean showDiscard = validationSettings != null && validationSettings.isWithDiscard();
    boolean showGoBack = validationSettings == null && showBackButton;

    ICentralPanel centralPanel = getCentralPanel();
    if (centralPanel instanceof FocXMLLayout) {
        FocXMLLayout layout = (FocXMLLayout) centralPanel;

        if (Globals.isValo()) {
            Component comp = valo_GetNotCompletedYet(true);
            if (comp != null) {
                mainHorizontalLayout.addComponent(comp);
                mainHorizontalLayout.setComponentAlignment(comp, Alignment.MIDDLE_RIGHT);
            }//from   www  . ja v a2  s  . co m
        }

        if (layout.getTableTreeThatOpenedThisForm() != null
                && layout.getTableTreeThatOpenedThisForm().getTableTreeDelegate() != null
                && layout.getTableTreeThatOpenedThisForm().getTableTreeDelegate().isDeleteEnabled()
                && getFocObject() != null) {
            if (Globals.isValo()) {
                AbstractComponent deleteButtton = valo_GetDeleteEmbedded(true);
                if (deleteButtton != null) {
                    mainHorizontalLayout.addComponent(deleteButtton);
                    mainHorizontalLayout.setComponentAlignment(deleteButtton, Alignment.BOTTOM_LEFT);
                }
            } else {
                Button deleteButtton = getDeleteButton(true);
                if (deleteButtton != null) {
                    mainHorizontalLayout.addComponentAsFirst(deleteButtton);
                    mainHorizontalLayout.setComponentAlignment(deleteButtton, Alignment.BOTTOM_LEFT);
                }
            }
        }
    }

    Component discardOrGoBackButton = null;

    if (showDiscard) {
        if (Globals.isValo()) {
            discardOrGoBackButton = valo_GetDiscardButton(true);
        } else {
            discardOrGoBackButton = getDiscardButton(true);
        }
    } else if (showGoBack) {
        if (Globals.isValo()) {
            discardOrGoBackButton = valo_GetGoBackEmbedded(true);
        } else {
            discardOrGoBackButton = getGoBackButton(true);
        }
    }

    if (discardOrGoBackButton != null) {
        mainHorizontalLayout.addComponent(discardOrGoBackButton);
        if (Globals.isValo()) {
            mainHorizontalLayout.setComponentAlignment(discardOrGoBackButton, Alignment.MIDDLE_RIGHT);
        } else {
            mainHorizontalLayout.setComponentAlignment(discardOrGoBackButton, Alignment.BOTTOM_RIGHT);
        }

        if (titleLabel == null) {
        }
    }

    if (showValidationAndSave) {
        if (showSave) {
            if (Globals.isValo()) {
                mainHorizontalLayout.addComponent(valo_GetSaveButton(true));
                mainHorizontalLayout.setComponentAlignment(valo_GetSaveButton(false), Alignment.MIDDLE_LEFT);
            } else {
                mainHorizontalLayout.addComponent(getSaveButton(true));
                mainHorizontalLayout.setComponentAlignment(getSaveButton(false), Alignment.BOTTOM_LEFT);
            }
        }

        if (Globals.isValo()) {
            mainHorizontalLayout.addComponent(valo_GetApplyButton(true));
            mainHorizontalLayout.setComponentAlignment(valo_GetApplyButton(false), Alignment.MIDDLE_LEFT);
        } else {
            mainHorizontalLayout.addComponent(getApplyButton(true));
            mainHorizontalLayout.setComponentAlignment(getApplyButton(false), Alignment.BOTTOM_LEFT);
        }
    }
}