com.vaadin.ui.TextArea - java examples

Here are the examples of the java api com.vaadin.ui.TextArea taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

71 Examples 7

19 View Complete Implementation : CommitteeRankingOverviewPageModContentFactoryImpl.java
Copyright Apache License 2.0
Author : Hack23
/**
 * Creates the description.
 *
 * @return the text area
 */
private static TextArea createDescription() {
    final TextArea totalCommitteeRankinglistLabel = new TextArea(COMMITTEE_RANKING_BY_TOPIC, COMMITTEE_RANKING_BY_TOPIC_DESCRIPTION);
    totalCommitteeRankinglistLabel.setSizeFull();
    totalCommitteeRankinglistLabel.setStyleName("Level2Header");
    return totalCommitteeRankinglistLabel;
}

19 View Complete Implementation : FormHelper.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public TextArea bindTextAreaField(String fieldLabel, String fieldName, int rows) {
    TextArea field = bindTextAreaField(form, group, fieldLabel, fieldName, rows);
    this.fieldList.add(field);
    return field;
}

19 View Complete Implementation : PIPSQLResolverEditorWindow.java
Copyright MIT License
Author : att
public clreplaced PIPSQLResolverEditorWindow extends CustomComponent implements FormChangedEventNotifier, Handler {

    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Table tableAttributes;

    @AutoGenerated
    private Table tableRequiredAttributes;

    @AutoGenerated
    private CheckBox checkBoxShortIds;

    @AutoGenerated
    private TextField textFieldFilter;

    @AutoGenerated
    private TextField textFieldBase;

    @AutoGenerated
    private TextArea textAreaSelect;

    private final Action ADD_ATTRIBUTE = new Action("Add Attribute");

    private final Action EDIT_ATTRIBUTE = new Action("Edit Attribute");

    private final Action CLONE_ATTRIBUTE = new Action("Clone Attribute");

    private final Action REMOVE_ATTRIBUTE = new Action("Remove Attribute");

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    /**
     */
    protected clreplaced ResolverAttribute implements Serializable {

        private static final long serialVersionUID = 1L;

        String identifier = null;

        String prefix = null;

        PIPResolverParam id = null;

        PIPResolverParam category = null;

        PIPResolverParam datatype = null;

        PIPResolverParam issuer = null;

        PIPResolverParam column = null;

        public ResolverAttribute(String prefix, String identifier) {
            this.prefix = prefix;
            this.identifier = identifier;
        }

        public ResolverAttribute(String prefix, String identifier, ResolverAttribute target) {
            this(prefix, identifier);
            this.setId(target.getId());
            this.setCategory(target.getCategory());
            this.setDatatype(target.getDatatype());
            this.setIssuer(target.getIssuer());
            this.setColumn(target.getColumn());
            this.setResolver(target.id.getPipresolver());
        }

        public String getIdentifier() {
            return this.identifier;
        }

        public String getId() {
            if (this.id == null) {
                return null;
            }
            return this.id.getParamValue();
        }

        public String getShortId() {
            String id = this.getId();
            if (id == null) {
                return null;
            }
            return XACMLConstants.extractShortName(id);
        }

        public PIPResolverParam getIdParam() {
            return this.id;
        }

        public void setId(String id) {
            if (this.id == null) {
                this.id = new PIPResolverParam();
                this.id.setParamName(this.prefix + this.identifier + ".id");
            }
            this.id.setParamValue(id);
        }

        public void setId(PIPResolverParam param) {
            this.id = param;
        }

        public String getCategory() {
            if (this.category == null) {
                return null;
            }
            return this.category.getParamValue();
        }

        public String getShortCategory() {
            String category = this.getCategory();
            if (category == null) {
                return null;
            }
            return XACMLConstants.extractShortName(category);
        }

        public PIPResolverParam getCategoryParam() {
            return this.category;
        }

        public void setCategory(String category) {
            if (this.category == null) {
                this.category = new PIPResolverParam();
                this.category.setParamName(this.prefix + this.identifier + ".category");
            }
            this.category.setParamValue(category);
        }

        public void setCategory(PIPResolverParam param) {
            this.category = param;
        }

        public String getDatatype() {
            if (this.datatype == null) {
                return null;
            }
            return this.datatype.getParamValue();
        }

        public String getShortDatatype() {
            String dt = this.getDatatype();
            if (dt == null) {
                return null;
            }
            return XACMLConstants.extractShortName(dt);
        }

        public PIPResolverParam getDatatypeParam() {
            return this.datatype;
        }

        public void setDatatype(String datatype) {
            if (this.datatype == null) {
                this.datatype = new PIPResolverParam();
                this.datatype.setParamName(this.prefix + this.identifier + ".datatype");
            }
            this.datatype.setParamValue(datatype);
        }

        public void setDatatype(PIPResolverParam param) {
            this.datatype = param;
        }

        public String getIssuer() {
            if (this.issuer == null) {
                return null;
            }
            return this.issuer.getParamValue();
        }

        public String getShortIssuer() {
            String issuer = this.getIssuer();
            if (issuer == null) {
                return null;
            }
            return XACMLConstants.extractShortName(issuer);
        }

        public PIPResolverParam getIssuerParam() {
            return this.issuer;
        }

        public void setIssuer(String issuer) {
            if (this.issuer == null) {
                this.issuer = new PIPResolverParam();
                this.issuer.setParamName(this.prefix + this.identifier + ".issuer");
            }
            this.issuer.setParamValue(issuer);
        }

        public void setIssuer(PIPResolverParam param) {
            this.issuer = param;
        }

        public Integer getColumn() {
            if (this.column == null) {
                return null;
            }
            try {
                return Integer.parseInt(this.column.getParamValue());
            } catch (NumberFormatException e) {
                logger.error("Failed to set column: " + e);
                return null;
            }
        }

        public PIPResolverParam getColumnParam() {
            return this.column;
        }

        public void setColumn(Integer col) {
            if (this.column == null) {
                this.column = new PIPResolverParam();
                this.column.setParamName(this.prefix + this.identifier + "column");
            }
            this.column.setParamValue(col.toString());
        }

        public void setColumn(PIPResolverParam param) {
            this.column = param;
        }

        public void setResolver(PIPResolver resolver) {
            if (this.id != null) {
                this.id.setPipresolver(resolver);
            }
            if (this.category != null) {
                this.category.setPipresolver(resolver);
            }
            if (this.datatype != null) {
                this.datatype.setPipresolver(resolver);
            }
            if (this.issuer != null) {
                this.issuer.setPipresolver(resolver);
            }
            if (this.column != null) {
                this.column.setPipresolver(resolver);
            }
        }
    }

    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(PIPSQLResolverEditorWindow.clreplaced);

    private final PIPSQLResolverEditorWindow self = this;

    private final EnreplacedyItem<PIPResolver> enreplacedy;

    private final BeanItemContainer<ResolverAttribute> fieldsContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.clreplaced);

    private final BeanItemContainer<ResolverAttribute> parametersContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.clreplaced);

    private final BasicNotifier notifier = new BasicNotifier();

    boolean isSaved = false;

    String fieldPrefix;

    String parameterPrefix;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param enreplacedy
     */
    public PIPSQLResolverEditorWindow(EnreplacedyItem<PIPResolver> enreplacedy) {
        buildMainLayout();
        setCompositionRoot(mainLayout);
        // 
        // Save
        // 
        this.enreplacedy = enreplacedy;
        // 
        // Initialize
        // 
        this.initialize();
    }

    protected boolean isSQL() {
        if (this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isSQL() || this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isHyperCSV()) {
            return true;
        }
        return false;
    }

    protected boolean isLDAP() {
        return this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isLDAP();
    }

    protected boolean isCSV() {
        return this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isCSV();
    }

    protected void initialize() {
        // 
        // Initialize enreplacedy
        // 
        this.initializeEnreplacedy();
        // 
        // Go through the parameters, save them into a
        // properties object.
        // 
        boolean sourceInitialized = false;
        boolean attributeInitialized = false;
        for (PIPResolverParam param : this.enreplacedy.getEnreplacedy().getPipresolverParams()) {
            // 
            // Look for ones we know about
            // 
            if (param.getParamName().equalsIgnoreCase("select")) {
                this.textAreaSelect.setValue(param.getParamValue());
                this.textAreaSelect.setData(param);
            } else if (param.getParamName().equals("fields") || param.getParamName().equals("filter.view")) {
                this.initializeSourceTable(param.getParamValue());
                this.tableRequiredAttributes.setData(param);
                sourceInitialized = true;
            } else if (param.getParamName().equals("parameters") || param.getParamName().equals("filter.parameters")) {
                this.initializeAttributeTable(param.getParamValue());
                this.tableAttributes.setData(param);
                attributeInitialized = true;
            } else if (param.getParamName().equalsIgnoreCase("base")) {
                this.textFieldBase.setValue(param.getParamValue());
                this.textFieldBase.setData(param);
            } else if (param.getParamName().equalsIgnoreCase("filter")) {
                this.textFieldFilter.setValue(param.getParamValue());
                this.textFieldFilter.setData(param);
            }
        }
        // 
        // Initialize GUI
        // 
        this.initializeText();
        this.initializeCheckBox();
        // 
        // Verify the tables get setup, if this is a new object
        // then they haven't been.
        // 
        if (sourceInitialized == false) {
            this.initializeSourceTable("");
        }
        if (attributeInitialized == false) {
            this.initializeAttributeTable("");
        }
    }

    protected void initializeEnreplacedy() {
        // 
        // Make sure the clreplacedname is set correctly
        // 
        if (this.isSQL()) {
            // 
            // 
            // 
            this.fieldPrefix = "field.";
            this.parameterPrefix = "parameter.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableJDBCResolver.clreplaced.getCanonicalName());
        } else if (this.isLDAP()) {
            // 
            // 
            // 
            this.fieldPrefix = "filter.view.";
            this.parameterPrefix = "filter.parameters.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableLDAPResolver.clreplaced.getCanonicalName());
        } else if (this.isCSV()) {
            // 
            // 
            // 
            this.fieldPrefix = "field.";
            this.parameterPrefix = "parameter.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableCSVResolver.clreplaced.getCanonicalName());
        }
    }

    protected void initializeText() {
        // 
        // Are we SQL or LDAP?
        // 
        if (this.isSQL()) {
            // 
            // Turn these off
            // 
            this.textFieldBase.setRequired(false);
            this.textFieldBase.setVisible(false);
            this.textFieldFilter.setRequired(false);
            this.textFieldFilter.setVisible(false);
            // 
            // GUI properties
            // 
            this.textAreaSelect.setImmediate(true);
            // 
            // Respond to changes
            // 
            this.textAreaSelect.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textAreaSelect.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("select");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textAreaSelect.setData(param);
                    }
                    param.setParamValue(self.textAreaSelect.getValue());
                    self.fireFormChangedEvent();
                }
            });
        } else if (this.isLDAP()) {
            // 
            // Turn these off
            // 
            this.textAreaSelect.setRequired(false);
            this.textAreaSelect.setVisible(false);
            // 
            // 
            // 
            this.textFieldBase.setImmediate(true);
            this.textFieldBase.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textFieldBase.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("base");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textFieldBase.setData(param);
                    }
                    param.setParamValue(self.textFieldBase.getValue());
                    self.fireFormChangedEvent();
                }
            });
            // 
            // 
            // 
            this.textFieldFilter.setImmediate(true);
            this.textFieldFilter.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textFieldFilter.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("filter");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textFieldFilter.setData(param);
                    }
                    param.setParamValue(self.textFieldFilter.getValue());
                    self.fireFormChangedEvent();
                }
            });
        } else if (this.isCSV()) {
            // 
            // Turn these off
            // 
            this.textAreaSelect.setRequired(false);
            this.textAreaSelect.setVisible(false);
            this.textFieldBase.setRequired(false);
            this.textFieldBase.setVisible(false);
            this.textFieldFilter.setRequired(false);
            this.textFieldFilter.setVisible(false);
        }
    }

    protected void initializeCheckBox() {
        this.checkBoxShortIds.setValue(true);
        this.checkBoxShortIds.setImmediate(true);
        this.checkBoxShortIds.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (self.checkBoxShortIds.getValue()) {
                    self.tableRequiredAttributes.setColumnCollapsed("id", true);
                    self.tableRequiredAttributes.setColumnCollapsed("category", true);
                    self.tableRequiredAttributes.setColumnCollapsed("datatype", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortId", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortCategory", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", false);
                } else {
                    self.tableRequiredAttributes.setColumnCollapsed("id", false);
                    self.tableRequiredAttributes.setColumnCollapsed("category", false);
                    self.tableRequiredAttributes.setColumnCollapsed("datatype", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortId", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortCategory", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", true);
                }
            }
        });
    }

    protected void initializeSourceTable(String fields) {
        // 
        // Add data into the container
        // 
        this.populateData(this.fieldPrefix, fields, this.fieldsContainer);
        // 
        // Set GUI properties
        // 
        this.tableRequiredAttributes.setContainerDataSource(this.fieldsContainer);
        this.tableRequiredAttributes.setPageLength((this.fieldsContainer.size() == 0 ? 3 : this.fieldsContainer.size() + 1));
        this.tableRequiredAttributes.setSizeFull();
        this.tableRequiredAttributes.setColumnCollapsingAllowed(true);
        this.tableRequiredAttributes.setVisibleColumns(new Object[] { "identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype" });
        this.tableRequiredAttributes.setColumnHeaders(new String[] { "Field", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type" });
        this.tableRequiredAttributes.setColumnCollapsed("id", true);
        this.tableRequiredAttributes.setColumnCollapsed("category", true);
        this.tableRequiredAttributes.setColumnCollapsed("datatype", true);
        this.tableRequiredAttributes.setSelectable(true);
        // 
        // Setup its handler
        // 
        this.tableRequiredAttributes.addActionHandler(this);
        // 
        // Respond to events
        // 
        this.tableRequiredAttributes.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    Object id = event.gereplacedemId();
                    if (id == null) {
                        // 
                        // Really shouldn't get here
                        // 
                        return;
                    }
                    BeanItem<ResolverAttribute> beanItem = self.fieldsContainer.gereplacedem(id);
                    if (beanItem == null) {
                        // 
                        // Again, shouldn't get here
                        // 
                        return;
                    }
                    self.editAttribute(self.tableRequiredAttributes, beanItem.getBean());
                }
            }
        });
    }

    protected void initializeAttributeTable(String parameters) {
        // 
        // Add data into the container
        // 
        this.populateData(this.parameterPrefix, parameters, this.parametersContainer);
        // 
        // setup gui properties
        // 
        this.tableAttributes.setContainerDataSource(this.parametersContainer);
        this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
        this.tableAttributes.setSizeFull();
        this.tableAttributes.setColumnCollapsingAllowed(true);
        this.tableAttributes.setVisibleColumns(new Object[] { "identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype" });
        this.tableAttributes.setColumnHeaders(new String[] { "Position", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type" });
        this.tableAttributes.setColumnCollapsed("id", true);
        this.tableAttributes.setColumnCollapsed("category", true);
        this.tableAttributes.setColumnCollapsed("datatype", true);
        this.tableAttributes.setSelectable(true);
        // 
        // Setup its handler
        // 
        this.tableAttributes.addActionHandler(this);
        // 
        // Respond to events
        // 
        this.tableAttributes.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    Object id = event.gereplacedemId();
                    if (id == null) {
                        // 
                        // Really shouldn't get here
                        // 
                        return;
                    }
                    BeanItem<ResolverAttribute> beanItem = self.parametersContainer.gereplacedem(id);
                    if (beanItem == null) {
                        // 
                        // Again, shouldn't get here
                        // 
                        return;
                    }
                    self.editAttribute(self.tableAttributes, beanItem.getBean());
                }
            }
        });
    }

    protected void populateData(String prefix, String list, BeanItemContainer<ResolverAttribute> container) {
        for (String field : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
            // 
            // Create a bean for this field
            // 
            ResolverAttribute bean = new ResolverAttribute(prefix, field);
            // 
            // Now try to find the attribute information
            // 
            for (PIPResolverParam param : this.enreplacedy.getEnreplacedy().getPipresolverParams()) {
                if (param.getParamName().equals(prefix + field + ".id")) {
                    bean.setId(param);
                } else if (param.getParamName().equals(prefix + field + ".category")) {
                    bean.setCategory(param);
                } else if (param.getParamName().equals(prefix + field + ".datatype")) {
                    bean.setDatatype(param);
                } else if (param.getParamName().equals(prefix + field + ".issuer")) {
                    bean.setIssuer(param);
                } else if (param.getParamName().equals(prefix + field + ".column")) {
                    bean.setColumn(param);
                }
            }
            container.addBean(bean);
        }
    }

    @Override
    public Action[] getActions(Object target, Object sender) {
        if (target == null) {
            return new Action[] { ADD_ATTRIBUTE };
        }
        return new Action[] { EDIT_ATTRIBUTE, CLONE_ATTRIBUTE, REMOVE_ATTRIBUTE };
    }

    @Override
    public void handleAction(Action action, Object sender, Object target) {
        if (action == ADD_ATTRIBUTE) {
            if (sender.equals(this.tableRequiredAttributes)) {
                this.editAttribute(self.tableRequiredAttributes, null);
            } else {
                this.editAttribute(self.tableAttributes, null);
            }
            return;
        }
        if (action == EDIT_ATTRIBUTE) {
            replacedert (target instanceof ResolverAttribute);
            if (sender.equals(this.tableRequiredAttributes)) {
                this.editAttribute(self.tableRequiredAttributes, (ResolverAttribute) target);
            } else {
                this.editAttribute(self.tableAttributes, (ResolverAttribute) target);
            }
            return;
        }
        if (action == CLONE_ATTRIBUTE) {
            replacedert (target instanceof ResolverAttribute);
            try {
                // 
                // Which table?
                // 
                if (sender.equals(this.tableRequiredAttributes)) {
                    // 
                    // Clone the attribute giving it a new
                    // field name.
                    // 
                    ResolverAttribute clone = new ResolverAttribute(this.fieldPrefix, this.getNextField(), (ResolverAttribute) target);
                    // 
                    // Add it to the container
                    // 
                    this.fieldsContainer.addBean(clone);
                    // 
                    // Reset the page length so we can see it and have room
                    // to add another.
                    // 
                    this.tableRequiredAttributes.setPageLength(this.fieldsContainer.size() + 1);
                    // 
                    // Select it
                    // 
                    this.tableRequiredAttributes.select(clone);
                } else {
                    // 
                    // Clone the attribute giving it a new
                    // field name.
                    // 
                    ResolverAttribute clone = new ResolverAttribute(this.parameterPrefix, this.getNextParameter(), (ResolverAttribute) target);
                    // 
                    // Add it to the container
                    // 
                    this.parametersContainer.addBean(clone);
                    // 
                    // Reset the page length so we can see it and have room
                    // to add another.
                    // 
                    this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
                    // 
                    // Select it
                    // 
                    this.tableAttributes.select(clone);
                }
                // 
                // We have changed
                // 
                this.fireFormChangedEvent();
            } catch (Exception e) {
                logger.error("Failed to clone: " + e);
            }
            return;
        }
        if (action == REMOVE_ATTRIBUTE) {
            replacedert (target instanceof ResolverAttribute);
            // 
            // Help method to remove the attribute
            // 
            this.removeAttribute((ResolverAttribute) target);
            // 
            // Which table?
            // 
            if (sender.equals(this.tableRequiredAttributes)) {
                // 
                // Now remove it from the table
                // 
                this.tableRequiredAttributes.removeItem(target);
            } else {
                // 
                // Now remove it from the table
                // 
                this.tableAttributes.removeItem(target);
            }
            // 
            // we have changed
            // 
            this.fireFormChangedEvent();
            return;
        }
    }

    protected void removeAttribute(ResolverAttribute target) {
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getIdParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getCategoryParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getDatatypeParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getIssuerParam());
    }

    protected void editAttribute(final Table table, final ResolverAttribute request) {
        if (this.isCSV()) {
            this.editCSVAttribute(table, request);
        } else {
            this.editResolverAttribute(table, request, null);
        }
    }

    protected void editCSVAttribute(final Table table, final ResolverAttribute request) {
        replacedert (this.isCSV());
        // 
        // Prompt for the column
        // 
        final ColumnSelectionWindow window = new ColumnSelectionWindow((request != null ? request.getColumn() : 0));
        if (request == null) {
            window.setCaption("Input the CSV Column for the new attribute");
        } else {
            window.setCaption("Edit the CSV Column for the attribute");
        }
        window.setModal(true);
        window.center();
        window.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                // 
                // Did the user save?
                // 
                if (window.isSaved() == false) {
                    return;
                }
                // 
                // Save it if its not a new
                // 
                if (request != null) {
                    request.setColumn(window.getColumn());
                }
                // 
                // Now we select the attribute, preplaced the column
                // in case this is a brand new attribute. Yeah its messy.
                // 
                self.editResolverAttribute(table, request, window.getColumn());
            }
        });
        window.center();
        UI.getCurrent().addWindow(window);
    }

    protected void editResolverAttribute(final Table table, final ResolverAttribute request, final Integer column) {
        // 
        // Provide objects to the attribute selection window
        // 
        AttributeDesignatorType designator = new AttributeDesignatorType();
        if (request == null) {
            designator.setAttributeId(XACML3.ID_SUBJECT_SUBJECT_ID.stringValue());
            designator.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue());
            designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
            designator.setIssuer(this.enreplacedy.getEnreplacedy().getIssuer());
        } else {
            designator.setAttributeId(request.getId());
            designator.setCategory(request.getCategory());
            designator.setDataType(request.getDatatype());
            designator.setIssuer(request.getIssuer());
        }
        // 
        // Have user select an attribute
        // 
        final AttributeSelectionWindow selection = new AttributeSelectionWindow(null, designator);
        selection.setModal(true);
        selection.setCaption("Select Attribute");
        selection.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent event) {
                // 
                // User click Save button?
                // 
                if (selection.isSaved() == false) {
                    return;
                }
                // 
                // Yes - get the final attribute
                // 
                Attribute attribute = selection.getAttribute();
                // 
                // Is it a new one?
                // 
                if (request == null) {
                    try {
                        // 
                        // Create a new bean
                        // 
                        ResolverAttribute bean = null;
                        if (table.equals(self.tableRequiredAttributes)) {
                            bean = new ResolverAttribute(self.fieldPrefix, self.getNextField());
                        } else {
                            bean = new ResolverAttribute(self.parameterPrefix, self.getNextParameter());
                        }
                        bean.setId(attribute.getXacmlId());
                        bean.setCategory(attribute.getCategoryBean().getXacmlId());
                        bean.setDatatype(attribute.getDatatypeBean().getXacmlId());
                        if (attribute.getIssuer() != null) {
                            bean.setIssuer(attribute.getIssuer());
                        }
                        if (column != null) {
                            bean.setColumn(column);
                        }
                        // 
                        // Add it to the resolver
                        // 
                        bean.setResolver(self.enreplacedy.getEnreplacedy());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getIdParam());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getCategoryParam());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getDatatypeParam());
                        if (bean.getIssuer() != null) {
                            self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getIssuerParam());
                        }
                        // 
                        // Which table?
                        // 
                        if (table.equals(self.tableRequiredAttributes)) {
                            // 
                            // Add to table
                            // 
                            self.fieldsContainer.addBean(bean);
                            // 
                            // Reset the page length
                            // 
                            self.tableRequiredAttributes.setPageLength(self.fieldsContainer.size() + 1);
                        } else if (table.equals(self.tableAttributes)) {
                            // 
                            // Add to table
                            // 
                            self.parametersContainer.addBean(bean);
                            // 
                            // Reset the page length
                            // 
                            self.tableAttributes.setPageLength(self.parametersContainer.size() + 1);
                        }
                        if (logger.isDebugEnabled()) {
                            logger.debug("Added new attribute: " + bean);
                        }
                    } catch (Exception e) {
                        logger.error(e);
                        AdminNotification.error("Unable to add another required attribute field");
                    }
                } else {
                    // 
                    // Update the table entry
                    // 
                    request.setId(attribute.getXacmlId());
                    request.setCategory(attribute.getCategoryBean().getXacmlId());
                    request.setDatatype(attribute.getDatatypeBean().getXacmlId());
                    request.setIssuer(attribute.getIssuer());
                    // 
                    // Let the table know
                    // 
                    table.refreshRowCache();
                }
                // 
                // we have changed
                // 
                self.fireFormChangedEvent();
            }
        });
        selection.center();
        UI.getCurrent().addWindow(selection);
    }

    protected String getNextField() throws Exception {
        // 
        // Start at the next index number. NOTE: The GUI needs
        // to use numbers to index the fields.
        // 
        int index = this.tableRequiredAttributes.size() + 1;
        // 
        // Really if we get to 100, that's an insane number of fields
        // needed for a SQL query.
        // 
        while (index < 100) {
            String field = String.format("%02d", index);
            boolean exists = false;
            for (Object id : this.tableRequiredAttributes.gereplacedemIds()) {
                @SuppressWarnings("unchecked")
                BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableRequiredAttributes.gereplacedem(id);
                if (required.getBean().getIdentifier().equals(field)) {
                    exists = true;
                    index++;
                    break;
                }
            }
            if (exists == false) {
                return field;
            }
        }
        // 
        // Sanity check
        // 
        throw new Exception("Unable to find a next field name. Are there too many fields?");
    }

    protected String getNextParameter() throws Exception {
        // 
        // Start at the next index number. NOTE: The GUI needs
        // to use numbers to index the fields.
        // 
        int index = this.tableAttributes.size() + 1;
        // 
        // Really if we get to 100, that's an insane number of fields
        // needed for a SQL query.
        // 
        while (index < 100) {
            String field = String.format("%02d", index);
            boolean exists = false;
            for (Object id : this.tableAttributes.gereplacedemIds()) {
                @SuppressWarnings("unchecked")
                BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableAttributes.gereplacedem(id);
                if (required.getBean().getIdentifier().equals(field)) {
                    exists = true;
                    index++;
                    break;
                }
            }
            if (exists == false) {
                return field;
            }
        }
        // 
        // Sanity check
        // 
        throw new Exception("Unable to find a next parameter name. Are there too many parameters?");
    }

    public void discard() throws SourceException {
        if (this.isSQL()) {
            this.textAreaSelect.discard();
        } else if (this.isLDAP()) {
            this.textFieldBase.discard();
            this.textFieldFilter.discard();
        } else if (this.isCSV()) {
        }
    }

    public void validate() throws InvalidValueException {
        if (this.isSQL()) {
            this.textAreaSelect.validate();
        } else if (this.isLDAP()) {
            this.textFieldBase.validate();
            this.textFieldFilter.validate();
        } else if (this.isCSV()) {
        }
    }

    public void commit() throws SourceException, InvalidValueException {
        // 
        // Commit required fields
        // 
        if (this.isSQL()) {
            this.textAreaSelect.commit();
        } else if (this.isLDAP()) {
            this.textFieldBase.commit();
            this.textFieldFilter.commit();
        } else if (this.isCSV()) {
        }
        // 
        // Setup the fields
        // 
        {
            List<String> fields = new ArrayList<String>(this.fieldsContainer.size());
            for (ResolverAttribute attribute : this.fieldsContainer.gereplacedemIds()) {
                fields.add(attribute.getIdentifier());
            }
            PIPResolverParam param = (PIPResolverParam) this.tableRequiredAttributes.getData();
            if (param == null) {
                param = new PIPResolverParam();
                if (this.isSQL()) {
                    param.setParamName("fields");
                } else if (this.isLDAP()) {
                    param.setParamName("filter.view");
                } else if (this.isCSV()) {
                    param.setParamName("fields");
                }
                this.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                this.tableRequiredAttributes.setData(param);
            }
            param.setParamValue(Joiner.on(',').join(fields));
        }
        // 
        // Setup the parameters
        // 
        {
            List<String> parameters = new ArrayList<String>(this.parametersContainer.size());
            for (ResolverAttribute attribute : this.parametersContainer.gereplacedemIds()) {
                parameters.add(attribute.getIdentifier());
            }
            PIPResolverParam param = (PIPResolverParam) this.tableAttributes.getData();
            if (param == null) {
                param = new PIPResolverParam();
                if (this.isSQL()) {
                    param.setParamName("parameters");
                } else if (this.isLDAP()) {
                    param.setParamName("filter.parameters");
                } else if (this.isCSV()) {
                    param.setParamName("parameters");
                }
                this.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                this.tableAttributes.setData(param);
            }
            param.setParamValue(Joiner.on(',').join(parameters));
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    @Override
    public boolean addListener(FormChangedEventListener listener) {
        return this.notifier.addListener(listener);
    }

    @Override
    public boolean removeListener(FormChangedEventListener listener) {
        return this.notifier.removeListener(listener);
    }

    @Override
    public void fireFormChangedEvent() {
        this.notifier.fireFormChangedEvent();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaSelect
        textAreaSelect = new TextArea();
        textAreaSelect.setCaption("SQL Select Statement");
        textAreaSelect.setImmediate(false);
        textAreaSelect.setWidth("100.0%");
        textAreaSelect.setHeight("-1px");
        textAreaSelect.setInvalidAllowed(false);
        textAreaSelect.setRequired(true);
        mainLayout.addComponent(textAreaSelect);
        mainLayout.setExpandRatio(textAreaSelect, 1.0f);
        // textFieldBase
        textFieldBase = new TextField();
        textFieldBase.setCaption("Base DN");
        textFieldBase.setImmediate(false);
        textFieldBase.setWidth("-1px");
        textFieldBase.setHeight("-1px");
        mainLayout.addComponent(textFieldBase);
        // textFieldFilter
        textFieldFilter = new TextField();
        textFieldFilter.setCaption("Filter");
        textFieldFilter.setImmediate(false);
        textFieldFilter.setWidth("-1px");
        textFieldFilter.setHeight("-1px");
        mainLayout.addComponent(textFieldFilter);
        // checkBoxShortIds
        checkBoxShortIds = new CheckBox();
        checkBoxShortIds.setCaption("Display short id’s.");
        checkBoxShortIds.setImmediate(false);
        checkBoxShortIds.setWidth("-1px");
        checkBoxShortIds.setHeight("-1px");
        mainLayout.addComponent(checkBoxShortIds);
        // tableRequiredAttributes
        tableRequiredAttributes = new Table();
        tableRequiredAttributes.setCaption("Attributes Returned");
        tableRequiredAttributes.setImmediate(false);
        tableRequiredAttributes.setWidth("-1px");
        tableRequiredAttributes.setHeight("-1px");
        mainLayout.addComponent(tableRequiredAttributes);
        // tableAttributes
        tableAttributes = new Table();
        tableAttributes.setCaption("Parameters - Attributes Needed (i.e. ?)");
        tableAttributes.setImmediate(false);
        tableAttributes.setWidth("-1px");
        tableAttributes.setHeight("-1px");
        tableAttributes.setInvalidAllowed(false);
        tableAttributes.setRequired(true);
        mainLayout.addComponent(tableAttributes);
        return mainLayout;
    }
}

19 View Complete Implementation : TargetBulkUpdateWindowLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
private TextArea getDescriptionTextArea() {
    final TextArea description = new TextAreaBuilder(Target.DESCRIPTION_MAX_SIZE).caption(i18n.getMessage("textfield.description")).style("text-area-style").id(UIComponentIdProvider.BULK_UPLOAD_DESC).buildTextComponent();
    description.setWidth("100%");
    return description;
}

19 View Complete Implementation : RuleEditorWindow.java
Copyright MIT License
Author : att
public clreplaced RuleEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private OptionGroup optionGroupEffect;

    @AutoGenerated
    private Label labelRuleID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final RuleEditorWindow self = this;

    private final RuleType rule;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param rule
     */
    public RuleEditorWindow(RuleType rule) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.rule = rule;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize
        // 
        this.initializeLabel();
        this.initializeOption();
        this.initializeText();
        this.initializeButton();
    }

    protected void initializeLabel() {
        if (this.rule.getRuleId() == null) {
            this.rule.setRuleId(((XacmlAdminUI) UI.getCurrent()).newRuleID());
        }
        this.labelRuleID.setValue(this.rule.getRuleId());
    }

    protected void initializeOption() {
        this.optionGroupEffect.setRequiredError("You MUST select an effect (Permit or Deny for the rule.");
        this.optionGroupEffect.addItem("Permit");
        this.optionGroupEffect.addItem("Deny");
        if (this.rule.getEffect() == null) {
            this.rule.setEffect(EffectType.PERMIT);
        }
        if (this.rule.getEffect() == EffectType.PERMIT) {
            this.optionGroupEffect.setValue("Permit");
        } else {
            this.optionGroupEffect.setValue("Deny");
        }
    }

    protected void initializeText() {
        this.textAreaDescription.setValue(this.rule.getDescription());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.optionGroupEffect.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    if (self.optionGroupEffect.getValue() == "Permit") {
                        self.rule.setEffect(EffectType.PERMIT);
                    } else {
                        self.rule.setEffect(EffectType.DENY);
                    }
                    self.rule.setDescription(self.textAreaDescription.getValue());
                    // 
                    // Set ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public RuleType getRule() {
        return this.rule;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelRuleID
        labelRuleID = new Label();
        labelRuleID.setCaption("Rule ID");
        labelRuleID.setImmediate(false);
        labelRuleID.setWidth("100.0%");
        labelRuleID.setHeight("-1px");
        labelRuleID.setValue("Label");
        mainLayout.addComponent(labelRuleID);
        mainLayout.setExpandRatio(labelRuleID, 1.0f);
        // optionGroupEffect
        optionGroupEffect = new OptionGroup();
        optionGroupEffect.setCaption("Choose the effect.");
        optionGroupEffect.setImmediate(false);
        optionGroupEffect.setWidth("-1px");
        optionGroupEffect.setHeight("-1px");
        optionGroupEffect.setInvalidAllowed(false);
        optionGroupEffect.setRequired(true);
        mainLayout.addComponent(optionGroupEffect);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Enter a description for the Rule.");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        textAreaDescription.setNullSettingAllowed(true);
        textAreaDescription.setNullRepresentation("");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : EditPDPWindow.java
Copyright MIT License
Author : att
public clreplaced EditPDPWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textDescription;

    @AutoGenerated
    private TextField textName;

    @AutoGenerated
    private TextField textId;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final EditPDPWindow self = this;

    private final PDP pdp;

    private final List<PDPGroup> groups;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param pdp
     * @param list
     */
    public EditPDPWindow(PDP pdp, List<PDPGroup> list) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save data
        // 
        this.pdp = pdp;
        this.groups = list;
        // 
        // Initialize
        // 
        this.initializeText();
        this.initializeButton();
        // 
        // Keyboard short
        // 
        this.setCloseShortcut(KeyCode.ESC);
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        // 
        // Focus
        // 
        this.textId.focus();
    }

    protected void initializeText() {
        // 
        // Initialize values
        // 
        if (this.pdp != null) {
            this.textId.setValue(this.pdp.getId());
            this.textName.setValue(this.pdp.getName());
            this.textDescription.setValue(this.pdp.getDescription());
        }
        // 
        // 
        // 
        this.textId.setRequiredError("You must enter a valid id for the PDP.");
        this.textId.setNullRepresentation("");
        this.textId.addValidator(new RegexpValidator("[\\w=,]", false, "Please enter a valid URL with no whitespace or \"=\" or \",\" characters."));
        this.textId.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                // 
                // Cannot be null
                // 
                if (value == null || value.toString().length() == 0) {
                    throw new InvalidValueException("ID cannot be null.");
                }
                // 
                // Make sure its a valid URL
                // 
                try {
                    new URL(value.toString());
                } catch (MalformedURLException e) {
                    throw new InvalidValueException("The PDP URL '" + value.toString() + "' is not a valid URL: '" + e.getMessage() + "'");
                }
            }
        });
        // 
        // 
        // 
        this.textName.setNullRepresentation("");
        this.textName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                // 
                // If the value is null, set it to the id
                // 
                if (value == null || value.toString().length() == 0) {
                    return;
                }
            }
        });
        // 
        // 
        // 
        this.textDescription.setNullRepresentation("");
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Do a commit
                    // 
                    self.textName.commit();
                    self.textId.commit();
                    self.textDescription.commit();
                    // 
                    // Should be a string, but to be safe
                    // 
                    String id = self.textId.getValue();
                    String name = self.textName.getValue();
                    if (name == null || name.isEmpty()) {
                        self.textName.setValue(id);
                        name = id;
                    }
                    // 
                    // ID must be unique.
                    // Also the Name must be unique AND not match any existing IDs
                    // because user uses the NAME to identify this PDP on the browser window, not the ID.
                    // 
                    for (PDPGroup g : self.groups) {
                        for (PDP p : g.getPdps()) {
                            if (p.getId().equals(id)) {
                                if (self.pdp != null) {
                                    // 
                                    // we are editing this pdp
                                    // 
                                    continue;
                                }
                                throw new InvalidValueException("URL must be unique - the PDP '" + id + "' already exists in group '" + g.getName() + "'");
                            }
                            if (id.equals(p.getName())) {
                                throw new InvalidValueException("A previous PDP with URL '" + p.getId() + "' has been given the name '" + id + "'.  Please edit that PDP to change the name before creating a nwe PDP with this URL.");
                            }
                            if (name != null && name.length() > 0 && self.pdp == null) {
                                if (p.getId().equals(name) || name.equals(p.getName())) {
                                    throw new InvalidValueException("Name must not be the same as another PDP's name OR another PDP's URL.");
                                }
                            }
                        }
                    }
                    // 
                    // make sure name is NOT a URL, unless it is identical to the ID.
                    // (If it is a URL, then a later PDP might be created with that URL as it's ID, which would be confusing.)
                    // 
                    if (!id.equals(name)) {
                        try {
                            new URL(name);
                            // if we get here the name is a URL but not identical to the id, which is not good
                            AdminNotification.warn("The Name must not be a URL unless it is the same as the PDP URL");
                            return;
                        } catch (Exception e) {
                        // ignore - we want to get here
                        }
                    }
                    // 
                    // If we get here the inputs are ok
                    // 
                    self.isSaved = true;
                    // 
                    // 
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e1) {
                // 
                // Vaadin will display error
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getPDPId() {
        return this.textId.getValue();
    }

    public String getPDPName() {
        return this.textName.getValue();
    }

    public String getPDPDescription() {
        return this.textDescription.getValue();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textId
        textId = new TextField();
        textId.setCaption("PDP URL");
        textId.setImmediate(false);
        textId.setDescription("The URL is the ID of the PDP");
        textId.setWidth("-1px");
        textId.setHeight("-1px");
        textId.setRequired(true);
        textId.setInputPrompt("Eg. http://localhost:8080/pdp");
        mainLayout.addComponent(textId);
        // textName
        textName = new TextField();
        textName.setCaption("PDP Name");
        textName.setImmediate(false);
        textName.setWidth("-1px");
        textName.setHeight("-1px");
        mainLayout.addComponent(textName);
        // textDescription
        textDescription = new TextArea();
        textDescription.setCaption("PDP Description");
        textDescription.setImmediate(false);
        textDescription.setWidth("100.0%");
        textDescription.setHeight("-1px");
        textDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textDescription);
        mainLayout.setExpandRatio(textDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : ImportPanel.java
Copyright Apache License 2.0
Author : korpling
/**
 * @author Thomas Krause {@literal <[email protected]>}
 */
public clreplaced ImportPanel extends Panel implements Upload.ProgressListener, Upload.FinishedListener, Upload.StartedListener, Upload.Receiver, LoginListener {

    public static clreplaced ImportRequest {

        String email;

        /**
         * @return the email
         */
        public String getEmail() {
            return email;
        }

        /**
         * @param email
         *                the email to set
         */
        public void setEmail(String email) {
            this.email = email;
        }
    }

    private static final Logger log = LoggerFactory.getLogger(ImportPanel.clreplaced);

    private final VerticalLayout layout;

    private final TextArea txtMessages;

    private final Upload upload;

    private final TextField txtMail;

    private final CheckBox cbOverwrite;

    private final TextField txtAlias;

    private final ProgressBar progress;

    private final Label lblProgress;

    private final Button btDetailedLog;

    private File temporaryCorpusFile;

    private boolean kickstarterMode;

    private final ImportRequest importRequest = new ImportRequest();

    private Binder<ImportRequest> requestBinder = new Binder<>();

    public ImportPanel() {
        setSizeFull();
        layout = new VerticalLayout();
        layout.setWidth("100%");
        layout.setHeight("100%");
        layout.setMargin(true);
        setContent(layout);
        FormLayout form = new FormLayout();
        layout.addComponent(form);
        cbOverwrite = new CheckBox("Overwrite existing corpus");
        form.addComponent(cbOverwrite);
        txtMail = new TextField("e-mail address for status updates");
        requestBinder.forField(txtMail).withValidator(new EmailValidator("Must be a valid e-mail address")).bind(ImportRequest::getEmail, ImportRequest::setEmail);
        requestBinder.setBean(importRequest);
        form.addComponent(txtMail);
        txtAlias = new TextField("alias name");
        form.addComponent(txtAlias);
        HorizontalLayout actionBar = new HorizontalLayout();
        actionBar.setSpacing(true);
        actionBar.setWidth("100%");
        upload = new Upload("", this);
        upload.setButtonCaption("Upload ZIP file with relANNIS corpus and start import");
        upload.addStartedListener(this);
        upload.addFinishedListener(this);
        upload.setEnabled(true);
        actionBar.addComponent(upload);
        progress = new ProgressBar();
        progress.setIndeterminate(true);
        progress.setVisible(false);
        actionBar.addComponent(progress);
        lblProgress = new Label();
        lblProgress.setWidth("100%");
        actionBar.addComponent(lblProgress);
        actionBar.setExpandRatio(lblProgress, 1.0f);
        actionBar.setComponentAlignment(lblProgress, Alignment.MIDDLE_LEFT);
        actionBar.setComponentAlignment(upload, Alignment.MIDDLE_LEFT);
        actionBar.setComponentAlignment(progress, Alignment.MIDDLE_LEFT);
        layout.addComponent(actionBar);
        btDetailedLog = new Button();
        btDetailedLog.setStyleName(BaseTheme.BUTTON_LINK);
        btDetailedLog.addClickListener(new Button.ClickListener() {

            @Override
            public void buttonClick(Button.ClickEvent event) {
                setLogVisible(!isLogVisible());
            }
        });
        layout.addComponent(btDetailedLog);
        txtMessages = new TextArea();
        txtMessages.setSizeFull();
        txtMessages.setValue("");
        txtMessages.setReadOnly(true);
        layout.addComponent(txtMessages);
        layout.setExpandRatio(txtMessages, 1.0f);
        setLogVisible(false);
        appendMessage("Ready.");
    }

    private boolean isLogVisible() {
        return txtMessages.isVisible();
    }

    private void setLogVisible(boolean visible) {
        txtMessages.setVisible(visible);
        if (visible) {
            btDetailedLog.setCaption("Hide log");
            btDetailedLog.setIcon(VaadinIcons.MINUS_SQUARE_LEFT_O, "minus sign");
            layout.setExpandRatio(btDetailedLog, 0.0f);
        } else {
            btDetailedLog.setCaption("Show log");
            btDetailedLog.setIcon(VaadinIcons.PLUS_SQUARE_LEFT_O, "plus sign");
            layout.setExpandRatio(btDetailedLog, 1.0f);
        }
    }

    private void appendMessage(String message) {
        lblProgress.setValue(message);
        txtMessages.setReadOnly(false);
        String oldVal = txtMessages.getValue();
        if (oldVal == null || oldVal.isEmpty()) {
            txtMessages.setValue(message);
        } else {
            txtMessages.setValue(oldVal + "\n" + message);
        }
        txtMessages.setCursorPosition(txtMessages.getValue().length() - 1);
        txtMessages.setReadOnly(true);
    }

    @Override
    public void updateProgress(long readBytes, long contentLength) {
        float ratioComplete = (float) readBytes / (float) contentLength;
        DecimalFormat format = new DecimalFormat("#0.00");
        appendMessage("uploaded " + format.format(ratioComplete * 100.0f) + "%");
    }

    @Override
    public void uploadFinished(Upload.FinishedEvent event) {
        appendMessage("Finished upload, starting import");
        startImport();
    }

    @Override
    public void uploadStarted(Upload.StartedEvent event) {
        upload.setEnabled(false);
        progress.setVisible(true);
        progress.setEnabled(true);
        appendMessage("Started upload");
        event.getUpload().addProgressListener(this);
    }

    @Override
    public OutputStream receiveUpload(String filename, String mimeType) {
        try {
            temporaryCorpusFile = File.createTempFile(filename, ".zip");
            temporaryCorpusFile.deleteOnExit();
            return new FileOutputStream(temporaryCorpusFile);
        } catch (IOException ex) {
            log.error(null, ex);
        }
        return null;
    }

    private void startImport() {
        WebResource res = Helper.getAnnisWebResource(UI.getCurrent()).path("admin").path("import");
        String mail = txtMail.getValue();
        if (requestBinder.isValid() && mail != null && !mail.isEmpty()) {
            res = res.queryParam("statusMail", mail);
        }
        if (cbOverwrite.getValue() == true) {
            res = res.queryParam("overwrite", "true");
        }
        String alias = txtAlias.getValue();
        if (alias != null && !alias.isEmpty()) {
            res = res.queryParam("alias", alias);
        }
        try (FileInputStream tmpFileStream = new FileInputStream(temporaryCorpusFile)) {
            ClientResponse response = res.enreplacedy(tmpFileStream).type("application/zip").post(ClientResponse.clreplaced);
            if (response.getStatus() == Response.Status.ACCEPTED.getStatusCode()) {
                URI location = response.getLocation();
                appendMessage("Import requested, update URL is " + location);
                UI ui = UI.getCurrent();
                Background.run(new WaitForFinishRunner(location, ui));
            } else {
                upload.setEnabled(true);
                progress.setVisible(false);
                appendMessage("Error (response code " + response.getStatus() + "): " + response.getEnreplacedy(String.clreplaced));
            }
        } catch (IOException ex) {
            log.error(null, ex);
        }
    }

    private clreplaced WaitForFinishRunner implements Runnable {

        private final UI ui;

        private final String uuid;

        private int currentMessageIndex = 0;

        public WaitForFinishRunner(URI location, UI ui) {
            this.ui = ui;
            List<String> path = Splitter.on('/').trimResults().omitEmptyStrings().splitToList(location.getPath());
            uuid = path.get(path.size() - 1);
        }

        @Override
        public void run() {
            // check the overall status
            WebResource res = Helper.getAnnisWebResource(ui).path("admin").path("import").path("status");
            ImportJob.Status lastStatus = ImportJob.Status.WAITING;
            try {
                while (lastStatus == ImportJob.Status.WAITING || lastStatus == ImportJob.Status.RUNNING) {
                    lastStatus = ImportJob.Status.ERROR;
                    List<ImportJob> jobs = res.get(new GenericType<List<ImportJob>>() {
                    });
                    for (ImportJob j : jobs) {
                        if (uuid.equals(j.getUuid())) {
                            lastStatus = j.getStatus();
                            if (lastStatus == ImportJob.Status.WAITING) {
                                appendFromBackground("Still waiting for other imports to finish...");
                            } else if (lastStatus == ImportJob.Status.RUNNING) {
                                outputNewMessages(j.getMessages());
                            }
                            break;
                        }
                    }
                    Thread.sleep(500);
                }
            } catch (InterruptedException ex) {
                log.error(null, ex);
            }
            ImportJob finishInfo = res.path("finished").path(uuid).get(ImportJob.clreplaced);
            // print all remaining messages
            outputNewMessages(finishInfo.getMessages());
            if (finishInfo.getStatus() == ImportJob.Status.SUCCESS) {
                appendFromBackground("Finished successfully.");
            } else if (finishInfo.getStatus() == ImportJob.Status.ERROR) {
                appendFromBackground("Failed.");
            } else {
                appendFromBackground("Unknown status.");
            }
            ui.access(new Runnable() {

                @Override
                public void run() {
                    progress.setVisible(false);
                    upload.setEnabled(true);
                }
            });
        }

        private void outputNewMessages(List<String> allMessages) {
            if (currentMessageIndex < allMessages.size()) {
                final List<String> newMessages = allMessages.subList(currentMessageIndex, allMessages.size());
                currentMessageIndex = allMessages.size();
                appendFromBackground(newMessages);
            }
        }

        private void appendFromBackground(final String message) {
            ui.access(new Runnable() {

                @Override
                public void run() {
                    appendMessage(message);
                }
            });
        }

        private void appendFromBackground(List<String> message) {
            for (String m : message) {
                appendFromBackground(m);
            }
        }
    }

    @Override
    public void onLogin() {
        if (!kickstarterMode) {
            upload.setEnabled(true);
        }
    }

    @Override
    public void onLogout() {
        if (!kickstarterMode) {
            upload.setEnabled(false);
        }
    }

    public void updateMode(boolean kickstarterMode, boolean isLoggedIn) {
        this.kickstarterMode = kickstarterMode;
        if (kickstarterMode) {
            upload.setEnabled(true);
        } else {
            upload.setEnabled(isLoggedIn);
        }
    }
}

19 View Complete Implementation : PolicyNameEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced PolicyNameEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(PolicyNameEditorWindow.clreplaced);

    private final PolicyNameEditorWindow self = this;

    private Object data = null;

    private String filename = null;

    private boolean isSaved = false;

    @AutoGenerated
    private FormLayout mainLayout;

    @AutoGenerated
    private ComboBox comboAlgorithms;

    @AutoGenerated
    private OptionGroup optionPolicySet;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private TextField textFieldPolicyName;

    @AutoGenerated
    private Button buttonSave;

    JPAContainer<PolicyAlgorithms> policyAlgorithms;

    JPAContainer<RuleAlgorithms> ruleAlgorithms;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public PolicyNameEditorWindow(String filename, Object policyData, JPAContainer<PolicyAlgorithms> policyAlgs, JPAContainer<RuleAlgorithms> ruleAlgs) {
        buildMainLayout();
        setContent(mainLayout);
        this.mainLayout.setMargin(true);
        this.filename = filename;
        this.data = policyData;
        this.policyAlgorithms = policyAlgs;
        this.ruleAlgorithms = ruleAlgs;
        this.optionPolicySet.addItem("Policy Set");
        this.optionPolicySet.addItem("Policy");
        this.comboAlgorithms.setNewItemsAllowed(false);
        this.comboAlgorithms.setNullSelectionAllowed(false);
        this.comboAlgorithms.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.comboAlgorithms.sereplacedemCaptionPropertyId("xacmlId");
        // 
        // Setup the policy filename
        // 
        this.textFieldPolicyName.setImmediate(true);
        this.textFieldPolicyName.setNullRepresentation("");
        if (filename != null) {
            this.textFieldPolicyName.setValue(filename);
        }
        this.textFieldPolicyName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (value instanceof String) {
                    String filename = (String) value;
                    if (filename.endsWith(".xml")) {
                        filename = filename.substring(0, filename.length() - 4);
                    }
                    if (filename.length() == 0) {
                        throw new InvalidValueException("Invalid filename.");
                    }
                    if (filename.indexOf('.') != -1) {
                        throw new InvalidValueException("Please do not use a \'.\' in the filename.");
                    }
                }
            }
        });
        this.textFieldPolicyName.setValidationVisible(true);
        // 
        // Are we editing or creating?
        // 
        if (this.data != null) {
            // 
            // We are editing
            // 
            if (this.data instanceof PolicySetType) {
                this.optionPolicySet.setValue("Policy Set");
                this.optionPolicySet.setVisible(false);
                this.textAreaDescription.setValue(((PolicySetType) this.data).getDescription());
                this.comboAlgorithms.setContainerDataSource(policyAlgs);
                for (Object object : this.policyAlgorithms.gereplacedemIds()) {
                    PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                    if (a.getXacmlId().equals(((PolicySetType) this.data).getPolicyCombiningAlgId())) {
                        this.comboAlgorithms.select(object);
                        break;
                    }
                }
            }
            if (this.data instanceof PolicyType) {
                this.optionPolicySet.setValue("Policy");
                this.optionPolicySet.setVisible(false);
                this.textAreaDescription.setValue(((PolicyType) this.data).getDescription());
                this.comboAlgorithms.setContainerDataSource(ruleAlgs);
                for (Object object : this.ruleAlgorithms.gereplacedemIds()) {
                    RuleAlgorithms a = (RuleAlgorithms) this.ruleAlgorithms.gereplacedem(object).getEnreplacedy();
                    if (a.getXacmlId().equals(((PolicyType) this.data).getRuleCombiningAlgId())) {
                        this.comboAlgorithms.select(object);
                        break;
                    }
                }
            }
        } else {
            // 
            // Creating a new policy
            // 
            this.optionPolicySet.setValue("Policy Set");
            this.comboAlgorithms.setContainerDataSource(policyAlgs);
            this.comboAlgorithms.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
            this.comboAlgorithms.sereplacedemCaptionPropertyId("xacmlId");
            for (Object object : this.policyAlgorithms.gereplacedemIds()) {
                PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
                    this.comboAlgorithms.select(object);
                    break;
                }
            }
            this.optionPolicySet.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
                        self.comboAlgorithms.setContainerDataSource(self.policyAlgorithms);
                        for (Object object : self.policyAlgorithms.gereplacedemIds()) {
                            PolicyAlgorithms a = (PolicyAlgorithms) self.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                            if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
                                self.comboAlgorithms.select(object);
                                break;
                            }
                        }
                    } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
                        self.comboAlgorithms.setContainerDataSource(self.ruleAlgorithms);
                        for (Object object : self.ruleAlgorithms.gereplacedemIds()) {
                            RuleAlgorithms a = (RuleAlgorithms) self.ruleAlgorithms.gereplacedem(object).getEnreplacedy();
                            if (a.getXacmlId().equals(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue())) {
                                self.comboAlgorithms.select(object);
                                break;
                            }
                        }
                    }
                }
            });
        }
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                // 
                // Make sure the policy filename was valid
                // 
                if (self.textFieldPolicyName.isValid() == false) {
                    return;
                }
                // 
                // Grab the filename (NOTE: The user may or may not
                // have changed the name).
                // 
                self.filename = self.textFieldPolicyName.getValue();
                // 
                // Make sure the filename ends with an extension
                // 
                if (self.filename.endsWith(".xml") == false) {
                    self.filename = self.filename + ".xml";
                }
                // 
                // Set ourselves as saved
                // 
                self.isSaved = true;
                // 
                // Now grab the policy file's data
                // 
                if (self.data == null) {
                    // 
                    // This is a brand new Policy
                    // 
                    if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
                        PolicySetType policySet = new PolicySetType();
                        policySet.setVersion("1");
                        policySet.setPolicySetId(((XacmlAdminUI) getUI()).newPolicyID());
                        policySet.setTarget(new TargetType());
                        self.data = policySet;
                    } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
                        PolicyType policy = new PolicyType();
                        policy.setVersion("1");
                        policy.setPolicyId(((XacmlAdminUI) getUI()).newPolicyID());
                        policy.setTarget(new TargetType());
                        self.data = policy;
                    } else {
                        logger.error("Policy option NOT setup correctly.");
                    }
                }
                if (self.data != null) {
                    // 
                    // Save off everything
                    // 
                    if (self.data instanceof PolicySetType) {
                        ((PolicySetType) self.data).setDescription(self.textAreaDescription.getValue());
                        Object a = self.comboAlgorithms.getValue();
                        PolicyAlgorithms alg = (PolicyAlgorithms) ((JPAContainerItem<?>) self.comboAlgorithms.gereplacedem(a)).getEnreplacedy();
                        ((PolicySetType) self.data).setPolicyCombiningAlgId(alg.getXacmlId());
                    } else if (self.data instanceof PolicyType) {
                        ((PolicyType) self.data).setDescription(self.textAreaDescription.getValue());
                        Object a = self.comboAlgorithms.getValue();
                        RuleAlgorithms alg = (RuleAlgorithms) ((JPAContainerItem<?>) self.comboAlgorithms.gereplacedem(a)).getEnreplacedy();
                        ((PolicyType) self.data).setRuleCombiningAlgId(alg.getXacmlId());
                    } else {
                        logger.error("Unsupported data object." + self.data.getClreplaced().getCanonicalName());
                    }
                }
                // 
                // Now we can close the window
                // 
                self.close();
            }
        });
        this.textFieldPolicyName.focus();
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public Object getPolicyData() {
        if (this.isSaved) {
            return this.data;
        }
        return null;
    }

    public String getPolicyFilename() {
        if (this.isSaved) {
            return this.filename;
        }
        return null;
    }

    @AutoGenerated
    private FormLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new FormLayout();
        mainLayout.setImmediate(false);
        // textFieldPolicyName
        textFieldPolicyName = new TextField();
        textFieldPolicyName.setCaption("Policy File Name");
        textFieldPolicyName.setImmediate(true);
        textFieldPolicyName.setWidth("-1px");
        textFieldPolicyName.setHeight("-1px");
        textFieldPolicyName.setInputPrompt("Enter filename eg. foobar.xml");
        textFieldPolicyName.setRequired(true);
        mainLayout.addComponent(textFieldPolicyName);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100%");
        textAreaDescription.setHeight("-1px");
        textAreaDescription.setInputPrompt("Enter a description for the Policy/PolicySet.");
        textAreaDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textAreaDescription);
        // optionPolicySet
        optionPolicySet = new OptionGroup();
        optionPolicySet.setCaption("Policy or PolicySet?");
        optionPolicySet.setImmediate(true);
        optionPolicySet.setDescription("Is the root level a Policy or Policy Set.");
        optionPolicySet.setWidth("-1px");
        optionPolicySet.setHeight("-1px");
        optionPolicySet.setRequired(true);
        mainLayout.addComponent(optionPolicySet);
        // comboAlgorithms
        comboAlgorithms = new ComboBox();
        comboAlgorithms.setCaption("Combining Algorithm");
        comboAlgorithms.setImmediate(false);
        comboAlgorithms.setDescription("Select the combining algorithm.");
        comboAlgorithms.setWidth("-1px");
        comboAlgorithms.setHeight("-1px");
        comboAlgorithms.setRequired(true);
        mainLayout.addComponent(comboAlgorithms);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : MultiColumnFormLayout.java
Copyright GNU General Public License v3.0
Author : rlsutton1
/**
 * @param fieldLabel
 *            - the label that will be displayed in the screen layout
 * @param fieldName
 *            - the column name of the field in the database
 * @return
 */
public TextArea bindTextAreaField(String fieldLabel, String fieldName, int rows) {
    TextArea field = formHelper.bindTextAreaField(this, fieldGroup, fieldLabel, fieldName, rows);
    this.fieldList.add(field);
    return field;
}

19 View Complete Implementation : RuleEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced RuleEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private OptionGroup optionGroupEffect;

    @AutoGenerated
    private Label labelRuleID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final RuleEditorWindow self = this;

    private final RuleType rule;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public RuleEditorWindow(RuleType rule) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.rule = rule;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize
        // 
        this.initializeLabel();
        this.initializeOption();
        this.initializeText();
        this.initializeButton();
    }

    protected void initializeLabel() {
        if (this.rule.getRuleId() == null) {
            this.rule.setRuleId(((XacmlAdminUI) UI.getCurrent()).newRuleID());
        }
        this.labelRuleID.setValue(this.rule.getRuleId());
    }

    protected void initializeOption() {
        this.optionGroupEffect.setRequiredError("You MUST select an effect (Permit or Deny for the rule.");
        this.optionGroupEffect.addItem("Permit");
        this.optionGroupEffect.addItem("Deny");
        if (this.rule.getEffect() == null) {
            this.rule.setEffect(EffectType.PERMIT);
        }
        if (this.rule.getEffect() == EffectType.PERMIT) {
            this.optionGroupEffect.setValue("Permit");
        } else {
            this.optionGroupEffect.setValue("Deny");
        }
    }

    protected void initializeText() {
        this.textAreaDescription.setValue(this.rule.getDescription());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.optionGroupEffect.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    if (self.optionGroupEffect.getValue() == "Permit") {
                        self.rule.setEffect(EffectType.PERMIT);
                    } else {
                        self.rule.setEffect(EffectType.DENY);
                    }
                    self.rule.setDescription(self.textAreaDescription.getValue());
                    // 
                    // Set ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // NOPMD
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public RuleType getRule() {
        return this.rule;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelRuleID
        labelRuleID = new Label();
        labelRuleID.setCaption("Rule ID");
        labelRuleID.setImmediate(false);
        labelRuleID.setWidth("100.0%");
        labelRuleID.setHeight("-1px");
        labelRuleID.setValue("Label");
        mainLayout.addComponent(labelRuleID);
        mainLayout.setExpandRatio(labelRuleID, 1.0f);
        // optionGroupEffect
        optionGroupEffect = new OptionGroup();
        optionGroupEffect.setCaption("Choose the effect.");
        optionGroupEffect.setImmediate(false);
        optionGroupEffect.setWidth("-1px");
        optionGroupEffect.setHeight("-1px");
        optionGroupEffect.setInvalidAllowed(false);
        optionGroupEffect.setRequired(true);
        mainLayout.addComponent(optionGroupEffect);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Enter a description for the Rule.");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        textAreaDescription.setNullSettingAllowed(true);
        textAreaDescription.setNullRepresentation("");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : AbstractTagLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Abstract clreplaced for tag layout.
 *
 * @param <E>
 *            enreplacedy clreplaced
 */
public abstract clreplaced AbstractTagLayout<E extends NamedEnreplacedy> extends CustomComponent implements ColorChangeListener, ColorSelector {

    private static final long serialVersionUID = 1L;

    private static final String TAG_NAME_DYNAMIC_STYLE = "new-tag-name";

    private static final String TAG_DESC_DYNAMIC_STYLE = "new-tag-desc";

    private static final String TAG_DYNAMIC_STYLE = "tag-color-preview";

    private static final String MESSAGE_ERROR_MISSING_TAGNAME = "message.error.missing.tagname";

    private static final int MAX_TAGS = 500;

    private final VaadinMessageSource i18n;

    private transient EnreplacedyFactory enreplacedyFactory;

    private transient EventBus.UIEventBus eventBus;

    private final SpPermissionChecker permChecker;

    private final UINotification uiNotification;

    private final FormLayout formLayout = new FormLayout();

    private CommonDialogWindow window;

    private Label colorLabel;

    private TextField tagName;

    private TextArea tagDesc;

    private Button tagColorPreviewBtn;

    private ColorPickerLayout colorPickerLayout;

    private GridLayout mainLayout;

    private VerticalLayout contentLayout;

    private boolean tagPreviewBtnClicked;

    private String colorPicked;

    private HorizontalLayout colorLabelLayout;

    /**
     * Constructor for AbstractCreateUpdateTagLayout
     *
     * @param i18n
     *            I18N
     * @param enreplacedyFactory
     *            EnreplacedyFactory
     * @param eventBus
     *            UIEventBus
     * @param permChecker
     *            SpPermissionChecker
     * @param uiNotification
     *            UINotification
     */
    public AbstractTagLayout(final VaadinMessageSource i18n, final EnreplacedyFactory enreplacedyFactory, final UIEventBus eventBus, final SpPermissionChecker permChecker, final UINotification uiNotification) {
        this.i18n = i18n;
        this.enreplacedyFactory = enreplacedyFactory;
        this.eventBus = eventBus;
        this.permChecker = permChecker;
        this.uiNotification = uiNotification;
        init();
    }

    /**
     * Save or update the enreplacedy.
     */
    private final clreplaced SaveOnDialogCloseListener implements SaveDialogCloseListener {

        @Override
        public void saveOrUpdate() {
            saveEnreplacedy();
        }

        @Override
        public boolean canWindowSaveOrUpdate() {
            return isDeleteAction() || (isUpdateAction() || !isDuplicate());
        }
    }

    protected boolean isDeleteAction() {
        return false;
    }

    /**
     * Discard the changes and close the popup.
     */
    protected void discard() {
        UI.getCurrent().removeWindow(window);
    }

    /**
     * Init the layout.
     */
    protected void init() {
        setSizeUndefined();
        createRequiredComponents();
        buildLayout();
        addListeners();
        eventBus.subscribe(this);
        openConfigureWindow();
    }

    protected abstract Optional<E> findEnreplacedyByName();

    protected abstract String getWindowCaption();

    protected abstract void saveEnreplacedy();

    protected void createRequiredComponents() {
        colorLabel = new LabelBuilder().name(i18n.getMessage("label.choose.tag.color")).buildLabel();
        colorLabel.addStyleName(SPUIStyleDefinitions.COLOR_LABEL_STYLE);
        tagName = new TextFieldBuilder(getTagNameSize()).caption(i18n.getMessage("textfield.name")).styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_NAME).required(true, i18n).prompt(i18n.getMessage("textfield.name")).immediate(true).id(getTagNameId()).buildTextComponent();
        tagDesc = new TextAreaBuilder(getTagDescSize()).caption(i18n.getMessage("textfield.description")).styleName(ValoTheme.TEXTFIELD_TINY + " " + SPUIDefinitions.TAG_DESC).prompt(i18n.getMessage("textfield.description")).id(getTagDescId()).buildTextComponent();
        tagDesc.setNullRepresentation("");
        tagColorPreviewBtn = new Button();
        tagColorPreviewBtn.setId(UIComponentIdProvider.TAG_COLOR_PREVIEW_ID);
        getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
        tagColorPreviewBtn.setStyleName(TAG_DYNAMIC_STYLE);
    }

    protected abstract String getTagDescId();

    protected abstract String getTagNameId();

    protected abstract int getTagDescSize();

    protected abstract int getTagNameSize();

    protected void buildLayout() {
        mainLayout = new GridLayout(3, 2);
        mainLayout.setSpacing(true);
        colorPickerLayout = new ColorPickerLayout();
        ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
        contentLayout = new VerticalLayout();
        colorLabelLayout = new HorizontalLayout();
        colorLabelLayout.setMargin(false);
        colorLabelLayout.addComponents(colorLabel, tagColorPreviewBtn);
        formLayout.addComponent(tagName);
        formLayout.addComponent(tagDesc);
        formLayout.setSizeFull();
        contentLayout.addComponent(formLayout);
        contentLayout.addComponent(colorLabelLayout);
        contentLayout.setComponentAlignment(formLayout, Alignment.MIDDLE_CENTER);
        contentLayout.setComponentAlignment(colorLabelLayout, Alignment.MIDDLE_LEFT);
        contentLayout.setSizeUndefined();
        mainLayout.setSizeFull();
        mainLayout.addComponent(contentLayout, 0, 0);
        colorPickerLayout.setVisible(false);
        mainLayout.addComponent(colorPickerLayout, 1, 0);
        mainLayout.setComponentAlignment(colorPickerLayout, Alignment.MIDDLE_CENTER);
        setCompositionRoot(mainLayout);
        tagName.focus();
    }

    protected void addListeners() {
        colorPickerLayout.getColorSelect().addColorChangeListener(this);
        colorPickerLayout.getSelPreview().addColorChangeListener(this);
        tagColorPreviewBtn.addClickListener(event -> previewButtonClicked());
        slidersValueChangeListeners();
    }

    protected Color getColorForColorPicker() {
        return ColorPickerConstants.START_COLOR;
    }

    protected void resetFields() {
        tagName.setEnabled(true);
        tagName.clear();
        tagDesc.clear();
        restoreComponentStyles();
        colorPickerLayout.setSelectedColor(colorPickerLayout.getDefaultColor());
        colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
        tagPreviewBtnClicked = false;
        disableFields();
    }

    protected void disableFields() {
    // can be overwritten
    }

    /**
     * Dynamic styles for window.
     *
     * @param top
     *            int value
     * @param marginLeft
     *            int value
     */
    protected void getPreviewButtonColor(final String color) {
        Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.getPreviewButtonColorScript(color));
    }

    /**
     * Set tag name and desc field border color based on chosen color.
     *
     * @param tagName
     * @param tagDesc
     * @param taregtTagColor
     */
    protected void createDynamicStyleForComponents(final TextField tagName, final TextArea tagDesc, final String taregtTagColor) {
        tagName.removeStyleName(SPUIDefinitions.TAG_NAME);
        tagDesc.removeStyleName(SPUIDefinitions.TAG_DESC);
        getTargetDynamicStyles(taregtTagColor);
        tagName.addStyleName(TAG_NAME_DYNAMIC_STYLE);
        tagDesc.addStyleName(TAG_DESC_DYNAMIC_STYLE);
    }

    /**
     * reset the tag name and tag description component border color.
     */
    protected void restoreComponentStyles() {
        tagName.removeStyleName(TAG_NAME_DYNAMIC_STYLE);
        tagDesc.removeStyleName(TAG_DESC_DYNAMIC_STYLE);
        tagName.addStyleName(SPUIDefinitions.TAG_NAME);
        tagDesc.addStyleName(SPUIDefinitions.TAG_DESC);
        getPreviewButtonColor(ColorPickerConstants.DEFAULT_COLOR);
    }

    protected void setColorToComponents(final Color newColor) {
        setColor(newColor);
        colorPickerLayout.getColorSelect().setColor(newColor);
        getPreviewButtonColor(newColor.getCSS());
        createDynamicStyleForComponents(tagName, tagDesc, newColor.getCSS());
    }

    protected void displaySuccess(final String tagName) {
        uiNotification.displaySuccess(i18n.getMessage("message.save.success", tagName));
    }

    protected void displayValidationError(final String errorMessage) {
        uiNotification.displayValidationError(errorMessage);
    }

    protected void setTagColor(final Color selectedColor, final String previewColor) {
        getColorPickerLayout().setSelectedColor(selectedColor);
        getColorPickerLayout().getSelPreview().setColor(getColorPickerLayout().getSelectedColor());
        getColorPickerLayout().getColorSelect().setColor(getColorPickerLayout().getSelectedColor());
        createDynamicStyleForComponents(tagName, tagDesc, previewColor);
        getPreviewButtonColor(previewColor);
    }

    protected abstract boolean isUpdateAction();

    protected boolean isDuplicate() {
        return isDuplicateByName();
    }

    @Override
    public Color getColor() {
        return null;
    }

    @Override
    public void setColor(final Color color) {
        if (color == null) {
            return;
        }
        colorPickerLayout.setSelectedColor(color);
        colorPickerLayout.getSelPreview().setColor(colorPickerLayout.getSelectedColor());
        final String colorPickedPreview = colorPickerLayout.getSelPreview().getColor().getCSS();
        if (colorPickerLayout.getColorSelect() != null) {
            createDynamicStyleForComponents(tagName, tagDesc, colorPickedPreview);
            colorPickerLayout.getColorSelect().setColor(colorPickerLayout.getSelPreview().getColor());
        }
    }

    public ColorPickerLayout getColorPickerLayout() {
        return colorPickerLayout;
    }

    /**
     * Creates the window to create or update a tag or type
     *
     * @return the created window
     */
    public CommonDialogWindow createWindow() {
        window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(getWindowCaption()).content(this).cancelButtonClickListener(event -> discard()).layout(mainLayout).i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
        return window;
    }

    @Override
    public void colorChanged(final ColorChangeEvent event) {
        setColor(event.getColor());
        for (final ColorSelector select : colorPickerLayout.getSelectors()) {
            if (!event.getSource().equals(select) && select.equals(this) && !select.getColor().equals(colorPickerLayout.getSelectedColor())) {
                select.setColor(colorPickerLayout.getSelectedColor());
            }
        }
        ColorPickerHelper.setRgbSliderValues(colorPickerLayout);
        getPreviewButtonColor(event.getColor().getCSS());
        createDynamicStyleForComponents(tagName, tagDesc, event.getColor().getCSS());
    }

    protected String getColorPicked() {
        return colorPicked;
    }

    protected void setColorPicked(final String colorPicked) {
        this.colorPicked = colorPicked;
    }

    protected FormLayout getFormLayout() {
        return formLayout;
    }

    protected GridLayout getMainLayout() {
        return mainLayout;
    }

    @Override
    public void addColorChangeListener(final ColorChangeListener listener) {
    }

    @Override
    public void removeColorChangeListener(final ColorChangeListener listener) {
    }

    protected static String getTagNameDynamicStyle() {
        return TAG_NAME_DYNAMIC_STYLE;
    }

    protected static String getTagDescDynamicStyle() {
        return TAG_DESC_DYNAMIC_STYLE;
    }

    protected static String getTagDynamicStyle() {
        return TAG_DYNAMIC_STYLE;
    }

    protected static String getMessageErrorMissingTagname() {
        return MESSAGE_ERROR_MISSING_TAGNAME;
    }

    protected static int getMaxTags() {
        return MAX_TAGS;
    }

    protected VaadinMessageSource getI18n() {
        return i18n;
    }

    protected EnreplacedyFactory getEnreplacedyFactory() {
        return enreplacedyFactory;
    }

    protected EventBus.UIEventBus getEventBus() {
        return eventBus;
    }

    protected SpPermissionChecker getPermChecker() {
        return permChecker;
    }

    protected UINotification getUiNotification() {
        return uiNotification;
    }

    protected Label getColorLabel() {
        return colorLabel;
    }

    protected TextField getTagName() {
        return tagName;
    }

    protected TextArea getTagDesc() {
        return tagDesc;
    }

    protected Button getTagColorPreviewBtn() {
        return tagColorPreviewBtn;
    }

    protected VerticalLayout getContentLayout() {
        return contentLayout;
    }

    protected boolean isTagPreviewBtnClicked() {
        return tagPreviewBtnClicked;
    }

    protected HorizontalLayout getColorLabelLayout() {
        return colorLabelLayout;
    }

    protected void setTagName(final TextField tagName) {
        this.tagName = tagName;
    }

    protected void setTagDesc(final TextArea tagDesc) {
        this.tagDesc = tagDesc;
    }

    protected void setTagColorPreviewBtn(final Button tagColorPreviewBtn) {
        this.tagColorPreviewBtn = tagColorPreviewBtn;
    }

    /**
     * Open color picker on click of preview button. Auto select the color based
     * on target tag if already selected.
     */
    private void previewButtonClicked() {
        if (!tagPreviewBtnClicked) {
            colorPickerLayout.setSelectedColor(ColorPickerHelper.rgbToColorConverter(ColorPickerConstants.DEFAULT_COLOR));
        }
        tagPreviewBtnClicked = !tagPreviewBtnClicked;
        colorPickerLayout.setVisible(tagPreviewBtnClicked);
    }

    /**
     * Get target style - Dynamically as per the color picked, cannot be done
     * from the static css.
     *
     * @param colorPickedPreview
     */
    private static void getTargetDynamicStyles(final String colorPickedPreview) {
        Page.getCurrent().getJavaScript().execute(HawkbitCommonUtil.changeToNewSelectedPreviewColor(colorPickedPreview));
    }

    /**
     * Value change listeners implementations of sliders.
     */
    private void slidersValueChangeListeners() {
        colorPickerLayout.getRedSlider().addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(final ValueChangeEvent event) {
                final double red = (Double) event.getProperty().getValue();
                final Color newColor = new Color((int) red, colorPickerLayout.getSelectedColor().getGreen(), colorPickerLayout.getSelectedColor().getBlue());
                setColorToComponents(newColor);
            }
        });
        colorPickerLayout.getGreenSlider().addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(final ValueChangeEvent event) {
                final double green = (Double) event.getProperty().getValue();
                final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(), (int) green, colorPickerLayout.getSelectedColor().getBlue());
                setColorToComponents(newColor);
            }
        });
        colorPickerLayout.getBlueSlider().addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(final ValueChangeEvent event) {
                final double blue = (Double) event.getProperty().getValue();
                final Color newColor = new Color(colorPickerLayout.getSelectedColor().getRed(), colorPickerLayout.getSelectedColor().getGreen(), (int) blue);
                setColorToComponents(newColor);
            }
        });
    }

    private boolean isDuplicateByName() {
        final Optional<E> existingType = findEnreplacedyByName();
        existingType.ifPresent(type -> uiNotification.displayValidationError(i18n.getMessage("message.tag.duplicate.check", type.getName())));
        return existingType.isPresent();
    }

    private void openConfigureWindow() {
        createWindow();
        UI.getCurrent().addWindow(window);
        window.setModal(true);
        window.setVisible(Boolean.TRUE);
    }

    protected CommonDialogWindow getWindow() {
        return window;
    }
}

19 View Complete Implementation : SoftwareModuleAddUpdateWindow.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Generates window for Software module add or update.
 */
public clreplaced SoftwareModuleAddUpdateWindow extends CustomComponent {

    private static final Logger LOGGER = LoggerFactory.getLogger(SoftwareModuleAddUpdateWindow.clreplaced.getName());

    private static final long serialVersionUID = 1L;

    private final VaadinMessageSource i18n;

    private final UINotification uiNotifcation;

    private final transient EventBus.UIEventBus eventBus;

    private final transient SoftwareModuleManagement softwareModuleManagement;

    private final transient SoftwareModuleTypeManagement softwareModuleTypeManagement;

    private final transient EnreplacedyFactory enreplacedyFactory;

    private final AbstractTable<SoftwareModule> softwareModuleTable;

    private TextField nameTextField;

    private TextField versionTextField;

    private TextField vendorTextField;

    private ComboBox typeComboBox;

    private TextArea descTextArea;

    private Boolean editSwModule = Boolean.FALSE;

    private Long baseSwModuleId;

    private FormLayout formLayout;

    private Label softwareModuleType;

    /**
     * Constructor for SoftwareModuleAddUpdateWindow
     *
     * @param i18n
     *            I18N
     * @param uiNotifcation
     *            UINotification
     * @param eventBus
     *            UIEventBus
     * @param softwareModuleManagement
     *            management for {@link SoftwareModule}s
     * @param softwareModuleTypeManagement
     *            management for {@link SoftwareModuleType}s
     * @param enreplacedyFactory
     *            EnreplacedyFactory
     */
    public SoftwareModuleAddUpdateWindow(final VaadinMessageSource i18n, final UINotification uiNotifcation, final UIEventBus eventBus, final SoftwareModuleManagement softwareModuleManagement, final SoftwareModuleTypeManagement softwareModuleTypeManagement, final EnreplacedyFactory enreplacedyFactory, final AbstractTable<SoftwareModule> softwareModuleTable) {
        this.i18n = i18n;
        this.uiNotifcation = uiNotifcation;
        this.eventBus = eventBus;
        this.softwareModuleManagement = softwareModuleManagement;
        this.softwareModuleTypeManagement = softwareModuleTypeManagement;
        this.enreplacedyFactory = enreplacedyFactory;
        this.softwareModuleTable = softwareModuleTable;
        createRequiredComponents();
    }

    private void createRequiredComponents() {
        nameTextField = createTextField("textfield.name", UIComponentIdProvider.SOFT_MODULE_NAME, SoftwareModule.NAME_MAX_SIZE);
        versionTextField = createTextField("textfield.version", UIComponentIdProvider.SOFT_MODULE_VERSION, SoftwareModule.VERSION_MAX_SIZE);
        vendorTextField = new TextFieldBuilder(SoftwareModule.VENDOR_MAX_SIZE).caption(i18n.getMessage("textfield.vendor")).id(UIComponentIdProvider.SOFT_MODULE_VENDOR).buildTextComponent();
        descTextArea = new TextAreaBuilder(SoftwareModule.DESCRIPTION_MAX_SIZE).caption(i18n.getMessage("textfield.description")).style("text-area-style").id(UIComponentIdProvider.ADD_SW_MODULE_DESCRIPTION).buildTextComponent();
        typeComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE), "", null, null, true, null, i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE));
        typeComboBox.setId(UIComponentIdProvider.SW_MODULE_TYPE);
        typeComboBox.setStyleName(SPUIDefinitions.COMBO_BOX_SPECIFIC_STYLE + " " + ValoTheme.COMBOBOX_TINY);
        typeComboBox.setNewItemsAllowed(Boolean.FALSE);
        typeComboBox.setImmediate(Boolean.TRUE);
    }

    private TextField createTextField(final String in18Key, final String id, final int maxLength) {
        return new TextFieldBuilder(maxLength).caption(i18n.getMessage(in18Key)).required(true, i18n).id(id).buildTextComponent();
    }

    /**
     * Creates window for new software module.
     *
     * @return reference of {@link com.vaadin.ui.Window} to add new software
     *         module.
     */
    public CommonDialogWindow createAddSoftwareModuleWindow() {
        return createUpdateSoftwareModuleWindow(null);
    }

    /**
     * Creates window for update software module.
     *
     * @param baseSwModuleId
     *            id of the software module to edit.
     * @return reference of {@link com.vaadin.ui.Window} to update software
     *         module.
     */
    public CommonDialogWindow createUpdateSoftwareModuleWindow(final Long baseSwModuleId) {
        this.baseSwModuleId = baseSwModuleId;
        resetComponents();
        populateTypeNameCombo();
        populateValuesOfSwModule();
        return createWindow();
    }

    private void resetComponents() {
        vendorTextField.clear();
        nameTextField.clear();
        versionTextField.clear();
        descTextArea.clear();
        if (!editSwModule) {
            typeComboBox.clear();
        }
        editSwModule = Boolean.FALSE;
    }

    private void populateTypeNameCombo() {
        typeComboBox.setContainerDataSource(HawkbitCommonUtil.createLazyQueryContainer(new BeanQueryFactory<>(SoftwareModuleTypeBeanQuery.clreplaced)));
        typeComboBox.sereplacedemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
    }

    /**
     * fill the data of a softwareModule in the content of the window
     */
    private void populateValuesOfSwModule() {
        if (baseSwModuleId == null) {
            return;
        }
        editSwModule = Boolean.TRUE;
        softwareModuleManagement.get(baseSwModuleId).ifPresent(swModule -> {
            nameTextField.setValue(swModule.getName());
            versionTextField.setValue(swModule.getVersion());
            vendorTextField.setValue(swModule.getVendor());
            descTextArea.setValue(swModule.getDescription());
            softwareModuleType = new LabelBuilder().name(swModule.getType().getName()).caption(i18n.getMessage(UIMessageIdProvider.CAPTION_ARTIFACT_SOFTWARE_MODULE_TYPE)).buildLabel();
        });
    }

    private CommonDialogWindow createWindow() {
        final Label madatoryStarLabel = new Label("*");
        madatoryStarLabel.setStyleName("v-caption v-required-field-indicator");
        madatoryStarLabel.setWidth(null);
        addStyleName("lay-color");
        setSizeUndefined();
        formLayout = new FormLayout();
        formLayout.setCaption(null);
        if (editSwModule) {
            formLayout.addComponent(softwareModuleType);
        } else {
            formLayout.addComponent(typeComboBox);
            typeComboBox.focus();
        }
        formLayout.addComponent(nameTextField);
        formLayout.addComponent(versionTextField);
        formLayout.addComponent(vendorTextField);
        formLayout.addComponent(descTextArea);
        setCompositionRoot(formLayout);
        final CommonDialogWindow window = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(i18n.getMessage("caption.create.new", i18n.getMessage("caption.software.module"))).id(UIComponentIdProvider.SW_MODULE_CREATE_DIALOG).content(this).layout(formLayout).i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
        nameTextField.setEnabled(!editSwModule);
        versionTextField.setEnabled(!editSwModule);
        return window;
    }

    public FormLayout getFormLayout() {
        return formLayout;
    }

    /**
     * Save or update the sw module.
     */
    private final clreplaced SaveOnDialogCloseListener implements SaveDialogCloseListener {

        @Override
        public boolean canWindowSaveOrUpdate() {
            return editSwModule || !isDuplicate();
        }

        @Override
        public void saveOrUpdate() {
            if (editSwModule) {
                updateSwModule();
                return;
            }
            addNewBaseSoftware();
        }

        /**
         * updates a softwareModule
         */
        private void updateSwModule() {
            final SoftwareModule newSWModule = softwareModuleManagement.update(enreplacedyFactory.softwareModule().update(baseSwModuleId).description(descTextArea.getValue()).vendor(vendorTextField.getValue()));
            if (newSWModule != null) {
                uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", newSWModule.getName() + ":" + newSWModule.getVersion()));
                eventBus.publish(this, new SoftwareModuleEvent(BaseEnreplacedyEventType.UPDATED_ENreplacedY, newSWModule));
            }
        }

        private void addNewBaseSoftware() {
            final String name = nameTextField.getValue();
            final String version = versionTextField.getValue();
            final String vendor = vendorTextField.getValue();
            final String description = descTextArea.getValue();
            final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
            final SoftwareModuleType softwareModuleTypeByName = softwareModuleTypeManagement.getByName(type).orElseThrow(() -> new EnreplacedyNotFoundException(SoftwareModuleType.clreplaced, type));
            final SoftwareModuleCreate softwareModule = enreplacedyFactory.softwareModule().create().type(softwareModuleTypeByName).name(name).version(version).description(description).vendor(vendor);
            final SoftwareModule newSoftwareModule;
            try {
                newSoftwareModule = softwareModuleManagement.create(softwareModule);
            } catch (ConstraintViolationException ex) {
                String message = "This SoftwareModuleName is not valid! " + "Please choose a SoftwareModuleName without the characters /, ?, #, blank, and quota chars" + ex.getMessage();
                LOGGER.warn(message, ex);
                uiNotifcation.displayValidationError(i18n.getMessage("message.save.fail", name + ":" + version));
                return;
            }
            eventBus.publish(this, new SoftwareModuleEvent(BaseEnreplacedyEventType.ADD_ENreplacedY, newSoftwareModule));
            uiNotifcation.displaySuccess(i18n.getMessage("message.save.success", newSoftwareModule.getName() + ":" + newSoftwareModule.getVersion()));
            softwareModuleTable.setValue(Sets.newHashSet(newSoftwareModule.getId()));
        }

        private boolean isDuplicate() {
            final String name = nameTextField.getValue();
            final String version = versionTextField.getValue();
            final String type = typeComboBox.getValue() != null ? typeComboBox.getValue().toString() : null;
            final Optional<Long> moduleType = softwareModuleTypeManagement.getByName(type).map(SoftwareModuleType::getId);
            if (moduleType.isPresent() && softwareModuleManagement.getByNameAndVersionAndType(name, version, moduleType.get()).isPresent()) {
                uiNotifcation.displayValidationError(i18n.getMessage("message.duplicate.softwaremodule", name, version));
                return true;
            }
            return false;
        }
    }
}

19 View Complete Implementation : AttributeEditorWindow.java
Copyright MIT License
Author : att
public clreplaced AttributeEditorWindow extends Window {

    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(AttributeEditorWindow.clreplaced);

    private AttributeEditorWindow self = this;

    private boolean isSaved = false;

    private Attribute attribute;

    private FormLayout mainLayout = new FormLayout();

    @PropertyId("isDesignator")
    DesignatorSelectorField selectDesignator;

    @PropertyId("selectorPath")
    TextField selectorPath = new TextField("Attribute Selector Path");

    @PropertyId("xacmlId")
    TextField xacmlID = new TextField("XACML ID");

    @PropertyId("categoryBean")
    ComboBox category = new ComboBox("Category");

    @PropertyId("description")
    TextArea descriptionField = new TextArea("Description");

    @PropertyId("datatypeBean")
    ComboBox datatype = new ComboBox("DataType");

    @PropertyId("constraintType")
    ComboBox constraintTypes = new ComboBox("Constraint Type");

    @PropertyId("constraintValues")
    ConstraintField constraintValues;

    Button saveButton = new Button("Save");

    FieldGroup fieldGroup = null;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param enreplacedyItem
     */
    public AttributeEditorWindow(EnreplacedyItem<Attribute> enreplacedyItem) {
        // 
        // Save our attribute
        // 
        this.attribute = enreplacedyItem.getEnreplacedy();
        if (logger.isDebugEnabled()) {
            logger.debug("Editing attribute: " + enreplacedyItem.getEnreplacedy().toString());
        }
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Create our main layout
        // 
        this.setContent(mainLayout);
        // 
        // Finish setting up the main layout
        // 
        this.mainLayout.setSpacing(true);
        this.mainLayout.setMargin(true);
        // 
        // Setup option group, binding the
        // field group doesn't seem to work.
        // 
        this.selectDesignator = new DesignatorSelectorField(enreplacedyItem);
        this.selectDesignator.setCaption("Select the Attribute Type");
        this.selectDesignator.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Object value = self.selectDesignator.getValue();
                if (value == null || !(value instanceof Character)) {
                    self.selectorPath.setVisible(false);
                }
                if (((Character) value) == '1') {
                    self.selectorPath.setVisible(false);
                } else {
                    self.selectorPath.setVisible(true);
                }
            }
        });
        // 
        // Setup selector path
        // 
        this.selectorPath.setImmediate(true);
        this.selectorPath.setNullRepresentation("");
        this.selectorPath.setWidth("100%");
        // 
        // Setup the Category combo
        // 
        this.category.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getCategories());
        this.category.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.category.sereplacedemCaptionPropertyId("xacmlId");
        this.category.setFilteringMode(FilteringMode.CONTAINS);
        this.category.setImmediate(true);
        this.category.setNullSelectionAllowed(false);
        this.category.setConverter(new SingleSelectConverter<Object>(this.category));
        // 
        // Setup the Datatype combo
        // 
        this.datatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
        this.datatype.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.datatype.sereplacedemCaptionPropertyId("xacmlId");
        this.datatype.setFilteringMode(FilteringMode.CONTAINS);
        this.datatype.setImmediate(true);
        this.datatype.setNullSelectionAllowed(false);
        this.datatype.setConverter(new SingleSelectConverter<Object>(this.datatype));
        // 
        // Setup the constraint type combo
        // 
        this.constraintTypes.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getConstraintTypes());
        this.constraintTypes.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.constraintTypes.sereplacedemCaptionPropertyId("constraintType");
        this.constraintTypes.setFilteringMode(FilteringMode.CONTAINS);
        this.constraintTypes.setImmediate(true);
        this.constraintTypes.setNullSelectionAllowed(true);
        this.constraintTypes.setConverter(new SingleSelectConverter<Object>(this.constraintTypes));
        // 
        // Setup the constraint value custom field
        // 
        this.constraintValues = new ConstraintField(enreplacedyItem);
        // 
        // Finish laying out the main layout
        // 
        this.mainLayout.addComponent(this.selectDesignator);
        this.mainLayout.addComponent(this.selectorPath);
        this.mainLayout.addComponent(this.xacmlID);
        this.mainLayout.addComponent(this.category);
        this.mainLayout.addComponent(this.descriptionField);
        this.mainLayout.addComponent(this.datatype);
        this.mainLayout.addComponent(this.constraintTypes);
        this.mainLayout.addComponent(this.constraintValues);
        // 
        // Now create our field group and bind our bean items
        // This will populate the components with the attribute's
        // current value.
        // 
        this.fieldGroup = new FieldGroup(enreplacedyItem);
        this.fieldGroup.bindMemberFields(this);
        // 
        // Finishing setting up after the bind. There are some components
        // where initializing the bind causes some properties to be reset.
        // 
        this.xacmlID.setWidth("100%");
        this.descriptionField.setNullRepresentation("");
        this.descriptionField.setWidth("100%");
        this.setupDatatype(this.attribute.getDatatypeBean().getIdentifer());
        this.datatype.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Identifier id = self.getCurrentDatatype();
                if (id != null) {
                    self.setupDatatype(id);
                }
            }
        });
        // 
        // Listen to when constraint type changes
        // 
        this.constraintTypes.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Object value = self.constraintTypes.getValue();
                if (value == null) {
                    self.constraintValues.resetContent(null, self.getCurrentDatatype());
                } else {
                    ConstraintType newValue = ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().gereplacedem(value).getEnreplacedy();
                    self.constraintValues.resetContent(newValue, self.getCurrentDatatype());
                }
            }
        });
        // 
        // Setup our "SAVE" button to commit the fields
        // 
        this.mainLayout.addComponent(this.saveButton);
        this.mainLayout.setComponentAlignment(this.saveButton, Alignment.MIDDLE_CENTER);
        this.saveButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // SAVE the latest values
                    // 
                    fieldGroup.commit();
                    // 
                    // Set that we did save the attribute
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (CommitException e) {
                    logger.error("Failed to commit fields", e);
                }
            }
        });
        // 
        // Add our close listener so we can discard anything that was changed.
        // 
        this.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                if (self.isSaved == false) {
                    logger.info("discarding");
                    // 
                    // Discard any changes to the existing JPA container enreplacedy
                    // 
                    self.fieldGroup.discard();
                    // 
                    // Make sure there are no filters on the container
                    // 
                    ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
                }
            }
        });
        // 
        // Set focus
        // 
        this.xacmlID.focus();
    }

    private void setupDatatype(Identifier datatype) {
        if (datatype.equals(XACML3.ID_DATATYPE_INTEGER) || datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
            ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
            this.constraintTypes.setEnabled(true);
            this.constraintValues.resetDatatype(datatype);
            return;
        }
        if (datatype.equals(XACML3.ID_DATATYPE_STRING)) {
            ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().addContainerFilter(new Not(new Compare.Equal("constraintType", ConstraintType.RANGE_TYPE)));
            if (this.attribute.getConstraintType() != null && this.attribute.getConstraintType().getConstraintType() != null && this.attribute.getConstraintType().getConstraintType().equals(ConstraintType.RANGE_TYPE)) {
                this.attribute.setConstraintType(null);
            }
            this.constraintValues.resetDatatype(datatype);
            return;
        }
        // 
        // No constraint for all other datatypes
        // 
        this.attribute.setConstraintType(null);
        this.constraintTypes.select(null);
        this.constraintTypes.setEnabled(false);
    }

    private Identifier getCurrentDatatype() {
        Object id = self.datatype.getValue();
        if (id != null) {
            EnreplacedyItem<Datatype> dt = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().gereplacedem(id);
            if (dt != null) {
                return dt.getEnreplacedy().getIdentifer();
            }
        }
        return null;
    }

    public boolean isSaved() {
        return this.isSaved;
    }
}

19 View Complete Implementation : AddUpdateRolloutWindowLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
private static TextArea createDescription() {
    final TextArea descriptionField = new TextAreaBuilder(Rollout.DESCRIPTION_MAX_SIZE).style("text-area-style").id(UIComponentIdProvider.ROLLOUT_DESCRIPTION_ID).buildTextComponent();
    descriptionField.setSizeUndefined();
    return descriptionField;
}

19 View Complete Implementation : PIPSQLResolverEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced PIPSQLResolverEditorWindow extends CustomComponent implements FormChangedEventNotifier, Handler {

    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Table tableAttributes;

    @AutoGenerated
    private Table tableRequiredAttributes;

    @AutoGenerated
    private CheckBox checkBoxShortIds;

    @AutoGenerated
    private TextField textFieldFilter;

    @AutoGenerated
    private TextField textFieldBase;

    @AutoGenerated
    private TextArea textAreaSelect;

    private final Action ADD_ATTRIBUTE = new Action("Add Attribute");

    private final Action EDIT_ATTRIBUTE = new Action("Edit Attribute");

    private final Action CLONE_ATTRIBUTE = new Action("Clone Attribute");

    private final Action REMOVE_ATTRIBUTE = new Action("Remove Attribute");

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    /**
     */
    protected clreplaced ResolverAttribute implements Serializable {

        private static final long serialVersionUID = 1L;

        String identifier = null;

        String prefix = null;

        PIPResolverParam id = null;

        PIPResolverParam category = null;

        PIPResolverParam datatype = null;

        PIPResolverParam issuer = null;

        PIPResolverParam column = null;

        public ResolverAttribute(String prefix, String identifier) {
            this.prefix = prefix;
            this.identifier = identifier;
        }

        public ResolverAttribute(String prefix, String identifier, ResolverAttribute target) {
            this(prefix, identifier);
            this.setId(target.getId());
            this.setCategory(target.getCategory());
            this.setDatatype(target.getDatatype());
            this.setIssuer(target.getIssuer());
            this.setColumn(target.getColumn());
            this.setResolver(target.id.getPipresolver());
        }

        public String getIdentifier() {
            return this.identifier;
        }

        public String getId() {
            if (this.id == null) {
                return null;
            }
            return this.id.getParamValue();
        }

        public String getShortId() {
            String id = this.getId();
            if (id == null) {
                return null;
            }
            return XACMLConstants.extractShortName(id);
        }

        public PIPResolverParam getIdParam() {
            return this.id;
        }

        public void setId(String id) {
            if (this.id == null) {
                this.id = new PIPResolverParam();
                this.id.setParamName(this.prefix + this.identifier + ".id");
            }
            this.id.setParamValue(id);
        }

        public void setId(PIPResolverParam param) {
            this.id = param;
        }

        public String getCategory() {
            if (this.category == null) {
                return null;
            }
            return this.category.getParamValue();
        }

        public String getShortCategory() {
            String category = this.getCategory();
            if (category == null) {
                return null;
            }
            return XACMLConstants.extractShortName(category);
        }

        public PIPResolverParam getCategoryParam() {
            return this.category;
        }

        public void setCategory(String category) {
            if (this.category == null) {
                this.category = new PIPResolverParam();
                this.category.setParamName(this.prefix + this.identifier + ".category");
            }
            this.category.setParamValue(category);
        }

        public void setCategory(PIPResolverParam param) {
            this.category = param;
        }

        public String getDatatype() {
            if (this.datatype == null) {
                return null;
            }
            return this.datatype.getParamValue();
        }

        public String getShortDatatype() {
            String dt = this.getDatatype();
            if (dt == null) {
                return null;
            }
            return XACMLConstants.extractShortName(dt);
        }

        public PIPResolverParam getDatatypeParam() {
            return this.datatype;
        }

        public void setDatatype(String datatype) {
            if (this.datatype == null) {
                this.datatype = new PIPResolverParam();
                this.datatype.setParamName(this.prefix + this.identifier + ".datatype");
            }
            this.datatype.setParamValue(datatype);
        }

        public void setDatatype(PIPResolverParam param) {
            this.datatype = param;
        }

        public String getIssuer() {
            if (this.issuer == null) {
                return null;
            }
            return this.issuer.getParamValue();
        }

        public String getShortIssuer() {
            String issuer = this.getIssuer();
            if (issuer == null) {
                return null;
            }
            return XACMLConstants.extractShortName(issuer);
        }

        public PIPResolverParam getIssuerParam() {
            return this.issuer;
        }

        public void setIssuer(String issuer) {
            if (this.issuer == null) {
                this.issuer = new PIPResolverParam();
                this.issuer.setParamName(this.prefix + this.identifier + ".issuer");
            }
            this.issuer.setParamValue(issuer);
        }

        public void setIssuer(PIPResolverParam param) {
            this.issuer = param;
        }

        public Integer getColumn() {
            if (this.column == null) {
                return null;
            }
            try {
                return Integer.parseInt(this.column.getParamValue());
            } catch (NumberFormatException e) {
                logger.error("Failed to set column: " + e);
                return null;
            }
        }

        public PIPResolverParam getColumnParam() {
            return this.column;
        }

        public void setColumn(Integer col) {
            if (this.column == null) {
                this.column = new PIPResolverParam();
                this.column.setParamName(this.prefix + this.identifier + "column");
            }
            this.column.setParamValue(col.toString());
        }

        public void setColumn(PIPResolverParam param) {
            this.column = param;
        }

        public void setResolver(PIPResolver resolver) {
            if (this.id != null) {
                this.id.setPipresolver(resolver);
            }
            if (this.category != null) {
                this.category.setPipresolver(resolver);
            }
            if (this.datatype != null) {
                this.datatype.setPipresolver(resolver);
            }
            if (this.issuer != null) {
                this.issuer.setPipresolver(resolver);
            }
            if (this.column != null) {
                this.column.setPipresolver(resolver);
            }
        }
    }

    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(PIPSQLResolverEditorWindow.clreplaced);

    private final PIPSQLResolverEditorWindow self = this;

    private final EnreplacedyItem<PIPResolver> enreplacedy;

    private final BeanItemContainer<ResolverAttribute> fieldsContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.clreplaced);

    private final BeanItemContainer<ResolverAttribute> parametersContainer = new BeanItemContainer<ResolverAttribute>(ResolverAttribute.clreplaced);

    private final BasicNotifier notifier = new BasicNotifier();

    boolean isSaved = false;

    String fieldPrefix;

    String parameterPrefix;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public PIPSQLResolverEditorWindow(EnreplacedyItem<PIPResolver> enreplacedy) {
        buildMainLayout();
        setCompositionRoot(mainLayout);
        // 
        // Save
        // 
        this.enreplacedy = enreplacedy;
        // 
        // Initialize
        // 
        this.initialize();
    }

    protected boolean isSQL() {
        if (this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isSQL() || this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isHyperCSV()) {
            return true;
        }
        return false;
    }

    protected boolean isLDAP() {
        return this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isLDAP();
    }

    protected boolean isCSV() {
        return this.enreplacedy.getEnreplacedy().getPipconfiguration().getPiptype().isCSV();
    }

    protected void initialize() {
        // 
        // Initialize enreplacedy
        // 
        this.initializeEnreplacedy();
        // 
        // Go through the parameters, save them into a
        // properties object.
        // 
        boolean sourceInitialized = false;
        boolean attributeInitialized = false;
        for (PIPResolverParam param : this.enreplacedy.getEnreplacedy().getPipresolverParams()) {
            // 
            // Look for ones we know about
            // 
            if (param.getParamName().equalsIgnoreCase("select")) {
                this.textAreaSelect.setValue(param.getParamValue());
                this.textAreaSelect.setData(param);
            } else if (param.getParamName().equals("fields") || param.getParamName().equals("filter.view")) {
                this.initializeSourceTable(param.getParamValue());
                this.tableRequiredAttributes.setData(param);
                sourceInitialized = true;
            } else if (param.getParamName().equals("parameters") || param.getParamName().equals("filter.parameters")) {
                this.initializeAttributeTable(param.getParamValue());
                this.tableAttributes.setData(param);
                attributeInitialized = true;
            } else if (param.getParamName().equalsIgnoreCase("base")) {
                this.textFieldBase.setValue(param.getParamValue());
                this.textFieldBase.setData(param);
            } else if (param.getParamName().equalsIgnoreCase("filter")) {
                this.textFieldFilter.setValue(param.getParamValue());
                this.textFieldFilter.setData(param);
            }
        }
        // 
        // Initialize GUI
        // 
        this.initializeText();
        this.initializeCheckBox();
        // 
        // Verify the tables get setup, if this is a new object
        // then they haven't been.
        // 
        if (sourceInitialized == false) {
            this.initializeSourceTable("");
        }
        if (attributeInitialized == false) {
            this.initializeAttributeTable("");
        }
    }

    protected void initializeEnreplacedy() {
        // 
        // Make sure the clreplacedname is set correctly
        // 
        if (this.isSQL()) {
            // 
            // 
            // 
            this.fieldPrefix = "field.";
            this.parameterPrefix = "parameter.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableJDBCResolver.clreplaced.getCanonicalName());
        } else if (this.isLDAP()) {
            // 
            // 
            // 
            this.fieldPrefix = "filter.view.";
            this.parameterPrefix = "filter.parameters.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableLDAPResolver.clreplaced.getCanonicalName());
        } else if (this.isCSV()) {
            // 
            // 
            // 
            this.fieldPrefix = "field.";
            this.parameterPrefix = "parameter.";
            this.enreplacedy.getEnreplacedy().setClreplacedname(ConfigurableCSVResolver.clreplaced.getCanonicalName());
        }
    }

    protected void initializeText() {
        // 
        // Are we SQL or LDAP?
        // 
        if (this.isSQL()) {
            // 
            // Turn these off
            // 
            this.textFieldBase.setRequired(false);
            this.textFieldBase.setVisible(false);
            this.textFieldFilter.setRequired(false);
            this.textFieldFilter.setVisible(false);
            // 
            // GUI properties
            // 
            this.textAreaSelect.setImmediate(true);
            // 
            // Respond to changes
            // 
            this.textAreaSelect.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textAreaSelect.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("select");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textAreaSelect.setData(param);
                    }
                    param.setParamValue(self.textAreaSelect.getValue());
                    self.fireFormChangedEvent();
                }
            });
        } else if (this.isLDAP()) {
            // 
            // Turn these off
            // 
            this.textAreaSelect.setRequired(false);
            this.textAreaSelect.setVisible(false);
            // 
            // 
            // 
            this.textFieldBase.setImmediate(true);
            this.textFieldBase.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textFieldBase.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("base");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textFieldBase.setData(param);
                    }
                    param.setParamValue(self.textFieldBase.getValue());
                    self.fireFormChangedEvent();
                }
            });
            // 
            // 
            // 
            this.textFieldFilter.setImmediate(true);
            this.textFieldFilter.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    PIPResolverParam param = (PIPResolverParam) self.textFieldFilter.getData();
                    if (param == null) {
                        param = new PIPResolverParam();
                        param.setPipresolver(self.enreplacedy.getEnreplacedy());
                        param.setParamName("filter");
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                        self.textFieldFilter.setData(param);
                    }
                    param.setParamValue(self.textFieldFilter.getValue());
                    self.fireFormChangedEvent();
                }
            });
        } else if (this.isCSV()) {
            // 
            // Turn these off
            // 
            this.textAreaSelect.setRequired(false);
            this.textAreaSelect.setVisible(false);
            this.textFieldBase.setRequired(false);
            this.textFieldBase.setVisible(false);
            this.textFieldFilter.setRequired(false);
            this.textFieldFilter.setVisible(false);
        }
    }

    protected void initializeCheckBox() {
        this.checkBoxShortIds.setValue(true);
        this.checkBoxShortIds.setImmediate(true);
        this.checkBoxShortIds.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                if (self.checkBoxShortIds.getValue()) {
                    self.tableRequiredAttributes.setColumnCollapsed("id", true);
                    self.tableRequiredAttributes.setColumnCollapsed("category", true);
                    self.tableRequiredAttributes.setColumnCollapsed("datatype", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortId", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortCategory", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", false);
                } else {
                    self.tableRequiredAttributes.setColumnCollapsed("id", false);
                    self.tableRequiredAttributes.setColumnCollapsed("category", false);
                    self.tableRequiredAttributes.setColumnCollapsed("datatype", false);
                    self.tableRequiredAttributes.setColumnCollapsed("shortId", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortCategory", true);
                    self.tableRequiredAttributes.setColumnCollapsed("shortDatatype", true);
                }
            }
        });
    }

    protected void initializeSourceTable(String fields) {
        // 
        // Add data into the container
        // 
        this.populateData(this.fieldPrefix, fields, this.fieldsContainer);
        // 
        // Set GUI properties
        // 
        this.tableRequiredAttributes.setContainerDataSource(this.fieldsContainer);
        this.tableRequiredAttributes.setPageLength((this.fieldsContainer.size() == 0 ? 3 : this.fieldsContainer.size() + 1));
        this.tableRequiredAttributes.setSizeFull();
        this.tableRequiredAttributes.setColumnCollapsingAllowed(true);
        this.tableRequiredAttributes.setVisibleColumns(new Object[] { "identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype" });
        this.tableRequiredAttributes.setColumnHeaders(new String[] { "Field", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type" });
        this.tableRequiredAttributes.setColumnCollapsed("id", true);
        this.tableRequiredAttributes.setColumnCollapsed("category", true);
        this.tableRequiredAttributes.setColumnCollapsed("datatype", true);
        this.tableRequiredAttributes.setSelectable(true);
        // 
        // Setup its handler
        // 
        this.tableRequiredAttributes.addActionHandler(this);
        // 
        // Respond to events
        // 
        this.tableRequiredAttributes.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    Object id = event.gereplacedemId();
                    if (id == null) {
                        // 
                        // Really shouldn't get here
                        // 
                        return;
                    }
                    BeanItem<ResolverAttribute> beanItem = self.fieldsContainer.gereplacedem(id);
                    if (beanItem == null) {
                        // 
                        // Again, shouldn't get here
                        // 
                        return;
                    }
                    self.editAttribute(self.tableRequiredAttributes, beanItem.getBean());
                }
            }
        });
    }

    protected void initializeAttributeTable(String parameters) {
        // 
        // Add data into the container
        // 
        this.populateData(this.parameterPrefix, parameters, this.parametersContainer);
        // 
        // setup gui properties
        // 
        this.tableAttributes.setContainerDataSource(this.parametersContainer);
        this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
        this.tableAttributes.setSizeFull();
        this.tableAttributes.setColumnCollapsingAllowed(true);
        this.tableAttributes.setVisibleColumns(new Object[] { "identifier", "id", "category", "datatype", "shortId", "shortCategory", "shortDatatype" });
        this.tableAttributes.setColumnHeaders(new String[] { "Position", "Attribute Id", "Category", "Data Type", "Attribute Id", "Category", "Data Type" });
        this.tableAttributes.setColumnCollapsed("id", true);
        this.tableAttributes.setColumnCollapsed("category", true);
        this.tableAttributes.setColumnCollapsed("datatype", true);
        this.tableAttributes.setSelectable(true);
        // 
        // Setup its handler
        // 
        this.tableAttributes.addActionHandler(this);
        // 
        // Respond to events
        // 
        this.tableAttributes.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    Object id = event.gereplacedemId();
                    if (id == null) {
                        // 
                        // Really shouldn't get here
                        // 
                        return;
                    }
                    BeanItem<ResolverAttribute> beanItem = self.parametersContainer.gereplacedem(id);
                    if (beanItem == null) {
                        // 
                        // Again, shouldn't get here
                        // 
                        return;
                    }
                    self.editAttribute(self.tableAttributes, beanItem.getBean());
                }
            }
        });
    }

    protected void populateData(String prefix, String list, BeanItemContainer<ResolverAttribute> container) {
        for (String field : Splitter.on(',').trimResults().omitEmptyStrings().split(list)) {
            // 
            // Create a bean for this field
            // 
            ResolverAttribute bean = new ResolverAttribute(prefix, field);
            // 
            // Now try to find the attribute information
            // 
            for (PIPResolverParam param : this.enreplacedy.getEnreplacedy().getPipresolverParams()) {
                if (param.getParamName().equals(prefix + field + ".id")) {
                    bean.setId(param);
                } else if (param.getParamName().equals(prefix + field + ".category")) {
                    bean.setCategory(param);
                } else if (param.getParamName().equals(prefix + field + ".datatype")) {
                    bean.setDatatype(param);
                } else if (param.getParamName().equals(prefix + field + ".issuer")) {
                    bean.setIssuer(param);
                } else if (param.getParamName().equals(prefix + field + ".column")) {
                    bean.setColumn(param);
                }
            }
            container.addBean(bean);
        }
    }

    @Override
    public Action[] getActions(Object target, Object sender) {
        if (target == null) {
            return new Action[] { ADD_ATTRIBUTE };
        }
        return new Action[] { EDIT_ATTRIBUTE, CLONE_ATTRIBUTE, REMOVE_ATTRIBUTE };
    }

    @Override
    public void handleAction(Action action, Object sender, Object target) {
        if (action == ADD_ATTRIBUTE) {
            if (sender.equals(this.tableRequiredAttributes)) {
                this.editAttribute(self.tableRequiredAttributes, null);
            } else {
                this.editAttribute(self.tableAttributes, null);
            }
            return;
        }
        if (action == EDIT_ATTRIBUTE) {
            replacedert target instanceof ResolverAttribute;
            if (sender.equals(this.tableRequiredAttributes)) {
                this.editAttribute(self.tableRequiredAttributes, (ResolverAttribute) target);
            } else {
                this.editAttribute(self.tableAttributes, (ResolverAttribute) target);
            }
            return;
        }
        if (action == CLONE_ATTRIBUTE) {
            replacedert target instanceof ResolverAttribute;
            try {
                // 
                // Which table?
                // 
                if (sender.equals(this.tableRequiredAttributes)) {
                    // 
                    // Clone the attribute giving it a new
                    // field name.
                    // 
                    ResolverAttribute clone = new ResolverAttribute(this.fieldPrefix, this.getNextField(), (ResolverAttribute) target);
                    // 
                    // Add it to the container
                    // 
                    this.fieldsContainer.addBean(clone);
                    // 
                    // Reset the page length so we can see it and have room
                    // to add another.
                    // 
                    this.tableRequiredAttributes.setPageLength(this.fieldsContainer.size() + 1);
                    // 
                    // Select it
                    // 
                    this.tableRequiredAttributes.select(clone);
                } else {
                    // 
                    // Clone the attribute giving it a new
                    // field name.
                    // 
                    ResolverAttribute clone = new ResolverAttribute(this.parameterPrefix, this.getNextParameter(), (ResolverAttribute) target);
                    // 
                    // Add it to the container
                    // 
                    this.parametersContainer.addBean(clone);
                    // 
                    // Reset the page length so we can see it and have room
                    // to add another.
                    // 
                    this.tableAttributes.setPageLength(this.parametersContainer.size() + 1);
                    // 
                    // Select it
                    // 
                    this.tableAttributes.select(clone);
                }
                // 
                // We have changed
                // 
                this.fireFormChangedEvent();
            } catch (Exception e) {
                logger.error("Failed to clone: " + e);
            }
            return;
        }
        if (action == REMOVE_ATTRIBUTE) {
            replacedert target instanceof ResolverAttribute;
            // 
            // Help method to remove the attribute
            // 
            this.removeAttribute((ResolverAttribute) target);
            // 
            // Which table?
            // 
            if (sender.equals(this.tableRequiredAttributes)) {
                // 
                // Now remove it from the table
                // 
                this.tableRequiredAttributes.removeItem(target);
            } else {
                // 
                // Now remove it from the table
                // 
                this.tableAttributes.removeItem(target);
            }
            // 
            // we have changed
            // 
            this.fireFormChangedEvent();
            return;
        }
    }

    protected void removeAttribute(ResolverAttribute target) {
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getIdParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getCategoryParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getDatatypeParam());
        this.enreplacedy.getEnreplacedy().removePipresolverParam(target.getIssuerParam());
    }

    protected void editAttribute(final Table table, final ResolverAttribute request) {
        if (this.isCSV()) {
            this.editCSVAttribute(table, request);
        } else {
            this.editResolverAttribute(table, request, null);
        }
    }

    protected void editCSVAttribute(final Table table, final ResolverAttribute request) {
        replacedert this.isCSV();
        // 
        // Prompt for the column
        // 
        final ColumnSelectionWindow window = new ColumnSelectionWindow((request != null ? request.getColumn() : 0));
        if (request == null) {
            window.setCaption("Input the CSV Column for the new attribute");
        } else {
            window.setCaption("Edit the CSV Column for the attribute");
        }
        window.setModal(true);
        window.center();
        window.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                // 
                // Did the user save?
                // 
                if (window.isSaved() == false) {
                    return;
                }
                // 
                // Save it if its not a new
                // 
                if (request != null) {
                    request.setColumn(window.getColumn());
                }
                // 
                // Now we select the attribute, preplaced the column
                // in case this is a brand new attribute. Yeah its messy.
                // 
                self.editResolverAttribute(table, request, window.getColumn());
            }
        });
        window.center();
        UI.getCurrent().addWindow(window);
    }

    protected void editResolverAttribute(final Table table, final ResolverAttribute request, final Integer column) {
        // 
        // Provide objects to the attribute selection window
        // 
        AttributeDesignatorType designator = new AttributeDesignatorType();
        if (request == null) {
            designator.setAttributeId(XACML3.ID_SUBJECT_SUBJECT_ID.stringValue());
            designator.setCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue());
            designator.setDataType(XACML3.ID_DATATYPE_STRING.stringValue());
            designator.setIssuer(this.enreplacedy.getEnreplacedy().getIssuer());
        } else {
            designator.setAttributeId(request.getId());
            designator.setCategory(request.getCategory());
            designator.setDataType(request.getDatatype());
            designator.setIssuer(request.getIssuer());
        }
        // 
        // Have user select an attribute
        // 
        final AttributeSelectionWindow selection = new AttributeSelectionWindow(null, designator);
        selection.setModal(true);
        selection.setCaption("Select Attribute");
        selection.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent event) {
                // 
                // User click Save button?
                // 
                if (selection.isSaved() == false) {
                    return;
                }
                // 
                // Yes - get the final attribute
                // 
                Attribute attribute = selection.getAttribute();
                // 
                // Is it a new one?
                // 
                if (request == null) {
                    try {
                        // 
                        // Create a new bean
                        // 
                        ResolverAttribute bean = null;
                        if (table.equals(self.tableRequiredAttributes)) {
                            bean = new ResolverAttribute(self.fieldPrefix, self.getNextField());
                        } else {
                            bean = new ResolverAttribute(self.parameterPrefix, self.getNextParameter());
                        }
                        bean.setId(attribute.getXacmlId());
                        bean.setCategory(attribute.getCategoryBean().getXacmlId());
                        bean.setDatatype(attribute.getDatatypeBean().getXacmlId());
                        if (attribute.getIssuer() != null) {
                            bean.setIssuer(attribute.getIssuer());
                        }
                        if (column != null) {
                            bean.setColumn(column);
                        }
                        // 
                        // Add it to the resolver
                        // 
                        bean.setResolver(self.enreplacedy.getEnreplacedy());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getIdParam());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getCategoryParam());
                        self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getDatatypeParam());
                        if (bean.getIssuer() != null) {
                            self.enreplacedy.getEnreplacedy().addPipresolverParam(bean.getIssuerParam());
                        }
                        // 
                        // Which table?
                        // 
                        if (table.equals(self.tableRequiredAttributes)) {
                            // 
                            // Add to table
                            // 
                            self.fieldsContainer.addBean(bean);
                            // 
                            // Reset the page length
                            // 
                            self.tableRequiredAttributes.setPageLength(self.fieldsContainer.size() + 1);
                        } else if (table.equals(self.tableAttributes)) {
                            // 
                            // Add to table
                            // 
                            self.parametersContainer.addBean(bean);
                            // 
                            // Reset the page length
                            // 
                            self.tableAttributes.setPageLength(self.parametersContainer.size() + 1);
                        }
                        if (logger.isDebugEnabled()) {
                            logger.debug("Added new attribute: " + bean);
                        }
                    } catch (Exception e) {
                        logger.error(e);
                        AdminNotification.error("Unable to add another required attribute field");
                    }
                } else {
                    // 
                    // Update the table entry
                    // 
                    request.setId(attribute.getXacmlId());
                    request.setCategory(attribute.getCategoryBean().getXacmlId());
                    request.setDatatype(attribute.getDatatypeBean().getXacmlId());
                    request.setIssuer(attribute.getIssuer());
                    // 
                    // Let the table know
                    // 
                    table.refreshRowCache();
                }
                // 
                // we have changed
                // 
                self.fireFormChangedEvent();
            }
        });
        selection.center();
        UI.getCurrent().addWindow(selection);
    }

    protected String getNextField() throws Exception {
        // 
        // Start at the next index number. NOTE: The GUI needs
        // to use numbers to index the fields.
        // 
        int index = this.tableRequiredAttributes.size() + 1;
        // 
        // Really if we get to 100, that's an insane number of fields
        // needed for a SQL query.
        // 
        while (index < 100) {
            String field = String.format("%02d", index);
            boolean exists = false;
            for (Object id : this.tableRequiredAttributes.gereplacedemIds()) {
                @SuppressWarnings("unchecked")
                BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableRequiredAttributes.gereplacedem(id);
                if (required.getBean().getIdentifier().equals(field)) {
                    exists = true;
                    index++;
                    break;
                }
            }
            if (exists == false) {
                return field;
            }
        }
        // 
        // Sanity check
        // 
        throw new Exception("Unable to find a next field name. Are there too many fields?");
    }

    protected String getNextParameter() throws Exception {
        // 
        // Start at the next index number. NOTE: The GUI needs
        // to use numbers to index the fields.
        // 
        int index = this.tableAttributes.size() + 1;
        // 
        // Really if we get to 100, that's an insane number of fields
        // needed for a SQL query.
        // 
        while (index < 100) {
            String field = String.format("%02d", index);
            boolean exists = false;
            for (Object id : this.tableAttributes.gereplacedemIds()) {
                @SuppressWarnings("unchecked")
                BeanItem<ResolverAttribute> required = (BeanItem<ResolverAttribute>) this.tableAttributes.gereplacedem(id);
                if (required.getBean().getIdentifier().equals(field)) {
                    exists = true;
                    index++;
                    break;
                }
            }
            if (exists == false) {
                return field;
            }
        }
        // 
        // Sanity check
        // 
        throw new Exception("Unable to find a next parameter name. Are there too many parameters?");
    }

    public void discard() throws SourceException {
        if (this.isSQL()) {
            this.textAreaSelect.discard();
        } else if (this.isLDAP()) {
            this.textFieldBase.discard();
            this.textFieldFilter.discard();
        // } else if (this.isCSV()) {
        }
    }

    public void validate() throws InvalidValueException {
        if (this.isSQL()) {
            this.textAreaSelect.validate();
        } else if (this.isLDAP()) {
            this.textFieldBase.validate();
            this.textFieldFilter.validate();
        // } else if (this.isCSV()) {
        }
    }

    public void commit() throws SourceException, InvalidValueException {
        // 
        // Commit required fields
        // 
        if (this.isSQL()) {
            this.textAreaSelect.commit();
        } else if (this.isLDAP()) {
            this.textFieldBase.commit();
            this.textFieldFilter.commit();
        // } else if (this.isCSV()) {
        }
        // 
        // Setup the fields
        // 
        {
            List<String> fields = new ArrayList<String>(this.fieldsContainer.size());
            for (ResolverAttribute attribute : this.fieldsContainer.gereplacedemIds()) {
                fields.add(attribute.getIdentifier());
            }
            PIPResolverParam param = (PIPResolverParam) this.tableRequiredAttributes.getData();
            if (param == null) {
                param = new PIPResolverParam();
                if (this.isSQL()) {
                    param.setParamName("fields");
                } else if (this.isLDAP()) {
                    param.setParamName("filter.view");
                } else if (this.isCSV()) {
                    param.setParamName("fields");
                }
                this.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                this.tableRequiredAttributes.setData(param);
            }
            param.setParamValue(Joiner.on(',').join(fields));
        }
        // 
        // Setup the parameters
        // 
        {
            List<String> parameters = new ArrayList<String>(this.parametersContainer.size());
            for (ResolverAttribute attribute : this.parametersContainer.gereplacedemIds()) {
                parameters.add(attribute.getIdentifier());
            }
            PIPResolverParam param = (PIPResolverParam) this.tableAttributes.getData();
            if (param == null) {
                param = new PIPResolverParam();
                if (this.isSQL()) {
                    param.setParamName("parameters");
                } else if (this.isLDAP()) {
                    param.setParamName("filter.parameters");
                } else if (this.isCSV()) {
                    param.setParamName("parameters");
                }
                this.enreplacedy.getEnreplacedy().addPipresolverParam(param);
                this.tableAttributes.setData(param);
            }
            param.setParamValue(Joiner.on(',').join(parameters));
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    @Override
    public boolean addListener(FormChangedEventListener listener) {
        return this.notifier.addListener(listener);
    }

    @Override
    public boolean removeListener(FormChangedEventListener listener) {
        return this.notifier.removeListener(listener);
    }

    @Override
    public void fireFormChangedEvent() {
        this.notifier.fireFormChangedEvent();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaSelect
        textAreaSelect = new TextArea();
        textAreaSelect.setCaption("SQL Select Statement");
        textAreaSelect.setImmediate(false);
        textAreaSelect.setWidth("100.0%");
        textAreaSelect.setHeight("-1px");
        textAreaSelect.setInvalidAllowed(false);
        textAreaSelect.setRequired(true);
        mainLayout.addComponent(textAreaSelect);
        mainLayout.setExpandRatio(textAreaSelect, 1.0f);
        // textFieldBase
        textFieldBase = new TextField();
        textFieldBase.setCaption("Base DN");
        textFieldBase.setImmediate(false);
        textFieldBase.setWidth("-1px");
        textFieldBase.setHeight("-1px");
        mainLayout.addComponent(textFieldBase);
        // textFieldFilter
        textFieldFilter = new TextField();
        textFieldFilter.setCaption("Filter");
        textFieldFilter.setImmediate(false);
        textFieldFilter.setWidth("-1px");
        textFieldFilter.setHeight("-1px");
        mainLayout.addComponent(textFieldFilter);
        // checkBoxShortIds
        checkBoxShortIds = new CheckBox();
        checkBoxShortIds.setCaption("Display short id’s.");
        checkBoxShortIds.setImmediate(false);
        checkBoxShortIds.setWidth("-1px");
        checkBoxShortIds.setHeight("-1px");
        mainLayout.addComponent(checkBoxShortIds);
        // tableRequiredAttributes
        tableRequiredAttributes = new Table();
        tableRequiredAttributes.setCaption("Attributes Returned");
        tableRequiredAttributes.setImmediate(false);
        tableRequiredAttributes.setWidth("-1px");
        tableRequiredAttributes.setHeight("-1px");
        mainLayout.addComponent(tableRequiredAttributes);
        // tableAttributes
        tableAttributes = new Table();
        tableAttributes.setCaption("Parameters - Attributes Needed (i.e. ?)");
        tableAttributes.setImmediate(false);
        tableAttributes.setWidth("-1px");
        tableAttributes.setHeight("-1px");
        tableAttributes.setInvalidAllowed(false);
        tableAttributes.setRequired(true);
        mainLayout.addComponent(tableAttributes);
        return mainLayout;
    }
}

19 View Complete Implementation : PartyRankingOverviewPageModContentFactoryImpl.java
Copyright Apache License 2.0
Author : Hack23
/**
 * Creates the description.
 *
 * @return the text area
 */
private static TextArea createDescription() {
    final TextArea totalpartytoplistLabel = new TextArea("Party Ranking by topic", "Time served in Parliament:ALL:CURRENT:" + "\nTime served in Committees:ALL:CURRENT:" + "\nTime served in Government:ALL:CURRENT:" + "\nTop doreplacedent author NR:ALL:YEAR:CURRENT:*FILTER:DoreplacednetType" + "\nTop doreplacedent author SIZE:YEAR:ALL:CURRENT:*FILTER:DoreplacednetType" + "\nTop votes NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart" + "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart" + "\nTop vote party rebel NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart" + "\nTop vote presence NR/PERCENTAGE :ALL:YEAR:CURRENT::#Views:List,Timeline,BarChart,PieChart" + "\nSearch by name");
    totalpartytoplistLabel.setSizeFull();
    totalpartytoplistLabel.setStyleName("Level2Header");
    return totalpartytoplistLabel;
}

19 View Complete Implementation : GitSynchronizeWindow.java
Copyright MIT License
Author : att
public clreplaced GitSynchronizeWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSynchronize;

    @AutoGenerated
    private TextArea textAreaResults;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final GitSynchronizeWindow self = this;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public GitSynchronizeWindow() {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // 
        // 
        this.initializeButtons();
    }

    protected void initializeButtons() {
        this.buttonSynchronize.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                if (self.buttonSynchronize.getCaption().equals("Synchronize")) {
                    self.synchronize();
                } else {
                    self.close();
                }
            }
        });
    }

    protected void synchronize() {
        // 
        // Grab our working repository
        // 
        Path repoPath = ((XacmlAdminUI) getUI()).getUserGitPath();
        try {
            final Git git = Git.open(repoPath.toFile());
            PullResult result = git.pull().call();
            FetchResult fetch = result.getFetchResult();
            MergeResult merge = result.getMergeResult();
            RebaseResult rebase = result.getRebaseResult();
            if (result.isSuccessful()) {
                // 
                // TODO add more notification
                // 
                this.textAreaResults.setValue("Successful!");
            } else {
                // 
                // TODO
                // 
                this.textAreaResults.setValue("Failed.");
            }
        } catch (IOException | GitAPIException e) {
            e.printStackTrace();
        }
        this.buttonSynchronize.setCaption("Ok");
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaResults
        textAreaResults = new TextArea();
        textAreaResults.setCaption("Synch Results");
        textAreaResults.setImmediate(false);
        textAreaResults.setWidth("462px");
        textAreaResults.setHeight("222px");
        mainLayout.addComponent(textAreaResults);
        // buttonSynchronize
        buttonSynchronize = new Button();
        buttonSynchronize.setCaption("Synchronize");
        buttonSynchronize.setImmediate(true);
        buttonSynchronize.setWidth("-1px");
        buttonSynchronize.setHeight("-1px");
        mainLayout.addComponent(buttonSynchronize);
        mainLayout.setComponentAlignment(buttonSynchronize, new Alignment(24));
        return mainLayout;
    }
}

19 View Complete Implementation : SendMessageClickListener.java
Copyright GNU General Public License v3.0
Author : nfrankel
public clreplaced SendMessageClickListener implements Button.ClickListener {

    private MessageTable output;

    private TextArea input;

    public SendMessageClickListener(MessageTable output, TextArea input) {
        this.output = output;
        this.input = input;
    }

    @Override
    public void buttonClick(Button.ClickEvent event) {
        String author = VaadinSession.getCurrent().getAttribute(String.clreplaced);
        String text = input.getValue();
        Date date = new Date();
        Message message = new Message(author, text, date);
        output.addMessage(message);
        input.setValue("");
    }
}

19 View Complete Implementation : EditPDPWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced EditPDPWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textDescription;

    @AutoGenerated
    private TextField textName;

    @AutoGenerated
    private TextField textId;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final EditPDPWindow self = this;

    private final PDP pdp;

    private final List<PDPGroup> groups;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param pdp
     */
    public EditPDPWindow(PDP pdp, List<PDPGroup> list) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save data
        // 
        this.pdp = pdp;
        this.groups = list;
        // 
        // Initialize
        // 
        this.initializeText();
        this.initializeButton();
        // 
        // Keyboard short
        // 
        this.setCloseShortcut(KeyCode.ESC);
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        // 
        // Focus
        // 
        this.textId.focus();
    }

    protected void initializeText() {
        // 
        // Initialize values
        // 
        if (this.pdp != null) {
            this.textId.setValue(this.pdp.getId());
            this.textName.setValue(this.pdp.getName());
            this.textDescription.setValue(this.pdp.getDescription());
        }
        // 
        // 
        // 
        this.textId.setRequiredError("You must enter a valid id for the PDP.");
        this.textId.setNullRepresentation("");
        this.textId.addValidator(new RegexpValidator("[\\w=,]", false, "Please enter a valid URL with no whitespace or \"=\" or \",\" characters."));
        this.textId.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                // 
                // Cannot be null
                // 
                if (value == null || value.toString().length() == 0) {
                    throw new InvalidValueException("ID cannot be null.");
                }
                // 
                // Make sure its a valid URL
                // 
                try {
                    new URL(value.toString());
                } catch (MalformedURLException e) {
                    throw new InvalidValueException("The PDP URL '" + value.toString() + "' is not a valid URL: '" + e.getMessage() + "'");
                }
            }
        });
        // 
        // 
        // 
        this.textName.setNullRepresentation("");
        this.textName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                // 
                // If the value is null, set it to the id
                // 
                if (value == null || value.toString().length() == 0) {
                    return;
                }
            }
        });
        // 
        // 
        // 
        this.textDescription.setNullRepresentation("");
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Do a commit
                    // 
                    self.textName.commit();
                    self.textId.commit();
                    self.textDescription.commit();
                    // 
                    // Should be a string, but to be safe
                    // 
                    String id = self.textId.getValue();
                    String name = self.textName.getValue();
                    if (name == null || name.isEmpty()) {
                        self.textName.setValue(id);
                        name = id;
                    }
                    // 
                    // ID must be unique.
                    // Also the Name must be unique AND not match any existing IDs
                    // because user uses the NAME to identify this PDP on the browser window, not the ID.
                    // 
                    for (PDPGroup g : self.groups) {
                        for (PDP p : g.getPdps()) {
                            if (p.getId().equals(id)) {
                                if (self.pdp != null) {
                                    // 
                                    // we are editing this pdp
                                    // 
                                    continue;
                                }
                                throw new InvalidValueException("URL must be unique - the PDP '" + id + "' already exists in group '" + g.getName() + "'");
                            }
                            if (id.equals(p.getName())) {
                                throw new InvalidValueException("A previous PDP with URL '" + p.getId() + "' has been given the name '" + id + "'.  Please edit that PDP to change the name before creating a nwe PDP with this URL.");
                            }
                            if (name != null && name.length() > 0 && self.pdp == null && (p.getId().equals(name) || name.equals(p.getName()))) {
                                throw new InvalidValueException("Name must not be the same as another PDP's name OR another PDP's URL.");
                            }
                        }
                    }
                    // 
                    // make sure name is NOT a URL, unless it is identical to the ID.
                    // (If it is a URL, then a later PDP might be created with that URL as it's ID, which would be confusing.)
                    // 
                    if (!id.equals(name)) {
                        try {
                            new URL(name);
                            // if we get here the name is a URL but not identical to the id, which is not good
                            AdminNotification.warn("The Name must not be a URL unless it is the same as the PDP URL");
                            return;
                        } catch (Exception e) {
                        // NOPMD
                        // ignore - we want to get here
                        }
                    }
                    // 
                    // If we get here the inputs are ok
                    // 
                    self.isSaved = true;
                    // 
                    // 
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e1) {
                // NOPMD
                // 
                // Vaadin will display error
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getPDPId() {
        return this.textId.getValue();
    }

    public String getPDPName() {
        return this.textName.getValue();
    }

    public String getPDPDescription() {
        return this.textDescription.getValue();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textId
        textId = new TextField();
        textId.setCaption("PDP URL");
        textId.setImmediate(false);
        textId.setDescription("The URL is the ID of the PDP");
        textId.setWidth("-1px");
        textId.setHeight("-1px");
        textId.setRequired(true);
        textId.setInputPrompt("Eg. http://localhost:8080/pdp");
        mainLayout.addComponent(textId);
        // textName
        textName = new TextField();
        textName.setCaption("PDP Name");
        textName.setImmediate(false);
        textName.setWidth("-1px");
        textName.setHeight("-1px");
        mainLayout.addComponent(textName);
        // textDescription
        textDescription = new TextArea();
        textDescription.setCaption("PDP Description");
        textDescription.setImmediate(false);
        textDescription.setWidth("100.0%");
        textDescription.setHeight("-1px");
        textDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textDescription);
        mainLayout.setExpandRatio(textDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : FormHelper.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public TextArea bindTextAreaField(String fieldLabel, SingularAttribute<? super E, String> attribute, int rows) {
    TextArea field = bindTextAreaField(form, group, fieldLabel, attribute.getName(), rows);
    this.fieldList.add(field);
    return field;
}

19 View Complete Implementation : PolicyNameEditorWindow.java
Copyright MIT License
Author : att
public clreplaced PolicyNameEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(PolicyNameEditorWindow.clreplaced);

    private final PolicyNameEditorWindow self = this;

    private Object data = null;

    private String filename = null;

    private boolean isSaved = false;

    @AutoGenerated
    private FormLayout mainLayout;

    @AutoGenerated
    private ComboBox comboAlgorithms;

    @AutoGenerated
    private OptionGroup optionPolicySet;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private TextField textFieldPolicyName;

    @AutoGenerated
    private Button buttonSave;

    JPAContainer<PolicyAlgorithms> policyAlgorithms;

    JPAContainer<RuleAlgorithms> ruleAlgorithms;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param filename
     * @param policyData
     * @param policyAlgs
     * @param ruleAlgs
     */
    public PolicyNameEditorWindow(String filename, Object policyData, JPAContainer<PolicyAlgorithms> policyAlgs, JPAContainer<RuleAlgorithms> ruleAlgs) {
        buildMainLayout();
        setContent(mainLayout);
        this.mainLayout.setMargin(true);
        this.filename = filename;
        this.data = policyData;
        this.policyAlgorithms = policyAlgs;
        this.ruleAlgorithms = ruleAlgs;
        this.optionPolicySet.addItem("Policy Set");
        this.optionPolicySet.addItem("Policy");
        this.comboAlgorithms.setNewItemsAllowed(false);
        this.comboAlgorithms.setNullSelectionAllowed(false);
        this.comboAlgorithms.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.comboAlgorithms.sereplacedemCaptionPropertyId("xacmlId");
        // 
        // Setup the policy filename
        // 
        this.textFieldPolicyName.setImmediate(true);
        this.textFieldPolicyName.setNullRepresentation("");
        if (filename != null) {
            this.textFieldPolicyName.setValue(filename);
        }
        this.textFieldPolicyName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                if (value instanceof String) {
                    String filename = (String) value;
                    if (filename.endsWith(".xml")) {
                        filename = filename.substring(0, filename.length() - 4);
                    }
                    if (filename.length() == 0) {
                        throw new InvalidValueException("Invalid filename.");
                    }
                    if (filename.indexOf('.') != -1) {
                        throw new InvalidValueException("Please do not use a \'.\' in the filename.");
                    }
                }
            }
        });
        this.textFieldPolicyName.setValidationVisible(true);
        // 
        // Are we editing or creating?
        // 
        if (this.data != null) {
            // 
            // We are editing
            // 
            if (this.data instanceof PolicySetType) {
                this.optionPolicySet.setValue("Policy Set");
                this.optionPolicySet.setVisible(false);
                this.textAreaDescription.setValue(((PolicySetType) this.data).getDescription());
                this.comboAlgorithms.setContainerDataSource(policyAlgs);
                for (Object object : this.policyAlgorithms.gereplacedemIds()) {
                    PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                    if (a.getXacmlId().equals(((PolicySetType) this.data).getPolicyCombiningAlgId())) {
                        this.comboAlgorithms.select(object);
                        break;
                    }
                }
            }
            if (this.data instanceof PolicyType) {
                this.optionPolicySet.setValue("Policy");
                this.optionPolicySet.setVisible(false);
                this.textAreaDescription.setValue(((PolicyType) this.data).getDescription());
                this.comboAlgorithms.setContainerDataSource(ruleAlgs);
                for (Object object : this.ruleAlgorithms.gereplacedemIds()) {
                    RuleAlgorithms a = (RuleAlgorithms) this.ruleAlgorithms.gereplacedem(object).getEnreplacedy();
                    if (a.getXacmlId().equals(((PolicyType) this.data).getRuleCombiningAlgId())) {
                        this.comboAlgorithms.select(object);
                        break;
                    }
                }
            }
        } else {
            // 
            // Creating a new policy
            // 
            this.optionPolicySet.setValue("Policy Set");
            this.comboAlgorithms.setContainerDataSource(policyAlgs);
            this.comboAlgorithms.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
            this.comboAlgorithms.sereplacedemCaptionPropertyId("xacmlId");
            for (Object object : this.policyAlgorithms.gereplacedemIds()) {
                PolicyAlgorithms a = (PolicyAlgorithms) this.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
                    this.comboAlgorithms.select(object);
                    break;
                }
            }
            this.optionPolicySet.addValueChangeListener(new ValueChangeListener() {

                private static final long serialVersionUID = 1L;

                @Override
                public void valueChange(ValueChangeEvent event) {
                    if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
                        self.comboAlgorithms.setContainerDataSource(self.policyAlgorithms);
                        for (Object object : self.policyAlgorithms.gereplacedemIds()) {
                            PolicyAlgorithms a = (PolicyAlgorithms) self.policyAlgorithms.gereplacedem(object).getEnreplacedy();
                            if (a.getXacmlId().equals(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue())) {
                                self.comboAlgorithms.select(object);
                                break;
                            }
                        }
                    } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
                        self.comboAlgorithms.setContainerDataSource(self.ruleAlgorithms);
                        for (Object object : self.ruleAlgorithms.gereplacedemIds()) {
                            RuleAlgorithms a = (RuleAlgorithms) self.ruleAlgorithms.gereplacedem(object).getEnreplacedy();
                            if (a.getXacmlId().equals(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue())) {
                                self.comboAlgorithms.select(object);
                                break;
                            }
                        }
                    }
                }
            });
        }
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                // 
                // Make sure the policy filename was valid
                // 
                if (self.textFieldPolicyName.isValid() == false) {
                    return;
                }
                // 
                // Grab the filename (NOTE: The user may or may not
                // have changed the name).
                // 
                self.filename = self.textFieldPolicyName.getValue();
                // 
                // Make sure the filename ends with an extension
                // 
                if (self.filename.endsWith(".xml") == false) {
                    self.filename = self.filename + ".xml";
                }
                // 
                // Set ourselves as saved
                // 
                self.isSaved = true;
                // 
                // Now grab the policy file's data
                // 
                if (self.data == null) {
                    // 
                    // This is a brand new Policy
                    // 
                    if (self.optionPolicySet.getValue().toString().equals("Policy Set")) {
                        PolicySetType policySet = new PolicySetType();
                        policySet.setVersion("1");
                        policySet.setPolicySetId(((XacmlAdminUI) getUI()).newPolicyID());
                        policySet.setTarget(new TargetType());
                        self.data = policySet;
                    } else if (self.optionPolicySet.getValue().toString().equals("Policy")) {
                        PolicyType policy = new PolicyType();
                        policy.setVersion("1");
                        policy.setPolicyId(((XacmlAdminUI) getUI()).newPolicyID());
                        policy.setTarget(new TargetType());
                        self.data = policy;
                    } else {
                        logger.error("Policy option NOT setup correctly.");
                    }
                }
                if (self.data != null) {
                    // 
                    // Save off everything
                    // 
                    if (self.data instanceof PolicySetType) {
                        ((PolicySetType) self.data).setDescription(self.textAreaDescription.getValue());
                        Object a = self.comboAlgorithms.getValue();
                        PolicyAlgorithms alg = (PolicyAlgorithms) ((JPAContainerItem<?>) self.comboAlgorithms.gereplacedem(a)).getEnreplacedy();
                        ((PolicySetType) self.data).setPolicyCombiningAlgId(alg.getXacmlId());
                    } else if (self.data instanceof PolicyType) {
                        ((PolicyType) self.data).setDescription(self.textAreaDescription.getValue());
                        Object a = self.comboAlgorithms.getValue();
                        RuleAlgorithms alg = (RuleAlgorithms) ((JPAContainerItem<?>) self.comboAlgorithms.gereplacedem(a)).getEnreplacedy();
                        ((PolicyType) self.data).setRuleCombiningAlgId(alg.getXacmlId());
                    } else {
                        logger.error("Unsupported data object." + self.data.getClreplaced().getCanonicalName());
                    }
                }
                // 
                // Now we can close the window
                // 
                self.close();
            }
        });
        this.textFieldPolicyName.focus();
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public Object getPolicyData() {
        if (this.isSaved) {
            return this.data;
        }
        return null;
    }

    public String getPolicyFilename() {
        if (this.isSaved) {
            return this.filename;
        }
        return null;
    }

    @AutoGenerated
    private FormLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new FormLayout();
        mainLayout.setImmediate(false);
        // textFieldPolicyName
        textFieldPolicyName = new TextField();
        textFieldPolicyName.setCaption("Policy File Name");
        textFieldPolicyName.setImmediate(true);
        textFieldPolicyName.setWidth("-1px");
        textFieldPolicyName.setHeight("-1px");
        textFieldPolicyName.setInputPrompt("Enter filename eg. foobar.xml");
        textFieldPolicyName.setRequired(true);
        mainLayout.addComponent(textFieldPolicyName);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100%");
        textAreaDescription.setHeight("-1px");
        textAreaDescription.setInputPrompt("Enter a description for the Policy/PolicySet.");
        textAreaDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textAreaDescription);
        // optionPolicySet
        optionPolicySet = new OptionGroup();
        optionPolicySet.setCaption("Policy or PolicySet?");
        optionPolicySet.setImmediate(true);
        optionPolicySet.setDescription("Is the root level a Policy or Policy Set.");
        optionPolicySet.setWidth("-1px");
        optionPolicySet.setHeight("-1px");
        optionPolicySet.setRequired(true);
        mainLayout.addComponent(optionPolicySet);
        // comboAlgorithms
        comboAlgorithms = new ComboBox();
        comboAlgorithms.setCaption("Combining Algorithm");
        comboAlgorithms.setImmediate(false);
        comboAlgorithms.setDescription("Select the combining algorithm.");
        comboAlgorithms.setWidth("-1px");
        comboAlgorithms.setHeight("-1px");
        comboAlgorithms.setRequired(true);
        mainLayout.addComponent(comboAlgorithms);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : PolicySetEditorWindow.java
Copyright MIT License
Author : att
public clreplaced PolicySetEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private ListSelect listSelectAlgorithm;

    @AutoGenerated
    private TextField textFieldVersion;

    @AutoGenerated
    private Label labelID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final PolicySetEditorWindow self = this;

    private final PolicySetType policySet;

    private JPAContainer<PolicyAlgorithms> algorithms = ((XacmlAdminUI) UI.getCurrent()).getPolicyAlgorithms();

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param policySet
     */
    public PolicySetEditorWindow(PolicySetType policySet) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.policySet = policySet;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeLabel();
        this.initializeText();
        this.initializeSelect();
        this.initializeButton();
        // 
        // Focus
        // 
        this.textAreaDescription.focus();
    }

    protected void initializeLabel() {
        if (this.policySet.getPolicySetId() == null) {
            this.policySet.setPolicySetId(((XacmlAdminUI) UI.getCurrent()).newPolicyID());
        }
        this.labelID.setValue(this.policySet.getPolicySetId());
    }

    protected void initializeText() {
        // 
        // 
        // 
        this.textAreaDescription.setNullRepresentation("");
        this.textAreaDescription.setValue(this.policySet.getDescription());
        // 
        // 
        // 
        if (this.policySet.getVersion() == null) {
            this.policySet.setVersion("1");
        }
        this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
        this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
        this.textFieldVersion.setValue(this.policySet.getVersion());
    }

    protected void initializeSelect() {
        this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
        this.listSelectAlgorithm.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.listSelectAlgorithm.sereplacedemCaptionPropertyId("xacmlId");
        this.listSelectAlgorithm.setNullSelectionAllowed(false);
        if (this.policySet.getPolicyCombiningAlgId() == null) {
            this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
        }
        this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.listSelectAlgorithm.commit();
                    self.textFieldVersion.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    self.policySet.setDescription(self.textAreaDescription.getValue());
                    self.policySet.setVersion(self.textFieldVersion.getValue());
                    Object id = self.listSelectAlgorithm.getValue();
                    self.policySet.setPolicyCombiningAlgId(algorithms.gereplacedem(id).getEnreplacedy().getXacmlId());
                    // 
                    // Mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public PolicySetType getPolicySet() {
        return this.policySet;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelID
        labelID = new Label();
        labelID.setCaption("Policy Set ID");
        labelID.setImmediate(false);
        labelID.setWidth("100.0%");
        labelID.setHeight("-1px");
        labelID.setValue("Label");
        mainLayout.addComponent(labelID);
        // textFieldVersion
        textFieldVersion = new TextField();
        textFieldVersion.setCaption("Version");
        textFieldVersion.setImmediate(false);
        textFieldVersion.setDescription("The format is numbers only separated by decimal point.");
        textFieldVersion.setWidth("-1px");
        textFieldVersion.setHeight("-1px");
        textFieldVersion.setInvalidAllowed(false);
        textFieldVersion.setRequired(true);
        textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
        mainLayout.addComponent(textFieldVersion);
        // listSelectAlgorithm
        listSelectAlgorithm = new ListSelect();
        listSelectAlgorithm.setCaption("Policy Combining Algorithm");
        listSelectAlgorithm.setImmediate(false);
        listSelectAlgorithm.setWidth("100.0%");
        listSelectAlgorithm.setHeight("-1px");
        listSelectAlgorithm.setInvalidAllowed(false);
        listSelectAlgorithm.setRequired(true);
        mainLayout.addComponent(listSelectAlgorithm);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : GitPushWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced GitPushWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonPush;

    @AutoGenerated
    private Table tableChanges;

    @AutoGenerated
    private TextArea textAreaComments;

    /**
     */
    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(GitPushWindow.clreplaced);

    private final GitPushWindow self = this;

    private final GitStatusContainer container;

    private final Git git;

    private final File target;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param git
     * @param status
     */
    public GitPushWindow(Git git, File target, Status status) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save data
        // 
        this.git = git;
        this.target = target;
        this.container = new GitStatusContainer(status);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeText();
        this.initializeTable(status);
        this.initializeButtons();
        // 
        // Focus
        // 
        this.textAreaComments.focus();
    }

    protected void initializeText() {
        this.textAreaComments.setImmediate(true);
        this.textAreaComments.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void textChange(TextChangeEvent event) {
                if (event.getText().isEmpty()) {
                    self.buttonPush.setEnabled(false);
                } else {
                    if (self.container.getConflictCount() == 0) {
                        self.buttonPush.setEnabled(true);
                    } else {
                        self.buttonPush.setEnabled(false);
                    }
                }
            }
        });
    }

    protected void initializeTable(Status status) {
        // 
        // Setup the table
        // 
        this.tableChanges.setContainerDataSource(this.container);
        this.tableChanges.setPageLength(this.container.size());
        this.tableChanges.setImmediate(true);
        // 
        // Generate column
        // 
        this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {

            private static final long serialVersionUID = 1L;

            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Item item = self.container.gereplacedem(itemId);
                replacedert item != null;
                if (item instanceof StatusItem) {
                    return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
                }
                replacedert item instanceof StatusItem;
                return null;
            }
        });
    }

    protected Object generateGitEntryComponent(final GitEntry entry) {
        // 
        // If its conflicting, take care of it
        // 
        if (entry.isConflicting()) {
            return this.generateConflictingEntry(entry);
        }
        if (entry.isUntracked()) {
            return this.generateUntrackedEntry(entry);
        }
        /*
		if (entry.isChanged() ||
			entry.isModified() ||
			entry.isUncommitted()) {
			return this.generateUncommittedEntry(entry);
		}
		*/
        return null;
    }

    protected Object generateConflictingEntry(final GitEntry entry) {
        Button resolve = new Button("Resolve");
        resolve.setImmediate(true);
        resolve.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
            }
        });
        return resolve;
    }

    protected Object generateUntrackedEntry(final GitEntry entry) {
        Button add = new Button("Add");
        add.setImmediate(true);
        add.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    DirCache cache = self.git.add().addFilepattern(entry.getName()).call();
                    DirCacheEntry cacheEntry = cache.getEntry(entry.getName());
                    replacedert cacheEntry != null;
                    if (cacheEntry == null) {
                        return;
                    }
                    if (cacheEntry.isMerged()) {
                        self.refreshStatus();
                    }
                } catch (GitAPIException e) {
                    String error = "Failed to add: " + e.getLocalizedMessage();
                    logger.error(error);
                    AdminNotification.error(error);
                }
            }
        });
        return add;
    }

    protected Object generateUncommittedEntry(final GitEntry entry) {
        Button commit = new Button("Commit");
        commit.setImmediate(true);
        commit.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
            }
        });
        return commit;
    }

    protected void initializeButtons() {
        this.buttonPush.setEnabled(false);
        this.buttonPush.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.textAreaComments.commit();
                    // 
                    // Mark as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException idontcare) {
                // NOPMD
                // 
                // Vaadin will highlight the failed requirement or validation
                // 
                }
            }
        });
    }

    protected void refreshStatus() {
        try {
            // 
            // Grab our working repository
            // 
            Path repoPath = ((XacmlAdminUI) getUI()).getUserGitPath();
            final Git git = Git.open(repoPath.toFile());
            // 
            // Get our status
            // 
            final String base;
            Status status;
            if (target == null) {
                base = ".";
            } else {
                Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
                base = relativePath.toString();
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Status on base: " + base);
            }
            status = git.status().addPath(base).call();
            // 
            // Preplaced it to our container
            // 
            this.container.refreshStatus(status);
            this.tableChanges.refreshRowCache();
        } catch (NoWorkTreeException | IOException | GitAPIException e) {
            String error = "Failed to refresh status: " + e.getLocalizedMessage();
            logger.error(error);
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getComment() {
        return this.textAreaComments.getValue();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaComments
        textAreaComments = new TextArea();
        textAreaComments.setCaption("Add Comments");
        textAreaComments.setImmediate(false);
        textAreaComments.setDescription("Enter comments that reflect the changes you have made to the repository domains and/or policy files.");
        textAreaComments.setWidth("400px");
        textAreaComments.setHeight("-1px");
        textAreaComments.setInvalidAllowed(false);
        textAreaComments.setRequired(true);
        textAreaComments.setInputPrompt("Eg. Add new rule for employees in marketing department.");
        mainLayout.addComponent(textAreaComments);
        // tableChanges
        tableChanges = new Table();
        tableChanges.setCaption("Changes To Be Pushed");
        tableChanges.setImmediate(false);
        tableChanges.setWidth("100.0%");
        tableChanges.setHeight("-1px");
        mainLayout.addComponent(tableChanges);
        mainLayout.setExpandRatio(tableChanges, 1.0f);
        // buttonPush
        buttonPush = new Button();
        buttonPush.setCaption("Push Changes");
        buttonPush.setImmediate(true);
        buttonPush.setWidth("-1px");
        buttonPush.setHeight("-1px");
        mainLayout.addComponent(buttonPush);
        mainLayout.setComponentAlignment(buttonPush, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : RepositoryForm.java
Copyright BSD 3-Clause "New" or "Revised" License
Author : doecode
/**
 * the basic UI/Form for editing software metadata.
 *
 * Extends and implements FormLayout for styling.  Attributes should be named
 * the same as corresponding values in the underlying Bean object (SoftwareRepository).
 *
 * @author ensornl
 */
public clreplaced RepositoryForm extends FormLayout {

    private TextField siteOwnershipCode = new TextField("Site");

    private CheckBox openSource = new CheckBox("Open Source?");

    private TextField name = new TextField("replacedle/Name");

    private TextField acronym = new TextField("Acronym");

    private TextField url = new TextField("URL");

    private TextField doi = new TextField("DOI");

    private NativeSelect countryCode = new NativeSelect("Country");

    private TextField keywords = new TextField("Keywords");

    private TextField rights = new TextField("Rights/Disclaimers");

    private TextField license = new TextField("License");

    private TextField operatingSystem = new TextField("Operating System");

    private TextField siteAccessionNumber = new TextField("Site Accession Number");

    private TextArea otherRequirements = new TextArea("Other Requirements");

    private TextArea description = new TextArea("Description");

    // display items for child tables
    private Grid agentGrid = new Grid("");

    private Grid idGrid = new Grid("");

    private Button loadButton = new Button("Load");

    private Button save = new Button("Save");

    private MyUI ui;

    private SoftwareRepository repository = new SoftwareRepository();

    private AgentForm agentForm;

    private IdentifierForm idForm;

    // a static listing of Country Codes for drop down
    public static final String[] countryCodes = { "US", "FR", "GB", "DE", "ES" };

    /**
     * Preplaced through to add Identifier Objects to the software metadata.
     * @param id the Identifier to add
     * @return true if something was added, false if not
     */
    public boolean add(Identifier id) {
        if (repository.add(id)) {
            updateIdentifierList();
            return true;
        }
        return false;
    }

    /**
     * Remove a given Identifier from the list.
     * @param id the Identifier to remove
     * @return true if something changed, false if not
     */
    public boolean remove(Identifier id) {
        if (repository.remove(id)) {
            updateIdentifierList();
            return true;
        }
        return false;
    }

    /**
     * Add an Agent to the software list.
     *
     * @param a the Agent to add
     * @return true if changes took place, false if not
     */
    public boolean add(Agent a) {
        if (repository.add(a)) {
            updateAgentList();
            return true;
        }
        return false;
    }

    /**
     * Remove an Agent from the list
     * @param a the Agent to remove
     * @return true if something changed, false if not
     */
    public boolean remove(Agent a) {
        if (repository.remove(a)) {
            updateAgentList();
            return true;
        }
        return false;
    }

    /**
     * Update/paint the agent Grid.
     */
    private void updateAgentList() {
        List<Agent> agents = repository.getAgents();
        agentGrid.setContainerDataSource(new BeanItemContainer<>(Agent.clreplaced, agents));
        agentGrid.markAsDirty();
    }

    /**
     * Reset the identifier list/grid.
     */
    private void updateIdentifierList() {
        List<Identifier> identifiers = repository.getIdentifiers();
        idGrid.setContainerDataSource(new BeanItemContainer<>(Identifier.clreplaced, identifiers));
        idGrid.markAsDirty();
    }

    /**
     * Create a basic form UI for editing software metadata information.
     *
     * @param ui link to the MyUI parent UI
     */
    public RepositoryForm(MyUI ui) {
        this.ui = ui;
        setSizeUndefined();
        agentGrid.setColumns("firstName", "lastName", "email");
        agentGrid.setHeightMode(HeightMode.ROW);
        agentGrid.setHeightByRows(8);
        idGrid.setColumns("relationType", "identifierType", "value");
        idGrid.setHeightMode(HeightMode.ROW);
        idGrid.setHeightByRows(8);
        idForm = new IdentifierForm(this);
        agentForm = new AgentForm(this);
        TabSheet tabs = new TabSheet();
        tabs.addStyleName(ValoTheme.TABSHEET_FRAMED);
        tabs.addStyleName(ValoTheme.TABSHEET_PADDED_TABBAR);
        addComponent(tabs);
        HorizontalLayout main = new HorizontalLayout();
        main.setSpacing(true);
        main.setMargin(true);
        FormLayout left = new FormLayout();
        FormLayout right = new FormLayout();
        countryCode.addItems(countryCodes);
        left.addComponents(url, loadButton, name, openSource, siteOwnershipCode, acronym, doi, countryCode);
        right.addComponents(keywords, rights, license, operatingSystem, siteAccessionNumber, otherRequirements);
        loadButton.addClickListener(e -> {
            try {
                SoftwareRepository repo = Reader.loadRepository("doecode");
                setSoftwareRepository(repo);
            } catch (IOException ex) {
                setComponentError(new UserError("Unable to load: " + ex.getMessage()));
            }
        });
        main.addComponents(left, right);
        tabs.addTab(main, "Metadata");
        Button agentAddButton = new Button("New");
        agentAddButton.setStyleName(BaseTheme.BUTTON_LINK);
        agentAddButton.setIcon(FontAwesome.PLUS);
        agentAddButton.addClickListener(e -> {
            agentForm.setAgent(new Agent());
        });
        VerticalLayout innerAgent = new VerticalLayout(agentAddButton, agentGrid);
        innerAgent.setSizeUndefined();
        HorizontalLayout agentLayout = new HorizontalLayout(innerAgent, agentForm);
        agentLayout.setSpacing(true);
        agentLayout.setMargin(true);
        tabs.addTab(agentLayout, "Agents");
        Button idAddButton = new Button("New");
        idAddButton.setIcon(FontAwesome.PLUS);
        idAddButton.setStyleName(BaseTheme.BUTTON_LINK);
        idAddButton.setSizeUndefined();
        idAddButton.addClickListener(e -> {
            idForm.setIdentifier(new Identifier());
        });
        VerticalLayout innerId = new VerticalLayout(idAddButton, idGrid);
        HorizontalLayout idTab = new HorizontalLayout(innerId, idForm);
        idTab.setSpacing(true);
        idTab.setMargin(true);
        tabs.addTab(idTab, "Identifiers");
        agentGrid.addSelectionListener(e -> {
            if (!e.getSelected().isEmpty()) {
                Agent agent = (Agent) e.getSelected().iterator().next();
                agentForm.setAgent(agent);
                System.out.println("Selected " + agent.getFirstName());
            }
        });
        idGrid.addSelectionListener(e -> {
            if (!e.getSelected().isEmpty()) {
                Identifier identifier = (Identifier) e.getSelected().iterator().next();
                idForm.setIdentifier(identifier);
            }
        });
    }

    public void setSoftwareRepository(SoftwareRepository r) {
        repository = r;
        BeanFieldGroup.bindFieldsUnbuffered(r, this);
        updateAgentList();
        updateIdentifierList();
        setVisible(true);
        name.selectAll();
    }
}

19 View Complete Implementation : NoteLayout.java
Copyright Apache License 2.0
Author : apache
public clreplaced NoteLayout extends AbsoluteLayout {

    private static final Logger LOG = LoggerFactory.getLogger(NoteLayout.clreplaced);

    private NoteDao noteDao = InjectorFactory.getInstance(NoteDao.clreplaced);

    private TextArea textArea;

    private Button editButton;

    private Button saveButton;

    private Button cancelButton;

    private String commitId;

    private int runNumber;

    private String oldText;

    public NoteLayout() {
        init();
        addButtons();
        textArea = UIUtil.addTextArea(this, "", "left: 0px; top: 35px;", "250px", "100px", true);
    }

    private void init() {
        setWidth("250px");
        setHeight("250px");
    }

    private void addButtons() {
        UIUtil.addLabel(this, "Note:", "left: 0px; top: 10px;", "120px");
        editButton = createButton("Edit", "left: 210px; top: 10px;", true);
        editButton.addClickListener(new Button.ClickListener() {

            public void buttonClick(Button.ClickEvent event) {
                edit();
            }
        });
        saveButton = createButton("Save", "left: 170px; top: 10px;", false);
        saveButton.addClickListener(new Button.ClickListener() {

            public void buttonClick(Button.ClickEvent event) {
                save();
                cancel();
            }
        });
        cancelButton = createButton("Cancel", "left: 210px; top: 10px;", false);
        cancelButton.addClickListener(new Button.ClickListener() {

            public void buttonClick(Button.ClickEvent event) {
                restoreText();
                cancel();
            }
        });
    }

    private void restoreText() {
        textArea.setValue(oldText);
    }

    private Button createButton(String caption, String position, boolean visible) {
        Button button = UIUtil.addButton(this, caption, position, "50px");
        button.setStyleName(Reindeer.BUTTON_LINK);
        button.setVisible(visible);
        return button;
    }

    private void edit() {
        editButton.setVisible(false);
        saveButton.setVisible(true);
        cancelButton.setVisible(true);
        textArea.setReadOnly(false);
    }

    private void cancel() {
        editButton.setVisible(true);
        saveButton.setVisible(false);
        cancelButton.setVisible(false);
        textArea.setReadOnly(true);
    }

    private void save() {
        Note note = new Note(commitId, runNumber, textArea.getValue());
        try {
            noteDao.save(note);
        } catch (IOException e) {
            LOG.error("Exception while saving a note: ", e);
        }
    }

    private void doLoad(String commitId, int runNumber) {
        this.commitId = commitId;
        this.runNumber = runNumber;
        Note note = noteDao.get(commitId, runNumber);
        oldText = note != null ? note.getText() : "";
        textArea.setReadOnly(false);
        textArea.setValue(oldText);
    }

    public void load(String commitId, int runNumber) {
        doLoad(commitId, runNumber);
        cancel();
    }
}

19 View Complete Implementation : AbstractTagLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
protected void setTagDesc(final TextArea tagDesc) {
    this.tagDesc = tagDesc;
}

19 View Complete Implementation : AbstractMetadataPopupLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * Abstract pop up layout
 *
 * @param <E>
 *            E id the enreplacedy for which metadata is displayed
 * @param <M>
 *            M is the metadata
 */
public abstract clreplaced AbstractMetadataPopupLayout<E extends NamedEnreplacedy, M extends MetaData> extends CustomComponent {

    private static final long serialVersionUID = 1L;

    private static final String DELETE_BUTTON = "DELETE_BUTTON";

    private static final int INPUT_DEBOUNCE_TIMEOUT = 250;

    protected static final String VALUE = "value";

    protected static final String KEY = "key";

    protected static final int MAX_METADATA_QUERY = 500;

    protected VaadinMessageSource i18n;

    private final UINotification uiNotification;

    protected transient EventBus.UIEventBus eventBus;

    private TextField keyTextField;

    private TextArea valueTextArea;

    private Button addIcon;

    private Grid metaDataGrid;

    private Label headerCaption;

    private CommonDialogWindow metadataWindow;

    private E selectedEnreplacedy;

    private HorizontalLayout mainLayout;

    protected SpPermissionChecker permChecker;

    protected AbstractMetadataPopupLayout(final VaadinMessageSource i18n, final UINotification uiNotification, final UIEventBus eventBus, final SpPermissionChecker permChecker) {
        this.i18n = i18n;
        this.uiNotification = uiNotification;
        this.eventBus = eventBus;
        this.permChecker = permChecker;
        createComponents();
        buildLayout();
    }

    /**
     * Save the metadata and never close the window after saving.
     */
    private final clreplaced SaveOnDialogCloseListener implements SaveDialogCloseListener {

        @Override
        public void saveOrUpdate() {
            onSave();
        }

        @Override
        public boolean canWindowClose() {
            return false;
        }

        @Override
        public boolean canWindowSaveOrUpdate() {
            return true;
        }
    }

    /**
     * Returns metadata popup.
     *
     * @param enreplacedy
     *            enreplacedy for which metadata data is displayed
     * @param metaDatakey
     *            metadata key to be selected
     * @return {@link CommonDialogWindow}
     */
    public CommonDialogWindow getWindow(final E enreplacedy, final String metaDatakey) {
        selectedEnreplacedy = enreplacedy;
        metadataWindow = new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(getMetadataCaption()).content(this).cancelButtonClickListener(event -> onCancel()).id(UIComponentIdProvider.METADATA_POPUP_ID).layout(mainLayout).i18n(i18n).saveDialogCloseListener(new SaveOnDialogCloseListener()).buildCommonDialogWindow();
        metadataWindow.setHeight(550, Unit.PIXELS);
        metadataWindow.setWidth(800, Unit.PIXELS);
        metadataWindow.getMainLayout().setSizeFull();
        metadataWindow.getButtonsLayout().setHeight("45px");
        setUpDetails(enreplacedy.getId(), metaDatakey);
        return metadataWindow;
    }

    public E getSelectedEnreplacedy() {
        return selectedEnreplacedy;
    }

    public void setSelectedEnreplacedy(final E selectedEnreplacedy) {
        this.selectedEnreplacedy = selectedEnreplacedy;
    }

    protected abstract boolean checkForDuplicate(E enreplacedy, String value);

    protected abstract M createMetadata(E enreplacedy, String key, String value);

    protected abstract M updateMetadata(E enreplacedy, String key, String value);

    protected abstract List<M> getMetadataList();

    protected abstract void deleteMetadata(E enreplacedy, String key);

    protected abstract boolean hasCreatePermission();

    protected abstract boolean hasUpdatePermission();

    protected void createComponents() {
        keyTextField = createKeyTextField();
        valueTextArea = createValueTextField();
        metaDataGrid = createMetadataGrid();
        addIcon = createAddIcon();
        headerCaption = createHeaderCaption();
    }

    private void buildLayout() {
        final HorizontalLayout headerLayout = new HorizontalLayout();
        headerLayout.addStyleName(SPUIStyleDefinitions.WIDGET_replacedLE);
        headerLayout.setSpacing(false);
        headerLayout.setMargin(false);
        headerLayout.setSizeFull();
        headerLayout.addComponent(headerCaption);
        if (hasCreatePermission()) {
            headerLayout.addComponents(addIcon);
            headerLayout.setComponentAlignment(addIcon, Alignment.MIDDLE_RIGHT);
        }
        headerLayout.setExpandRatio(headerCaption, 1.0F);
        final HorizontalLayout headerWrapperLayout = new HorizontalLayout();
        headerWrapperLayout.addStyleName("bordered-layout" + " " + "no-border-bottom" + " " + "metadata-table-margin");
        headerWrapperLayout.addComponent(headerLayout);
        headerWrapperLayout.setWidth("100%");
        headerLayout.setHeight("30px");
        final VerticalLayout tableLayout = new VerticalLayout();
        tableLayout.setSizeFull();
        tableLayout.setHeight("100%");
        tableLayout.addComponent(headerWrapperLayout);
        tableLayout.addComponent(metaDataGrid);
        tableLayout.addStyleName("table-layout");
        tableLayout.setExpandRatio(metaDataGrid, 1.0F);
        final VerticalLayout metadataFieldsLayout = createMetadataFieldsLayout();
        mainLayout = new HorizontalLayout();
        mainLayout.addComponent(tableLayout);
        mainLayout.addComponent(metadataFieldsLayout);
        mainLayout.setExpandRatio(tableLayout, 0.5F);
        mainLayout.setExpandRatio(metadataFieldsLayout, 0.5F);
        mainLayout.setSizeFull();
        mainLayout.setSpacing(true);
        setCompositionRoot(mainLayout);
        setSizeFull();
    }

    protected VerticalLayout createMetadataFieldsLayout() {
        final VerticalLayout metadataFieldsLayout = new VerticalLayout();
        metadataFieldsLayout.setSizeFull();
        metadataFieldsLayout.setHeight("100%");
        metadataFieldsLayout.addComponent(keyTextField);
        metadataFieldsLayout.addComponent(valueTextArea);
        metadataFieldsLayout.setSpacing(true);
        metadataFieldsLayout.setExpandRatio(valueTextArea, 1F);
        return metadataFieldsLayout;
    }

    private TextField createKeyTextField() {
        final TextField keyField = new TextFieldBuilder(MetaData.KEY_MAX_SIZE).caption(i18n.getMessage("textfield.key")).required(true, i18n).id(UIComponentIdProvider.METADATA_KEY_FIELD_ID).buildTextComponent();
        keyField.addTextChangeListener(this::onKeyChange);
        keyField.setTextChangeEventMode(TextChangeEventMode.LAZY);
        keyField.setTextChangeTimeout(INPUT_DEBOUNCE_TIMEOUT);
        keyField.setWidth("100%");
        return keyField;
    }

    private TextArea createValueTextField() {
        valueTextArea = new TextAreaBuilder(MetaData.VALUE_MAX_SIZE).caption(i18n.getMessage("textfield.value")).required(true, i18n).id(UIComponentIdProvider.METADATA_VALUE_ID).buildTextComponent();
        valueTextArea.setSizeFull();
        valueTextArea.setHeight(100, Unit.PERCENTAGE);
        valueTextArea.addTextChangeListener(this::onValueChange);
        valueTextArea.setTextChangeEventMode(TextChangeEventMode.LAZY);
        valueTextArea.setTextChangeTimeout(INPUT_DEBOUNCE_TIMEOUT);
        return valueTextArea;
    }

    protected Grid createMetadataGrid() {
        final Grid metadataGrid = new Grid();
        metadataGrid.addStyleName(SPUIStyleDefinitions.METADATA_GRID);
        metadataGrid.setImmediate(true);
        metadataGrid.setHeight("100%");
        metadataGrid.setWidth("100%");
        metadataGrid.setId(UIComponentIdProvider.METDATA_TABLE_ID);
        metadataGrid.setSelectionMode(SelectionMode.SINGLE);
        metadataGrid.setColumnReorderingAllowed(true);
        metadataGrid.setContainerDataSource(getMetadataContainer());
        metadataGrid.getColumn(KEY).setHeaderCaption(i18n.getMessage("header.key"));
        metadataGrid.getColumn(VALUE).setHeaderCaption(i18n.getMessage("header.value"));
        metadataGrid.getColumn(VALUE).setHidden(true);
        metadataGrid.addSelectionListener(this::onRowClick);
        metadataGrid.getColumn(DELETE_BUTTON).setHeaderCaption("");
        metadataGrid.getColumn(DELETE_BUTTON).setRenderer(new HtmlButtonRenderer(this::onDelete));
        metadataGrid.getColumn(DELETE_BUTTON).setWidth(50);
        metadataGrid.getColumn(KEY).setExpandRatio(1);
        return metadataGrid;
    }

    private void onDelete(final RendererClickEvent event) {
        final Item item = metaDataGrid.getContainerDataSource().gereplacedem(event.gereplacedemId());
        final String key = (String) item.gereplacedemProperty(KEY).getValue();
        final ConfirmationDialog confirmDialog = new ConfirmationDialog(i18n.getMessage("caption.enreplacedy.delete.action.confirmbox"), i18n.getMessage("message.confirm.delete.metadata", key), i18n.getMessage(UIMessageIdProvider.BUTTON_OK), i18n.getMessage(UIMessageIdProvider.BUTTON_CANCEL), ok -> {
            if (ok) {
                handleOkDeleteMetadata(event, key);
            }
        });
        UI.getCurrent().addWindow(confirmDialog.getWindow());
        confirmDialog.getWindow().bringToFront();
    }

    private void handleOkDeleteMetadata(final RendererClickEvent event, final String key) {
        deleteMetadata(getSelectedEnreplacedy(), key);
        uiNotification.displaySuccess(i18n.getMessage("message.metadata.deleted.successfully", key));
        final Object selectedRow = metaDataGrid.getSelectedRow();
        metaDataGrid.getContainerDataSource().removeItem(event.gereplacedemId());
        // force grid to refresh
        metaDataGrid.clearSortOrder();
        if (!metaDataGrid.getContainerDataSource().gereplacedemIds().isEmpty()) {
            if (selectedRow != null) {
                if (selectedRow.equals(event.gereplacedemId())) {
                    metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
                } else {
                    metaDataGrid.select(selectedRow);
                }
            }
        } else {
            resetFields();
        }
    }

    private void resetFields() {
        clearFields();
        metaDataGrid.select(null);
        if (hasCreatePermission()) {
            enableEditing();
            addIcon.setEnabled(false);
        }
    }

    private Button createAddIcon() {
        addIcon = SPUIComponentProvider.getButton(UIComponentIdProvider.METADTA_ADD_ICON_ID, i18n.getMessage("button.save"), null, null, false, FontAwesome.PLUS, SPUIButtonStyleNoBorder.clreplaced);
        addIcon.addClickListener(event -> onAdd());
        return addIcon;
    }

    private Label createHeaderCaption() {
        return new LabelBuilder().name(i18n.getMessage("caption.metadata")).buildCaptionLabel();
    }

    private static IndexedContainer getMetadataContainer() {
        final IndexedContainer swcontactContainer = new IndexedContainer();
        swcontactContainer.addContainerProperty(KEY, String.clreplaced, "");
        swcontactContainer.addContainerProperty(VALUE, String.clreplaced, "");
        swcontactContainer.addContainerProperty(DELETE_BUTTON, String.clreplaced, FontAwesome.TRASH_O.getHtml());
        return swcontactContainer;
    }

    protected Item popualateKeyValue(final Object metadataCompositeKey) {
        if (metadataCompositeKey != null) {
            final Item item = metaDataGrid.getContainerDataSource().gereplacedem(metadataCompositeKey);
            keyTextField.setValue((String) item.gereplacedemProperty(KEY).getValue());
            valueTextArea.setValue((String) item.gereplacedemProperty(VALUE).getValue());
            keyTextField.setEnabled(false);
            if (hasUpdatePermission()) {
                valueTextArea.setEnabled(true);
            }
            return item;
        }
        return null;
    }

    private void populateGrid() {
        final List<M> metadataList = getMetadataList();
        for (final M metaData : metadataList) {
            addItemToGrid(metaData);
        }
    }

    protected Item addItemToGrid(final M metaData) {
        final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
        final Item item = metadataContainer.addItem(metaData.getKey());
        item.gereplacedemProperty(VALUE).setValue(metaData.getValue());
        item.gereplacedemProperty(KEY).setValue(metaData.getKey());
        return item;
    }

    protected Item updateItemInGrid(final String key) {
        final IndexedContainer metadataContainer = (IndexedContainer) metaDataGrid.getContainerDataSource();
        final Item item = metadataContainer.gereplacedem(key);
        item.gereplacedemProperty(VALUE).setValue(valueTextArea.getValue());
        return item;
    }

    private void onAdd() {
        metaDataGrid.deselect(metaDataGrid.getSelectedRow());
        clearFields();
        enableEditing();
        addIcon.setEnabled(true);
    }

    protected void clearFields() {
        valueTextArea.clear();
        keyTextField.clear();
    }

    protected void onSave() {
        final String key = keyTextField.getValue();
        final String value = valueTextArea.getValue();
        if (mandatoryCheck()) {
            final E enreplacedy = selectedEnreplacedy;
            if (metaDataGrid.getSelectedRow() == null) {
                if (!duplicateCheck(enreplacedy)) {
                    final M metadata = createMetadata(enreplacedy, key, value);
                    uiNotification.displaySuccess(i18n.getMessage("message.metadata.saved", metadata.getKey()));
                    addItemToGrid(metadata);
                    metaDataGrid.scrollToEnd();
                    metaDataGrid.select(metadata.getKey());
                    addIcon.setEnabled(true);
                    metadataWindow.setSaveButtonEnabled(false);
                    if (!hasUpdatePermission()) {
                        valueTextArea.setEnabled(false);
                    }
                }
            } else {
                final M metadata = updateMetadata(enreplacedy, key, value);
                uiNotification.displaySuccess(i18n.getMessage("message.metadata.updated", metadata.getKey()));
                updateItemInGrid(metadata.getKey());
                metaDataGrid.select(metadata.getKey());
                addIcon.setEnabled(true);
                metadataWindow.setSaveButtonEnabled(false);
            }
        }
    }

    private boolean mandatoryCheck() {
        if (keyTextField.getValue().isEmpty()) {
            uiNotification.displayValidationError(i18n.getMessage("message.key.missing"));
            return false;
        }
        if (valueTextArea.getValue().isEmpty()) {
            uiNotification.displayValidationError(i18n.getMessage("message.value.missing"));
            return false;
        }
        return true;
    }

    private boolean duplicateCheck(final E enreplacedy) {
        if (!checkForDuplicate(enreplacedy, keyTextField.getValue())) {
            return false;
        }
        uiNotification.displayValidationError(i18n.getMessage("message.metadata.duplicate.check", keyTextField.getValue()));
        return true;
    }

    private String getMetadataCaption() {
        final StringBuilder caption = new StringBuilder();
        caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_START + i18n.getMessage("caption.metadata.popup") + " " + HawkbitCommonUtil.getBoldHTMLText(getElementreplacedle()));
        caption.append(HawkbitCommonUtil.DIV_DESCRIPTION_END);
        return caption.toString();
    }

    protected String getElementreplacedle() {
        return getSelectedEnreplacedy().getName();
    }

    private void onCancel() {
        metadataWindow.close();
        UI.getCurrent().removeWindow(metadataWindow);
    }

    private void onKeyChange(final TextChangeEvent event) {
        if (hasCreatePermission() || hasUpdatePermission()) {
            if (!valueTextArea.getValue().isEmpty() && !event.getText().isEmpty()) {
                metadataWindow.setSaveButtonEnabled(true);
            } else {
                metadataWindow.setSaveButtonEnabled(false);
            }
        }
    }

    protected void onRowClick(final SelectionEvent event) {
        final Set<Object> itemsSelected = event.getSelected();
        if (!itemsSelected.isEmpty()) {
            popualateKeyValue(itemsSelected.iterator().next());
            addIcon.setEnabled(true);
        } else {
            clearFields();
            if (hasCreatePermission()) {
                enableEditing();
                addIcon.setEnabled(false);
            } else {
                keyTextField.setEnabled(false);
                valueTextArea.setEnabled(false);
            }
        }
        metadataWindow.setSaveButtonEnabled(false);
    }

    protected void enableEditing() {
        keyTextField.setEnabled(true);
        valueTextArea.setEnabled(true);
    }

    private void onValueChange(final TextChangeEvent event) {
        if (hasCreatePermission() || hasUpdatePermission()) {
            if (!keyTextField.getValue().isEmpty() && !event.getText().isEmpty()) {
                metadataWindow.setSaveButtonEnabled(true);
            } else {
                metadataWindow.setSaveButtonEnabled(false);
            }
        }
    }

    private void setUpDetails(final Long swId, final String metaDatakey) {
        resetDetails();
        metadataWindow.clearOriginalValues();
        if (swId != null) {
            metaDataGrid.getContainerDataSource().removeAllItems();
            populateGrid();
            metaDataGrid.getSelectionModel().reset();
            if (!metaDataGrid.getContainerDataSource().gereplacedemIds().isEmpty()) {
                if (metaDatakey == null) {
                    metaDataGrid.select(metaDataGrid.getContainerDataSource().getIdByIndex(0));
                } else {
                    metaDataGrid.select(metaDatakey);
                }
            } else if (hasCreatePermission()) {
                enableEditing();
                addIcon.setEnabled(false);
            }
        }
    }

    private void resetDetails() {
        clearFields();
        disableEditing();
        metadataWindow.setSaveButtonEnabled(false);
        addIcon.setEnabled(true);
    }

    protected void disableEditing() {
        keyTextField.setEnabled(false);
        valueTextArea.setEnabled(false);
    }

    protected TextArea getValueTextArea() {
        return valueTextArea;
    }

    protected TextField getKeyTextField() {
        return keyTextField;
    }

    protected CommonDialogWindow getMetadataWindow() {
        return metadataWindow;
    }
}

19 View Complete Implementation : ApplyEditorWindow.java
Copyright MIT License
Author : att
public clreplaced ApplyEditorWindow extends Window implements ApplyParametersChangedNotifier {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSelect;

    @AutoGenerated
    private Table tableFunction;

    @AutoGenerated
    private HorizontalLayout horizontalLayout_1;

    @AutoGenerated
    private CheckBox checkBoxFilterIsBag;

    @AutoGenerated
    private ComboBox comboBoxDatatypeFilter;

    @AutoGenerated
    private TextField textFieldFilter;

    @AutoGenerated
    private TextArea textAreaDescription;

    /**
     */
    private static final long serialVersionUID = 1L;

    private static Log logger = LogFactory.getLog(ApplyEditorWindow.clreplaced);

    private final ApplyEditorWindow self = this;

    private final ApplyParametersChangedNotifier notifier = new ApplyParametersChangedNotifier.BasicNotifier();

    private final BeanItemContainer<FunctionDefinition> container = new BeanItemContainer<FunctionDefinition>(FunctionDefinition.clreplaced);

    private final ApplyType apply;

    private final ApplyType applyParent;

    private final FunctionArgument argument;

    private final Object parent;

    private boolean isSaved = false;

    private FunctionDefinition function = null;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param apply
     * @param parent
     * @param parentApply
     * @param argument
     */
    public ApplyEditorWindow(ApplyType apply, ApplyType parentApply, FunctionArgument argument, Object parent) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.apply = apply;
        this.applyParent = parentApply;
        this.argument = argument;
        this.parent = parent;
        logger.info(this.apply + " " + this.applyParent + " " + this.argument + " " + this.parent);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize
        // 
        this.textAreaDescription.setValue(apply.getDescription());
        this.textAreaDescription.setNullRepresentation("");
        this.initializeButton();
        this.initializeTable();
        this.initializeFilters();
        // 
        // focus
        // 
        this.textFieldFilter.focus();
    }

    protected void initializeTable() {
        // 
        // Setup GUI properties
        // 
        this.tableFunction.setImmediate(true);
        this.tableFunction.setSelectable(true);
        this.tableFunction.setNullSelectionAllowed(false);
        this.tableFunction.setRequired(true);
        this.tableFunction.setRequiredError("You MUST select a function for the Apply");
        // 
        // Set its data source
        // 
        this.tableFunction.setContainerDataSource(this.container);
        this.tableFunction.setVisibleColumns(new Object[] { "xacmlid", "shortname", "datatypeBean", "isBagReturn" });
        this.tableFunction.setColumnHeaders(new String[] { "Function Xacml ID", "ID", "Return Data Type", "Return Bag?" });
        // 
        // Determine appropriate filters
        // 
        Datatype datatypeId = null;
        if (this.applyParent == null) {
            if (this.parent instanceof ConditionType) {
                // 
                // Only boolean functions allowed
                // 
                datatypeId = JPAUtils.findDatatype(XACML3.ID_DATATYPE_BOOLEAN);
            }
        } else {
            String parentFunction = this.applyParent.getFunctionId();
            this.function = JPAUtils.findFunction(parentFunction);
            if (this.function == null) {
                throw new IllegalArgumentException("applyParent's function is not found:" + parentFunction);
            }
            if (this.argument == null) {
                throw new IllegalArgumentException("Need to know what argument apply is ");
            }
            datatypeId = this.argument.getDatatypeBean();
        }
        Map<Datatype, List<FunctionDefinition>> functionMap = JPAUtils.getFunctionDatatypeMap();
        if (datatypeId == null) {
            // 
            // All functions are available
            // 
            for (Datatype id : functionMap.keySet()) {
                this.addTableEntries(functionMap.get(id));
            }
        } else {
            for (Datatype id : functionMap.keySet()) {
                if (id == null) {
                    if (datatypeId == null) {
                        this.addTableEntries(functionMap.get(id));
                        break;
                    }
                    continue;
                }
                if (id.getId() == datatypeId.getId()) {
                    this.addTableEntries(functionMap.get(id));
                    break;
                }
            }
        }
        // 
        // Setup double-click
        // 
        this.tableFunction.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    self.selected();
                }
            }
        });
        // 
        // Value change listener
        // 
        this.tableFunction.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                logger.info("valueChange " + self.tableFunction.getValue());
                if (self.tableFunction.getValue() != null) {
                    self.buttonSelect.setEnabled(true);
                } else {
                    self.buttonSelect.setEnabled(false);
                }
            }
        });
        // 
        // Select current value if possible
        // 
        if (this.apply != null && this.apply.getFunctionId() != null && this.apply.getFunctionId().isEmpty() == false) {
            FunctionDefinition current = JPAUtils.findFunction(this.apply.getFunctionId());
            if (current != null) {
                this.tableFunction.select(current);
                this.tableFunction.setCurrentPageFirsreplacedemId(current);
            } else {
                logger.warn("Could not find function in table for " + this.apply.getFunctionId());
            }
        } else {
            this.buttonSelect.setEnabled(false);
        }
    }

    protected void addTableEntries(List<FunctionDefinition> functions) {
        if (functions == null) {
            logger.warn("NULL list of functions, cannot add to table.");
            return;
        }
        for (FunctionDefinition function : functions) {
            // 
            // Just check if this function is available for this
            // apply.
            // 
            // if (XACMLFunctionValidator.isFunctionAvailable(function, this.apply, this.argument)) {
            this.container.addBean(function);
        // } else {
        // if (logger.isDebugEnabled()) {
        // logger.debug("Function not available: " + function);
        // }
        // }
        }
    }

    protected void initializeButton() {
        this.buttonSelect.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                self.selected();
            }
        });
    }

    protected void initializeFilters() {
        this.textFieldFilter.setImmediate(true);
        this.textFieldFilter.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            SimpleStringFilter currentFilter = null;

            @Override
            public void textChange(TextChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Get the text
                // 
                String value = event.getText();
                if (value != null && value.length() > 0) {
                    // 
                    // Add the new filter
                    // 
                    this.currentFilter = new SimpleStringFilter("shortname", value, true, false);
                    self.container.addContainerFilter(this.currentFilter);
                }
            }
        });
        this.comboBoxDatatypeFilter.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
        this.comboBoxDatatypeFilter.setImmediate(true);
        this.comboBoxDatatypeFilter.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.comboBoxDatatypeFilter.sereplacedemCaptionPropertyId("xacmlId");
        this.comboBoxDatatypeFilter.setNullSelectionAllowed(true);
        this.comboBoxDatatypeFilter.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            Container.Filter currentFilter = null;

            @Override
            public void valueChange(ValueChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Get the current selection
                // 
                Object id = self.comboBoxDatatypeFilter.getValue();
                if (id == null) {
                    return;
                }
                // 
                // Setup the filter
                // 
                final Datatype datatype = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().gereplacedem(id).getEnreplacedy();
                this.currentFilter = new Container.Filter() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public boolean preplacedesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                        if (itemId instanceof FunctionDefinition) {
                            Datatype dt = ((FunctionDefinition) itemId).getDatatypeBean();
                            if (dt == null) {
                                return false;
                            }
                            return (dt.getXacmlId().equals(datatype.getXacmlId()));
                        }
                        return false;
                    }

                    @Override
                    public boolean appliesToProperty(Object propertyId) {
                        if (propertyId != null && propertyId.toString().equals("datatypeBean")) {
                            return true;
                        }
                        return false;
                    }
                };
                self.container.addContainerFilter(this.currentFilter);
            }
        });
        this.checkBoxFilterIsBag.setImmediate(true);
        this.checkBoxFilterIsBag.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            Filter currentFilter = null;

            @Override
            public void valueChange(ValueChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Is it checked?
                // 
                if (self.checkBoxFilterIsBag.getValue() == false) {
                    // 
                    // Nope, get out of here
                    // 
                    return;
                }
                // 
                // Add the filter
                // 
                this.currentFilter = new Compare.Equal("isBagReturn", true);
                self.container.addContainerFilter(this.currentFilter);
            }
        });
    }

    protected void selected() {
        // 
        // Is there a selected function?
        // 
        try {
            // 
            // Run the commit
            // 
            this.textAreaDescription.commit();
            this.tableFunction.commit();
            // 
            // Commit worked, get the selected function
            // 
            Object id = this.tableFunction.getValue();
            // 
            // Sanity check, it *should* never be null
            // unless someone changed the initialization code.
            // 
            if (id == null || !(id instanceof FunctionDefinition)) {
                throw new InvalidValueException(this.tableFunction.getRequiredError());
            }
            // 
            // Get the actual function and save it into the apply
            // 
            this.function = (FunctionDefinition) id;
            this.apply.setDescription(this.textAreaDescription.getValue());
            this.apply.setFunctionId(function.getXacmlid());
        } catch (SourceException | InvalidValueException e) {
            // 
            // Vaadin GUI will display message
            // 
            return;
        }
        /**
         * 		//
         * 		// Make sure the arguments are good
         * 		//
         * 		final ApplyType copyApply = XACMLObjectCopy.copy(this.apply);
         * 		final ApplyArgumentsEditorWindow window = new ApplyArgumentsEditorWindow(copyApply, this.function);
         * 		window.setCaption("Define Arguments for " + this.function.getShortname());
         * 		window.setModal(true);
         * 		window.addCloseListener(new CloseListener() {
         * 			private static final long serialVersionUID = 1L;
         *
         * 			@Override
         * 			public void windowClose(CloseEvent e) {
         * 				//
         * 				// Did the user click save?
         * 				//
         * 				if (window.isSaved() == false) {
         * 					return;
         * 				}
         * 				//
         * 				// Save our arguments
         * 				//
         * 				self.apply.getExpression().clear();
         * 				self.apply.getExpression().addAll(copyApply.getExpression());
         * 				//
         * 				// We are saved
         * 				//
         * 				self.isSaved = true;
         * 				//
         * 				// Fire
         * 				//
         * 				self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
         * 				//
         * 				// Close the apply editor window
         * 				//
         * 				self.close();
         * 			}
         * 		});
         * 		window.center();
         * 		UI.getCurrent().addWindow(window);
         */
        // 
        // We are saved
        // 
        self.isSaved = true;
        // 
        // Fire
        // 
        self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
        // 
        // Close the apply editor window
        // 
        self.close();
    }

    @Override
    public boolean addListener(ApplyParametersChangedListener listener) {
        return this.notifier.addListener(listener);
    }

    @Override
    public boolean removeListener(ApplyParametersChangedListener listener) {
        return this.notifier.removeListener(listener);
    }

    @Override
    public void fireEvent(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container) {
        this.notifier.fireEvent(apply, parent, argument, container);
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public FunctionDefinition getSelectedFunction() {
        return this.function;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // horizontalLayout_1
        horizontalLayout_1 = buildHorizontalLayout_1();
        mainLayout.addComponent(horizontalLayout_1);
        // tableFunction
        tableFunction = new Table();
        tableFunction.setCaption("Select A Function");
        tableFunction.setImmediate(false);
        tableFunction.setWidth("100.0%");
        tableFunction.setHeight("-1px");
        tableFunction.setInvalidAllowed(false);
        tableFunction.setRequired(true);
        mainLayout.addComponent(tableFunction);
        mainLayout.setExpandRatio(tableFunction, 1.0f);
        // buttonSelect
        buttonSelect = new Button();
        buttonSelect.setCaption("Select and Continue");
        buttonSelect.setImmediate(true);
        buttonSelect.setWidth("-1px");
        buttonSelect.setHeight("-1px");
        mainLayout.addComponent(buttonSelect);
        mainLayout.setComponentAlignment(buttonSelect, new Alignment(48));
        return mainLayout;
    }

    @AutoGenerated
    private HorizontalLayout buildHorizontalLayout_1() {
        // common part: create layout
        horizontalLayout_1 = new HorizontalLayout();
        horizontalLayout_1.setImmediate(false);
        horizontalLayout_1.setWidth("-1px");
        horizontalLayout_1.setHeight("-1px");
        horizontalLayout_1.setMargin(false);
        horizontalLayout_1.setSpacing(true);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Enter A Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("50.0%");
        textAreaDescription.setHeight("-1px");
        horizontalLayout_1.addComponent(textAreaDescription);
        // textFieldFilter
        textFieldFilter = new TextField();
        textFieldFilter.setCaption("Filter Function By ID");
        textFieldFilter.setImmediate(false);
        textFieldFilter.setWidth("-1px");
        textFieldFilter.setHeight("-1px");
        horizontalLayout_1.addComponent(textFieldFilter);
        horizontalLayout_1.setComponentAlignment(textFieldFilter, new Alignment(9));
        // comboBoxDatatypeFilter
        comboBoxDatatypeFilter = new ComboBox();
        comboBoxDatatypeFilter.setCaption("Filter By Data Type");
        comboBoxDatatypeFilter.setImmediate(false);
        comboBoxDatatypeFilter.setWidth("-1px");
        comboBoxDatatypeFilter.setHeight("-1px");
        horizontalLayout_1.addComponent(comboBoxDatatypeFilter);
        horizontalLayout_1.setComponentAlignment(comboBoxDatatypeFilter, new Alignment(9));
        // checkBoxFilterIsBag
        checkBoxFilterIsBag = new CheckBox();
        checkBoxFilterIsBag.setCaption("Is Bag Filter");
        checkBoxFilterIsBag.setImmediate(false);
        checkBoxFilterIsBag.setWidth("-1px");
        checkBoxFilterIsBag.setHeight("-1px");
        horizontalLayout_1.addComponent(checkBoxFilterIsBag);
        horizontalLayout_1.setComponentAlignment(checkBoxFilterIsBag, new Alignment(9));
        return horizontalLayout_1;
    }
}

19 View Complete Implementation : DistributionAddUpdateWindowLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
/**
 * WindowContent for adding/editing a Distribution
 */
public clreplaced DistributionAddUpdateWindowLayout extends CustomComponent {

    private static final long serialVersionUID = -5602182034230568435L;

    private final VaadinMessageSource i18n;

    private final UINotification notificationMessage;

    private final transient EventBus.UIEventBus eventBus;

    private final transient DistributionSetManagement distributionSetManagement;

    private final transient DistributionSetTypeManagement distributionSetTypeManagement;

    private final transient SystemManagement systemManagement;

    private final transient EnreplacedyFactory enreplacedyFactory;

    private final transient TenantConfigurationManagement tenantConfigurationManagement;

    private final transient SystemSecurityContext systemSecurityContext;

    private final DistributionSetTable distributionSetTable;

    private TextField distNameTextField;

    private TextField distVersionTextField;

    private TextArea descTextArea;

    private CheckBox reqMigStepCheckbox;

    private ComboBox distsetTypeNameComboBox;

    private FormLayout formLayout;

    /**
     * Constructor for DistributionAddUpdateWindowLayout
     *
     * @param i18n
     *            I18N
     * @param notificationMessage
     *            UINotification
     * @param eventBus
     *            UIEventBus
     * @param distributionSetManagement
     *            DistributionSetManagement
     * @param distributionSetTypeManagement
     *            distributionSetTypeManagement
     * @param systemManagement
     *            SystemManagement
     * @param enreplacedyFactory
     *            EnreplacedyFactory
     * @param distributionSetTable
     *            DistributionSetTable
     * @param tenantConfigurationManagement
     *            TenantConfigurationManagement
     */
    public DistributionAddUpdateWindowLayout(final VaadinMessageSource i18n, final UINotification notificationMessage, final UIEventBus eventBus, final DistributionSetManagement distributionSetManagement, final DistributionSetTypeManagement distributionSetTypeManagement, final SystemManagement systemManagement, final EnreplacedyFactory enreplacedyFactory, final DistributionSetTable distributionSetTable, final TenantConfigurationManagement tenantConfigurationManagement, final SystemSecurityContext systemSecurityContext) {
        this.i18n = i18n;
        this.notificationMessage = notificationMessage;
        this.eventBus = eventBus;
        this.distributionSetManagement = distributionSetManagement;
        this.distributionSetTypeManagement = distributionSetTypeManagement;
        this.systemManagement = systemManagement;
        this.enreplacedyFactory = enreplacedyFactory;
        this.distributionSetTable = distributionSetTable;
        this.tenantConfigurationManagement = tenantConfigurationManagement;
        this.systemSecurityContext = systemSecurityContext;
        createRequiredComponents();
        buildLayout();
    }

    /**
     * Updates the distribution set on close.
     */
    private final clreplaced UpdateOnCloseDialogListener implements SaveDialogCloseListener {

        private final Long editDistId;

        public UpdateOnCloseDialogListener(final Long editDistId) {
            this.editDistId = editDistId;
        }

        @Override
        public void saveOrUpdate() {
            if (isDuplicate(editDistId)) {
                return;
            }
            final boolean isMigStepReq = reqMigStepCheckbox.getValue();
            final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue();
            distributionSetTypeManagement.get(distSetTypeId).ifPresent(type -> {
                final DistributionSet currentDS = distributionSetManagement.update(enreplacedyFactory.distributionSet().update(editDistId).name(distNameTextField.getValue()).description(descTextArea.getValue()).version(distVersionTextField.getValue()).requiredMigrationStep(isMigStepReq));
                notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", currentDS.getName(), currentDS.getVersion()));
                // update table row+details layout
                eventBus.publish(this, new DistributionTableEvent(BaseEnreplacedyEventType.UPDATED_ENreplacedY, currentDS));
            });
        }

        @Override
        public boolean canWindowSaveOrUpdate() {
            return !isDuplicate(editDistId);
        }
    }

    /**
     * Creates the distribution set on close.
     */
    private final clreplaced CreateOnCloseDialogListener implements SaveDialogCloseListener {

        @Override
        public void saveOrUpdate() {
            final String name = distNameTextField.getValue();
            final String version = distVersionTextField.getValue();
            final Long distSetTypeId = (Long) distsetTypeNameComboBox.getValue();
            final String desc = descTextArea.getValue();
            final boolean isMigStepReq = reqMigStepCheckbox.getValue();
            final DistributionSetType distributionSetType = distributionSetTypeManagement.get(distSetTypeId).orElseThrow(() -> new EnreplacedyNotFoundException(DistributionSetType.clreplaced, distSetTypeId));
            final DistributionSet newDist = distributionSetManagement.create(enreplacedyFactory.distributionSet().create().name(name).version(version).description(desc).type(distributionSetType).requiredMigrationStep(isMigStepReq));
            eventBus.publish(this, new DistributionTableEvent(BaseEnreplacedyEventType.ADD_ENreplacedY, newDist));
            notificationMessage.displaySuccess(i18n.getMessage("message.new.dist.save.success", newDist.getName(), newDist.getVersion()));
            distributionSetTable.setValue(Sets.newHashSet(newDist.getId()));
        }

        @Override
        public boolean canWindowSaveOrUpdate() {
            return !isDuplicate(null);
        }
    }

    private boolean isDuplicate(final Long editDistId) {
        final String name = distNameTextField.getValue();
        final String version = distVersionTextField.getValue();
        final Optional<DistributionSet> existingDs = distributionSetManagement.getByNameAndVersion(name, version);
        /*
         * Distribution should not exists with the same name & version. Display
         * error message, when the "existingDs" is not null and it is add window
         * (or) when the "existingDs" is not null and it is edit window and the
         * distribution Id of the edit window is different then the "existingDs"
         */
        if (existingDs.isPresent() && !existingDs.get().getId().equals(editDistId)) {
            distNameTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
            distVersionTextField.addStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
            notificationMessage.displayValidationError(i18n.getMessage("message.duplicate.dist", existingDs.get().getName(), existingDs.get().getVersion()));
            return true;
        }
        return false;
    }

    private void buildLayout() {
        addStyleName("lay-color");
        setSizeUndefined();
        formLayout = new FormLayout();
        formLayout.addComponent(distsetTypeNameComboBox);
        formLayout.addComponent(distNameTextField);
        formLayout.addComponent(distVersionTextField);
        formLayout.addComponent(descTextArea);
        formLayout.addComponent(reqMigStepCheckbox);
        setCompositionRoot(formLayout);
        distNameTextField.focus();
    }

    /**
     * Create required UI components.
     */
    private void createRequiredComponents() {
        distNameTextField = createTextField("textfield.name", UIComponentIdProvider.DIST_ADD_NAME, DistributionSet.NAME_MAX_SIZE);
        distVersionTextField = createTextField("textfield.version", UIComponentIdProvider.DIST_ADD_VERSION, DistributionSet.VERSION_MAX_SIZE);
        distsetTypeNameComboBox = SPUIComponentProvider.getComboBox(i18n.getMessage("label.combobox.type"), "", null, "", false, "", i18n.getMessage("label.combobox.type"));
        distsetTypeNameComboBox.setImmediate(true);
        distsetTypeNameComboBox.setNullSelectionAllowed(false);
        distsetTypeNameComboBox.setId(UIComponentIdProvider.DIST_ADD_DISTSETTYPE);
        descTextArea = new TextAreaBuilder(DistributionSet.DESCRIPTION_MAX_SIZE).caption(i18n.getMessage("textfield.description")).style("text-area-style").id(UIComponentIdProvider.DIST_ADD_DESC).buildTextComponent();
        reqMigStepCheckbox = SPUIComponentProvider.getCheckBox(i18n.getMessage("checkbox.dist.required.migration.step"), "dist-checkbox-style", null, false, "");
        reqMigStepCheckbox.addStyleName(ValoTheme.CHECKBOX_SMALL);
        reqMigStepCheckbox.setId(UIComponentIdProvider.DIST_ADD_MIGRATION_CHECK);
    }

    private TextField createTextField(final String in18Key, final String id, final int maxLength) {
        return new TextFieldBuilder(maxLength).caption(i18n.getMessage(in18Key)).required(true, i18n).id(id).buildTextComponent();
    }

    /**
     * Get the LazyQueryContainer instance for DistributionSetTypes.
     *
     * @return
     */
    private static LazyQueryContainer getDistSetTypeLazyQueryContainer() {
        final BeanQueryFactory<DistributionSetTypeBeanQuery> dtQF = new BeanQueryFactory<>(DistributionSetTypeBeanQuery.clreplaced);
        dtQF.setQueryConfiguration(Collections.emptyMap());
        final LazyQueryContainer disttypeContainer = new LazyQueryContainer(new LazyQueryDefinition(true, SPUIDefinitions.DIST_TYPE_SIZE, SPUILabelDefinitions.VAR_ID), dtQF);
        disttypeContainer.addContainerProperty(SPUILabelDefinitions.VAR_NAME, String.clreplaced, "", true, true);
        return disttypeContainer;
    }

    private DistributionSetType getDefaultDistributionSetType() {
        final TenantMetaData tenantMetaData = systemManagement.getTenantMetadata();
        return tenantMetaData.getDefaultDsType();
    }

    /**
     * clear all the fields.
     */
    public void resetComponents() {
        distNameTextField.clear();
        distNameTextField.removeStyleName("v-textfield-error");
        distVersionTextField.clear();
        distVersionTextField.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
        distsetTypeNameComboBox.removeStyleName(SPUIStyleDefinitions.SP_TEXTFIELD_LAYOUT_ERROR_HIGHTLIGHT);
        distsetTypeNameComboBox.clear();
        distsetTypeNameComboBox.setEnabled(true);
        descTextArea.clear();
        reqMigStepCheckbox.clear();
        reqMigStepCheckbox.setVisible(!isMultireplacedignmentEnabled());
    }

    private boolean isMultireplacedignmentEnabled() {
        return systemSecurityContext.runreplacedystem(() -> tenantConfigurationManagement.getConfigurationValue(TenantConfigurationKey.MULTI_replacedIGNMENTS_ENABLED, Boolean.clreplaced).getValue());
    }

    private void populateValuesOfDistribution(final Long editDistId) {
        final Optional<DistributionSet> distSet = distributionSetManagement.getWithDetails(editDistId);
        if (!distSet.isPresent()) {
            return;
        }
        distNameTextField.setValue(distSet.get().getName());
        distVersionTextField.setValue(distSet.get().getVersion());
        if (distSet.get().getType().isDeleted()) {
            distsetTypeNameComboBox.addItem(distSet.get().getType().getId());
        }
        distsetTypeNameComboBox.setValue(distSet.get().getType().getId());
        distsetTypeNameComboBox.setEnabled(false);
        reqMigStepCheckbox.setValue(distSet.get().isRequiredMigrationStep());
        descTextArea.setValue(distSet.get().getDescription());
    }

    /**
     * Returns the dialog window for creating a distribution.
     *
     * @return window
     */
    public CommonDialogWindow getWindowForCreateDistributionSet() {
        return getWindow(null);
    }

    /**
     * Returns the dialog window for updating a distribution.
     *
     * @param editDistId
     *            the id of the distribution that should be updated
     * @return window
     */
    public CommonDialogWindow getWindowForUpdateDistributionSet(final Long editDistId) {
        return getWindow(editDistId);
    }

    /**
     * Internal method to create a window to create or update a DistributionSet.
     *
     * @param editDistId
     *            if <code>null</code> is provided the window is configured to
     *            create a DistributionSet otherwise it is configured for
     *            update.
     * @return
     */
    private CommonDialogWindow getWindow(final Long editDistId) {
        final SaveDialogCloseListener saveDialogCloseListener;
        String caption;
        resetComponents();
        populateDistSetTypeNameCombo();
        if (editDistId == null) {
            saveDialogCloseListener = new CreateOnCloseDialogListener();
            caption = i18n.getMessage("caption.create.new", i18n.getMessage("caption.distribution"));
        } else {
            saveDialogCloseListener = new UpdateOnCloseDialogListener(editDistId);
            caption = i18n.getMessage("caption.update", i18n.getMessage("caption.distribution"));
            populateValuesOfDistribution(editDistId);
        }
        return new WindowBuilder(SPUIDefinitions.CREATE_UPDATE_WINDOW).caption(caption).content(this).id(UIComponentIdProvider.CREATE_POPUP_ID).layout(formLayout).i18n(i18n).saveDialogCloseListener(saveDialogCloseListener).buildCommonDialogWindow();
    }

    /**
     * Populate DistributionSet Type name combo.
     */
    private void populateDistSetTypeNameCombo() {
        distsetTypeNameComboBox.setContainerDataSource(getDistSetTypeLazyQueryContainer());
        distsetTypeNameComboBox.sereplacedemCaptionPropertyId(SPUILabelDefinitions.VAR_NAME);
        distsetTypeNameComboBox.setValue(getDefaultDistributionSetType().getId());
    }
}

19 View Complete Implementation : ObadviceEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced ObadviceEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    private static final long serialVersionUID = 1L;

    private ObadviceEditorWindow self = this;

    private FormLayout mainLayout = new FormLayout();

    @PropertyId("type")
    OptionGroup typeOption = new OptionGroup("Type");

    @PropertyId("xacmlId")
    TextField xacmlID = new TextField("Obligation Id");

    @PropertyId("description")
    TextArea descriptionField = new TextArea("Description");

    @PropertyId("fulfillOn")
    OptionGroup fulfillOption = new OptionGroup("Fullfill On");

    @PropertyId("obadviceExpressions")
    OaExpressionsField expressionsField;

    // Table tableExpressions = new Table("Attribute replacedignments");
    Button saveButton = new Button("Save");

    private FieldGroup fieldGroup = null;

    private final EnreplacedyItem<Obadvice> obad;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param caption
     */
    public ObadviceEditorWindow(EnreplacedyItem<Obadvice> obad) {
        this.setContent(mainLayout);
        // 
        // Save
        // 
        this.obad = obad;
        // 
        // Initialize main layout
        // 
        this.mainLayout.setMargin(true);
        this.mainLayout.setWidth("-1px");
        // 
        // Initialize components
        // 
        this.typeOption.setNullSelectionAllowed(false);
        this.typeOption.setImmediate(true);
        this.typeOption.setDescription("Select whether this is an obligation or advice");
        this.typeOption.addItem("Obligation");
        this.typeOption.addItem("Advice");
        this.fulfillOption.setNullSelectionAllowed(true);
        this.fulfillOption.setDescription("Optionally restrict the use of the obligation/advice to a Permit or a Deny");
        this.fulfillOption.addItem("Permit");
        this.fulfillOption.addItem("Deny");
        this.descriptionField.setNullRepresentation("");
        this.expressionsField = new OaExpressionsField(this.obad);
        // 
        // Add our form components
        // 
        this.mainLayout.addComponent(this.typeOption);
        this.mainLayout.addComponent(this.fulfillOption);
        this.mainLayout.addComponent(this.xacmlID);
        this.mainLayout.addComponent(this.descriptionField);
        this.mainLayout.addComponent(this.expressionsField);
        // this.mainLayout.addComponent(this.tableExpressions);
        this.mainLayout.addComponent(this.saveButton);
        // 
        // Now bind those fields to the data
        // 
        this.fieldGroup = new FieldGroup(obad);
        this.fieldGroup.bindMemberFields(this);
        // 
        // Finish setting up
        // 
        this.initializeButtons();
        this.initializeOptions();
        // 
        // Set focus
        // 
        this.xacmlID.focus();
    }

    private void initializeButtons() {
        this.saveButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    fieldGroup.commit();
                    self.isSaved = true;
                    self.close();
                } catch (CommitException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    private void initializeOptions() {
        self.setIDCaption();
        this.typeOption.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                self.setIDCaption();
            }
        });
    }

    private void setIDCaption() {
        String value = (String) self.typeOption.getValue();
        if (value.equals("Obligation")) {
            self.xacmlID.setCaption("Obligation Id");
        } else {
            self.xacmlID.setCaption("Advice Id");
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public void discard() {
        // 
        // May be discarded automatically??
        // 
        this.fieldGroup.discard();
    }
}

19 View Complete Implementation : AddUpdateRolloutWindowLayout.java
Copyright Eclipse Public License 1.0
Author : eclipse
private static TextArea createTargetFilterQuery() {
    final TextArea filterField = new TextAreaBuilder(TargetFilterQuery.QUERY_MAX_SIZE).style("text-area-style").id(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD).buildTextComponent();
    filterField.setId(UIComponentIdProvider.ROLLOUT_TARGET_FILTER_QUERY_FIELD);
    filterField.setEnabled(false);
    filterField.setSizeUndefined();
    return filterField;
}

19 View Complete Implementation : EditPDPGroupWindow.java
Copyright MIT License
Author : att
public clreplaced EditPDPGroupWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private Table tablePIP;

    @AutoGenerated
    private Table tablePolicies;

    @AutoGenerated
    private TextArea textDescription;

    @AutoGenerated
    private TextField textName;

    private static final Action ADD_POLICY = new Action("Add New Policy");

    private static final Action REMOVE_POLICY = new Action("Remove Policy");

    private static final Action MAKE_ROOT = new Action("Make Root");

    private static final Action MAKE_REFERENCED = new Action("Make Referenced");

    private static final Action EDIT_CONFIG = new Action("Edit Configurations");

    // 
    // ?? Why is this static?
    // 
    private static PDPPolicyContainer policyContainer;

    private PDPPIPContainer pipContainer;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final EditPDPGroupWindow self = this;

    private final StdPDPGroup group;

    private boolean isSaved = false;

    // this is the version that contains all of the edits made by the user.
    // it may be a copy of the original object (edited) or a new one.
    private StdPDPGroup updatedObject;

    private PAPEngine papEngine;

    private List<PDPGroup> groups;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param group
     * @param list
     * @param engine
     */
    public EditPDPGroupWindow(StdPDPGroup group, List<PDPGroup> list, PAPEngine engine) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save pointers
        // 
        this.group = group;
        this.groups = list;
        this.papEngine = engine;
        // 
        // Initialize
        // 
        this.initialize();
        // 
        // Shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        // 
        // Focus
        // 
        this.textName.focus();
    }

    protected void initialize() {
        this.initializeText();
        this.initializeButton();
        this.initializeTables();
    }

    protected void initializeText() {
        this.textName.setNullRepresentation("");
        this.textDescription.setNullRepresentation("");
        if (this.group != null) {
            this.textName.setValue(this.group.getName());
            this.textDescription.setValue(this.group.getDescription());
        }
        // 
        // Validation
        // 
        this.textName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                replacedert (value instanceof String);
                if (value == null) {
                    throw new InvalidValueException("The name cannot be blank.");
                }
                // Group names must be unique so that user can distinguish between them (and we can create unique IDs from them)
                for (PDPGroup g : self.groups) {
                    if (group != null && g.getId().equals(group.getId())) {
                        // ignore this group - we may or may not be changing the name
                        continue;
                    }
                    if (g.getName().equals(value.toString())) {
                        throw new InvalidValueException("Name must be unique");
                    }
                }
            }
        });
        this.textName.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void textChange(TextChangeEvent event) {
                if (event.getText() == null || event.getText().isEmpty()) {
                    self.buttonSave.setEnabled(false);
                } else {
                    self.buttonSave.setEnabled(true);
                }
            }
        });
    }

    protected void initializeTables() {
        this.initializePolicyTable();
        this.initializePIPTable();
    }

    protected void initializePolicyTable() {
        if (this.group == null) {
            this.tablePolicies.setVisible(false);
            return;
        }
        // 
        // GUI properties
        // 
        EditPDPGroupWindow.policyContainer = new PDPPolicyContainer(group);
        this.tablePolicies.setContainerDataSource(EditPDPGroupWindow.policyContainer);
        // , "Description");
        this.tablePolicies.setVisibleColumns("Root", "Name", "Version", "Id");
        this.tablePolicies.setPageLength(EditPDPGroupWindow.policyContainer.size() + 1);
        this.tablePolicies.setSelectable(true);
        this.tablePolicies.setSizeFull();
        /*
		 * Not in this release.
		 * 
		this.tablePolicies.setColumnCollapsingAllowed(true);
		this.tablePolicies.setColumnCollapsed("Description", true);
		//
		// Generated columns
		//
		this.tablePolicies.addGeneratedColumn("Description", new ColumnGenerator() {
			private static final long serialVersionUID = 1L;

			@Override
			public Object generateCell(Table source, Object itemId, Object columnId) {
				TextArea area = new TextArea();
				if (itemId != null && itemId instanceof PDPPolicy) {
					area.setValue(((PDPPolicy)itemId).getDescription());
				}
				area.setNullRepresentation("");
				area.setWidth("100.0%");
				return area;
			}
		});
		*/
        // 
        // Actions
        // 
        this.tablePolicies.addActionHandler(new Handler() {

            private static final long serialVersionUID = 1L;

            @Override
            public Action[] getActions(Object target, Object sender) {
                if (target == null) {
                    return new Action[] { ADD_POLICY };
                }
                return new Action[] { ADD_POLICY, REMOVE_POLICY, MAKE_ROOT, MAKE_REFERENCED };
            }

            @Override
            public void handleAction(Action action, Object sender, Object target) {
                if (action == ADD_POLICY) {
                    final SelectWorkspacePoliciesWindow policiesWindow = new SelectWorkspacePoliciesWindow();
                    policiesWindow.setCaption("Select Policy to Add");
                    policiesWindow.setModal(true);
                    policiesWindow.addCloseListener(new CloseListener() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void windowClose(CloseEvent event) {
                            // 
                            // Did the user hit save?
                            // 
                            if (policiesWindow.isSaved() == false) {
                                return;
                            }
                            // 
                            // Get the selected policy
                            // 
                            StdPDPPolicy selectedPolicy = policiesWindow.getSelectedPolicy();
                            if (selectedPolicy != null) {
                                // do not allow multiple copies of same policy
                                for (Object existingPolicy : EditPDPGroupWindow.policyContainer.gereplacedemIds()) {
                                    if (selectedPolicy.getId().equals(((PDPPolicy) existingPolicy).getId())) {
                                        AdminNotification.warn("Cannot re-add Policy with the same ID (i.e. same Name, source Sub-Domain and Version)");
                                        return;
                                    }
                                }
                                // copy policy to PAP
                                try {
                                    papEngine.copyPolicy(selectedPolicy, self.group);
                                } catch (PAPException e) {
                                    AdminNotification.warn("Unable to copy Policy '" + selectedPolicy.getPolicyId() + "' to PAP: " + e.getMessage());
                                    return;
                                }
                                // add Policy to group
                                EditPDPGroupWindow.policyContainer.addItem(selectedPolicy);
                                self.markAsDirtyRecursive();
                            }
                        }
                    });
                    policiesWindow.center();
                    UI.getCurrent().addWindow(policiesWindow);
                    return;
                }
                if (action == REMOVE_POLICY) {
                    replacedert (target != null);
                    PDPPolicy policy = (PDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.removeItem(policy);
                    self.markAsDirtyRecursive();
                    return;
                }
                if (action == MAKE_ROOT) {
                    replacedert (target != null);
                    replacedert (target instanceof StdPDPPolicy);
                    StdPDPPolicy policy = (StdPDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.gereplacedem(policy).gereplacedemProperty("Root").setValue(true);
                    self.markAsDirtyRecursive();
                    return;
                }
                if (action == MAKE_REFERENCED) {
                    replacedert (target != null);
                    replacedert (target instanceof StdPDPPolicy);
                    StdPDPPolicy policy = (StdPDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.gereplacedem(policy).gereplacedemProperty("Root").setValue(false);
                    self.markAsDirtyRecursive();
                    return;
                }
                AdminNotification.error("Unrecognized action '" + action + "' on target '" + target + "'");
            }
        });
    }

    protected void initializePIPTable() {
        if (this.group == null) {
            this.tablePIP.setVisible(false);
            return;
        }
        // 
        // Setup data source and GUI properties
        // 
        this.pipContainer = new PDPPIPContainer(group);
        this.tablePIP.setContainerDataSource(this.pipContainer);
        this.tablePIP.setPageLength(this.pipContainer.size() + 2);
        this.tablePIP.setSelectable(true);
        this.tablePIP.setSizeFull();
        // 
        // Add the action handler
        // 
        this.tablePIP.addActionHandler(new Handler() {

            private static final long serialVersionUID = 1L;

            @Override
            public Action[] getActions(Object target, Object sender) {
                return new Action[] { EDIT_CONFIG };
            }

            @Override
            public void handleAction(Action action, Object sender, Object target) {
                if (action == EDIT_CONFIG) {
                    self.editPIPConfiguration();
                    return;
                }
            }
        });
    }

    protected void editPIPConfiguration() {
        final SelectPIPConfigurationWindow window = new SelectPIPConfigurationWindow(this.group);
        window.setCaption("Select PIP Configurations");
        window.setModal(true);
        window.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                // 
                // Did the user click save button?
                // 
                if (window.isSaved() == false) {
                    return;
                }
                // 
                // Yes - save the PIP configuration
                // 
                Set<PDPPIPConfig> configs = window.getSelectedConfigs();
                replacedert (configs != null);
                self.group.setPipConfigs(configs);
                // 
                // Update the container
                // 
                self.pipContainer.refresh();
            }
        });
        window.center();
        UI.getCurrent().addWindow(window);
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Validate
                    // 
                    self.textName.commit();
                    // 
                    // All good save everything
                    // 
                    self.doSave();
                    // 
                    // mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (InvalidValueException e) {
                // 
                // Ignore, Vaadin will display our message
                // 
                }
            }
        });
    }

    protected void doSave() {
        if (this.group == null) {
            return;
        }
        StdPDPGroup updatedGroupObject = new StdPDPGroup(this.group.getId(), this.group.isDefaultGroup(), this.textName.getValue(), this.textDescription.getValue(), null);
        // replace the original set of Policies with the set from the container (possibly modified by the user)
        Set<PDPPolicy> changedPolicies = new HashSet<PDPPolicy>();
        changedPolicies.addAll((Collection<PDPPolicy>) EditPDPGroupWindow.policyContainer.gereplacedemIds());
        updatedGroupObject.setPolicies(changedPolicies);
        updatedGroupObject.setPdps(this.group.getPdps());
        // replace the original set of PIP Configs with the set from the container
        // TODO - get PIP Configs from a container used to support editing
        // selfPDPObject.getPipConfigs().clear();
        // selfPDPObject.getPipConfigs().addAll(containerGroup.getPipConfigs());
        updatedGroupObject.setPipConfigs(this.group.getPipConfigs());
        // copy those things that the user cannot change from the original to the new object
        updatedGroupObject.setStatus(this.group.getStatus());
        this.updatedObject = updatedGroupObject;
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getGroupName() {
        return this.textName.getValue();
    }

    public String getGroupDescription() {
        return this.textDescription.getValue();
    }

    public PDPGroup getUpdatedObject() {
        return this.updatedObject;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("100.0%");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textName
        textName = new TextField();
        textName.setCaption("Group Name");
        textName.setImmediate(false);
        textName.setWidth("-1px");
        textName.setHeight("-1px");
        textName.setRequired(true);
        mainLayout.addComponent(textName);
        // textDescription
        textDescription = new TextArea();
        textDescription.setCaption("Group Description");
        textDescription.setImmediate(false);
        textDescription.setWidth("100.0%");
        textDescription.setHeight("-1px");
        textDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textDescription);
        mainLayout.setExpandRatio(textDescription, 1.0f);
        // tablePolicies
        tablePolicies = new Table();
        tablePolicies.setCaption("Policies");
        tablePolicies.setImmediate(false);
        tablePolicies.setWidth("-1px");
        tablePolicies.setHeight("-1px");
        mainLayout.addComponent(tablePolicies);
        mainLayout.setExpandRatio(tablePolicies, 1.0f);
        // tablePIP
        tablePIP = new Table();
        tablePIP.setCaption("PIP Configurations");
        tablePIP.setImmediate(false);
        tablePIP.setWidth("-1px");
        tablePIP.setHeight("-1px");
        mainLayout.addComponent(tablePIP);
        mainLayout.setExpandRatio(tablePIP, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : DecisionFlowChartManagerImpl.java
Copyright Apache License 2.0
Author : Hack23
@Override
public TextArea createCommitteeeDecisionSummary(final Map<String, List<ViewRiksdagenCommittee>> committeeMap, final String rm) {
    final TextArea area = new TextArea("Summary");
    final StringBuilder stringBuilder = new StringBuilder();
    final List<ProposalCommitteeeSummary> createCommitteeSummary = decisionDataFactory.createCommitteeSummary(rm);
    final Map<String, List<ProposalCommitteeeSummary>> orgProposalMap = createCommitteeSummary.stream().collect(Collectors.groupingBy(ProposalCommitteeeSummary::getOrg));
    for (final Entry<String, List<ProposalCommitteeeSummary>> entry : orgProposalMap.entrySet()) {
        if (committeeMap.containsKey(entry.getKey())) {
            addCommiteeSummary(stringBuilder, entry, committeeMap.get(entry.getKey()).stream().findFirst());
        }
    }
    area.setValue(stringBuilder.toString());
    return area;
}

19 View Complete Implementation : EditPDPGroupWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced EditPDPGroupWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private Table tablePIP;

    @AutoGenerated
    private Table tablePolicies;

    @AutoGenerated
    private TextArea textDescription;

    @AutoGenerated
    private TextField textName;

    private static final Action ADD_POLICY = new Action("Add New Policy");

    private static final Action REMOVE_POLICY = new Action("Remove Policy");

    private static final Action MAKE_ROOT = new Action("Make Root");

    private static final Action MAKE_REFERENCED = new Action("Make Referenced");

    private static final Action EDIT_CONFIG = new Action("Edit Configurations");

    // 
    // ?? Why is this static?
    // 
    private static PDPPolicyContainer policyContainer;

    private PDPPIPContainer pipContainer;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final EditPDPGroupWindow self = this;

    private final StdPDPGroup group;

    private boolean isSaved = false;

    // this is the version that contains all of the edits made by the user.
    // it may be a copy of the original object (edited) or a new one.
    private StdPDPGroup updatedObject;

    private PAPEngine papEngine;

    private List<PDPGroup> groups;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public EditPDPGroupWindow(StdPDPGroup group, List<PDPGroup> list, PAPEngine engine) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save pointers
        // 
        this.group = group;
        this.groups = list;
        this.papEngine = engine;
        // 
        // Initialize
        // 
        this.initialize();
        // 
        // Shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        this.buttonSave.setClickShortcut(KeyCode.ENTER);
        // 
        // Focus
        // 
        this.textName.focus();
    }

    protected void initialize() {
        this.initializeText();
        this.initializeButton();
        this.initializeTables();
    }

    protected void initializeText() {
        this.textName.setNullRepresentation("");
        this.textDescription.setNullRepresentation("");
        if (this.group != null) {
            this.textName.setValue(this.group.getName());
            this.textDescription.setValue(this.group.getDescription());
        }
        // 
        // Validation
        // 
        this.textName.addValidator(new Validator() {

            private static final long serialVersionUID = 1L;

            @Override
            public void validate(Object value) throws InvalidValueException {
                replacedert value instanceof String;
                if (value == null) {
                    throw new InvalidValueException("The name cannot be blank.");
                }
                // Group names must be unique so that user can distinguish between them (and we can create unique IDs from them)
                for (PDPGroup g : self.groups) {
                    if (group != null && g.getId().equals(group.getId())) {
                        // ignore this group - we may or may not be changing the name
                        continue;
                    }
                    if (g.getName().equals(value.toString())) {
                        throw new InvalidValueException("Name must be unique");
                    }
                }
            }
        });
        this.textName.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void textChange(TextChangeEvent event) {
                if (event.getText() == null || event.getText().isEmpty()) {
                    self.buttonSave.setEnabled(false);
                } else {
                    self.buttonSave.setEnabled(true);
                }
            }
        });
    }

    protected void initializeTables() {
        this.initializePolicyTable();
        this.initializePIPTable();
    }

    protected void initializePolicyTable() {
        if (this.group == null) {
            this.tablePolicies.setVisible(false);
            return;
        }
        // 
        // GUI properties
        // 
        EditPDPGroupWindow.policyContainer = new PDPPolicyContainer(group);
        this.tablePolicies.setContainerDataSource(EditPDPGroupWindow.policyContainer);
        // , "Description");
        this.tablePolicies.setVisibleColumns("Root", "Name", "Version", "Id");
        this.tablePolicies.setPageLength(EditPDPGroupWindow.policyContainer.size() + 1);
        this.tablePolicies.setSelectable(true);
        this.tablePolicies.setSizeFull();
        /*
		 * Not in this release.
		 * 
		this.tablePolicies.setColumnCollapsingAllowed(true);
		this.tablePolicies.setColumnCollapsed("Description", true);
		//
		// Generated columns
		//
		this.tablePolicies.addGeneratedColumn("Description", new ColumnGenerator() {
			private static final long serialVersionUID = 1L;

			@Override
			public Object generateCell(Table source, Object itemId, Object columnId) {
				TextArea area = new TextArea();
				if (itemId != null && itemId instanceof PDPPolicy) {
					area.setValue(((PDPPolicy)itemId).getDescription());
				}
				area.setNullRepresentation("");
				area.setWidth("100.0%");
				return area;
			}
		});
		*/
        // 
        // Actions
        // 
        this.tablePolicies.addActionHandler(new Handler() {

            private static final long serialVersionUID = 1L;

            @Override
            public Action[] getActions(Object target, Object sender) {
                if (target == null) {
                    return new Action[] { ADD_POLICY };
                }
                return new Action[] { ADD_POLICY, REMOVE_POLICY, MAKE_ROOT, MAKE_REFERENCED };
            }

            @Override
            public void handleAction(Action action, Object sender, Object target) {
                if (action == ADD_POLICY) {
                    final SelectWorkspacePoliciesWindow policiesWindow = new SelectWorkspacePoliciesWindow();
                    policiesWindow.setCaption("Select Policy to Add");
                    policiesWindow.setModal(true);
                    policiesWindow.addCloseListener(new CloseListener() {

                        private static final long serialVersionUID = 1L;

                        @Override
                        public void windowClose(CloseEvent event) {
                            // 
                            // Did the user hit save?
                            // 
                            if (policiesWindow.isSaved() == false) {
                                return;
                            }
                            // 
                            // Get the selected policy
                            // 
                            StdPDPPolicy selectedPolicy = policiesWindow.getSelectedPolicy();
                            if (selectedPolicy != null) {
                                // do not allow multiple copies of same policy
                                for (Object existingPolicy : EditPDPGroupWindow.policyContainer.gereplacedemIds()) {
                                    if (selectedPolicy.getId().equals(((PDPPolicy) existingPolicy).getId())) {
                                        AdminNotification.warn("Cannot re-add Policy with the same ID (i.e. same Name, source Sub-Domain and Version)");
                                        return;
                                    }
                                }
                                // copy policy to PAP
                                try {
                                    papEngine.copyPolicy(selectedPolicy, self.group);
                                } catch (PAPException e) {
                                    AdminNotification.warn("Unable to copy Policy '" + selectedPolicy.getPolicyId() + "' to PAP: " + e.getMessage());
                                    return;
                                }
                                // add Policy to group
                                EditPDPGroupWindow.policyContainer.addItem(selectedPolicy);
                                self.markAsDirtyRecursive();
                            }
                        }
                    });
                    policiesWindow.center();
                    UI.getCurrent().addWindow(policiesWindow);
                    return;
                }
                if (action == REMOVE_POLICY) {
                    replacedert target != null;
                    PDPPolicy policy = (PDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.removeItem(policy);
                    self.markAsDirtyRecursive();
                    return;
                }
                if (action == MAKE_ROOT) {
                    replacedert target != null;
                    replacedert target instanceof StdPDPPolicy;
                    StdPDPPolicy policy = (StdPDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.gereplacedem(policy).gereplacedemProperty("Root").setValue(true);
                    self.markAsDirtyRecursive();
                    return;
                }
                if (action == MAKE_REFERENCED) {
                    replacedert target != null;
                    replacedert target instanceof StdPDPPolicy;
                    StdPDPPolicy policy = (StdPDPPolicy) target;
                    EditPDPGroupWindow.policyContainer.gereplacedem(policy).gereplacedemProperty("Root").setValue(false);
                    self.markAsDirtyRecursive();
                    return;
                }
                AdminNotification.error("Unrecognized action '" + action + "' on target '" + target + "'");
            }
        });
    }

    protected void initializePIPTable() {
        if (this.group == null) {
            this.tablePIP.setVisible(false);
            return;
        }
        // 
        // Setup data source and GUI properties
        // 
        this.pipContainer = new PDPPIPContainer(group);
        this.tablePIP.setContainerDataSource(this.pipContainer);
        this.tablePIP.setPageLength(this.pipContainer.size() + 2);
        this.tablePIP.setSelectable(true);
        this.tablePIP.setSizeFull();
        // 
        // Add the action handler
        // 
        this.tablePIP.addActionHandler(new Handler() {

            private static final long serialVersionUID = 1L;

            @Override
            public Action[] getActions(Object target, Object sender) {
                return new Action[] { EDIT_CONFIG };
            }

            @Override
            public void handleAction(Action action, Object sender, Object target) {
                if (action == EDIT_CONFIG) {
                    self.editPIPConfiguration();
                    return;
                }
            }
        });
    }

    protected void editPIPConfiguration() {
        final SelectPIPConfigurationWindow window = new SelectPIPConfigurationWindow(this.group);
        window.setCaption("Select PIP Configurations");
        window.setModal(true);
        window.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                // 
                // Did the user click save button?
                // 
                if (window.isSaved() == false) {
                    return;
                }
                // 
                // Yes - save the PIP configuration
                // 
                Set<PDPPIPConfig> configs = window.getSelectedConfigs();
                replacedert configs != null;
                self.group.setPipConfigs(configs);
                // 
                // Update the container
                // 
                self.pipContainer.refresh();
            }
        });
        window.center();
        UI.getCurrent().addWindow(window);
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Validate
                    // 
                    self.textName.commit();
                    // 
                    // All good save everything
                    // 
                    self.doSave();
                    // 
                    // mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (InvalidValueException e) {
                // NOPMD
                // 
                // Ignore, Vaadin will display our message
                // 
                }
            }
        });
    }

    protected void doSave() {
        if (this.group == null) {
            return;
        }
        StdPDPGroup updatedGroupObject = new StdPDPGroup(this.group.getId(), this.group.isDefaultGroup(), this.textName.getValue(), this.textDescription.getValue(), null);
        // replace the original set of Policies with the set from the container (possibly modified by the user)
        Set<PDPPolicy> changedPolicies = new HashSet<PDPPolicy>();
        changedPolicies.addAll((Collection<PDPPolicy>) EditPDPGroupWindow.policyContainer.gereplacedemIds());
        updatedGroupObject.setPolicies(changedPolicies);
        updatedGroupObject.setPdps(this.group.getPdps());
        // replace the original set of PIP Configs with the set from the container
        // TODO - get PIP Configs from a container used to support editing
        // selfPDPObject.getPipConfigs().clear();
        // selfPDPObject.getPipConfigs().addAll(containerGroup.getPipConfigs());
        updatedGroupObject.setPipConfigs(this.group.getPipConfigs());
        // copy those things that the user cannot change from the original to the new object
        updatedGroupObject.setStatus(this.group.getStatus());
        this.updatedObject = updatedGroupObject;
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getGroupName() {
        return this.textName.getValue();
    }

    public String getGroupDescription() {
        return this.textDescription.getValue();
    }

    public PDPGroup getUpdatedObject() {
        return this.updatedObject;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("100.0%");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textName
        textName = new TextField();
        textName.setCaption("Group Name");
        textName.setImmediate(false);
        textName.setWidth("-1px");
        textName.setHeight("-1px");
        textName.setRequired(true);
        mainLayout.addComponent(textName);
        // textDescription
        textDescription = new TextArea();
        textDescription.setCaption("Group Description");
        textDescription.setImmediate(false);
        textDescription.setWidth("100.0%");
        textDescription.setHeight("-1px");
        textDescription.setNullSettingAllowed(true);
        mainLayout.addComponent(textDescription);
        mainLayout.setExpandRatio(textDescription, 1.0f);
        // tablePolicies
        tablePolicies = new Table();
        tablePolicies.setCaption("Policies");
        tablePolicies.setImmediate(false);
        tablePolicies.setWidth("-1px");
        tablePolicies.setHeight("-1px");
        mainLayout.addComponent(tablePolicies);
        mainLayout.setExpandRatio(tablePolicies, 1.0f);
        // tablePIP
        tablePIP = new Table();
        tablePIP.setCaption("PIP Configurations");
        tablePIP.setImmediate(false);
        tablePIP.setWidth("-1px");
        tablePIP.setHeight("-1px");
        mainLayout.addComponent(tablePIP);
        mainLayout.setExpandRatio(tablePIP, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : MinistryRankingOverviewPageModContentFactoryImpl.java
Copyright Apache License 2.0
Author : Hack23
/**
 * Creates the description.
 *
 * @return the text area
 */
private static TextArea createDescription() {
    final TextArea totalCommitteeRankinglistLabel = new TextArea(MINISTRY_RANKING_BY_TOPIC, MINISTRY_RANKING_BY_TOPIC_DESCRIPTION);
    totalCommitteeRankinglistLabel.setSizeFull();
    totalCommitteeRankinglistLabel.setStyleName("Level2Header");
    return totalCommitteeRankinglistLabel;
}

19 View Complete Implementation : GitPushWindow.java
Copyright MIT License
Author : att
public clreplaced GitPushWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonPush;

    @AutoGenerated
    private Table tableChanges;

    @AutoGenerated
    private TextArea textAreaComments;

    /**
     */
    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(GitPushWindow.clreplaced);

    private final GitPushWindow self = this;

    private final GitStatusContainer container;

    private final Git git;

    private final File target;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param git
     * @param target
     * @param status
     */
    public GitPushWindow(Git git, File target, Status status) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save data
        // 
        this.git = git;
        this.target = target;
        this.container = new GitStatusContainer(status);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeText();
        this.initializeTable(status);
        this.initializeButtons();
        // 
        // Focus
        // 
        this.textAreaComments.focus();
    }

    protected void initializeText() {
        this.textAreaComments.setImmediate(true);
        this.textAreaComments.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void textChange(TextChangeEvent event) {
                if (event.getText().isEmpty()) {
                    self.buttonPush.setEnabled(false);
                } else {
                    if (self.container.getConflictCount() == 0) {
                        self.buttonPush.setEnabled(true);
                    } else {
                        self.buttonPush.setEnabled(false);
                    }
                }
            }
        });
    }

    protected void initializeTable(Status status) {
        // 
        // Setup the table
        // 
        this.tableChanges.setContainerDataSource(this.container);
        this.tableChanges.setPageLength(this.container.size());
        this.tableChanges.setImmediate(true);
        // 
        // Generate column
        // 
        this.tableChanges.addGeneratedColumn("Entry", new ColumnGenerator() {

            private static final long serialVersionUID = 1L;

            @Override
            public Object generateCell(Table source, Object itemId, Object columnId) {
                Item item = self.container.gereplacedem(itemId);
                replacedert (item != null);
                if (item instanceof StatusItem) {
                    return self.generateGitEntryComponent(((StatusItem) item).getGitEntry());
                }
                replacedert (item instanceof StatusItem);
                return null;
            }
        });
    }

    protected Object generateGitEntryComponent(final GitEntry entry) {
        // 
        // If its conflicting, take care of it
        // 
        if (entry.isConflicting()) {
            return this.generateConflictingEntry(entry);
        }
        if (entry.isUntracked()) {
            return this.generateUntrackedEntry(entry);
        }
        /*
		if (entry.isChanged() ||
			entry.isModified() ||
			entry.isUncommitted()) {
			return this.generateUncommittedEntry(entry);
		}
		*/
        return null;
    }

    protected Object generateConflictingEntry(final GitEntry entry) {
        Button resolve = new Button("Resolve");
        resolve.setImmediate(true);
        resolve.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
            }
        });
        return resolve;
    }

    protected Object generateUntrackedEntry(final GitEntry entry) {
        Button add = new Button("Add");
        add.setImmediate(true);
        add.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    DirCache cache = self.git.add().addFilepattern(entry.getName()).call();
                    DirCacheEntry cacheEntry = cache.getEntry(entry.getName());
                    replacedert (cacheEntry != null);
                    if (cacheEntry == null) {
                        return;
                    }
                    if (cacheEntry.isMerged()) {
                        self.refreshStatus();
                    }
                } catch (GitAPIException e) {
                    String error = "Failed to add: " + e.getLocalizedMessage();
                    logger.error(error);
                    AdminNotification.error(error);
                }
            }
        });
        return add;
    }

    protected Object generateUncommittedEntry(final GitEntry entry) {
        Button commit = new Button("Commit");
        commit.setImmediate(true);
        commit.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
            }
        });
        return commit;
    }

    protected void initializeButtons() {
        this.buttonPush.setEnabled(false);
        this.buttonPush.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.textAreaComments.commit();
                    // 
                    // Mark as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException idontcare) {
                // 
                // Vaadin will highlight the failed requirement or validation
                // 
                }
            }
        });
    }

    protected void refreshStatus() {
        try {
            // 
            // Grab our working repository
            // 
            Path repoPath = ((XacmlAdminUI) getUI()).getUserGitPath();
            final Git git = Git.open(repoPath.toFile());
            // 
            // Get our status
            // 
            final String base;
            Status status;
            if (target == null) {
                base = ".";
            } else {
                Path relativePath = repoPath.relativize(Paths.get(target.getPath()));
                base = relativePath.toString();
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Status on base: " + base);
            }
            status = git.status().addPath(base).call();
            // 
            // Preplaced it to our container
            // 
            this.container.refreshStatus(status);
            this.tableChanges.refreshRowCache();
        } catch (NoWorkTreeException | IOException | GitAPIException e) {
            String error = "Failed to refresh status: " + e.getLocalizedMessage();
            logger.error(error);
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public String getComment() {
        return this.textAreaComments.getValue();
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaComments
        textAreaComments = new TextArea();
        textAreaComments.setCaption("Add Comments");
        textAreaComments.setImmediate(false);
        textAreaComments.setDescription("Enter comments that reflect the changes you have made to the repository domains and/or policy files.");
        textAreaComments.setWidth("400px");
        textAreaComments.setHeight("-1px");
        textAreaComments.setInvalidAllowed(false);
        textAreaComments.setRequired(true);
        textAreaComments.setInputPrompt("Eg. Add new rule for employees in marketing department.");
        mainLayout.addComponent(textAreaComments);
        // tableChanges
        tableChanges = new Table();
        tableChanges.setCaption("Changes To Be Pushed");
        tableChanges.setImmediate(false);
        tableChanges.setWidth("100.0%");
        tableChanges.setHeight("-1px");
        mainLayout.addComponent(tableChanges);
        mainLayout.setExpandRatio(tableChanges, 1.0f);
        // buttonPush
        buttonPush = new Button();
        buttonPush.setCaption("Push Changes");
        buttonPush.setImmediate(true);
        buttonPush.setWidth("-1px");
        buttonPush.setHeight("-1px");
        mainLayout.addComponent(buttonPush);
        mainLayout.setComponentAlignment(buttonPush, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : PoliticianRankingOverviewPageModContentFactoryImpl.java
Copyright Apache License 2.0
Author : Hack23
/**
 * Creates the description.
 *
 * @return the text area
 */
private static TextArea createDescription() {
    final TextArea totalpoliticantoplistLabel = new TextArea("Politician Ranking by topic", "Time served in Parliament:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion" + "\nTime served in Committees:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion" + "\nTime served in Government:ALL:CURRENT:*FILTER:Gender,Party,ElectionRegion" + "\nTop doreplacedent author NR:ALL:YEAR:CURRENT:*FILTER:DoreplacednetType,Gender,Party,ElectionRegion" + "\nTop doreplacedent author SIZE:YEAR:ALL:CURRENT:*FILTER:DoreplacednetType,Gender,Party,ElectionRegion" + "\nTop votes:ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion" + "\nTop vote winner NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion" + "\nTop vote party rebel NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion" + "\nTop vote presence NR/PERCENTAGE :ALL:YEAR:CURRENT::*FILTER:Gender,Party,ElectionRegion" + "\nSearch by name");
    totalpoliticantoplistLabel.setSizeFull();
    totalpoliticantoplistLabel.setStyleName("Level2Header");
    return totalpoliticantoplistLabel;
}

19 View Complete Implementation : PolicyEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced PolicyEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private ListSelect listSelectAlgorithm;

    @AutoGenerated
    private TextField textFieldVersion;

    @AutoGenerated
    private Label labelID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final PolicyEditorWindow self = this;

    private final PolicyType policy;

    private JPAContainer<RuleAlgorithms> algorithms = ((XacmlAdminUI) UI.getCurrent()).getRuleAlgorithms();

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public PolicyEditorWindow(PolicyType policy) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.policy = policy;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeLabel();
        this.initializeText();
        this.initializeSelect();
        this.initializeButton();
        // 
        // Focus
        // 
        this.textAreaDescription.focus();
    }

    protected void initializeLabel() {
        if (this.policy.getPolicyId() == null) {
            this.policy.setPolicyId(((XacmlAdminUI) UI.getCurrent()).newPolicyID());
        }
        this.labelID.setValue(this.policy.getPolicyId());
    }

    protected void initializeText() {
        // 
        // 
        // 
        this.textAreaDescription.setNullRepresentation("");
        this.textAreaDescription.setValue(this.policy.getDescription());
        // 
        // 
        // 
        if (this.policy.getVersion() == null) {
            this.policy.setVersion("1");
        }
        this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
        this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
        this.textFieldVersion.setValue(this.policy.getVersion());
    }

    protected void initializeSelect() {
        this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
        this.listSelectAlgorithm.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.listSelectAlgorithm.sereplacedemCaptionPropertyId("xacmlId");
        this.listSelectAlgorithm.setNullSelectionAllowed(false);
        if (this.policy.getRuleCombiningAlgId() == null) {
            this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
        }
        this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.listSelectAlgorithm.commit();
                    self.textFieldVersion.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    self.policy.setDescription(self.textAreaDescription.getValue());
                    self.policy.setVersion(self.textFieldVersion.getValue());
                    Object id = self.listSelectAlgorithm.getValue();
                    self.policy.setRuleCombiningAlgId(algorithms.gereplacedem(id).getEnreplacedy().getXacmlId());
                    // 
                    // Mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // NOPMD
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public PolicyType getPolicySet() {
        return this.policy;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelID
        labelID = new Label();
        labelID.setCaption("Policy Set ID");
        labelID.setImmediate(false);
        labelID.setWidth("100.0%");
        labelID.setHeight("-1px");
        labelID.setValue("Label");
        mainLayout.addComponent(labelID);
        // textFieldVersion
        textFieldVersion = new TextField();
        textFieldVersion.setCaption("Version");
        textFieldVersion.setImmediate(false);
        textFieldVersion.setDescription("The format is numbers only separated by decimal point.");
        textFieldVersion.setWidth("-1px");
        textFieldVersion.setHeight("-1px");
        textFieldVersion.setInvalidAllowed(false);
        textFieldVersion.setRequired(true);
        textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
        mainLayout.addComponent(textFieldVersion);
        // listSelectAlgorithm
        listSelectAlgorithm = new ListSelect();
        listSelectAlgorithm.setCaption("Policy Combining Algorithm");
        listSelectAlgorithm.setImmediate(false);
        listSelectAlgorithm.setWidth("100.0%");
        listSelectAlgorithm.setHeight("-1px");
        listSelectAlgorithm.setInvalidAllowed(false);
        listSelectAlgorithm.setRequired(true);
        mainLayout.addComponent(listSelectAlgorithm);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : QueryPanel.java
Copyright Apache License 2.0
Author : korpling
/**
 * @author thomas
 */
public clreplaced QueryPanel extends GridLayout implements ValueChangeListener {

    public static final int MAX_HISTORY_MENU_ITEMS = 5;

    // the view name
    public static final String NAME = "query";

    private AqlCodeEditor txtQuery;

    private TextArea txtStatus;

    private Button btShowResult;

    // private Button btShowResultNewTab;
    private PopupButton btHistory;

    private final ListSelect lstHistory;

    private final QueryUIState state;

    private ProgressBar piCount;

    private String lastPublicStatus;

    private Window historyWindow;

    private PopupButton btMoreActions;

    private FrequencyQueryPanel frequencyPanel;

    private final AnnisUI ui;

    private final BeanItemContainer<Query> historyContainer = new BeanItemContainer<>(Query.clreplaced);

    public QueryPanel(final AnnisUI ui) {
        super(4, 5);
        this.ui = ui;
        this.lastPublicStatus = "Welcome to ANNIS! " + "A tutorial is available on the right side.";
        this.state = ui.getQueryState();
        setSpacing(true);
        setMargin(false);
        setRowExpandRatio(0, 1.0f);
        setColumnExpandRatio(0, 0.0f);
        setColumnExpandRatio(1, 0.1f);
        setColumnExpandRatio(2, 0.0f);
        setColumnExpandRatio(3, 0.0f);
        txtQuery = new AqlCodeEditor();
        txtQuery.setPropertyDataSource(state.getAql());
        txtQuery.setInputPrompt("Please enter AQL query");
        txtQuery.addStyleName("query");
        if (ui.getInstanceFont() == null) {
            txtQuery.addStyleName("default-query-font");
            txtQuery.setTextareaStyle("default-query-font");
        } else {
            txtQuery.addStyleName(Helper.CORPUS_FONT);
            txtQuery.setTextareaStyle(Helper.CORPUS_FONT);
        }
        txtQuery.addStyleName("keyboardInput");
        txtQuery.setWidth("100%");
        txtQuery.setHeight(15f, Unit.EM);
        txtQuery.setTextChangeTimeout(500);
        final VirtualKeyboardCodeEditor virtualKeyboard;
        if (ui.getInstanceConfig().getKeyboardLayout() == null) {
            virtualKeyboard = null;
        } else {
            virtualKeyboard = new VirtualKeyboardCodeEditor();
            virtualKeyboard.setKeyboardLayout(ui.getInstanceConfig().getKeyboardLayout());
            virtualKeyboard.extend(txtQuery);
        }
        txtStatus = new TextArea();
        txtStatus.setValue(this.lastPublicStatus);
        txtStatus.setWidth("100%");
        txtStatus.setHeight(4.0f, Unit.EM);
        txtStatus.addStyleName("border-layout");
        txtStatus.setReadOnly(true);
        piCount = new ProgressBar();
        piCount.setIndeterminate(true);
        piCount.setEnabled(false);
        piCount.setVisible(false);
        btShowResult = new Button("Search");
        btShowResult.setIcon(FontAwesome.SEARCH);
        btShowResult.setWidth("100%");
        btShowResult.addClickListener(new ShowResultClickListener());
        btShowResult.setDescription("<strong>Show Result</strong><br />Ctrl + Enter", ContentMode.HTML);
        btShowResult.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL);
        btShowResult.setDisableOnClick(true);
        VerticalLayout historyListLayout = new VerticalLayout();
        historyListLayout.setSizeUndefined();
        lstHistory = new ListSelect();
        lstHistory.setWidth("200px");
        lstHistory.setNullSelectionAllowed(false);
        lstHistory.setValue(null);
        lstHistory.addValueChangeListener((ValueChangeListener) this);
        lstHistory.setImmediate(true);
        lstHistory.setContainerDataSource(historyContainer);
        lstHistory.sereplacedemCaptionPropertyId("query");
        lstHistory.addStyleName(Helper.CORPUS_FONT);
        Button btShowMoreHistory = new Button("Show more details", new Button.ClickListener() {

            @Override
            public void buttonClick(ClickEvent event) {
                if (historyWindow == null) {
                    historyWindow = new Window("History");
                    historyWindow.setModal(false);
                    historyWindow.setWidth("400px");
                    historyWindow.setHeight("250px");
                }
                historyWindow.setContent(new HistoryPanel(state.getHistory(), ui.getQueryController()));
                if (UI.getCurrent().getWindows().contains(historyWindow)) {
                    historyWindow.bringToFront();
                } else {
                    UI.getCurrent().addWindow(historyWindow);
                }
            }
        });
        btShowMoreHistory.setWidth("100%");
        historyListLayout.addComponent(lstHistory);
        historyListLayout.addComponent(btShowMoreHistory);
        historyListLayout.setExpandRatio(lstHistory, 1.0f);
        historyListLayout.setExpandRatio(btShowMoreHistory, 0.0f);
        btHistory = new PopupButton("History");
        btHistory.setContent(historyListLayout);
        btHistory.setDescription("<strong>Show History</strong><br />" + "Either use the short overview (arrow down) or click on the button " + "for the extended view.", ContentMode.HTML);
        Button btShowKeyboard = null;
        if (virtualKeyboard != null) {
            btShowKeyboard = new Button();
            btShowKeyboard.setWidth("100%");
            btShowKeyboard.setDescription("Click to show a virtual keyboard");
            btShowKeyboard.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
            btShowKeyboard.addStyleName(ValoTheme.BUTTON_SMALL);
            btShowKeyboard.setIcon(new ClreplacedResource(VirtualKeyboardCodeEditor.clreplaced, "keyboard.png"));
            btShowKeyboard.addClickListener(new ShowKeyboardClickListener(virtualKeyboard));
        }
        final JSClipboard clipboard = new JSClipboard();
        Button btCopy = new Button("");
        btCopy.setWidth("100%");
        btCopy.setDescription("Copy query to clipboard");
        btCopy.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        btCopy.addStyleName(ValoTheme.BUTTON_SMALL);
        btCopy.setIcon(FontAwesome.COPY);
        clipboard.apply(btCopy, txtQuery);
        clipboard.setText(state.getAql().getValue());
        state.getAql().addValueChangeListener(new ValueChangeListener() {

            @Override
            public void valueChange(ValueChangeEvent event) {
                clipboard.setText(event.getProperty().getValue().toString());
            }
        });
        clipboard.addSuccessListener(new JSClipboard.SuccessListener() {

            @Override
            public void onSuccess() {
                Notification.show("Copied AQL to clipboard");
            }
        });
        Button btShowQueryBuilder = new Button("Query<br />Builder");
        btShowQueryBuilder.setHtmlContentAllowed(true);
        btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_SMALL);
        btShowQueryBuilder.addStyleName(ValoTheme.BUTTON_ICON_ALIGN_TOP);
        btShowQueryBuilder.setIcon(new ThemeResource("images/tango-icons/32x32/doreplacedent-properties.png"));
        btShowQueryBuilder.addClickListener(new ShowQueryBuilderClickListener(ui));
        VerticalLayout moreActionsLayout = new VerticalLayout();
        moreActionsLayout.setWidth("250px");
        btMoreActions = new PopupButton("More");
        btMoreActions.setContent(moreActionsLayout);
        // btShowResultNewTab = new Button("Search (open in new tab)");
        // btShowResultNewTab.setWidth("100%");
        // btShowResultNewTab.addClickListener(new ShowResultInNewTabClickListener());
        // btShowResultNewTab.setDescription("<strong>Show Result and open result in new tab</strong><br />Ctrl + Shift + Enter");
        // btShowResultNewTab.setDisableOnClick(true);
        // btShowResultNewTab.setClickShortcut(KeyCode.ENTER, ModifierKey.CTRL, ModifierKey.SHIFT);
        // moreActionsLayout.addComponent(btShowResultNewTab);
        Button btShowExport = new Button("Export", new ShowExportClickListener(ui));
        btShowExport.setIcon(FontAwesome.DOWNLOAD);
        btShowExport.setWidth("100%");
        moreActionsLayout.addComponent(btShowExport);
        Button btShowFrequency = new Button("Frequency replacedysis", new ShowFrequencyClickListener(ui));
        btShowFrequency.setIcon(FontAwesome.BAR_CHART_O);
        btShowFrequency.setWidth("100%");
        moreActionsLayout.addComponent(btShowFrequency);
        /*
     * We use the grid layout for a better rendering efficiency, but this comes
     * with the cost of some complexity when defining the positions of the
     * elements in the layout.
     * 
     * This grid hopefully helps a little bit in understanding the "magic"
     * numbers better.
     * 
     * Q: Query text field
     * QB: Button to toggle query builder // TODO
     * KEY: Button to show virtual keyboard
     * COPY: Button for copying the text
     * SEA: "Search" button
     * MOR: "More actions" button 
     * HIST: "History" button
     * STAT: Text field with the real status
     * PROG: indefinite progress bar (spinning circle)
     * 
     *  \   0  |  1  |  2  |  3  
     * --+-----+---+---+---+-----
     * 0 |  Q  |  Q  |  Q  | QB 
     * --+-----+-----+-----+-----
     * 1 |  Q  |  Q  |  Q  | KEY 
     * --+-----+-----+-----+-----
     * 2 |  Q  |  Q  |  Q  | COPY
     * --+-----+-----+-----+-----
     * 3 | SEA | MOR | HIST|     
     * --+-----+-----+-----+-----
     * 4 | STAT| STAT| STAT| PROG
     */
        addComponent(txtQuery, 0, 0, 2, 2);
        addComponent(txtStatus, 0, 4, 2, 4);
        addComponent(btShowResult, 0, 3);
        addComponent(btMoreActions, 1, 3);
        addComponent(btHistory, 2, 3);
        addComponent(piCount, 3, 4);
        addComponent(btShowQueryBuilder, 3, 0);
        if (btShowKeyboard != null) {
            addComponent(btShowKeyboard, 3, 1);
            addComponent(btCopy, 3, 2);
        } else {
            addComponent(btCopy, 3, 1);
        }
        // alignment
        setRowExpandRatio(0, 0.0f);
        setRowExpandRatio(1, 0.0f);
        setRowExpandRatio(2, 1.0f);
        setColumnExpandRatio(0, 1.0f);
        setColumnExpandRatio(1, 0.0f);
        setColumnExpandRatio(2, 0.0f);
        setColumnExpandRatio(3, 0.0f);
    // setComponentAlignment(btShowQueryBuilder, Alignment.BOTTOM_CENTER);
    }

    @Override
    public void attach() {
        super.attach();
        IDGenerator.replacedignIDForFields(QueryPanel.this, btShowResult, btMoreActions);
    }

    public void updateShortHistory() {
        historyContainer.removeAllItems();
        int counter = 0;
        for (Query q : state.getHistory().gereplacedemIds()) {
            if (counter >= MAX_HISTORY_MENU_ITEMS) {
                break;
            } else {
                historyContainer.addBean(q);
            }
            counter++;
        }
    }

    public void setQuery(String query) {
        if (txtQuery != null) {
            txtQuery.setValue(query);
        }
    }

    public String getQuery() {
        if (txtQuery != null) {
            return (String) txtQuery.getValue();
        }
        return "";
    }

    public void setNodes(List<NodeDesc> nodes) {
        txtQuery.setNodes(nodes);
    }

    public void setErrors(List<AqlParseError> errors) {
        txtQuery.setErrors(errors);
    }

    public void notifyFrequencyTabClose() {
        txtQuery.removeTextChangeListener(frequencyPanel);
        frequencyPanel = null;
    }

    @Override
    public void valueChange(ValueChangeEvent event) {
        btHistory.setPopupVisible(false);
        Object q = event.getProperty().getValue();
        if (ui != null && ui.getQueryController() != null && q instanceof Query) {
            ui.getQueryController().setQuery((Query) q);
        }
    }

    public clreplaced ShowResultClickListener implements Button.ClickListener {

        @Override
        public void buttonClick(ClickEvent event) {
            if (ui != null && ui.getQueryController() != null) {
                ui.getQueryController().executeSearch(true, true);
            }
        }
    }

    // public clreplaced ShowResultInNewTabClickListener implements Button.ClickListener
    // {
    // 
    // @Override
    // public void buttonClick(ClickEvent event)
    // {
    // if(controller != null)
    // {
    // controller.setQuery((txtQuery.getValue()));
    // controller.executeQuery(false);
    // }
    // }
    // }
    public void setCountIndicatorEnabled(boolean enabled) {
        if (piCount != null && btShowResult != null && txtStatus != null) {
            if (enabled) {
                if (!piCount.isVisible()) {
                    piCount.setVisible(true);
                    piCount.setEnabled(true);
                }
            }
            btShowResult.setEnabled(!enabled);
        // btShowResultNewTab.setEnabled(!enabled);
        }
    }

    public void setStatus(String status) {
        if (txtStatus != null) {
            txtStatus.setReadOnly(false);
            txtStatus.setValue(status);
            lastPublicStatus = status;
            txtStatus.setReadOnly(true);
        }
    }

    public void setStatus(String status, String resultStatus) {
        if (txtStatus != null) {
            txtStatus.setReadOnly(false);
            txtStatus.setValue(status + resultStatus);
            lastPublicStatus = status;
            txtStatus.setReadOnly(true);
        }
    }

    private static clreplaced ShowKeyboardClickListener implements ClickListener {

        private final VirtualKeyboardCodeEditor virtualKeyboard;

        public ShowKeyboardClickListener(VirtualKeyboardCodeEditor virtualKeyboard) {
            this.virtualKeyboard = virtualKeyboard;
        }

        @Override
        public void buttonClick(ClickEvent event) {
            virtualKeyboard.show();
        }
    }

    private clreplaced ShowExportClickListener implements ClickListener {

        private AnnisUI ui;

        private ExportPanel panel;

        public ShowExportClickListener(AnnisUI ui) {
            this.ui = ui;
        }

        @Override
        public void buttonClick(ClickEvent event) {
            if (panel == null) {
                panel = new ExportPanel(QueryPanel.this, ui.getQueryController(), state, ui);
            }
            final TabSheet tabSheet = ui.getSearchView().getMainTab();
            Tab tab = tabSheet.getTab(panel);
            if (tab == null) {
                tab = tabSheet.addTab(panel, "Export");
                tab.setIcon(FontAwesome.DOWNLOAD);
            }
            tab.setClosable(true);
            tabSheet.setSelectedTab(panel);
            btMoreActions.setPopupVisible(false);
        }
    }

    private clreplaced ShowFrequencyClickListener implements ClickListener {

        private AnnisUI ui;

        public ShowFrequencyClickListener(AnnisUI ui) {
            this.ui = ui;
        }

        @Override
        public void buttonClick(ClickEvent event) {
            if (frequencyPanel == null) {
                frequencyPanel = new FrequencyQueryPanel(ui.getQueryController(), state);
                txtQuery.addTextChangeListener(frequencyPanel);
            }
            final TabSheet tabSheet = ui.getSearchView().getMainTab();
            Tab tab = tabSheet.getTab(frequencyPanel);
            if (tab == null) {
                tab = tabSheet.addTab(frequencyPanel, "Frequency replacedysis");
                tab.setIcon(FontAwesome.BAR_CHART_O);
            }
            tab.setClosable(true);
            tabSheet.setSelectedTab(frequencyPanel);
            btMoreActions.setPopupVisible(false);
        }
    }

    private static clreplaced ShowQueryBuilderClickListener implements ClickListener {

        private QueryBuilderChooser queryBuilder;

        private AnnisUI ui;

        public ShowQueryBuilderClickListener(AnnisUI ui) {
            this.ui = ui;
        }

        @Override
        public void buttonClick(ClickEvent event) {
            if (queryBuilder == null) {
                queryBuilder = new QueryBuilderChooser(ui.getQueryController(), ui, ui.getInstanceConfig());
            }
            final TabSheet tabSheet = ui.getSearchView().getMainTab();
            Tab tab = tabSheet.getTab(queryBuilder);
            if (tab == null) {
                tab = tabSheet.addTab(queryBuilder, "Query Builder", new ThemeResource("images/tango-icons/16x16/doreplacedent-properties.png"));
                ui.addAction(new ShortcutListener("^Query builder") {

                    @Override
                    public void handleAction(Object sender, Object target) {
                        if (queryBuilder != null && tabSheet.getTab(queryBuilder) != null) {
                            tabSheet.setSelectedTab(queryBuilder);
                        }
                    }
                });
            }
            tab.setClosable(true);
            tabSheet.setSelectedTab(queryBuilder);
        }
    }

    public String getLastPublicStatus() {
        return lastPublicStatus;
    }

    public ProgressBar getPiCount() {
        return piCount;
    }
}

19 View Complete Implementation : ObadviceEditorWindow.java
Copyright MIT License
Author : att
public clreplaced ObadviceEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    private static final long serialVersionUID = 1L;

    private ObadviceEditorWindow self = this;

    private FormLayout mainLayout = new FormLayout();

    @PropertyId("type")
    OptionGroup typeOption = new OptionGroup("Type");

    @PropertyId("xacmlId")
    TextField xacmlID = new TextField("Obligation Id");

    @PropertyId("description")
    TextArea descriptionField = new TextArea("Description");

    @PropertyId("fulfillOn")
    OptionGroup fulfillOption = new OptionGroup("Fullfill On");

    @PropertyId("obadviceExpressions")
    OaExpressionsField expressionsField;

    // Table tableExpressions = new Table("Attribute replacedignments");
    Button saveButton = new Button("Save");

    private FieldGroup fieldGroup = null;

    private final EnreplacedyItem<Obadvice> obad;

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param obad
     */
    public ObadviceEditorWindow(EnreplacedyItem<Obadvice> obad) {
        this.setContent(mainLayout);
        // 
        // Save
        // 
        this.obad = obad;
        // 
        // Initialize main layout
        // 
        this.mainLayout.setMargin(true);
        this.mainLayout.setWidth("-1px");
        // 
        // Initialize components
        // 
        this.typeOption.setNullSelectionAllowed(false);
        this.typeOption.setImmediate(true);
        this.typeOption.setDescription("Select whether this is an obligation or advice");
        this.typeOption.addItem("Obligation");
        this.typeOption.addItem("Advice");
        this.fulfillOption.setNullSelectionAllowed(true);
        this.fulfillOption.setDescription("Optionally restrict the use of the obligation/advice to a Permit or a Deny");
        this.fulfillOption.addItem("Permit");
        this.fulfillOption.addItem("Deny");
        this.descriptionField.setNullRepresentation("");
        this.expressionsField = new OaExpressionsField(this.obad);
        // 
        // Add our form components
        // 
        this.mainLayout.addComponent(this.typeOption);
        this.mainLayout.addComponent(this.fulfillOption);
        this.mainLayout.addComponent(this.xacmlID);
        this.mainLayout.addComponent(this.descriptionField);
        this.mainLayout.addComponent(this.expressionsField);
        // this.mainLayout.addComponent(this.tableExpressions);
        this.mainLayout.addComponent(this.saveButton);
        // 
        // Now bind those fields to the data
        // 
        this.fieldGroup = new FieldGroup(obad);
        this.fieldGroup.bindMemberFields(this);
        // 
        // Finish setting up
        // 
        this.initializeButtons();
        this.initializeOptions();
        // 
        // Set focus
        // 
        this.xacmlID.focus();
    }

    private void initializeButtons() {
        this.saveButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    fieldGroup.commit();
                    self.isSaved = true;
                    self.close();
                } catch (CommitException e) {
                    e.printStackTrace();
                }
            }
        });
    }

    private void initializeOptions() {
        self.setIDCaption();
        this.typeOption.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                self.setIDCaption();
            }
        });
    }

    private void setIDCaption() {
        String value = (String) self.typeOption.getValue();
        if (value.equals("Obligation")) {
            self.xacmlID.setCaption("Obligation Id");
        } else {
            self.xacmlID.setCaption("Advice Id");
        }
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public void discard() {
        // 
        // May be discarded automatically??
        // 
        this.fieldGroup.discard();
    }
}

19 View Complete Implementation : FormHelper.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public <M> TextArea bindTextAreaField(AbstractLayout form, ValidatingFieldGroup<E> group, String fieldLabel, SingularAttribute<E, M> member, int rows) {
    TextArea field = bindTextAreaField(form, group, fieldLabel, member.getName(), rows);
    this.fieldList.add(field);
    return field;
}

19 View Complete Implementation : ApplyEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced ApplyEditorWindow extends Window implements ApplyParametersChangedNotifier {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSelect;

    @AutoGenerated
    private Table tableFunction;

    @AutoGenerated
    private HorizontalLayout horizontalLayout_1;

    @AutoGenerated
    private CheckBox checkBoxFilterIsBag;

    @AutoGenerated
    private ComboBox comboBoxDatatypeFilter;

    @AutoGenerated
    private TextField textFieldFilter;

    @AutoGenerated
    private TextArea textAreaDescription;

    /**
     */
    private static final long serialVersionUID = 1L;

    private static Log logger = LogFactory.getLog(ApplyEditorWindow.clreplaced);

    private final ApplyEditorWindow self = this;

    private final ApplyParametersChangedNotifier notifier = new ApplyParametersChangedNotifier.BasicNotifier();

    private final BeanItemContainer<FunctionDefinition> container = new BeanItemContainer<FunctionDefinition>(FunctionDefinition.clreplaced);

    private final ApplyType apply;

    private final ApplyType applyParent;

    private final FunctionArgument argument;

    private final Object parent;

    private boolean isSaved = false;

    private FunctionDefinition function = null;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param parent
     * @param parentApply
     */
    public ApplyEditorWindow(ApplyType apply, ApplyType parentApply, FunctionArgument argument, Object parent) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.apply = apply;
        this.applyParent = parentApply;
        this.argument = argument;
        this.parent = parent;
        logger.info(this.apply + " " + this.applyParent + " " + this.argument + " " + this.parent);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize
        // 
        this.textAreaDescription.setValue(apply.getDescription());
        this.textAreaDescription.setNullRepresentation("");
        this.initializeButton();
        this.initializeTable();
        this.initializeFilters();
        // 
        // focus
        // 
        this.textFieldFilter.focus();
    }

    protected void initializeTable() {
        // 
        // Setup GUI properties
        // 
        this.tableFunction.setImmediate(true);
        this.tableFunction.setSelectable(true);
        this.tableFunction.setNullSelectionAllowed(false);
        this.tableFunction.setRequired(true);
        this.tableFunction.setRequiredError("You MUST select a function for the Apply");
        // 
        // Set its data source
        // 
        this.tableFunction.setContainerDataSource(this.container);
        this.tableFunction.setVisibleColumns(new Object[] { "xacmlid", "shortname", "datatypeBean", "isBagReturn" });
        this.tableFunction.setColumnHeaders(new String[] { "Function Xacml ID", "ID", "Return Data Type", "Return Bag?" });
        // 
        // Determine appropriate filters
        // 
        Datatype datatypeId = null;
        if (this.applyParent == null) {
            if (this.parent instanceof ConditionType) {
                // 
                // Only boolean functions allowed
                // 
                datatypeId = JPAUtils.findDatatype(XACML3.ID_DATATYPE_BOOLEAN);
            }
        } else {
            String parentFunction = this.applyParent.getFunctionId();
            this.function = JPAUtils.findFunction(parentFunction);
            if (this.function == null) {
                throw new IllegalArgumentException("applyParent's function is not found:" + parentFunction);
            }
            if (this.argument == null) {
                throw new IllegalArgumentException("Need to know what argument apply is ");
            }
            datatypeId = this.argument.getDatatypeBean();
        }
        Map<Datatype, List<FunctionDefinition>> functionMap = JPAUtils.getFunctionDatatypeMap();
        if (datatypeId == null) {
            // 
            // All functions are available
            // 
            for (Datatype id : functionMap.keySet()) {
                this.addTableEntries(functionMap.get(id));
            }
        } else {
            for (Datatype id : functionMap.keySet()) {
                if (id == null) {
                    if (datatypeId == null) {
                        this.addTableEntries(functionMap.get(id));
                        break;
                    }
                    continue;
                }
                if (id.getId() == datatypeId.getId()) {
                    this.addTableEntries(functionMap.get(id));
                    break;
                }
            }
        }
        // 
        // Setup double-click
        // 
        this.tableFunction.addItemClickListener(new ItemClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void itemClick(ItemClickEvent event) {
                if (event.isDoubleClick()) {
                    self.selected();
                }
            }
        });
        // 
        // Value change listener
        // 
        this.tableFunction.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                logger.info("valueChange " + self.tableFunction.getValue());
                if (self.tableFunction.getValue() != null) {
                    self.buttonSelect.setEnabled(true);
                } else {
                    self.buttonSelect.setEnabled(false);
                }
            }
        });
        // 
        // Select current value if possible
        // 
        if (this.apply != null && this.apply.getFunctionId() != null && this.apply.getFunctionId().isEmpty() == false) {
            FunctionDefinition current = JPAUtils.findFunction(this.apply.getFunctionId());
            if (current != null) {
                this.tableFunction.select(current);
                this.tableFunction.setCurrentPageFirsreplacedemId(current);
            } else {
                logger.warn("Could not find function in table for " + this.apply.getFunctionId());
            }
        } else {
            this.buttonSelect.setEnabled(false);
        }
    }

    protected void addTableEntries(List<FunctionDefinition> functions) {
        if (functions == null) {
            logger.warn("NULL list of functions, cannot add to table.");
            return;
        }
        for (FunctionDefinition function : functions) {
            // 
            // Just check if this function is available for this
            // apply.
            // 
            // if (XACMLFunctionValidator.isFunctionAvailable(function, this.apply, this.argument)) {
            this.container.addBean(function);
        // } else {
        // if (logger.isDebugEnabled()) {
        // logger.debug("Function not available: " + function);
        // }
        // }
        }
    }

    protected void initializeButton() {
        this.buttonSelect.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                self.selected();
            }
        });
    }

    protected void initializeFilters() {
        this.textFieldFilter.setImmediate(true);
        this.textFieldFilter.addTextChangeListener(new TextChangeListener() {

            private static final long serialVersionUID = 1L;

            SimpleStringFilter currentFilter = null;

            @Override
            public void textChange(TextChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Get the text
                // 
                String value = event.getText();
                if (value != null && value.length() > 0) {
                    // 
                    // Add the new filter
                    // 
                    this.currentFilter = new SimpleStringFilter("shortname", value, true, false);
                    self.container.addContainerFilter(this.currentFilter);
                }
            }
        });
        this.comboBoxDatatypeFilter.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
        this.comboBoxDatatypeFilter.setImmediate(true);
        this.comboBoxDatatypeFilter.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.comboBoxDatatypeFilter.sereplacedemCaptionPropertyId("xacmlId");
        this.comboBoxDatatypeFilter.setNullSelectionAllowed(true);
        this.comboBoxDatatypeFilter.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            Container.Filter currentFilter = null;

            @Override
            public void valueChange(ValueChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Get the current selection
                // 
                Object id = self.comboBoxDatatypeFilter.getValue();
                if (id == null) {
                    return;
                }
                // 
                // Setup the filter
                // 
                final Datatype datatype = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().gereplacedem(id).getEnreplacedy();
                this.currentFilter = new Container.Filter() {

                    private static final long serialVersionUID = 1L;

                    @Override
                    public boolean preplacedesFilter(Object itemId, Item item) throws UnsupportedOperationException {
                        if (itemId instanceof FunctionDefinition) {
                            Datatype dt = ((FunctionDefinition) itemId).getDatatypeBean();
                            if (dt == null) {
                                return false;
                            }
                            return dt.getXacmlId().equals(datatype.getXacmlId());
                        }
                        return false;
                    }

                    @Override
                    public boolean appliesToProperty(Object propertyId) {
                        if (propertyId != null && propertyId.toString().equals("datatypeBean")) {
                            return true;
                        }
                        return false;
                    }
                };
                self.container.addContainerFilter(this.currentFilter);
            }
        });
        this.checkBoxFilterIsBag.setImmediate(true);
        this.checkBoxFilterIsBag.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            Filter currentFilter = null;

            @Override
            public void valueChange(ValueChangeEvent event) {
                // 
                // Remove current filter
                // 
                if (this.currentFilter != null) {
                    self.container.removeContainerFilter(this.currentFilter);
                    this.currentFilter = null;
                }
                // 
                // Is it checked?
                // 
                if (self.checkBoxFilterIsBag.getValue() == false) {
                    // 
                    // Nope, get out of here
                    // 
                    return;
                }
                // 
                // Add the filter
                // 
                this.currentFilter = new Compare.Equal("isBagReturn", true);
                self.container.addContainerFilter(this.currentFilter);
            }
        });
    }

    protected void selected() {
        // 
        // Is there a selected function?
        // 
        try {
            // 
            // Run the commit
            // 
            this.textAreaDescription.commit();
            this.tableFunction.commit();
            // 
            // Commit worked, get the selected function
            // 
            Object id = this.tableFunction.getValue();
            // 
            // Sanity check, it *should* never be null
            // unless someone changed the initialization code.
            // 
            if (id == null || !(id instanceof FunctionDefinition)) {
                throw new InvalidValueException(this.tableFunction.getRequiredError());
            }
            // 
            // Get the actual function and save it into the apply
            // 
            this.function = (FunctionDefinition) id;
            this.apply.setDescription(this.textAreaDescription.getValue());
            this.apply.setFunctionId(function.getXacmlid());
        } catch (SourceException | InvalidValueException e) {
            // 
            // Vaadin GUI will display message
            // 
            return;
        }
        /**
         * 		//
         * 		// Make sure the arguments are good
         * 		//
         * 		final ApplyType copyApply = XACMLObjectCopy.copy(this.apply);
         * 		final ApplyArgumentsEditorWindow window = new ApplyArgumentsEditorWindow(copyApply, this.function);
         * 		window.setCaption("Define Arguments for " + this.function.getShortname());
         * 		window.setModal(true);
         * 		window.addCloseListener(new CloseListener() {
         * 			private static final long serialVersionUID = 1L;
         *
         * 			@Override
         * 			public void windowClose(CloseEvent e) {
         * 				//
         * 				// Did the user click save?
         * 				//
         * 				if (window.isSaved() == false) {
         * 					return;
         * 				}
         * 				//
         * 				// Save our arguments
         * 				//
         * 				self.apply.getExpression().clear();
         * 				self.apply.getExpression().addAll(copyApply.getExpression());
         * 				//
         * 				// We are saved
         * 				//
         * 				self.isSaved = true;
         * 				//
         * 				// Fire
         * 				//
         * 				self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
         * 				//
         * 				// Close the apply editor window
         * 				//
         * 				self.close();
         * 			}
         * 		});
         * 		window.center();
         * 		UI.getCurrent().addWindow(window);
         */
        // 
        // We are saved
        // 
        self.isSaved = true;
        // 
        // Fire
        // 
        self.fireEvent(self.apply, self.applyParent, self.argument, self.parent);
        // 
        // Close the apply editor window
        // 
        self.close();
    }

    @Override
    public boolean addListener(ApplyParametersChangedListener listener) {
        return this.notifier.addListener(listener);
    }

    @Override
    public boolean removeListener(ApplyParametersChangedListener listener) {
        return this.notifier.removeListener(listener);
    }

    @Override
    public void fireEvent(ApplyType apply, ApplyType parent, FunctionArgument argument, Object container) {
        this.notifier.fireEvent(apply, parent, argument, container);
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public FunctionDefinition getSelectedFunction() {
        return this.function;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // horizontalLayout_1
        horizontalLayout_1 = buildHorizontalLayout_1();
        mainLayout.addComponent(horizontalLayout_1);
        // tableFunction
        tableFunction = new Table();
        tableFunction.setCaption("Select A Function");
        tableFunction.setImmediate(false);
        tableFunction.setWidth("100.0%");
        tableFunction.setHeight("-1px");
        tableFunction.setInvalidAllowed(false);
        tableFunction.setRequired(true);
        mainLayout.addComponent(tableFunction);
        mainLayout.setExpandRatio(tableFunction, 1.0f);
        // buttonSelect
        buttonSelect = new Button();
        buttonSelect.setCaption("Select and Continue");
        buttonSelect.setImmediate(true);
        buttonSelect.setWidth("-1px");
        buttonSelect.setHeight("-1px");
        mainLayout.addComponent(buttonSelect);
        mainLayout.setComponentAlignment(buttonSelect, new Alignment(48));
        return mainLayout;
    }

    @AutoGenerated
    private HorizontalLayout buildHorizontalLayout_1() {
        // common part: create layout
        horizontalLayout_1 = new HorizontalLayout();
        horizontalLayout_1.setImmediate(false);
        horizontalLayout_1.setWidth("-1px");
        horizontalLayout_1.setHeight("-1px");
        horizontalLayout_1.setMargin(false);
        horizontalLayout_1.setSpacing(true);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Enter A Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("50.0%");
        textAreaDescription.setHeight("-1px");
        horizontalLayout_1.addComponent(textAreaDescription);
        // textFieldFilter
        textFieldFilter = new TextField();
        textFieldFilter.setCaption("Filter Function By ID");
        textFieldFilter.setImmediate(false);
        textFieldFilter.setWidth("-1px");
        textFieldFilter.setHeight("-1px");
        horizontalLayout_1.addComponent(textFieldFilter);
        horizontalLayout_1.setComponentAlignment(textFieldFilter, new Alignment(9));
        // comboBoxDatatypeFilter
        comboBoxDatatypeFilter = new ComboBox();
        comboBoxDatatypeFilter.setCaption("Filter By Data Type");
        comboBoxDatatypeFilter.setImmediate(false);
        comboBoxDatatypeFilter.setWidth("-1px");
        comboBoxDatatypeFilter.setHeight("-1px");
        horizontalLayout_1.addComponent(comboBoxDatatypeFilter);
        horizontalLayout_1.setComponentAlignment(comboBoxDatatypeFilter, new Alignment(9));
        // checkBoxFilterIsBag
        checkBoxFilterIsBag = new CheckBox();
        checkBoxFilterIsBag.setCaption("Is Bag Filter");
        checkBoxFilterIsBag.setImmediate(false);
        checkBoxFilterIsBag.setWidth("-1px");
        checkBoxFilterIsBag.setHeight("-1px");
        horizontalLayout_1.addComponent(checkBoxFilterIsBag);
        horizontalLayout_1.setComponentAlignment(checkBoxFilterIsBag, new Alignment(9));
        return horizontalLayout_1;
    }
}

19 View Complete Implementation : FormHelper.java
Copyright GNU General Public License v3.0
Author : rlsutton1
public TextArea bindTextAreaField(String fieldLabel, String fieldName, int rows, int maxlength) {
    TextArea field = bindTextAreaField(form, group, fieldLabel, fieldName, rows);
    field.setMaxLength(maxlength);
    this.fieldList.add(field);
    return field;
}

19 View Complete Implementation : PolicyEditorWindow.java
Copyright MIT License
Author : att
public clreplaced PolicyEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private ListSelect listSelectAlgorithm;

    @AutoGenerated
    private TextField textFieldVersion;

    @AutoGenerated
    private Label labelID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final PolicyEditorWindow self = this;

    private final PolicyType policy;

    private JPAContainer<RuleAlgorithms> algorithms = ((XacmlAdminUI) UI.getCurrent()).getRuleAlgorithms();

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     * @param policy
     */
    public PolicyEditorWindow(PolicyType policy) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.policy = policy;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeLabel();
        this.initializeText();
        this.initializeSelect();
        this.initializeButton();
        // 
        // Focus
        // 
        this.textAreaDescription.focus();
    }

    protected void initializeLabel() {
        if (this.policy.getPolicyId() == null) {
            this.policy.setPolicyId(((XacmlAdminUI) UI.getCurrent()).newPolicyID());
        }
        this.labelID.setValue(this.policy.getPolicyId());
    }

    protected void initializeText() {
        // 
        // 
        // 
        this.textAreaDescription.setNullRepresentation("");
        this.textAreaDescription.setValue(this.policy.getDescription());
        // 
        // 
        // 
        if (this.policy.getVersion() == null) {
            this.policy.setVersion("1");
        }
        this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
        this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
        this.textFieldVersion.setValue(this.policy.getVersion());
    }

    protected void initializeSelect() {
        this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
        this.listSelectAlgorithm.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.listSelectAlgorithm.sereplacedemCaptionPropertyId("xacmlId");
        this.listSelectAlgorithm.setNullSelectionAllowed(false);
        if (this.policy.getRuleCombiningAlgId() == null) {
            this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
        }
        this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.listSelectAlgorithm.commit();
                    self.textFieldVersion.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    self.policy.setDescription(self.textAreaDescription.getValue());
                    self.policy.setVersion(self.textFieldVersion.getValue());
                    Object id = self.listSelectAlgorithm.getValue();
                    self.policy.setRuleCombiningAlgId(algorithms.gereplacedem(id).getEnreplacedy().getXacmlId());
                    // 
                    // Mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public PolicyType getPolicySet() {
        return this.policy;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelID
        labelID = new Label();
        labelID.setCaption("Policy Set ID");
        labelID.setImmediate(false);
        labelID.setWidth("100.0%");
        labelID.setHeight("-1px");
        labelID.setValue("Label");
        mainLayout.addComponent(labelID);
        // textFieldVersion
        textFieldVersion = new TextField();
        textFieldVersion.setCaption("Version");
        textFieldVersion.setImmediate(false);
        textFieldVersion.setDescription("The format is numbers only separated by decimal point.");
        textFieldVersion.setWidth("-1px");
        textFieldVersion.setHeight("-1px");
        textFieldVersion.setInvalidAllowed(false);
        textFieldVersion.setRequired(true);
        textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
        mainLayout.addComponent(textFieldVersion);
        // listSelectAlgorithm
        listSelectAlgorithm = new ListSelect();
        listSelectAlgorithm.setCaption("Policy Combining Algorithm");
        listSelectAlgorithm.setImmediate(false);
        listSelectAlgorithm.setWidth("100.0%");
        listSelectAlgorithm.setHeight("-1px");
        listSelectAlgorithm.setInvalidAllowed(false);
        listSelectAlgorithm.setRequired(true);
        mainLayout.addComponent(listSelectAlgorithm);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : PolicySetEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced PolicySetEditorWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSave;

    @AutoGenerated
    private TextArea textAreaDescription;

    @AutoGenerated
    private ListSelect listSelectAlgorithm;

    @AutoGenerated
    private TextField textFieldVersion;

    @AutoGenerated
    private Label labelID;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final PolicySetEditorWindow self = this;

    private final PolicySetType policySet;

    private JPAContainer<PolicyAlgorithms> algorithms = ((XacmlAdminUI) UI.getCurrent()).getPolicyAlgorithms();

    private boolean isSaved = false;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public PolicySetEditorWindow(PolicySetType policySet) {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Save
        // 
        this.policySet = policySet;
        // 
        // Close shortcut
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Initialize GUI
        // 
        this.initializeLabel();
        this.initializeText();
        this.initializeSelect();
        this.initializeButton();
        // 
        // Focus
        // 
        this.textAreaDescription.focus();
    }

    protected void initializeLabel() {
        if (this.policySet.getPolicySetId() == null) {
            this.policySet.setPolicySetId(((XacmlAdminUI) UI.getCurrent()).newPolicyID());
        }
        this.labelID.setValue(this.policySet.getPolicySetId());
    }

    protected void initializeText() {
        // 
        // 
        // 
        this.textAreaDescription.setNullRepresentation("");
        this.textAreaDescription.setValue(this.policySet.getDescription());
        // 
        // 
        // 
        if (this.policySet.getVersion() == null) {
            this.policySet.setVersion("1");
        }
        this.textFieldVersion.setRequiredError("The exact format is: ((\\d+|\\*)\\.)*(\\d+|\\*|\\+)");
        this.textFieldVersion.addValidator(new RegexpValidator("((\\d+|\\*)\\.)*(\\d+|\\*|\\+)", true, "The version MUST a number optionally separated by '.' eg. 1 or 1.0 or 1.1.1 etc."));
        this.textFieldVersion.setValue(this.policySet.getVersion());
    }

    protected void initializeSelect() {
        this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
        this.listSelectAlgorithm.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.listSelectAlgorithm.sereplacedemCaptionPropertyId("xacmlId");
        this.listSelectAlgorithm.setNullSelectionAllowed(false);
        if (this.policySet.getPolicyCombiningAlgId() == null) {
            this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
        }
        this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
    }

    protected void initializeButton() {
        this.buttonSave.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // Commit
                    // 
                    self.listSelectAlgorithm.commit();
                    self.textFieldVersion.commit();
                    self.textAreaDescription.commit();
                    // 
                    // Save everything
                    // 
                    self.policySet.setDescription(self.textAreaDescription.getValue());
                    self.policySet.setVersion(self.textFieldVersion.getValue());
                    Object id = self.listSelectAlgorithm.getValue();
                    self.policySet.setPolicyCombiningAlgId(algorithms.gereplacedem(id).getEnreplacedy().getXacmlId());
                    // 
                    // Mark ourselves as saved
                    // 
                    self.isSaved = true;
                    // 
                    // Close window
                    // 
                    self.close();
                } catch (SourceException | InvalidValueException e) {
                // NOPMD
                // 
                // VAADIN will show the required error message to the user
                // 
                }
            }
        });
    }

    public boolean isSaved() {
        return this.isSaved;
    }

    public PolicySetType getPolicySet() {
        return this.policySet;
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // labelID
        labelID = new Label();
        labelID.setCaption("Policy Set ID");
        labelID.setImmediate(false);
        labelID.setWidth("100.0%");
        labelID.setHeight("-1px");
        labelID.setValue("Label");
        mainLayout.addComponent(labelID);
        // textFieldVersion
        textFieldVersion = new TextField();
        textFieldVersion.setCaption("Version");
        textFieldVersion.setImmediate(false);
        textFieldVersion.setDescription("The format is numbers only separated by decimal point.");
        textFieldVersion.setWidth("-1px");
        textFieldVersion.setHeight("-1px");
        textFieldVersion.setInvalidAllowed(false);
        textFieldVersion.setRequired(true);
        textFieldVersion.setInputPrompt("Eg. 1 or 1.0 or 1.0.0 etc.");
        mainLayout.addComponent(textFieldVersion);
        // listSelectAlgorithm
        listSelectAlgorithm = new ListSelect();
        listSelectAlgorithm.setCaption("Policy Combining Algorithm");
        listSelectAlgorithm.setImmediate(false);
        listSelectAlgorithm.setWidth("100.0%");
        listSelectAlgorithm.setHeight("-1px");
        listSelectAlgorithm.setInvalidAllowed(false);
        listSelectAlgorithm.setRequired(true);
        mainLayout.addComponent(listSelectAlgorithm);
        // textAreaDescription
        textAreaDescription = new TextArea();
        textAreaDescription.setCaption("Description");
        textAreaDescription.setImmediate(false);
        textAreaDescription.setWidth("100.0%");
        textAreaDescription.setHeight("-1px");
        mainLayout.addComponent(textAreaDescription);
        mainLayout.setExpandRatio(textAreaDescription, 1.0f);
        // buttonSave
        buttonSave = new Button();
        buttonSave.setCaption("Save");
        buttonSave.setImmediate(true);
        buttonSave.setWidth("-1px");
        buttonSave.setHeight("-1px");
        mainLayout.addComponent(buttonSave);
        mainLayout.setComponentAlignment(buttonSave, new Alignment(48));
        return mainLayout;
    }
}

19 View Complete Implementation : CmsSqlConsoleLayout.java
Copyright GNU Lesser General Public License v2.1
Author : alkacon
/**
 * Widget for the SQL console.<p>
 */
public clreplaced CmsSqlConsoleLayout extends VerticalLayout {

    /**
     * Serial version id.
     */
    private static final long serialVersionUID = 1L;

    /**
     * The button to execute the SQL.
     */
    protected Button m_ok;

    /**
     * Combo box for selecting the pool.
     */
    protected ComboBox<String> m_pool;

    /**
     * Text area containing the SQL statements.
     */
    protected TextArea m_script;

    /**
     * The executor.
     */
    private CmsSqlConsoleExecutor m_console;

    /**
     * Creates a new instance.<p>
     *
     * @param console the SQL executor
     */
    public CmsSqlConsoleLayout(CmsSqlConsoleExecutor console) {
        CmsVaadinUtils.readAndLocalizeDesign(this, CmsVaadinUtils.getWpMessagesForCurrentLocale(), null);
        m_console = console;
        m_ok.addClickListener(evt -> runQuery());
        m_pool.sereplacedems(OpenCms.getDbPoolNames());
        m_pool.setValue(CmsDbPoolV11.getDefaultDbPoolName());
        m_pool.setEmptySelectionAllowed(false);
    }

    /**
     * Runs the currently entered query and displays the results.
     */
    protected void runQuery() {
        String pool = m_pool.getValue();
        String stmt = m_script.getValue();
        if (stmt.trim().isEmpty()) {
            return;
        }
        CmsStringBufferReport report = new CmsStringBufferReport(Locale.ENGLISH);
        List<Throwable> errors = new ArrayList<>();
        CmsSqlConsoleResults result = m_console.execute(stmt, pool, report, errors);
        if (errors.size() > 0) {
            CmsErrorDialog.showErrorDialog(report.toString() + errors.get(0).getMessage(), errors.get(0));
        } else {
            Window window = CmsBasicDialog.prepareWindow(DialogWidth.max);
            window.setCaption(CmsVaadinUtils.getMessageText(Messages.GUI_SQLCONSOLE_QUERY_RESULTS_0));
            window.setContent(new CmsSqlConsoleResultsForm(result, report.toString()));
            A_CmsUI.get().addWindow(window);
            window.center();
        }
    }
}

19 View Complete Implementation : AttributeEditorWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced AttributeEditorWindow extends Window {

    private static final long serialVersionUID = 1L;

    private static final Log logger = LogFactory.getLog(AttributeEditorWindow.clreplaced);

    private AttributeEditorWindow self = this;

    private boolean isSaved = false;

    private Attribute attribute;

    private FormLayout mainLayout = new FormLayout();

    @PropertyId("isDesignator")
    DesignatorSelectorField selectDesignator;

    @PropertyId("selectorPath")
    TextField selectorPath = new TextField("Attribute Selector Path");

    @PropertyId("xacmlId")
    TextField xacmlID = new TextField("XACML ID");

    @PropertyId("categoryBean")
    ComboBox category = new ComboBox("Category");

    @PropertyId("description")
    TextArea descriptionField = new TextArea("Description");

    @PropertyId("datatypeBean")
    ComboBox datatype = new ComboBox("DataType");

    @PropertyId("constraintType")
    ComboBox constraintTypes = new ComboBox("Constraint Type");

    @PropertyId("constraintValues")
    ConstraintField constraintValues;

    Button saveButton = new Button("Save");

    FieldGroup fieldGroup = null;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public AttributeEditorWindow(EnreplacedyItem<Attribute> enreplacedyItem) {
        // 
        // Save our attribute
        // 
        this.attribute = enreplacedyItem.getEnreplacedy();
        if (logger.isDebugEnabled()) {
            logger.debug("Editing attribute: " + enreplacedyItem.getEnreplacedy().toString());
        }
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // Create our main layout
        // 
        this.setContent(mainLayout);
        // 
        // Finish setting up the main layout
        // 
        this.mainLayout.setSpacing(true);
        this.mainLayout.setMargin(true);
        // 
        // Setup option group, binding the
        // field group doesn't seem to work.
        // 
        this.selectDesignator = new DesignatorSelectorField(enreplacedyItem);
        this.selectDesignator.setCaption("Select the Attribute Type");
        this.selectDesignator.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Object value = self.selectDesignator.getValue();
                if (value == null || !(value instanceof Character)) {
                    self.selectorPath.setVisible(false);
                }
                if (((Character) value) == '1') {
                    self.selectorPath.setVisible(false);
                } else {
                    self.selectorPath.setVisible(true);
                }
            }
        });
        // 
        // Setup selector path
        // 
        this.selectorPath.setImmediate(true);
        this.selectorPath.setNullRepresentation("");
        this.selectorPath.setWidth("100%");
        // 
        // Setup the Category combo
        // 
        this.category.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getCategories());
        this.category.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.category.sereplacedemCaptionPropertyId("xacmlId");
        this.category.setFilteringMode(FilteringMode.CONTAINS);
        this.category.setImmediate(true);
        this.category.setNullSelectionAllowed(false);
        this.category.setConverter(new SingleSelectConverter<Object>(this.category));
        // 
        // Setup the Datatype combo
        // 
        this.datatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
        this.datatype.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.datatype.sereplacedemCaptionPropertyId("xacmlId");
        this.datatype.setFilteringMode(FilteringMode.CONTAINS);
        this.datatype.setImmediate(true);
        this.datatype.setNullSelectionAllowed(false);
        this.datatype.setConverter(new SingleSelectConverter<Object>(this.datatype));
        // 
        // Setup the constraint type combo
        // 
        this.constraintTypes.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getConstraintTypes());
        this.constraintTypes.sereplacedemCaptionMode(ItemCaptionMode.PROPERTY);
        this.constraintTypes.sereplacedemCaptionPropertyId("constraintType");
        this.constraintTypes.setFilteringMode(FilteringMode.CONTAINS);
        this.constraintTypes.setImmediate(true);
        this.constraintTypes.setNullSelectionAllowed(true);
        this.constraintTypes.setConverter(new SingleSelectConverter<Object>(this.constraintTypes));
        // 
        // Setup the constraint value custom field
        // 
        this.constraintValues = new ConstraintField(enreplacedyItem);
        // 
        // Finish laying out the main layout
        // 
        this.mainLayout.addComponent(this.selectDesignator);
        this.mainLayout.addComponent(this.selectorPath);
        this.mainLayout.addComponent(this.xacmlID);
        this.mainLayout.addComponent(this.category);
        this.mainLayout.addComponent(this.descriptionField);
        this.mainLayout.addComponent(this.datatype);
        this.mainLayout.addComponent(this.constraintTypes);
        this.mainLayout.addComponent(this.constraintValues);
        // 
        // Now create our field group and bind our bean items
        // This will populate the components with the attribute's
        // current value.
        // 
        this.fieldGroup = new FieldGroup(enreplacedyItem);
        this.fieldGroup.bindMemberFields(this);
        // 
        // Finishing setting up after the bind. There are some components
        // where initializing the bind causes some properties to be reset.
        // 
        this.xacmlID.setWidth("100%");
        this.descriptionField.setNullRepresentation("");
        this.descriptionField.setWidth("100%");
        this.setupDatatype(this.attribute.getDatatypeBean().getIdentifer());
        this.datatype.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Identifier id = self.getCurrentDatatype();
                if (id != null) {
                    self.setupDatatype(id);
                }
            }
        });
        // 
        // Listen to when constraint type changes
        // 
        this.constraintTypes.addValueChangeListener(new ValueChangeListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void valueChange(ValueChangeEvent event) {
                Object value = self.constraintTypes.getValue();
                if (value == null) {
                    self.constraintValues.resetContent(null, self.getCurrentDatatype());
                } else {
                    ConstraintType newValue = ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().gereplacedem(value).getEnreplacedy();
                    self.constraintValues.resetContent(newValue, self.getCurrentDatatype());
                }
            }
        });
        // 
        // Setup our "SAVE" button to commit the fields
        // 
        this.mainLayout.addComponent(this.saveButton);
        this.mainLayout.setComponentAlignment(this.saveButton, Alignment.MIDDLE_CENTER);
        this.saveButton.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                try {
                    // 
                    // SAVE the latest values
                    // 
                    fieldGroup.commit();
                    // 
                    // Set that we did save the attribute
                    // 
                    self.isSaved = true;
                    // 
                    // Close the window
                    // 
                    self.close();
                } catch (CommitException e) {
                    logger.error("Failed to commit fields", e);
                }
            }
        });
        // 
        // Add our close listener so we can discard anything that was changed.
        // 
        this.addCloseListener(new CloseListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void windowClose(CloseEvent e) {
                if (self.isSaved == false) {
                    logger.info("discarding");
                    // 
                    // Discard any changes to the existing JPA container enreplacedy
                    // 
                    self.fieldGroup.discard();
                    // 
                    // Make sure there are no filters on the container
                    // 
                    ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
                }
            }
        });
        // 
        // Set focus
        // 
        this.xacmlID.focus();
    }

    private void setupDatatype(Identifier datatype) {
        if (datatype.equals(XACML3.ID_DATATYPE_INTEGER) || datatype.equals(XACML3.ID_DATATYPE_DOUBLE)) {
            ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().removeAllContainerFilters();
            this.constraintTypes.setEnabled(true);
            this.constraintValues.resetDatatype(datatype);
            return;
        }
        if (datatype.equals(XACML3.ID_DATATYPE_STRING)) {
            ((XacmlAdminUI) UI.getCurrent()).getConstraintTypes().addContainerFilter(new Not(new Compare.Equal("constraintType", ConstraintType.RANGE_TYPE)));
            if (this.attribute.getConstraintType() != null && this.attribute.getConstraintType().getConstraintType() != null && this.attribute.getConstraintType().getConstraintType().equals(ConstraintType.RANGE_TYPE)) {
                this.attribute.setConstraintType(null);
            }
            this.constraintValues.resetDatatype(datatype);
            return;
        }
        // 
        // No constraint for all other datatypes
        // 
        this.attribute.setConstraintType(null);
        this.constraintTypes.select(null);
        this.constraintTypes.setEnabled(false);
    }

    private Identifier getCurrentDatatype() {
        Object id = self.datatype.getValue();
        if (id != null) {
            EnreplacedyItem<Datatype> dt = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().gereplacedem(id);
            if (dt != null) {
                return dt.getEnreplacedy().getIdentifer();
            }
        }
        return null;
    }

    public boolean isSaved() {
        return this.isSaved;
    }
}

19 View Complete Implementation : GitSynchronizeWindow.java
Copyright Apache License 2.0
Author : apache
public clreplaced GitSynchronizeWindow extends Window {

    /*- VaadinEditorProperties={"grid":"RegularGrid,20","showGrid":true,"snapToGrid":true,"snapToObject":true,"movingGuides":false,"snappingDistance":10} */
    @AutoGenerated
    private VerticalLayout mainLayout;

    @AutoGenerated
    private Button buttonSynchronize;

    @AutoGenerated
    private TextArea textAreaResults;

    /**
     */
    private static final long serialVersionUID = 1L;

    private final GitSynchronizeWindow self = this;

    /**
     * The constructor should first build the main layout, set the
     * composition root and then do any custom initialization.
     *
     * The constructor will not be automatically regenerated by the
     * visual editor.
     */
    public GitSynchronizeWindow() {
        buildMainLayout();
        // setCompositionRoot(mainLayout);
        setContent(mainLayout);
        // 
        // Set our shortcuts
        // 
        this.setCloseShortcut(KeyCode.ESCAPE);
        // 
        // 
        // 
        this.initializeButtons();
    }

    protected void initializeButtons() {
        this.buttonSynchronize.addClickListener(new ClickListener() {

            private static final long serialVersionUID = 1L;

            @Override
            public void buttonClick(ClickEvent event) {
                if (self.buttonSynchronize.getCaption().equals("Synchronize")) {
                    self.synchronize();
                } else {
                    self.close();
                }
            }
        });
    }

    protected void synchronize() {
        // 
        // Grab our working repository
        // 
        Path repoPath = ((XacmlAdminUI) getUI()).getUserGitPath();
        try {
            final Git git = Git.open(repoPath.toFile());
            PullResult result = git.pull().call();
            // FetchResult fetch = result.getFetchResult();
            // MergeResult merge = result.getMergeResult();
            // RebaseResult rebase = result.getRebaseResult();
            if (result.isSuccessful()) {
                // 
                // TODO add more notification
                // 
                this.textAreaResults.setValue("Successful!");
            } else {
                // 
                // TODO
                // 
                this.textAreaResults.setValue("Failed.");
            }
        } catch (IOException | GitAPIException e) {
            e.printStackTrace();
        }
        this.buttonSynchronize.setCaption("Ok");
    }

    @AutoGenerated
    private VerticalLayout buildMainLayout() {
        // common part: create layout
        mainLayout = new VerticalLayout();
        mainLayout.setImmediate(false);
        mainLayout.setWidth("-1px");
        mainLayout.setHeight("-1px");
        mainLayout.setMargin(true);
        mainLayout.setSpacing(true);
        // top-level component properties
        setWidth("-1px");
        setHeight("-1px");
        // textAreaResults
        textAreaResults = new TextArea();
        textAreaResults.setCaption("Synch Results");
        textAreaResults.setImmediate(false);
        textAreaResults.setWidth("462px");
        textAreaResults.setHeight("222px");
        mainLayout.addComponent(textAreaResults);
        // buttonSynchronize
        buttonSynchronize = new Button();
        buttonSynchronize.setCaption("Synchronize");
        buttonSynchronize.setImmediate(true);
        buttonSynchronize.setWidth("-1px");
        buttonSynchronize.setHeight("-1px");
        mainLayout.addComponent(buttonSynchronize);
        mainLayout.setComponentAlignment(buttonSynchronize, new Alignment(24));
        return mainLayout;
    }
}

19 View Complete Implementation : LogLayout.java
Copyright Apache License 2.0
Author : apache
public clreplaced LogLayout extends VerticalLayout {

    private final static Logger LOG = LoggerFactory.getLogger(LogLayout.clreplaced);

    private TextArea logArea;

    private RandomAccessFile r;

    private File file;

    public LogLayout() {
        initializeUIComponents();
        this.setSizeFull();
    }

    private void initializeUIComponents() {
        addLogArea();
        addRefreshButton();
    }

    private void addLogArea() {
        logArea = new TextArea("Coordinator Logs");
        // TODO make this file point configurable
        file = new File("/var/log/chop-webapp.log");
        try {
            r = new RandomAccessFile(file, "r");
        } catch (FileNotFoundException e) {
            LOG.error("Error while accessing file {}: {}", file, e);
        }
        logArea.setHeight("100%");
        logArea.setWidth("100%");
        getApplicationLog();
        addComponent(logArea);
        this.setComponentAlignment(logArea, Alignment.TOP_CENTER);
        this.setExpandRatio(logArea, 0.95f);
    }

    private void getApplicationLog() {
        logArea.setReadOnly(false);
        try {
            String str = null;
            StringBuilder log = new StringBuilder();
            log.append(logArea.getValue());
            while ((str = r.readLine()) != null) {
                log.append(str);
                log.append(System.getProperty("line.separator"));
            }
            r.seek(r.getFilePointer());
            logArea.setValue(log.toString());
            logArea.setCursorPosition(log.toString().length() - 1);
        } catch (IOException e) {
            e.printStackTrace();
        }
        logArea.setReadOnly(true);
    }

    private void addRefreshButton() {
        Button button = new Button("Refresh");
        button.setWidth("100px");
        button.addClickListener(new Button.ClickListener() {

            public void buttonClick(Button.ClickEvent event) {
                loadData();
            }
        });
        addComponent(button);
        setComponentAlignment(button, Alignment.BOTTOM_CENTER);
        this.setExpandRatio(button, 0.05f);
    }

    private void loadData() {
        getApplicationLog();
    }
}

19 View Complete Implementation : TextAreaBuilder.java
Copyright Eclipse Public License 1.0
Author : eclipse
@Override
protected TextArea createTextComponent() {
    final TextArea textArea = new TextArea();
    textArea.addStyleName(ValoTheme.TEXTAREA_SMALL);
    return textArea;
}