List of usage examples for com.vaadin.ui ListSelect ListSelect
public ListSelect(String caption, Collection<T> options)
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected Component buildSimpleTable(final String propId, final ContainerProperty prop) { String label = prop.getLabel(); if (label == null) label = DisplayUtils.getPrettyName((String) propId); final MyBeanItemContainer<Object> container = prop.getValue(); final ListSelect listBox = new ListSelect(label, container); listBox.setValue(container);//ww w. j a va 2 s . c om listBox.setItemCaptionMode(ItemCaptionMode.PROPERTY); listBox.setItemCaptionPropertyId(MyBeanItem.PROP_VALUE); listBox.setImmediate(true); listBox.setBuffered(true); listBox.setNullSelectionAllowed(false); listBox.setDescription(prop.getDescription()); listBox.setWidth(500, Unit.PIXELS); listBox.setRows(Math.max(2, Math.min(5, container.size()))); FieldWrapper<Object> field = new FieldWrapper<Object>(listBox) { private static final long serialVersionUID = 1499878131611223989L; protected Component initContent() { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); // inner field layout.addComponent(innerField); layout.setComponentAlignment(innerField, Alignment.MIDDLE_LEFT); VerticalLayout buttons = new VerticalLayout(); layout.addComponent(buttons); // add button Button addBtn = new Button(ADD_ICON); addBtn.addStyleName(STYLE_QUIET); addBtn.addStyleName(STYLE_SMALL); buttons.addComponent(addBtn); addBtn.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { ValueEntryPopup popup = new ValueEntryPopup(500, new ValueCallback() { @Override public void newValue(String value) { container.addBean(value); // grow list size with max at 5 listBox.setRows(Math.max(2, Math.min(5, container.size()))); } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); // remove button Button delBtn = new Button(DEL_ICON); delBtn.addStyleName(STYLE_QUIET); delBtn.addStyleName(STYLE_SMALL); buttons.addComponent(delBtn); delBtn.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { Object itemId = listBox.getValue(); container.removeItem(itemId); } }); return layout; } @Override public void commit() throws SourceException, InvalidValueException { // override commit here because the ListSelect setValue() method // only sets the index of the selected item, and not the list content prop.setValue(container); } }; return field; }
From source file:org.vaadin.miki.widgets.ItemGridUI.java
License:Apache License
@SuppressWarnings("unchecked") @Override//from w ww. j a v a 2 s.co m protected void init(VaadinRequest request) { this.primary.addContainerProperty("text", String.class, ""); this.primary.addContainerProperty("number", Integer.class, 0); this.primary.addContainerProperty("bool", Boolean.class, false); for (int zmp1 = 0; zmp1 < 15; zmp1++) { Item item = this.primary.addItem(zmp1); item.getItemProperty("text").setValue("number " + zmp1); item.getItemProperty("number").setValue(zmp1 * 3); item.getItemProperty("bool").setValue((zmp1 % 3) == 1); } this.secondary.addContainerProperty("caption", String.class, "default"); this.secondary.addContainerProperty("price", Double.class, 1.99); for (int zmp1 = 5; zmp1 < 60; zmp1 += 3) { Item item = this.secondary.addItem(zmp1); item.getItemProperty("caption").setValue("this is item with id " + zmp1); item.getItemProperty("price").setValue(1.0 / zmp1); } final VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); this.setContent(layout); final ItemGrid grid = new ItemGrid(); grid.setContainerDataSource(this.primary); grid.setItemComponentGenerator(this.generator); layout.addComponent(grid); Slider slider = new Slider(1, 20); slider.setCaption("Select number of columns:"); slider.setValue(new Double(grid.getColumnCount())); slider.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140509; @Override public void valueChange(Property.ValueChangeEvent event) { Object number = event.getProperty().getValue(); if (number != null) grid.setColumnCount((int) Math.round((Double) number)); } }); slider.setSizeFull(); layout.addComponent(slider); CheckBox selectable = new CheckBox("Selectable?", grid.isSelectable()); selectable.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140510; @Override public void valueChange(Property.ValueChangeEvent event) { grid.setSelectable((Boolean) event.getProperty().getValue()); } }); layout.addComponent(selectable); CheckBox nullSelection = new CheckBox("Null selection allowed?", grid.isNullSelectionAllowed()); nullSelection.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140512; @Override public void valueChange(Property.ValueChangeEvent event) { grid.setNullSelectionAllowed((Boolean) event.getProperty().getValue()); } }); layout.addComponent(nullSelection); CheckBox multiSelection = new CheckBox("Multiple selection allowed?", grid.isMultiSelect()); multiSelection.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140512; @Override public void valueChange(Property.ValueChangeEvent event) { grid.setMultiSelect((Boolean) event.getProperty().getValue()); } }); layout.addComponent(multiSelection); CheckBox defaultGenerator = new CheckBox("Use ItemGrid's default component generator?"); defaultGenerator.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140513; @Override public void valueChange(Property.ValueChangeEvent event) { if ((Boolean) event.getProperty().getValue()) grid.setItemComponentGenerator(null); else grid.setItemComponentGenerator(ItemGridUI.this.generator); } }); layout.addComponent(defaultGenerator); ListSelect container = new ListSelect("Container data source", Arrays.asList(this.primary, this.secondary)); container.setNullSelectionAllowed(false); container.setItemCaption(this.primary, "Primary container"); container.setItemCaption(this.secondary, "Backup container"); container.select(this.primary); container.setImmediate(true); container.addValueChangeListener(new Property.ValueChangeListener() { private static final long serialVersionUID = 20140514; @Override public void valueChange(ValueChangeEvent event) { grid.setContainerDataSource((Container) event.getProperty().getValue()); } }); layout.addComponent(container); Button addItem = new Button("Add item to current container", new Button.ClickListener() { private static final long serialVersionUID = 20140515; @Override public void buttonClick(ClickEvent event) { grid.getContainerDataSource().addItem(grid.getContainerDataSource().size() + 0.5); } }); layout.addComponent(addItem); }
From source file:rs.pupin.jpo.validation.gui.constraints.IC01.java
@Override public void generateGUI() { Iterator<BindingSet> res = icQuery.getResults(); if (icQuery.getStatus() == ICQuery.Status.ERROR) { Label label = new Label(); label.setValue("ERROR \n" + icQuery.getErrorMessage()); rootLayout.addComponent(label);//from w ww. j a v a2 s .com return; } final HashMap<String, String> map = new HashMap<String, String>(); while (res.hasNext()) { BindingSet set = res.next(); map.put(set.getValue("obs").stringValue(), set.getValue("dsNum").stringValue()); } if (map.isEmpty()) { Label label = new Label(); label.setValue("All observations have links to data sets"); rootLayout.addComponent(label); return; } Label label = new Label(); label.setValue( "Below is the list of observations that are not linked to exactly one data set. Click on any of them to get more information and either edit the resource in OntoWiki or choose a quick solution"); rootLayout.addComponent(label); final ListSelect listObs = new ListSelect("Observations", map.keySet()); listObs.setNullSelectionAllowed(false); rootLayout.addComponent(listObs); listObs.setImmediate(true); listObs.setWidth("100%"); 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); 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); editInOW.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { editManually((String) listObs.getValue()); } }); Form panelQuickFix = new Form(); panelQuickFix.setCaption("Quick Fix"); panelQuickFix.setSizeFull(); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setSpacing(true); panelLayout.setSizeFull(); panelQuickFix.setLayout(panelLayout); rootLayout.addComponent(panelQuickFix); rootLayout.setExpandRatio(panelQuickFix, 2.0f); panelLayout.addComponent(new Label( "After the fix the selected observation will belong only to the data set selected below or you can choose to edit the selected observation manually in OntoWiki")); final ComboBox comboDataSets = new ComboBox(null, getDataSets()); comboDataSets.setNullSelectionAllowed(false); comboDataSets.setWidth("100%"); comboDataSets.setImmediate(true); panelLayout.addComponent(comboDataSets); final Button fix = new Button("Quick Fix"); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.addComponent(fix); buttonsLayout.addComponent(editInOW); panelLayout.addComponent(buttonsLayout); panelLayout.setExpandRatio(buttonsLayout, 2.0f); listObs.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(); } String chosenObs = (String) event.getProperty().getValue(); lblProblem.setValue("<b>Problem description: </b>The selected observation belongs to " + map.get(chosenObs) + " data sets. It should belong to exactly one."); } }); fix.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String chosenDataSet = (String) comboDataSets.getValue(); String observation = (String) listObs.getValue(); if (chosenDataSet == null) { Notification.show("DataSet was not selected", Notification.Type.ERROR_MESSAGE); return; } if (observation == null) { Notification.show("Observation was not selected", Notification.Type.ERROR_MESSAGE); return; } String dataSetProp = "http://purl.org/linked-data/cube#dataSet"; List<String> forRemoval = getObsDataSets(observation); if (forRemoval.size() > 0) { ArrayList<Statement> stmts = new ArrayList<Statement>(); for (String ds : forRemoval) stmts.add(getStatementFromUris(observation, dataSetProp, ds)); removeStatements(stmts); } ArrayList<Statement> addStmts = new ArrayList<Statement>(); addStmts.add(getStatementFromUris(observation, dataSetProp, chosenDataSet)); uploadStatements(addStmts); Notification.show("Fix executed"); icQuery.eval(); } }); }
From source file:rs.pupin.jpo.validation.gui.constraints.IC02.java
@Override public void generateGUI() { rootLayout.removeAllComponents();/*from w w w . jav 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> map = new HashMap<String, String>(); while (res.hasNext()) { BindingSet set = res.next(); map.put(set.getValue("dataSet").stringValue(), set.getValue("dsdNum").stringValue()); } if (map.isEmpty()) { Label label = new Label(); label.setValue("All data sets have exactly one link to the DSD"); rootLayout.addComponent(label); return; } Label label = new Label(); label.setValue( "Below is the list of data sets that are not linked to exactly one DSD. Click on any of them to get more information and either edit the data set in OntoWiki or choose a quick solution"); rootLayout.addComponent(label); final ListSelect listDataSets = new ListSelect("Data Sets", map.keySet()); listDataSets.setNullSelectionAllowed(false); rootLayout.addComponent(listDataSets); listDataSets.setImmediate(true); listDataSets.setWidth("100%"); 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); 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); editInOW.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { editManually((String) listDataSets.getValue()); } }); Form panelQuickFix = new Form(); panelQuickFix.setCaption("Quick Fix"); panelQuickFix.setSizeFull(); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setSpacing(true); panelLayout.setSizeFull(); panelQuickFix.setLayout(panelLayout); rootLayout.addComponent(panelQuickFix); rootLayout.setExpandRatio(panelQuickFix, 2.0f); panelLayout.addComponent(new Label( "After the fix the selected data sets will link only to the DSD selected below or you can choose to edit the selected data set manually in OntoWiki")); final ComboBox comboDSDs = new ComboBox(null, getDataStructureDefinitions()); comboDSDs.setNullSelectionAllowed(false); comboDSDs.setWidth("100%"); comboDSDs.setImmediate(true); panelLayout.addComponent(comboDSDs); final Button fix = new Button("Quick Fix"); HorizontalLayout buttonsLayout = new HorizontalLayout(); buttonsLayout.setSpacing(true); buttonsLayout.addComponent(fix); buttonsLayout.addComponent(editInOW); panelLayout.addComponent(buttonsLayout); panelLayout.setExpandRatio(buttonsLayout, 2.0f); listDataSets.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(); } String chosenDataSet = (String) event.getProperty().getValue(); lblProblem.setValue("<b>Problem description: </b>The selected data set belongs to " + map.get(chosenDataSet) + " DSDs. It should belong to exactly one."); } }); fix.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String chosenDSD = (String) comboDSDs.getValue(); String dataSet = (String) listDataSets.getValue(); if (chosenDSD == null) { Notification.show("DSD was not selected", Notification.Type.ERROR_MESSAGE); return; } if (dataSet == null) { Notification.show("Data set was not selected", Notification.Type.ERROR_MESSAGE); return; } String structProp = "http://purl.org/linked-data/cube#structure"; List<String> forRemoval = getDataSetDSDs(dataSet); if (forRemoval.size() > 0) { ArrayList<Statement> stmts = new ArrayList<Statement>(); for (String dsd : forRemoval) { stmts.add(getStatementFromUris(dataSet, structProp, dsd)); } removeStatements(stmts); } ArrayList<Statement> addStmts = new ArrayList<Statement>(); addStmts.add(getStatementFromUris(dataSet, structProp, chosenDSD)); uploadStatements(addStmts); Notification.show("Fix executed"); icQuery.eval(); } }); }
From source file:rs.pupin.jpo.validation.gui.constraints.IC03.java
@Override public void generateGUI() { rootLayout.removeAllComponents();// w w w . j ava2s . c o m Iterator<BindingSet> res = icQuery.getResults(); if (icQuery.getStatus() == ICQuery.Status.ERROR) { Label label = new Label(); label.setValue("ERROR \n" + icQuery.getErrorMessage()); rootLayout.addComponent(label); return; } final List<String> dsdList = new ArrayList<String>(); while (res.hasNext()) { BindingSet set = res.next(); dsdList.add(set.getValue("dsd").stringValue()); } if (dsdList.isEmpty()) { Label label = new Label(); label.setValue("All DSDs contain at least one measure"); rootLayout.addComponent(label); return; } Label lbl = new Label(); lbl.setValue("Following DSDs do not have at least one measure defined"); rootLayout.addComponent(lbl); final ListSelect listDSDs = new ListSelect("DSDs", dsdList); listDSDs.setNullSelectionAllowed(false); listDSDs.setImmediate(true); rootLayout.addComponent(listDSDs); Form panelQuickFix = new Form(); panelQuickFix.setCaption("Quick Fix"); panelQuickFix.setSizeFull(); VerticalLayout panelLayout = new VerticalLayout(); panelLayout.setSpacing(true); panelLayout.setSizeFull(); panelQuickFix.setLayout(panelLayout); rootLayout.addComponent(panelQuickFix); rootLayout.setExpandRatio(panelQuickFix, 2.0f); Label fixLabel = new Label(); fixLabel.setContentMode(ContentMode.HTML); fixLabel.setValue("After the fix, component selected in the combo box below will be turned to measure, " + "or you can choose to edit the above selected DSD manually in OntoWiki"); panelLayout.addComponent(fixLabel); final ComboBox comboComponents = new ComboBox(); comboComponents.setWidth("100%"); comboComponents.setNullSelectionAllowed(false); comboComponents.setImmediate(true); panelLayout.addComponent(comboComponents); HorizontalLayout btnLayout = new HorizontalLayout(); btnLayout.setSpacing(true); Button editOW = new Button("Edit in OntoWiki"); editOW.setEnabled(owUrl != null); Button turnToMeasure = new Button("Turn to measure"); btnLayout.addComponent(turnToMeasure); btnLayout.addComponent(editOW); panelLayout.addComponent(btnLayout); panelLayout.setExpandRatio(btnLayout, 2.0f); listDSDs.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent event) { String dsd = event.getProperty().getValue().toString(); if (dsd == null || dsd.equalsIgnoreCase("")) { return; } comboComponents.removeAllItems(); TupleQueryResult qRes = executeTupleQuery( ValidationFixUtils.ic03_getRequiredAttributes(graph, dsd)); try { while (qRes.hasNext()) { comboComponents.addItem(qRes.next().getValue("attr").toString()); } } catch (QueryEvaluationException e) { e.printStackTrace(); } } }); turnToMeasure.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Object selVal = comboComponents.getValue(); if (selVal == null) { Notification.show("No component was selected in the combo box"); return; } GraphQueryResult resFix = executeDoubleGraphQuery( ValidationFixUtils.ic03_turnToMeasure(graph, selVal.toString()), ValidationFixUtils.ic03_turnToMeasure2(graph, selVal.toString())); if (resFix != null) { Notification.show("Fix executed"); icQuery.eval(); } } }); editOW.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { editManually((String) listDSDs.getValue()); } }); }
From source file:rs.pupin.jpo.validation.gui.constraints.IC04.java
@Override public void generateGUI() { rootLayout.removeAllComponents();//from w w w . j a v a 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("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();/* www. j ava 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();//from www. j a v a2 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 a v a 2 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 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(); } } }); }