List of usage examples for com.vaadin.ui VerticalLayout setComponentAlignment
@Override public void setComponentAlignment(Component childComponent, Alignment alignment)
From source file:dhbw.ka.mwi.businesshorizon2.ui.login.LogInScreenViewImpl.java
License:Open Source License
/** * Konkrete Erzeugung des Dialogfensters zur Registrierung eines neuen * Users.// w w w . jav a2 s.co m * * @author Christian Scherer, Marcel Rosenberger, Annika Weis */ public void showRegisterUserDialog() { regDialog = new Window("Benutzer bei Business Horizon registrieren"); regDialog.setModal(true); regDialog.setWidth(400, UNITS_PIXELS); regDialog.setResizable(false); regDialog.setDraggable(false); regDialog.setCaption("Registrierung eines neuen Benutzers"); fl = new FormLayout(); fl.setSpacing(true); fl.setMargin(true); regDialog.addComponent(fl); //Vorname textfieldFirstName = new TextField(); textfieldFirstName.setCaption("Bitte Vornamen angeben: "); textfieldFirstName.setRequired(true); textfieldFirstName.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldFirstName); //Nachname textfieldLastName = new TextField(); textfieldLastName.setCaption("Bitte Nachnamen angeben: "); textfieldLastName.setRequired(true); textfieldLastName.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldLastName); //Unternehmen textfieldCompany = new TextField(); textfieldCompany.setCaption("Bitte Unternehmen angeben: "); textfieldCompany.setRequired(true); textfieldCompany.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldCompany); //Mailadresse textfieldEmailAdress = new TextField(); textfieldEmailAdress.setCaption("Bitte Mailadresse angeben: "); textfieldEmailAdress.setRequired(true); textfieldEmailAdress.setRequiredError("Pflichtfeld"); fl.addComponent(textfieldEmailAdress); //Passwort passwordFieldPassword = new PasswordField("Bitte Passwort whlen: "); passwordFieldPassword.setRequired(true); passwordFieldPassword.setRequiredError("Pflichtfeld"); fl.addComponent(passwordFieldPassword); //Passwort WDH passwordFieldPasswordRep = new PasswordField("Bitte Passwort wiederholen:"); passwordFieldPasswordRep.setRequired(true); passwordFieldPasswordRep.setRequiredError("Pflichtfeld"); fl.addComponent(passwordFieldPasswordRep); VerticalLayout vl = new VerticalLayout(); dialogRegBtn = new Button("Registrierung abschlieen", this); vl.addComponent(dialogRegBtn); vl.setComponentAlignment(dialogRegBtn, Alignment.MIDDLE_CENTER); regDialog.addComponent(vl); getWindow().addWindow(regDialog); logger.debug("Registrier-Dialog erzeugt"); }
From source file:ed.cracken.pos.ui.purchases.PurchaserView.java
public PurchaserView() { summary = SellSummaryTo.builder().count(BigDecimal.ZERO).total(BigDecimal.ZERO).build(); setSizeFull();/* w w w . j av a 2s . c om*/ addStyleName("crud-view"); viewLogic = new PurchaserLogic(this); paymentView = new PurchaserPaymentView(); grid = new PurchaserGrid(); grid.addSelectionListener((SelectionEvent event) -> { viewLogic.editItem(grid.getSelectedRow()); }); VerticalLayout mainContent = new VerticalLayout(); HorizontalLayout foot; mainContent.addComponent(createTopBar()); mainContent.addComponent(grid); mainContent.addComponent(foot = createFooter()); mainContent.setMargin(true); mainContent.setSpacing(true); mainContent.setSizeFull(); mainContent.setExpandRatio(grid, 1); mainContent.setStyleName("crud-main-layout"); mainContent.setComponentAlignment(foot, Alignment.TOP_CENTER); addComponent(mainContent); addComponent(purchaseItemForm = new PurchaseItemForm(viewLogic)); }
From source file:ed.cracken.pos.ui.seller.SellerView.java
public SellerView() { summary = SellSummaryTo.builder().count(BigDecimal.ZERO).total(BigDecimal.ZERO).build(); setSizeFull();// w ww. j a v a 2 s .c o m addStyleName("crud-view"); viewLogic = new SellerLogic(this); paymentView = new SellerPaymentView(); grid = new SellerGrid(); grid.addSelectionListener((SelectionEvent event) -> { viewLogic.editItem(grid.getSelectedRow()); }); VerticalLayout barAndGridLayout = new VerticalLayout(); HorizontalLayout foot; barAndGridLayout.addComponent(createTopBar()); barAndGridLayout.addComponent(grid); barAndGridLayout.addComponent(foot = createFooter()); barAndGridLayout.setMargin(true); barAndGridLayout.setSpacing(true); barAndGridLayout.setSizeFull(); barAndGridLayout.setExpandRatio(grid, 1); barAndGridLayout.setStyleName("crud-main-layout"); barAndGridLayout.setComponentAlignment(foot, Alignment.TOP_CENTER); addComponent(barAndGridLayout); addComponent(sellItemForm = new SellItemForm(viewLogic)); }
From source file:edu.cornell.qatarmed.planrnaseq.BrowseAndAnnotate.java
private void initSearch() { searchField.setInputPrompt("Search Project"); /*//from w w w . j a v a2 s . 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.cornell.qatarmed.planrnaseq.SimpleLoginView.java
public SimpleLoginView() { setSizeFull();//from w w w .j av a2 s . c o m // Create the user input field user = new TextField("User:"); user.setWidth("300px"); user.setRequired(true); user.setInputPrompt("Your username (eg. joe@email.com)"); user.addValidator(new EmailValidator("Username must be an email address")); user.setInvalidAllowed(false); // Create the password input field password = new PasswordField("Password:"); password.setWidth("300px"); password.addValidator(new PasswordValidator()); password.setRequired(true); password.setValue(""); password.setNullRepresentation(""); // Create login button loginButton = new Button("Login", this); // Add both to a panel VerticalLayout fields = new VerticalLayout(user, password, loginButton); fields.setCaption("Please login to access the application. (test@test.com/passw0rd)"); fields.setSpacing(true); fields.setMargin(new MarginInfo(true, true, true, false)); fields.setSizeUndefined(); // The view root layout VerticalLayout viewLayout = new VerticalLayout(fields); viewLayout.setSizeFull(); viewLayout.setComponentAlignment(fields, Alignment.MIDDLE_CENTER); viewLayout.setStyleName(Reindeer.LAYOUT_BLUE); setCompositionRoot(viewLayout); }
From source file:edu.kit.dama.ui.admin.administration.user.MembershipRoleEditorWindow.java
License:Apache License
/** * Get the main layout./* w w w . j a v a 2 s .c o m*/ * * @return The main layout. */ private GridLayout getMainLayout() { if (mainPanel == null) { String id = "mainPanel"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); builder.addComponent(getMembershipsTable(), 0, 0); Label l = new Label( "To update the membership role of the selected group(s) select the new role below and click <i>'Apply New Role'</i>. The new role is limited by the user's maximum role.", ContentMode.HTML); Label spacer = new Label("<br/>", ContentMode.HTML); Button closeButton = new Button("Close"); closeButton.addClickListener((event) -> { close(); }); VerticalLayout actionLayout = new VerticalLayout(l, spacer, getRoleComboBox(), getCommitChangeButton()); actionLayout.setComponentAlignment(l, Alignment.TOP_CENTER); actionLayout.setComponentAlignment(getRoleComboBox(), Alignment.TOP_RIGHT); actionLayout.setComponentAlignment(getCommitChangeButton(), Alignment.TOP_RIGHT); actionLayout.setComponentAlignment(getCommitChangeButton(), Alignment.TOP_RIGHT); actionLayout.setSpacing(true); actionLayout.setSizeFull(); builder.addComponent(actionLayout, 1, 0); builder.addComponent(closeButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1); mainPanel = builder.getLayout(); mainPanel.setId(DEBUG_ID_PREFIX + id); mainPanel.setSizeFull(); mainPanel.setColumnExpandRatio(0, .7f); mainPanel.setColumnExpandRatio(1, .3f); mainPanel.setRowExpandRatio(0, .99f); mainPanel.setRowExpandRatio(1, .01f); mainPanel.setSpacing(true); mainPanel.setMargin(true); updateMainPanel(); } return mainPanel; }
From source file:edu.kit.dama.ui.admin.administration.usergroup.GroupMembershipEditorWindow.java
License:Apache License
private GridLayout getMainLayout() throws AuthorizationException, UnsupportedEnumException { if (mainPanel == null) { String id = "mainPanel"; LOGGER.debug("Building " + DEBUG_ID_PREFIX + id + " ..."); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(2, 2); //add table and exclude button builder.addComponent(getMembersTable(), 0, 0).addComponent(getExcludeMembersButton(), Alignment.BOTTOM_LEFT, 0, 1, 1, 1); Label l = new Label( "To add members select them in the list below and click <i>'Add Member(s)'</i>. To exclude members select them in the table and click <i>'Exclude Member(s)'</i>", ContentMode.HTML); Button closeButton = new Button("Close"); closeButton.addClickListener((event) -> { close();//from w ww . jav a2s. co m }); VerticalLayout actionLayout = new VerticalLayout(l, getUserSelector(), getAddMembersButton()); actionLayout.setComponentAlignment(l, Alignment.TOP_CENTER); actionLayout.setComponentAlignment(getUserSelector(), Alignment.TOP_RIGHT); actionLayout.setComponentAlignment(getAddMembersButton(), Alignment.TOP_RIGHT); actionLayout.setExpandRatio(getUserSelector(), 1.0f); actionLayout.setSpacing(true); actionLayout.setSizeFull(); builder.addComponent(actionLayout, 1, 0, 1, 1).addComponent(closeButton, Alignment.BOTTOM_RIGHT, 1, 1, 1, 1); mainPanel = builder.getLayout(); mainPanel.setId(DEBUG_ID_PREFIX + id); mainPanel.setSizeFull(); mainPanel.setColumnExpandRatio(0, .7f); mainPanel.setColumnExpandRatio(1, .3f); mainPanel.setRowExpandRatio(0, .99f); mainPanel.setRowExpandRatio(1, .01f); mainPanel.setSpacing(true); mainPanel.setMargin(true); updateMainPanel(); } return mainPanel; }
From source file:edu.kit.dama.ui.admin.LandingPageComponent.java
License:Apache License
public final void update(DigitalObject object, boolean privileged) { if (object == null) { UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(1, 1); builder.fill(new Label("Access to digital object not permitted."), 0, 0); mainLayout = builder.getLayout(); mainLayout.setMargin(true);// w w w . j av a 2s. c o m mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); } else { final TextField oidField = new TextField(); Button searchButton = new Button("Search"); Button metsButton = new Button("METS"); final Button dcButton = new Button("DublinCore"); Button dataButton = new Button("Download"); VerticalLayout metadataDownloadButtons = new VerticalLayout(dcButton, metsButton); UIUtils7.GridLayoutBuilder builder = new UIUtils7.GridLayoutBuilder(3, 6); StreamResource metsResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); MetsBuilder.init(object).createMinimalMetsDocument(UserData.WORLD_USER).write(bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (Exception ex) { LOGGER.error("Failed to provide METS document.", ex); UIComponentTools.showError( "Failed to initialize METS document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".mets.xml"); StreamResource dcResource = new StreamResource(() -> { try { ByteArrayOutputStream bout = new ByteArrayOutputStream(); DublinCoreHelper.writeDublinCoreDocument(object, UserData.WORLD_USER, bout); return new ByteArrayInputStream(bout.toByteArray()); } catch (ParserConfigurationException ex) { LOGGER.error("Failed to provide DC document.", ex); UIComponentTools .showError("Failed to initialize DC document for download. Cause: " + ex.getMessage()); return null; } }, object.getDigitalObjectIdentifier() + ".dc.xml"); StreamResource dataResource = new StreamResource(() -> { IMetaDataManager mdm = MetaDataManagement.getMetaDataManagement().getMetaDataManager(); mdm.setAuthorizationContext(AuthorizationContext.factorySystemContext()); try { IAuthorizationContext ctx = new AuthorizationContext(new UserId(Constants.WORLD_USER_ID), new GroupId(Constants.WORLD_USER_ID), Role.GUEST); if (accessGranted(object, ctx) || accessGranted(object, UIHelper.getSessionContext())) { Response response = new PublicDownloadHandler().prepareStream(object); if (response.getStatus() == Response.Status.OK.getStatusCode()) { return (InputStream) response.getEntity(); } else { LOGGER.error("Preparation of the public download for object " + object.getDigitalObjectIdentifier() + " returned status " + response.getStatus() + ". Aborting."); } } throw new IOException("Public access not available."); } catch (IOException ex) { LOGGER.error( "Failed to provide data stream for object " + object.getDigitalObjectIdentifier() + ".", ex); UIComponentTools.showError( "Failed to initialize data stream for public download. Probably, the digital object is not publicly available."); return null; } }, object.getDigitalObjectIdentifier() + ".zip"); Map<String, String> dcElementMap = new HashMap<>(); try { dcElementMap = DublinCoreHelper.createDublinCoreElementMap(object, UserData.WORLD_USER); } catch (ParserConfigurationException ex) { LOGGER.error( "Failed to create DC metadata for object with id " + object.getDigitalObjectIdentifier(), ex); } oidField.setValue(object.getDigitalObjectIdentifier()); FileDownloader metsDownloader = new FileDownloader(metsResource); metsDownloader.extend(metsButton); FileDownloader dcDownloader = new FileDownloader(dcResource); dcDownloader.extend(dcButton); FileDownloader dataDownloader = new FileDownloader(dataResource); dataDownloader.extend(dataButton); oidField.setSizeFull(); searchButton.setWidth("128px"); searchButton.addClickListener((Button.ClickEvent event) -> { String oid = oidField.getValue(); Page.getCurrent().setLocation( URI.create(UIHelper.getWebAppUrl().toString() + "?landing&oid=" + oid).toString()); }); dcButton.setWidth("128px"); metsButton.setWidth("128px"); dataButton.setWidth("128px"); metadataDownloadButtons.setComponentAlignment(dcButton, Alignment.TOP_LEFT); metadataDownloadButtons.setComponentAlignment(metsButton, Alignment.TOP_LEFT); //build layout Label oidLabel = new Label("<u>Object Id</u>", ContentMode.HTML); builder.fillRow(oidLabel, 0, 0, 1); oidLabel.addStyleName("myboldcaption"); builder.addComponent(oidField, 0, 1, 2, 1).addComponent(searchButton, 2, 1); Label dcMetadataLabel = new Label("<u>DC Metadata</u>", ContentMode.HTML); builder.fillRow(dcMetadataLabel, 0, 2, 1); dcMetadataLabel.addStyleName("myboldcaption"); Set<Map.Entry<String, String>> entries = dcElementMap.entrySet(); Table dcTable = new Table(); dcTable.setPageLength(entries.size() + 1); dcTable.addContainerProperty("dc:key", String.class, "-"); dcTable.addContainerProperty("dc:value", String.class, "-"); entries.forEach((entry) -> { Object newItemId = dcTable.addItem(); Item row1 = dcTable.getItem(newItemId); row1.getItemProperty("dc:key").setValue(entry.getKey()); row1.getItemProperty("dc:value").setValue(entry.getValue()); }); dcTable.setWidth("640px"); dcTable.addStyleName("myboldcaption"); builder.addComponent(dcTable, 0, 3, 2, 1); builder.addComponent(metadataDownloadButtons, 2, 3, 1, 1); builder.fillRow(new Label("<u>Data Access</u>", ContentMode.HTML), 0, 4, 1); long bytes = DataOrganizationUtils.getAssociatedDataSize(object.getDigitalObjectId()); String formatted = AbstractFile.formatSize(bytes); Label oidDownloadLabel = new Label( object.getDigitalObjectIdentifier() + ".zip (approx. " + formatted + ")"); oidDownloadLabel.addStyleName("myboldcaption"); builder.addComponent(oidDownloadLabel, 0, 5, 2, 1); builder.addComponent(dataButton, 2, 5, 1, 1); mainLayout = builder.getLayout(); mainLayout.setRowExpandRatio(0, .1f); mainLayout.setRowExpandRatio(1, .1f); mainLayout.setRowExpandRatio(2, .6f); mainLayout.setRowExpandRatio(3, .1f); mainLayout.setRowExpandRatio(4, .1f); mainLayout.setColumnExpandRatio(0, .1f); mainLayout.setColumnExpandRatio(1, .8f); mainLayout.setColumnExpandRatio(2, .1f); } mainLayout.setMargin(true); mainLayout.setSpacing(true); mainLayout.setStyleName("landing"); HorizontalLayout hLayout = new HorizontalLayout(mainLayout); hLayout.setSizeFull(); hLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(hLayout); }
From source file:edu.kit.dama.ui.admin.login.AbstractLoginComponent.java
License:Apache License
/** * Basic initialization of components./*from ww w .ja v a2 s .c o m*/ */ private void initializeLayout() { registrationFormView.setWidth("400px"); loginButton = new Button("Login"); loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); loginButton.setWidth("100px"); loginButton.addClickListener(this); registerButton = new Button("Register"); registerButton.setWidth("100px"); registerButton.addClickListener(this); mainLayout = new UIUtils7.GridLayoutBuilder(2, 2).addComponent(getLoginForm(), 0, 0, 2, 1) .addComponent(registerButton, 0, 1, 1, 1).addComponent(loginButton, 1, 1, 1, 1).getLayout(); mainLayout.setComponentAlignment(getLoginForm(), Alignment.TOP_CENTER); mainLayout.setComponentAlignment(loginButton, Alignment.BOTTOM_RIGHT); mainLayout.setSpacing(true); mainLayout.setMargin(false); mainLayout.setComponentAlignment(registerButton, Alignment.BOTTOM_LEFT); VerticalLayout vLayout = new VerticalLayout(mainLayout); vLayout.setImmediate(true); vLayout.setComponentAlignment(mainLayout, Alignment.MIDDLE_CENTER); setCompositionRoot(vLayout); }
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).// ww w . j av a2 s.com * * @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; }