List of usage examples for com.vaadin.ui Window setModal
public void setModal(boolean modal)
From source file:de.uni_tuebingen.qbic.qbicmainportlet.LevelComponent.java
License:Open Source License
/** * Precondition: {DatasetView#table} has to be initialized. e.g. with * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the * Layout of this view./* w w w. jav a 2s . c o m*/ */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setWidth("100%"); // Table (containing datasets) section VerticalLayout tableSectionDatasets = new VerticalLayout(); VerticalLayout tableSectionSamples = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); HorizontalLayout sampletableSectionContent = new HorizontalLayout(); tableSectionContent.setMargin(new MarginInfo(false, false, false, false)); sampletableSectionContent.setMargin(new MarginInfo(false, false, false, false)); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); descriptionLabel.setWidth("100%"); tableSectionDatasets.addComponent(descriptionLabel); sampletableSectionContent.addComponent(sampleGrid); tableSectionContent.addComponent(this.datasetTable); tableSectionDatasets.setMargin(new MarginInfo(true, false, false, true)); tableSectionDatasets.setSpacing(true); tableSectionSamples.setMargin(new MarginInfo(true, false, true, true)); tableSectionSamples.setSpacing(true); tableSectionDatasets.addComponent(tableSectionContent); tableSectionSamples.addComponent(sampletableSectionContent); tableSectionSamples.addComponent(exportSamples); this.vert.addComponent(tableSectionDatasets); sampleGrid.setWidth("100%"); datasetTable.setWidth("100%"); tableSectionDatasets.setWidth("100%"); tableSectionSamples.setWidth("100%"); sampletableSectionContent.setWidth("100%"); tableSectionContent.setWidth("100%"); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, false, true)); buttonLayout.setHeight(null); buttonLayout.setSpacing(true); this.download.setEnabled(false); buttonLayout.setSpacing(true); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(true); } } }); Button uncheckAll = new Button("Unselect all datasets"); uncheckAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); buttonLayout.addComponent(exportData); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); String content = "<p> In case of multiple file selections, Project Browser will create a tar archive.</p>" + "<hr>" + "<p> If you need help on extracting a tar archive file, follow the tips below: </p>" + "<p>" + FontAwesome.WINDOWS.getHtml() + " Windows </p>" + "<p> To open/extract TAR file on Windows, you can use 7-Zip, Easy 7-Zip, PeaZip.</p>" + "<hr>" + "<p>" + FontAwesome.APPLE.getHtml() + " MacOS </p>" + "<p> To open/extract TAR file on Mac, you can use Mac OS built-in utility Archive Utility,<br> or third-part freeware. </p>" + "<hr>" + "<p>" + FontAwesome.LINUX.getHtml() + " Linux </p>" + "<p> You need to use command tar. The tar is the GNU version of tar archiving utility. <br> " + "To extract/unpack a tar file, type: $ tar -xvf file.tar</p>"; PopupView tooltip = new PopupView(new helpers.ToolTip(content)); tooltip.setHeight("44px"); HorizontalLayout help = new HorizontalLayout(); help.setSizeFull(); HorizontalLayout helpContent = new HorizontalLayout(); // helpContent.setSizeFull(); help.setMargin(new MarginInfo(false, false, false, true)); Label helpText = new Label("Attention: Click here before Download!"); helpContent.addComponent(new Label(FontAwesome.QUESTION_CIRCLE.getHtml(), ContentMode.HTML)); helpContent.addComponent(helpText); helpContent.addComponent(tooltip); helpContent.setSpacing(true); help.addComponent(helpContent); help.setComponentAlignment(helpContent, Alignment.TOP_CENTER); /** * prepare download. */ download.setResource(new ExternalResource("javascript:")); download.setEnabled(false); for (final Object itemId : this.datasetTable.getItemIds()) { setCheckedBox(itemId, (String) this.datasetTable.getItem(itemId).getItemProperty("CODE").getValue()); } this.datasetTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) datasetTable.getItem(event.getItemId()) .getItemProperty("isDirectory").getValue())) { String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) datasetTable.getItem(event.getItemId()) .getItemProperty("File Name").getValue(); URL url = null; try { Resource res = null; Object parent = datasetTable.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) datasetTable.getItem(parent) .getItemProperty("File Name").getValue(); try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } else { try { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, URLEncoder.encode(datasetFileName, "UTF-8")); } catch (UnsupportedEncodingException e) { // TODO Auto-generated catch block e.printStackTrace(); } } Window subWindow = new Window(); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.setSizeFull(); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); Boolean visualize = false; if (datasetFileName.endsWith(".pdf")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/pdf"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".png")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/png"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".qcML")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/xml"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".alleles")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".tsv")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".log")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".html")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/html"); res = streamres; visualize = true; } if (datasetFileName.endsWith(".GSvar")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("text/plain"); res = streamres; visualize = true; } if (visualize) { BrowserFrame frame = new BrowserFrame("", res); frame.setSizeFull(); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeUndefined(); subWindow.setHeight("75%"); subWindow.setWidth("75%"); subWindow.setResizable(false); frame.setSizeFull(); frame.setHeight("100%"); // frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS); // Open it in the UI ui.addWindow(subWindow); } } catch (MalformedURLException e) { LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s", datasetCode)); helpers.Utils.Notification("No file attached.", "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data", "error"); // Notification // .show( // "Given dataset has no file attached to it!! Please Contact your project manager. Or // check whether it already has some data", // Notification.Type.ERROR_MESSAGE); } } } }); this.vert.addComponent(help); this.vert.addComponent(buttonLayout); this.vert.addComponent(tableSectionSamples); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjInformationComponent.java
License:Open Source License
private void initUI() { vert = new VerticalLayout(); descHorz = new HorizontalLayout(); // horz = new HorizontalLayout(); statusPanel = new Panel(); descriptionPanel = new Panel(); datasetTable = buildFilterTable();/*from w w w . j a v a 2 s . c o m*/ peopleInCharge = new Accordion(); setResponsive(true); vert.setResponsive(true); descHorz.setResponsive(true); statusPanel.setResponsive(true); descriptionPanel.setResponsive(true); vert.setMargin(new MarginInfo(true, true, false, false)); setSizeFull(); vert.setSizeFull(); descHorz.setSizeFull(); statusPanel.setSizeFull(); descriptionPanel.setSizeFull(); investigator = new Label("", ContentMode.HTML); contactPerson = new Label("", ContentMode.HTML); projectManager = new Label("", ContentMode.HTML); final VerticalLayout layoutI = new VerticalLayout(investigator); final VerticalLayout layoutC = new VerticalLayout(contactPerson); final VerticalLayout layoutP = new VerticalLayout(projectManager); layoutI.setMargin(true); layoutC.setMargin(true); layoutP.setMargin(true); peopleInCharge.addTab(layoutI, "Investigator"); peopleInCharge.addTab(layoutC, "Contact Person"); peopleInCharge.addTab(layoutP, "Project Manager"); descEdit = new Button("Edit"); descEdit.setIcon(FontAwesome.PENCIL); descEdit.setStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); descEdit.setResponsive(true); descEdit.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { changeMetadata.updateUI(projectBean); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subContent.addComponent(changeMetadata); Window subWindow = new Window("Edit Metadata"); subWindow.setContent(subContent); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setIcon(FontAwesome.PENCIL); subWindow.setHeight("75%"); subWindow.setResizable(false); // subWindow.setSizeFull(); subWindow.addCloseListener(new CloseListener() { /** * */ private static final long serialVersionUID = -1329152609834711109L; @Override public void windowClose(CloseEvent e) { ProjectBean updatedBean = datahandler.getProjectFromDB(projectBean.getId()); updateUI(updatedBean, projectType); } }); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(subWindow); } }); // horz.addComponent(descEdit); // horz.setComponentAlignment(descEdit, Alignment.TOP_RIGHT); // horz.setExpandRatio(investigator, 0.4f); // horz.setExpandRatio(contactPerson, 0.4f); // horz.setExpandRatio(descEdit, 0.2f); contact = new Label("", ContentMode.HTML); patientInformation = new Label("No patient information provided.", ContentMode.HTML); experimentLabel = new Label(""); statusContent = new VerticalLayout(); hlaTypeLabel = new Label("Not available.", ContentMode.HTML); hlaTypeLabel.setStyleName("patientview"); this.setCompositionRoot(vert); // this.setCompositionRoot(mainLayout); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.ProjInformationComponent.java
License:Open Source License
/** * Precondition: {DatasetView#table} has to be initialized. e.g. with * {DatasetView#buildFilterTable} If it is not, strange behaviour has to be expected. builds the * Layout of this view.//from w w w.j a va 2 s .co m */ private void buildLayout(Boolean dataAvailable, String projectType) { vert.removeAllComponents(); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); VerticalLayout projDescription = new VerticalLayout(); VerticalLayout projDescriptionContent = new VerticalLayout(); tableSectionContent.setMargin(new MarginInfo(false, false, false, false)); projDescriptionContent.setMargin(new MarginInfo(false, false, false, false)); descHorz.addComponent(descContent); descHorz.addComponent(descEdit); descHorz.setComponentAlignment(descEdit, Alignment.TOP_RIGHT); descHorz.setExpandRatio(descContent, 0.9f); descHorz.setExpandRatio(descEdit, 0.1f); projDescriptionContent.addComponent(descHorz); projDescriptionContent.addComponent(peopleInCharge); // descContent.setWidth("80%"); projDescriptionContent.addComponent(descriptionPanel); projDescriptionContent.addComponent(statusPanel); // longDescription.setWidth("80%"); // projDescriptionContent.addComponent(experimentLabel); // projDescriptionContent.addComponent(statusContent); // statusContent.setSpacing(true); // statusContent.setMargin(new MarginInfo(false, false, false, true)); if (projectType.equals("patient")) { String patientInfo = ""; Boolean available = false; SearchCriteria sampleSc = new SearchCriteria(); sampleSc.addMatchClause( MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, "Q_BIOLOGICAL_ENTITY")); SearchCriteria projectSc = new SearchCriteria(); projectSc.addMatchClause( MatchClause.createAttributeMatch(MatchClauseAttribute.PROJECT, projectBean.getCode())); sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(projectSc)); SearchCriteria experimentSc = new SearchCriteria(); experimentSc.addMatchClause(MatchClause.createAttributeMatch(MatchClauseAttribute.TYPE, model.ExperimentType.Q_EXPERIMENTAL_DESIGN.name())); sampleSc.addSubCriteria(SearchSubCriteria.createExperimentCriteria(experimentSc)); List<ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample> samples = datahandler.getOpenBisClient() .getFacade().searchForSamples(sampleSc); for (ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Sample sample : samples) { if (sample.getProperties().get("Q_ADDITIONAL_INFO") != null) { available = true; String[] splitted = sample.getProperties().get("Q_ADDITIONAL_INFO").split(";"); for (String s : splitted) { String[] splitted2 = s.split(":"); patientInfo += String.format("<p><u>%s</u>: %s </p> ", splitted2[0], splitted2[1]); } } } if (available) { patientInformation.setValue(patientInfo); } else { patientInformation.setValue("No patient information provided."); } updateHLALayout(); projDescriptionContent.addComponent(patientInformation); projDescriptionContent.addComponent(hlaTypeLabel); // Vaccine Designer /* * Button vaccineDesigner = new Button("Vaccine Designer"); * vaccineDesigner.setStyleName(ValoTheme.BUTTON_PRIMARY); * vaccineDesigner.setIcon(FontAwesome.CUBES); * * vaccineDesigner.addClickListener(new ClickListener() { * * @Override public void buttonClick(ClickEvent event) { * * ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); StringBuilder * sb = new StringBuilder("type="); sb.append("vaccinedesign"); sb.append("&"); * sb.append("id="); sb.append(projectBean.getId()); message.add(sb.toString()); * message.add(VaccineDesignerView.navigateToLabel); state.notifyObservers(message); */ // UI.getCurrent().getNavigator() // .navigateTo(String.format(VaccineDesignerView.navigateToLabel)); // } // }); // projDescriptionContent.addComponent(vaccineDesigner); } projDescriptionContent.addComponent(tsvDownloadContent); projDescription.addComponent(projDescriptionContent); projDescriptionContent.setSpacing(true); projDescription.setMargin(new MarginInfo(false, false, true, true)); projDescription.setWidth("100%"); projDescription.setSpacing(true); // descriptionLabel.setWidth("100%"); // tableSection.addComponent(descriptionLabel); tableSectionContent.addComponent(this.datasetTable); projDescriptionContent.addComponent(contact); tableSection.setMargin(new MarginInfo(true, false, false, true)); tableSection.setSpacing(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(projDescription); datasetTable.setWidth("100%"); tableSection.setWidth("100%"); tableSectionContent.setWidth("100%"); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, false)); buttonLayout.setHeight(null); // buttonLayout.setWidth("100%"); buttonLayout.setSpacing(true); this.download.setEnabled(false); buttonLayout.setSpacing(true); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(true); } } }); Button uncheckAll = new Button("Unselect all datasets"); uncheckAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : datasetTable.getItemIds()) { ((CheckBox) datasetTable.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); buttonLayout.addComponent(this.download); /** * prepare download. */ download.setResource(new ExternalResource("javascript:")); download.setEnabled(false); for (final Object itemId : this.datasetTable.getItemIds()) { setCheckedBox(itemId, (String) this.datasetTable.getItem(itemId).getItemProperty("CODE").getValue()); } /* * Send message that in datasetview the following was selected. WorkflowViews get those messages * and save them, if it is valid information for them. */ this.datasetTable.addValueChangeListener(new ValueChangeListener() { /** * */ private static final long serialVersionUID = -3554627008191389648L; @Override public void valueChange(ValueChangeEvent event) { // Nothing selected or more than one selected. Set<Object> selectedValues = (Set<Object>) event.getProperty().getValue(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("DataSetView"); if (selectedValues != null && selectedValues.size() == 1) { Iterator<Object> iterator = selectedValues.iterator(); Object next = iterator.next(); String datasetType = (String) datasetTable.getItem(next).getItemProperty("Dataset Type") .getValue(); message.add(datasetType); String project = (String) datasetTable.getItem(next).getItemProperty("Project").getValue(); String space = datahandler.getOpenBisClient().getProjectByCode(project).getSpaceCode();// .getIdentifier().split("/")[1]; message.add(project); message.add((String) datasetTable.getItem(next).getItemProperty("Sample").getValue()); // message.add((String) table.getItem(next).getItemProperty("Sample Type").getValue()); message.add((String) datasetTable.getItem(next).getItemProperty("dl_link").getValue()); message.add((String) datasetTable.getItem(next).getItemProperty("File Name").getValue()); message.add(space); // state.notifyObservers(message); } else { message.add("null"); } // TODO // state.notifyObservers(message); } }); this.datasetTable.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick()) { String datasetCode = (String) datasetTable.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) datasetTable.getItem(event.getItemId()) .getItemProperty("File Name").getValue(); URL url; try { Resource res = null; Object parent = datasetTable.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) datasetTable.getItem(parent) .getItemProperty("File Name").getValue(); url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, parentDatasetFileName + "/" + datasetFileName); } else { url = datahandler.getOpenBisClient().getUrlForDataset(datasetCode, datasetFileName); } Window subWindow = new Window(); VerticalLayout subContent = new VerticalLayout(); subContent.setMargin(true); subWindow.setContent(subContent); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); Boolean visualize = false; if (datasetFileName.endsWith(".pdf")) { QcMlOpenbisSource re = new QcMlOpenbisSource(url); StreamResource streamres = new StreamResource(re, datasetFileName); streamres.setMIMEType("application/pdf"); res = streamres; visualize = true; } if (visualize) { LOGGER.debug("Is resource null?: " + String.valueOf(res == null)); BrowserFrame frame = new BrowserFrame("", res); frame.setSizeFull(); subContent.addComponent(frame); // Center it in the browser window subWindow.center(); subWindow.setModal(true); subWindow.setSizeFull(); frame.setHeight((int) (ui.getPage().getBrowserWindowHeight() * 0.9), Unit.PIXELS); // Open it in the UI ui.addWindow(subWindow); } } catch (MalformedURLException e) { LOGGER.error(String.format("Visualization failed because of malformedURL for dataset: %s", datasetCode)); Notification.show( "Given dataset has no file attached to it!! Please Contact your project manager. Or check whether it already has some data", Notification.Type.ERROR_MESSAGE); } } } }); // this.vert.addComponent(buttonLayout); if (dataAvailable) { this.vert.addComponent(tableSection); tableSection.addComponent(buttonLayout); projDescription.setMargin(new MarginInfo(false, false, false, true)); } }
From source file:dev.DevUI.java
License:Open Source License
@Override protected void init(VaadinRequest request) { final VerticalLayout mainLayout = new VerticalLayout(); mainLayout.setSpacing(true);/*from w w w . j av a 2 s . c o m*/ mainLayout.setMargin(true); PluploadManager mgr = createUploadManager("Manager 1"); PluploadManager mgr2 = createUploadManager("Manager 2"); PluploadManager mgr3 = createChunkingUploadManager("Manager 3"); mgr.getUploader().addFilter(new PluploadFilter("music", "mp3,flac")); VerticalLayout dropZone = new VerticalLayout() { { addComponent(new Label("Additional drop zone for music files")); setId("music-drop-zone"); } }; mgr.getUploader().addDropZone(dropZone); mgr2.getUploader().addFilter(new PluploadFilter("images", "jpg, jpeg, png")); mgr2.getUploader().setImageResize( new PluploadImageResize().setEnabled(true).setCrop(true).setHeight(200).setWidth(400)); mainLayout.addComponent(mgr); mainLayout.addComponent(dropZone); mainLayout.addComponent(mgr2); mainLayout.addComponent(mgr3); PluploadField<File> field = createUploadField(); final Form form = new Form(); form.addField("file", field); field.addValidator(new NullValidator("file must not be null", false)); Button submit = new Button("commit form"); submit.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { form.commit(); } }); mainLayout.addComponent(form); mainLayout.addComponent(submit); PluploadField<byte[]> byteField = createByteUploadField(); mainLayout.addComponent(byteField); final Plupload uploader = createSimpleUploader(); uploader.setEnabled(false); Button b = new Button("toggle Enabled!", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { uploader.setEnabled(!uploader.isEnabled()); } }); mainLayout.addComponent(b); mainLayout.addComponent(uploader); final Counter c = new Counter(); final Button.ClickListener l = new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Window w = new Window("win"); if (c.get() < 5) { w.setContent(new Button("win", this)); c.increment(); } else { Field f = createUploadField(); w.setContent(f); c.reset(); } w.setWidth("400px"); w.setHeight("200px"); getUI().addWindow(w); } }; Button win = new Button("Win"); win.addClickListener(l); mainLayout.addComponent(win); Button modal = new Button("modal"); modal.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Window w = new Window("modal"); final PluploadField f = createUploadField(); w.addCloseListener(new Window.CloseListener() { @Override public void windowClose(Window.CloseEvent e) { Notification.show("closed modal"); f.getUploader().destroy(); } }); VerticalLayout lay = new VerticalLayout(); lay.addComponent(f); lay.addComponent(new Button("destroy", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { f.getUploader().destroy(); } })); w.setContent(lay); w.setModal(true); getUI().addWindow(w); } }); Accordion acc = new Accordion(); acc.addTab(this.createUploadManager("mgr3"), "uploader"); acc.addTab(new HorizontalLayout(), "Stub"); mainLayout.addComponent(acc); mainLayout.addComponent(modal); this.setContent(mainLayout); }
From source file:dhbw.clippinggorilla.userinterface.windows.ActivateWindow.java
public static Window get() { Window window = new Window(); window.setModal(true); window.setResizable(false);/*from ww w .j av a2 s. c o m*/ window.setDraggable(false); window.setCaption(Language.get(Word.ACTIVATION_CODE)); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); VerticalLayout windowLayout = new VerticalLayout(); windowLayout.setMargin(false); windowLayout.setSizeUndefined(); FormLayout forms = new FormLayout(); forms.setMargin(true); forms.setSizeUndefined(); Button save = new Button(Language.get(Word.ACTIVATE)); TextField activationCode = new TextField(Language.get(Word.ACTIVATION_CODE)); activationCode.setMaxLength(6); activationCode.focus(); activationCode.addValueChangeListener(e -> { if (activationCode.getValue().length() > 5) { save.setEnabled(true); activationCode.setComponentError(null); } else { save.setEnabled(false); activationCode.setComponentError(new UserError(Language.get(Word.ACTIVATION_CODE_SIX_CHARS), AbstractErrorMessage.ContentMode.HTML, ErrorMessage.ErrorLevel.INFORMATION)); VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_CODE_SIX_CHARS)); } }); forms.addComponent(activationCode); Button resendMail = new Button(Language.get(Word.RESEND_ACTIVATION_CODE)); resendMail.addStyleName(ValoTheme.BUTTON_BORDERLESS_COLORED); resendMail.addClickListener(ce -> { try { UserUtils.resendActivationMail(UserUtils.getCurrent()); VaadinUtils.infoNotification(Language.get(Word.RESEND_ACTIVATION_CODE_SUCCESSFUL)); } catch (EmailException ex) { VaadinUtils.errorNotification(Language.get(Word.RESEND_ACTIVATION_CODE_FAILED)); } }); forms.addComponent(resendMail); GridLayout footer = new GridLayout(3, 1); footer.setSpacing(true); footer.addStyleName(ValoTheme.WINDOW_BOTTOM_TOOLBAR); footer.setWidth(100.0f, Sizeable.Unit.PERCENTAGE); Label placeholder = new Label(); Button cancel = new Button(Language.get(Word.CANCEL)); cancel.setIcon(VaadinIcons.CLOSE); cancel.addClickListener(ce -> { window.close(); }); cancel.setClickShortcut(ShortcutAction.KeyCode.ESCAPE, null); save.setEnabled(false); save.setIcon(VaadinIcons.CHECK); save.addStyleName(ValoTheme.BUTTON_PRIMARY); save.addClickListener(ce -> { try { String code = activationCode.getValue(); User user = UserUtils.getCurrent(); if (UserUtils.activateUser(user, code)) { VaadinUtils.infoNotification(Language.get(Word.ACTIVATION_SUCCESSFUL)); window.close(); } else { activationCode.setValue(""); VaadinUtils.errorNotification(Language.get(Word.ACTIVATION_FAILED)); } } catch (NumberFormatException e) { } }); save.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); footer.setSizeUndefined(); footer.setWidth("100%"); footer.addComponents(placeholder, cancel, save); footer.setColumnExpandRatio(0, 1);//ExpandRatio(placeholder, 1); footer.setComponentAlignment(cancel, Alignment.MIDDLE_CENTER); footer.setComponentAlignment(save, Alignment.MIDDLE_CENTER); windowLayout.addComponent(forms); windowLayout.addComponent(footer); window.setContent(windowLayout); return window; }
From source file:dhbw.clippinggorilla.userinterface.windows.PDFWindow.java
public static Window get(Path pdfFile) { Window window = new Window(); window.setModal(true); window.setResizable(false);/* w w w .jav a2 s . c om*/ window.setWidth("90%"); window.setHeight("90%"); window.addCloseShortcut(ShortcutAction.KeyCode.ENTER, null); BrowserFrame e = new BrowserFrame(pdfFile.getFileName().toString(), new FileResource(pdfFile.toFile())); e.setSizeFull(); window.setContent(e); return window; }
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); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true);/*w ww.ja v a2s. co m*/ 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.AbstractMmowgliControllerHelper.java
License:Open Source License
void handleShowActiveUsersActionTL(MenuBar menubar) { Session session = HSess.get();/* w w w.ja v a 2s . com*/ Criteria criteria = session.createCriteria(User.class); criteria.setProjection(Projections.rowCount()); criteria.add(Restrictions.eq("accountDisabled", false)); int totcount = ((Long) criteria.list().get(0)).intValue(); // new and improved int count = Mmowgli2UI.getGlobals().getSessionCount(); Window countWin = new Window("Display Active User Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of users* (including yourself)<br/>currently playing:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); layout.addComponent(new Label("* Count incremented on login, decremented on timeout or logout.")); hl = new HorizontalLayout(); hl.setSpacing(true); hl.addComponent(lab = new HtmlLabel("Total registered users:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label totalLab = new HtmlLabel(); totalLab.setWidth("50px"); totalLab.setValue(" " + totcount); totalLab.addStyleName("m-greyborder"); hl.addComponent(totalLab); hl.setComponentAlignment(totalLab, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("325px"); UI.getCurrent().addWindow(countWin); countWin.center(); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
private void _postGameEvent(String title, final GameEvent.EventType typ, String buttName, boolean doWarning, MenuBar mbar) {//from ww w . j ava2s. com // Create the window... final Window bcastWindow = new Window(title); bcastWindow.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); bcastWindow.setContent(layout); layout.addComponent(new Label("Compose message (255 char limit):")); final TextArea ta = new TextArea(); ta.setRows(5); ta.setWidth("99%"); layout.addComponent(ta); HorizontalLayout buttHl = new HorizontalLayout(); final Button bcancelButt = new Button("Cancel"); buttHl.addComponent(bcancelButt); Button bokButt = new Button(buttName); bokButt.setClickShortcut(ShortcutAction.KeyCode.ENTER, null); buttHl.addComponent(bokButt); layout.addComponent(buttHl); layout.setComponentAlignment(buttHl, Alignment.TOP_RIGHT); if (doWarning) layout.addComponent(new Label("Use with great deliberation!")); bcastWindow.setWidth("320px"); UI.getCurrent().addWindow(bcastWindow); bcastWindow.setPositionX(0); bcastWindow.setPositionY(0); ta.focus(); @SuppressWarnings("serial") ClickListener lis = new ClickListener() { @Override @MmowgliCodeEntry @HibernateOpened @HibernateClosed public void buttonClick(ClickEvent event) { if (event.getButton() == bcancelButt) ; // nothin else { // This check is now done in GameEvent.java, but should ideally prompt the user. String msg = ta.getValue().toString().trim(); if (msg.length() > 0) { HSess.init(); if (msg.length() > 255) // clamp to 255 to avoid db exception msg = msg.substring(0, 254); User u = Mmowgli2UI.getGlobals().getUserTL(); if (typ == GameEvent.EventType.GAMEMASTERNOTE) GameEventLogger.logGameMasterCommentTL(msg, u); else GameEventLogger.logGameMasterBroadcastTL(typ, msg, u); HSess.close(); } } bcastWindow.close(); } }; bcancelButt.addClickListener(lis); bokButt.addClickListener(lis); }
From source file:edu.nps.moves.mmowgli.AbstractMmowgliControllerHelper.java
License:Open Source License
public void handleShowNumberCardsActionTL(MenuBar mbar) { Session session = HSess.get();/*ww w.j a va 2s .co m*/ Criteria criteria = session.createCriteria(Card.class); criteria.setProjection(Projections.rowCount()); int count = ((Long) criteria.list().get(0)).intValue(); // Create the window... Window countWin = new Window("Display Card Count"); countWin.setModal(true); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.setSpacing(true); layout.setWidth("99%"); countWin.setContent(layout); HorizontalLayout hl = new HorizontalLayout(); hl.setSpacing(true); Label lab; hl.addComponent(lab = new HtmlLabel("Number of cards played:")); hl.addComponent(lab = new Label()); lab.setWidth("15px"); Label countTf = new HtmlLabel(); countTf.setWidth("50px"); countTf.setValue(" " + count); countTf.addStyleName("m-greyborder"); hl.addComponent(countTf); hl.setComponentAlignment(countTf, Alignment.MIDDLE_LEFT); layout.addComponent(hl); countWin.setWidth("255px"); UI.getCurrent().addWindow(countWin); countWin.center(); }