List of usage examples for com.vaadin.ui Label setSizeUndefined
@Override public void setSizeUndefined()
From source file:de.symeda.sormas.ui.utils.EpiWeekAndDateFilterComponent.java
License:Open Source License
public EpiWeekAndDateFilterComponent(Button applyButton, boolean fillAutomatically, boolean showCaption, String infoText, Class<E> dateType, String dateTypePrompt, Enum<E> defaultDateType) { setSpacing(true);/*from w w w.ja v a 2 s .co m*/ Calendar c = Calendar.getInstance(); c.setTime(new Date()); dateFilterOptionFilter = new ComboBox(); dateTypeSelector = new ComboBox(); weekFromFilter = new ComboBox(); weekToFilter = new ComboBox(); dateFromFilter = new PopupDateField(); dateToFilter = new PopupDateField(); // Date filter options dateFilterOptionFilter.setWidth(200, Unit.PIXELS); dateFilterOptionFilter.addItems((Object[]) DateFilterOption.values()); dateFilterOptionFilter.setNullSelectionAllowed(false); dateFilterOptionFilter.select(DateFilterOption.EPI_WEEK); if (showCaption) { CssStyles.style(dateFilterOptionFilter, CssStyles.FORCE_CAPTION); } dateFilterOptionFilter.addValueChangeListener(e -> { if (e.getProperty().getValue() == DateFilterOption.DATE) { int newIndex = getComponentIndex(weekFromFilter); removeComponent(weekFromFilter); removeComponent(weekToFilter); addComponent(dateFromFilter, newIndex); addComponent(dateToFilter, newIndex + 1); if (fillAutomatically) { dateFromFilter.setValue(DateHelper.subtractDays(c.getTime(), 7)); } if (fillAutomatically) { dateToFilter.setValue(c.getTime()); } } else { int newIndex = getComponentIndex(dateFromFilter); removeComponent(dateFromFilter); removeComponent(dateToFilter); addComponent(weekFromFilter, newIndex); addComponent(weekToFilter, newIndex + 1); if (fillAutomatically) { weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (fillAutomatically) { weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } } }); addComponent(dateFilterOptionFilter); // New case date type selector if (dateType != null) { dateTypeSelector.setWidth(200, Unit.PIXELS); dateTypeSelector.addItems((Object[]) dateType.getEnumConstants()); if (dateTypePrompt != null) { dateTypeSelector.setInputPrompt(dateTypePrompt); } if (defaultDateType != null) { dateTypeSelector.select(defaultDateType); } if (showCaption) { CssStyles.style(dateTypeSelector, CssStyles.FORCE_CAPTION); } addComponent(dateTypeSelector); if (!StringUtils.isEmpty(infoText)) { Label infoLabel = new Label(VaadinIcons.INFO_CIRCLE.getHtml(), ContentMode.HTML); infoLabel.setSizeUndefined(); infoLabel.setDescription(infoText); CssStyles.style(infoLabel, CssStyles.LABEL_XLARGE, CssStyles.LABEL_SECONDARY); addComponent(infoLabel); } } // Epi week filter List<EpiWeek> epiWeekList = DateHelper.createEpiWeekList(c.get(Calendar.YEAR), c.get(Calendar.WEEK_OF_YEAR)); weekFromFilter.setWidth(200, Unit.PIXELS); for (EpiWeek week : epiWeekList) { weekFromFilter.addItem(week); } weekFromFilter.setNullSelectionAllowed(false); if (fillAutomatically) { weekFromFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (showCaption) { weekFromFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekFrom)); } if (applyButton != null) { weekFromFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } addComponent(weekFromFilter); weekToFilter.setWidth(200, Unit.PIXELS); for (EpiWeek week : epiWeekList) { weekToFilter.addItem(week); } weekToFilter.setNullSelectionAllowed(false); if (fillAutomatically) { weekToFilter.setValue(DateHelper.getEpiWeek(c.getTime())); } if (showCaption) { weekToFilter.setCaption(I18nProperties.getCaption(Captions.epiWeekTo)); } if (applyButton != null) { weekToFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } addComponent(weekToFilter); // Date filter dateFromFilter.setWidth(200, Unit.PIXELS); if (showCaption) { dateFromFilter.setCaption(I18nProperties.getCaption(Captions.from)); } if (applyButton != null) { dateFromFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } dateToFilter.setWidth(200, Unit.PIXELS); if (showCaption) { dateToFilter.setCaption(I18nProperties.getCaption(Captions.to)); } if (applyButton != null) { dateToFilter.addValueChangeListener(e -> { applyButton.addStyleName(ValoTheme.BUTTON_PRIMARY); }); } }
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. * /*w w w. j a va 2 s . co m*/ * 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:dhbw.ka.mwi.businesshorizon2.ui.initialscreen.InitialScreenViewImpl.java
License:Open Source License
public void createImportButton() { importButton = new VerticalLayout(); importButton.setWidth(150, com.vaadin.terminal.Sizeable.UNITS_PIXELS); importButton.setHeight(80, com.vaadin.terminal.Sizeable.UNITS_PIXELS); importButton.setStyleName("topBarButtonContainer"); UploadReceiver receiver = new UploadReceiver(eventBus); Upload upload = new Upload(null, receiver); upload.setButtonCaption(""); upload.setImmediate(true);/*from w w w . j a v a 2 s .c om*/ upload.addListener(receiver); upload.setStyleName("importButton"); upload.setWidth(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS); upload.setHeight(30, com.vaadin.terminal.Sizeable.UNITS_PIXELS); Label gap = new Label(); gap.setHeight("5px"); Label label = new Label("Projekte"); label.setStyleName("topBarButtonLabel"); label.setSizeUndefined(); Label label2 = new Label("importieren"); label2.setStyleName("topBarButtonLabel"); label2.setSizeUndefined(); VerticalLayout labelLayout = new VerticalLayout(); labelLayout.setHeight(45, com.vaadin.terminal.Sizeable.UNITS_PIXELS); labelLayout.setWidth(100, UNITS_PERCENTAGE); importButton.addComponent(upload); labelLayout.addComponent(label); labelLayout.addComponent(label2); importButton.addComponent(gap); importButton.addComponent(labelLayout); importButton.setComponentAlignment(upload, Alignment.TOP_CENTER); labelLayout.setComponentAlignment(label, Alignment.MIDDLE_CENTER); labelLayout.setComponentAlignment(label2, Alignment.MIDDLE_CENTER); }
From source file:edu.kit.dama.ui.commons.util.PaginationLayout.java
License:Apache License
/** * Update the layout. This method is either called internally when scrolling * or/*from w w w.ja va 2s. co m*/ */ public final void update() { //remove all components (old result page and navigation) removeAllComponents(); //add current results renderPage(); //build pagination int pages = overallEntries / entriesPerPage; if (overallEntries % entriesPerPage > 0) { pages++; } final int overallPages = pages; HorizontalLayout navigation = new HorizontalLayout(); //add "JumpToFirstPage" button final NativeButton first = new NativeButton(); first.setIcon(firstIcon); if (firstIcon == null) { first.setCaption("<<"); } first.setDescription("First Page"); first.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = 0; update(); } }); //add "PreviousPage" button final NativeButton prev = new NativeButton(); prev.setIcon(prevIcon); if (prevIcon == null) { prev.setCaption("<"); } prev.setDescription("Previous Page"); prev.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage > 0) { currentPage--; update(); } } }); //add "NextPage" button final NativeButton next = new NativeButton(); next.setIcon(nextIcon); if (nextIcon == null) { next.setCaption(">"); } next.setDescription("Next Page"); next.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage + 1 < overallPages) { currentPage++; update(); } } }); //add "JumpToLastPage" button final NativeButton last = new NativeButton(); last.setIcon(endIcon); if (endIcon == null) { next.setCaption(">>"); } last.setDescription("Last Page"); last.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = overallPages - 1; update(); } }); //enable/disable buttons depending on the current page if (overallPages == 0) { first.setEnabled(false); prev.setEnabled(false); next.setEnabled(false); last.setEnabled(false); } else { first.setEnabled(!(currentPage == 0) || !(overallPages < 2)); prev.setEnabled(!(currentPage == 0) || !(overallPages < 2)); next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); } //at first, put the page size selection box into the navigation final ComboBox entriesPerPageBox = new ComboBox(); entriesPerPageBox.setItemCaptionPropertyId("name"); entriesPerPageBox.addContainerProperty("name", String.class, null); entriesPerPageBox.addItem(5); entriesPerPageBox.getContainerProperty(5, "name").setValue("5 Entries / Page"); entriesPerPageBox.addItem(10); entriesPerPageBox.getContainerProperty(10, "name").setValue("10 Entries / Page"); entriesPerPageBox.addItem(15); entriesPerPageBox.getContainerProperty(15, "name").setValue("15 Entries / Page"); entriesPerPageBox.addItem(20); entriesPerPageBox.getContainerProperty(20, "name").setValue("20 Entries / Page"); entriesPerPageBox.setValue(entriesPerPage); entriesPerPageBox.setNullSelectionAllowed(false); entriesPerPageBox.setImmediate(true); entriesPerPageBox.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { entriesPerPage = (Integer) entriesPerPageBox.getValue(); update(); } }); navigation.addComponent(entriesPerPageBox); //filler labels are added to the beginning and to the end to keep the navigation in the middle Label leftFiller = new Label(); leftFiller.setWidth("25px"); navigation.addComponent(leftFiller); navigation.addComponent(first); navigation.addComponent(prev); //Show max. 10 pages at once for performance and layout reasons. //If there are more than 10 pages, "move" the to show 10 pages based on the current page. int start = currentPage - 5; start = (start < 0) ? 0 : start; int end = start + 10; end = (end > pages) ? pages : end; if (end - start < 10 && pages > 10) { start = end - 10; } if (overallPages == 0) { Label noEntryLabel = new Label("<i>No entries</i>", Label.CONTENT_XHTML); //noEntryLabel.setWidth("80px"); noEntryLabel.setSizeUndefined(); navigation.addComponent(noEntryLabel); navigation.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER); } //build the actual page entries for (int i = start; i < end; i++) { if (i == currentPage) { //the current page is marked with a special style Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", Label.CONTENT_XHTML); pageLink.setStyleName("currentpage"); pageLink.setWidth("15px"); navigation.addComponent(pageLink); navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } else { //otherwise normal links are added, click-events are handled via LayoutClickListener Link pageLink = new Link(Integer.toString(i + 1), null); navigation.addComponent(pageLink); navigation.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } } //add right navigation buttons navigation.addComponent(next); navigation.addComponent(last); //...and fill the remaining space Label rightFiller = new Label(); navigation.addComponent(rightFiller); // navigation.setExpandRatio(leftFiller, 1.0f); navigation.setExpandRatio(rightFiller, 1.0f); navigation.setSpacing(true); //put everything ot the middle navigation.setComponentAlignment(first, Alignment.MIDDLE_CENTER); navigation.setComponentAlignment(prev, Alignment.MIDDLE_CENTER); navigation.setComponentAlignment(next, Alignment.MIDDLE_CENTER); navigation.setComponentAlignment(last, Alignment.MIDDLE_CENTER); //add layout click listener to be able to navigate by clicking the single pages navigation.addListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { // Get the child component which was clicked Component child = event.getChildComponent(); if (child == null) { // Not over any child component } else { // Over a child component if (child instanceof Link) { // Over a valid child element currentPage = Integer.parseInt(((Link) child).getCaption()) - 1; update(); } } } }); //finalize navigation.setWidth("100%"); navigation.setHeight("25px"); //add navigation and align it right below the result page addComponent(page); setExpandRatio(page, 1f); if (overallEntries > 0) { addComponent(navigation); setComponentAlignment(navigation, Alignment.BOTTOM_CENTER); setExpandRatio(navigation, .05f); } requestRepaint(); }
From source file:edu.kit.dama.ui.components.ConfirmationWindow7.java
License:Apache License
/** * Builds a customized subwindow <b>ConfirmationWindow</b> that allows the * user to confirm his previously requested action. * * @param pTitle The title of the window. * @param pMessage The message shown in the window. * @param pOptionType The type of the window (OK or YES_NO) which defines the * visible buttons./* w ww . j a v a 2s . c o m*/ * @param pMessageType The message type (INFORMATION, WARNING, ERROR) which * determines the icon. If pMessageType is null, no icon will be shown. * @param pListener The listener which receives the result if a button was * pressed or the window was closed. * */ ConfirmationWindow7(String pTitle, String pMessage, OPTION_TYPE pOptionType, MESSAGE_TYPE pMessageType, IConfirmationWindowListener7 pListener) { this.listener = pListener; //basic setup //set caption depending on type String caption = pTitle; if (caption == null) { if (pMessageType != null) { switch (pMessageType) { case QUESTION: caption = DEFAULT_TITLE; break; case INFORMATION: caption = "Information"; break; case WARNING: caption = "Warning"; break; case ERROR: caption = "Error"; break; } } else { //no type provided...use default title caption = DEFAULT_TITLE; } } setCaption(caption); setModal(true); center(); // Build line of buttons depending on pOptionType HorizontalLayout buttonLine = new HorizontalLayout(); buttonLine.setSpacing(true); buttonLine.setWidth("100%"); //add spacer Label spacer = new Label(); buttonLine.addComponent(spacer); //add buttons if (OPTION_TYPE.YES_NO_OPTION.equals(pOptionType)) { buttonLine.addComponent(buildYesButton("Yes")); buttonLine.addComponent(buildNoButton()); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); buttonLine.setComponentAlignment(noButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the YES button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to the NO button noButton.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); } else { buttonLine.addComponent(buildYesButton("OK")); buttonLine.setComponentAlignment(yesButton, Alignment.MIDDLE_RIGHT); //Assign ENTER to the OK button yesButton.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); //Assign ESC to close the dialog setCloseShortcut(ShortcutAction.KeyCode.ESCAPE, null); } buttonLine.setExpandRatio(spacer, 1.0f); //determine the icon depending on pMessageType ThemeResource icon = null; if (pMessageType != null) { switch (pMessageType) { case QUESTION: icon = new ThemeResource("img/24x24/question.png"); break; case INFORMATION: icon = new ThemeResource("img/24x24/information.png"); break; case WARNING: icon = new ThemeResource("img/24x24/warning.png"); break; case ERROR: icon = new ThemeResource("img/24x24/forbidden.png"); break; } } Component iconComponent = new Label(); if (icon != null) { //icon was set, overwrite icon component iconComponent = new Image(null, icon); } //build the message label Label message = new Label(pMessage, ContentMode.HTML); message.setSizeUndefined(); //build the main layout GridLayout mainLayout = new UIUtils7.GridLayoutBuilder(2, 2) .addComponent(iconComponent, Alignment.TOP_LEFT, 0, 0, 1, 1).addComponent(message, 1, 0, 1, 1) .addComponent(buttonLine, 0, 1, 2, 1).getLayout(); mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setColumnExpandRatio(0, .05f); mainLayout.setColumnExpandRatio(1, 1f); mainLayout.setRowExpandRatio(0, 1f); mainLayout.setRowExpandRatio(1, .05f); setContent(mainLayout); //add the close listener addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { fireCloseEvents(RESULT.CANCEL); } }); }
From source file:edu.kit.dama.ui.repo.components.PaginationPanel.java
License:Apache License
/** * Build the navigation layout including the appropriate buttons to navigate * through the pagination pages.//from w ww. ja v a 2 s .c om * * @return The navigation layout component. */ private HorizontalLayout buildNavigationComponent() { HorizontalLayout result = new HorizontalLayout(); //add "JumpToFirstPage" button final NativeButton first = new NativeButton(); first.setIcon(new ThemeResource("img/16x16/beginning.png")); first.setDescription("First Page"); first.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = 0; updatePage(); } }); //add "PreviousPage" button final NativeButton prev = new NativeButton(); prev.setIcon(new ThemeResource("img/16x16/prev.png")); prev.setDescription("Previous Page"); prev.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage > 0) { currentPage--; updatePage(); } } }); //add "NextPage" button final NativeButton next = new NativeButton(); next.setDescription("Next Page"); next.setIcon(new ThemeResource("img/16x16/next.png")); next.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (currentPage + 1 < overallPages) { currentPage++; updatePage(); } } }); //add "JumpToLastPage" button final NativeButton last = new NativeButton(); last.setDescription("Last Page"); last.setIcon(new ThemeResource("img/16x16/end.png")); last.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { currentPage = overallPages - 1; updatePage(); } }); //enable/disable buttons depending on the current page if (overallPages == 0) { first.setEnabled(false); prev.setEnabled(false); next.setEnabled(false); last.setEnabled(false); } else { first.setEnabled(!(currentPage == 0) || !(overallPages < 2)); prev.setEnabled(!(currentPage == 0) || !(overallPages < 2)); next.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); last.setEnabled(!(currentPage == overallPages - 1) || !(overallPages < 2)); } Label leftFiller = new Label(); result.addComponent(leftFiller); result.setExpandRatio(leftFiller, 1.0f); result.addComponent(first); result.addComponent(prev); int start = currentPage - 5; start = (start < 0) ? 0 : start; int end = start + 10; end = (end > overallPages) ? overallPages : end; if (end - start < 10 && overallPages > 10) { start = end - 10; } if (overallPages == 0) { Label noEntryLabel = new Label("<i>No entries</i>", ContentMode.HTML); //noEntryLabel.setWidth("80px"); noEntryLabel.setSizeUndefined(); result.addComponent(noEntryLabel); result.setComponentAlignment(noEntryLabel, Alignment.MIDDLE_CENTER); } //build the actual page entries for (int i = start; i < end; i++) { if (i == currentPage) { //the current page is marked with a special style Label pageLink = new Label("<b>" + Integer.toString(i + 1) + "</b>", ContentMode.HTML); pageLink.setStyleName("currentpage"); pageLink.setWidth("15px"); result.addComponent(pageLink); result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } else { //otherwise normal links are added, click-events are handled via LayoutClickListener Link pageLink = new Link(Integer.toString(i + 1), null); result.addComponent(pageLink); result.setComponentAlignment(pageLink, Alignment.MIDDLE_CENTER); } } //add right navigation buttons result.addComponent(next); result.addComponent(last); //...and fill the remaining space Label rightFiller = new Label(); result.addComponent(rightFiller); result.setExpandRatio(rightFiller, 1.0f); result.setSpacing(true); //put everything ot the middle result.setComponentAlignment(first, Alignment.MIDDLE_CENTER); result.setComponentAlignment(prev, Alignment.MIDDLE_CENTER); result.setComponentAlignment(next, Alignment.MIDDLE_CENTER); result.setComponentAlignment(last, Alignment.MIDDLE_CENTER); //add layout click listener to be able to navigate by clicking the single pages result.addLayoutClickListener(new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { // Get the child component which was clicked Component child = event.getChildComponent(); if (child == null) { // Not over any child component } else // Over a child component { if (child instanceof Link) { } } } }); //finalize result.setWidth("100%"); result.setHeight("25px"); return result; }
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);/* ww w.ja 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.components.Leaderboard.java
License:Open Source License
private void maybeShowMoveSelector(HorizontalLayout hl) { Move m = Move.getCurrentMoveTL();//from w w w .ja v a 2s. c o m int thisMove = m.getNumber(); if (thisMove <= 1) return; Label lab = null; hl.addComponent(lab = new Label("Showing scores from ")); lab.setSizeUndefined(); hl.setComponentAlignment(lab, Alignment.MIDDLE_CENTER); hl.addComponent(lab = new Label()); lab.setWidth("5px"); ArrayList<String> mvLst = new ArrayList<String>(); int i = 1; while (i <= thisMove) { mvLst.add("Round " + i++); } mvLst.add(COMBINED); NativeSelect sel = new NativeSelect(null, mvLst); sel.setNullSelectionAllowed(false); sel.setValue("Round " + thisMove); sel.setImmediate(true); sel.addValueChangeListener(new MoveListener()); hl.addComponent(sel); hl.setComponentAlignment(sel, Alignment.MIDDLE_CENTER); }
From source file:edu.nps.moves.mmowgli.modules.administration.GameDesignPanel.java
License:Open Source License
public void initGuiTL() { tabSh.setHeight("100%"); tabSh.setWidth("930px"); HorizontalLayout topHL = new HorizontalLayout(); topHL.setSpacing(true);//from w ww .j av a 2 s.com topHL.setMargin(true); Label lab; topHL.addComponent(lab = new Label()); lab.setWidth("1px"); topHL.setExpandRatio(lab, 0.5f); topHL.addComponent(lab = new Label("Round being edited:")); lab.setSizeUndefined(); topHL.addComponent(moveSelector = new MoveSelector(null)); moveSelector.addValueChangeListener(new MoveSelectorListener()); topHL.addComponent( runningMoveWarningLabel = new HtmlLabel("<font color='red'><i>Active game round!</i></font>")); runningMoveWarningLabel.setSizeUndefined(); runningMoveWarningLabel.setVisible(AbstractGameBuilderPanel.isRunningMoveTL(moveBeingEdited)); topHL.addComponent(newMoveButt = new NativeButton("Add new round to game", new NewMoveListener())); topHL.addComponent(lab = new Label()); lab.setWidth("1px"); topHL.setExpandRatio(lab, 0.5f); topHL.setWidth("100%"); addComponent(topHL); addComponent(lab = new Label("The currently active round is set through the Game Administrator menu")); lab.setSizeUndefined(); setComponentAlignment(lab, Alignment.TOP_CENTER); tabSh.addTab(titlesPan, "Game Titles"); tabSh.addTab(topCardsPan, "Top Card Types"); tabSh.addTab(subCardsPan, "Sub Card Types"); //tabSh.addTab(seedCardsPan, "Seed Card Initialization"); tabSh.addTab(chaptersPan, "Action Plan Headings"); addComponent(tabSh); titlesPan.initGui(); topCardsPan.initGui(); subCardsPan.initGui(); //seedCardsPan.initGui(); chaptersPan.initGui(); moveSelector.setMove(Game.getTL().getCurrentMove()); }
From source file:edu.nps.moves.mmowgli.modules.administration.GameDesignPanel.java
License:Open Source License
@SuppressWarnings("serial") @HibernateSessionThreadLocalConstructor//from www . java 2 s . c o m public PhasesEditPanel(Move move, GameDesignGlobals globs) { this.moveBeingEdited = move; setWidth("100%"); setSpacing(true); phaseBeingEdited = moveBeingEdited.getCurrentMovePhase(); tabSh = new TabSheet(); tabPanels.add(titlePan = new PhaseTitlesGameDesignPanel(phaseBeingEdited, auxListener, globs)); tabPanels.add(signupPan = new SignupHTMLGameDesignPanel(phaseBeingEdited, auxListener, globs)); tabPanels.add(loginPan = new LoginSignupGameDesignPanel(phaseBeingEdited, auxListener, globs)); tabPanels.add(welcomePan = new WelcomeScreenGameDesignPanel(phaseBeingEdited, auxListener, globs)); tabPanels.add(call2ActionPan = new CallToActionGameDesignPanel(phaseBeingEdited, auxListener, globs)); Label lab; addComponent(lab = new Label()); lab.setHeight("5px"); HorizontalLayout topHL = new HorizontalLayout(); topHL.setSpacing(true); topHL.addComponent(lab = new Label()); lab.setWidth("1px"); topHL.setExpandRatio(lab, 0.5f); topHL.addComponent(topLevelLabel = new Label()); setTopLabelText(moveBeingEdited); topLevelLabel.setSizeUndefined(); topHL.addComponent(phaseSelector = new PhaseSelector(null, Move.getCurrentMoveTL())); phaseSelector.addValueChangeListener(new PhaseComboListener()); topHL.addComponent( runningPhaseWarningLabel = new HtmlLabel("<font color='red'><i>Active game phase!</i></font>")); runningPhaseWarningLabel.setSizeUndefined(); runningPhaseWarningLabel.setVisible(AbstractGameBuilderPanel.isRunningPhaseTL(phaseBeingEdited)); topHL.addComponent(newPhaseButt = new NativeButton("Add new phase to round")); newPhaseButt.setEnabled(false); topHL.addComponent(lab = new Label()); lab.setWidth("1px"); topHL.setExpandRatio(lab, 0.5f); topHL.setWidth("100%"); addComponent(topHL); propagateCB = new CheckBox("Propagate new phase-dependent edits to all other phases in this round"); addComponent(propagateCB); setComponentAlignment(propagateCB, Alignment.MIDDLE_CENTER); propagateCB.setVisible(phaseBeingEdited.isPreparePhase()); addComponent(lab = new HtmlLabel( "<b>The currently running phase is set through the Game Administrator menu</b>")); lab.setSizeUndefined(); setComponentAlignment(lab, Alignment.TOP_CENTER); newPhaseButt.addClickListener(new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { HSess.init(); NewMovePhaseDialog dial = new NewMovePhaseDialog(moveBeingEdited); dial.addCloseListener(new CloseListener() { @Override public void windowClose(CloseEvent e) { Object key = HSess.checkInit(); phaseSelector.fillCombo(moveBeingEdited); HSess.checkClose(key); } }); dial.showDialog(); HSess.close(); } }); }