/** * Build content 'evaluation process' of tab 3. * * @return content of third tab */ private Layout buildTab3Content() { VerticalLayout tab3Content = new VerticalLayout(); tab3Content.setSpacing(true); tab3Content.setMargin(true); tab3Content.setSizeFull(); Label instructions = new Label( "<b>Instructions:</b> <i>Please select and click a sentence below in order to process the evaluation.</i>", Label.CONTENT_XHTML); tab3Content.addComponent(instructions); this.tableEvaluation = new Table("Evaluation process:"); tableEvaluation.setHeight("150px"); tableEvaluation.setWidth("100%"); tableEvaluation.setImmediate(true); tableEvaluation.setSelectable(true); tableEvaluation.setMultiSelect(false); tableEvaluation.setSortDisabled(false); tableEvaluation.addContainerProperty("ID", Integer.class, null); tableEvaluation.addContainerProperty("Sentence", String.class, null); tableEvaluation.addContainerProperty("Precision", Double.class, null); tableEvaluation.addContainerProperty("Recall", Double.class, null); tableEvaluation.addContainerProperty("F-Score", Double.class, null); tab3Content.addComponent(tableEvaluation); this.buttonNext2 = new Button("Next"); buttonNext2.setImmediate(true); buttonNext2.setDescription("Get the next sentence in table"); tab3Content.addComponent(buttonNext2); this.textAreaEvalSentence = new TextArea("Sentence:"); textAreaEvalSentence.setImmediate(false); textAreaEvalSentence.setReadOnly(true); textAreaEvalSentence.setRows(3); textAreaEvalSentence.setWidth("100%"); tab3Content.addComponent(textAreaEvalSentence); HorizontalLayout hlay1 = new HorizontalLayout(); this.listSelectGoldstandard = new ListSelect("Goldstandard:"); listSelectGoldstandard.setImmediate(true); listSelectGoldstandard.setHeight("120px"); listSelectGoldstandard.setWidth("100%"); listSelectGoldstandard.setNullSelectionAllowed(false); this.listSelectFramework = new ListSelect("Framework:"); listSelectFramework.setImmediate(true); listSelectFramework.setHeight("120px"); listSelectFramework.setWidth("100%"); listSelectFramework.setNullSelectionAllowed(false); hlay1.setSpacing(true); hlay1.setMargin(false); hlay1.setWidth("100%"); hlay1.addComponent(listSelectGoldstandard); hlay1.addComponent(listSelectFramework); tab3Content.addComponent(hlay1); return tab3Content; }
@Override public void bind() { Table userList = this.view.getUserList(); container = new BeanItemContainer<User>(User.class); userList.setContainerDataSource(container); userList.setVisibleColumns(new String[] {"userName", "firstName", "lastName"}); userList.setImmediate(true); userList.setSelectable(true); userList.setMultiSelect(false); // userList.setEditable(true); }
public ObjectTypeSelectionPopup( String title, final Map<String, Class<?>> typeList, final ObjectTypeSelectionCallback callback) { super(title); VerticalLayout layout = new VerticalLayout(); layout.setSpacing(true); // generate table with type list final Table table = new Table(); table.setSizeFull(); table.setSelectable(true); table.setColumnReorderingAllowed(true); table.addContainerProperty(UIConstants.PROP_NAME, String.class, null); table.setColumnHeaderMode(ColumnHeaderMode.HIDDEN); table.setPageLength(10); table.setMultiSelect(false); final Map<Object, Class<?>> idTypeMap = new HashMap<Object, Class<?>>(); for (Entry<String, Class<?>> item : typeList.entrySet()) { Object id = table.addItem(new Object[] {item.getKey()}, null); idTypeMap.put(id, item.getValue()); } layout.addComponent(table); // add OK button Button okButton = new Button("OK"); okButton.addClickListener( new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { Object selectedItemId = table.getValue(); if (selectedItemId != null) { Class<?> clazz = idTypeMap.get(selectedItemId); if (clazz != null) callback.onSelected(clazz); } close(); } }); layout.addComponent(okButton); layout.setComponentAlignment(okButton, Alignment.MIDDLE_CENTER); setContent(layout); center(); }
private Panel designMainPanel() { // positioning indices final int leftStart = 450, topStart = 10, space = 100; // create the panel that will hold all components Panel pnlURIsProperties = new Panel("URI Display"); pnlURIsProperties.setWidth("100%"); pnlURIsProperties.setHeight("100%"); // Create absolute layout specifying its properties final AbsoluteLayout layout = new AbsoluteLayout(); layout.setWidth("100%"); layout.setHeight("100%"); layout.setSizeFull(); // Create components Objects and specify their properties Button btnCorrect = new Button("Correct"); Button btnIncorrect = new Button("Incorrect"); Button btnUnsure = new Button("Unsure"); Button btnGetProperties = new Button("Get properties"); final NativeSelect cmbSourceEndpoint = new NativeSelect("Source Endpoint"); final NativeSelect cmbDestinationEndpoint = new NativeSelect("Destination Endpoint"); final ListSelect lstSuggestedProperties = new ListSelect("Lookup Properties"); // to load properties of loaded resources automatically final CheckBox chkAutomaticPropertiesLoad = new CheckBox("Automatic Properties loading (next time)"); chkAutomaticPropertiesLoad.setValue(false); cmbSourceEndpoint.setNullSelectionAllowed(false); cmbDestinationEndpoint.setNullSelectionAllowed(false); lstSuggestedProperties.setRows(4); lstSuggestedProperties.setNullSelectionAllowed(false); source = new Label("Source URI"); destination = new Label("Destination URI"); final Table tblSourcePropertiesMapping = new Table("Source Properties"); final Table tblDestinationPropertiesMapping = new Table("Destination Properties"); tblSourcePropertiesParam = tblSourcePropertiesMapping; tblDestinationPropertiesParam = tblDestinationPropertiesMapping; tblSourcePropertiesMapping.setWidth("50%"); tblDestinationPropertiesMapping.setWidth("100%"); tblSourcePropertiesMapping.setSelectable(true); tblDestinationPropertiesMapping.setSelectable(true); /* Define the names and data types of columns. * The "default value" parameter is meaningless here. */ tblSourcePropertiesMapping.addContainerProperty("Property", String.class, null); tblSourcePropertiesMapping.addContainerProperty("Value", String.class, null); tblDestinationPropertiesMapping.addContainerProperty("Property", String.class, null); tblDestinationPropertiesMapping.addContainerProperty("Value", String.class, null); tblDestinationPropertiesMapping.setMultiSelect(true); /// get data for comboboxes SQLContainer cmbContainer = connectToDB("root", "mofo", "Endpoints"); // fill endpoints cmbSourceEndpoint.setContainerDataSource(cmbContainer); cmbDestinationEndpoint.setContainerDataSource(cmbContainer); cmbSourceEndpoint.setValue(cmbSourceEndpoint.getItemIds().iterator().next()); cmbDestinationEndpoint.setValue(cmbDestinationEndpoint.getItemIds().iterator().next()); SQLContainer lstContainer = getSuggestedProperties("root", "mofo"); int lstSize = lstContainer.size(); int i = 0; for (Object cityItemId : lstContainer.getItemIds()) { lstSuggestedProperties.addItem(i); String g = lstContainer.getItem(cityItemId).getItemProperty("property").getValue().toString(); lstSuggestedProperties.setItemCaption(i, g); i++; } lstSuggestedProperties.setValue(lstSuggestedProperties.getItemIds().iterator().next()); btnCorrect.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); long lEllapsedTime = lEndTime - lStartTime; tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Correct"); tblSourceDestinationparam .getContainerProperty(rowId, "time") .setValue(String.valueOf(lEllapsedTime)); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } /////////////////////////////////// } }); btnIncorrect.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); long lEllapsedTime = lEndTime - lStartTime; tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam .getContainerProperty(rowId, "decision") .setValue("Incorrect"); tblSourceDestinationparam .getContainerProperty(rowId, "time") .setValue(String.valueOf(lEllapsedTime)); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR Not Properties queried"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } /////////////////////////////////// } }); btnUnsure.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { try { Object rowId = tblSourceDestinationparam.getValue(); Item myitem = tblSourceDestinationparam.getItem(tblSourceDestinationparam.getValue()); lEndTime = System.currentTimeMillis(); float lEllapsedTime = lEndTime - lStartTime; String elapsedTime = String.valueOf(lEllapsedTime); tblSourceDestinationparam.setEditable(true); tblSourceDestinationparam.getContainerProperty(rowId, "decision").setValue("Unsure"); tblSourceDestinationparam.getContainerProperty(rowId, "time").setValue(elapsedTime); tblSourceDestinationparam.setEditable(false); SQLContainer c = (SQLContainer) tblSourceDestinationparam.getContainerDataSource(); try { c.commit(); } catch (UnsupportedOperationException | SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } // int selectedId=Integer.parseInt(tblSourceDestination.getValue().toString()); int maxindex = tblSourceDestination.size(); SQLContainer s = (SQLContainer) tblSourceDestination.getContainerDataSource(); // Item x=s.getItem(tblSourceDestination.getValue()); if (!(tblSourceDestination.getValue().equals(tblSourceDestination.lastItemId()))) { int index = s.indexOfId(tblSourceDestination.getValue()); index++; tblSourceDestination.setValue(s.getIdByIndex(index)); try { Object rowId2 = tblSourceDestination.getValue(); Property sourceProperty = tblSourceDestination.getContainerProperty(rowId2, "sourceURI"); Property destinationProperty = tblSourceDestination.getContainerProperty(rowId2, "destinationURI"); source.setValue(sourceProperty.toString()); destination.setValue(destinationProperty.toString()); tblSourcePropertiesParam.removeAllItems(); tblDestinationPropertiesParam.removeAllItems(); Notification loadURI = new Notification(""); loadURI.show("Links' URIs are successfully loaded "); if (chkAutomaticPropertiesLoad.getValue()) // the automatic buton i schecked { // load the properties automatically String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties( sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show("ERROR Not Properties queried"); } lStartTime = System.currentTimeMillis(); // start time for next one } } catch (Exception e) { Notification error = new Notification("Error"); error.show("You did not select an item in the links table"); } } } catch (Exception e) { Notification.show(e.getMessage()); } } }); btnGetProperties.addClickListener( new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { String sourceEndpoint = "", destinationEndpoint = ""; sourceEndpoint = cmbSourceEndpoint.getItemCaption(cmbSourceEndpoint.getValue()); destinationEndpoint = cmbDestinationEndpoint.getItemCaption(cmbDestinationEndpoint.getValue()); lStartTime = System.currentTimeMillis(); try { String sparqlQuery = source.getValue(); getURIProperties(sparqlQuery, sourceEndpoint, tblSourcePropertiesMapping); sparqlQuery = destination.getValue(); getURIProperties(sparqlQuery, destinationEndpoint, tblDestinationPropertiesMapping); } catch (Exception e) { Notification.show( "ERROR while sparqling the endpoint for resources' properties (Are they selected/loaded ?)"); } // cachingForTriples(tblSourceDestination, sourceEndpoint); } }); lstSuggestedProperties.addValueChangeListener( new ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent event) { final String valueString = String.valueOf(event.getProperty().getValue()); // Notification.show(valueString); List<Object> Ids = new ArrayList<Object>(); Object first = null; for (Iterator i = tblSourcePropertiesMapping.getItemIds().iterator(); i.hasNext(); ) { // Get the current item identifier, which is an integer. first = i.next(); int iid = (Integer) first; String other = tblSourcePropertiesMapping.getItem(iid).getItemProperty("Property").toString(); // Notification.show(other); if (other.equals(valueString)) // if(other.equals(property)) { Ids.add(iid); break; } } tblSourcePropertiesMapping.setImmediate(true); tblSourcePropertiesMapping.setValue(Ids); tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first); } }); tblSourcePropertiesMapping.addItemClickListener( new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { String property = tblSourcePropertiesMapping .getContainerProperty(event.getItemId(), event.getPropertyId()) .toString(); List<String> res = getRelatedProperties(property); if (res == null) { Notification.show("No related Properties"); return; } boolean Found = false; List<Object> Ids = new ArrayList<Object>(); Object first = null; int x = 0; for (String relatedProperty : res) { for (Iterator i = tblDestinationPropertiesMapping.getItemIds().iterator(); i.hasNext(); ) { // Get the current item identifier, which is an integer. Object theId = i.next(); int iid = (Integer) theId; String other = tblDestinationPropertiesMapping .getItem(iid) .getItemProperty(event.getPropertyId()) .toString(); if (other.equals(relatedProperty)) // if(other.equals(property)) { Ids.add(iid); if (x == 0) { first = theId; x = 1; } Found = true; } } } if (!Found) Notification.show( "Related property is not Found in destination table try manual search"); else { Notification.show("Found in destination table"); tblDestinationPropertiesMapping.setValue(Ids); tblDestinationPropertiesMapping.setCurrentPageFirstItemId(first); } } }); // add component to the layout specifying its position on the layout layout.addComponent(btnCorrect, "left: " + leftStart + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnIncorrect, "left: " + (leftStart + space) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnUnsure, "left: " + (leftStart + 2 * space) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( btnGetProperties, "left: " + (leftStart + 3 * space + 50) + "px; top: " + (topStart + 450) + "px;"); layout.addComponent( chkAutomaticPropertiesLoad, "left: " + (leftStart + 3 * space + 250) + "px; top: " + (topStart + 450) + "px;"); /*layout.addComponent(sourceURI,"left: "+(leftStart-space/2)+"px; top: "+(topStart+space/2)+"px;"); layout.addComponent(destinationURI,"left: "+(leftStart+2*space)+"px; top: "+(topStart+space/2)+"px;");*/ layout.addComponent(source, "left: 30px; top: " + (topStart + space / 2) + "px;"); layout.addComponent( destination, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space / 2) + "px;"); layout.addComponent(cmbSourceEndpoint, "left: 50px; top: " + (topStart + 20) + "px;"); layout.addComponent( cmbDestinationEndpoint, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + 20) + "px;"); layout.addComponent( lstSuggestedProperties, "left: " + (leftStart + 100) + "px; top: " + (topStart + 20) + "px;"); layout.addComponent( tblSourcePropertiesMapping, "left: 10px; top: " + (topStart + space) + "px;"); layout.addComponent( tblDestinationPropertiesMapping, "left: " + (leftStart + 3 * space + 200) + "px; top: " + (topStart + space) + "px;"); pnlURIsProperties.setContent(layout); return pnlURIsProperties; }
protected Component createMainArea() { layout = new VerticalLayout(); layout.setSpacing(true); layout.setMargin(true); layout.setSizeFull(); HorizontalLayout filterLine = new HorizontalLayout(); TextField filterBox = new TextField(); filterBox.addStyleName(JabylonStyle.SEARCH_FIELD.getCSSName()); filterBox.addListener( new TextChangeListener() { @Override public void textChange(TextChangeEvent event) { propertyFilter.setFilterText(event.getText()); propertyPairContainer.addContainerFilter(propertyFilter); } }); filterBox.setInputPrompt( Messages.getString("PropertiesEditor_FILTER_INPUT_PROMPT")); // $NON-NLS-1$ filterLine.addComponent(filterBox); final CheckBox untranslatedBox = new CheckBox( Messages.getString( "PropertiesEditor_SHOW_ONLY_UNTRANSLATED_BUTTON_CAPTION")); //$NON-NLS-1$ untranslatedBox.addListener( new ClickListener() { @Override public void buttonClick(ClickEvent event) { propertyPairContainer.removeContainerFilter(untranslatedFilter); if (untranslatedBox.getValue().equals(Boolean.TRUE)) propertyPairContainer.addContainerFilter(untranslatedFilter); } }); untranslatedBox.setImmediate(true); filterLine.addComponent(untranslatedBox); layout.addComponent(filterLine); layout.setExpandRatio(filterLine, 0); table = new Table(); table.addStyleName(JabylonStyle.TABLE_STRIPED.getCSSName()); table.setSizeFull(); target = descriptor.loadProperties(); source = descriptor.getMaster().loadProperties(); propertyPairContainer = new PropertyPairContainer(source, target); table.setContainerDataSource(propertyPairContainer); table.setVisibleColumns( propertyPairContainer.getContainerPropertyIds().subList(0, 2).toArray()); table.setWidth(100, Table.UNITS_PERCENTAGE); table.addGeneratedColumn( Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"), new ColumnGenerator() { //$NON-NLS-1$ @Override public Object generateCell(Table source, Object itemId, Object columnId) { if (reviews.containsKey(itemId)) { Embedded embedded = new Embedded("", ImageConstants.IMAGE_ERROR); // $NON-NLS-1$ Review review = reviews.get((String) itemId).iterator().next(); // TODO: this can't be the right way to refresh? if (review.cdoInvalid()) { reviews.remove(itemId, review); // the review is // no // longer valid embedded.setIcon(ImageConstants.IMAGE_OK); embedded.setDescription(""); // $NON-NLS-1$ } else { embedded.setDescription(review.getMessage()); } return embedded; } else return new Embedded("", ImageConstants.IMAGE_OK); // $NON-NLS-1$ } }); table.setColumnHeaderMode(Table.COLUMN_HEADER_MODE_EXPLICIT); table.setColumnHeaders( new String[] { Messages.getString("PropertiesEditor_ORIGINAL_COLUMN_HEADER"), Messages.getString("PropertiesEditor_TRANSLATED_COLUMN_HEADER"), Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER") }); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(0), 1.0f); table.setColumnExpandRatio(propertyPairContainer.getContainerPropertyIds().get(1), 1.0f); table.setColumnExpandRatio( Messages.getString("PropertiesEditor_PROBLEMS_COLUMN_HEADER"), 0.0f); // $NON-NLS-1$ table.setEditable(false); table.setWriteThrough(false); table.setSelectable(true); table.setMultiSelect(false); table.setImmediate(true); // react at once when something is selected table.addListener(this); layout.addComponent(table); layout.setExpandRatio(table, 2); createEditorArea(); return layout; }