Example usage for com.vaadin.ui Label setContentMode

List of usage examples for com.vaadin.ui Label setContentMode

Introduction

In this page you can find the example usage for com.vaadin.ui Label setContentMode.

Prototype

public void setContentMode(ContentMode contentMode) 

Source Link

Document

Sets the content mode of the label.

Usage

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//  w w  w.j  a  va  2s.co 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   w  ww  .  ja  va  2s  .  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> 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   ww  w .  j  a v a 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 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 v a2s.  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  w  w .j  a  v  a  2s.  co  m

    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();/*from w  w  w. j  a  v a 2  s .  c  o m*/

    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.IC13.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();// w  ww  .java  2s.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> 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:se.natusoft.osgi.aps.apsadminweb.app.gui.vaadin.LogoPanel.java

License:Open Source License

public LogoPanel(Button.ClickListener clickListener) {
    super();//from  w w w . j  a v a  2  s.  co  m
    HorizontalLayout topLayout = new HorizontalLayout();
    topLayout.setSpacing(true);
    topLayout.setMargin(true, true, false, true);
    setContent(topLayout);
    setStyleName(Reindeer.PANEL_LIGHT);

    ThemeResource logo = new ThemeResource("images/app-platform-services.png");
    Label logoLabel = new Label();
    logoLabel.setWidth("300px");
    logoLabel.setIcon(logo);

    addComponent(logoLabel);

    Label textLabel = new Label("<font size='+1'><b>Admin Web</b></font>");
    textLabel.setContentMode(Label.CONTENT_XHTML);
    addComponent(textLabel);

    Button refreshButton = new Button("Refresh", clickListener);
    refreshButton.setStyleName(BaseTheme.BUTTON_LINK);
    addComponent(refreshButton);
}

From source file:uk.co.intec.keyDatesApp.pages.HomeView.java

License:Apache License

/**
 * Loads the main content for the page. Only called on first entry to the
 * page, because calling method sets <i>isLoaded</i> to true after
 * successfully completing./*from   w  w w . j  ava  2s. c o  m*/
 */
public void loadContent() {
    if ("Anonymous".equals(GenericDatabaseUtils.getUserName())) {
        final Label warning = new Label();
        warning.setStyleName(ValoTheme.LABEL_H2);
        warning.setStyleName(ValoTheme.LABEL_FAILURE);
        warning.setValue("Anonymous access is not allowed on this application!");
        addComponent(warning);
    } else {
        if (GenericDatabaseUtils.doesDbExist()) {
            final Label intro = new Label();
            intro.setStyleName(ValoTheme.LABEL_H2);
            intro.setValue("Welcome to Key Dates OSGi Application");
            addComponent(intro);
        } else {
            final Label warning = new Label();
            warning.setStyleName(ValoTheme.LABEL_H2);
            warning.setStyleName(ValoTheme.LABEL_FAILURE);
            warning.setContentMode(ContentMode.HTML);
            warning.setValue(
                    "We cannot open the data database. Most likely reasons are:<ul><li>You don't have access to the database, in which case you should contact IT.</li>"
                            + "<li>The Key Dates database has not been set up at the filepath "
                            + AppUtils.getDataDbFilepath()
                            + ". Create the data database at that location or amend the 'dataDbFilePath' context parameter in WebContent > WEB-INF > web.xml of the application and issue 'restart task http' to the Domino server</li></ul>");
            addComponent(warning);
        }
    }
}

From source file:uk.co.intec.keyDatesApp.pages.MainView.java

License:Apache License

/**
 * Removes any existing row data loaded to the page and loads
 * ViewEntryWrappers passed to this method. If no entries were passed to the
 * method, the message "No entries found matching criteria" is displayed.
 * Otherwise writes the entries to the page, grouped under the date each Key
 * Date is for.//from   ww w.j  a va  2  s .com
 *
 * @param data
 *            Map of data where key is a java.sql.Date (so does not include
 *            a time element) and value is the wrapped ViewEntries for that
 *            date.
 */
public void loadRowData(final Map<Object, List<ViewEntryWrapper>> data) {
    body.removeAllComponents();
    if (null == data || data.isEmpty()) {
        final Label msg = new Label("No entries found matching criteria");
        msg.setStyleName(ValoTheme.LABEL_FAILURE);
        body.addComponent(msg);
    } else {
        for (final Object key : data.keySet()) {
            if (key instanceof java.sql.Date) { // It will be!
                // Add the header
                final VerticalLayout catContainer = new VerticalLayout();
                catContainer.addStyleName(ValoTheme.MENU_TITLE);
                catContainer.addStyleName("category-header");
                final Label category = new Label();
                final java.sql.Date sqlDate = (java.sql.Date) key;
                category.setValue(DATE_ONLY.format(sqlDate));
                catContainer.addComponent(category);
                body.addComponent(catContainer);

                // Load the entries
                for (final ViewEntryWrapper veWrapped : data.get(key)) {
                    final VerticalLayout entryRow = new VerticalLayout();
                    final KeyDateEntryWrapper entry = (KeyDateEntryWrapper) veWrapped;
                    final StringBuilder suffixTitle = new StringBuilder("");
                    if (getViewWrapper().getViewName().equals(KeyDateViewWrapper.ViewType.BY_DATE)) {
                        if (StringUtils.isNotEmpty(entry.getCustomer())) {
                            suffixTitle.append(" (" + entry.getCustomer());
                            if (StringUtils.isNotEmpty(entry.getContact())) {
                                suffixTitle.append(" - " + entry.getContact());
                            }
                            suffixTitle.append(")");
                        }
                    } else {
                        if (StringUtils.isNotEmpty(entry.getContact())) {
                            suffixTitle.append(" - " + entry.getContact());
                        }
                    }
                    final Button title = new Button(entry.getTitle() + suffixTitle.toString());
                    title.addStyleName(ValoTheme.BUTTON_LINK);
                    // Add click event
                    title.addClickListener(new DocLinkListener(KeyDateView.VIEW_NAME, entry.getNoteId()));
                    entryRow.addComponent(title);

                    // Add summary, if appropriate
                    if (StringUtils.isNotEmpty(entry.getDescription())) {
                        final Label summary = new Label(entry.getDescription());
                        summary.setContentMode(ContentMode.HTML);
                        summary.addStyleName(ValoTheme.LABEL_SMALL);
                        summary.addStyleName("view-desc");
                        entryRow.addComponent(summary);
                    }

                    body.addComponent(entryRow);
                }
            }
        }

    }
}