List of usage examples for com.vaadin.ui Button addListener
@Override
public Registration addListener(Component.Listener listener)
From source file:rs.pupin.jpo.esta_ld.DSDRepoComponent.java
private void refreshContentCreateDSD(DataSet ds) { if (ds == null) { getWindow().showNotification("No dataset selected", Window.Notification.TYPE_ERROR_MESSAGE); return;// www.j a v a2 s . c om } Structure struct = ds.getStructure(); if (struct != null) { contentLayout.addComponent(new Label("The dataset already has a DSD!")); return; } dataset = ds.getUri(); contentLayout.removeAllComponents(); dataTree = new Tree("Dataset"); dataTree.setNullSelectionAllowed(true); dataTree.setImmediate(true); dataTree.setWidth("500px"); populateDataTree(); addDataTreeListenersCreate(); contentLayout.addComponent(dataTree); contentLayout.setExpandRatio(dataTree, 0.0f); final VerticalLayout right = new VerticalLayout(); right.setSpacing(true); contentLayout.addComponent(right); contentLayout.setExpandRatio(right, 2.0f); lblUndefined = new Label("There are still x undefined components", Label.CONTENT_XHTML); right.addComponent(lblUndefined); lblMissingCodeLists = new Label("There are still y missing code lists", Label.CONTENT_XHTML); right.addComponent(lblMissingCodeLists); final TextField dsdUri = new TextField("Enter DSD URI"); dsdUri.setWidth("300px"); right.addComponent(dsdUri); final Button btnCreate = new Button("Create DSD"); right.addComponent(btnCreate); right.addComponent(new Label("<hr/>", Label.CONTENT_XHTML)); compatibleCodeLists = new Tree("Compatible code lists"); right.addComponent(compatibleCodeLists); updateUndefinedAndMissing(); compatibleCodeLists.addActionHandler(new Action.Handler() { public Action[] getActions(Object target, Object sender) { if (target == null) return null; if (compatibleCodeLists.getParent(target) != null) return null; return new Action[] { ACTION_SET_AS_CL }; } public void handleAction(Action action, Object sender, Object target) { if (action == ACTION_SET_AS_CL) { Object item = compatibleCodeLists.getData(); if (item == null) { getWindow().showNotification( "Error, the component cannot determine where to put the code list", Window.Notification.TYPE_ERROR_MESSAGE); return; } if (dataTree.getChildren(item).size() == 2) { getWindow().showNotification("The component property already has a code list", Window.Notification.TYPE_ERROR_MESSAGE); return; } try { RepositoryConnection conn = repository.getConnection(); String cl = (String) target; String prop = (String) dataTree.getValue(); GraphQuery query = conn.prepareGraphQuery(QueryLanguage.SPARQL, DSDRepoUtils.qPullCodeList(cl, prop, repoGraph, dataGraph)); query.evaluate(); getWindow().showNotification("Code List set"); addCodeListToDataTree(); updateUndefinedAndMissing(); } catch (RepositoryException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedQueryException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } catch (QueryEvaluationException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } } } }); btnCreate.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (numUndefinedComponents > 0) { getWindow().showNotification("There can be no undefined components", Window.Notification.TYPE_ERROR_MESSAGE); return; } if (numMissingCodeLists > 0) { getWindow().showNotification("All code lists must first be created or imported", Window.Notification.TYPE_ERROR_MESSAGE); return; } final String dsd = dsdUri.getValue().toString(); if (!isUri(dsd)) { getWindow().showNotification("Enter a valid URI for the DSD", Window.Notification.TYPE_ERROR_MESSAGE); } try { RepositoryConnection conn = repository.getConnection(); LinkedList<String> dList = new LinkedList<String>(); LinkedList<String> mList = new LinkedList<String>(); LinkedList<String> aList = new LinkedList<String>(); LinkedList<String> uList = new LinkedList<String>(); LinkedList<String> propList = new LinkedList<String>(); LinkedList<String> rangeList = new LinkedList<String>(); for (Object id : dataTree.rootItemIds()) { Collection<?> children = dataTree.getChildren(id); if (children == null) continue; Collection<String> list = null; if (id.toString().startsWith("D")) list = dList; else if (id.toString().startsWith("M")) list = mList; else if (id.toString().startsWith("A")) list = aList; else if (id.toString().startsWith("U")) list = uList; for (Object prop : dataTree.getChildren(id)) { CountingTreeHeader h = (CountingTreeHeader) dataTree.getChildren(prop).iterator() .next(); propList.add(prop.toString()); list.add(prop.toString()); if (h.toString().startsWith("C")) { rangeList.add("http://www.w3.org/2004/02/skos/core#Concept"); } else { rangeList.add(dataTree.getChildren(h).iterator().next().toString()); } } } if (uList.size() > 0) { getWindow().showNotification("There are undefined properties!", Window.Notification.TYPE_WARNING_MESSAGE); return; } GraphQuery query = conn.prepareGraphQuery(QueryLanguage.SPARQL, DSDRepoUtils.qCreateDSD(dataset, dsd, dList, mList, aList, propList, rangeList, dataGraph)); query.evaluate(); getWindow().showNotification("DSD created!"); DSDRepoComponent.this.ds = new SparqlDataSet(repository, DSDRepoComponent.this.ds.getUri(), dataGraph); createDSD(); } catch (RepositoryException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } catch (MalformedQueryException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } catch (QueryEvaluationException ex) { Logger.getLogger(DSDRepoComponent.class.getName()).log(Level.SEVERE, null, ex); } } }); }
From source file:rs.pupin.jpo.esta_ld.EstaLdComponent.java
private void createGUI() { mainLayout = new VerticalLayout(); mainLayout.setSizeFull();//from ww w . ja va 2 s. co m mainLayout.setSpacing(false); mainLayout.setDebugId("l-main"); if (indAnimatorEnabled) { animator = new AnimatorProxy(); mainLayout.addComponent(animator); indSettingsVisible = true; } brandLayout = new HorizontalLayout(); brandLayout.setSpacing(true); brandLayout.setMargin(true); brandLayout.setWidth("100%"); brandLayout.setDebugId("l-brand"); Label brandSpan = new Label("<span id='brand'>ESTA-LD</span>", Label.CONTENT_XHTML); brandLayout.addComponent(brandSpan); brandLayout.setExpandRatio(brandSpan, 2.0f); brandLayout.setComponentAlignment(brandSpan, Alignment.MIDDLE_LEFT); Button btnEndpoint = new Button("Endpoint"); brandLayout.addComponent(btnEndpoint); brandLayout.setComponentAlignment(btnEndpoint, Alignment.MIDDLE_RIGHT); btnEndpoint.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { final EndpointWindow.EndpointState state = new EndpointWindow.EndpointState(); state.endpoint = endpoint; Window w = new EndpointWindow(state); w.addListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { try { if (!endpoint.equals(state.endpoint)) repository.shutDown(); } catch (RepositoryException ex) { Logger.getLogger(EstaLdComponent.class.getName()).log(Level.SEVERE, null, ex); } if (state.repository != null && state.repository.isInitialized()) { repository = state.repository; endpoint = state.endpoint; endpointChanged(); } } }); getWindow().addWindow(w); } }); btnInspect = new Button("Inspect"); if (indShowInspect) { brandLayout.addComponent(btnInspect); brandLayout.setExpandRatio(btnInspect, 0.0f); } Button btnSettings = new Button("Parameters"); brandLayout.addComponent(btnSettings); brandLayout.setComponentAlignment(btnSettings, Alignment.MIDDLE_RIGHT); btnSettings.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { // getWindow().executeJavaScript("$('#l-dataset').parent().parent().slideToggle(function(){ vaadin.forceLayout(); })"); if (!indAnimatorEnabled) { getWindow().executeJavaScript("$('#l-settings').parent().parent().slideToggle()"); settingsLayout.setVisible(!settingsLayout.isVisible()); } else { // if (indSettingsVisible) { // animator.animate(settingsLayout, VAnimatorProxy.AnimType.ROLL_UP_CLOSE); // } else { // animator.animate(settingsLayout, VAnimatorProxy.AnimType.ROLL_DOWN_OPEN_POP); // } // indSettingsVisible = !indSettingsVisible; } // getWindow().executeJavaScript("setTimeout(function(){ vaadin.forceSync(); map.invalidateSize(); }, 0)"); // getWindow().executeJavaScript("setTimeout(function(){ runSparqlDimensionValueChangedVuk(); map.invalidateSize() }, 200)"); // getWindow().executeJavaScript("setTimeout(function(){ currentChart.reflow(); map.invalidateSize() }, 200)"); } }); settingsLayout = new VerticalLayout(); settingsLayout.setDebugId("l-settings"); settingsLayout.setSpacing(true); settingsLayout.setMargin(true); settingsLayout.setWidth("100%"); datasetLayout = new HorizontalLayout(); datasetLayout.setSpacing(true); datasetLayout.setWidth("100%"); datasetLayout.setDebugId("l-dataset"); mainLayout.addComponent(brandLayout); mainLayout.setExpandRatio(brandLayout, 0.0f); settingsLayout.addComponent(datasetLayout); Label lblSettingsSeparator = new Label("<hr/>", Label.CONTENT_XHTML); lblSettingsSeparator.addStyleName("settings-separator"); settingsLayout.addComponent(lblSettingsSeparator); mainLayout.addComponent(settingsLayout); mainLayout.setExpandRatio(settingsLayout, 0.0f); // in place of this divide borders and shadows will be added // Label lblDivider = new Label("<hr/>", Label.CONTENT_XHTML); // mainLayout.addComponent(lblDivider); // mainLayout.setExpandRatio(lblDivider, 0.0f); // contentLayout = new HorizontalLayout(); contentLayout = new HorizontalSplitPanel(); contentLayout.setMargin(true); contentLayout.setSizeFull(); contentLayout.setWidth("100%"); // contentLayout.setSpacing(true); contentLayout.setSplitPosition(50, UNITS_PERCENTAGE); contentLayout.setDebugId("l-content"); mainLayout.addComponent(contentLayout); mainLayout.setExpandRatio(contentLayout, 2.0f); createDataSetLayout(); }
From source file:rs.pupin.jpo.esta_ld.EstaLdComponent.java
private void refreshDimensions() { // clean everything just in case dimLayout.removeAllComponents();//from w w w. j av a2 s .co m geoDimension = null; timeDimension = null; measures = null; btnGeo = null; boxGeo = null; dimNames = null; dimValues = null; if (selectDataSet.getValue() == null) return; // VerticalLayout lLayout = new VerticalLayout(); // lLayout.setSizeUndefined(); // lLayout.setSpacing(true); // lLayout.setDebugId("dim-btn-layout"); // dimLayout.addComponent(lLayout); // VerticalLayout rLayout = new VerticalLayout(); // rLayout.setSizeUndefined(); // rLayout.setSpacing(true); // rLayout.setWidth("100%"); // dimLayout.addComponent(rLayout); // dimLayout.setExpandRatio(rLayout, 2.0f); final DataSet ds = (DataSet) selectDataSet.getValue(); measures = ds.getStructure().getMeasures(); StringBuilder builderMeasures = new StringBuilder(); StringBuilder builderMeasureNames = new StringBuilder(); for (Measure m : measures) { builderMeasures.append(", '"); builderMeasures.append(m.getUri()); builderMeasures.append("'"); if (m.getLabel() != null) { builderMeasureNames.append(", '"); builderMeasureNames.append(m.getLabel()); builderMeasureNames.append("'"); } else { builderMeasureNames.append(", undefined"); } } builderMeasureNames.replace(0, 2, "[").append("]"); builderMeasures.replace(0, 2, "javaSetMeasures(["); builderMeasures.append("], ").append(builderMeasureNames.toString()).append(")"); getWindow().executeJavaScript(builderMeasures.toString()); measName = new Button("Measure"); // measName.setSizeUndefined(); // measName.setWidth("100%"); measName.setHeight(CONTENT_ELEM_HEIGHT); measName.setWidth(CONTENT_ELEM_WIDTH); measName.addStyleName("dim-name"); measName.addStyleName("unselectable"); measValues = new ComboBox(null, measures); measValues.setImmediate(true); measValues.setSizeUndefined(); measValues.setWidth("100%"); measValues.setHeight(CONTENT_ELEM_HEIGHT); measValues.addStyleName("dim-value"); measValues.setNullSelectionAllowed(false); measValues.select(measures.iterator().next()); measValues.addListener(dimListener); // measValues.addListener(new Property.ValueChangeListener() { // public void valueChange(Property.ValueChangeEvent event) { // Measure m = (Measure)event.getProperty().getValue(); // // put measure in // } // }); int rowIndex = 0; int columnIndex = 0; dimLayout.addComponent(measName, columnIndex, rowIndex); columnIndex++; // dimLayout.setExpandRatio(measName, 2.0f); dimLayout.addComponent(measValues, columnIndex, rowIndex, columnIndex + 1, rowIndex); columnIndex += 2; // dimLayout.setComponentAlignment(measValues, Alignment.BOTTOM_LEFT); LinkedList<Dimension> dimsForShow = new LinkedList<Dimension>(); for (Dimension dim : ds.getStructure().getDimensions()) { if (dim.isGeoDimension()) geoDimension = dim; else if (dim.isTimeDimension()) { timeDimension = dim; dimsForShow.addFirst(dim); } else dimsForShow.add(dim); } dimNames = new Button[dimsForShow.size()]; dimAggregIndicators = new Label[dimsForShow.size()]; dimValues = new ComboBox[dimsForShow.size()]; int i = 0; StringBuilder builderPossibleValues = new StringBuilder(); boolean firstPass = true; for (Dimension dim : dimsForShow) { // add dimension pick // first create a button to represent dimension name final Button btnName = new Button(dim.toString()); // btnName.setSizeUndefined(); // btnName.setWidth("100%"); btnName.setHeight(CONTENT_ELEM_HEIGHT); btnName.setWidth(CONTENT_ELEM_WIDTH); btnName.setData(dim); btnName.addStyleName("dim-name"); if (firstPass) { btnName.addStyleName("selected"); firstPass = false; } btnName.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (btnName.getStyleName().contains("selected")) { btnName.removeStyleName("selected"); } else { btnName.addStyleName("selected"); } freeDimensionsChanged(); } }); dimNames[i] = btnName; final Label btnAggreg = new Label("<span>Σ</span>", Label.CONTENT_XHTML); btnAggreg.setWidth("30px"); btnAggreg.setHeight(CONTENT_ELEM_HEIGHT); btnAggreg.setData(dim); btnAggreg.addStyleName("dim-name"); btnAggreg.addStyleName("dim-aggreg"); // this will have to go to the layout listener // btnAggreg.addListener(new Button.ClickListener() { // public void buttonClick(Button.ClickEvent event) { // if (btnAggreg.getStyleName().contains("selected")) { // btnAggreg.removeStyleName("selected"); // } else { // btnAggreg.addStyleName("selected"); // aggregDimensionsChanged(); // } // } // }); dimAggregIndicators[i] = btnAggreg; // create a combo box for picking dimension value Collection<Value> vals = ds.getValuesForDimension(dim); Collection<ValueWrapper> valsWrapped = new LinkedList<ValueWrapper>(); for (Value v : vals) valsWrapped.add(new ValueWrapper(v)); builderPossibleValues.append(",").append(stringifyCollection(vals)); ComboBox boxValue = new ComboBox(null, valsWrapped); boxValue.setImmediate(true); boxValue.setNullSelectionAllowed(false); if (valsWrapped.iterator().hasNext()) boxValue.select(valsWrapped.iterator().next()); else boxValue.setEnabled(false); boxValue.setSizeUndefined(); boxValue.setWidth("100%"); boxValue.setHeight(CONTENT_ELEM_HEIGHT); boxValue.addStyleName("dim-value"); boxValue.addListener(dimListener); dimValues[i] = boxValue; // put them in a horizontal layout and add to the view // HorizontalLayout layout = new HorizontalLayout(); // layout.setSizeUndefined(); // layout.setWidth("100%"); // layout.setSpacing(true); // dimLayout.addComponent(layout); // dimLayout.setExpandRatio(layout, 2.0f); // layout.addComponent(btnName); // layout.addComponent(boxValue); // layout.setExpandRatio(boxValue, 2.0f); // lLayout.addComponent(btnName); // lLayout.setExpandRatio(btnName, 2.0f); // rLayout.addComponent(boxValue); // rLayout.setComponentAlignment(boxValue, Alignment.BOTTOM_LEFT); dimLayout.addComponent(btnName, columnIndex, rowIndex); if (++columnIndex == 6) { columnIndex = 0; rowIndex++; dimLayout.setRows(rowIndex + 1); } dimLayout.addComponent(btnAggreg, columnIndex, rowIndex); if (++columnIndex == 6) { columnIndex = 0; rowIndex++; dimLayout.setRows(rowIndex + 1); } dimLayout.addComponent(boxValue, columnIndex, rowIndex); if (++columnIndex == 6) { columnIndex = 0; rowIndex++; dimLayout.setRows(rowIndex + 1); } i++; } if (timeDimension != null) getWindow().executeJavaScript("javaSetHasTimeDimension(true)"); else getWindow().executeJavaScript("javaSetHasTimeDimension(false)"); if (geoDimension != null) { btnGeo = new Button(geoDimension.toString()); // btnGeo.setSizeUndefined(); // btnGeo.setWidth("100%"); btnGeo.setHeight(CONTENT_ELEM_HEIGHT); btnGeo.setWidth(CONTENT_ELEM_WIDTH); btnGeo.setData(geoDimension); btnGeo.addStyleName("dim-name"); btnGeo.addStyleName("geo-name"); btnGeo.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (btnGeo.getStyleName().contains("selected")) { btnGeo.removeStyleName("selected"); } else { btnGeo.addStyleName("selected"); } freeDimensionsChanged(); } }); btnAggregGeo = new Label("<span>Σ</span>", Label.CONTENT_XHTML); btnAggregGeo.setHeight(CONTENT_ELEM_HEIGHT); btnAggregGeo.setData(geoDimension); btnAggregGeo.addStyleName("dim-name"); btnAggregGeo.addStyleName("dim-aggreg"); StringBuilder builder = new StringBuilder(); Collection<Value> posVals = ds.getValuesForDimension(geoDimension); Collection<ValueWrapper> posValsWrapped = new LinkedList<ValueWrapper>(); for (Value v : posVals) posValsWrapped.add(new ValueWrapper(v)); Value selectedVal = posVals.iterator().next(); String selectedValString = ""; if (selectedVal instanceof URI) { selectedValString = "<" + selectedVal.stringValue() + ">"; } else { selectedValString = "\"" + selectedVal.stringValue() + "\""; URI dataType = ((Literal) selectedVal).getDatatype(); if (dataType != null && !dataType.stringValue().contains("string")) { selectedValString += "^^<" + dataType.stringValue() + ">"; } } builder.append("javaSetGeoAll('").append(geoDimension.getUri()); builder.append("',").append(stringifyCollection(posVals)); builder.append(",'").append(selectedValString).append("',true)"); boxGeo = new ComboBox(null, posValsWrapped); boxGeo.setData(posVals); boxGeo.setImmediate(true); boxGeo.setNullSelectionAllowed(false); boxGeo.select(posValsWrapped.iterator().next()); boxGeo.setSizeUndefined(); boxGeo.setWidth("100%"); boxGeo.setHeight(CONTENT_ELEM_HEIGHT); boxGeo.addStyleName("geo-value"); boxGeo.addListener(geoListener); // lLayout.addComponent(btnGeo); // lLayout.setExpandRatio(btnGeo, 2.0f); // rLayout.addComponent(boxGeo); // rLayout.setComponentAlignment(boxGeo, Alignment.BOTTOM_LEFT); dimLayout.addComponent(btnGeo, columnIndex, rowIndex); columnIndex++; dimLayout.addComponent(btnAggregGeo, columnIndex, rowIndex); columnIndex++; dimLayout.addComponent(boxGeo, columnIndex, rowIndex); columnIndex++; getWindow().executeJavaScript(builder.toString()); } else { getWindow().executeJavaScript("javaSetGeoAll('',[],'',true)"); } // TODO cover the case where there is more than 1 geo dimension builderPossibleValues.replace(0, 1, "javaSetPossibleValues(["); builderPossibleValues.append("])"); getWindow().executeJavaScript(builderPossibleValues.toString()); if (dimsForShow.isEmpty()) { if (geoDimension != null) getWindow().executeJavaScript("javaSetGeoFree(true)"); else getWindow().executeJavaScript("javaSetGeoFree(false)"); getWindow().executeJavaScript("javaSetFreeDimensions([], true)"); } else { getWindow().executeJavaScript("javaSetGeoFree(false)"); getWindow().executeJavaScript("javaSetFreeDimensions([0], true)"); } dimListener.valueChange(null); getWindow().executeJavaScript("setTimeout(expandDimNameButtons(),200)"); }
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 om*/ 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.esta_ld.InspectComponent.java
private void showManageGeoView(Dimension dim) { dimTransformLayout.removeAllComponents(); dimTransformLayout.addComponent(new Label("<h1>Manage Spatial 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 {/*from w w w. ja v a2s.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)); final SpatialDimensionManipulator manipulator = new SpatialDimensionManipulator(dim, SpatialDimensionManipulator.Kind.BY_CODE); final ComboBox comboKind = new ComboBox("Choose kind:", Arrays.asList(SpatialDimensionManipulator.Kind.values())); comboKind.setNullSelectionAllowed(false); comboKind.select(SpatialDimensionManipulator.Kind.BY_CODE); dimTransformLayout.addComponent(comboKind); // text field: { pattern } final TextField fieldPrefix = new TextField("Prefix:"); fieldPrefix.setWidth("400px"); dimTransformLayout.addComponent(fieldPrefix); // button: insert polygons final Button btnInsertPolygons = new Button("Insert Polygons"); dimTransformLayout.addComponent(btnInsertPolygons); btnInsertPolygons.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { String prefix = fieldPrefix.getValue().toString(); if (prefix == null) { return; } String array = manipulator.extractPairs(prefix); String jsCall = "javaInsertPolygons(" + array + ")"; getWindow().executeJavaScript(jsCall); } }); }
From source file:rs.pupin.jpo.esta_ld.InspectComponent.java
private void refreshContentCreateDSD(DataSet ds) { if (ds == null) { getWindow().showNotification("No dataset selected", Window.Notification.TYPE_ERROR_MESSAGE); return;/* w w w .java2 s .c o m*/ } Structure struct = ds.getStructure(); if (struct != null) { contentLayout.addComponent(new Label("The dataset already has a DSD!")); return; } dataset = ds.getUri(); contentLayout.removeAllComponents(); dataTree = new Tree("Dataset"); dataTree.setNullSelectionAllowed(true); dataTree.setImmediate(true); dataTree.setWidth("500px"); populateDataTree(); addDataTreeListenersCreate(); contentLayout.addComponent(dataTree); contentLayout.setExpandRatio(dataTree, 0.0f); final VerticalLayout right = new VerticalLayout(); right.setSpacing(true); contentLayout.addComponent(right); contentLayout.setExpandRatio(right, 2.0f); lblUndefined = new Label("There are still x undefined components", Label.CONTENT_XHTML); right.addComponent(lblUndefined); lblMissingCodeLists = new Label("There are still y missing code lists", Label.CONTENT_XHTML); right.addComponent(lblMissingCodeLists); final TextField dsdUri = new TextField("Enter DSD URI"); dsdUri.setWidth("300px"); right.addComponent(dsdUri); final Button btnCreate = new Button("Create DSD"); right.addComponent(btnCreate); right.addComponent(new Label("<hr/>", Label.CONTENT_XHTML)); compatibleCodeLists = new Tree("Compatible code lists"); right.addComponent(compatibleCodeLists); updateUndefinedAndMissing(); compatibleCodeLists.addActionHandler(new Action.Handler() { public Action[] getActions(Object target, Object sender) { if (target == null) return null; if (compatibleCodeLists.getParent(target) != null) return null; return new Action[] { ACTION_SET_AS_CL }; } public void handleAction(Action action, Object sender, Object target) { if (action == ACTION_SET_AS_CL) { getWindow().showNotification("Action not available"); } } }); btnCreate.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (numUndefinedComponents > 0) { getWindow().showNotification("There can be no undefined components", Window.Notification.TYPE_ERROR_MESSAGE); return; } if (numMissingCodeLists > 0) { getWindow().showNotification("All code lists must first be created or imported", Window.Notification.TYPE_ERROR_MESSAGE); return; } final String dsd = dsdUri.getValue().toString(); if (!isUri(dsd)) { getWindow().showNotification("Enter a valid URI for the DSD", Window.Notification.TYPE_ERROR_MESSAGE); } try { RepositoryConnection conn = repository.getConnection(); LinkedList<String> dList = new LinkedList<String>(); LinkedList<String> mList = new LinkedList<String>(); LinkedList<String> aList = new LinkedList<String>(); LinkedList<String> uList = new LinkedList<String>(); LinkedList<String> propList = new LinkedList<String>(); LinkedList<String> rangeList = new LinkedList<String>(); for (Object id : dataTree.rootItemIds()) { Collection<?> children = dataTree.getChildren(id); if (children == null) continue; Collection<String> list = null; if (id.toString().startsWith("D")) list = dList; else if (id.toString().startsWith("M")) list = mList; else if (id.toString().startsWith("A")) list = aList; else if (id.toString().startsWith("U")) list = uList; for (Object prop : dataTree.getChildren(id)) { CountingTreeHeader h = (CountingTreeHeader) dataTree.getChildren(prop).iterator() .next(); propList.add(prop.toString()); list.add(prop.toString()); if (h.toString().startsWith("C")) { rangeList.add("http://www.w3.org/2004/02/skos/core#Concept"); } else { rangeList.add(dataTree.getChildren(h).iterator().next().toString()); } } } if (uList.size() > 0) { getWindow().showNotification("There are undefined properties!", Window.Notification.TYPE_WARNING_MESSAGE); return; } GraphQuery query = conn.prepareGraphQuery(QueryLanguage.SPARQL, DSDRepoUtils.qCreateDSD(dataset, dsd, dList, mList, aList, propList, rangeList, dataGraph)); query.evaluate(); getWindow().showNotification("DSD created!"); InspectComponent.this.ds = new SparqlDataSet(repository, InspectComponent.this.ds.getUri(), dataGraph); createDSD(); } 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); } } }); }
From source file:rs.pupin.jpo.esta_ld.InspectWrapperComponent.java
private void createGUI() { mainLayout = new VerticalLayout(); mainLayout.setSpacing(false);// w ww . j a v a 2 s .co m mainLayout.setDebugId("l-main"); brandLayout = new HorizontalLayout(); brandLayout.setSpacing(true); brandLayout.setMargin(true); brandLayout.setWidth("100%"); brandLayout.setDebugId("l-brand"); Label brandSpan = new Label("<span id='brand'>ESTA-LD: <i>Inspect and Prepare</i></span>", Label.CONTENT_XHTML); brandLayout.addComponent(brandSpan); brandLayout.setExpandRatio(brandSpan, 2.0f); brandLayout.setComponentAlignment(brandSpan, Alignment.MIDDLE_LEFT); Button btnEndpoint = new Button("Endpoint"); brandLayout.addComponent(btnEndpoint); brandLayout.setComponentAlignment(btnEndpoint, Alignment.MIDDLE_RIGHT); btnEndpoint.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { final EndpointWindow.EndpointState state = new EndpointWindow.EndpointState(); state.endpoint = endpoint; Window w = new EndpointWindow(state); w.addListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { try { if (!endpoint.equals(state.endpoint)) repository.shutDown(); } catch (RepositoryException ex) { Logger.getLogger(EstaLdComponent.class.getName()).log(Level.SEVERE, null, ex); } if (state.repository != null && state.repository.isInitialized()) { repository = state.repository; endpoint = state.endpoint; endpointChanged(); } } }); getWindow().addWindow(w); } }); settingsLayout = new VerticalLayout(); settingsLayout.setDebugId("l-settings"); settingsLayout.setSpacing(true); settingsLayout.setMargin(true); settingsLayout.setWidth("100%"); datasetLayout = new HorizontalLayout(); datasetLayout.setSpacing(true); datasetLayout.setWidth("100%"); datasetLayout.setDebugId("l-dataset"); mainLayout.addComponent(brandLayout); // mainLayout.setExpandRatio(brandLayout, 0.0f); settingsLayout.addComponent(datasetLayout); mainLayout.addComponent(settingsLayout); // mainLayout.setExpandRatio(settingsLayout, 0.0f); // in place of this divide borders and shadows will be added // Label lblDivider = new Label("<hr/>", Label.CONTENT_XHTML); // mainLayout.addComponent(lblDivider); // mainLayout.setExpandRatio(lblDivider, 0.0f); // contentLayout = new HorizontalLayout(); contentLayout = new VerticalLayout(); contentLayout.setMargin(true); // contentLayout.setSizeFull(); contentLayout.setWidth("100%"); // contentLayout.setSpacing(true); contentLayout.addStyleName("l-content-inspect"); mainLayout.addComponent(contentLayout); // mainLayout.setExpandRatio(contentLayout, 2.0f); createDataSetLayout(); }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createEmailDatesPanel() { VerticalLayout emailDates = new VerticalLayout(); emailDates.setSpacing(true);//from ww w . ja v a 2 s .com emailDates.setMargin(true); emailDates.setSizeFull(); Panel panel2 = new Panel(" ? ??", emailDates); panel2.setSizeFull(); final TextField emailToField = new TextField("e-mail ?:"); emailToField.setValue(get(API.EMAIL_TO)); emailToField.setRequired(true); emailToField.setReadOnly(true); emailToField.addValidator(new EmailValidator(" e-mail ?")); final TextField receiverNameField = new TextField("? ?:"); receiverNameField.setValue(get(API.RECEIVER_NAME)); receiverNameField.setRequired(true); receiverNameField.setReadOnly(true); final TextField emailFromField = new TextField("e-mail ?:"); emailFromField.setValue(get(API.EMAIL_FROM)); emailFromField.setRequired(true); emailFromField.setReadOnly(true); emailFromField.addValidator(new EmailValidator(" e-mail ?")); final TextField senderLoginField = new TextField(" ?:"); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderLoginField.setRequired(true); senderLoginField.setReadOnly(true); final TextField senderNameField = new TextField("? ?:"); senderNameField.setValue(get(API.SENDER_NAME)); senderNameField.setRequired(true); senderNameField.setReadOnly(true); final PasswordField passwordField = new PasswordField(":"); passwordField.setValue(API.PASSWORD); passwordField.setRequired(true); passwordField.setReadOnly(true); final TextField hostField = new TextField("SMTP ?:"); String host = get(API.HOST); hostField.setValue(host == null ? "" : host); hostField.setRequired(true); hostField.setReadOnly(true); final TextField portField = new TextField(":"); String port = get(API.PORT); portField.setValue(port == null ? "" : port); portField.setRequired(true); portField.setReadOnly(true); portField.addValidator(new IntegerValidator(" ")); final CheckBox tls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.TLS)); tls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); final Button check = new Button(""); check.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { String emailTo = get(API.EMAIL_TO); String receiverName = get(API.RECEIVER_NAME); String hostName = get(API.HOST); String port = get(API.PORT); String senderLogin = get(API.SENDER_LOGIN); String password = get(API.PASSWORD); String emailFrom = get(API.EMAIL_FROM); String senderName = get(API.SENDER_NAME); if (emailTo.isEmpty() || receiverName.isEmpty() || hostName.isEmpty() || port.isEmpty() || senderLogin.isEmpty() || password.isEmpty() || emailFrom.isEmpty() || senderName.isEmpty()) { check.getWindow().showNotification("? ? "); return; } Email email = new SimpleEmail(); try { email.setSubject("? ?"); email.setMsg("? ?"); email.addTo(emailTo, receiverName); email.setHostName(hostName); email.setSmtpPort(Integer.parseInt(port)); email.setTLS(AdminServiceProvider.getBoolProperty(API.TLS)); email.setAuthentication(senderLogin, password); email.setFrom(emailFrom, senderName); email.setCharset("utf-8"); email.send(); } catch (EmailException e) { check.getWindow().showNotification(e.getMessage()); e.printStackTrace(); return; } check.getWindow().showNotification("? ? "); } }); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setReadOnly(false); receiverNameField.setReadOnly(false); emailFromField.setReadOnly(false); senderLoginField.setReadOnly(false); senderNameField.setReadOnly(false); passwordField.setReadOnly(false); hostField.setReadOnly(false); portField.setReadOnly(false); tls.setReadOnly(false); change.setVisible(false); check.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) emailToField.getValue()) || StringUtils.isEmpty((String) receiverNameField.getValue()) || StringUtils.isEmpty((String) emailFromField.getValue()) || StringUtils.isEmpty((String) senderNameField.getValue()) || StringUtils.isEmpty((String) senderLoginField.getValue()) || StringUtils.isEmpty((String) passwordField.getValue()) || StringUtils.isEmpty((String) hostField.getValue()) || portField.getValue() == null) { emailToField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { emailToField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { emailFromField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { portField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.EMAIL_TO, emailToField.getValue()); set(API.RECEIVER_NAME, receiverNameField.getValue()); set(API.EMAIL_FROM, emailFromField.getValue()); set(API.SENDER_LOGIN, senderLoginField.getValue()); set(API.SENDER_NAME, senderNameField.getValue()); set(API.PASSWORD, passwordField.getValue()); set(API.HOST, hostField.getValue()); set(API.PORT, portField.getValue()); set(API.TLS, tls.getValue()); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); emailToField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { emailToField.setValue(get(API.EMAIL_TO)); receiverNameField.setValue(get(API.RECEIVER_NAME)); emailFromField.setValue(get(API.EMAIL_FROM)); senderLoginField.setValue(get(API.SENDER_LOGIN)); senderNameField.setValue(get(API.SENDER_NAME)); passwordField.setValue(get(API.PASSWORD)); hostField.setValue(get(API.HOST)); portField.setValue(get(API.PORT)); tls.setValue(AdminServiceProvider.getBoolProperty(API.TLS)); emailToField.setReadOnly(true); receiverNameField.setReadOnly(true); emailFromField.setReadOnly(true); senderLoginField.setReadOnly(true); senderNameField.setReadOnly(true); passwordField.setReadOnly(true); hostField.setReadOnly(true); portField.setReadOnly(true); tls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); check.setVisible(true); } }); FormLayout fields1 = new FormLayout(); fields1.setSizeFull(); fields1.addComponent(senderLoginField); fields1.addComponent(passwordField); fields1.addComponent(hostField); fields1.addComponent(portField); fields1.addComponent(tls); FormLayout fields2 = new FormLayout(); fields2.setSizeFull(); fields2.addComponent(emailToField); fields2.addComponent(receiverNameField); fields2.addComponent(emailFromField); fields2.addComponent(senderNameField); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setSizeFull(); fields.addComponent(fields1); fields.addComponent(fields2); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); buttons.addComponent(check); Label label = new Label("?? "); label.addStyleName(Reindeer.LABEL_H2); emailDates.addComponent(label); emailDates.addComponent(fields); emailDates.addComponent(buttons); emailDates.setExpandRatio(fields, 1f); return panel2; }
From source file:ru.codeinside.adm.ui.AdminApp.java
License:Mozilla Public License
private Panel createMilTaskConfigPanel() { VerticalLayout mailConfig = new VerticalLayout(); mailConfig.setSpacing(true);/*w ww .j a v a 2 s.c o m*/ mailConfig.setMargin(true); mailConfig.setSizeFull(); Panel emailTaskPanel = new Panel("?? SMTP ? Email Task", mailConfig); emailTaskPanel.setSizeFull(); final TextField mtDefaultFrom = new TextField("email :"); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtDefaultFrom.setRequired(true); mtDefaultFrom.setReadOnly(true); mtDefaultFrom.addValidator(new EmailValidator(" e-mail ?")); final TextField mtSenderLoginField = new TextField(" ?:"); mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtSenderLoginField.setRequired(true); mtSenderLoginField.setReadOnly(true); final PasswordField mtPasswordField = new PasswordField(":"); mtPasswordField.setValue(API.MT_PASSWORD); mtPasswordField.setRequired(true); mtPasswordField.setReadOnly(true); final TextField mtHostField = new TextField("SMTP ?:"); String host = get(API.MT_HOST); mtHostField.setValue(host == null ? "" : host); mtHostField.setRequired(true); mtHostField.setReadOnly(true); final TextField mtPortField = new TextField(":"); String port = get(API.MT_PORT); mtPortField.setValue(port == null ? "" : port); mtPortField.setRequired(true); mtPortField.setReadOnly(true); mtPortField.addValidator(new IntegerValidator(" ")); final CheckBox mtTls = new CheckBox("? TLS", AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtTls.setReadOnly(true); final Button save = new Button(""); save.setVisible(false); final Button cancel = new Button(""); cancel.setVisible(false); final Button change = new Button(""); change.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setReadOnly(false); mtDefaultFrom.setReadOnly(false); mtPasswordField.setReadOnly(false); mtHostField.setReadOnly(false); mtPortField.setReadOnly(false); mtTls.setReadOnly(false); change.setVisible(false); save.setVisible(true); cancel.setVisible(true); } }); save.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (StringUtils.isEmpty((String) mtSenderLoginField.getValue()) || StringUtils.isEmpty((String) mtDefaultFrom.getValue()) || StringUtils.isEmpty((String) mtPasswordField.getValue()) || StringUtils.isEmpty((String) mtHostField.getValue()) || mtPortField.getValue() == null) { mtSenderLoginField.getWindow().showNotification(" ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); return; } boolean errors = false; try { mtDefaultFrom.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } try { mtPortField.validate(); } catch (Validator.InvalidValueException ignore) { errors = true; } if (errors) { return; } set(API.MT_SENDER_LOGIN, mtSenderLoginField.getValue()); set(API.MT_DEFAULT_FROM, mtDefaultFrom.getValue()); set(API.MT_PASSWORD, mtPasswordField.getValue()); set(API.MT_HOST, mtHostField.getValue()); set(API.MT_PORT, mtPortField.getValue()); set(API.MT_TLS, mtTls.getValue()); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); mtSenderLoginField.getWindow().showNotification("?? ?", Window.Notification.TYPE_HUMANIZED_MESSAGE); } }); cancel.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { mtSenderLoginField.setValue(get(API.MT_SENDER_LOGIN)); mtDefaultFrom.setValue(get(API.MT_DEFAULT_FROM)); mtPasswordField.setValue(get(API.MT_PASSWORD)); mtHostField.setValue(get(API.MT_HOST)); mtPortField.setValue(get(API.MT_PORT)); mtTls.setValue(AdminServiceProvider.getBoolProperty(API.MT_TLS)); mtSenderLoginField.setReadOnly(true); mtDefaultFrom.setReadOnly(true); mtPasswordField.setReadOnly(true); mtHostField.setReadOnly(true); mtPortField.setReadOnly(true); mtTls.setReadOnly(true); save.setVisible(false); cancel.setVisible(false); change.setVisible(true); } }); FormLayout leftFields = new FormLayout(); leftFields.setSizeFull(); leftFields.addComponent(mtSenderLoginField); leftFields.addComponent(mtDefaultFrom); leftFields.addComponent(mtPasswordField); leftFields.addComponent(mtHostField); leftFields.addComponent(mtPortField); FormLayout rightFields = new FormLayout(); rightFields.setSizeFull(); rightFields.addComponent(mtTls); HorizontalLayout fieldsLayout = new HorizontalLayout(); fieldsLayout.setSpacing(true); fieldsLayout.setSizeFull(); fieldsLayout.addComponent(leftFields); fieldsLayout.addComponent(rightFields); fieldsLayout.setExpandRatio(leftFields, 0.6f); fieldsLayout.setExpandRatio(rightFields, 0.4f); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); buttons.addComponent(change); buttons.addComponent(save); buttons.addComponent(cancel); Label label = new Label("?? Email Task"); label.addStyleName(Reindeer.LABEL_H2); mailConfig.addComponent(label); mailConfig.addComponent(fieldsLayout); mailConfig.addComponent(buttons); mailConfig.setExpandRatio(fieldsLayout, 1f); return emailTaskPanel; }
From source file:ru.codeinside.adm.ui.employee.CertificateBlock.java
License:Mozilla Public License
public CertificateBlock(UserItem userItem) { this.x509 = userItem.getX509(); Component root = new HorizontalLayout(); if (x509 != null) { X509Certificate x509Certificate = X509.decode(x509); if (x509Certificate != null) { HorizontalLayout h = new HorizontalLayout(); h.setSpacing(true);/*from w ww .ja va2s . com*/ h.setMargin(true); h.setSizeUndefined(); NameParts subjectParts = X509.getSubjectParts(x509Certificate); Label certLabel = new Label(subjectParts.getShortName()); h.addComponent(certLabel); h.setComponentAlignment(certLabel, Alignment.MIDDLE_CENTER); Button remove = new Button("? ? ?"); remove.setStyleName(Reindeer.BUTTON_SMALL); h.addComponent(remove); h.setComponentAlignment(remove, Alignment.MIDDLE_CENTER); remove.addListener((Button.ClickListener) new CertificateCleaner(remove, certLabel)); Panel panel = new Panel(); panel.setCaption("? ?:"); panel.setContent(h); panel.setSizeUndefined(); root = panel; } else { certificateWasRemoved = true; } } setCompositionRoot(root); setSizeUndefined(); }