List of usage examples for com.vaadin.ui VerticalLayout setId
@Override public void setId(String id)
From source file:com.logviewer.ui.dialog.FilterLog.java
License:Open Source License
private com.vaadin.ui.Component buildContetDialog() { final TextField txtFilter = new TextField() { {//from w w w .ja v a2 s . c om setWidth(100, Unit.PERCENTAGE); } }; table = new Table(""); table.addStyleName("small compact"); table.setSizeFull(); table.setImmediate(true); table.setSelectable(true); table.setEditable(false); table.addContainerProperty("Filter", String.class, null); loadTable(); VerticalLayout panelContent = new VerticalLayout(); panelContent.setSpacing(true); panelContent.setMargin(true); panelContent.setSizeFull(); panelContent.setId("panel-content"); panelContent.addComponent(new HorizontalLayout() { { addComponent(txtFilter); addComponent(new Button("Add", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { filters.add(txtFilter.getValue()); loadTable(); } })); setExpandRatio(txtFilter, 1f); setWidth(100, Unit.PERCENTAGE); } }); panelContent.addComponent(table); panelContent.setExpandRatio(table, 1.0f); return panelContent; }
From source file:com.peergreen.webconsole.core.vaadin7.BaseUI.java
License:Open Source License
/** * Build login view/*from w ww . ja v a 2s.co m*/ * * @param exit */ private void buildLoginView(final boolean exit) { if (exit) { root.removeAllComponents(); } notifierService.closeAll(); addStyleName("login"); VerticalLayout loginLayout = new VerticalLayout(); loginLayout.setId("webconsole_loginlayout_id"); loginLayout.setSizeFull(); loginLayout.addStyleName("login-layout"); root.addComponent(loginLayout); final CssLayout loginPanel = new CssLayout(); loginPanel.addStyleName("login-panel"); HorizontalLayout labels = new HorizontalLayout(); labels.setWidth(MAX_WIDTH); labels.setMargin(true); loginPanel.addComponent(labels); Label welcome = new Label("Welcome"); welcome.addStyleName("h4"); labels.addComponent(welcome); labels.setComponentAlignment(welcome, Alignment.MIDDLE_LEFT); Label title = new Label(consoleName); //title.setSizeUndefined(); title.addStyleName("h2"); title.addStyleName("light"); labels.addComponent(title); labels.setComponentAlignment(title, Alignment.MIDDLE_RIGHT); HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.setMargin(true); fields.addStyleName("fields"); final TextField username = new TextField("Username"); username.focus(); username.setId("webconsole_login_username"); fields.addComponent(username); final PasswordField password = new PasswordField("Password"); password.setId("webconsole_login_password"); fields.addComponent(password); final Button signin = new Button("Sign In"); signin.setId("webconsole_login_signin"); signin.addStyleName("default"); fields.addComponent(signin); fields.setComponentAlignment(signin, Alignment.BOTTOM_LEFT); final ShortcutListener enter = new ShortcutListener("Sign In", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object sender, Object target) { signin.click(); } }; signin.addShortcutListener(enter); loginPanel.addComponent(fields); HorizontalLayout bottomRow = new HorizontalLayout(); bottomRow.setWidth(MAX_WIDTH); bottomRow.setMargin(new MarginInfo(false, true, false, true)); final CheckBox keepLoggedIn = new CheckBox("Keep me logged in"); bottomRow.addComponent(keepLoggedIn); bottomRow.setComponentAlignment(keepLoggedIn, Alignment.MIDDLE_LEFT); // Add new error message final Label error = new Label("Wrong username or password.", ContentMode.HTML); error.setId("webconsole_login_error"); error.addStyleName("error"); error.setSizeUndefined(); error.addStyleName("light"); // Add animation error.addStyleName("v-animate-reveal"); error.setVisible(false); bottomRow.addComponent(error); bottomRow.setComponentAlignment(error, Alignment.MIDDLE_RIGHT); loginPanel.addComponent(bottomRow); signin.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (authenticate(username.getValue(), password.getValue())) { // if (keepLoggedIn.getValue()) { // //Cookie userCookie = getCookieByName(PEERGREEN_USER_COOKIE_NAME); // if (getCookieByName(PEERGREEN_USER_COOKIE_NAME) == null) { // // Get a token for this user and create a cooki // Page.getCurrent().getJavaScript().execute( String.format("document.cookie = '%s=%s; path=%s'", // PEERGREEN_USER_COOKIE_NAME, token, VaadinService.getCurrentRequest().getContextPath())); // } else { // // update token // userCookie.setValue(token); // userCookie.setPath(VaadinService.getCurrentRequest().getContextPath()); // } // } buildMainView(); } else { error.setVisible(true); } } }); loginLayout.addComponent(loginPanel); loginLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); }
From source file:com.snowy.Requests.java
public void updateRequests() { if (this.getComponentCount() > 0) { x = Integer.parseInt(this.getSelectedTab().getId().substring(3)); //Logger.getLogger(Requests.class.getName()).info(this.getSelectedTab().getId()); }// www . j a va 2s . com if (this.getComponentCount() < d.retriveChallenges().size()) { Notification.show("New Game Request", Notification.Type.TRAY_NOTIFICATION); } this.removeAllComponents(); ArrayList<ArrayList<String>> al = d.retriveChallenges(); int i = 0; for (ArrayList<String> ss : al) { VerticalLayout vl = new VerticalLayout(); HorizontalLayout hl = new HorizontalLayout(); if ((!d.getUsernameFromToken().equals(ss.get(0)) || (d.getUsernameFromToken().equals(ss.get(0)) && d.getUsernameFromToken().equals(ss.get(1)))) && Integer.parseInt(ss.get(3)) == 0) { vl.addComponent(new Label("You have been challenged by " + ss.get(0) + " on " + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString())); //Notification.show("New Game Reqest from "+ss.get(0), Notification.Type.TRAY_NOTIFICATION); hl.addComponent(new Button("Accept", ee -> { d.acceptRefuse(Integer.parseInt(ss.get(4)), true); })); hl.addComponent(new Button("Refuse", rr -> { d.acceptRefuse(Integer.parseInt(ss.get(4)), false); })); vl.addComponent(hl); } else { vl.addComponent(new Label("You challenged " + ss.get(1) + " on " + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString())); switch (Integer.parseInt(ss.get(3))) { case 0: vl.addComponent(new Label("Status: Awaiting Response")); break; case 1: PostLoginView plv = ((PostLoginView) this.getUI().getContent()); vl.addComponent(new Label("Status: Accepted")); plv.getGameWindow().initGame(ss.get(0), ss.get(1), Integer.parseInt(ss.get(4))); //Logger.getLogger(Requests.class.getName()).info(ss.get(4)); int gameId = d.getGameIdfromRequest(Integer.parseInt(ss.get(4))); if (plv.getGameWindow().gameIds().contains(gameId) != true && plv.getChatWindow().getChatIds().contains(gameId) != true) { plv.getChatWindow().addChat(gameId); //add game } //Logger.getLogger(Requests.class.getName()).info(plv.getGameWindow().gameIds().get(0)+" | "+ss.get(4)); break; case 2: vl.addComponent(new Label("Status: Refused")); break; } } vl.setSpacing(true); hl.setSpacing(true); vl.setMargin(true); vl.setId("set" + al.indexOf(ss)); this.addTab(vl, ss.get(0) + "\t" + new java.sql.Timestamp(Long.parseLong(ss.get(2))).toString()); //this.getTab(vl).setId("set"+i); i++; } this.setSelectedTab(x); }
From source file:edu.cornell.qatarmed.planrnaseq.BrowseAndAnnotate.java
private void initSearch() { searchField.setInputPrompt("Search Project"); /*/*from w w w . j a va 2s. c om*/ //Attempted to do autosuggestion but it require Indexcontainer for attached to vaadin table. Currently vaadin table is // attached to SqlContainer. It's possble to store fetch table data and use it for creating Indexcontainer and then attach it to vaadin table searchField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.LAZY); searchField.addTextChangeListener(new FieldEvents.TextChangeListener() { public void textChange(final FieldEvents.TextChangeEvent event) { rnaseqContainer.removeAllContainerFilters(); // rnaseqContainer.addContainerFilter(new AnnotateRNAseqSQL.ContactFilter(event // .getText())); } }); */ searchButton.setClickShortcut(KeyCode.ENTER); searchButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (event.getButton() == searchButton) { Component cc = findById(leftLayout, "GuidedSearch"); if (cc != null) { leftLayout.removeComponent(cc); } String search_value = searchField.getValue(); rnaseqContainer = createMySQLContainer("study_filter", search_value); rnaseqContainer.removeAllContainerFilters(); bioprojectSummaryTable.setContainerDataSource(rnaseqContainer); // bioprojectSummaryTable.setVisibleColumns(new String[] { studyName }); bioprojectSummaryTable.setSelectable(true); bioprojectSummaryTable.setImmediate(true); bioprojectSummaryTable.setColumnReorderingAllowed(true); bioprojectSummaryTable.setSortEnabled(true); bioprojectSummaryTable.setVisibleColumns(new Object[] { "Study", "title", "Numsample", "Numexp", "Numrun", "Avgspots", "avgbases", "name" }); } } }); slowSearchButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (event.getButton() == slowSearchButton) { Component cc = findById(leftLayout, "GuidedSearch"); if (cc != null) { leftLayout.removeComponent(cc); } String search_value = searchField.getValue(); rnaseqContainer = createMySQLContainer("study_filter_slow", search_value); rnaseqContainer.removeAllContainerFilters(); bioprojectSummaryTable.setContainerDataSource(rnaseqContainer); // bioprojectSummaryTable.setVisibleColumns(new String[] { studyName }); bioprojectSummaryTable.setSelectable(true); bioprojectSummaryTable.setImmediate(true); bioprojectSummaryTable.setColumnReorderingAllowed(true); bioprojectSummaryTable.setSortEnabled(true); bioprojectSummaryTable.setVisibleColumns(new Object[] { "Study", "title", "Numsample", "Numexp", "Numrun", "Avgspots", "avgbases", "name" }); } } }); guidedSearchButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (event.getButton() == guidedSearchButton) { VerticalLayout guidedSearchLayout = new VerticalLayout(); guidedSearchLayout.setId("GuidedSearch"); //<editor-fold defaultstate="collapsed" desc="Guided search layout"> HorizontalLayout diseaseLayout = new HorizontalLayout(); CheckBox checkboxDiseaseYes = new CheckBox("Yes"); CheckBox checkboxDiseaseNo = new CheckBox("No"); Label diseaseTitle = new Label("<b>Disease: </b>", ContentMode.HTML); diseaseLayout.addComponent(diseaseTitle); diseaseLayout.addComponent(checkboxDiseaseNo); diseaseLayout.addComponent(checkboxDiseaseYes); //<editor-fold defaultstate="collapsed" desc="Study types panel (guided search)"> Panel studyTypesPanel = new Panel("Sample Types"); HorizontalLayout studyTypesLayout = new HorizontalLayout(); HorizontalLayout caseControlLayout = new HorizontalLayout(); CheckBox checkboxCaseControlYes = new CheckBox("Yes"); CheckBox checkboxCaseControlNo = new CheckBox("No"); Label caseControlTitle = new Label("<b>Case-Control: </b>", ContentMode.HTML); caseControlLayout.addComponent(caseControlTitle); caseControlLayout.addComponent(checkboxCaseControlYes); caseControlLayout.addComponent(checkboxCaseControlNo); HorizontalLayout timeSeriesLayout = new HorizontalLayout(); CheckBox checkboxTimeSeriesYes = new CheckBox("Yes"); CheckBox checkboxTimeSeriesNo = new CheckBox("No"); Label timeSeriesTitle = new Label("<b>Time Series: </b>", ContentMode.HTML); timeSeriesLayout.addComponent(timeSeriesTitle); timeSeriesLayout.addComponent(checkboxTimeSeriesYes); timeSeriesLayout.addComponent(checkboxTimeSeriesNo); HorizontalLayout treatementLayout = new HorizontalLayout(); CheckBox checkboxTreatmentYes = new CheckBox("Yes"); CheckBox checkboxTreatmentNo = new CheckBox("No"); // checkboxTreatmentYes.setValue(true); Label treatmentTitle = new Label("<b>Treatment: </b>", ContentMode.HTML); treatementLayout.addComponent(treatmentTitle); treatementLayout.addComponent(checkboxTreatmentYes); treatementLayout.addComponent(checkboxTreatmentNo); studyTypesLayout.addComponent(caseControlLayout); Label emptyLabel = new Label(" ", ContentMode.HTML); studyTypesLayout.addComponent(emptyLabel); studyTypesLayout.addComponent(timeSeriesLayout); Label emptyLabel_2 = new Label(" ", ContentMode.HTML); studyTypesLayout.addComponent(emptyLabel_2); studyTypesLayout.addComponent(treatementLayout); studyTypesLayout.setSizeFull(); studyTypesPanel.setContent(studyTypesLayout); studyTypesPanel.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PERCENTAGE); studyTypesPanel.addStyleName("panelborder"); //</editor-fold>` //<editor-fold defaultstate="collapsed" desc="Disease Category Panel (guided search)"> Panel diseaseCategoryPanel = new Panel("Disease Category"); HorizontalLayout diseaseCategoriesLayout = new HorizontalLayout(); //Complex Disease ListSelect complexDisease = new ListSelect("Complex Disease"); complexDisease.setMultiSelect(true); for (String disease : complexDiseaseArray) { complexDisease.addItem(disease); } diseaseCategoriesLayout.addComponent(complexDisease); Label emptyLabel2 = new Label(" ", ContentMode.HTML); diseaseCategoriesLayout.addComponent(emptyLabel2); // Rare disease ListSelect rareDisease = new ListSelect("Rare Diseases"); rareDisease.setMultiSelect(true); for (String disease : rareDiseaseArray) { rareDisease.addItem(disease); } diseaseCategoriesLayout.addComponent(rareDisease); Label emptyLabel3 = new Label(" ", ContentMode.HTML); diseaseCategoriesLayout.addComponent(emptyLabel3); // Other diseases ListSelect otherDisease = new ListSelect("Other Diseases"); otherDisease.setMultiSelect(true); for (String disease : otherDiseaseArray) { otherDisease.addItem(disease); } diseaseCategoriesLayout.addComponent(otherDisease); // Label emptyLabel4 = new Label(" ", ContentMode.HTML); // diseaseCategoriesLayout.addComponent(emptyLabel4); diseaseCategoryPanel.setContent(diseaseCategoriesLayout); diseaseCategoryPanel.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PERCENTAGE); diseaseCategoryPanel.addStyleName("panelborder"); //</editor-fold> //<editor-fold defaultstate="collapsed" desc="Platform (guided search)"> ListSelect platformsListSelect = new ListSelect("Sequencing Platform"); platformsListSelect.setMultiSelect(true); for (String platform : platforms) { platformsListSelect.addItem(platform); } HorizontalLayout platformLayout = new HorizontalLayout(); platformsListSelect.setHeight(platformsListSelect.size() + 2, Unit.EM); platformLayout.addComponent(platformsListSelect); //</editor-fold> //<editor-fold defaultstate="collapsed" desc="Sample types panel (guided search)"> Panel sampleTypesPanel = new Panel("Sample Types"); HorizontalLayout sampleTypesLayout = new HorizontalLayout(); CheckBox checkboxSampleTypeCellLine = new CheckBox("Cell Line"); CheckBox checkboxSampleTypeTissue = new CheckBox("Tissue"); CheckBox checkboxSampleTypePrimaryCells = new CheckBox("Primary Cells"); CheckBox checkboxSampleTypeWholeBlood = new CheckBox("Whole Blood"); CheckBox checkboxSampleTypePlasma = new CheckBox("Plasma"); HorizontalLayout CellLineLayout = new HorizontalLayout(); CellLineLayout.addComponent(checkboxSampleTypeCellLine); HorizontalLayout PrimaryCellsLayout = new HorizontalLayout(); PrimaryCellsLayout.addComponent(checkboxSampleTypePrimaryCells); HorizontalLayout TissueLayout = new HorizontalLayout(); TissueLayout.addComponent(checkboxSampleTypeTissue); HorizontalLayout WholeBloodLayout = new HorizontalLayout(); WholeBloodLayout.addComponent(checkboxSampleTypeWholeBlood); HorizontalLayout PlasmaLayout = new HorizontalLayout(); PlasmaLayout.addComponent(checkboxSampleTypePlasma); sampleTypesLayout.addComponent(CellLineLayout); Label emptyLabel8 = new Label(" ", ContentMode.HTML); sampleTypesLayout.addComponent(emptyLabel8); sampleTypesLayout.addComponent(PrimaryCellsLayout); Label emptyLabel5 = new Label(" ", ContentMode.HTML); sampleTypesLayout.addComponent(emptyLabel5); sampleTypesLayout.addComponent(TissueLayout); Label emptyLabel6 = new Label(" ", ContentMode.HTML); sampleTypesLayout.addComponent(emptyLabel6); sampleTypesLayout.addComponent(WholeBloodLayout); Label emptyLabel7 = new Label(" ", ContentMode.HTML); sampleTypesLayout.addComponent(emptyLabel7); sampleTypesLayout.addComponent(PlasmaLayout); sampleTypesPanel.setContent(sampleTypesLayout); sampleTypesPanel.setWidth(Sizeable.SIZE_UNDEFINED, Unit.PERCENTAGE); sampleTypesPanel.addStyleName("panelborder"); //</editor-fold> //<editor-fold defaultstate="collapsed" desc="Replicate Type"> HorizontalLayout replicatTypesLayout = new HorizontalLayout(); String replicateType_from_sra = ""; String replicateType_confidence = ""; Label suggestedreplicatTypeLabel = new Label("<b><i>Suggestion: </i></b>" + replicateType_from_sra + " <b> <i> Confidence: <i></b> " + replicateType_confidence, ContentMode.HTML); String[] replicatTypes = new String[] { "Biological -- different individuals", "Biological -- same individual but severe treatment to RNA", "Semi Biological/Technical -- mild treatment", "Technical -- machine parameter or buffer (very mild)" }; List<String> replicatTypesList = Arrays.asList(replicatTypes); ComboBox replicatTypesListComboBox = new ComboBox("Replicates Type ", replicatTypesList); replicatTypesLayout.addComponent(replicatTypesListComboBox); replicatTypesLayout.addComponent(suggestedreplicatTypeLabel); //</editor-fold> checkboxCaseControlYes.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxCaseControlYes.getValue()) { checkboxCaseControlNo.setValue(!checkboxCaseControlYes.getValue()); } } }); checkboxCaseControlNo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxCaseControlNo.getValue()) { checkboxCaseControlYes.setValue(!checkboxCaseControlNo.getValue()); } } }); checkboxTimeSeriesYes.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxTimeSeriesYes.getValue()) { checkboxTimeSeriesNo.setValue(!checkboxTimeSeriesYes.getValue()); } } }); checkboxTimeSeriesNo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxTimeSeriesNo.getValue()) { checkboxTimeSeriesYes.setValue(!checkboxTimeSeriesNo.getValue()); } } }); checkboxTreatmentYes.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxTreatmentYes.getValue()) { checkboxTreatmentNo.setValue(!checkboxTreatmentYes.getValue()); } } }); checkboxTreatmentNo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxTreatmentNo.getValue()) { checkboxTreatmentYes.setValue(!checkboxTreatmentNo.getValue()); } } }); checkboxDiseaseYes.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxDiseaseYes.getValue()) { checkboxDiseaseNo.setValue(!checkboxDiseaseYes.getValue()); diseaseCategoryPanel.setVisible(true); } } }); checkboxDiseaseNo.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxDiseaseNo.getValue()) { checkboxDiseaseYes.setValue(!checkboxDiseaseNo.getValue()); diseaseCategoryPanel.setVisible(false); } } }); //<editor-fold defaultstate="collapsed" desc="CheckBox Annotation Ongoing or Completed "> CheckBox checkboxAnnotaionCompleted = new CheckBox("Annotaion Completed"); CheckBox checkboxAnnotaionOngoing = new CheckBox("Annotaion Ongoing"); // checkboxAnnotaionOngoing.setValue(true); checkboxAnnotaionCompleted.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxAnnotaionCompleted.getValue()) { checkboxAnnotaionOngoing.setValue(!checkboxAnnotaionCompleted.getValue()); } } }); checkboxAnnotaionOngoing.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { if (checkboxAnnotaionOngoing.getValue()) { checkboxAnnotaionCompleted.setValue(!checkboxAnnotaionOngoing.getValue()); } } }); //</editor-fold> HorizontalLayout annotationStatusLayout = new HorizontalLayout(); annotationStatusLayout.addComponent(checkboxAnnotaionOngoing); annotationStatusLayout.addComponent(checkboxAnnotaionCompleted); Button guidedSearchSubmitButton = new Button("Search Meeting ALL Criteria"); guidedSearchSubmitButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (event.getButton() == guidedSearchSubmitButton) { String query_part3 = ""; if (checkboxDiseaseYes.getValue() && !checkboxDiseaseNo.getValue()) { query_part3 = query_part3 + " AND ( isDisease = 1) "; } else if (!checkboxDiseaseYes.getValue() && checkboxDiseaseNo.getValue()) { query_part3 = query_part3 + " AND (isDisease = null or isDisease = 0 ) "; } String selected_disease_category = ""; String main_disease = ""; for (Iterator i = complexDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (complexDisease.isSelected(iid)) { // System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "complex_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "complex_disease|" + main_disease + "|" + temp; } } else { //main disease is selected // selected_disease_main = main_disease; if (selected_disease_category.isEmpty()) { selected_disease_category = "complex_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "complex_disease|" + main_disease + "|" + "Any"; } } } } main_disease = ""; for (Iterator i = rareDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (rareDisease.isSelected(iid)) { // System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "rare_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "rare_disease|" + main_disease + "|" + temp; } } else { if (selected_disease_category.isEmpty()) { selected_disease_category = "rare_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "rare_disease|" + main_disease + "|" + "Any"; } } } } main_disease = ""; for (Iterator i = otherDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (otherDisease.isSelected(iid)) { // System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "other_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "other_disease|" + main_disease + "|" + temp; } } else { if (selected_disease_category.isEmpty()) { selected_disease_category = "other_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "other_disease|" + main_disease + "|" + "Any"; } } } } if (checkboxCaseControlYes.getValue() && !checkboxCaseControlNo.getValue()) { query_part3 = query_part3 + " AND ( isCaseControl = 1) "; } else if (!checkboxCaseControlYes.getValue() && checkboxCaseControlNo.getValue()) { query_part3 = query_part3 + " AND (isCaseControl = null or isCaseControl = 0 ) "; } if (checkboxTimeSeriesYes.getValue() && !checkboxTimeSeriesNo.getValue()) { query_part3 = query_part3 + " AND ( isTimeSeries = 1) "; } else if (!checkboxTimeSeriesYes.getValue() && checkboxTimeSeriesNo.getValue()) { query_part3 = query_part3 + " AND (isTimeSeries = null or isTimeSeries = 0 ) "; } if (checkboxTreatmentYes.getValue() && !checkboxTreatmentNo.getValue()) { query_part3 = query_part3 + " AND ( isTreatment = 1) "; } else if (!checkboxTreatmentYes.getValue() && checkboxTreatmentNo.getValue()) { query_part3 = query_part3 + " AND (isTreatment = null or isTreatment = 0 ) "; } if (checkboxSampleTypeTissue.getValue()) { query_part3 = query_part3 + " AND ( isTissue = 1) "; } else { // query_part3 = query_part3 + " AND (isTissue = null or isTissue = 0 ) " ; } if (checkboxSampleTypeCellLine.getValue()) { query_part3 = query_part3 + " AND ( isCellLine = 1) "; } else { // query_part3 = query_part3 + " AND (isCellLine = null or isCellLine = 0 ) " ; } if (checkboxSampleTypePrimaryCells.getValue()) { query_part3 = query_part3 + " AND ( isPrimaryCells = 1) "; } else { // query_part3 = query_part3 + " AND (isPrimaryCells = null or isPrimaryCells = 0 ) " ; } if (checkboxSampleTypeWholeBlood.getValue()) { query_part3 = query_part3 + " AND ( isWholeBlood = 1) "; } else { // query_part3 = query_part3 + " AND (isWholeBlood = null or isWholeBlood = 0 ) " ; } if (checkboxSampleTypePlasma.getValue()) { query_part3 = query_part3 + " AND ( isPlasma = 1) "; } else { // query_part3 = query_part3 + " AND (isPlasma = null or isPlasma = 0 ) " ; } String selected_sequencing_platforms = ""; for (Iterator i = platformsListSelect.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (platformsListSelect.isSelected(iid)) { if (selected_sequencing_platforms.isEmpty()) { selected_sequencing_platforms = temp; } else { selected_sequencing_platforms = selected_sequencing_platforms + ";" + temp; } } } String replicate_type = ""; if (!(replicatTypesListComboBox.getValue() == null)) { replicate_type = replicatTypesListComboBox.getValue().toString(); } String annotation_status = ""; if (checkboxAnnotaionCompleted.getValue() && !checkboxAnnotaionOngoing.getValue()) { annotation_status = "completed"; } else if (!checkboxAnnotaionCompleted.getValue() && checkboxAnnotaionOngoing.getValue()) { annotation_status = "completed"; } try { String query_part1 = "SELECT * FROM study_summary "; String query_part2 = " SELECT studyid FROM manual_annotation "; if (replicate_type.length() > 1) { query_part3 = query_part3 + " AND ( replicate_type = '" + replicate_type + "' ) "; } if (annotation_status.length() > 1) { query_part3 = query_part3 + " AND ( annotation_status = '" + annotation_status + "' ) "; } if (selected_disease_category.length() > 1) { query_part3 = query_part3 + " AND disease_category like " + "'%" + selected_disease_category + "%'"; } if (selected_sequencing_platforms.length() > 1) { query_part3 = query_part3 + " AND sequencing_platform like " + "'%" + selected_sequencing_platforms + "%'"; } query_part3 = query_part3.trim(); if (query_part3.startsWith("AND")) { query_part3 = query_part3.substring(3); } String search_query = query_part1 + " where Study in (" + query_part2 + " WHERE " + query_part3 + ")"; rnaseqContainer = createMySQLContainer("search_manual_annotation", search_query); rnaseqContainer.removeAllContainerFilters(); bioprojectSummaryTable.setContainerDataSource(rnaseqContainer); // bioprojectSummaryTable.setVisibleColumns(new String[] { studyName }); bioprojectSummaryTable.setSelectable(true); bioprojectSummaryTable.setImmediate(true); bioprojectSummaryTable.setColumnReorderingAllowed(true); bioprojectSummaryTable.setSortEnabled(true); bioprojectSummaryTable.setVisibleColumns(new Object[] { "Study", "title", "Numsample", "Numexp", "Numrun", "Avgspots", "avgbases", "name" }); } catch (Exception e) { } } } }); Button guidedSearchANYSubmitButton = new Button("Search Meeting ANY Criteria"); guidedSearchANYSubmitButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { if (event.getButton() == guidedSearchANYSubmitButton) { String query_part3 = ""; if (checkboxDiseaseYes.getValue() && !checkboxDiseaseNo.getValue()) { query_part3 = query_part3 + " OR ( isDisease = 1) "; } else if (!checkboxDiseaseYes.getValue() && checkboxDiseaseNo.getValue()) { query_part3 = query_part3 + " OR (isDisease = null or isDisease = 0 ) "; } String selected_disease_category = ""; String main_disease = ""; for (Iterator i = complexDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (complexDisease.isSelected(iid)) { //System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "complex_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "complex_disease|" + main_disease + "|" + temp; } } else { //main disease is selected // selected_disease_main = main_disease; if (selected_disease_category.isEmpty()) { selected_disease_category = "complex_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "complex_disease|" + main_disease + "|" + "Any"; } } } } main_disease = ""; for (Iterator i = rareDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (rareDisease.isSelected(iid)) { // System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "rare_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "rare_disease|" + main_disease + "|" + temp; } } else { if (selected_disease_category.isEmpty()) { selected_disease_category = "rare_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "rare_disease|" + main_disease + "|" + "Any"; } } } } main_disease = ""; for (Iterator i = otherDisease.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (!temp.startsWith("--")) { main_disease = temp; } if (otherDisease.isSelected(iid)) { // System.out.println("Selected" + temp); if (iid.toString().startsWith("--")) { // sub disease is selected if (selected_disease_category.isEmpty()) { selected_disease_category = "other_disease|" + main_disease + "|" + temp; } else { selected_disease_category = selected_disease_category + ";" + "other_disease|" + main_disease + "|" + temp; } } else { if (selected_disease_category.isEmpty()) { selected_disease_category = "other_disease|" + main_disease + "|" + "Any"; } else { selected_disease_category = selected_disease_category + ";" + "other_disease|" + main_disease + "|" + "Any"; } } } } if (checkboxCaseControlYes.getValue() && !checkboxCaseControlNo.getValue()) { query_part3 = query_part3 + " OR ( isCaseControl = 1) "; } else if (!checkboxCaseControlYes.getValue() && checkboxCaseControlNo.getValue()) { query_part3 = query_part3 + " OR (isCaseControl = null or isCaseControl = 0 ) "; } if (checkboxTimeSeriesYes.getValue() && !checkboxTimeSeriesNo.getValue()) { query_part3 = query_part3 + " OR ( isTimeSeries = 1) "; } else if (!checkboxTimeSeriesYes.getValue() && checkboxTimeSeriesNo.getValue()) { query_part3 = query_part3 + " OR (isTimeSeries = null or isTimeSeries = 0 ) "; } if (checkboxTreatmentYes.getValue() && !checkboxTreatmentNo.getValue()) { query_part3 = query_part3 + " OR ( isTreatment = 1) "; } else if (!checkboxTreatmentYes.getValue() && checkboxTreatmentNo.getValue()) { query_part3 = query_part3 + " OR (isTreatment = null or isTreatment = 0 ) "; } if (checkboxSampleTypeTissue.getValue()) { query_part3 = query_part3 + " OR ( isTissue = 1) "; } else { // query_part3 = query_part3 + " AND (isTissue = null or isTissue = 0 ) " ; } if (checkboxSampleTypeCellLine.getValue()) { query_part3 = query_part3 + " OR ( isCellLine = 1) "; } else { // query_part3 = query_part3 + " AND (isCellLine = null or isCellLine = 0 ) " ; } if (checkboxSampleTypePrimaryCells.getValue()) { query_part3 = query_part3 + " OR ( isPrimaryCells = 1) "; } else { // query_part3 = query_part3 + " AND (isPrimaryCells = null or isPrimaryCells = 0 ) " ; } if (checkboxSampleTypeWholeBlood.getValue()) { query_part3 = query_part3 + " OR ( isWholeBlood = 1) "; } else { // query_part3 = query_part3 + " AND (isWholeBlood = null or isWholeBlood = 0 ) " ; } if (checkboxSampleTypePlasma.getValue()) { query_part3 = query_part3 + " OR ( isPlasma = 1) "; } else { // query_part3 = query_part3 + " AND (isPlasma = null or isPlasma = 0 ) " ; } String selected_sequencing_platforms = ""; for (Iterator i = platformsListSelect.getItemIds().iterator(); i.hasNext();) { Object iid = (Object) i.next(); String temp = iid.toString(); if (platformsListSelect.isSelected(iid)) { if (selected_sequencing_platforms.isEmpty()) { selected_sequencing_platforms = temp; } else { selected_sequencing_platforms = selected_sequencing_platforms + ";" + temp; } } } String replicate_type = ""; if (!(replicatTypesListComboBox.getValue() == null)) { replicate_type = replicatTypesListComboBox.getValue().toString(); } String annotation_status = ""; if (checkboxAnnotaionCompleted.getValue() && !checkboxAnnotaionOngoing.getValue()) { annotation_status = "completed"; } else if (!checkboxAnnotaionCompleted.getValue() && checkboxAnnotaionOngoing.getValue()) { annotation_status = "completed"; } try { String query_part1 = "SELECT * FROM study_summary "; String query_part2 = " SELECT studyid FROM manual_annotation "; if (replicate_type.length() > 1) { query_part3 = query_part3 + " OR ( replicate_type = '" + replicate_type + "' ) "; } if (annotation_status.length() > 1) { query_part3 = query_part3 + " OR ( annotation_status = '" + annotation_status + "' ) "; } if (selected_disease_category.length() > 1) { query_part3 = query_part3 + " OR disease_category like " + "'%" + selected_disease_category + "%'"; } if (selected_sequencing_platforms.length() > 1) { query_part3 = query_part3 + " AND sequencing_platform like " + "'%" + selected_sequencing_platforms + "%'"; } query_part3 = query_part3.trim(); if (query_part3.startsWith("OR")) { query_part3 = query_part3.substring(2); } String search_query = query_part1 + " where Study in (" + query_part2 + " WHERE " + query_part3 + ")"; rnaseqContainer = createMySQLContainer("search_manual_annotation", search_query); rnaseqContainer.removeAllContainerFilters(); bioprojectSummaryTable.setContainerDataSource(rnaseqContainer); // bioprojectSummaryTable.setVisibleColumns(new String[] { studyName }); bioprojectSummaryTable.setSelectable(true); bioprojectSummaryTable.setImmediate(true); bioprojectSummaryTable.setColumnReorderingAllowed(true); bioprojectSummaryTable.setSortEnabled(true); bioprojectSummaryTable.setVisibleColumns(new Object[] { "Study", "title", "Numsample", "Numexp", "Numrun", "Avgspots", "avgbases", "name" }); } catch (Exception e) { } } } }); HorizontalLayout guidedSearchButtonLayout = new HorizontalLayout(); guidedSearchButtonLayout.addComponent(guidedSearchSubmitButton); guidedSearchButtonLayout.addComponent(guidedSearchANYSubmitButton); guidedSearchLayout.addComponent(diseaseLayout); // guidedSearchLayout.addComponent(caseControlLayout); // guidedSearchLayout.addComponent(timeSeriesLayout); guidedSearchLayout.addComponent(studyTypesPanel); guidedSearchLayout.addComponent(diseaseCategoryPanel); guidedSearchLayout.addComponent(platformLayout); guidedSearchLayout.addComponent(sampleTypesPanel); guidedSearchLayout.addComponent(replicatTypesLayout); guidedSearchLayout.addComponent(annotationStatusLayout); guidedSearchLayout.addComponent(guidedSearchButtonLayout); guidedSearchLayout.setComponentAlignment(guidedSearchButtonLayout, Alignment.MIDDLE_CENTER); int leftTopLayoutIndex = leftLayout.getComponentIndex(leftTopLayout); leftLayout.addComponent(guidedSearchLayout, leftTopLayoutIndex + 1); //</editor-fold> } } }); }
From source file:edu.kit.dama.ui.admin.MainControlPanel.java
License:Apache License
/** * Create a new cell for the UI. Each cell contains an image located in the * provided resource and a help label for the cell adverse to it. * Furthermore, a style is provided which can be 'help-left' or 'help-right' * depending on which side the help text should be aligned (help in left col * -> align right).//from ww w. j a v a 2 s .co m * * @param pResourceString The image resource string. * @param The alignment of the image (TOP_LEFT or TOP_RIGHT, depending on * the column) * @param cellNumber The cell number (0-3) counting from top left to bottom * right * @param pHelp The help string which may contain HTML tags. * @param pStyle The help label style ('help-left' or 'help-right'). * * @return The cell layout. */ private VerticalLayout createCell(String pResourceString, Alignment pAlignment, int cellNumber, String pHelp, String pStyle) { final String cellHeight = "132px"; //create the cell image Image cellImage = new Image(null, new ThemeResource(pResourceString)); cellImage.addStyleName("border"); //create the cell image wrapper, which provides the shadow and this show/hide functionality VerticalLayout imageWrapper = new VerticalLayout(cellImage); imageWrapper.addComponent(cellImage); imageWrapper.setComponentAlignment(cellImage, Alignment.MIDDLE_CENTER); imageWrapper.setWidth(cellHeight); imageWrapper.setHeight(cellHeight); imageWrapper.addStyleName("shadow"); imageWrapper.addStyleName("visible"); //help label for the cell adverse to the current cell Label oppositeCellHelp = new Label(pHelp, ContentMode.HTML); oppositeCellHelp.addStyleName(pStyle); oppositeCellHelp.setSizeFull(); oppositeCellHelp.addStyleName("invisible"); oppositeCellHelp.setHeight(cellHeight); //the cell layout containing image and help label VerticalLayout cell = new VerticalLayout(); cell.addComponent(imageWrapper); cell.setComponentAlignment(imageWrapper, pAlignment); cell.setMargin(true); cell.addComponent(oppositeCellHelp); cell.setComponentAlignment(oppositeCellHelp, Alignment.MIDDLE_CENTER); //define component ids depending on the provided cell number //--------- //| 0 | 1 | //| 2 | 3 | //--------- //Each cell gets the id 'image<cellNumber>' //The currently created wrapper and help label are getting the cellId of the adverse cell (0 -> 1, 1 -> 0, 2 -> 3, 3 -> 2). //These ids are used then by edu.kit.dama.ui.admin.client.HelpConnector to show/hide elements on mouse over. switch (cellNumber) { case 0: cellImage.setId("image0"); //this cell contains the help for cell 1 imageWrapper.setId("image1_wrapper"); oppositeCellHelp.setId("image1_help"); break; case 1: cellImage.setId("image1"); //this cell contains the help for cell 0 imageWrapper.setId("image0_wrapper"); oppositeCellHelp.setId("image0_help"); break; case 2: cellImage.setId("image2"); //this cell contains the help for cell 3 imageWrapper.setId("image3_wrapper"); oppositeCellHelp.setId("image3_help"); break; case 3: cellImage.setId("image3"); //this cell contains the help for cell 2 imageWrapper.setId("image2_wrapper"); oppositeCellHelp.setId("image2_help"); break; } //link the HelpExtension to the image new HelpExtension().extend(cellImage); return cell; }
From source file:fr.univlorraine.mondossierweb.views.ListeInscritsView.java
License:Apache License
private void displayTrombinoscope() { List<Inscrit> linscrits = MainUI.getCurrent().getListeInscrits(); if (trombiLayout != null) { trombiLayout.removeAllComponents(); } else {// w w w . j a v a 2s .c o m trombiLayout = new GridLayout(); trombiLayout.setColumns(5); trombiLayout.setWidth("100%"); trombiLayout.setHeight(null); trombiLayout.setSpacing(true); } for (Inscrit inscrit : linscrits) { if (listecodind.contains(inscrit.getCod_ind())) { VerticalLayout photoLayout = new VerticalLayout(); photoLayout.setId(inscrit.getCod_ind()); photoLayout.setHeight("100%"); if (inscrit.getUrlphoto() != null) { //Button fotoEtu=new Button(); Image fotoEtudiant = new Image(null, new ExternalResource(inscrit.getUrlphoto())); fotoEtudiant.setWidth("120px"); fotoEtudiant.setStyleName(ValoTheme.BUTTON_LINK); fotoEtudiant.addClickListener(e -> { rechercheController.accessToDetail(inscrit.getCod_etu().toString(), Utils.TYPE_ETU, null); }); photoLayout.addComponent(fotoEtudiant); //photoLayout.addComponent(fotoEtu); photoLayout.setComponentAlignment(fotoEtudiant, Alignment.MIDDLE_CENTER); photoLayout.setExpandRatio(fotoEtudiant, 1); } VerticalLayout nomCodeLayout = new VerticalLayout(); nomCodeLayout.setSizeFull(); nomCodeLayout.setSpacing(false); Button btnNomEtudiant = new Button(inscrit.getPrenom() + " " + inscrit.getNom()); btnNomEtudiant.setSizeFull(); btnNomEtudiant.setStyleName(ValoTheme.BUTTON_BORDERLESS); btnNomEtudiant.addStyleName("link"); btnNomEtudiant.addStyleName("v-link"); nomCodeLayout.addComponent(btnNomEtudiant); btnNomEtudiant.addClickListener(e -> { rechercheController.accessToDetail(inscrit.getCod_etu().toString(), Utils.TYPE_ETU, null); }); nomCodeLayout.setComponentAlignment(btnNomEtudiant, Alignment.MIDDLE_CENTER); //nomCodeLayout.setExpandRatio(btnNomEtudiant, 1); Label codetuLabel = new Label(inscrit.getCod_etu()); codetuLabel.setSizeFull(); codetuLabel.setStyleName(ValoTheme.LABEL_TINY); codetuLabel.addStyleName("label-centre"); nomCodeLayout.addComponent(codetuLabel); nomCodeLayout.setComponentAlignment(codetuLabel, Alignment.TOP_CENTER); photoLayout.addComponent(nomCodeLayout); trombiLayout.addComponent(photoLayout); trombiLayout.setComponentAlignment(photoLayout, Alignment.MIDDLE_CENTER); } } }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.about.AboutProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vl = new VerticalLayout(); vl.addComponent(new Image("", LOGO)); TextField version = new TextField(TRANSLATOR.translate("general.version")); version.setValue(((ValidationManagerUI) UI.getCurrent()).getVersion()); version.setReadOnly(true);/* ww w. j a va 2 s. c o m*/ vl.addComponent(version); TextField build = new TextField(TRANSLATOR.translate("general.build")); build.setValue(((ValidationManagerUI) UI.getCurrent()).getBuild()); build.setReadOnly(true); vl.addComponent(build); TextArea desc = new TextArea(); desc.setValue("Validation Manager is a tool to handle all the " + "cumbersome paperwork of regulated environment validations. " + "Including Validation Plans, protocols, " + "executions and exceptions. Keeping everything in one " + "place and best of all paperless. "); desc.setReadOnly(true); desc.setWidth(100, Unit.PERCENTAGE); Link link = new Link("Get more information here", new ExternalResource("https://github.com/javydreamercsw/validation-manager")); vl.addComponent(desc); vl.addComponent(link); vl.setId(getComponentCaption()); return vl; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.admin.AdminScreenProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout layout = new VerticalLayout(); adminSheet.removeAllComponents();//w ww . j ava2s . c om //Build left side //Build setting tab adminSheet.addTab(getSettingTab(), TRANSLATOR.translate("general.settings")); //Build email setting tab adminSheet.addTab(getEmailSettingTab(), TRANSLATOR.translate("general.email.settings")); //Build user management tab adminSheet.addTab(getUserManagementTab(), TRANSLATOR.translate("menu.user")); //Build configurable items management tab adminSheet.addTab(getConfigurableTab(), TRANSLATOR.translate("general.configuration")); //Build configurable items management tab //TODO: Disabled for now. // adminSheet.addTab(getWorkflowTab(), TRANSLATOR // .translate("workflow.manager")); layout.addComponent(adminSheet); layout.setId(getComponentCaption()); return layout; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.notification.NotificationScreenProvider.java
License:Apache License
@Override public Component getContent() { VerticalLayout vs = new VerticalLayout(); //On top put a list of notifications BeanItemContainer<Notification> container = new BeanItemContainer<>(Notification.class); ValidationManagerUI.getInstance().getUser().getNotificationList().forEach(n -> { container.addBean(n);/* w ww. j a v a 2s. c o m*/ }); // Unable to use VerticalSplitPanel as I hoped. // See: https://github.com/vaadin/framework/issues/9460 // VerticalSplitPanel vs = new VerticalSplitPanel(); // vs.setSplitPosition(25, Sizeable.Unit.PERCENTAGE); TextArea text = new TextArea(TRANSLATOR.translate("general.text")); text.setWordwrap(true); text.setReadOnly(true); text.setSizeFull(); Grid grid = new Grid(TRANSLATOR.translate("general.notifications"), container); grid.setColumns("notificationType", "author", "creationDate", "archieved"); if (container.size() > 0) { grid.setHeightMode(HeightMode.ROW); grid.setHeightByRows(container.size() > 5 ? 5 : container.size()); } GridCellFilter filter = new GridCellFilter(grid); filter.setBooleanFilter("archieved", new GridCellFilter.BooleanRepresentation(VaadinIcons.CHECK, TRANSLATOR.translate("general.yes")), new GridCellFilter.BooleanRepresentation(VaadinIcons.CLOSE, TRANSLATOR.translate("general.no"))); filter.setDateFilter("creationDate", new SimpleDateFormat(VMSettingServer.getSetting("date.format").getStringVal()), true); grid.sort("creationDate"); Column nt = grid.getColumn("notificationType"); nt.setHeaderCaption(TRANSLATOR.translate("notification.type")); nt.setConverter(new Converter<String, NotificationType>() { @Override public NotificationType convertToModel(String value, Class<? extends NotificationType> targetType, Locale locale) throws Converter.ConversionException { for (NotificationType n : new NotificationTypeJpaController( DataBaseManager.getEntityManagerFactory()).findNotificationTypeEntities()) { if (Lookup.getDefault().lookup(InternationalizationProvider.class).translate(n.getTypeName()) .equals(value)) { return n; } } return null; } @Override public String convertToPresentation(NotificationType value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return Lookup.getDefault().lookup(InternationalizationProvider.class) .translate(value.getTypeName()); } @Override public Class<NotificationType> getModelType() { return NotificationType.class; } @Override public Class<String> getPresentationType() { return String.class; } }); Column author = grid.getColumn("author"); author.setConverter(new UserToStringConverter()); author.setHeaderCaption(TRANSLATOR.translate("notification.author")); Column creation = grid.getColumn("creationDate"); creation.setHeaderCaption(TRANSLATOR.translate("creation.time")); Column archive = grid.getColumn("archieved"); archive.setHeaderCaption(TRANSLATOR.translate("general.archived")); archive.setConverter(new Converter<String, Boolean>() { @Override public Boolean convertToModel(String value, Class<? extends Boolean> targetType, Locale locale) throws Converter.ConversionException { return value.equals(TRANSLATOR.translate("general.yes")); } @Override public String convertToPresentation(Boolean value, Class<? extends String> targetType, Locale locale) throws Converter.ConversionException { return value ? TRANSLATOR.translate("general.yes") : TRANSLATOR.translate("general.no"); } @Override public Class<Boolean> getModelType() { return Boolean.class; } @Override public Class<String> getPresentationType() { return String.class; } }); grid.setSelectionMode(SelectionMode.SINGLE); grid.setSizeFull(); ContextMenu menu = new ContextMenu(grid, true); menu.addItem(TRANSLATOR.translate("notification.mark.unread"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setAcknowledgeDate(null); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); menu.addItem(TRANSLATOR.translate("notification.archive"), (MenuItem selectedItem) -> { Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { NotificationServer ns = new NotificationServer((Notification) selected); ns.setArchieved(true); try { ns.write2DB(); ((VMUI) UI.getCurrent()).updateScreen(); ((VMUI) UI.getCurrent()).showTab(getComponentCaption()); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } }); grid.addSelectionListener(selectionEvent -> { // Get selection from the selection model Object selected = ((SingleSelectionModel) grid.getSelectionModel()).getSelectedRow(); if (selected != null) { text.setReadOnly(false); Notification n = (Notification) selected; text.setValue(n.getContent()); text.setReadOnly(true); if (n.getAcknowledgeDate() != null) { try { //Mark as read NotificationServer ns = new NotificationServer((Notification) n); ns.setAcknowledgeDate(new Date()); ns.write2DB(); } catch (VMException ex) { LOG.log(Level.SEVERE, null, ex); } } } }); vs.addComponent(grid); vs.addComponent(text); vs.setSizeFull(); vs.setId(getComponentCaption()); return vs; }
From source file:net.sourceforge.javydreamercsw.validation.manager.web.tester.ExecutionScreen.java
License:Apache License
@Override public Component getContent() { VerticalLayout vl = new VerticalLayout(); update();/*from w w w . j a v a 2s.c o m*/ vl.addComponent(testCaseTree); vl.setId(getComponentCaption()); return vl; }