List of usage examples for com.vaadin.ui HorizontalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:edu.nps.moves.mmowgli.MmowgliOuterFrame.java
License:Open Source License
public void addMenuBarAndFouoRowTL(User me) { HorizontalLayout hlay = new MHorizontalLayout().withMargin(false).withSpacing(false).withFullHeight(); addComponent(hlay);// w ww .j a v a2s . c o m if (me.isGameMaster() || me.isAdministrator() || me.isDesigner()) { menubar = new AppMenuBar(me.isGameMaster(), me.isAdministrator(), me.isDesigner()); hlay.addComponent(menubar); hlay.setExpandRatio(menubar, 0.5f); hlay.setComponentAlignment(menubar, Alignment.TOP_LEFT); } else { Label lab = new Label(); hlay.addComponent(lab); hlay.setExpandRatio(lab, 0.5f); } hlay.addComponent(fouoButton = makeFouoButtonTL()); Label lab = new Label(); hlay.addComponent(lab); hlay.setExpandRatio(lab, 0.5f); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionDashboard.java
License:Open Source License
public void initGuiTL() { setSizeUndefined();//from w w w . j a v a 2 s . com setWidth(APPLICATION_SCREEN_WIDTH); // setHeight("855px"); //ACTIONDASHBOARD_H); Label sp; addComponent(sp = new Label()); sp.setHeight("10px"); HorizontalLayout titleHL = new HorizontalLayout(); titleHL.setWidth("95%"); addComponent(titleHL); titleHL.addComponent(sp = new Label()); sp.setWidth("20px"); Component titleC; titleHL.addComponent(titleC = Mmowgli2UI.getGlobals().getMediaLocator().getActionDashboardTitle()); titleHL.setComponentAlignment(titleC, Alignment.MIDDLE_LEFT); titleHL.addComponent(sp = new Label()); sp.setWidth("1px"); titleHL.setExpandRatio(sp, 1.0f); titleHL.addComponent(howToWinActionButt); howToWinActionButt.setDescription(howWinAction_tt); AbsoluteLayout absL = new AbsoluteLayout(); addComponent(absL); absL.setWidth(APPLICATION_SCREEN_WIDTH); absL.setHeight(ACTIONDASHBOARD_H); MediaLocator medLoc = Mmowgli2UI.getGlobals().getMediaLocator(); AbsoluteLayout mainAbsLay = new AbsoluteLayout(); // offset it from master mainAbsLay.setWidth(APPLICATION_SCREEN_WIDTH); mainAbsLay.setHeight(ACTIONDASHBOARD_H); absL.addComponent(mainAbsLay, ACTIONDASHBOARD_OFFSET_POS); // Now the background Embedded backgroundImage = new Embedded(null, medLoc.getActionDashboardPlanBackground()); backgroundImage.setWidth(ACTIONDASHBOARD_W); backgroundImage.setHeight(ACTIONDASHBOARD_H); mainAbsLay.addComponent(backgroundImage, "top:0px;left:0px"); HorizontalLayout tabsHL = new HorizontalLayout(); tabsHL.setStyleName("m-actionDashboardBlackTabs"); tabsHL.setSpacing(false); tabsHL.addComponent(sp = new Label()); sp.setWidth("12px"); TabClickHandler tabHndlr = new TabClickHandler(); actionPlansTabButt.setStyleName("m-actionDashboardActionPlansTab"); actionPlansTabButt.addClickListener(tabHndlr); actionPlansTabButt.setId(ACTION_DASHBOARD_ACTION_PLANS_TAB); tabsHL.addComponent(actionPlansTabButt); tabsHL.addComponent(sp = new Label()); sp.setWidth("1px"); myPlansTabButt.setStyleName("m-actionDashboardMyPlansTab"); myPlansTabButt.addClickListener(tabHndlr); myPlansTabButt.setId(ACTION_DASHBOARD_MY_ACTION_PLANS_TAB); tabsHL.addComponent(myPlansTabButt); myPlansTabButt.addStyleName("m-transparent-background"); // initially tabsHL.addComponent(sp = new Label()); sp.setWidth("1px"); needAuthorsTabButt.setStyleName("m-actionDashboardNeedAuthorsTab"); needAuthorsTabButt.addClickListener(tabHndlr); needAuthorsTabButt.setId(ACTION_DASHBOARD_NEED_AUTHORS_TAB); tabsHL.addComponent(needAuthorsTabButt); needAuthorsTabButt.addStyleName("m-transparent-background"); // initially absL.addComponent(tabsHL, "left:7px;top:8px"); // stack the pages absL.addComponent(actionPlansTab, ACTIONDASHBOARD_TABCONTENT_POS); actionPlansTab.initGuiTL(); absL.addComponent(myPlansTab, ACTIONDASHBOARD_TABCONTENT_POS); myPlansTab.initGuiTL(); myPlansTab.setVisible(false); absL.addComponent(needAuthorsTab, ACTIONDASHBOARD_TABCONTENT_POS); needAuthorsTab.initGuiTL(); needAuthorsTab.setVisible(false); User me = Mmowgli2UI.getGlobals().getUserTL(); Set<ActionPlan> invitedSet = me.getActionPlansInvited(); if (invitedSet != null && (invitedSet.size()) > 0) { Notification note = new Notification("<center>You're invited to an Action Plan!</center>", "<center> Look for the \"you're invited to join!\" notice.<br/>" + "First, check out the plan. Then, if you want to join,<br/>" + "click the link to become an author." + "</center>", Type.HUMANIZED_MESSAGE, true); // allow html note.setPosition(Position.MIDDLE_CENTER); note.setDelayMsec(5000);// 5 secs note.show(Page.getCurrent()); } }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java
License:Open Source License
private Component makeIdField(ActionPlan ap) { HorizontalLayout hl = new HorizontalLayout(); hl.setMargin(false);//from ww w . ja v a2 s.c om hl.setSpacing(false); hl.setHeight("22px"); Label lab; hl.addComponent(lab = new Label()); lab.setWidth("270px"); hl.addComponent(lab = new Label("ID " + ap.getId())); hl.setComponentAlignment(lab, Alignment.BOTTOM_LEFT); maybeAddHiddenCheckBoxTL(hl, ap); return hl; }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPage2.java
License:Open Source License
@SuppressWarnings("serial") private void maybeAddHiddenCheckBoxTL(HorizontalLayout hl, ActionPlan ap) { User me = Mmowgli2UI.getGlobals().getUserTL(); if (me.isAdministrator() || me.isGameMaster()) { Label sp;/*from w w w.ja v a 2 s . c o m*/ hl.addComponent(sp = new Label()); sp.setWidth("80px"); final CheckBox hidCb = new CheckBox("hidden"); hidCb.setValue(ap.isHidden()); hidCb.setDescription("Only game masters see this"); hidCb.setImmediate(true); hl.addComponent(hidCb); hl.setComponentAlignment(hidCb, Alignment.BOTTOM_RIGHT); hidCb.addValueChangeListener(new ValueChangeListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void valueChange(ValueChangeEvent event) { HSess.init(); ActionPlan acntp = ActionPlan.getTL(getApId()); boolean nowHidden = acntp.isHidden(); boolean tobeHidden = hidCb.getValue(); if (nowHidden != tobeHidden) { acntp.setHidden(tobeHidden); ActionPlan.updateTL(acntp); } HSess.close(); } }); final CheckBox supIntCb = new CheckBox("super interesting"); supIntCb.setValue(ap.isSuperInteresting()); supIntCb.setDescription("Mark plan super-interesting (only game masters see this)"); supIntCb.setImmediate(true); hl.addComponent(supIntCb); hl.setComponentAlignment(supIntCb, Alignment.BOTTOM_RIGHT); supIntCb.addValueChangeListener(new ValueChangeListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void valueChange(ValueChangeEvent event) { HSess.init(); ActionPlan acntp = ActionPlan.getTL(getApId()); boolean nowSupInt = acntp.isSuperInteresting(); boolean tobeSupInt = supIntCb.getValue(); if (nowSupInt != tobeSupInt) { acntp.setSuperInteresting(tobeSupInt); ActionPlan.updateTL(acntp); } HSess.close(); } }); } }
From source file:edu.nps.moves.mmowgli.modules.administration.SignupHTMLGameDesignPanel.java
License:Open Source License
private AbstractComponent makeButton(String s, ClickListener lis) { HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("100%"); Button b;// w w w . ja va 2 s . c om hl.addComponent(b = new Button(s, lis)); hl.setComponentAlignment(b, Alignment.MIDDLE_CENTER); return hl; }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
private void showAddDialogOrCancel(final DoneListener lis) { dialog = new Window("Add to VIP list"); dialog.setModal(true);/*from w w w .j a v a 2 s . c o m*/ dialog.setWidth("400px"); dialog.setHeight("350px"); VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<String> rtypes = Arrays.asList(new String[] { EMAILTYPE, DOMAINTYPE }); radios = new OptionGroup("Select type", rtypes); radios.setNullSelectionAllowed(false); // user can not 'unselect' radios.select("Emails"); // select this by default radios.setImmediate(false); // don't send the change to the server at once layout.addComponent(radios); final TextArea ta = new TextArea(); //ta.setColumns(40); ta.setSizeFull(); ta.setInputPrompt( "Type or paste a tab-, comma- or space-separated list of emails or domains. For domains, " + "use forms such as \"army.mil\", \"nmci.navy.mil\", \"ucla.edu\", \"gov\", etc."); layout.addComponent(ta); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); @SuppressWarnings("serial") Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); @SuppressWarnings("serial") Button addButt = new Button("Add", new Button.ClickListener() { public void buttonClick(ClickEvent event) { String[] returnArr = null; String result = ta.getValue().toString(); if (result == null || result.length() <= 0) returnArr = null; else if ((returnArr = parseIt(result)) == null) return; dialog.close(); lis.continueOrCancel(returnArr); } }); hl.addComponent(cancelButt); hl.addComponent(addButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(hl); hl.setWidth("100%"); ta.setWidth("100%"); ta.setHeight("100%"); layout.setExpandRatio(ta, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.administration.VipListManager.java
License:Open Source License
@SuppressWarnings({ "unchecked", "serial" }) private void showViewOrDelete(final DeleteListener lis) { dialog = new Window("View / Delete VIPs"); dialog.setModal(true);//from www . ja va2 s . c om VerticalLayout layout = new VerticalLayout(); dialog.setContent(layout); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); List<VipPii> vLis = VHibPii.getAllVips(); vipListSelect = new ListSelect("Select items to delete"); StringBuffer sb = new StringBuffer(); // for popup vipListSelect.addStyleName("m-greyborder"); String lf = System.getProperty("line.separator"); for (int i = 0; i < vLis.size(); i++) { VipPii v; vipListSelect.addItem(v = vLis.get(i)); sb.append(v.getEntry()); sb.append(lf); } if (sb.length() > 0) sb.setLength(sb.length() - 1); // last space vipListSelect.setNullSelectionAllowed(true); vipListSelect.setMultiSelect(true); vipListSelect.setImmediate(true); vipListSelect.addValueChangeListener(new VipSelectListener()); layout.addComponent(vipListSelect); Label copyPopupList = new HtmlLabel("<pre>" + sb.toString() + "</pre>"); Panel p = new Panel(); VerticalLayout lay = new VerticalLayout(); p.setContent(lay); lay.addComponent(copyPopupList); p.setWidth("400px"); p.setHeight("300px"); PopupView popup = new PopupView("Display list as copyable text", p); popup.setHideOnMouseOut(false); if (sb.length() <= 0) popup.setEnabled(false); layout.addComponent(popup); layout.setComponentAlignment(popup, Alignment.MIDDLE_CENTER); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Button cancelButt = new Button("Cancel", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); lis.continueOrCancel(null); } }); deleteButt = new Button("Delete & Close", new Button.ClickListener() { public void buttonClick(ClickEvent event) { Set<VipPii> set = (Set<VipPii>) vipListSelect.getValue(); if (set.size() <= 0) set = null; dialog.close(); lis.continueOrCancel(set); } }); deleteButt.setEnabled(false); hl.addComponent(cancelButt); hl.addComponent(deleteButt); hl.setComponentAlignment(cancelButt, Alignment.MIDDLE_RIGHT); hl.setExpandRatio(cancelButt, 1.0f); // The components added to the window are actually added to the window's // layout; you can use either. Alignments are set using the layout layout.addComponent(hl); dialog.setWidth("300px"); dialog.setHeight("350px"); hl.setWidth("100%"); vipListSelect.setWidth("99%"); vipListSelect.setHeight("99%"); layout.setExpandRatio(vipListSelect, 1.0f); UI.getCurrent().addWindow(dialog); dialog.center(); }
From source file:edu.nps.moves.mmowgli.modules.cards.IdeaDashboardTabPanel.java
License:Open Source License
private Label buildTitleLabel(HorizontalLayout c, String s) { Label lab = new HtmlLabel(s); lab.addStyleName("m-tabpanel-right-title"); c.addComponent(lab);//from w w w . jav a 2 s .c o m c.setComponentAlignment(lab, Alignment.MIDDLE_LEFT); return lab; }
From source file:edu.nps.moves.mmowgli.modules.maps.LeafletMap.java
License:Open Source License
public void initGuiTL() { setSpacing(true);//from w ww. ja va 2s.c o m setSizeUndefined(); setWidth("950px"); addStyleName("m-marginleft-20"); Label lab; HorizontalLayout hLay = new HorizontalLayout(); hLay.setMargin(false); hLay.setSpacing(false); hLay.setWidth("100%"); NativeButton butt; hLay.addComponent(butt = new NativeButton("go to default game location", new MyDefaultLocationListener())); hLay.setExpandRatio(butt, 0.5f); hLay.setComponentAlignment(butt, Alignment.BOTTOM_LEFT); hLay.addComponent(lab = new HtmlLabel(title)); lab.setWidth(null); makeLayerPopups(); HorizontalLayout popLay = new HorizontalLayout(); popLay.setMargin(false); popLay.setSpacing(false); popLay.setWidth("100%"); popLay.addComponent(lab = new Label()); lab.setWidth("1px"); popLay.setExpandRatio(lab, 1.0f); popLay.addComponent(baseLayerPopup); popLay.addComponent(overlayPopup); hLay.addComponent(popLay); hLay.setComponentAlignment(popLay, Alignment.BOTTOM_RIGHT); hLay.setExpandRatio(popLay, 0.5f); addComponent(hLay); User me = Mmowgli2UI.getGlobals().getUserTL(); this.imAGuest = me.isViewOnly() || me.isAccountDisabled(); map.setAttributionPrefix("Powered by Leaflet with v-leaflet"); map.addStyleName("m-greyborder"); map.removeAllComponents(); // map.addControl(new LScale()); layerMap = installAllLayers(map); fillLayerPopupsTL(); // build the widgets setDefaultMapValuesTL(me); // set default zoom, center, layers if (!imAGuest) setUserMapValuesTL(me); // set zoom, center and layers from userID pref. setOptionGroupWidgetsFromLayerMap();// syncs up the widgets to match the active layers Collection<Extension> exts = map.getExtensions(); LLayers llayers = null; for (Extension ex : exts) if (ex instanceof LLayers) { llayers = (LLayers) ex; break; } if (llayers != null) map.removeExtension(llayers); addComponent(map); setExpandRatio(map, 1); map.setHeight("600px"); map.setWidth("100%"); map.addMoveEndListener(new MyMoveEndListener()); }
From source file:edu.nps.moves.mmowgli.modules.registrationlogin.RegistrationPageAgreement.java
License:Open Source License
public RegistrationPageAgreement(Button.ClickListener listener) { super(listener); super.initGui(); setTitleString(getTitle()); //"User Agreement 1"); contentVLayout.setSpacing(true);//ww w .ja v a 2s . c o m Label lab = new HtmlLabel(getLabelText()); //"First, please confirm your willingness to meet game requirements. I also confirm that I am at least 18 years of age."); lab.addStyleName(topLabelStyle); contentVLayout.addComponent(lab); HorizontalLayout hlayout = new HorizontalLayout(); contentVLayout.addComponent(hlayout); hlayout.setSpacing(true); hlayout.setWidth("100%"); hlayout.addStyleName(labelStyle); String readUrl = getReadUrlTL(); if (readUrl != null) { Link readLink = new Link("Read", new ExternalResource(getReadUrlTL())); //REGISTRATIONCONSENTURL)); readLink.setTargetName("_agreements"); readLink.setTargetBorder(BorderStyle.DEFAULT); readLink.setDescription("Opens in new window/tab"); hlayout.addComponent(readLink); readLink.setSizeUndefined(); hlayout.setComponentAlignment(readLink, Alignment.MIDDLE_LEFT); } lab = new HtmlLabel(getReadLabel()); //"<i>Consent to Participate in Anonymous Survey</i>"); lab.setSizeUndefined(); hlayout.addComponent(lab); hlayout.setSizeUndefined(); hlayout.setComponentAlignment(lab, Alignment.TOP_LEFT); contentVLayout.addComponent(lab = new Label()); lab.setHeight("15px"); HorizontalLayout hl = new HorizontalLayout(); hl.setWidth("98%"); //"100%"); contentVLayout.addComponent(hl); hl.addComponent(lab = new Label()); lab.setWidth("20px"); NativeButton rejectButt = new NativeButton(); hl.addComponent(rejectButt); rejectButt.setStyleName("m-rejectNoThanksButton"); // Mmowgli2UI.getGlobals().mediaLocator().decorateDialogRejectButton(rejectButt); rejectButt.addClickListener(new RejectListener()); hl.addComponent(lab = new Label()); hl.setExpandRatio(lab, 1.0f); NativeButton continueButt = new NativeButton(); hl.addComponent(continueButt); //Mmowgli2UI.getGlobals().mediaLocator().decorateDialogAcceptAndContinueButton(continueButt); continueButt.setStyleName("m-acceptAndContinueButton"); continueButt.addClickListener(new MyContinueListener()); continueButt.setClickShortcut(KeyCode.ENTER); }