List of usage examples for com.vaadin.ui ListSelect ListSelect
public ListSelect(String caption, Collection<T> options)
From source file:rs.pupin.jpo.validation.gui.constraints.IC09.java
@Override public void generateGUI() { rootLayout.removeAllComponents();/*from ww w . ja 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.IC10.java
@Override public void generateGUI() { rootLayout.removeAllComponents();// ww w. j a v a2 s . 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 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();// ww w . jav a2 s. co 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 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();/* w ww . j a va 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 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();//from 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 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 av a2s .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("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()); } }); }
From source file:rs.pupin.jpo.validation.gui.constraints.IC16.java
@Override public void generateGUI() { rootLayout.removeAllComponents();// w w w.ja v a2 s.c o m Iterator<BindingSet> res = icQuery.getResults(); @SuppressWarnings("unused") final class MeasureOmeasurePair { String measure; String omeasure; } if (icQuery.getStatus() == ICQuery.Status.ERROR) { Label label = new Label(); label.setValue("ERROR \n" + icQuery.getErrorMessage()); rootLayout.addComponent(label); return; } final HashMap<String, MeasureOmeasurePair> obsMap = new HashMap<String, MeasureOmeasurePair>(); while (res.hasNext()) { BindingSet set = res.next(); MeasureOmeasurePair pair = new MeasureOmeasurePair(); pair.measure = set.getValue("measure").stringValue(); pair.omeasure = set.getValue("omeasure").stringValue(); obsMap.put(set.getValue("obs").stringValue(), pair); } if (obsMap.isEmpty()) { Label label = new Label(); label.setValue( "No problems were detected - In Data Sets that use a Measure dimension (if there are any) each Observation only has a value for one measure"); rootLayout.addComponent(label); return; } Label lbl = new Label(); lbl.setValue( "Following observations belong to data sets that use a Measure dimension and have a value for more than one measure"); 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 what is the measure dimension and mention the omeasure, perhaps details table 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.IC17.java
@Override public void generateGUI() { rootLayout.removeAllComponents();//www . j a v a2s .com Iterator<BindingSet> res = icQuery.getResults(); @SuppressWarnings("unused") final class NumMeasuresCountPair { String numMeasures; String count; } if (icQuery.getStatus() == ICQuery.Status.ERROR) { Label label = new Label(); label.setValue("ERROR \n" + icQuery.getErrorMessage()); rootLayout.addComponent(label); return; } final HashMap<String, NumMeasuresCountPair> obsMap = new HashMap<String, NumMeasuresCountPair>(); while (res.hasNext()) { BindingSet set = res.next(); NumMeasuresCountPair pair = new NumMeasuresCountPair(); pair.numMeasures = set.getValue("numMeasures").stringValue(); pair.count = set.getValue("count").stringValue(); obsMap.put(set.getValue("obs1").stringValue(), pair); } if (obsMap.isEmpty()) { Label label = new Label(); label.setValue("No problems were detected - In a data set which uses a measure dimension then " + "if there is an Observation for some combination of non-measure dimensions then " + "there must be other Observations with the same non-measure dimension values for each of the declared measures"); rootLayout.addComponent(label); return; } Label lbl = new Label(); lbl.setValue( "Following observations belong to data sets that use a Measure dimension and break a rule that " + "if there is an Observation for some combination of non-measure dimensions then " + "there must be other Observations with the same non-measure dimension values for each of the declared measures"); 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 what is the difference in counts, maybe even more, perhaps details table 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.IC18.java
@Override public void generateGUI() { rootLayout.removeAllComponents();//from w w w.j a va 2s.com Iterator<BindingSet> res = icQuery.getResults(); @SuppressWarnings("unused") final class DataSetSlicePair { String dataset; String slice; } if (icQuery.getStatus() == ICQuery.Status.ERROR) { Label label = new Label(); label.setValue("ERROR \n" + icQuery.getErrorMessage()); rootLayout.addComponent(label); return; } final HashMap<String, DataSetSlicePair> obsMap = new HashMap<String, DataSetSlicePair>(); while (res.hasNext()) { BindingSet set = res.next(); DataSetSlicePair pair = new DataSetSlicePair(); pair.dataset = set.getValue("dataset").stringValue(); pair.slice = set.getValue("slice").stringValue(); obsMap.put(set.getValue("obs").stringValue(), pair); } if (obsMap.isEmpty()) { Label label = new Label(); label.setValue( "No problems were detected - If a qb:DataSet D has a qb:slice S, and S has an qb:observation O, then the qb:dataSet corresponding to O must be D"); rootLayout.addComponent(label); return; } Label lbl = new Label(); lbl.setValue("Following observations are missing a link to the appropriate data set"); 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 dataset and slice are in question, perhaps details table 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.IC19.java
@Override public void generateGUI() { rootLayout.removeAllComponents();// w ww .j a va 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 HashMap<String, String> map = new HashMap<String, String>(); while (res.hasNext()) { BindingSet set = res.next(); map.put(set.getValue("v").stringValue(), set.getValue("list").stringValue()); } if (map.isEmpty()) { Label label = new Label(); label.setValue("All values of coded dimensions are linked to the code lists"); rootLayout.addComponent(label); return; } Label label = new Label(); label.setValue( "Following resources should be of type skos:Concept and linked to the appropriate code list"); rootLayout.addComponent(label); final ListSelect listValues = new ListSelect("Resources", map.keySet()); listValues.setNullSelectionAllowed(false); listValues.setImmediate(true); rootLayout.addComponent(listValues); Button editInOW = new Button("Edit in OntoWiki"); editInOW.setEnabled(owUrl != null); editInOW.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { editManually((String) listValues.getValue()); } }); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); Button fix = new Button("Quick Fix"); rootLayout.addComponent(buttonsLayout); rootLayout.setExpandRatio(buttonsLayout, 2.0f); buttonsLayout.addComponent(fix); buttonsLayout.addComponent(editInOW); fix.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String resource = (String) listValues.getValue(); String codeList = map.get(resource); getUI().addWindow(new QuickFixCodesFromCodeLists(resource, codeList)); } }); }