List of usage examples for com.vaadin.ui GridLayout setSpacing
@Override public void setSpacing(boolean spacing)
From source file:edu.kit.dama.ui.simon.panel.SimonMainPanel.java
License:Apache License
/** * Build the overview tab including the list of all categories and der * overall status.//w w w .j a v a 2 s. c o m * * @param pCategories A list of all categories. * * @return The tab component. */ private Component buildOverviewTab(String[] pCategories) { AbsoluteLayout abLay = new AbsoluteLayout(); UIUtils7.GridLayoutBuilder layoutBuilder = new UIUtils7.GridLayoutBuilder(4, pCategories.length + 1); updateButton = new Button("Update Status"); updateButton.addClickListener(this); Embedded logo = new Embedded(null, new ThemeResource("img/simon.png")); abLay.addComponent(logo, "top:30px;left:30px;"); Label simonSaysLabel = new Label("", ContentMode.HTML); simonSaysLabel.setHeight("150px"); setSimonSaysContent(simonSaysLabel, "Everything is fine."); abLay.addComponent(simonSaysLabel, "top:30px;left:250px;"); int row = 0; for (String category : pCategories) { HorizontalLayout rowLayout = new HorizontalLayout(); Label name = new Label(category); name.setWidth("200px"); name.setHeight("24px"); List<AbstractProbe> probes = probesByCategory.get(category); Collections.sort(probes, new Comparator<AbstractProbe>() { @Override public int compare(AbstractProbe o1, AbstractProbe o2) { return o1.getCurrentStatus().compareTo(o2.getCurrentStatus()); } }); int failed = 0; int unknown = 0; int unavailable = 0; int charactersPerProbe = 100; if (probes.size() > 0) { charactersPerProbe = (int) Math.rint((700.0 / probes.size()) / 8.0); } for (AbstractProbe probe : probes) { Label probeLabel = new Label(StringUtils.abbreviate(probe.getName(), charactersPerProbe)); probeLabel.setHeight("24px"); switch (probe.getCurrentStatus()) { case UNKNOWN: probeLabel.setDescription(probe.getName() + ": UNKNOWN"); probeLabel.addStyleName("probe-unknown"); unknown++; break; case UPDATING: probeLabel.setDescription(probe.getName() + ": UPDATING"); probeLabel.addStyleName("probe-updating"); break; case UNAVAILABLE: probeLabel.setDescription(probe.getName() + ": UNAVAILABLE"); probeLabel.addStyleName("probe-unavailable"); unavailable++; break; case FAILED: probeLabel.setDescription(probe.getName() + ": FAILED"); probeLabel.addStyleName("probe-failed"); failed++; break; default: probeLabel.setDescription(probe.getName() + ": SUCCESS"); probeLabel.addStyleName("probe-success"); } probeLabel.addStyleName("probe"); rowLayout.addComponent(probeLabel); } if (failed != 0) { setSimonSaysContent(simonSaysLabel, "There are errors!"); } else { if (unknown != 0) { setSimonSaysContent(simonSaysLabel, "There are unknown states. Please select 'Update Status'."); } else { if (unavailable != 0) { setSimonSaysContent(simonSaysLabel, "Some probes are unavailable. Please check their configuration."); } } } rowLayout.setWidth("700px"); layoutBuilder.addComponent(name, Alignment.TOP_LEFT, 0, row, 1, 1).addComponent(rowLayout, Alignment.TOP_LEFT, 1, row, 3, 1); row++; } layoutBuilder.addComponent(updateButton, Alignment.BOTTOM_RIGHT, 3, row, 1, 1); GridLayout tabLayout = layoutBuilder.getLayout(); tabLayout.setSpacing(true); tabLayout.setMargin(true); Panel p = new Panel(); p.setContent(tabLayout); p.setWidth("1024px"); p.setHeight("400px"); abLay.addComponent(p, "top:160px;left:30px;"); abLay.setSizeFull(); return abLay; }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersPerServer(MenuBar mbar) { Object[][] oa = Mmowgli2UI.getGlobals().getSessionCountByServer(); Window svrCountWin = new Window("Display Active Users Per Server"); svrCountWin.setModal(true);/* w w w . j a v a 2s .co m*/ VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); svrCountWin.setContent(layout); GridLayout gl = new GridLayout(2, Math.max(1, oa.length)); gl.setSpacing(true); gl.addStyleName("m-greyborder"); for (Object[] row : oa) { Label lab = new Label(); lab.setSizeUndefined(); lab.setValue(row[0].toString()); gl.addComponent(lab); gl.setComponentAlignment(lab, Alignment.MIDDLE_RIGHT); gl.addComponent(new Label(row[1].toString())); } layout.addComponent(gl); layout.setComponentAlignment(gl, Alignment.MIDDLE_CENTER); svrCountWin.setWidth("250px"); UI.getCurrent().addWindow(svrCountWin); svrCountWin.center(); }
From source file:edu.nps.moves.mmowgli.export.BaseExporter.java
License:Open Source License
protected void getMetaStringOrCancel(final MetaListener lis, String title, final Map<String, String> params) { final Window dialog = new Window(title); final TextField[] parameterFields; dialog.setModal(true);// ww w .ja va 2s. co m VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); dialog.setContent(layout); final TextArea ta = new TextArea(); ta.setWidth("100%"); ta.setInputPrompt("Type a description of this data, or the game which generated this data (optional)"); ta.setImmediate(true); layout.addComponent(ta); Set<String> keySet = params.keySet(); parameterFields = new TextField[keySet.size()]; int i = 0; GridLayout pGL = new GridLayout(); pGL.addStyleName("m-greyborder"); pGL.setColumns(2); Label hdr = new HtmlLabel("<b>Parameters</b>"); hdr.addStyleName("m-textaligncenter"); pGL.addComponent(hdr, 0, 0, 1, 0); // top row pGL.setComponentAlignment(hdr, Alignment.MIDDLE_CENTER); pGL.setSpacing(false); for (String key : keySet) { pGL.addComponent(new HtmlLabel(" " + key + " ")); pGL.addComponent(parameterFields[i] = new TextField()); parameterFields[i++].setValue(params.get(key)); } if (i > 0) { layout.addComponent(pGL); layout.setComponentAlignment(pGL, Alignment.TOP_CENTER); } 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 exportButt = new Button("Export", new Button.ClickListener() { public void buttonClick(ClickEvent event) { dialog.close(); Set<String> keySet = params.keySet(); int i = 0; for (String key : keySet) params.put(key, parameterFields[i++].getValue().toString()); lis.continueOrCancel(ta.getValue().toString()); } }); hl.addComponent(cancelButt); hl.addComponent(exportButt); 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("385px"); dialog.setHeight("310px"); hl.setWidth("100%"); ta.setWidth("100%"); ta.setHeight("100%"); layout.setExpandRatio(ta, 1.0f); UI.getCurrent().addWindow(dialog); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabImages.java
License:Open Source License
@Override public void initGui() { setSizeUndefined();//from w ww. j a v a 2s . c om VerticalLayout leftLay = getLeftLayout(); leftLay.setSpacing(false); leftLay.setMargin(false); VerticalLayout flowLay = new VerticalLayout(); flowLay.setWidth("100%"); leftLay.addComponent(flowLay); flowLay.setSpacing(true); Label missionLab = new Label("Authors, add some images!"); flowLay.addComponent(missionLab); flowLay.setComponentAlignment(missionLab, Alignment.TOP_LEFT); missionLab.addStyleName("m-actionplan-mission-title-text"); ActionPlan ap = ActionPlan.getTL(apId); Label missionContentLab; if (!isMockup) missionContentLab = new HtmlLabel(ap.getImagesInstructions()); else { Game g = Game.getTL(); missionContentLab = new HtmlLabel(g.getDefaultActionPlanImagesText()); } flowLay.addComponent(missionContentLab); flowLay.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT); flowLay.addStyleName("m-actionplan-mission-content-text"); MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals(); flowLay.addComponent(addImageButt); addImageButt.addStyleName("m-actionplan-addimage-butt"); addImageButt.addStyleName("borderless"); addImageButt.setIcon(globs.getMediaLocator().getActionPlanAddImageButt()); addImageButt.addClickListener(new ImageAdder()); addImageButt.setEnabled(!isReadOnly); flowLay.addComponent(nonAuthorLabel = new Label("Authors may add images when editing the plan.")); nonAuthorLabel.setVisible(false); VerticalLayout rightLay = getRightLayout(); rightLay.setSpacing(false); rightLay.setMargin(false); imageScroller = new Panel(); GridLayout gridL = new GridLayout(); gridL.setColumns(2); gridL.setSpacing(true); gridL.setMargin(new MarginInfo(true)); imageScroller.setContent(gridL); imageScroller.setStyleName(Reindeer.PANEL_LIGHT); // make a transparent scroller imageScroller.setWidth("100%"); imageScroller.setHeight("99%"); setUpIndexListener(imageScroller); rightLay.addComponent(imageScroller); fillWithImagesTL(); }
From source file:edu.nps.moves.mmowgli.modules.actionplans.ActionPlanPageTabVideos.java
License:Open Source License
@Override public void initGui() { setSizeUndefined();//from w w w .j av a 2s .c o m VerticalLayout leftLay = getLeftLayout(); leftLay.setSpacing(false); leftLay.setMargin(false); VerticalLayout flowLay = new VerticalLayout(); flowLay.setWidth("100%"); leftLay.addComponent(flowLay); flowLay.setSpacing(true); Label missionLab = new Label("Authors, add some videos!"); flowLay.addComponent(missionLab); flowLay.setComponentAlignment(missionLab, Alignment.TOP_LEFT); missionLab.addStyleName("m-actionplan-mission-title-text"); ActionPlan ap = ActionPlan.getTL(apId); Label missionContentLab; if (!isMockup) missionContentLab = new HtmlLabel(ap.getVideosInstructions()); else { Game g = Game.getTL(); missionContentLab = new HtmlLabel(g.getDefaultActionPlanVideosText()); } flowLay.addComponent(missionContentLab); flowLay.setComponentAlignment(missionContentLab, Alignment.TOP_LEFT); flowLay.addStyleName("m-actionplan-mission-content-text"); MmowgliSessionGlobals globs = Mmowgli2UI.getGlobals(); flowLay.addComponent(addVideoButt); addVideoButt.addStyleName("m-actionplan-addimage-butt"); addVideoButt.addStyleName("borderless"); addVideoButt.setIcon(globs.getMediaLocator().getActionPlanAddVideoButt()); addVideoButt.addClickListener(new VideoAdder()); addVideoButt.setEnabled(!isReadOnly); flowLay.addComponent(nonAuthorLabel = new Label("Authors may add videos when editing the plan.")); nonAuthorLabel.setVisible(false); VerticalLayout rightLay = getRightLayout(); rightLay.setSpacing(false); rightLay.setMargin(false); rightScroller = new Panel(); GridLayout gridL = new GridLayout(); gridL.setColumns(2); gridL.setSpacing(true); gridL.setMargin(new MarginInfo(true)); rightScroller.setContent(gridL); rightScroller.setStyleName(Reindeer.PANEL_LIGHT); // make a transparent scroller rightScroller.setWidth("100%"); rightScroller.setHeight("99%"); setUpIndexListener(rightScroller); rightLay.addComponent(rightScroller); ; fillWithVideosTL(); }
From source file:edu.nps.moves.mmowgli.modules.userprofile.UserProfileMyIdeasPanel2.java
License:Open Source License
@SuppressWarnings("unchecked") private Component createProfileTL() { VerticalLayout lay = new VerticalLayout(); lay.setWidth("670px"); Label lab;// w ww .j a v a 2 s .c o m lay.addComponent(lab = new Label()); lab.setHeight("10px"); VerticalLayout innerVL = new VerticalLayout(); innerVL.setSpacing(true); innerVL.setMargin(true); innerVL.setWidth("100%"); //"90%"); innerVL.addStyleName("m-myideaprofile-table"); lay.addComponent(innerVL); GridLayout gridL = new GridLayout(); gridL.setColumns(2); gridL.addStyleName("m-userprofile-text"); gridL.setSpacing(true); CardType ct; int count = 0; int largest = -1; List<Card> lisPos = commonCriteria() .add(Restrictions.eq("cardType", ct = CardType .getCurrentPositiveIdeaCardTypeTL()/*CardTypeManager.getPositiveIdeaCardTypeTL()*/)) .list(); count += lisPos.size(); largest = Math.max(largest, lisPos.size()); List<Card> lisNeg = commonCriteria() .add(Restrictions.eq("cardType", ct = CardType.getCurrentNegativeIdeaCardTypeTL())).list(); //CardTypeManager.getNegativeIdeaCardTypeTL())).list(); count += lisNeg.size(); largest = Math.max(largest, lisNeg.size()); List<Card> lisExpand = commonCriteria().add(Restrictions.eq("cardType", ct = CardType.getExpandTypeTL())) .list();//CardTypeManager.getExpandTypeTL())).list(); count += lisExpand.size(); largest = Math.max(largest, lisExpand.size()); List<Card> lisAdapt = commonCriteria().add(Restrictions.eq("cardType", ct = CardType.getAdaptTypeTL())) .list();//CardTypeManager.getAdaptTypeTL())).list(); count += lisAdapt.size(); largest = Math.max(largest, lisAdapt.size()); List<Card> lisCounter = commonCriteria().add(Restrictions.eq("cardType", ct = CardType.getCounterTypeTL())) .list();//CardTypeManager.getCounterTypeTL())).list(); count += lisCounter.size(); largest = Math.max(largest, lisCounter.size()); List<Card> lisExplore = commonCriteria().add(Restrictions.eq("cardType", ct = CardType.getExploreTypeTL())) .list();//CardTypeManager.getExploreTypeTL())).list(); count += lisExplore.size(); largest = Math.max(largest, lisExplore.size()); ct = CardType.getCurrentPositiveIdeaCardTypeTL(); //CardTypeManager.getPositiveIdeaCardTypeTL(); row(ct.getSummaryHeader(), largest, lisPos.size(), ct, gridL); ct = CardType.getCurrentNegativeIdeaCardTypeTL(); //CardTypeManager.getNegativeIdeaCardTypeTL(); row(ct.getSummaryHeader(), largest, lisNeg.size(), ct, gridL); ct = CardType.getExpandTypeTL(); //CardTypeManager.getExpandTypeTL(); row(ct.getSummaryHeader(), largest, lisExpand.size(), ct, gridL); ct = CardType.getAdaptTypeTL(); //CardTypeManager.getAdaptTypeTL(); row(ct.getSummaryHeader(), largest, lisAdapt.size(), ct, gridL); ct = CardType.getCounterTypeTL(); //CardTypeManager.getCounterTypeTL(); row(ct.getSummaryHeader(), largest, lisCounter.size(), ct, gridL); ct = CardType.getExploreTypeTL(); //CardTypeManager.getExploreTypeTL(); row(ct.getSummaryHeader(), largest, lisExplore.size(), ct, gridL); gridL.addComponent(new Label("")); gridL.addComponent(new Label("")); gridL.addComponent(new Label("TOTAL")); gridL.addComponent(new Label("" + count)); innerVL.addComponent(gridL); lay.addComponent(lab = new Label()); lab.setHeight("1px"); lay.setExpandRatio(lab, 1.0f); return lay; }
From source file:edu.nps.moves.mmowgliMobile.ui.UserRenderer2.java
License:Open Source License
public void setMessage(FullEntryView2 mView, ListEntry message, ListView2 messageList, AbstractOrderedLayout layout) {//from w w w.ja v a2s. c o m // messageList can be null if coming in from ActionPlan Object key = HSess.checkInit(); UserListEntry wu = (UserListEntry) message; User u = wu.getUser(); layout.removeAllComponents(); HorizontalLayout hlay = new HorizontalLayout(); layout.addComponent(hlay); hlay.addStyleName("m-userview-top"); hlay.setWidth("100%"); hlay.setMargin(true); hlay.setSpacing(true); Image img = new Image(); img.addStyleName("m-ridgeborder"); img.setSource(mediaLocator.locate(u.getAvatar().getMedia())); img.setWidth("90px"); img.setHeight("90px"); hlay.addComponent(img); hlay.setComponentAlignment(img, Alignment.MIDDLE_CENTER); Label lab; hlay.addComponent(lab = new Label()); lab.setWidth("5px"); VerticalLayout vlay = new VerticalLayout(); vlay.setSpacing(true); hlay.addComponent(vlay); hlay.setComponentAlignment(vlay, Alignment.MIDDLE_LEFT); vlay.setWidth("100%"); hlay.setExpandRatio(vlay, 1.0f); HorizontalLayout horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.BOTTOM_LEFT); horl.addComponent(lab = new Label("name")); lab.addStyleName("m-user-top-label"); //light-text"); horl.addComponent(lab = new HtmlLabel(" " + u.getUserName())); lab.addStyleName("m-user-top-value"); horl = new HorizontalLayout(); horl.setSpacing(false); vlay.addComponent(horl); vlay.setComponentAlignment(horl, Alignment.TOP_LEFT); horl.addComponent(lab = new Label("level")); lab.addStyleName("m-user-top-label"); //light-text"); Level lev = u.getLevel(); if (u.isGameMaster()) { Level l = Level.getLevelByOrdinal(Level.GAME_MASTER_ORDINAL, HSess.get()); if (l != null) lev = l; } horl.addComponent(lab = new HtmlLabel(" " + lev.getDescription())); lab.addStyleName("m-user-top-value"); GridLayout gLay = new GridLayout(); // gLay.setHeight("155px"); // won't size properly gLay.setMargin(true); gLay.addStyleName("m-userview-mid"); gLay.setColumns(2); gLay.setRows(11); gLay.setSpacing(true); gLay.setWidth("100%"); gLay.setColumnExpandRatio(1, 1.0f); layout.addComponent(gLay); addRow(gLay, "user ID:", "" + getPojoId(message)); addRow(gLay, "location:", u.getLocation()); addRow(gLay, "expertise:", u.getExpertise()); addRow(gLay, "affiliation:", u.getAffiliation()); addRow(gLay, "date registered:", formatter.format(u.getRegisterDate())); gLay.addComponent(new Hr(), 0, 5, 1, 5); Container cntr = new CardsByUserContainer<Card>(u); // expects ThreadLocal session to be setup numCards = cntr.size(); addRow(gLay, "cards played:", "" + numCards); cntr = new ActionPlansByUserContainer<Card>(u); // expects ThreadLocal session to be setup numAps = cntr.size(); addRow(gLay, "action plans:", "" + numAps); gLay.addComponent(new Hr(), 0, 8, 1, 8); addRow(gLay, "exploration points:", "" + u.getBasicScore()); addRow(gLay, "innovation points:", "" + u.getInnovationScore()); cardListener = new CardLis(u, mView); apListener = new AppLis(u, mView); layout.addComponent(makeButtons()); HSess.checkClose(key); }
From source file:facs.components.BookAdmin.java
License:Open Source License
private Component deletedBookingsGrid() { VerticalLayout devicesLayout = new VerticalLayout(); devicesLayout.setCaption("Trash"); // HorizontalLayout buttonLayout = new HorizontalLayout(); // there will now be space around the test component // components added to the test component will now not stick together but have space between // them//from w ww .j a va 2s . c o m devicesLayout.setMargin(true); devicesLayout.setSpacing(true); // buttonLayout.setMargin(true); // buttonLayout.setSpacing(true); // buttonLayout.addComponent(add); BeanItemContainer<BookingBean> booking = getDeletedBookings(); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(booking); gpc.addGeneratedProperty("restore", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 4082425701384202280L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Restore"; // The caption } @Override public Class<String> getType() { return String.class; } }); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 1307493624895857513L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Purge"; // The caption } @Override public Class<String> getType() { return String.class; } }); devicesGridTrash = new Grid(gpc); // Create a grid devicesGridTrash.setWidth("100%"); devicesGridTrash.setSelectionMode(SelectionMode.SINGLE); devicesGridTrash.getColumn("delete").setRenderer(new HtmlRenderer()); devicesGridTrash.getColumn("restore").setRenderer(new HtmlRenderer()); setRenderers(devicesGridTrash); devicesGridTrash.setColumnOrder("ID", "deviceName", "service", "start", "end", "username", "phone", "price"); // Render a button that deletes the data row (item) /* * devicesGrid.addColumn("delete", FontIcon.class).setWidth(35) .setRenderer(new * FontIconRenderer(new RendererClickListener() { * * @Override public void click(RendererClickEvent e) { Notification.show("Deleted item " + * e.getItemId()); } })); */ devicesGridTrash.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 302628105070456680L; @Override public void click(RendererClickEvent event) { try { Window cd = new Window("Purge Booking"); cd.setHeight("200px"); cd.setWidth("400px"); cd.setResizable(false); GridLayout dialogLayout = new GridLayout(3, 3); Button okButton = new Button("Yes"); okButton.addStyleName(ValoTheme.BUTTON_DANGER); Button cancelButton = new Button("No, I'm actually not sure!"); cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); Label information = new Label("Are you sure you want to purge this item?"); information.addStyleName(ValoTheme.LABEL_NO_MARGIN); okButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 3739260172118651857L; @Override public void buttonClick(ClickEvent okEvent) { purgeBooking((BookingBean) event.getItemId()); cd.close(); Notification("The booking was purged!", "At the end, you are the admin, you have the power.", ""); } }); cancelButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = -3931200823633220160L; @Override public void buttonClick(ClickEvent okEvent) { cd.close(); } }); dialogLayout.addComponent(information, 0, 0, 2, 0); dialogLayout.addComponent(okButton, 0, 1); dialogLayout.addComponent(cancelButton, 1, 1); dialogLayout.setMargin(true); dialogLayout.setSpacing(true); cd.setContent(dialogLayout); cd.center(); UI.getCurrent().addWindow(cd); } catch (Exception e) { e.printStackTrace(); } FieldGroup fieldGroup = devicesGridTrash.getEditorFieldGroup(); fieldGroup.addCommitHandler(new FieldGroup.CommitHandler() { /** * */ private static final long serialVersionUID = 3799806709907688919L; @Override public void preCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { } @Override public void postCommit(FieldGroup.CommitEvent commitEvent) throws FieldGroup.CommitException { Notification("Successfully Updated", "Selected values are updated in the database. If it was a mistake, please remind that there is no 'undo' functionality yet.", "success"); refreshGrid(); } private void refreshGrid() { getDeletedBookings(); } }); } })); devicesGridTrash.getColumn("restore") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = -9104571186503913834L; @Override public void click(RendererClickEvent event) { restoreBooking((BookingBean) event.getItemId()); } })); // devicesGrid.setEditorEnabled(true); // devicesLayout.addComponent(buttonLayout); devicesLayout.addComponent(devicesGridTrash); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }
From source file:facs.components.Booking.java
License:Open Source License
private Component myUpcomingBookings() { VerticalLayout devicesLayout = new VerticalLayout(); // devicesLayout.setCaption("My Bookings"); // there will now be space around the test component // components added to the test component will now not stick together but have space between // them/*from w w w. ja va2s . c o m*/ devicesLayout.setMargin(true); devicesLayout.setSpacing(true); Date serverTime = new WebBrowser().getCurrentDate(); Date nextDayTime = new Date(serverTime.getTime() + (1000 * 60 * 60 * 24)); BeanItemContainer<BookingBean> users = getMyUpcomingBookings(bookingModel.getLDAP(), nextDayTime); // System.out.println(bookingModel.getLDAP()); GeneratedPropertyContainer gpc = new GeneratedPropertyContainer(users); gpc.addGeneratedProperty("delete", new PropertyValueGenerator<String>() { /** * */ private static final long serialVersionUID = 1263377339178640406L; @Override public String getValue(Item item, Object itemId, Object propertyId) { // return FontAwesome.TRASH_O.getHtml(); // The caption return "Trash"; // The caption } @Override public Class<String> getType() { return String.class; } }); /* * * try { * * FreeformQuery query = new FreeformQuery( * "SELECT * FROM booking INNER JOIN user ON booking.user_ldap = user.user_ldap WHERE deleted IS NULL AND booking.user_ldap ='" * + bookingModel.getLDAP() + "';", DBManager.getDatabaseInstanceAlternative(), "booking_id"); * SQLContainer container = new SQLContainer(query); * * // System.out.println("Print Container: " + container.size()); * container.setAutoCommit(isEnabled()); * * myBookings = new Grid(container); * * } catch (Exception e) { e.printStackTrace(); } * * myBookings.setColumnOrder("booking_id", "confirmation", "device_name", "service", "start", * "end", "kostenstelle", "price", "project"); * * myBookings.removeColumn("user_ldap"); myBookings.removeColumn("timestamp"); * myBookings.removeColumn("deleted"); myBookings.removeColumn("user_name"); * myBookings.removeColumn("group_id"); myBookings.removeColumn("workgroup_id"); * myBookings.removeColumn("email"); myBookings.removeColumn("phone"); * myBookings.removeColumn("admin_panel"); myBookings.removeColumn("user_id"); * * myBookings.getColumn("booking_id").setHeaderCaption("Booking ID"); */ upcomingBookings = new Grid(gpc); // Create a grid upcomingBookings.setStyleName("my-style"); upcomingBookings.setWidth("100%"); upcomingBookings.setSelectionMode(SelectionMode.SINGLE); upcomingBookings.setEditorEnabled(false); upcomingBookings.setColumnOrder("ID", "confirmation", "deviceName", "service", "start", "end", "username", "phone", "price"); upcomingBookings.getColumn("price").setHeaderCaption("Approx. Price"); // System.out.println(myBookings.getColumns()); setRenderers(upcomingBookings); devicesLayout.addComponent(upcomingBookings); upcomingBookings.getColumn("delete") .setRenderer(new ButtonRenderer(new ClickableRenderer.RendererClickListener() { /** * */ private static final long serialVersionUID = 302628105070456680L; @Override public void click(RendererClickEvent event) { try { Window cd = new Window("Delete Booking"); cd.setHeight("200px"); cd.setWidth("400px"); cd.setResizable(false); GridLayout dialogLayout = new GridLayout(3, 3); Button okButton = new Button("Yes"); okButton.addStyleName(ValoTheme.BUTTON_DANGER); Button cancelButton = new Button("No, I'm actually not sure!"); cancelButton.addStyleName(ValoTheme.BUTTON_PRIMARY); Label information = new Label("Are you sure you want to trash this item?"); information.addStyleName(ValoTheme.LABEL_NO_MARGIN); okButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = 1778157399909757369L; @Override public void buttonClick(ClickEvent okEvent) { purgeBooking((BookingBean) event.getItemId()); booking.setSelectedTab(myUpcomingBookings()); cd.close(); showNotification("The booking was deleted!", "You wanted to delete an upcoming booking and it wasn't within the next 24 hours. All good, item purged."); } }); cancelButton.addClickListener(new Button.ClickListener() { /** * */ private static final long serialVersionUID = -8957620319158438769L; @Override public void buttonClick(ClickEvent okEvent) { cd.close(); } }); dialogLayout.addComponent(information, 0, 0, 2, 0); dialogLayout.addComponent(okButton, 0, 1); dialogLayout.addComponent(cancelButton, 1, 1); dialogLayout.setMargin(true); dialogLayout.setSpacing(true); cd.setContent(dialogLayout); cd.center(); UI.getCurrent().addWindow(cd); } catch (Exception e) { e.printStackTrace(); } } })); // TODO filtering // HeaderRow filterRow = devicesGrid.prependHeaderRow(); return devicesLayout; }
From source file:fr.amapj.view.views.permanence.mespermanences.grille.InscriptionPopupRoleDifferent.java
License:Open Source License
/** * Permet de dessiner le tableau //from w w w. j a v a 2 s . c o m */ public void drawTab(Tab tab) { GridLayout gl = new GridLayout(4, 1 + tab.lines.size()); gl.setWidth("800px"); gl.setSpacing(false); contentLayout.addComponent(gl); // Construction du titre Label l = new Label(tab.titre); l.addStyleName(tab.styleTitre); l.setWidth("100%"); gl.addComponent(l, 0, 0, 3, 0); List<TabLine> lines = tab.lines; for (int i = 0; i < lines.size(); i++) { TabLine line = lines.get(i); int height = computeHeight(line); // La taille minimale est de 36 pixels, pour les boutons inscrire / desincrire height = Math.max(height, 36); Label l1 = new Label(line.col1); l1.addStyleName(line.styleCol1); l1.setWidth("100%"); l1.setHeight(height + "px"); gl.addComponent(l1, 0, i + 1); Label l2 = new Label(line.col2); l2.addStyleName(line.styleCol2); l2.setWidth("100%"); l2.setHeight(height + "px"); gl.addComponent(l2, 1, i + 1); Label l3 = new Label(line.col3); l3.addStyleName(line.styleCol3); l3.setWidth("100%"); l3.setHeight(height + "px"); gl.addComponent(l3, 2, i + 1); if (line.col4 != null) { Button b = new Button(line.col4); b.addStyleName(line.styleCol4); b.addClickListener(e -> handleButton(line.role)); b.setWidth("100%"); gl.addComponent(b, 3, i + 1); gl.setComponentAlignment(b, Alignment.MIDDLE_CENTER); } else { Label l4 = new Label(""); l4.addStyleName(line.styleCol4); l4.setWidth("100%"); l4.setHeight(height + "px"); gl.addComponent(l4, 3, i + 1); } } }