List of usage examples for com.vaadin.ui VerticalLayout setMargin
@Override public void setMargin(boolean enabled)
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 ww. j a va 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.//w ww . ja v a 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:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
/** * initializes the sampleview header (mainly name of sample) * //w w w.j a v a 2 s. c o m * @return */ VerticalLayout initHeadline() { VerticalLayout headline = new VerticalLayout(); headline.setMargin(new MarginInfo(true, false, true, false)); sampleNameLabel = new Label(""); sampleExtId = new Label(""); sampleExtId.addStyleName("qlabel-huge"); sampleNameLabel.addStyleName("qlabel-large"); headline.addComponent(sampleExtId); headline.addComponent(sampleNameLabel); headline.setMargin(true); return headline; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
/** * initializes the description layout/*from w ww . ja v a 2 s . c om*/ * * @return */ VerticalLayout initDescription() { VerticalLayout sampleDescription = new VerticalLayout(); VerticalLayout sampleDescriptionContent = new VerticalLayout(); // sampleDescriptionContent.setMargin(true); sampleDescription.setCaption(""); // sampleDescriptionContent.setIcon(FontAwesome.FILE_TEXT_O); sampleTypeLabel = new Label(""); sampleParentLabel = new Label("", ContentMode.HTML); parentButton = new Button(""); parentButton.setStyleName(ValoTheme.BUTTON_LINK); parentButton.setIcon(FontAwesome.ARROW_CIRCLE_RIGHT); // Navigate to parent sample given by caption of button parentButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(currentBean.getParents().get(0).getIdentifier()); message.add("sample"); state.notifyObservers(message); } }); numberOfDatasetsLabel = new Label(""); lastChangedDatasetLabel = new Label(""); propertiesLabel = new Label("", ContentMode.HTML); propertiesLabel.setCaption("Properties"); experimentalFactorLabel = new Label("", ContentMode.HTML); sampleDescriptionContent.addComponent(sampleTypeLabel); sampleDescriptionContent.addComponent(sampleParentLabel); sampleDescriptionContent.addComponent(parentButton); // sampleDescriptionContent.addComponent(numberOfDatasetsLabel); // sampleDescriptionContent.addComponent(lastChangedDatasetLabel); sampleDescriptionContent.addComponent(propertiesLabel); sampleDescriptionContent.addComponent(experimentalFactorLabel); sampleDescriptionContent.setSpacing(true); sampleDescriptionContent.setMargin(new MarginInfo(true, false, true, true)); sampleDescription.addComponent(sampleDescriptionContent); sampleDescription.setMargin(new MarginInfo(true, false, true, true)); return sampleDescription; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
/** * /*w w w . ja v a 2 s. c o m*/ * @return * */ VerticalLayout initStatistics() { // Statistics of sample VerticalLayout statistics = new VerticalLayout(); HorizontalLayout statContent = new HorizontalLayout(); statistics.setCaption("Statistics"); // statContent.setIcon(FontAwesome.BAR_CHART_O); numberOfDatasetsLabel = new Label(""); statContent.addComponent(numberOfDatasetsLabel); lastChangedDatasetLabel = new Label(""); statContent.addComponent(lastChangedDatasetLabel); statContent.setMargin(new MarginInfo(true, false, false, true)); statContent.setSpacing(true); // statContent.setMargin(true); // statContent.setSpacing(true); statistics.addComponent(statContent); // statistics.setMargin(true); // Properties of sample VerticalLayout properties = new VerticalLayout(); VerticalLayout propertiesContent = new VerticalLayout(); // propertiesContent.setCaption("Properties"); // propertiesContent.setIcon(FontAwesome.LIST_UL); propertiesLabel = new Label("", ContentMode.HTML); propertiesContent.addComponent(propertiesLabel); propertiesContent.setMargin(new MarginInfo(true, false, false, true)); properties.addComponent(propertiesContent); // properties.setMargin(true); statistics.addComponent(properties); // Experimental factors of sample VerticalLayout experimentalFactors = new VerticalLayout(); VerticalLayout experimentalFactorsContent = new VerticalLayout(); // experimentalFactorsContent.setCaption("Experimental Factors"); // experimentalFactorsContent.setIcon(FontAwesome.TH); experimentalFactorLabel = new Label("", ContentMode.HTML); experimentalFactorsContent.addComponent(experimentalFactorLabel); experimentalFactorsContent.setMargin(new MarginInfo(true, false, true, true)); experimentalFactors.addComponent(experimentalFactorsContent); statistics.addComponent(experimentalFactors); statistics.setSpacing(true); statistics.setMargin(new MarginInfo(true, false, true, true)); return statistics; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SampleView.java
License:Open Source License
VerticalLayout initTable() { this.table = this.buildFilterTable(); VerticalLayout tableSection = new VerticalLayout(); VerticalLayout tableSectionContent = new VerticalLayout(); tableSection.setCaption("Experiments"); // tableSectionContent.setCaption("Registered Experiments"); // tableSectionContent.setIcon(FontAwesome.FLASK); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(new MarginInfo(true, false, false, true)); tableSection.setMargin(new MarginInfo(true, false, false, true)); this.table.setWidth("100%"); // tableSection.setWidth(Page.getCurrent().getBrowserWindowWidth() * 0.8f, Unit.PIXELS); tableSectionContent.setWidth("100%"); tableSection.addComponent(tableSectionContent); this.export = new Button("Export as TSV"); buttonLayoutSection = new VerticalLayout(); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setHeight(null);//from w w w. j a v a 2 s. c om buttonLayout.setWidth("100%"); buttonLayout.addComponent(this.export); buttonLayout.setMargin(new MarginInfo(false, false, true, false)); buttonLayoutSection.addComponent(buttonLayout); buttonLayoutSection.setSpacing(true); buttonLayoutSection.setMargin(new MarginInfo(false, false, true, true)); tableSection.addComponent(buttonLayoutSection); return tableSection; }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SearchForUsers.java
License:Open Source License
public SearchForUsers() { this.vert = new VerticalLayout(); this.table = buildFilterTable(); this.table.setSelectable(true); // this.table.setSizeFull(); this.button = new Button("Show Users"); this.button.addClickListener(this); this.button.setIcon(FontAwesome.SEARCH); this.button.setDescription("Click button to show user information"); VerticalLayout searchSection = new VerticalLayout(); HorizontalLayout searchContent = new HorizontalLayout(); searchSection.setMargin(true); searchContent.setMargin(true);//w w w. ja v a 2s. c o m searchContent.addComponent(this.button); searchSection.addComponent(searchContent); VerticalLayout tableSection = new VerticalLayout(); HorizontalLayout tableSectionContent = new HorizontalLayout(); tableSectionContent.setIcon(FontAwesome.USERS); tableSectionContent.setCaption("Connected Users"); tableSectionContent.addComponent(this.table); tableSectionContent.setMargin(true); tableSection.setMargin(true); tableSection.addComponent(tableSectionContent); this.vert.addComponent(searchSection); this.vert.addComponent(tableSection); vert.setSpacing(true); this.setContent(vert); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.SearchResultsView.java
License:Open Source License
void buildLayout(int browserHeight, int browserWidth, WebBrowser browser) { // this.setMargin(new MarginInfo(true, true, false, false)); // clean up first searchResultsLayout.removeAllComponents(); searchResultsLayout.setWidth("100%"); // searchResultsLayout.setSpacing(true); searchResultsLayout.setCaption("Search results for query '" + queryString + "'"); // Label header = new Label("Search results for query '" + queryString + "':"); // searchResultsLayout.addComponent(header); // updateView(browserWidth, browserWidth, browser); VerticalLayout viewContent = new VerticalLayout(); viewContent.setWidth("100%"); viewContent.setSpacing(true);//from ww w. jav a2 s . co m viewContent.setMargin(new MarginInfo(true, false, false, false)); List<String> showOptions = datahandler.getShowOptions(); if (showOptions.contains("Projects")) { projectGrid = new Grid(projBeanContainer); projectGrid.setCaption("Found Projects"); projectGrid.setColumnOrder("projectID", "description"); projectGrid.setSizeFull(); projectGrid.setHeightMode(HeightMode.ROW); projectGrid.setHeightByRows(5); projectGrid.setSelectionMode(SelectionMode.SINGLE); projectGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { // TODO Auto-generated method stub String cellType = new String(event.getPropertyId().toString()); if (cellType.equals("projectID")) { String cellContent = new String( projBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId()) .getValue().toString()); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(cellContent); message.add("project"); state.notifyObservers(message); } } }); if (projBeanContainer.size() == 0) { Label noSamples = new Label("no projects were found"); noSamples.setCaption("Found Projects"); viewContent.addComponent(noSamples); } else { viewContent.addComponent(projectGrid); } } if (showOptions.contains("Experiments")) { // expGrid = new Grid(expBeanContainer); expGrid = new Grid(expBeanContainer); expGrid.setCaption("Found Experiments"); expGrid.setColumnOrder("experimentID", "experimentName", "matchedField"); expGrid.setSizeFull(); expGrid.getColumn("experimentID").setExpandRatio(0); expGrid.getColumn("experimentName").setExpandRatio(1); expGrid.getColumn("matchedField").setExpandRatio(1); expGrid.setHeightMode(HeightMode.ROW); expGrid.setHeightByRows(5); expGrid.setSelectionMode(SelectionMode.SINGLE); expGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { String cellType = new String(event.getPropertyId().toString()); if (cellType.equals("experimentID")) { String cellContent = new String( expBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId()) .getValue().toString()); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(cellContent); message.add("experiment"); state.notifyObservers(message); } } }); if (expBeanContainer.size() == 0) { Label noExps = new Label("no experiments were found"); noExps.setCaption("Found Experiments"); viewContent.addComponent(noExps); } else { viewContent.addComponent(expGrid); } } if (showOptions.contains("Samples")) { sampleGrid = new Grid(sampleBeanContainer); sampleGrid.setCaption("Found Samples"); sampleGrid.setColumnOrder("sampleID", "sampleName", "matchedField"); sampleGrid.setSizeFull(); sampleGrid.getColumn("sampleID").setExpandRatio(0); sampleGrid.getColumn("sampleName").setExpandRatio(1); sampleGrid.getColumn("matchedField").setExpandRatio(1); sampleGrid.setHeightMode(HeightMode.ROW); sampleGrid.setHeightByRows(5); sampleGrid.setSelectionMode(SelectionMode.SINGLE); sampleGrid.addItemClickListener(new ItemClickListener() { @Override public void itemClick(ItemClickEvent event) { String cellType = new String(event.getPropertyId().toString()); if (cellType.equals("sampleID")) { String cellContent = new String( sampleBeanContainer.getContainerProperty(event.getItemId(), event.getPropertyId()) .getValue().toString()); State state = (State) UI.getCurrent().getSession().getAttribute("state"); ArrayList<String> message = new ArrayList<String>(); message.add("clicked"); message.add(cellContent); message.add("sample"); state.notifyObservers(message); } } }); if (sampleBeanContainer.size() == 0) { Label noSamples = new Label("no samples were found"); noSamples.setCaption("Found Samples"); viewContent.addComponent(noSamples); } else { viewContent.addComponent(sampleGrid); } } searchResultsLayout.addComponent(viewContent); this.addComponent(searchResultsLayout); }
From source file:de.uni_tuebingen.qbic.qbicmainportlet.WorkflowComponent.java
License:Open Source License
private void addComponentListeners() { availableWorkflows.setDetailsGenerator(new DetailsGenerator() { private static final long serialVersionUID = 6123522348935657638L; @Override//from w w w . j ava2 s . c om public Component getDetails(RowReference rowReference) { Workflow w = (Workflow) rowReference.getItemId(); Label description = new Label(w.getDescription(), ContentMode.HTML); description.setCaption("Description"); VerticalLayout main = new VerticalLayout(description); main.setMargin(true); return main; } }); availableWorkflows.addItemClickListener(new ItemClickListener() { private static final long serialVersionUID = 3786125825391677177L; @Override public void itemClick(ItemClickEvent event) { // TODO get path of datasetBean and set it as input ?! Workflow selectedWorkflow = (Workflow) event.getItemId(); if (selectedWorkflow != null) { updateParameterView(selectedWorkflow, datasetBeans); submission.setVisible(true); // detailed Description should be visible availableWorkflows.setDetailsVisible(selectedWorkflow, !availableWorkflows.isDetailsVisible(selectedWorkflow)); } else { LOGGER.warn("selected Workflow is null?"); submission.setVisible(false); } } }); availableWorkflows.setEditorEnabled(false); }
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 a2 s . co 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); }