Example usage for com.vaadin.ui Button setEnabled

List of usage examples for com.vaadin.ui Button setEnabled

Introduction

In this page you can find the example usage for com.vaadin.ui Button setEnabled.

Prototype

@Override
    public void setEnabled(boolean enabled) 

Source Link

Usage

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();// w w w . java  2  s .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> 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();//from   w w  w. ja 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 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 av a 2  s.  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.IC08.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();/*from w w  w.  j  a  v  a 2  s.  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 all slice keys are consistent with associated DSD, i.e. for every slice key holds: "
                        + "every component property of the slice key is also declared as a component of the associated DSD");
        rootLayout.addComponent(label);
        return;
    }

    Label label = new Label();
    label.setValue(
            "All slice keys should be consistent with thier associated DSDs, i.e. for every slice key following should hold: "
                    + "every component property of the slice key is also declared as a component of the associated DSD.");
    rootLayout.addComponent(label);
    Label label2 = new Label();
    label2.setValue(
            "Following slice keys should be modified in order to be consistent with the associated DSD");
    rootLayout.addComponent(label2);
    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);

    Button editInOW = new Button("Edit in OntoWiki");
    editInOW.setEnabled(owUrl != null);
    rootLayout.addComponent(editInOW);

    editInOW.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();
            }
        }
    });
}

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from w  ww  . j  a v a 2  s.com

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from ww w  .  ja va  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 HashMap<String, ArrayList<String>> map = new HashMap<String, ArrayList<String>>();
    String lastSlice = null;
    ArrayList<String> lastDimensions = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        String s = set.getValue("slice").stringValue();
        if (lastSlice == null) {
            lastSlice = s;
        }
        String d = set.getValue("dim").stringValue();
        if (!s.equals(lastSlice)) {
            map.put(lastSlice, lastDimensions);
            lastSlice = s;
            lastDimensions = new ArrayList<String>();
        }
        lastDimensions.add(d);
    }
    if (lastSlice != null) {
        map.put(lastSlice, lastDimensions);
    }
    if (map.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - either there are no slices or every slice has a value for every dimension declared in its associated slice key (via property qb:sliceStructure)");
        rootLayout.addComponent(label);
        return;
    }

    Label label = new Label();
    label.setValue(
            "Following slices do not have a value for every dimension declared in its associated slice key (via property qb:sliceStructure)");
    rootLayout.addComponent(label);
    final ListSelect lsSlices = new ListSelect("Slices", map.keySet());
    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);

    final Label lblProblem = new Label("<b>Problem description: </b>", ContentMode.HTML);
    rootLayout.addComponent(lblProblem);

    Button editInOW = new Button("Edit in OntoWiki");
    editInOW.setEnabled(owUrl != null);
    rootLayout.addComponent(editInOW);

    editInOW.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) {
            String slice = (String) event.getProperty().getValue();
            TupleQueryResult res = getResourceProperties(slice);
            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();
            }
            StringBuilder sb = new StringBuilder();
            sb.append(
                    "<b>Problem description: </b>Selected slice is missing a value for the following dimensions:");
            for (String dim : map.get(slice)) {
                sb.append(" ").append(dim).append(",");
            }
            sb.deleteCharAt(sb.length() - 1);
            lblProblem.setValue(sb.toString());
        }
    });
}

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//from w  ww  .j  av a  2s  .  com

    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 observation don't have a value for each dimension: "));
    Iterator<BindingSet> res = icQuery.getResults();
    ArrayList<String> listObs = new ArrayList<String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        listObs.add(set.getValue("obs").stringValue());
    }
    ListSelect ls = new ListSelect("Observations", listObs);
    ls.setNullSelectionAllowed(false);
    ls.setImmediate(true);
    ls.setWidth("100%");
    rootLayout.addComponent(ls);
    Button fix = new Button("Quick Fix");
    fix.setEnabled(false);
    rootLayout.addComponent(fix);
    rootLayout.setExpandRatio(fix, 2.0f);
}

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();/*from  www. j a  v  a  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> 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:rs.pupin.jpo.validation.gui.constraints.IC14.java

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();//  w w w . j av  a 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("measure").stringValue());
    }

    if (obsMap.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - In Data Sets that do not use a Measure dimension (if there are any) each Observation has a value for every declared measure");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue("Following observations are missing a value for declared measure(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 measure is missing
    Button fix = new Button("Edit in OntoWiki");
    fix.setEnabled(owUrl != null);
    rootLayout.addComponent(fix);
    rootLayout.setExpandRatio(fix, 2.0f);

    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listObservations.getValue());
        }
    });
}

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

@Override
public void generateGUI() {
    rootLayout.removeAllComponents();/*from www  .  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> obsMap = new HashMap<String, String>();
    while (res.hasNext()) {
        BindingSet set = res.next();
        obsMap.put(set.getValue("obs").stringValue(), set.getValue("measure").stringValue());
    }

    if (obsMap.isEmpty()) {
        Label label = new Label();
        label.setValue(
                "No problems were detected - In Data Sets that a Measure dimension (if there are any) each Observation has a value for the measure corresponding to its given qb:measureType");
        rootLayout.addComponent(label);
        return;
    }

    Label lbl = new Label();
    lbl.setValue(
            "Following observations are missing a value for the measure corresponding to its given qb:measureType");
    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 measure is missing
    Button fix = new Button("Edit in OntoWiki");
    fix.setEnabled(owUrl != null);
    rootLayout.addComponent(fix);
    rootLayout.setExpandRatio(fix, 2.0f);

    fix.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent event) {
            editManually((String) listObservations.getValue());
        }
    });
}