List of usage examples for com.vaadin.ui Button setEnabled
@Override public void setEnabled(boolean enabled)
From source file:pl.exsio.frameset.vaadin.ui.support.component.data.common.DataComponent.java
License:Open Source License
private Button createFormSaveButton(final I item, final F form, final C container, final Window formWindow, final int mode) { Button save = new Button(t(config.getFormSaveButtonLabel()), FontAwesome.FLOPPY_O); save.addClickListener(new Button.ClickListener() { @Override// ww w. java2 s . co m public void buttonClick(Button.ClickEvent event) { handleFormSave(item, form, container, formWindow, mode); } }); if ((mode == MODE_EDITION && !this.canSaveItem(item)) || (mode == MODE_ADDITION && !this.canAddItem())) { save.setEnabled(false); } save.setStyleName("frameset-dc-form-button-save"); return save; }
From source file:qbic.vaadincomponents.TSVDownloadComponent.java
License:Open Source License
protected void armDownloadButton(Button b, StreamResource stream, int dlnum) { if (downloaders.size() < dlnum) { FileDownloader dl = new FileDownloader(stream); dl.extend(b);//www . j a v a 2 s . c o m downloaders.add(dl); } else downloaders.get(dlnum - 1).setFileDownloadResource(stream); b.setEnabled(true); }
From source file:ro.zg.netcell.vaadin.action.application.EntityListHandler.java
License:Apache License
private void refreshPageControls(final Entity entity, final UserAction ua, final OpenGroupsApplication app, final ComponentContainer container, final ActionContext ac) { final int itemsPerPage = entity.getState().getItemsPerPage(); Button prevButton = new Button(); prevButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.LEFT_ARROW, OpenGroupsIconsSet.SMALL)); ComboBox currentPageSelect = new ComboBox(); currentPageSelect.setImmediate(true); currentPageSelect.setNullSelectionAllowed(false); currentPageSelect.setNewItemsAllowed(false); double totalItemsCount = entity.getState().getCurrentListTotalItemsCount(); if (totalItemsCount < 0) { /* the type of the listed entities */ String targetEntityComplexType = ua.getTargetEntityComplexType().toLowerCase(); /* let's find out if this list is recursive or not */ boolean isRecursive = false; /* first check if the target type allows a recursive list in the first place */ // if (getAppConfigManager().getComplexEntityBooleanParam(ua.getTargetEntityComplexType(), // ComplexEntityParam.ALLOW_RECURSIVE_LIST)) { if (app.getAppConfigManager().getTypeRelationBooleanConfigParam(ua.getTypeRelationId(), TypeRelationConfigParam.ALLOW_RECURSIVE_LIST)) { /*/*from w w w . j av a 2s .c o m*/ * if it does, check if the filter is actually set to display all items, that means the recursion depth * is undefined or greater than 0 */ isRecursive = (entity.getFilterValue("depth") == null) ? true : false; if (!isRecursive) { long listDepth = (Long) entity.getFilter("depth").getValue(); if (listDepth > 0) { isRecursive = true; } } } /* if the list is recursive get the number of all entities of the specified type under selected entity */ if (isRecursive) { totalItemsCount = entity.getRecursiveSubtypeEntitiesCount().get(targetEntityComplexType); } /* not recursive, get only the number of first level entities of the specified type */ else { totalItemsCount = entity.getSubtypeEntitiesCount().get(targetEntityComplexType); } } /* * now that we know the total possible entities in this list, and the items per page, we can calculate, the * number of pages */ int numberOfPages = (int) Math.ceil(totalItemsCount / itemsPerPage); final int currentPage = entity.getState().getCurrentPageForCurrentAction(); /* populate the currentpage combobox with the number of pages */ for (int i = 1; i <= numberOfPages; i++) { currentPageSelect.addItem(i + "/" + numberOfPages); } String currentPageString = currentPage + "/" + numberOfPages; currentPageSelect.setValue(currentPageString); int width = currentPageString.length() * 20; currentPageSelect.setWidth(width + "px"); Button nextButton = new Button(); nextButton.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.RIGHT_ARROW, OpenGroupsIconsSet.SMALL)); if (currentPage == 1) { prevButton.setEnabled(false); } if (currentPage == numberOfPages) { nextButton.setEnabled(false); } prevButton.addStyleName("middle-left right-margin-10"); currentPageSelect.addStyleName("middle-left right-margin-10"); nextButton.addStyleName("middle-left"); container.addComponent(prevButton); container.addComponent(currentPageSelect); container.addComponent(nextButton); /* listeners */ prevButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { entity.getState().setCurrentPageForCurrentAction(currentPage - 1); refreshList(entity, ua, app, entity.getState().getLastUsedContainer(), ac); // refreshList(entity, ua, app, entity.getState().getChildrenListContainer()); } }); nextButton.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { entity.getState().setCurrentPageForCurrentAction(currentPage + 1); refreshList(entity, ua, app, entity.getState().getLastUsedContainer(), ac); // refreshList(entity, ua, app, entity.getState().getChildrenListContainer()); } }); currentPageSelect.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { String value = (String) event.getProperty().getValue(); String page = value.substring(0, value.indexOf("/")); entity.getState().setCurrentPageForCurrentAction(Integer.parseInt(page)); refreshList(entity, ua, app, entity.getState().getLastUsedContainer(), ac); // refreshList(entity, ua, app, entity.getState().getChildrenListContainer()); } }); }
From source file:ro.zg.opengroups.views.UserNotificationRulesListControls.java
License:Apache License
private void displayAddNewRuleButton(final NotificationRulesList updateData) { Button button = new Button(); button.addStyleName(updateData.getControlsContainerCellStyle()); // TODO: add an icon, don't let this hardcoded text button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.add.rule")); button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.ADD, OpenGroupsIconsSet.SMALL)); if (!updateData.isNewRuleAllowed()) { button.setEnabled(false); } else {/*from w w w . j a v a2 s . c om*/ button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { updateData.createNewRule(); } }); } container.addComponent(button); }
From source file:ro.zg.opengroups.views.UserNotificationRulesListControls.java
License:Apache License
private void displaySaveRulesButton(final NotificationRulesList updateData) { final Button button = new Button(); button.addStyleName(updateData.getControlsContainerCellStyle()); // TODO: add an icon, don't let this hardcoded text button.setDescription(OpenGroupsResources.getMessage("notification.rules.list.save")); button.setIcon(OpenGroupsResources.getIcon(OpenGroupsIconsSet.ACCEPT, OpenGroupsIconsSet.SMALL)); if (!updateData.isSaveNeeded()) { button.setEnabled(false); } else {//from ww w . j ava 2s. co m button.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { handleEvent(new UserEvent(NotificationUserEvents.SAVE_BUTTON_CLICKED, button, updateData)); } }); } container.addComponent(button); }
From source file:rs.pupin.jpo.esta_ld.InspectComponent.java
private void showTransformDimensionView(Dimension dim) { dimTransformLayout.removeAllComponents(); dimTransformLayout.addComponent(new Label("<h1>Manage Temporal Dimension</h1>", Label.CONTENT_XHTML)); dimTransformLayout.addComponent(new Label("<h2>Dimension: " + dim.getUri() + "</h2>", Label.CONTENT_XHTML)); // show properties table final Table propertiesTable = new Table("Properties"); propertiesTable.setHeight("250px"); propertiesTable.setWidth("100%"); propertiesTable.addContainerProperty("Property", String.class, null); propertiesTable.addContainerProperty("Value", String.class, null); dimTransformLayout.addComponent(propertiesTable); try {/* w w w . j a v a 2 s . c o m*/ RepositoryConnection conn = repository.getConnection(); TupleQuery query = conn.prepareTupleQuery(QueryLanguage.SPARQL, DSDRepoUtils.qResourcePorperties(dim.getUri(), dataGraph)); TupleQueryResult res = query.evaluate(); int i = 0; while (res.hasNext()) { BindingSet set = res.next(); Object[] row = new Object[] { set.getValue("p").stringValue(), set.getValue("o").stringValue() }; propertiesTable.addItem(row, i++); } } catch (RepositoryException ex) { logger.log(Level.SEVERE, null, ex); } catch (MalformedQueryException ex) { logger.log(Level.SEVERE, null, ex); } catch (QueryEvaluationException ex) { logger.log(Level.SEVERE, null, ex); } // add separator dimTransformLayout.addComponent(new Label("<hr/>", Label.CONTENT_XHTML)); // TODO: show transform to time dimension // select: { year, month, date } final ComboBox comboType = new ComboBox("Choose type:", Arrays.asList(TimeDimensionTransformator.Type.values())); comboType.setNullSelectionAllowed(false); comboType.select(TimeDimensionTransformator.Type.XSD_YEAR); dimTransformLayout.addComponent(comboType); // text field: { pattern } final TextField fieldPattern = new TextField("Transformation Pattern:"); fieldPattern.setWidth("400px"); dimTransformLayout.addComponent(fieldPattern); // button: transform final Button btnTransform = new Button("Transform"); dimTransformLayout.addComponent(btnTransform); final TimeDimensionTransformator timeTransformator = new TimeDimensionTransformator(repository, dataGraph, dim.getUri(), (TimeDimensionTransformator.Type) comboType.getValue()); try { timeTransformator.initialize(); } catch (RepositoryException ex) { logger.log(Level.SEVERE, null, ex); btnTransform.setEnabled(false); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } catch (MalformedQueryException ex) { logger.log(Level.SEVERE, null, ex); btnTransform.setEnabled(false); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } catch (QueryEvaluationException ex) { logger.log(Level.SEVERE, null, ex); btnTransform.setEnabled(false); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } btnTransform.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (fieldPattern.getValue() == null) { getWindow().showNotification("Come on, you need to provide the transformation pattern"); } try { // set type according to the value in the combo box timeTransformator.setType((TimeDimensionTransformator.Type) comboType.getValue()); // first check if the values can be parsed logger.fine("Parsing..."); timeTransformator.parseLean(fieldPattern.getValue().toString()); // if parsing went fine fire away logger.fine("Modifying dimension..."); timeTransformator.modifyDimension(); logger.fine("Removing old..."); timeTransformator.removeOld(); logger.fine("Inserting new..."); timeTransformator.insertNew(); logger.fine("Finished transformation!!!"); getWindow().showNotification("Dimension transformed"); // } catch (ParseException ex) { // logger.log(Level.SEVERE, null, ex); // String msg = "Could not parse values \n"; // getWindow().showNotification(msg + ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } catch (RepositoryException ex) { logger.log(Level.SEVERE, null, ex); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } catch (MalformedQueryException ex) { logger.log(Level.SEVERE, null, ex); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } catch (QueryEvaluationException ex) { logger.log(Level.SEVERE, null, ex); getWindow().showNotification(ex.getMessage(), Window.Notification.TYPE_ERROR_MESSAGE); } } }); }
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);// w ww.j a v a 2 s .c o m 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. j a v 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> 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 a v 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 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 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 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(); } } }); }