List of usage examples for com.vaadin.ui VerticalLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:annis.gui.admin.CorpusAdminPanel.java
License:Apache License
public CorpusAdminPanel() { corpusContainer.setBeanIdProperty("name"); final Grid corporaGrid = new Grid(corpusContainer); corporaGrid.setSizeFull();//from w ww.ja va 2 s.c om corporaGrid.setSelectionMode(Grid.SelectionMode.MULTI); corporaGrid.setColumns("name", "textCount", "tokenCount", "sourcePath"); corporaGrid.getColumn("textCount").setHeaderCaption("Texts"); corporaGrid.getColumn("tokenCount").setHeaderCaption("Tokens"); corporaGrid.getColumn("sourcePath").setHeaderCaption("Source Path"); Button btDelete = new Button("Delete selected"); btDelete.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Set<String> selection = new TreeSet<>(); for (Object o : corporaGrid.getSelectedRows()) { selection.add((String) o); } corporaGrid.getSelectionModel().reset(); if (!selection.isEmpty()) { for (CorpusListView.Listener l : listeners) { l.deleteCorpora(selection); } } } }); VerticalLayout layout = new VerticalLayout(btDelete, corporaGrid); layout.setSizeFull(); layout.setExpandRatio(corporaGrid, 1.0f); layout.setSpacing(true); layout.setMargin(new MarginInfo(true, false, false, false)); layout.setComponentAlignment(btDelete, Alignment.MIDDLE_CENTER); setContent(layout); setSizeFull(); }
From source file:annis.gui.admin.GroupManagementPanel.java
License:Apache License
public GroupManagementPanel() { groupsContainer.setBeanIdProperty("name"); progress = new ProgressBar(); progress.setCaption("Loading group list"); progress.setIndeterminate(true);//w w w . j a v a 2s .c o m progress.setVisible(false); GeneratedPropertyContainer generated = new GeneratedPropertyContainer(groupsContainer); generated.addGeneratedProperty("edit", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "Edit"; } @Override public Class<String> getType() { return String.class; } }); groupsGrid.setContainerDataSource(generated); groupsGrid.setSelectionMode(Grid.SelectionMode.MULTI); groupsGrid.setSizeFull(); groupsGrid.setColumns("name", "edit", "corpora"); Grid.HeaderRow filterRow = groupsGrid.appendHeaderRow(); TextField groupFilterField = new TextField(); groupFilterField.setInputPrompt("Filter"); groupFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { groupsContainer.removeContainerFilters("name"); if (!event.getText().isEmpty()) { groupsContainer .addContainerFilter(new SimpleStringFilter("name", event.getText(), true, false)); } } }); filterRow.getCell("name").setComponent(groupFilterField); TextField corpusFilterField = new TextField(); corpusFilterField.setInputPrompt("Filter by corpus"); corpusFilterField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent event) { groupsContainer.removeContainerFilters("corpora"); if (!event.getText().isEmpty()) { groupsContainer.addContainerFilter(new StringPatternInSetFilter("corpora", event.getText())); } } }); filterRow.getCell("corpora").setComponent(corpusFilterField); Grid.Column editColumn = groupsGrid.getColumn("edit"); editColumn.setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { @Override public void click(ClickableRenderer.RendererClickEvent event) { Group g = groupsContainer.getItem(event.getItemId()).getBean(); FieldGroup fields = new FieldGroup(groupsContainer.getItem(event.getItemId())); fields.addCommitHandler(new GroupCommitHandler(g.getName())); EditSingleGroup edit = new EditSingleGroup(fields, corpusContainer); Window w = new Window("Edit group \"" + g.getName() + "\""); w.setContent(edit); w.setModal(true); w.setWidth("500px"); w.setHeight("250px"); UI.getCurrent().addWindow(w); } })); Grid.Column corporaColumn = groupsGrid.getColumn("corpora"); ; corporaColumn.setConverter(new CommaSeperatedStringConverterSet()); txtGroupName = new TextField(); txtGroupName.setInputPrompt("New group name"); Button btAddNewGroup = new Button("Add new group"); btAddNewGroup.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { handleAdd(); } }); btAddNewGroup.addStyleName(ChameleonTheme.BUTTON_DEFAULT); Button btDeleteGroup = new Button("Delete selected group(s)"); btDeleteGroup.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // get selected groups Set<String> selectedGroups = new TreeSet<>(); for (Object id : groupsGrid.getSelectedRows()) { selectedGroups.add((String) id); } groupsGrid.getSelectionModel().reset(); for (GroupListView.Listener l : listeners) { l.deleteGroups(selectedGroups); } } }); actionLayout = new HorizontalLayout(txtGroupName, btAddNewGroup, btDeleteGroup); VerticalLayout layout = new VerticalLayout(actionLayout, progress, groupsGrid); layout.setSizeFull(); layout.setExpandRatio(groupsGrid, 1.0f); layout.setExpandRatio(progress, 1.0f); layout.setSpacing(true); layout.setMargin(new MarginInfo(true, false, false, false)); layout.setComponentAlignment(actionLayout, Alignment.MIDDLE_CENTER); layout.setComponentAlignment(progress, Alignment.TOP_CENTER); setContent(layout); setSizeFull(); addActionHandler(new AddGroupHandler(txtGroupName)); }
From source file:annis.gui.EmbeddedVisUI.java
License:Apache License
private void generateVisFromRemoteURL(final String visName, final String rawUri, Map<String, String[]> args) { try {/* w w w . j a v a 2s. c o m*/ // find the matching visualizer final VisualizerPlugin visPlugin = this.getVisualizer(visName); if (visPlugin == null) { displayMessage("Unknown visualizer \"" + visName + "\"", "This ANNIS instance does not know the given visualizer."); return; } URI uri = new URI(rawUri); // fetch content of the URI Client client = null; AnnisUser user = Helper.getUser(); if (user != null) { client = user.getClient(); } if (client == null) { client = Helper.createRESTClient(); } final WebResource saltRes = client.resource(uri); displayLoadingIndicator(); // copy the arguments for using them later in the callback final Map<String, String[]> argsCopy = new LinkedHashMap<>(args); Background.runWithCallback(new Callable<SaltProject>() { @Override public SaltProject call() throws Exception { return saltRes.get(SaltProject.class); } }, new FutureCallback<SaltProject>() { @Override public void onFailure(Throwable t) { displayMessage("Could not query the result.", t.getMessage()); } @Override public void onSuccess(SaltProject p) { // TODO: allow to display several visualizers when there is more than one document SCorpusGraph firstCorpusGraph = null; SDocument doc = null; if (p.getCorpusGraphs() != null && !p.getCorpusGraphs().isEmpty()) { firstCorpusGraph = p.getCorpusGraphs().get(0); if (firstCorpusGraph.getDocuments() != null && !firstCorpusGraph.getDocuments().isEmpty()) { doc = firstCorpusGraph.getDocuments().get(0); } } if (doc == null) { displayMessage("No documents found in provided URL.", ""); return; } if (argsCopy.containsKey(KEY_INSTANCE)) { Map<String, InstanceConfig> allConfigs = loadInstanceConfig(); InstanceConfig newConfig = allConfigs.get(argsCopy.get(KEY_INSTANCE)[0]); if (newConfig != null) { setInstanceConfig(newConfig); } } // now it is time to load the actual defined instance fonts loadInstanceFonts(); // generate the visualizer VisualizerInput visInput = new VisualizerInput(); visInput.setDocument(doc); if (getInstanceConfig() != null && getInstanceConfig().getFont() != null) { visInput.setFont(getInstanceFont()); } Properties mappings = new Properties(); for (Map.Entry<String, String[]> e : argsCopy.entrySet()) { if (!KEY_SALT.equals(e.getKey()) && e.getValue().length > 0) { mappings.put(e.getKey(), e.getValue()[0]); } } visInput.setMappings(mappings); String[] namespace = argsCopy.get(KEY_NAMESPACE); if (namespace != null && namespace.length > 0) { visInput.setNamespace(namespace[0]); } else { visInput.setNamespace(null); } String baseText = null; if (argsCopy.containsKey(KEY_BASE_TEXT)) { String[] value = argsCopy.get(KEY_BASE_TEXT); if (value.length > 0) { baseText = value[0]; } } List<SNode> segNodes = CommonHelper.getSortedSegmentationNodes(baseText, doc.getDocumentGraph()); if (argsCopy.containsKey(KEY_MATCH)) { String[] rawMatch = argsCopy.get(KEY_MATCH); if (rawMatch.length > 0) { // enhance the graph with match information from the arguments Match match = Match.parseFromString(rawMatch[0]); addMatchToDocumentGraph(match, doc); } } Map<String, String> markedColorMap = new HashMap<>(); Map<String, String> exactMarkedMap = Helper.calculateColorsForMarkedExact(doc); Map<String, Long> markedAndCovered = Helper.calculateMarkedAndCoveredIDs(doc, segNodes, baseText); Helper.calulcateColorsForMarkedAndCovered(doc, markedAndCovered, markedColorMap); visInput.setMarkedAndCovered(markedAndCovered); visInput.setMarkableMap(markedColorMap); visInput.setMarkableExactMap(exactMarkedMap); visInput.setContextPath(Helper.getContext()); String template = Helper.getContext() + "/Resource/" + visName + "/%s"; visInput.setResourcePathTemplate(template); visInput.setSegmentationName(baseText); // TODO: which other thing do we have to provide? Component c = visPlugin.createComponent(visInput, null); // add the styles c.addStyleName("corpus-font"); c.addStyleName("vis-content"); Link link = new Link(); link.setCaption("Show in ANNIS search interface"); link.setIcon(ANNISFontIcon.LOGO); link.setVisible(false); link.addStyleName("dontprint"); link.setTargetName("_blank"); if (argsCopy.containsKey(KEY_SEARCH_INTERFACE)) { String[] interfaceLink = argsCopy.get(KEY_SEARCH_INTERFACE); if (interfaceLink.length > 0) { link.setResource(new ExternalResource(interfaceLink[0])); link.setVisible(true); } } VerticalLayout layout = new VerticalLayout(link, c); layout.setComponentAlignment(link, Alignment.TOP_LEFT); layout.setSpacing(true); layout.setMargin(true); setContent(layout); IDGenerator.assignID(link); } }); } catch (URISyntaxException ex) { displayMessage("Invalid URL", "The provided URL is malformed:<br />" + ex.getMessage()); } catch (LoginDataLostException ex) { displayMessage("LoginData Lost", "No login data available any longer in the session:<br /> " + ex.getMessage()); } catch (UniformInterfaceException ex) { if (ex.getResponse().getStatus() == Response.Status.FORBIDDEN.getStatusCode()) { displayMessage("Corpus access forbidden", "You are not allowed to access this corpus. " + "Please login at the <a target=\"_blank\" href=\"" + Helper.getContext() + "\">main application</a> first and then reload this page."); } else { displayMessage("Service error", ex.getMessage()); } } catch (ClientHandlerException ex) { displayMessage("Could not generate the visualization because the ANNIS service reported an error.", ex.getMessage()); } catch (Throwable ex) { displayMessage("Could not generate the visualization.", ex.getMessage() == null ? ("An unknown error of type " + ex.getClass().getSimpleName()) + " occured." : ex.getMessage()); } }
From source file:at.peppol.webgui.app.components.InvoiceLineAllowanceChargeForm.java
License:Mozilla Public License
private void initElements() { final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);//w w w . j a v a2s . c om hiddenContent.setMargin(true); table = new InvoiceLineAllowanceChargeTable(lineAllowanceChargeList); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceLineAllowanceChargeTableEditor editor = new InvoiceLineAllowanceChargeTableEditor(editMode, inv); Label label = new Label("<h3>Adding allowance/charge line</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineAllowanceChargeList, label)); label = new Label("<h3>Edit allowance/charge line</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineAllowanceChargeList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); Panel outerPanel = new Panel(prefix + " Allowances/Charges"); //outerPanel.setStyleName("light"); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); // ---- HIDDEN FORM ENDS ----- grid.setSizeUndefined(); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerPanel.addComponent(formLayout); outerLayout.addComponent(outerPanel); outerPanel.requestRepaintAll(); VerticalLayout mainLayout = new VerticalLayout(); final VerticalLayout showHideContentLayout = new VerticalLayout(); showHideContentLayout.addComponent(outerPanel); HorizontalLayout showHideButtonLayout = new HorizontalLayout(); Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub showHideContentLayout.setVisible(!showHideContentLayout.isVisible()); } }); showHideButtonLayout.setWidth("100%"); showHideButtonLayout.addComponent(btn); showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT); //mainLayout.addComponent(showHideButtonLayout); mainLayout.addComponent(showHideContentLayout); //showHideContentLayout.setVisible(false); addComponent(mainLayout); }
From source file:at.peppol.webgui.app.components.InvoiceLineCommodityClassificationForm.java
License:Mozilla Public License
private void initElements() { final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);/*from w w w . j a va2 s. com*/ hiddenContent.setMargin(true); table = new InvoiceLineCommodityClassificationTable(lineCommodityList); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceLineCommodityClassificationTableEditor editor = new InvoiceLineCommodityClassificationTableEditor( editMode); Label label = new Label("<h3>Adding commodity classification line</h3>", Label.CONTENT_XHTML); addButton.addListener( editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineCommodityList, label)); label = new Label("<h3>Edit commodity classification line</h3>", Label.CONTENT_XHTML); editButton.addListener( editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineCommodityList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); Panel outerPanel = new Panel(prefix + " Commodity Classifications"); //outerPanel.setStyleName("light"); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); // ---- HIDDEN FORM ENDS ----- grid.setSizeUndefined(); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerPanel.addComponent(formLayout); outerLayout.addComponent(outerPanel); outerPanel.requestRepaintAll(); VerticalLayout mainLayout = new VerticalLayout(); final VerticalLayout showHideContentLayout = new VerticalLayout(); showHideContentLayout.addComponent(outerPanel); HorizontalLayout showHideButtonLayout = new HorizontalLayout(); Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub showHideContentLayout.setVisible(!showHideContentLayout.isVisible()); } }); showHideButtonLayout.setWidth("100%"); showHideButtonLayout.addComponent(btn); showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT); //mainLayout.addComponent(showHideButtonLayout); mainLayout.addComponent(showHideContentLayout); //showHideContentLayout.setVisible(false); addComponent(mainLayout); }
From source file:at.peppol.webgui.app.components.InvoiceLineOrderForm.java
License:Mozilla Public License
private void initElements() { final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);//from www. ja va2 s . co m hiddenContent.setMargin(true); table = new InvoiceLineOrderReferenceTable(lineOrderList); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceLineOrderReferenceTableEditor editor = new InvoiceLineOrderReferenceTableEditor(editMode); Label label = new Label("<h3>Adding order line</h3>", Label.CONTENT_XHTML); addButton.addListener( editor.addButtonListener(editButton, deleteButton, hiddenContent, table, lineOrderList, label)); label = new Label("<h3>Edit order line</h3>", Label.CONTENT_XHTML); editButton.addListener( editor.editButtonListener(addButton, deleteButton, hiddenContent, table, lineOrderList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); Panel outerPanel = new Panel(prefix + " Referencing Orders"); //outerPanel.setStyleName("light"); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); // ---- HIDDEN FORM ENDS ----- grid.setSizeUndefined(); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerPanel.addComponent(formLayout); outerLayout.addComponent(outerPanel); outerPanel.requestRepaintAll(); VerticalLayout mainLayout = new VerticalLayout(); final VerticalLayout showHideContentLayout = new VerticalLayout(); showHideContentLayout.addComponent(outerPanel); HorizontalLayout showHideButtonLayout = new HorizontalLayout(); Button btn = new Button("Show/Hide Allowances/Charges", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub showHideContentLayout.setVisible(!showHideContentLayout.isVisible()); } }); showHideButtonLayout.setWidth("100%"); showHideButtonLayout.addComponent(btn); showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT); //mainLayout.addComponent(showHideButtonLayout); mainLayout.addComponent(showHideContentLayout); //showHideContentLayout.setVisible(false); addComponent(mainLayout); }
From source file:at.peppol.webgui.app.components.InvoiceLineWindow.java
License:Mozilla Public License
public InvoiceLineWindow(final TabInvoiceLine parent) { this.parent = parent; invln = new InvoiceLineAdapter(); // line = new Line(); // BeanItem<InvoiceLineAdapter> invoiceLine = new BeanItem<InvoiceLineAdapter>(invln); // parent.setItemDataSource(invoiceLine); // BeanItem<Line> invoiceLine = new BeanItem<Line>(line); // parent.setItemDataSource(invoiceLine); subwindow = new Window("Invoice Line"); subwindow.setModal(true);/*from ww w .j a v a2s . c o m*/ VerticalLayout layout = (VerticalLayout) subwindow.getContent(); layout.setMargin(true); layout.setSpacing(true); Button btnClose = new Button("Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { (subwindow.getParent()).removeWindow(subwindow); } }); Button btnSave = new Button("Save", new Button.ClickListener() { public void buttonClick(ClickEvent event) { //update GUI table !! ///parent.getTable().addInvoiceLine (invln); //update actual invoice line item ///parent.items.add (invln); //close popup (subwindow.getParent()).removeWindow(subwindow); } }); try { layout.addComponent(createInvoiceLineForm()); } catch (Exception e) { e.printStackTrace(); } layout.addComponent(btnSave); layout.addComponent(btnClose); layout.setComponentAlignment(btnClose, Alignment.BOTTOM_RIGHT); }
From source file:at.peppol.webgui.app.components.ItemPropertyForm.java
License:Mozilla Public License
private void initElements() { final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);/*from w ww . ja v a 2s. c om*/ hiddenContent.setMargin(true); table = new InvoiceItemPropertyTable(itemPropertyBeanList); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(false); table.addStyleName("striped strong"); VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add new"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceItemPropertyTableEditor editor = new InvoiceItemPropertyTableEditor(editMode); Label label = new Label("<h3>Adding new item property</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, itemPropertyBeanList, label)); label = new Label("<h3>Edit item property</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, itemPropertyBeanList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); Panel outerPanel = new Panel(itemPropertyPrefix + " Item Properties"); //outerPanel.setStyleName("light"); // ---- HIDDEN FORM BEGINS ----- VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); // ---- HIDDEN FORM ENDS ----- grid.setSizeUndefined(); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerPanel.addComponent(formLayout); outerLayout.addComponent(outerPanel); outerPanel.requestRepaintAll(); VerticalLayout mainLayout = new VerticalLayout(); final VerticalLayout showHideContentLayout = new VerticalLayout(); showHideContentLayout.addComponent(outerPanel); HorizontalLayout showHideButtonLayout = new HorizontalLayout(); Button btn = new Button("Show/Hide Additional Item Property", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // TODO Auto-generated method stub showHideContentLayout.setVisible(!showHideContentLayout.isVisible()); } }); showHideButtonLayout.setWidth("100%"); showHideButtonLayout.addComponent(btn); showHideButtonLayout.setComponentAlignment(btn, Alignment.MIDDLE_RIGHT); //mainLayout.addComponent(showHideButtonLayout); mainLayout.addComponent(showHideContentLayout); //showHideContentLayout.setVisible(false); addComponent(mainLayout); }
From source file:at.peppol.webgui.app.components.PartyDetailForm.java
License:Mozilla Public License
private void initElements() { setCaption(party + " Party"); //setStyleName("light"); final VerticalLayout outerLayout = new VerticalLayout(); outerLayout.setSpacing(true); outerLayout.setMargin(true);/*from www . j ava2s. co m*/ hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true); hiddenContent.setMargin(true); PropertysetItem partyItemSet = new PropertysetItem(); PartyIdentificationType supplierPartyID; if (partyBean.getPartyIdentification().size() == 0) { supplierPartyID = new PartyIdentificationType(); supplierPartyID.setID(new IDType()); partyBean.getPartyIdentification().add(supplierPartyID); } else { supplierPartyID = partyBean.getPartyIdentification().get(0); } partyItemSet.addItemProperty("Party ID", new NestedMethodProperty(supplierPartyID, "ID.value")); EndpointIDType endPointID; if (partyBean.getEndpointID() == null) { endPointID = new EndpointIDType(); partyBean.setEndpointID(endPointID); } else { endPointID = partyBean.getEndpointID(); } partyItemSet.addItemProperty("Endpoint ID", new NestedMethodProperty(endPointID, "SchemeAgencyID")); PartyNameType partyName; if (partyBean.getPartyName().size() == 0) { partyName = new PartyNameType(); partyName.setName(new NameType()); partyBean.getPartyName().add(partyName); } else { partyName = partyBean.getPartyName().get(0); } partyItemSet.addItemProperty("Party Name", new NestedMethodProperty(partyName, "name.value")); /* partyItemSet.addItemProperty("Agency Name", new NestedMethodProperty(supplierPartyID, "ID.SchemeAgencyID") ); */ /* final AddressType partyrAddress = new AddressType(); partyBean.setPostalAddress(partyrAddress); partyrAddress.setStreetName(new StreetNameType()); partyrAddress.setCityName(new CityNameType()); partyrAddress.setPostalZone(new PostalZoneType()); partyrAddress.setCountry(new CountryType()); partyrAddress.getCountry().setIdentificationCode(new IdentificationCodeType()); partyItemSet.addItemProperty("Street Name", new NestedMethodProperty(partyrAddress, "streetName.value")); partyItemSet.addItemProperty("City", new NestedMethodProperty(partyrAddress, "cityName.value")); partyItemSet.addItemProperty("Postal Zone", new NestedMethodProperty(partyrAddress, "postalZone.value")); partyItemSet.addItemProperty("Country", new NestedMethodProperty(partyrAddress, "country.identificationCode.value")); */ AddressDetailForm partyAddressForm; AddressType address; if (partyBean.getPostalAddress() == null) { address = new AddressType(); } else { address = partyBean.getPostalAddress(); } partyAddressForm = new AddressDetailForm(party, address); partyBean.setPostalAddress(address); PartyTaxSchemeType taxScheme; if (partyBean.getPartyTaxScheme().size() == 0) { taxScheme = new PartyTaxSchemeType(); taxScheme.setCompanyID(new CompanyIDType()); //partyItemSet.addItemProperty(taxSchemeCompanyID, // new NestedMethodProperty(taxScheme.getCompanyID(),"value")); // TODO: Hardcoded ShemeID etc for TaxScheme. Should be from a codelist? taxScheme.setTaxScheme(new TaxSchemeType()); taxScheme.getTaxScheme().setID(new IDType()); taxScheme.getTaxScheme().getID().setValue("VAT"); taxScheme.getTaxScheme().getID().setSchemeID("UN/ECE 5153"); taxScheme.getTaxScheme().getID().setSchemeAgencyID("6"); partyBean.getPartyTaxScheme().add(taxScheme); } else { taxScheme = partyBean.getPartyTaxScheme().get(0); } partyItemSet.addItemProperty(taxSchemeCompanyID, new NestedMethodProperty(taxScheme.getCompanyID(), "value")); partyItemSet.addItemProperty(taxSchemeID, new NestedMethodProperty(taxScheme.getTaxScheme().getID(), "value")); final Form partyForm = new Form(); partyForm.setFormFieldFactory(new PartyFieldFactory()); partyForm.setItemDataSource(partyItemSet); partyForm.setImmediate(true); final Button addLegalEntityBtn = new Button("Add Legal Entity"); final Button removeLegalEntityBtn = new Button("Remove Legal Entity"); //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //add the legal entity component Panel panel = createLegalEntityPanel(removeLegalEntityBtn); outerLayout.addComponent(panel); panel.setWidth("90%"); addLegalEntityBtn.setVisible(false); //removeLegalEntityBtn.setVisible(true); //outerLayout.replaceComponent(removeLegalEntityBtn, panel); } }); removeLegalEntityBtn.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { //remove the legal entity component for (int i = 0; i < outerLayout.getComponentCount(); i++) { Component c = outerLayout.getComponent(i); if (c instanceof Panel) { if (c.getCaption().equals("Legal Entity")) { outerLayout.removeComponent(c); if (partyBean.getPartyLegalEntity().size() > 0) { partyBean.getPartyLegalEntity().clear(); ValidatorsList.removeListeners(Utils.getFieldListeners(legalEntityForm)); } } } } //removeLegalEntityBtn.setVisible(false); addLegalEntityBtn.setVisible(true); } }); outerLayout.addComponent(partyForm); partyForm.setWidth("90%"); outerLayout.addComponent(partyAddressForm); partyAddressForm.setWidth("90%"); outerLayout.addComponent(addLegalEntityBtn); if (partyBean.getPartyLegalEntity().size() > 0) addLegalEntityBtn.click(); //outerLayout.addComponent(removeLegalEntityBtn); //outerLayout.addComponent(createLegalEntityPanel()); setContent(outerLayout); }
From source file:at.peppol.webgui.app.components.TabInvoiceAllowanceCharge.java
License:Mozilla Public License
private void initElements() { allowanceChargeList = parent.getInvoice().getAllowanceCharge(); final GridLayout grid = new GridLayout(4, 4); final VerticalLayout outerLayout = new VerticalLayout(); hiddenContent = new VerticalLayout(); hiddenContent.setSpacing(true);/* ww w .j av a 2s. c o m*/ hiddenContent.setMargin(true); table = new InvoiceAllowanceChargeTable(parent.getInvoice().getAllowanceCharge()); table.setSelectable(true); table.setImmediate(true); table.setNullSelectionAllowed(false); table.setHeight(150, UNITS_PIXELS); table.setFooterVisible(true); table.addStyleName("striped strong"); //table.addListener(parent.new TaxExclusiveAmountListener()); final VerticalLayout tableContainer = new VerticalLayout(); tableContainer.addComponent(table); tableContainer.setMargin(false, true, false, false); Button addButton = new Button("Add New"); Button editButton = new Button("Edit selected"); Button deleteButton = new Button("Delete selected"); final VerticalLayout buttonsContainer = new VerticalLayout(); buttonsContainer.setSpacing(true); buttonsContainer.addComponent(addButton); buttonsContainer.addComponent(editButton); buttonsContainer.addComponent(deleteButton); InvoiceAllowanceChargeTableEditor editor = new InvoiceAllowanceChargeTableEditor(editMode, parent.getInvoice()); Label label = new Label("<h3>Adding new allowance/charge line</h3>", Label.CONTENT_XHTML); addButton.addListener(editor.addButtonListener(editButton, deleteButton, hiddenContent, table, allowanceChargeList, label)); label = new Label("<h3>Edit allowance/charge line</h3>", Label.CONTENT_XHTML); editButton.addListener(editor.editButtonListener(addButton, deleteButton, hiddenContent, table, allowanceChargeList, label)); deleteButton.addListener(editor.deleteButtonListener(table)); final Panel outerPanel = new Panel("Allowance Charge"); grid.addComponent(tableContainer, 0, 0); grid.addComponent(buttonsContainer, 1, 0); outerPanel.addComponent(grid); outerLayout.addComponent(outerPanel); // ---- HIDDEN FORM BEGINS ----- final VerticalLayout formLayout = new VerticalLayout(); formLayout.addComponent(hiddenContent); hiddenContent.setVisible(false); outerLayout.addComponent(formLayout); // ---- HIDDEN FORM ENDS ----- setLayout(outerLayout); grid.setSizeUndefined(); outerPanel.requestRepaintAll(); }