List of usage examples for com.vaadin.ui Window setWidth
@Override public void setWidth(String width)
From source file:com.tripoin.util.ui.calendar.BeanItemContainerTestUI.java
License:Apache License
/** * Opens up a modal dialog window where an event can be modified * //from w ww . j a va 2 s . c om * @param event * The event to modify */ private void editEvent(final BasicEvent event) { Window modal = new Window("Add event"); modal.setModal(true); modal.setResizable(false); modal.setDraggable(false); modal.setWidth("300px"); final FieldGroup fieldGroup = new FieldGroup(); FormLayout formLayout = new FormLayout(); TextField captionField = new TextField("Caption"); captionField.setImmediate(true); TextField descriptionField = new TextField("Description"); descriptionField.setImmediate(true); DateField startField = new DateField("Start"); startField.setResolution(Resolution.MINUTE); startField.setImmediate(true); DateField endField = new DateField("End"); endField.setImmediate(true); endField.setResolution(Resolution.MINUTE); formLayout.addComponent(captionField); formLayout.addComponent(descriptionField); formLayout.addComponent(startField); formLayout.addComponent(endField); fieldGroup.bind(captionField, ContainerEventProvider.CAPTION_PROPERTY); fieldGroup.bind(descriptionField, ContainerEventProvider.DESCRIPTION_PROPERTY); fieldGroup.bind(startField, ContainerEventProvider.STARTDATE_PROPERTY); fieldGroup.bind(endField, ContainerEventProvider.ENDDATE_PROPERTY); fieldGroup.setItemDataSource(new BeanItem<BasicEvent>(event, Arrays.asList(ContainerEventProvider.CAPTION_PROPERTY, ContainerEventProvider.DESCRIPTION_PROPERTY, ContainerEventProvider.STARTDATE_PROPERTY, ContainerEventProvider.ENDDATE_PROPERTY))); modal.setContent(formLayout); modal.addCloseListener(new Window.CloseListener() { /** * */ private static final long serialVersionUID = -3427881784024691882L; @Override public void windowClose(CloseEvent e) { // Commit changes to bean try { fieldGroup.commit(); } catch (CommitException e1) { e1.printStackTrace(); } if (events.containsId(event)) { /* * BeanItemContainer does not notify container listeners * when the bean changes so we need to trigger a * ItemSetChange event */ BasicEvent dummy = new BasicEvent(); events.addBean(dummy); events.removeItem(dummy); } else { events.addBean(event); } } }); getUI().addWindow(modal); }
From source file:com.trivago.mail.pigeon.web.components.mail.ActionButtonColumnGenerator.java
License:Apache License
@Override public Object generateCell(final Table source, final Object itemId, final Object columnId) { HorizontalLayout hl = new HorizontalLayout(); Button showNlConentButton = new Button(); showNlConentButton.setDescription("View"); showNlConentButton.setImmediate(true); showNlConentButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png")); showNlConentButton.addListener(new Button.ClickListener() { @Override/*from w ww . jav a2s . c o m*/ public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); Window nlConentView = new Window("Newsletter Contents of ID " + itemId); // Create an empty tab sheet. TabSheet tabsheet = new TabSheet(); Panel pText = new Panel("Text Content"); Panel pHtml = new Panel("Text Content"); RichTextArea textArea = new RichTextArea(); textArea.setValue(m.getText()); textArea.setReadOnly(true); RichTextArea richTextArea = new RichTextArea(); richTextArea.setValue(m.getHtml()); richTextArea.setReadOnly(true); pText.addComponent(textArea); pHtml.addComponent(richTextArea); richTextArea.setHeight("50%"); richTextArea.setWidth("100%"); textArea.setHeight("50%"); textArea.setWidth("100%"); nlConentView.setResizable(true); nlConentView.setWidth("800px"); nlConentView.setHeight("600px"); tabsheet.addTab(pText); tabsheet.getTab(pText).setCaption("Text Version"); tabsheet.addTab(pHtml); tabsheet.getTab(pHtml).setCaption("Html Version"); nlConentView.addComponent(tabsheet); source.getWindow().addWindow(nlConentView); nlConentView.setVisible(true); } }); final Button showOpenendMails = new Button(); showOpenendMails.setDescription("Show recipients of this mailling"); showOpenendMails.setIcon(new ThemeResource("../runo/icons/16/users.png")); showOpenendMails.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { Mail m = new Mail((Long) itemId); ModalRecipientListByMail modalRecipientListByMail = new ModalRecipientListByMail(m); source.getWindow().addWindow(modalRecipientListByMail); modalRecipientListByMail.setVisible(true); } }); hl.addComponent(showNlConentButton); hl.addComponent(showOpenendMails); return hl; }
From source file:de.akquinet.engineering.vaadin.vaangular.demo.VaangularUI.java
License:Apache License
private void showPopup(String eintrag) { Window modalWin = new Window("E-Mail is being sent..."); modalWin.setContent(new Label("<div style=\"margin: 10px; \">" + "<h2>Season's greetings</h2>" + "<p>" + eintrag + "</p>" + "</div>", ContentMode.HTML)); modalWin.setModal(true);//from w ww. j av a 2s .com modalWin.setWidth("400px"); modalWin.setHeight("250px"); modalWin.center(); UI.getCurrent().addWindow(modalWin); }
From source file:de.catma.ui.dialog.wizard.WizardFactory.java
License:Open Source License
public Window createWizardWindow(String caption, String width, String height) { Wizard wizard = new Wizard(); wizard.getFinishButton().setEnabled(false); Window wizardWindow = new Window(caption); wizardWindow.setModal(true);//from w w w .j a v a 2s. c o m wizardWindow.setContent(wizard); wizardWindow.setWidth(width); wizardWindow.setHeight(height); wizard.addListener(new WizardManager(wizardWindow)); wizard.addListener(wizardProgressListener); addSteps(wizard); return wizardWindow; }
From source file:de.dimm.vsm.vaadin.VSMCMain.java
public <T> void SelectObject(Class<T> t, String caption, String buttonCaption, List<T> list, final SelectObjectCallback cb) { if (list.size() == 1) { cb.SelectedAction(list.get(0));/* ww w .j a va 2s . co m*/ return; } final NativeSelect sel = new NativeSelect(caption); sel.setNewItemsAllowed(false); sel.setInvalidAllowed(false); sel.setNullSelectionAllowed(false); for (int i = 0; i < list.size(); i++) { Object object = list.get(i); sel.addItem(object); } if (!list.isEmpty()) sel.setValue(list.get(0)); VerticalLayout vl = new VerticalLayout(); vl.setSpacing(true); NativeButton ok = new NativeButton(buttonCaption); final Window win = new Window(Txt("Auswahl") + " " + caption); win.setWidth("350px"); win.center(); ok.addListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { getRootWin().removeWindow(win); cb.SelectedAction(sel.getValue()); } }); vl.addComponent(sel); sel.setWidth("80%"); vl.addComponent(ok); vl.setComponentAlignment(ok, Alignment.BOTTOM_RIGHT); vl.setSizeFull(); win.addComponent(vl); getRootWin().addWindow(win); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.DatasetComponent.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. j ava2 s. c om*/ */ private void buildLayout() { this.vert.removeAllComponents(); this.vert.setSizeFull(); vert.setResponsive(true); // Table (containing datasets) section VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSection.setResponsive(true); tableSectionContent.setResponsive(true); // tableSectionContent.setCaption("Datasets"); // tableSectionContent.setIcon(FontAwesome.FLASK); // tableSection.addComponent(new Label(String.format("This project contains %s dataset(s).", // numberOfDatasets))); tableSectionContent.setMargin(new MarginInfo(true, false, true, false)); tableSection.addComponent(headerLabel); tableSectionContent.addComponent(this.table); vert.setMargin(new MarginInfo(false, true, false, false)); tableSection.setMargin(new MarginInfo(true, false, false, true)); // tableSectionContent.setMargin(true); // tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(tableSection); table.setSizeFull(); tableSection.setSizeFull(); tableSectionContent.setSizeFull(); // this.table.setSizeFull(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setMargin(new MarginInfo(false, false, true, true)); buttonLayout.setHeight(null); // buttonLayout.setWidth("100%"); buttonLayout.setSpacing(true); buttonLayout.setResponsive(true); // final Button visualize = new Button(VISUALIZE_BUTTON_CAPTION); Button checkAll = new Button("Select all datasets"); checkAll.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { for (Object itemId : table.getItemIds()) { ((CheckBox) table.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 : table.getItemIds()) { ((CheckBox) table.getItem(itemId).getItemProperty("Select").getValue()).setValue(false); } } }); 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-party 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>"; export.setIcon(FontAwesome.DOWNLOAD); 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); buttonLayout.addComponent(export); buttonLayout.addComponent(checkAll); buttonLayout.addComponent(uncheckAll); // buttonLayout.addComponent(visualize); buttonLayout.addComponent(this.download); /** * prepare download. */ download.setEnabled(false); download.setResource(new ExternalResource("javascript:")); // visualize.setEnabled(false); for (final Object itemId : this.table.getItemIds()) { setCheckedBox(itemId, (String) this.table.getItem(itemId).getItemProperty("CODE").getValue()); } this.table.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { if (!event.isDoubleClick() & !((boolean) table.getItem(event.getItemId()).getItemProperty("isDirectory").getValue())) { String datasetCode = (String) table.getItem(event.getItemId()).getItemProperty("CODE") .getValue(); String datasetFileName = (String) table.getItem(event.getItemId()).getItemProperty("File Name") .getValue(); URL url; try { Resource res = null; Object parent = table.getParent(event.getItemId()); if (parent != null) { String parentDatasetFileName = (String) table.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); 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(".GSvar")) { 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 (visualize) { // LOGGER.debug("Is resource null?: " + String.valueOf(res == null)); BrowserFrame frame = new BrowserFrame("", res); 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)); 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); this.vert.addComponent(help); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.HomeView.java
License:Open Source License
/** * sets the ContainerDataSource of this view. Should usually contain project information. Caption * is caption./*from w w w . j a v a 2 s . co m*/ * * @param homeViewInformation * @param caption */ public void setContainerDataSource(SpaceBean spaceBean, String newCaption) { caption = newCaption; currentBean = spaceBean; numberOfProjects = currentBean.getProjects().size(); projectGrid = new Grid(); GeneratedPropertyContainer gpcProjects = new GeneratedPropertyContainer(spaceBean.getProjects()); gpcProjects.removeContainerProperty("members"); gpcProjects.removeContainerProperty("id"); gpcProjects.removeContainerProperty("experiments"); gpcProjects.removeContainerProperty("contact"); gpcProjects.removeContainerProperty("contactPerson"); gpcProjects.removeContainerProperty("projectManager"); gpcProjects.removeContainerProperty("containsData"); gpcProjects.removeContainerProperty("containsResults"); gpcProjects.removeContainerProperty("containsAttachments"); gpcProjects.removeContainerProperty("description"); gpcProjects.removeContainerProperty("progress"); gpcProjects.removeContainerProperty("registrationDate"); gpcProjects.removeContainerProperty("registrator"); gpcProjects.removeContainerProperty("longDescription"); projectGrid.setContainerDataSource(gpcProjects); projectGrid.setHeightMode(HeightMode.ROW); projectGrid.setHeightByRows(20); // projectGrid.getColumn("space").setWidthUndefined(); // projectGrid.getColumn("code").setWidthUndefined(); // projectGrid.getColumn("secondaryName").setWidthUndefined(); // projectGrid.getColumn("principalInvestigator").setWidthUndefined(); projectGrid.getColumn("code").setHeaderCaption("Sub-Project").setWidth(150); // projectGrid.getColumn("space").setWidth(200); Column nameCol = projectGrid.getColumn("secondaryName"); nameCol.setHeaderCaption("Short Name"); nameCol.setMaximumWidth(450); projectGrid.getColumn("space").setMaximumWidth(350); projectGrid.getColumn("space").setHeaderCaption("Project"); projectGrid.getColumn("principalInvestigator").setHeaderCaption("Investigator"); projectGrid.setColumnOrder("code", "space", "secondaryName", "principalInvestigator"); projectGrid.setResponsive(true); helpers.GridFunctions.addColumnFilters(projectGrid, gpcProjects); gpcProjects.addGeneratedProperty("Summary", new PropertyValueGenerator<String>() { @Override public String getValue(Item item, Object itemId, Object propertyId) { return "show"; } @Override public Class<String> getType() { return String.class; } }); projectGrid.getColumn("Summary").setWidthUndefined(); projectGrid.getColumn("Summary").setRenderer(new ButtonRenderer(new RendererClickListener() { @Override public void click(RendererClickEvent event) { // Show loading window ProgressBar bar = new ProgressBar(); bar.setIndeterminate(true); VerticalLayout vl = new VerticalLayout(bar); vl.setComponentAlignment(bar, Alignment.MIDDLE_CENTER); vl.setWidth("50%"); vl.setSpacing(true); vl.setMargin(true); Window loadingWindow = new Window("Loading project summary..."); loadingWindow.setWidth("50%"); loadingWindow.setContent(vl); loadingWindow.center(); loadingWindow.setModal(true); loadingWindow.setResizable(false); QbicmainportletUI ui = (QbicmainportletUI) UI.getCurrent(); ui.addWindow(loadingWindow); // fetch summary and create docx in tmp folder ProjectBean proj = (ProjectBean) event.getItemId(); summaryFetcher.fetchSummaryComponent(proj.getCode(), proj.getSecondaryName(), proj.getDescription(), new ProjectSummaryReadyRunnable(summaryFetcher, loadingWindow, proj.getCode())); } })); projectGrid.getColumn("Summary").setWidth(100); projectGrid.addSelectionListener(new SelectionListener() { @Override public void select(SelectionEvent event) { Set<Object> selectedElements = event.getSelected(); if (selectedElements == null) { return; } ProjectBean selectedProject = (ProjectBean) selectedElements.iterator().next(); if (selectedProject == null) { return; } String entity = selectedProject.getId(); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(entity); message.add(ProjectView.navigateToLabel); state.notifyObservers(message); } }); }
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.//from w w w. j a v a 2 s . 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: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. jav 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.PDFWindow.java
public static Window get(Path pdfFile) { Window window = new Window(); window.setModal(true);/*from www. j a va 2s . co m*/ window.setResizable(false); 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; }