Example usage for com.vaadin.ui VerticalLayout setExpandRatio

List of usage examples for com.vaadin.ui VerticalLayout setExpandRatio

Introduction

In this page you can find the example usage for com.vaadin.ui VerticalLayout setExpandRatio.

Prototype

public void setExpandRatio(Component component, float ratio) 

Source Link

Document

This method is used to control how excess space in layout is distributed among components.

Usage

From source file:rs.pupin.jpo.validation.gui.constraints.IC03.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//  ww  w.  jav  a2 s . c o  m
    Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final List<String> dsdList = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        dsdList.add(set.getValue("dsd").stringValue());
    }

    if (dsdList.isEmpty()) {
        Label label = new Label();
        label.setValue("All DSDs contain at least one measure");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following DSDs do not have at least one measure defined");
    rootLayout.addComponent(lbl);

    final ListSelect listDSDs = new ListSelect("DSDs", dsdList);
    listDSDs.setNullSelectionAllowed(false);
    listDSDs.setImmediate(true);
    rootLayout.addComponent(listDSDs);

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue("After the fix, component selected in the combo box below will be turned to measure, "
            + "or you can choose to edit the above selected DSD manually in OntoWiki");
    panelLayout.addComponent(fixLabel);
    final ComboBox comboComponents = new ComboBox();
    comboComponents.setWidth("100%");
    comboComponents.setNullSelectionAllowed(false);
    comboComponents.setImmediate(true);
    panelLayout.addComponent(comboComponents);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button turnToMeasure = new Button("Turn to measure");
    btnLayout.addComponent(turnToMeasure);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    listDSDs.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String dsd = event.getProperty().getValue().toString();
            if (dsd == null || dsd.equalsIgnoreCase("")) {
                return;
            }

            comboComponents.removeAllItems();
            TupleQueryResult qRes = executeTupleQuery(
                    ValidationFixUtils.ic03_getRequiredAttributes(graph, dsd));
            try {
                while (qRes.hasNext()) {
                    comboComponents.addItem(qRes.next().getValue("attr").toString());
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    turnToMeasure.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Object selVal = comboComponents.getValue();
            if (selVal == null) {
                Notification.show("No component was selected in the combo box");
                return;
            }

            GraphQueryResult resFix = executeDoubleGraphQuery(
                    ValidationFixUtils.ic03_turnToMeasure(graph, selVal.toString()),
                    ValidationFixUtils.ic03_turnToMeasure2(graph, selVal.toString()));
            if (resFix != null) {
                Notification.show("Fix executed");
                icQuery.eval();
            }
        }
    });
    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listDSDs.getValue());
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC04.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from   ww  w  .  ja  va  2 s  .com
    Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final List<String> dimList = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        dimList.add(set.getValue("dim").stringValue());
    }

    if (dimList.isEmpty()) {
        Label label = new Label();
        label.setValue("All dimensions have a defined range");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following dimensions do not have a defined range");
    rootLayout.addComponent(lbl);

    final ListSelect listDimensions = new ListSelect("Dimensions", dimList);
    listDimensions.setNullSelectionAllowed(false);
    listDimensions.setImmediate(true);
    rootLayout.addComponent(listDimensions);

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue("After the fix, dimension chosen above will have a range chosen in the combo box below. "
            + "Alternatively, the problematic dimension can be edited manually in OntoWiki");
    panelLayout.addComponent(fixLabel);
    final ComboBox comboType = new ComboBox();
    comboType.setWidth("100%");
    comboType.setNullSelectionAllowed(false);
    comboType.setImmediate(true);
    panelLayout.addComponent(comboType);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button fix = new Button("Quick fix");
    btnLayout.addComponent(fix);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listDimensions.getValue());
        }
    });
    listDimensions.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String dim = event.getProperty().getValue().toString();
            String query = ValidationFixUtils.ic04_getMathingRange(graph, dim);
            TupleQueryResult qRes = executeTupleQuery(query);
            comboType.removeAllItems();
            try {
                while (qRes.hasNext()) {
                    comboType.addItem(qRes.next().getValue("type").stringValue());
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    fix.addClickListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            Object selDim = listDimensions.getValue();
            Object selType = comboType.getValue();
            if (selDim == null || selType == null) {
                Notification.show("Dimension or type was not selected");
                return;
            }

            GraphQueryResult fixRes = executeGraphQuery(
                    ValidationFixUtils.ic04_insertRange(graph, selDim.toString(), selType.toString()));
            if (fixRes != null) {
                Notification.show("Fix executed");
                // update GUI after the fix
                icQuery.eval();
            }
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC05.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from  www .  j  a  va  2s .c om
    Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final List<String> dimList = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        dimList.add(set.getValue("dim").stringValue());
    }

    if (dimList.isEmpty()) {
        Label label = new Label();
        label.setValue("No problems were detected - every dimension with range skos:Concept has a code list");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following dimensions with range skos:Concept do not have a code list");
    rootLayout.addComponent(lbl);

    final ListSelect listDimensions = new ListSelect("Dimensions", dimList);
    listDimensions.setNullSelectionAllowed(false);
    listDimensions.setImmediate(true);
    rootLayout.addComponent(listDimensions);

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue(
            "After the fix, dimension chosen above will be associated with the code list chosen in the combo box below. "
                    + "Alternatively, the problematic dimension can be edited manually in OntoWiki");
    panelLayout.addComponent(fixLabel);
    final ComboBox comboCodeLists = new ComboBox();
    comboCodeLists.setWidth("100%");
    comboCodeLists.setNullSelectionAllowed(false);
    comboCodeLists.setImmediate(true);
    panelLayout.addComponent(comboCodeLists);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button fix = new Button("Quick fix");
    btnLayout.addComponent(fix);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listDimensions.getValue());
        }
    });
    listDimensions.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String dim = event.getProperty().getValue().toString();
            String query = ValidationFixUtils.ic05_getMathingCodeLists(graph, dim);
            TupleQueryResult qRes = executeTupleQuery(query);
            comboCodeLists.removeAllItems();
            try {
                while (qRes.hasNext()) {
                    comboCodeLists.addItem(qRes.next().getValue("list").stringValue());
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Object selDim = listDimensions.getValue();
            Object selList = comboCodeLists.getValue();
            if (selDim == null || selList == null) {
                Notification.show("Dimension or code list was not selected");
                return;
            }

            GraphQueryResult fixRes = executeGraphQuery(
                    ValidationFixUtils.ic05_insertCodeList(graph, selDim.toString(), selList.toString()));
            if (fixRes != null) {
                Notification.show("Fix executed");
                icQuery.eval();
            }
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC06.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();// ww  w. j  a  va 2 s .  c o  m
    Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final HashMap<String, String> compMap = new HashMap<String, String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        compMap.put(set.getValue("component").stringValue(), set.getValue("dsd").stringValue());
    }

    if (compMap.isEmpty()) {
        Label label = new Label();
        label.setValue("No problems were detected - if there are any optional components, they are attributes");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following components are marked as optional, but they are not attributes");
    rootLayout.addComponent(lbl);

    final ListSelect listComponents = new ListSelect("Component Properties", compMap.keySet());
    listComponents.setNullSelectionAllowed(false);
    listComponents.setImmediate(true);
    rootLayout.addComponent(listComponents);

    final Table detailsTable = new Table("Details");
    detailsTable.setHeight("250px");
    detailsTable.setWidth("100%");
    detailsTable.addContainerProperty("Property", String.class, null);
    detailsTable.addContainerProperty("Object", String.class, null);
    rootLayout.addComponent(detailsTable);
    listComponents.addValueChangeListener(new DetailsListener(detailsTable));

    //      final Label lblProblem = new Label("<b>Problem description: </b>", Label.CONTENT_XHTML);
    //      validationTab.addComponent(lblProblem);
    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue(""); // TODO
    panelLayout.addComponent(fixLabel);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button removeCompReq = new Button("Remove qb:componentRequired");
    Button turnToAttr = new Button("Turn to attribute");
    btnLayout.addComponent(removeCompReq);
    btnLayout.addComponent(turnToAttr);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    removeCompReq.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            String chosenComponent = (String) listComponents.getValue();
            if (chosenComponent == null) {
                Notification.show("Cannot execute the action", "A component needs to be chosen first",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String chosenDSD = compMap.get(chosenComponent);
            String query = ValidationFixUtils.ic06_removeComponentRequired(graph, chosenDSD, chosenComponent);
            GraphQueryResult resFix = executeGraphQuery(query);
            if (resFix != null) {
                Notification.show("Fix executed");
                // evaluate again after the fix
                icQuery.eval();
            }
        }
    });
    turnToAttr.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            String chosenComponent = (String) listComponents.getValue();
            if (chosenComponent == null) {
                Notification.show("Cannot execute the action", "A component needs to be chosen first",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String query = ValidationFixUtils.ic06_changeToAttribute(graph, chosenComponent);
            String query2 = ValidationFixUtils.ic06_changeToAttribute2(graph, chosenComponent);
            GraphQueryResult resFix = executeDoubleGraphQuery(query, query2);
            if (resFix != null) {
                Notification.show("Fix executed");
                // evaluate again after the fix
                icQuery.eval();
            }
        }
    });
    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listComponents.getValue());
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC07.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from  w  ww.  j a  v a2s .  c om

    final Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final ArrayList<String> listSliceKeys = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        listSliceKeys.add(set.getValue("sliceKey").stringValue());
    }
    if (listSliceKeys.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - either there are no slice keys or every slice key is associated with a DSD");
        rootLayout.addComponent(label);
        return;
    }

    Label label = new Label();
    label.setValue("Following slice keys should be associated with a DSD");
    rootLayout.addComponent(label);
    final ListSelect lsSliceKeys = new ListSelect("Slice keys", listSliceKeys);
    lsSliceKeys.setImmediate(true);
    lsSliceKeys.setNullSelectionAllowed(false);
    rootLayout.addComponent(lsSliceKeys);

    final Table detailsTable = new Table("Slice key details");
    detailsTable.setHeight("250px");
    detailsTable.setWidth("100%");
    detailsTable.addContainerProperty("Property", String.class, null);
    detailsTable.addContainerProperty("Object", String.class, null);
    rootLayout.addComponent(detailsTable);

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue(
            "After the fix, slice key chosen above will be associated with the DSD chosen below, or you can edit the slice key manually.");
    panelLayout.addComponent(fixLabel);
    final ComboBox comboDSDs = new ComboBox();
    comboDSDs.setNullSelectionAllowed(false);
    comboDSDs.setWidth("100%");
    comboDSDs.setImmediate(true);
    panelLayout.addComponent(comboDSDs);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button fix = new Button("Quick fix");
    btnLayout.addComponent(fix);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) lsSliceKeys.getValue());
        }
    });
    lsSliceKeys.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            TupleQueryResult res = getResourceProperties((String) event.getProperty().getValue());
            int i = 1;
            detailsTable.removeAllItems();
            try {
                while (res.hasNext()) {
                    BindingSet set = res.next();
                    detailsTable.addItem(
                            new Object[] { set.getValue("p").stringValue(), set.getValue("o").stringValue() },
                            i++);
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    lsSliceKeys.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String sk = event.getProperty().getValue().toString();
            if (sk == null || sk.equalsIgnoreCase("")) {
                return;
            }

            TupleQueryResult resSliceKeys = executeTupleQuery(
                    ValidationFixUtils.ic07_getMatchingDSDs(graph, sk));
            comboDSDs.removeAllItems();
            try {
                while (resSliceKeys.hasNext()) {
                    comboDSDs.addItem(resSliceKeys.next().getValue("dsd").stringValue());
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Object selVal = comboDSDs.getValue();
            if (selVal == null) {
                Notification.show("No DSD was selected");
                return;
            }
            GraphQueryResult fixRes = executeGraphQuery(ValidationFixUtils.ic07_insertConnection(graph,
                    selVal.toString(), lsSliceKeys.getValue().toString()));

            if (fixRes != null) {
                Notification.show("Fix executed");
                // evaluate again thereby also updating the GUI
                icQuery.eval();
            }
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC09.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();/*ww  w  . j a  v  a2s. c om*/

    final Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final ArrayList<String> listSlices = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        listSlices.add(set.getValue("slice").stringValue());
    }
    if (listSlices.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - either there are no slices or every slice has a unique structure, i.e. exactly one associated slice key (via property qb:sliceStructure)");
        rootLayout.addComponent(label);
        return;
    }

    Label label = new Label();
    label.setValue(
            "Following slices have 0 or more than 1 associated slice keys (via property qb:sliceStructure)");
    rootLayout.addComponent(label);
    final ListSelect lsSlices = new ListSelect("Slices", listSlices);
    lsSlices.setImmediate(true);
    lsSlices.setNullSelectionAllowed(false);
    rootLayout.addComponent(lsSlices);

    final Table detailsTable = new Table("Slice details");
    detailsTable.setHeight("250px");
    detailsTable.setWidth("100%");
    detailsTable.addContainerProperty("Property", String.class, null);
    detailsTable.addContainerProperty("Object", String.class, null);
    rootLayout.addComponent(detailsTable);

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue(
            "After the fix, slice chosen above will be associated with the slice key chosen in the below combo box, "
                    + "or the problematic slice can be edited manuallz in OntoWiki");
    panelLayout.addComponent(fixLabel);
    final ComboBox comboKeys = new ComboBox();
    comboKeys.setWidth("100%");
    comboKeys.setNullSelectionAllowed(false);
    comboKeys.setImmediate(true);
    panelLayout.addComponent(comboKeys);
    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    Button fix = new Button("Quick fix");
    btnLayout.addComponent(fix);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) lsSlices.getValue());
        }
    });
    lsSlices.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            TupleQueryResult res = getResourceProperties((String) event.getProperty().getValue());
            int i = 1;
            detailsTable.removeAllItems();
            try {
                while (res.hasNext()) {
                    BindingSet set = res.next();
                    detailsTable.addItem(
                            new Object[] { set.getValue("p").stringValue(), set.getValue("o").stringValue() },
                            i++);
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    lsSlices.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            String slice = event.getProperty().toString();
            comboKeys.removeAllItems();
            TupleQueryResult resKeys = executeTupleQuery(ValidationFixUtils.ic09_getMatchingKeys(graph, slice));
            try {
                while (resKeys.hasNext()) {
                    comboKeys.addItem(resKeys.next().getValue("key"));
                }
            } catch (QueryEvaluationException e) {
                e.printStackTrace();
            }
        }
    });
    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            Object selKey = comboKeys.getValue();
            Object selSlice = lsSlices.getValue();
            if (selKey == null || selSlice == null) {
                Notification.show("No slice key or slice was selected");
                return;
            }

            GraphQueryResult resFix = executeDoubleGraphQuery(
                    ValidationFixUtils.ic09_removeSliceKeys(graph, selSlice.toString()),
                    ValidationFixUtils.ic09_insertSliceKey(graph, selSlice.toString(), selKey.toString()));
            if (resFix != null) {
                Notification.show("Fix executed");
                // evaluate again after the fix
                icQuery.eval();
            }
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC12.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();/*from  w  ww. j  a va 2s  .  c o m*/

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    rootLayout.addComponent(new Label(
            "Following observations belong to the same data set and have the same value for all dimensions."));

    final ListSelect ls1 = new ListSelect("Observations");
    ls1.setNullSelectionAllowed(false);
    ls1.setImmediate(true);
    ls1.setWidth("100%");
    rootLayout.addComponent(ls1);

    Iterator<BindingSet> res = icQuery.getResults();
    final HashMap<String, List<String>> mapDuplicates = new HashMap<String, List<String>>();
    String lastObs = "";
    List<String> lastDuplicates = null;
    while (res.hasNext()) {
        BindingSet set = res.next();
        String obs1 = set.getValue("obs1").stringValue();
        if (!obs1.equals(lastObs)) {
            lastObs = obs1;
            lastDuplicates = new ArrayList<String>();
            mapDuplicates.put(lastObs, lastDuplicates);
            ls1.addItem(lastObs);
        }
        lastDuplicates.add(set.getValue("obs2").stringValue());
    }

    final ListSelect ls2 = new ListSelect("Duplicates");
    ls2.setNullSelectionAllowed(false);
    ls2.setImmediate(true);
    ls2.setWidth("100%");
    rootLayout.addComponent(ls2);

    ls1.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            ls2.removeAllItems();
            for (String duplicate : mapDuplicates.get(event.getProperty().getValue())) {
                ls2.addItem(duplicate);
            }
        }
    });

    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);
    panelLayout.addComponent(
            new Label("After the fix duplicates of the selected observation will be removed from the graph"));

    Button fix = new Button("Quick Fix");
    panelLayout.addComponent(fix);
    panelLayout.setExpandRatio(fix, 2.0f);

    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            String obsString = (String) ls1.getValue();
            if (obsString == null || obsString.isEmpty()) {
                Notification.show("Select observation first", Notification.Type.ERROR_MESSAGE);
                return;
            }
            ValueFactory factory = repository.getValueFactory();

            for (String duplicateString : mapDuplicates.get(obsString)) {
                URI duplicateURI = factory.createURI(duplicateString);
                TupleQueryResult res = getResourceProperties(duplicateString);
                ArrayList<Statement> stmts = new ArrayList<Statement>();
                try {
                    while (res.hasNext()) {
                        BindingSet set = res.next();
                        URI propURI = factory.createURI(set.getValue("p").stringValue());
                        Value objValue = set.getValue("o");
                        stmts.add(factory.createStatement(duplicateURI, propURI, objValue));
                    }
                    res = getResourceLinks(duplicateString);
                    while (res.hasNext()) {
                        BindingSet set = res.next();
                        URI propURI = factory.createURI(set.getValue("p").stringValue());
                        URI subURI = factory.createURI(set.getValue("s").stringValue());
                        stmts.add(factory.createStatement(subURI, propURI, duplicateURI));
                    }
                    removeStatements(stmts);
                } catch (QueryEvaluationException e) {
                    e.printStackTrace();
                }
            }
            Notification.show("Fix executed");
            // evaluate again after the fix
            icQuery.eval();
        }
    });
}

From source file:rs.pupin.jpo.validation.gui.constraints.IC13.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from www .java 2  s  .  c  om
    Iterator<BindingSet> res = icQuery.getResults();

    if (icQuery.getStatus() == ICQuery.Status.ERROR) {
        Label label = new Label();
        label.setValue("ERROR \n" + icQuery.getErrorMessage());
        rootLayout.addComponent(label);
        return;
    }

    final HashMap<String, String> obsMap = new HashMap<String, String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        obsMap.put(set.getValue("obs").stringValue(), set.getValue("attr").stringValue());
    }

    if (obsMap.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - Every qb:Observation has a value for each declared attribute that is marked as required");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following observations do not have a value for required attribute(s)");
    rootLayout.addComponent(lbl);

    final ListSelect listObservations = new ListSelect("Observations", obsMap.keySet());
    listObservations.setNullSelectionAllowed(false);
    listObservations.setImmediate(true);
    rootLayout.addComponent(listObservations);

    // TODO: add label that tells which attribute is missing
    Form panelQuickFix = new Form();
    panelQuickFix.setCaption("Quick Fix");
    panelQuickFix.setSizeFull();
    VerticalLayout panelLayout = new VerticalLayout();
    panelLayout.setSpacing(true);
    panelLayout.setSizeFull();
    panelQuickFix.setLayout(panelLayout);
    rootLayout.addComponent(panelQuickFix);
    rootLayout.setExpandRatio(panelQuickFix, 2.0f);

    Label fixLabel = new Label();
    fixLabel.setContentMode(ContentMode.HTML);
    fixLabel.setValue(""); // TODO
    panelLayout.addComponent(fixLabel);

    HorizontalLayout btnLayout = new HorizontalLayout();
    btnLayout.setSpacing(true);
    Button removeRequired = new Button("Remove qb:componentRequired");
    Button editOW = new Button("Edit in OntoWiki");
    editOW.setEnabled(owUrl != null);
    btnLayout.addComponent(removeRequired);
    btnLayout.addComponent(editOW);
    panelLayout.addComponent(btnLayout);
    panelLayout.setExpandRatio(btnLayout, 2.0f);

    removeRequired.addClickListener(new Button.ClickListener() {

        @Override
        public void buttonClick(Button.ClickEvent event) {
            String chosenObs = (String) listObservations.getValue();
            if (chosenObs == null) {
                Notification.show("Cannot execute the action", "Observation needs to be chosen first",
                        Notification.Type.ERROR_MESSAGE);
                return;
            }
            String query = ValidationFixUtils.ic13_removeComponentRequiredTrue(graph, chosenObs,
                    obsMap.get(chosenObs));
            GraphQueryResult fixRes = executeGraphQuery(query);
            if (fixRes != null) {
                Notification.show("Fix executed");
                // evaluate again after the fix
                icQuery.eval();
            }
        }
    });
    editOW.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listObservations.getValue());
        }
    });
}

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

private RefreshableTab createSettings() {

    final Form systemForm;
    {/*from  www .  jav a  2s. c o m*/
        final ComboBox serviceLocation;
        {
            String[][] defs = { { "? ", "http://195.245.214.33:7777/esv" },
                    { "? ",
                            "http://oraas.rt.ru:7777/gateway/services/SID0003318" } };
            serviceLocation = new ComboBox("?? ?? ");
            serviceLocation.setItemCaptionMode(ComboBox.ITEM_CAPTION_MODE_EXPLICIT);
            for (String[] def : defs) {
                addOption(serviceLocation, def[1], def[0], false);
            }
            serviceLocation.setImmediate(true);
            serviceLocation.setInputPrompt("http://");
            serviceLocation.setNewItemsAllowed(true);
            serviceLocation.setNewItemHandler(new AbstractSelect.NewItemHandler() {
                @Override
                public void addNewItem(String newItemCaption) {
                    addOption(serviceLocation, newItemCaption, newItemCaption, true);
                }
            });
            String href = AdminServiceProvider.get()
                    .getSystemProperty(CertificateVerifier.VERIFY_SERVICE_LOCATION);
            addOption(serviceLocation, href, href, true);
        }

        final CheckBox allowValidate;
        {
            allowValidate = new CheckBox(" ? ");
            allowValidate.setRequired(true);
            allowValidate.setImmediate(true);
            allowValidate.addListener(new Property.ValueChangeListener() {
                @Override
                public void valueChange(Property.ValueChangeEvent event) {
                    serviceLocation.setRequired(Boolean.TRUE.equals(event.getProperty().getValue()));
                }
            });
            allowValidate.setValue(AdminServiceProvider
                    .getBoolProperty(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY));
        }

        systemForm = new Form();
        systemForm.addField("location", serviceLocation);
        systemForm.addField("allowVerify", allowValidate);
        systemForm.setImmediate(true);
        systemForm.setWriteThrough(false);
        systemForm.setInvalidCommitted(false);

        Button commit = new Button("", new Button.ClickListener() {
            @Override
            public void buttonClick(Button.ClickEvent event) {
                try {
                    systemForm.commit();
                    set(CertificateVerifier.VERIFY_SERVICE_LOCATION, serviceLocation.getValue());
                    set(CertificateVerifier.ALLOW_VERIFY_CERTIFICATE_PROPERTY, allowValidate.getValue());
                    event.getButton().getWindow().showNotification("?? ?",
                            Window.Notification.TYPE_HUMANIZED_MESSAGE);
                } catch (Validator.InvalidValueException ignore) {
                }
            }
        });

        HorizontalLayout buttons = new HorizontalLayout();
        buttons.setSpacing(true);
        buttons.addComponent(commit);
        systemForm.getFooter().addComponent(buttons);
    }

    Panel b1 = new Panel();
    b1.setSizeFull();
    Label b1label = new Label(" ?");
    b1label.addStyleName(Reindeer.LABEL_H2);
    b1.addComponent(b1label);
    b1.addComponent(systemForm);

    VerticalLayout certificates = new VerticalLayout();
    certificates.setSizeFull();
    certificates.setSpacing(true);

    HorizontalLayout topHl = new HorizontalLayout();
    topHl.setSizeFull();
    topHl.setSpacing(true);

    Panel certificatesPanel = new Panel("", certificates);
    certificatesPanel.setSizeFull();
    certificatesPanel.addStyleName(Reindeer.PANEL_LIGHT);

    boolean linkCertificate = AdminServiceProvider.getBoolProperty(CertificateVerifier.LINK_CERTIFICATE);
    final CheckBox switchLink = new CheckBox("? ");
    switchLink.setValue(linkCertificate);
    switchLink.setImmediate(true);
    switchLink.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            set(CertificateVerifier.LINK_CERTIFICATE, switchLink.getValue());
            event.getButton().getWindow().showNotification("?? ?",
                    Window.Notification.TYPE_HUMANIZED_MESSAGE);
        }
    });

    Panel b2 = new Panel();
    b2.setSizeFull();
    Label b2label = new Label("? ?");
    b2label.addStyleName(Reindeer.LABEL_H2);
    b2.addComponent(b2label);
    b2.addComponent(switchLink);

    certificates.addComponent(b1);
    certificates.addComponent(b2);
    certificates.setExpandRatio(b1, 0.7f);
    certificates.setExpandRatio(b2, 0.3f);

    CheckBox productionMode = new CheckBox("?  ",
            AdminServiceProvider.getBoolProperty(API.PRODUCTION_MODE));
    productionMode.setImmediate(true);
    productionMode.setDescription(
            " ?   ?   ??   ?? testMsg");
    productionMode.addListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent event) {
            boolean value = Boolean.TRUE.equals(event.getProperty().getValue());
            set(API.PRODUCTION_MODE, value);
        }
    });
    Panel smevPanel = new Panel(" ");
    smevPanel.setSizeFull();
    smevPanel.addComponent(productionMode);

    HorizontalLayout bottomHl = new HorizontalLayout();
    bottomHl.setSizeFull();
    bottomHl.setSpacing(true);

    LogSettings logSettings = new LogSettings();
    Panel emailDatesPanel = createEmailDatesPanel();

    Panel mailTaskConfigPanel = createMilTaskConfigPanel();

    topHl.addComponent(certificatesPanel);
    topHl.addComponent(emailDatesPanel);
    topHl.addComponent(mailTaskConfigPanel);
    topHl.setExpandRatio(certificatesPanel, 0.4f);
    topHl.setExpandRatio(emailDatesPanel, 0.6f);
    topHl.setExpandRatio(mailTaskConfigPanel, 0.5f);

    Panel esiaPanel = buildEsiaPanel();
    Panel printTemplatesPanel = buildPrintTemplatesPanel();

    bottomHl.addComponent(smevPanel);
    bottomHl.addComponent(esiaPanel);
    bottomHl.addComponent(printTemplatesPanel);
    bottomHl.setExpandRatio(smevPanel, 0.2f);
    bottomHl.setExpandRatio(esiaPanel, 0.4f);
    bottomHl.setExpandRatio(printTemplatesPanel, 0.4f);

    final VerticalLayout layout = new VerticalLayout();
    layout.setSpacing(true);
    layout.setSizeFull();
    layout.addComponent(topHl);
    layout.addComponent(logSettings);
    layout.addComponent(bottomHl);
    layout.setExpandRatio(topHl, 0.40f);
    layout.setExpandRatio(logSettings, 0.40f);
    layout.setExpandRatio(bottomHl, 0.20f);
    layout.setMargin(true);
    layout.setSpacing(true);

    return new RefreshableTab(layout, logSettings);
}

From source file:ru.codeinside.adm.ui.AdminApp.java

License:Mozilla Public License

private Panel createEmailDatesPanel() {
    VerticalLayout emailDates = new VerticalLayout();
    emailDates.setSpacing(true);//from   www.ja  va 2 s.c om
    emailDates.setMargin(true);
    emailDates.setSizeFull();
    Panel panel2 = new Panel(" ? ??", emailDates);
    panel2.setSizeFull();

    final TextField emailToField = new TextField("e-mail ?:");
    emailToField.setValue(get(API.EMAIL_TO));
    emailToField.setRequired(true);
    emailToField.setReadOnly(true);
    emailToField.addValidator(new EmailValidator("  e-mail ?"));

    final TextField receiverNameField = new TextField("? ?:");
    receiverNameField.setValue(get(API.RECEIVER_NAME));
    receiverNameField.setRequired(true);
    receiverNameField.setReadOnly(true);

    final TextField emailFromField = new TextField("e-mail ?:");
    emailFromField.setValue(get(API.EMAIL_FROM));
    emailFromField.setRequired(true);
    emailFromField.setReadOnly(true);
    emailFromField.addValidator(new EmailValidator("  e-mail ?"));

    final TextField senderLoginField = new TextField(" ?:");
    senderLoginField.setValue(get(API.SENDER_LOGIN));
    senderLoginField.setRequired(true);
    senderLoginField.setReadOnly(true);

    final TextField senderNameField = new TextField("? ?:");
    senderNameField.setValue(get(API.SENDER_NAME));
    senderNameField.setRequired(true);
    senderNameField.setReadOnly(true);

    final PasswordField passwordField = new PasswordField(":");
    passwordField.setValue(API.PASSWORD);
    passwordField.setRequired(true);
    passwordField.setReadOnly(true);

    final TextField hostField = new TextField("SMTP ?:");
    String host = get(API.HOST);
    hostField.setValue(host == null ? "" : host);
    hostField.setRequired(true);
    hostField.setReadOnly(true);

    final TextField portField = new TextField(":");
    String port = get(API.PORT);
    portField.setValue(port == null ? "" : port);
    portField.setRequired(true);
    portField.setReadOnly(true);
    portField.addValidator(new IntegerValidator(" "));

    final CheckBox tls = new CheckBox("? TLS",
            AdminServiceProvider.getBoolProperty(API.TLS));
    tls.setReadOnly(true);

    final Button save = new Button("");
    save.setVisible(false);
    final Button cancel = new Button("");
    cancel.setVisible(false);
    final Button change = new Button("");
    final Button check = new Button("");
    check.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            String emailTo = get(API.EMAIL_TO);
            String receiverName = get(API.RECEIVER_NAME);
            String hostName = get(API.HOST);
            String port = get(API.PORT);
            String senderLogin = get(API.SENDER_LOGIN);
            String password = get(API.PASSWORD);
            String emailFrom = get(API.EMAIL_FROM);
            String senderName = get(API.SENDER_NAME);
            if (emailTo.isEmpty() || receiverName.isEmpty() || hostName.isEmpty() || port.isEmpty()
                    || senderLogin.isEmpty() || password.isEmpty() || emailFrom.isEmpty()
                    || senderName.isEmpty()) {
                check.getWindow().showNotification("? ? ");
                return;
            }
            Email email = new SimpleEmail();
            try {
                email.setSubject("? ?");
                email.setMsg("? ?");
                email.addTo(emailTo, receiverName);
                email.setHostName(hostName);
                email.setSmtpPort(Integer.parseInt(port));
                email.setTLS(AdminServiceProvider.getBoolProperty(API.TLS));
                email.setAuthentication(senderLogin, password);
                email.setFrom(emailFrom, senderName);
                email.setCharset("utf-8");
                email.send();
            } catch (EmailException e) {
                check.getWindow().showNotification(e.getMessage());
                e.printStackTrace();
                return;
            }
            check.getWindow().showNotification("? ? ");
        }
    });
    change.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            emailToField.setReadOnly(false);
            receiverNameField.setReadOnly(false);
            emailFromField.setReadOnly(false);
            senderLoginField.setReadOnly(false);
            senderNameField.setReadOnly(false);
            passwordField.setReadOnly(false);
            hostField.setReadOnly(false);
            portField.setReadOnly(false);
            tls.setReadOnly(false);

            change.setVisible(false);
            check.setVisible(false);
            save.setVisible(true);
            cancel.setVisible(true);
        }
    });
    save.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            if (StringUtils.isEmpty((String) emailToField.getValue())
                    || StringUtils.isEmpty((String) receiverNameField.getValue())
                    || StringUtils.isEmpty((String) emailFromField.getValue())
                    || StringUtils.isEmpty((String) senderNameField.getValue())
                    || StringUtils.isEmpty((String) senderLoginField.getValue())
                    || StringUtils.isEmpty((String) passwordField.getValue())
                    || StringUtils.isEmpty((String) hostField.getValue()) || portField.getValue() == null) {
                emailToField.getWindow().showNotification(" ?",
                        Window.Notification.TYPE_HUMANIZED_MESSAGE);
                return;
            }
            boolean errors = false;
            try {
                emailToField.validate();
            } catch (Validator.InvalidValueException ignore) {
                errors = true;
            }
            try {
                emailFromField.validate();
            } catch (Validator.InvalidValueException ignore) {
                errors = true;
            }
            try {
                portField.validate();
            } catch (Validator.InvalidValueException ignore) {
                errors = true;
            }
            if (errors) {
                return;
            }
            set(API.EMAIL_TO, emailToField.getValue());
            set(API.RECEIVER_NAME, receiverNameField.getValue());
            set(API.EMAIL_FROM, emailFromField.getValue());
            set(API.SENDER_LOGIN, senderLoginField.getValue());
            set(API.SENDER_NAME, senderNameField.getValue());
            set(API.PASSWORD, passwordField.getValue());
            set(API.HOST, hostField.getValue());
            set(API.PORT, portField.getValue());
            set(API.TLS, tls.getValue());

            emailToField.setReadOnly(true);
            receiverNameField.setReadOnly(true);
            emailFromField.setReadOnly(true);
            senderLoginField.setReadOnly(true);
            senderNameField.setReadOnly(true);
            passwordField.setReadOnly(true);
            hostField.setReadOnly(true);
            portField.setReadOnly(true);
            tls.setReadOnly(true);

            save.setVisible(false);
            cancel.setVisible(false);
            change.setVisible(true);
            check.setVisible(true);
            emailToField.getWindow().showNotification("?? ?",
                    Window.Notification.TYPE_HUMANIZED_MESSAGE);
        }
    });
    cancel.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            emailToField.setValue(get(API.EMAIL_TO));
            receiverNameField.setValue(get(API.RECEIVER_NAME));
            emailFromField.setValue(get(API.EMAIL_FROM));
            senderLoginField.setValue(get(API.SENDER_LOGIN));
            senderNameField.setValue(get(API.SENDER_NAME));
            passwordField.setValue(get(API.PASSWORD));
            hostField.setValue(get(API.HOST));
            portField.setValue(get(API.PORT));
            tls.setValue(AdminServiceProvider.getBoolProperty(API.TLS));

            emailToField.setReadOnly(true);
            receiverNameField.setReadOnly(true);
            emailFromField.setReadOnly(true);
            senderLoginField.setReadOnly(true);
            senderNameField.setReadOnly(true);
            passwordField.setReadOnly(true);
            hostField.setReadOnly(true);
            portField.setReadOnly(true);
            tls.setReadOnly(true);

            save.setVisible(false);
            cancel.setVisible(false);
            change.setVisible(true);
            check.setVisible(true);
        }
    });

    FormLayout fields1 = new FormLayout();
    fields1.setSizeFull();
    fields1.addComponent(senderLoginField);
    fields1.addComponent(passwordField);
    fields1.addComponent(hostField);
    fields1.addComponent(portField);
    fields1.addComponent(tls);

    FormLayout fields2 = new FormLayout();
    fields2.setSizeFull();
    fields2.addComponent(emailToField);
    fields2.addComponent(receiverNameField);
    fields2.addComponent(emailFromField);
    fields2.addComponent(senderNameField);

    HorizontalLayout fields = new HorizontalLayout();
    fields.setSpacing(true);
    fields.setSizeFull();
    fields.addComponent(fields1);
    fields.addComponent(fields2);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    buttons.addComponent(change);
    buttons.addComponent(save);
    buttons.addComponent(cancel);
    buttons.addComponent(check);

    Label label = new Label("?? ");
    label.addStyleName(Reindeer.LABEL_H2);
    emailDates.addComponent(label);
    emailDates.addComponent(fields);
    emailDates.addComponent(buttons);
    emailDates.setExpandRatio(fields, 1f);
    return panel2;
}