List of usage examples for com.vaadin.ui VerticalLayout getComponent
public Component getComponent(int index) throws IndexOutOfBoundsException
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);// w ww . j av a 2 s. c o m outerLayout.setMargin(true); 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:com.snowy.Login.java
@PostConstruct void init() {/*ww w. ja v a 2 s . c o m*/ d = ((MyVaadinUI) UI.getCurrent()).getDataObject(); //Logger.getLogger(Login.class.getName()).info(d); this.setSizeFull(); this.setSpacing(false); this.setMargin(true); Label MainL = new Label("<h1>Connect 4</h1?>", ContentMode.HTML); //layout.addComponent(MainL); MainL.setSizeUndefined(); VerticalLayout lay = new VerticalLayout(); lay.setMargin(false); lay.addComponent(MainL); lay.setComponentAlignment(MainL, Alignment.TOP_CENTER); HorizontalLayout hz = new HorizontalLayout(); hz.setMargin(false); hz.setSpacing(false); LoginForm lf = new LoginForm(); lf.addLoginListener((e) -> { String token = d.genToken(e.getLoginParameter("username"), e.getLoginParameter("password")); //String token="true"; if (!token.equals("false")) { Cookie c = new Cookie("token", token); VaadinService.getCurrentResponse().addCookie(c); //https://vaadin.com/wiki/-/wiki/Main/Setting+and+reading+Cookies //Notification.show(VaadinService.getCurrentRequest().getCookies()[1].getValue(),Notification.Type.ERROR_MESSAGE); //this.getNavigator().navigateTo("main"); //this.getUI().get this.getUI().getNavigator().navigateTo("main"); } else { Label l = new Label("<h4 style=\"color:red\">Invalid Username or Password</h4>", ContentMode.HTML); l.setId("created"); if (lay.getComponent(lay.getComponentIndex(lf) + 1).getId() == null) { //lay.addComponent(new Label(String.valueOf(lay.getComponentIndex(l)))); lay.addComponent(l, lay.getComponentIndex(lf) + 1); l.setSizeUndefined(); lay.setComponentAlignment(l, Alignment.TOP_CENTER); } } }); lay.addComponent(lf); Button newUser = new Button("New User"); newUser.addClickListener((e) -> { this.getUI().addWindow(new NewUserSubWindow(d)); }); //newUser.setWidth((float)5.5, Unit.EM); Button forgotPass = new Button("Forgot Password"); //temp forgotPass.addClickListener((e) -> { //Notification.show(, Notification.Type.ERROR_MESSAGE); }); forgotPass.setEnabled(false); forgotPass.setDescription("Feature Disabled, Contact Administrator for Assistance"); //forgotPass.setWidth((float) 8.5,Unit.EM); forgotPass.setStyleName(ValoTheme.BUTTON_LINK); newUser.setStyleName(ValoTheme.BUTTON_LINK); hz.addComponent(newUser); hz.addComponent(forgotPass); lay.addComponent(hz); lay.setComponentAlignment(lf, Alignment.TOP_CENTER); lay.setComponentAlignment(hz, Alignment.MIDDLE_CENTER); this.addComponent(lay); this.setComponentAlignment(lay, Alignment.MIDDLE_CENTER); }
From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java
License:Apache License
/** * @param aClass//from www . jav a 2 s . com */ public void showPanel(Class aClass) { Panel mainPanel = (Panel) this.mainWindow.getContent(); HorizontalLayout appLayout = (HorizontalLayout) mainPanel.getContent(); VerticalLayout mainLayout = (VerticalLayout) appLayout.getComponent(0); // the ApplicationLayout has one component which is the VerticalLayout 'mainLayout' IApplicationPanel panel = this.map.get(aClass); if (panel != null || !(aClass.equals(this.activePanel.getClass()))) { try { Log.info("Loading panel"); /* * mainLayout.getComponent(0) = Title * mainLayout.getComponent(1) = Menubar * mainLayout.getComponent(2) = IApplicationPanel */ ((IApplicationPanel) mainLayout.getComponent(2)).validate(); //make sure it's safe to navigate off the panel (opportunity to save data) panel.init(this.theSession, this); mainLayout.replaceComponent(mainLayout.getComponent(2), (Component) panel); this.activePanel = panel; } catch (Exception e) { this.mainWindow.getWindow().showNotification(e.getMessage(), e.getMessage(), Notification.TYPE_ERROR_MESSAGE); } } else Log.warning("Panel does not exist"); }
From source file:com.studiodojo.qwikinvoice.QwikInvoiceApplication.java
License:Apache License
/** * Return <code>true</code> is the specified component is the IApplicationPanel instance that is visible * @param aClass/*from w ww . j a va 2s .c o m*/ * @return */ private boolean isPanelVisable(Class aClass) { HorizontalLayout appLayout = (HorizontalLayout) this.mainWindow.getContent(); VerticalLayout mainLayout = (VerticalLayout) appLayout.getComponent(0); // the ApplicationLayout has one component which is the VerticalLayout 'mainLayout' if (mainLayout.getComponent(2).equals((Component) this.map.get(aClass))) return true; else return false; }
From source file:de.uni_leipzig.informatik.pcai042.boa.gui.goldstandard.GoldstandardGUI.java
License:Open Source License
/** * The constructor should first build the main layout, set the composition * root and then do any custom initialization. * //from w ww.j a va2 s. c om * The constructor will not be automatically regenerated by the visual * editor. */ public GoldstandardGUI() { buildMainLayout(); setCompositionRoot(mainLayout); // user code for (Type t : BoaAnnotation.Type.values()) { comboBoxTypes.addItem(t); } comboBoxTypes.setTextInputAllowed(false); listSelectAnnotations.setMultiSelect(false); comboBoxTypes.setNullSelectionAllowed(false); listSelectAnnotations.setNullSelectionAllowed(false); // with this layout components will get wrapped cssLayoutTokens = new CssLayout() { @Override protected String getCss(Component c) { return "float:left;margin-right:5px;"; } }; cssLayoutTokens.setWidth("100%"); // auto; becomes vertical scroll-able since verticalLayout_tokens height // is also auto cssLayoutTokens.setHeight(SIZE_UNDEFINED, 0); verticalLayoutTokens.addComponent(cssLayoutTokens); resetComponents(); buttonNext.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (sentence != null) { SentenceServer.returnSentence(sentence); } resetComponents(); sentence = SentenceServer.getSentence(); if (sentence == null) { getWindow().showNotification("No more senentences.", Notification.TYPE_ERROR_MESSAGE); return; } // create new check boxes for tokens CheckBox checkbox; Label label; VerticalLayout vertLayout; for (int i = 0; i < sentence.getTokens().size(); i++) { checkbox = new CheckBox(); checkbox.setImmediate(true); checkbox.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { Iterator<Component> iterator = cssLayoutTokens.getComponentIterator(); Label l; CheckBox cb; VerticalLayout vl; String s = ""; while (iterator.hasNext()) { vl = (VerticalLayout) iterator.next(); l = (Label) vl.getComponent(0); cb = (CheckBox) vl.getComponent(1); if (cb.booleanValue()) { s += l.getValue(); } } if (s.isEmpty()) s = ""; textFieldLabel.setReadOnly(false); textFieldLabel.setValue(s); textFieldLabel.setReadOnly(true); } }); label = new Label(sentence.getTokens().get(i)); label.setSizeUndefined(); vertLayout = new VerticalLayout(); vertLayout.addComponent(label); vertLayout.addComponent(checkbox); vertLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); vertLayout.setComponentAlignment(checkbox, Alignment.MIDDLE_CENTER); vertLayout.setSizeUndefined(); cssLayoutTokens.addComponent(vertLayout); } } }); buttonDiscard.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (sentence != null) { SentenceServer.discardSentence(sentence); resetComponents(); } } }); buttonAddAnno.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (!textFieldLabel.getValue().equals("") && comboBoxTypes.getValue() != null) { Iterator<Component> iterator = cssLayoutTokens.getComponentIterator(); Label l; CheckBox cb; VerticalLayout vl; ArrayList<String> selected = new ArrayList<String>(); while (iterator.hasNext()) { vl = (VerticalLayout) iterator.next(); l = (Label) vl.getComponent(0); cb = (CheckBox) vl.getComponent(1); if (cb.booleanValue()) { selected.add((String) l.getValue()); cb.setValue(false); } } BoaAnnotation anno = new BoaAnnotation((Type) comboBoxTypes.getValue(), selected); boolean isDuplicate = false; boolean isColliding = false; for (BoaAnnotation a : sentence.getAnnotations()) { if (a.getTokens().size() == anno.getTokens().size()) { boolean sameTokens = true; for (int i = 0; i < a.getTokens().size(); i++) { sameTokens = a.getTokens().get(i) == anno.getTokens().get(i); if (!sameTokens) break; } if (sameTokens) { isColliding = !(isDuplicate = a.getType().equals(anno.getType())); break; } } } if (isDuplicate) { getWindow().showNotification("Duplicate was dismissed.", Notification.TYPE_WARNING_MESSAGE); } else if (isColliding) { getWindow().showNotification("Label is already assigned to<br/> a different type.", Notification.TYPE_ERROR_MESSAGE); } else { sentence.getAnnotations().add(anno); listSelectAnnotations.addItem(anno); } } else getWindow().showNotification("Label or type is inavlid.", Notification.TYPE_ERROR_MESSAGE); } }); buttonDelAnno.addListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (listSelectAnnotations.getValue() != null) { sentence.getAnnotations().remove(listSelectAnnotations.getValue()); listSelectAnnotations.removeItem(listSelectAnnotations.getValue()); } } }); }
From source file:edu.kit.dama.ui.admin.wizard.FirstStartWizard.java
License:Apache License
private void buildMainLayout() { stepLayout = new VerticalLayout(); back.setEnabled(false);// w ww .j a v a 2 s. c o m stepLayout.addComponent(stepList[currentStep]); stepLayout.setComponentAlignment(stepList[currentStep], Alignment.TOP_RIGHT); stepLayout.setSpacing(false); stepLayout.setMargin(false); stepLayout.setWidth("100%"); stepLayout.setHeight("500px"); final VerticalLayout stepLabels = new VerticalLayout(); for (WizardStep step : stepList) { Label stepLabel = new Label(step.getStepName()); stepLabel.setWidth("250px"); stepLabels.addComponent(stepLabel); stepLabels.setComponentAlignment(stepLabel, Alignment.TOP_LEFT); } //make introduction label bold stepLabels.getComponent(0).addStyleName("myboldcaption"); Label spacer = new Label(); stepLabels.addComponent(spacer); stepLabels.setExpandRatio(spacer, 1.0f); stepLabels.setWidth("275px"); stepLabels.setHeight("550px"); stepLabels.setSpacing(true); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); HorizontalLayout buttonLayout = new HorizontalLayout(back, next); buttonLayout.setSizeFull(); buttonLayout.setComponentAlignment(back, Alignment.BOTTOM_RIGHT); buttonLayout.setComponentAlignment(next, Alignment.BOTTOM_RIGHT); buttonLayout.setExpandRatio(back, 1.0f); next.addClickListener((event) -> { if ("Go To Login".equals(next.getCaption())) { Page.getCurrent().reload(); } else if ("Finish".equals(next.getCaption())) { //do finish WizardPersistHelper helper = new WizardPersistHelper(); if (helper.persist(properties)) { UIUtils7.showInformation("Success", "All information have been successfully stored into the database. For details, please refer to the log output above.\n" + "You may now dismiss this message and click 'Go To Login' in order to access the login page.\n" + "From there you can to login using your administrator account or create a personalized user account.", 3000); back.setVisible(false); next.setCaption("Go To Login"); } else { UIUtils7.showError("Failed to store collected information in database.\n" + "Please refer to the log output above."); } ((WizardSummary) stepList[currentStep]).setSummary(helper.getMessages()); } else { if (currentStep + 1 <= stepList.length - 1) { if (stepList[currentStep].validate()) { stepList[currentStep].collectProperties(properties); currentStep++; stepLayout.replaceComponent(stepList[currentStep - 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep - 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); if (stepList[currentStep] instanceof WizardSummary) { StringBuilder summary = new StringBuilder(); for (WizardStep step : stepList) { summary.append(step.getSummary()).append("\n"); } ((WizardSummary) stepList[currentStep]).setSummary(summary.toString()); } } } if (currentStep == stepList.length - 1) { //finish next.setCaption("Finish"); } else { next.setCaption("Next"); } back.setEnabled(true); } }); back.addClickListener((event) -> { if (currentStep - 1 >= 0) { stepList[currentStep].collectProperties(properties); currentStep--; stepLayout.replaceComponent(stepList[currentStep + 1], stepList[currentStep]); Label currentLabel = (Label) stepLabels.getComponent(currentStep); Label prevLabel = (Label) stepLabels.getComponent(currentStep + 1); currentLabel.addStyleName("myboldcaption"); prevLabel.removeStyleName("myboldcaption"); } next.setEnabled(true); back.setEnabled(currentStep > 0); next.setCaption("Next"); }); builder.addComponent(stepLabels, Alignment.TOP_LEFT, 0, 0, 1, 2); builder.addComponent(stepLayout, Alignment.TOP_LEFT, 1, 0, 1, 1); builder.addComponent(buttonLayout, Alignment.BOTTOM_LEFT, 1, 1, 1, 1); mainLayout = builder.getLayout(); mainLayout.setMargin(true); mainLayout.setSizeFull(); // mainLayout.setColumnExpandRatio(0, .3f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, .95f); mainLayout.setRowExpandRatio(1, .05f); }
From source file:edu.nps.moves.mmowgli.components.WordCloudPanel.java
License:Open Source License
private void addAButton(WordButton butt) { if (!isIE7)/* ww w . j av a 2 s . c o m*/ meat.addComponent(butt); else { VerticalLayout vLay = (VerticalLayout) meat; int numLines = vLay.getComponentCount(); HorizontalLayout hL; if (numLines == 0) { hL = new HorizontalLayout(); vLay.addComponent(hL); vLay.setComponentAlignment(hL, Alignment.MIDDLE_CENTER); numLines = 1; } hL = (HorizontalLayout) vLay.getComponent(numLines - 1); hL.addComponent(butt); if (hL.getComponentCount() >= IE7MAXCOLCOUNT) { vLay.addComponent(hL = new HorizontalLayout()); vLay.setComponentAlignment(hL, Alignment.MIDDLE_CENTER); } } }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabTalk.java
License:Open Source License
@Override public boolean logUpdated_oobTL(Serializable chatLogId) { // This comes in on MY updates too, should do nothing since my just-entered msg is already displayed ActionPlan ap = ActionPlan.getTL(apId); ChatLog log = ap.getChatLog();//from www. j a v a 2s . co m if (chatLogId.equals(log.getId())) { // somebody else updated this log. // try not to load everything. All lists should be in order SortedSet<Message> msgs = log.getMessages(); if (msgs.size() <= 0) return false; VerticalLayout lay = (VerticalLayout) chatScroller.getContent(); Message topMsg = null; if (lay.getComponentCount() > 0) topMsg = ((ChatMsg) lay.getComponent(0)).getMessage(); int pos = 0; for (Iterator<Message> itr = msgs.iterator(); itr.hasNext();) { Message m = itr.next(); if (topMsg != null && m.getId() == topMsg.getId()) break; addMessageToScrollerAtPosition(m, pos++, HSess.get()); } return true; } return false; }
From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java
License:Open Source License
private void listFollowers_oob(Session sess, Object badboyId) { Card badboy = Card.get(badboyId, sess); Set<Card> children = badboy.getFollowOns(); Vector<CardSummary> vec = new Vector<CardSummary>(); User me = User.get(Mmowgli2UI.getGlobals().getUserID(), sess); int col = -1; for (CardType ct : followOnTypes) { col++;//www . j a v a2 s .c om VerticalLayout columnV = columnVLs.get(col); int numcards = columnV.getComponentCount(); // including header, which we // don't touch for (int i = numcards - 1; i > 0; i--) columnV.removeComponent(columnV.getComponent(i)); if (children != null) { vec.clear(); // need to sort below // todo, enforce this in db for (Card c : children) { if (!isGameMaster && CardMarkingManager.isHidden(c)) continue; if (!Card.canSeeCard_oob(c, me, sess)) continue; if (c.getCardType().getId() == ct.getId()) { CardSummary summ = CardSummary.newCardSummary(c.getId(), sess, me); vec.add(summ); } } for (CardSummary cs : vec) { columnV.addComponent(cs); cs.initGui(sess); } } } }
From source file:edu.nps.moves.mmowgli.modules.cards.CardChainPage.java
License:Open Source License
private boolean isDescendent(Card possibleChildCard) { VerticalLayout vl = getCardColumnLayout(possibleChildCard); if (vl == null) return false; int numChil = vl.getComponentCount(); for (int i = 0; i < numChil; i++) { Object comp = vl.getComponent(i); if (comp instanceof CardSummary) { CardSummary cs = (CardSummary) comp; if (cs.getCardId().equals(possibleChildCard.getId())) { cs.refreshContents(possibleChildCard); return true; }//from w ww. j a v a 2s .c om } } return false; }