List of usage examples for com.vaadin.ui Label setDescription
public void setDescription(String description)
From source file:org.opennms.features.vaadin.pmatrix.engine.PmatrixDataSourceImpl.java
License:Open Source License
/** * creates and initializes a PmatrixDataContainer from the * pmatrixSpecification/*from w ww . ja va2s. com*/ */ private void createPmatrixDataContainer() { if (LOG.isDebugEnabled()) LOG.debug("constructing new pmatrix table for table pmatrixName:'" + pmatrixName + "' matrixTitle:'" + pmatrixTitle + "'"); // Define two columns for the built-in container pmatrixDataContainer = new IndexedContainer(); // first column contains row names pmatrixDataContainer.addContainerProperty("rowName", String.class, null); // used to test for duplicate or missing row/column names // note some tests are duplicated - so may show two errors for same problem. However better to keep error messages together Set<String> testColNames = new HashSet<String>(); Set<String> testRowNames = new HashSet<String>(); // set up properties for container if (pmatrixSpecification.getColumnNames() == null || pmatrixSpecification.getColumnNames().isEmpty()) { LOG.error("Pmatrix definition with name:'" + pmatrixName + "' has no column names defined"); } else for (String columnName : pmatrixSpecification.getColumnNames()) { if (testColNames.contains(columnName)) { LOG.error("Pmatrix definition with name:'" + pmatrixName + "' has duplicate column name: '" + columnName + "'"); } else { if (LOG.isDebugEnabled()) LOG.debug("adding columnName:'" + columnName + "' to table:'" + pmatrixName + "'"); testColNames.add(columnName); pmatrixDataContainer.addContainerProperty(columnName, Component.class, null); } } // set up items for container if (pmatrixSpecification.getRowNames() == null || pmatrixSpecification.getRowNames().isEmpty()) { LOG.error("Pmatrix definition with name:'" + pmatrixName + "' has no row names defined"); } else for (String rowName : pmatrixSpecification.getRowNames()) { if (LOG.isDebugEnabled()) LOG.debug("adding rowName:'" + rowName + "' to table:'" + pmatrixName); if (testRowNames.contains(rowName)) { LOG.error("Pmatrix definition with name:'" + pmatrixName + "' has duplicate row name: '" + rowName + "'"); } else { testRowNames.add(rowName); Item row = pmatrixDataContainer.addItem(rowName); row.getItemProperty("rowName").setValue(rowName); // fill empty cells with empty values for (String colName : pmatrixSpecification.getColumnNames()) { String notDefinedStr = "<div class=\"pmatrix.notdefined\" style=\"vertical-align: middle; text-align: center; color:black; \">-</div>"; Label label = new Label(notDefinedStr, ContentMode.HTML); label.setDescription("A data value has not <BR>been defined for this cell."); row.getItemProperty(colName).setValue(label); } } } // set up data types if exist List<DataPointDefinition> dataPointDefintions = pmatrixSpecification.getDatapointDefinitions(); for (DataPointDefinition dpd : dataPointDefintions) { if (dpd.getRowName() != null && dpd.getColName() != null && testColNames.contains(dpd.getColName()) && testRowNames.contains(dpd.getRowName())) { } else { LOG.error("data point definition uses unknown row or column names for table name:'" + pmatrixName + "': row name:'" + dpd.getRowName() + "' is in table:" + testRowNames.contains(dpd.getRowName()) + "; col name:'" + dpd.getColName() + "' is in table:" + testColNames.contains(dpd.getColName()) + "; filePath:'" + dpd.getFilePath() + "'"); } } for (DataPointDefinition dpd : dataPointDefintions) { Item row = pmatrixDataContainer.getItem(dpd.getRowName()); if (row == null) { LOG.error("pmatrix row in definition does not exist for table name:'" + pmatrixName + "': row name:'" + dpd.getRowName() + "' filePath:'" + dpd.getFilePath() + "'"); } else { Property cell = row.getItemProperty(dpd.getColName()); // strange - vaadin will return a cell with a null value even if not defined if (cell == null || cell.getValue() == null) { LOG.error("pmatrix cell in definition does not exist for table name:'" + pmatrixName + "': row name:'" + dpd.getRowName() + "' col name:'" + dpd.getColName() + "' filePath:'" + dpd.getFilePath() + "'"); } else { if (dpd.getGraphURL() == null) { String filePath = dpd.getFilePath(); if (LOG.isDebugEnabled()) LOG.debug( "graphURL not defined. You need to create a url for point definition filePath:" + filePath); // TODO create URL from filePath if doesn't exist // Not possible to easily do a translation from filepath TO URL - information is missing for translation to correct graph // <filePath>/home/isawesome/devel/opennms-test/dist/share/rrd/response/204.79.197.200/icmp.jrb</filePath> // <graphURL>http://localhost:8980/opennms/graph/results.htm?resourceId=node[3].responseTime[204.79.197.200]&reports=icmp</graphURL> // This is difficult because PSMSDuration is actually included in a different report see jvm-graph.properties // report.jvm.gc.psms.columns=PSMSCollCnt, PSMSCollTime, PSMSDuration // <path>/home/isawesome/devel/opennms-test/dist/share/rrd/snmp/4/opennms-jvm/PSMSDuration.jrb</path> // http://localhost:8980/opennms/graph/results.htm?zoom=true&relativetime=custom&resourceId=node[4].responseTime[127.0.0.1]&reports=http&start=1392033278231&end=1392119678231 // http://localhost:8980/opennms/graph/results.htm?zoom=true&relativetime=custom&resourceId=node[4].responseTime[127.0.0.1]&reports=icmp&start=1392033278231&end=1392119678231 } String labelStr = labelStrFromDpd(dpd); //Note using Label instead of Link because Link proved very difficult to style Label label = new Label(labelStr, ContentMode.HTML); String mouseOverText = mouseOverTextEnabled ? dpd.getMouseOverText() : ""; label.setDescription(mouseOverText); cell.setValue(label); // insert data value point in localDataPointMap if not // duplicated. if (localDataPointMap.putIfAbsent(dpd.getFilePath(), dpd) != null) { LOG.error("the filePath in a dataPointDefinition is duplicated in table definition name:'" + pmatrixName + "' for data point definition:" + " row name:'" + dpd.getRowName() + "' col name:'" + dpd.getColName() + "' filePath:' " + dpd.getFilePath() + "'"); } } } } }
From source file:org.opennms.features.vaadin.pmatrix.engine.PmatrixDataSourceImpl.java
License:Open Source License
/** * updates the DataSourceContainer from a dataPointMapDao without synchronization *///from w w w . ja v a 2 s . c om private void updateDsc() { IndexedContainer pmdc = getPmatrixDataContainer(); // this deals with the minor race when the PmatrixDatasource registers for updates before the table is fully defined. if (pmdc == null) { if (LOG.isDebugEnabled()) LOG.debug("cannot update datasource container as still being constructed"); return; } // check each value in dataPointMapDao if defined in localDataPointMap. If not then ignore. for (String dataPointFilePath : dataPointMapDao.getDataPointMap().keySet()) { DataPointDefinition localdpd = localDataPointMap.get(dataPointFilePath); if (localdpd == null) { // if no local definition for this data point then do nothing and return } else { //Long lastCellUpdateTime = localdpd.getLatestTimestamp(); // if there is a local definition update it with the latest calculation PmatrixDpdCalculator pmatrixDpdCalculator = dataPointMapDao.getDataPointMap() .get(dataPointFilePath); // if the localdpd has a different update time to the calculator then the calculator has been updated // this prevents display container updates when not needed //TODO SET ALWAYS TRUE THE PROBLEM IS THAT IF UPDATE ONLY HAPPENS ONCE, ALL TABLES ARE NOT UPDATED //THERE SEEMS TO BE A PROBLEM WITH VAADIN UPDATING TABLES boolean dataIsChanged = true; if (localdpd.getRealUpdateTime() != pmatrixDpdCalculator.getRealUpdateTime()) { dataIsChanged = true; } pmatrixDpdCalculator.updateDpd(localdpd); // if there is a local definition then use the row name and column name to update the local cell with data Property cell = pmdc.getContainerProperty(localdpd.getRowName(), localdpd.getColName()); if (cell == null) { LOG.error( "could not copy value from dataPointMap to pmatrixDataContainer because it couldnt be found in pmatrixDataContainer " + "' dataPointFilePath:' " + dataPointFilePath + "'"); } else { //Note using Label instead of Link because Link proved very difficult to style String labelStr = labelStrFromDpd(localdpd); // create new label and update container if data is changed or value is indeterminate if (dataIsChanged || Integer.valueOf(DataPointDefinition.RANGE_INDETERMINATE) .equals(localdpd.getLatestDataValueRange())) { //Label label= new Label(labelStr, ContentMode.HTML); Label label = (Label) cell.getValue(); label.setValue(labelStr); String mouseOverText = mouseOverTextEnabled ? localdpd.getMouseOverText() : ""; label.setDescription(mouseOverText); cell.setValue(label); } } } } }
From source file:org.opennms.netmgt.bsm.vaadin.adminpage.BusinessServiceTreeTable.java
License:Open Source License
public BusinessServiceTreeTable(BusinessServiceManager businessServiceManager) { this.businessServiceManager = Objects.requireNonNull(businessServiceManager); setSizeFull();/* ww w . j a v a2s . c o m*/ setContainerDataSource(new BusinessServiceContainer()); // Add the "LINKS" columns addGeneratedColumn("links", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { final HorizontalLayout layout = new HorizontalLayout(); final BusinessServiceStateMachine stateMachine = businessServiceManager.getStateMachine(); final BusinessService businessService = getItem(itemId).getBean().getBusinessService(); final Status status = stateMachine.getOperationalStatus(businessService); if (status != null) { // Build the query string final List<BasicNameValuePair> urlParms = Lists.newArrayList( new BasicNameValuePair("focus-vertices", businessService.getId().toString()), new BasicNameValuePair("szl", "1"), new BasicNameValuePair("layout", "Hierarchy Layout"), new BasicNameValuePair("provider", "Business Services")); final String queryString = URLEncodedUtils.format(urlParms, Charset.forName("UTF-8")); // Generate the link final Link link = new Link("View in Topology UI", new ExternalResource(String.format("/opennms/topology?%s", queryString))); link.setIcon(FontAwesome.EXTERNAL_LINK_SQUARE); // This app is typically access in an iframe, so we open the URL in a new window/tab link.setTargetName("_blank"); layout.addComponent(link); layout.setComponentAlignment(link, Alignment.MIDDLE_CENTER); } else { Label label = new Label("N/A"); label.setDescription("Try reloading the daemon and refreshing the table."); label.setWidth(null); layout.addComponent(label); } return layout; } }); // add edit and delete buttons addGeneratedColumn("edit / delete", new Table.ColumnGenerator() { private static final long serialVersionUID = 7113848887128656685L; @Override public Object generateCell(Table source, Object itemId, Object columnId) { HorizontalLayout layout = new HorizontalLayout(); layout.setSpacing(true); Button editButton = new Button("Edit", FontAwesome.PENCIL_SQUARE_O); editButton.setId("editButton-" + getItem(itemId).getBean().getName()); editButton.addClickListener(UIHelper.getCurrent(TransactionAwareUI.class) .wrapInTransactionProxy((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); final BusinessServiceEditWindow window = new BusinessServiceEditWindow(businessService, businessServiceManager); window.addCloseListener(e -> refresh()); getUI().addWindow(window); })); layout.addComponent(editButton); Button deleteButton = new Button("Delete", FontAwesome.TRASH_O); deleteButton.setId("deleteButton-" + getItem(itemId).getBean().getName()); deleteButton.addClickListener((Button.ClickListener) event -> { final Long businessServiceId = getItem(itemId).getBean().getBusinessService().getId(); BusinessService businessService = businessServiceManager .getBusinessServiceById(businessServiceId); if (businessService.getParentServices().isEmpty() && businessService.getChildEdges().isEmpty()) { UIHelper.getCurrent(TransactionAwareUI.class).runInTransaction(() -> { businessServiceManager.getBusinessServiceById(businessServiceId).delete(); refresh(); }); } else { new org.opennms.netmgt.vaadin.core.ConfirmationDialog() .withOkAction((org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action) UIHelper .getCurrent(TransactionAwareUI.class).wrapInTransactionProxy( new org.opennms.netmgt.vaadin.core.ConfirmationDialog.Action() { @Override public void execute( org.opennms.netmgt.vaadin.core.ConfirmationDialog window) { businessServiceManager .getBusinessServiceById(businessServiceId).delete(); refresh(); } })) .withOkLabel("Delete anyway").withCancelLabel("Cancel").withCaption("Warning") .withDescription( "This entry is referencing or is referenced by other Business Services! Do you really want to delete this entry?") .open(); } }); layout.addComponent(deleteButton); return layout; } }); setColumnExpandRatio("name", 5); setColumnExpandRatio("links", 1); setColumnExpandRatio("edit / delete", 1); }
From source file:org.sensorhub.ui.GenericConfigForm.java
License:Mozilla Public License
protected Component buildTabs(final String propId, final ContainerProperty prop, final FieldGroup fieldGroup) { GridLayout layout = new GridLayout(); layout.setWidth(100.0f, Unit.PERCENTAGE); // title bar/*from ww w . jav a 2 s .com*/ HorizontalLayout titleBar = new HorizontalLayout(); titleBar.setMargin(new MarginInfo(true, false, false, false)); titleBar.setSpacing(true); String label = prop.getLabel(); if (label == null) label = DisplayUtils.getPrettyName((String) propId); Label sectionLabel = new Label(label); sectionLabel.setDescription(prop.getDescription()); sectionLabel.addStyleName(STYLE_H3); sectionLabel.addStyleName(STYLE_COLORED); titleBar.addComponent(sectionLabel); layout.addComponent(titleBar); // create one tab per item in container final MyBeanItemContainer<Object> container = prop.getValue(); final TabSheet tabs = new TabSheet(); tabs.setSizeFull(); int i = 1; for (Object itemId : container.getItemIds()) { MyBeanItem<Object> childBeanItem = (MyBeanItem<Object>) container.getItem(itemId); IModuleConfigForm subform = AdminUI.getInstance().generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform).setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); Tab tab = tabs.addTab(subform, "Item #" + (i++)); tab.setClosable(true); // store item id so we can map a tab with the corresponding bean item ((AbstractComponent) subform).setData(itemId); } // draw icon on last tab to add new items tabs.addTab(new VerticalLayout(), "", UIConstants.ADD_ICON); // catch close event to delete item tabs.setCloseHandler(new CloseHandler() { private static final long serialVersionUID = 1L; @Override public void onTabClose(TabSheet tabsheet, Component tabContent) { final Tab tab = tabs.getTab(tabContent); final ConfirmDialog popup = new ConfirmDialog( "Are you sure you want to delete " + tab.getCaption() + "?</br>All settings will be lost."); popup.addCloseListener(new CloseListener() { private static final long serialVersionUID = 1L; @Override public void windowClose(CloseEvent e) { if (popup.isConfirmed()) { // retrieve id of item shown on tab AbstractComponent tabContent = (AbstractComponent) tab.getComponent(); Object itemId = tabContent.getData(); // remove from UI int deletedTabPos = tabs.getTabPosition(tab); tabs.removeTab(tab); tabs.setSelectedTab(deletedTabPos - 1); // remove from container container.removeItem(itemId); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } }); // catch select event on '+' tab to add new item tabs.addSelectedTabChangeListener(new SelectedTabChangeListener() { private static final long serialVersionUID = 1L; public void selectedTabChange(SelectedTabChangeEvent event) { Component selectedTab = event.getTabSheet().getSelectedTab(); final Tab tab = tabs.getTab(selectedTab); final int selectedTabPos = tabs.getTabPosition(tab); // case of + tab to add new item if (tab.getCaption().equals("")) { tabs.setSelectedTab(selectedTabPos - 1); try { // show popup to select among available module types String title = "Please select the desired option"; Map<String, Class<?>> typeList = GenericConfigForm.this.getPossibleTypes(propId); ObjectTypeSelectionPopup popup = new ObjectTypeSelectionPopup(title, typeList, new ObjectTypeSelectionCallback() { public void typeSelected(Class<?> objectType) { try { // add new item to container MyBeanItem<Object> childBeanItem = container.addBean( objectType.newInstance(), ((String) propId) + PROP_SEP); // generate form for new item IModuleConfigForm subform = AdminUI.getInstance() .generateForm(childBeanItem.getBean().getClass()); subform.build(null, childBeanItem); ((MarginHandler) subform) .setMargin(new MarginInfo(true, false, true, false)); allForms.add(subform); // add new tab and select it Tab newTab = tabs.addTab(subform, "Item #" + (selectedTabPos + 1), null, selectedTabPos); newTab.setClosable(true); tabs.setSelectedTab(newTab); } catch (Exception e) { Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); popup.setModal(true); AdminUI.getInstance().addWindow(popup); } catch (Exception e) { e.printStackTrace(); } } } }); // also register commit handler fieldGroup.addCommitHandler(new CommitHandler() { private static final long serialVersionUID = 1L; @Override public void preCommit(CommitEvent commitEvent) throws CommitException { } @Override public void postCommit(CommitEvent commitEvent) throws CommitException { // make sure new items are transfered to model prop.setValue(prop.getValue()); } }); layout.addComponent(tabs); return layout; }
From source file:org.sensorhub.ui.SWECommonForm.java
License:Mozilla Public License
protected Component buildWidget(DataComponent dataComponent, boolean showValues) { if (dataComponent instanceof DataRecord || dataComponent instanceof Vector) { VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, false)); l.setDescription(getTooltip(dataComponent)); layout.addComponent(l);//from ww w. j a v a2 s . c o m VerticalLayout form = new VerticalLayout(); form.setMargin(new MarginInfo(false, false, false, true)); form.setSpacing(false); for (int i = 0; i < dataComponent.getComponentCount(); i++) { DataComponent c = dataComponent.getComponent(i); Component w = buildWidget(c, showValues); if (w != null) form.addComponent(w); } layout.addComponent(form); return layout; } else if (dataComponent instanceof DataArray) { DataArray dataArray = (DataArray) dataComponent; VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, false)); l.setDescription(getTooltip(dataComponent)); layout.addComponent(l); VerticalLayout form = new VerticalLayout(); form.setMargin(new MarginInfo(false, false, false, true)); form.setSpacing(false); form.addComponent(buildWidget(dataArray.getElementType(), false)); layout.addComponent(form); return layout; } else if (dataComponent instanceof DataChoice) { DataChoice dataChoice = (DataChoice) dataComponent; VerticalLayout layout = new VerticalLayout(); Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataChoice, false)); l.setDescription(getTooltip(dataChoice)); layout.addComponent(l); return layout; } else if (dataComponent instanceof SimpleComponent) { Label l = new Label(); l.setContentMode(ContentMode.HTML); l.setValue(getCaption(dataComponent, showValues)); l.setDescription(getTooltip(dataComponent)); return l; } return null; }
From source file:org.vaadin.arborgraph.demo.DemoApplication.java
License:Open Source License
private Label getHelpLabel(String help) { Label retval = new Label(); retval.addStyleName("help"); retval.setDescription(help); retval.setWidth(18, Sizeable.UNITS_PIXELS); retval.setHeight(18, Sizeable.UNITS_PIXELS); return retval; }
From source file:probe.com.view.body.quantdatasetsoverview.quantproteinstabsheet.studies.PeptidesComparisonsSequenceLayout.java
/** * * @param cp/*w ww. j av a2s .c o m*/ * @param width * @param Quant_Central_Manager */ public PeptidesComparisonsSequenceLayout(QuantCentralManager Quant_Central_Manager, final DiseaseGroupsComparisonsProteinLayout cp, int width) { this.studiesMap = new LinkedHashMap<String, StudyInfoData>(); this.setColumns(4); this.setRows(3); this.setWidthUndefined(); this.setSpacing(true); this.setMargin(new MarginInfo(true, false, false, false)); comparisonTitle = new Label(); comparisonTitle.setContentMode(ContentMode.HTML); comparisonTitle.setStyleName("custChartLabelHeader"); comparisonTitle.setWidth((width - 55) + "px"); this.addComponent(comparisonTitle, 1, 0); this.setComponentAlignment(comparisonTitle, Alignment.TOP_LEFT); closeBtn = new VerticalLayout(); closeBtn.setWidth("20px"); closeBtn.setHeight("20px"); closeBtn.setStyleName("closebtn"); this.addComponent(closeBtn, 2, 0); this.setComponentAlignment(closeBtn, Alignment.TOP_RIGHT); //end of toplayout //init comparison study layout GridLayout proteinSequenceComparisonsContainer = new GridLayout(2, cp.getComparison().getDatasetIndexes().length); proteinSequenceComparisonsContainer.setWidthUndefined(); proteinSequenceComparisonsContainer.setHeightUndefined(); proteinSequenceComparisonsContainer.setStyleName(Reindeer.LAYOUT_WHITE); proteinSequenceComparisonsContainer.setSpacing(true); proteinSequenceComparisonsContainer.setMargin(new MarginInfo(true, false, false, false)); this.addComponent(proteinSequenceComparisonsContainer, 1, 1); coverageWidth = (width - 100 - 180); Map<Integer, Set<QuantPeptide>> dsQuantPepMap = new HashMap<Integer, Set<QuantPeptide>>(); for (QuantPeptide quantPep : cp.getQuantPeptidesList()) { if (!dsQuantPepMap.containsKey(quantPep.getDsKey())) { Set<QuantPeptide> subList = new HashSet<QuantPeptide>(); dsQuantPepMap.put(quantPep.getDsKey(), subList); } Set<QuantPeptide> subList = dsQuantPepMap.get(quantPep.getDsKey()); subList.add(quantPep); dsQuantPepMap.put(quantPep.getDsKey(), subList); } int numb = 0; int panelWidth = Page.getCurrent().getBrowserWindowWidth() - 100; String groupCompTitle = cp.getComparison().getComparisonHeader(); String updatedHeader = groupCompTitle.split(" / ")[0].split("\n")[0] + " / " + groupCompTitle.split(" / ")[1].split("\n")[0];//+ " ( " + groupCompTitle.split(" / ")[1].split("\n")[1] + " )"; ; final StudyInformationPopupComponent studyInformationPopupPanel = new StudyInformationPopupComponent( panelWidth, cp.getProtName(), cp.getUrl(), cp.getComparison().getComparisonFullName()); studyInformationPopupPanel.setVisible(false); LayoutEvents.LayoutClickListener studyListener = new LayoutEvents.LayoutClickListener() { @Override public void layoutClick(LayoutEvents.LayoutClickEvent event) { Integer dsId; if (event.getComponent() instanceof AbsoluteLayout) { dsId = (Integer) ((AbsoluteLayout) event.getComponent()).getData(); } else { dsId = (Integer) ((VerticalLayout) event.getComponent()).getData(); } studyInformationPopupPanel.updateContent(dsToStudyLayoutMap.get(dsId)); } }; TreeSet<QuantProtein> orderSet = new TreeSet<QuantProtein>(cp.getDsQuantProteinsMap().values()); for (QuantProtein quantProtein : orderSet) { StudyInfoData exportData = new StudyInfoData(); exportData.setCoverageWidth(coverageWidth); Label studyTitle = new Label();//"Study " + (numb + 1)); studyTitle.setStyleName("peptideslayoutlabel"); studyTitle.setHeightUndefined(); studyTitle.setWidth("200px"); Label iconTitle = new Label("#Patients (" + (quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()) + ")"); exportData.setSubTitle(iconTitle.getValue()); iconTitle.setStyleName("peptideslayoutlabel"); iconTitle.setHeightUndefined(); if (quantProtein.getStringPValue().equalsIgnoreCase("Not Significant") || quantProtein.getStringFCValue().equalsIgnoreCase("Not regulated")) { iconTitle.setStyleName("notregicon"); exportData.setTrend(0); } else if (quantProtein.getStringFCValue().equalsIgnoreCase("Decreased")) { iconTitle.setStyleName("downarricon"); exportData.setTrend(-1); } else { exportData.setTrend(1); iconTitle.setStyleName("uparricon"); } iconTitle.setDescription(cp.getProteinAccssionNumber() + " : #Patients (" + (quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()) + ") " + quantProtein.getStringFCValue() + " " + quantProtein.getStringPValue() + ""); VerticalLayout labelContainer = new VerticalLayout(); labelContainer.addComponent(studyTitle); labelContainer.addComponent(iconTitle); proteinSequenceComparisonsContainer.addComponent(labelContainer, 0, numb); proteinSequenceComparisonsContainer.setComponentAlignment(labelContainer, Alignment.TOP_CENTER); Map<Integer, ComparisonDetailsBean> patientGroupsNumToDsIdMap = new HashMap<Integer, ComparisonDetailsBean>(); ComparisonDetailsBean pGr = new ComparisonDetailsBean(); patientGroupsNumToDsIdMap .put((quantProtein.getPatientsGroupIINumber() + quantProtein.getPatientsGroupINumber()), pGr); QuantDatasetObject ds; ds = Quant_Central_Manager.getFullQuantDatasetMap().get(quantProtein.getDsKey()); StudyPopupLayout study = new StudyPopupLayout(panelWidth, quantProtein, ds, cp.getProteinAccssionNumber(), cp.getUrl(), cp.getProtName(), Quant_Central_Manager.getDiseaseHashedColorMap()); Set<QuantDatasetObject> qdsSet = new HashSet<QuantDatasetObject>(); qdsSet.add(ds); study.setInformationData(qdsSet, cp); dsToStudyLayoutMap.put(ds.getDsKey(), study); labelContainer.addLayoutClickListener(studyListener); labelContainer.setData(ds.getDsKey()); studyTitle.setValue("[" + (numb + 1) + "] " + ds.getAuthor()); exportData.setTitle(ds.getAuthor()); if (dsQuantPepMap.get(quantProtein.getDsKey()) == null) { Label noPeptidesInfoLabel = new Label("No Peptide Information Available "); noPeptidesInfoLabel.setHeightUndefined(); noPeptidesInfoLabel.setStyleName("peptideslayoutlabel"); VerticalLayout labelValueContainer = new VerticalLayout(); labelValueContainer.addComponent(noPeptidesInfoLabel); labelValueContainer.addLayoutClickListener(studyListener); labelValueContainer.setData(ds.getDsKey()); proteinSequenceComparisonsContainer.addComponent(labelValueContainer, 1, numb); proteinSequenceComparisonsContainer.setComponentAlignment(labelValueContainer, Alignment.TOP_CENTER); numb++; studiesMap.put((numb + 1) + ds.getAuthor(), exportData); continue; } String key = "_-_" + quantProtein.getDsKey() + "_-_" + cp.getProteinAccssionNumber() + "_-_"; PeptidesInformationOverviewLayout peptideInfoLayout = new PeptidesInformationOverviewLayout( cp.getSequence(), dsQuantPepMap.get(quantProtein.getDsKey()), coverageWidth, true, studyListener, ds.getDsKey()); exportData.setPeptidesInfoList(peptideInfoLayout.getStackedPeptides()); exportData.setLevelsNumber(peptideInfoLayout.getLevel()); hasPTM = peptideInfoLayout.isHasPTM(); peptidesInfoLayoutDSIndexMap.put(key, peptideInfoLayout); proteinSequenceComparisonsContainer.addComponent(peptideInfoLayout, 1, numb); numb++; studiesMap.put((numb + 1) + ds.getAuthor(), exportData); } String rgbColor = Quant_Central_Manager .getDiseaseHashedColor(groupCompTitle.split(" / ")[1].split("\n")[1]); comparisonTitle.setValue("<font color='" + rgbColor + "' style='font-weight: bold;'>" + updatedHeader + " (#Datasets " + numb + "/" + cp.getComparison().getDatasetIndexes().length + ")</font>"); comparisonTitle.setDescription(cp.getComparison().getComparisonFullName()); VerticalLayout bottomSpacer = new VerticalLayout(); bottomSpacer.setWidth((width - 100) + "px"); bottomSpacer.setHeight("10px"); bottomSpacer.setStyleName("dottedline"); this.addComponent(bottomSpacer, 1, 2); }
From source file:probe.com.view.body.searching.SearchingFiltersControl.java
private VerticalLayout initFilterLabel(String title) { Label filterLabel = new Label(title); filterLabel.setContentMode(ContentMode.HTML); filterLabel.setStyleName("showFilterLabelHeader"); filterLabel.setDescription("Drop all " + title + " filter"); VerticalLayout layout = new VerticalLayout(); // layout.setId(title); layout.addComponentAsFirst(filterLabel); layout.addLayoutClickListener(listener); return layout; }
From source file:probe.com.view.body.welcomelayout.PublicationsInformationWindow.java
private VerticalLayout initPublicationLayout(Object[] publicationData) { VerticalLayout publicationlayout = new VerticalLayout(); publicationlayout.setWidth("500px"); publicationlayout.setHeightUndefined(); publicationlayout.setSpacing(true);/*www . j a v a 2 s . c om*/ publicationlayout.setMargin(new MarginInfo(false, false, false, false)); publicationlayout.setStyleName("publicationstyle"); Label pubmedIdLabel = new Label( "<h5>Pubmed Id: <a href='http://www.ncbi.nlm.nih.gov/pubmed/" + publicationData[0].toString() + "' target='_blank' ><font style:'text-decoration:underline !important;'>" + publicationData[0].toString() + "</font></a></h5>"); pubmedIdLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(pubmedIdLabel); pubmedIdLabel.setHeight("40px"); Label proteinsNumLabel = new Label("<h5>#Proteins: " + publicationData[5].toString() + "</h5>"); proteinsNumLabel.setDescription("Number of publication proteins " + publicationData[4].toString()); proteinsNumLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(proteinsNumLabel); proteinsNumLabel.setHeight("40px"); Label uproteinsNumLabel = new Label( "<h5>#Publication Specific Proteins: " + publicationData[4].toString() + "</h5>"); uproteinsNumLabel .setDescription("Number of publication specific proteins " + publicationData[4].toString()); uproteinsNumLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(uproteinsNumLabel); uproteinsNumLabel.setHeight("40px"); Label PeptidesNumLabel = new Label("<h5>#Peptides: " + publicationData[7].toString() + "</h5>"); PeptidesNumLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(PeptidesNumLabel); PeptidesNumLabel.setDescription("Number of publication peptides " + publicationData[7].toString()); PeptidesNumLabel.setHeight("40px"); Label uPeptidesNumLabel = new Label( "<h5>#Publication Specific Peptides: " + publicationData[6].toString() + "</h5>"); uPeptidesNumLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(uPeptidesNumLabel); uPeptidesNumLabel .setDescription("Number of publication specific peptides " + publicationData[6].toString()); uPeptidesNumLabel.setHeight("40px"); Label titleLabel = new Label( "<textarea rows='5' cols='52' readonly >" + publicationData[3].toString() + "</textarea>"); titleLabel.setContentMode(ContentMode.HTML); publicationlayout.addComponent(titleLabel); titleLabel.setHeight("100px"); return publicationlayout; }
From source file:ro.zg.netcell.vaadin.action.application.OpenSelectedEntityHandler.java
License:Apache License
@Override public void handle(final ActionContext actionContext) throws Exception { final ComponentContainer container = actionContext.getTargetContainer(); container.removeAllComponents();//w ww .j a v a2s. c o m // container.setSizeFull(); // container.setMargin(false); final OpenGroupsApplication app = actionContext.getApp(); final Entity entity = actionContext.getEntity(); EntityState entityState = entity.getState(); boolean isOpened = entityState.isOpened(); String complexEntityType = entity.getComplexType(); ApplicationConfigManager appConfigManager = app.getAppConfigManager(); List<String> subtyesList = appConfigManager.getSubtypesForComplexType(complexEntityType); // Panel currentContainer = (Panel) container; ComponentContainer currentContainer = container; entity.setEntityContainer(container); CssLayout headerContainer = new CssLayout(); headerContainer.addStyleName("entity-header-container"); currentContainer.addComponent(headerContainer); // CssLayout titleContainer = new CssLayout(); // titleContainer.setWidth("80%"); // titleContainer.addStyleName(OpenGroupsStyles.MIDDLE_LEFT); // headerContainer.addComponent(titleContainer); // titleContainer.setSizeFull(); // /* show level */ // String levelMsg = getMessage("level"); // Label levelLabel = new Label(levelMsg+" "+entity.getDepth()); // titleContainer.addComponent(levelLabel); /* show entity type */ if (entity.getState().isEntityTypeVisible()) { String entityTypeCaption = getMessage(entity.getComplexType()); String size = OpenGroupsIconsSet.MEDIUM; if (entity.getContent() != null) { size = OpenGroupsIconsSet.LARGE; } // Label typeIcon = new Label(); // typeIcon.setDescription(entityTypeCaption); // typeIcon.setIcon(OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), // size)); // typeIcon.setSizeUndefined(); // typeIcon.addStyleName("top-left right-margin-20"); // headerContainer.addComponent(typeIcon); Embedded eicon = new Embedded(null, OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), size)); eicon.setDescription(entityTypeCaption); eicon.addStyleName("top-left right-margin-20"); headerContainer.addComponent(eicon); // Embedded eicon2 = new Embedded("", // OpenGroupsResources.getIcon(entity.getComplexType().toLowerCase(), // size)); // eicon2.setDescription(entityTypeCaption); // eicon2.addStyleName("top-left right-margin-20"); // headerContainer.addComponent(eicon2); } // Label test = new Label("test"); // test.setSizeUndefined(); // test.addStyleName("top-left"); // headerContainer.addComponent(test); /* add last action for this entity */ if (entity.getLastActionType() != null) { String actionType = entity.getLastActionType(); String msg = getMessage(actionType); // Label actionLabel = new Label(); // actionLabel.setDescription(msg); // actionLabel.setIcon(OpenGroupsResources.getIcon(actionType, // OpenGroupsIconsSet.MEDIUM)); // actionLabel.setSizeUndefined(); // actionLabel.addStyleName(OpenGroupsStyles.MIDDLE_LEFT); // titleContainer.addComponent(actionLabel); Embedded actionIcon = new Embedded(null, OpenGroupsResources.getIcon(actionType, OpenGroupsIconsSet.MEDIUM)); actionIcon.setDescription(msg); actionIcon.addStyleName("top-left right-margin-20"); headerContainer.addComponent(actionIcon); } EntityLink selectedCause = entity.getSelectedCause(); /* display title */ /* if the entity is open */ /* treat leafs like all posts 21.08.2012 */ if (isOpened /* * || (subtyesList == null && entity.getLastActionType() == * null) */) { Label title = new Label(entity.getTitle()); if (isOpened) { title.addStyleName(OpenGroupsStyles.TITLE_LINK); } else { title.addStyleName("list-issue-title"); } // title.addStyleName("top-left"); // title.setSizeFull(); title.setWidth("80%"); // title.setHeight("100%"); headerContainer.addComponent(title); } else { // Button titleLink = new Button(entity.getTitle()); // titleLink.setWidth("100%"); // titleLink.addStyleName(BaseTheme.BUTTON_LINK); // titleLink.addStyleName("issue-title"); // titleLink.setDescription(entity.getContentPreview()); Label titleLink = null; /* treat leafs like all posts 21.08.2012 */ // if (subtyesList != null) { titleLink = OpenGroupsUtil.getLinkForEntity(entity, app); titleLink.setDescription(entity.getContentPreview()); titleLink.addStyleName("list-issue-title"); // } // /* is a leaf entity in the recent activity list */ // else { // String parentTitle = selectedCause.getParentTitle(); // Entity parentEntity = new Entity(selectedCause.getParentId()); // parentEntity.setTitle(parentTitle); // // parentEntity.getState().setDesiredActionsPath( // complexEntityType + // Defaults.getDefaultActionForEntityType(complexEntityType)); // titleLink = OpenGroupsUtil.getLinkForEntity(parentEntity, app, // entity.getTitle()); // titleLink.setDescription(entity.getContentPreview()); // titleLink.addStyleName("list-issue-title"); // // } // titleLink.setWidth("75%"); titleLink.addStyleName("top-left"); headerContainer.addComponent(titleLink); // titleContainer.setExpandRatio(titleLink, 10f); // currentContainer.addStyleName("list-item"); } /* add parent link */ if (selectedCause != null && !isOpened && entity.getContent() == null) { // CssLayout parentInfoContainer = new CssLayout(); // parentInfoContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); // headerContainer.addComponent(parentInfoContainer); // headerContainer.setColumnExpandRatio(1, 1f); // headerContainer.setComponentAlignment(parentInfoContainer, // Alignment.TOP_RIGHT); /* if parent entity is the current selected entity, say it */ Entity mainEntity = actionContext.getMainEntity(); if (selectedCause.getParentId() == mainEntity.getId()) { // String currentMsg = getMessage(mainEntity.getComplexType() + // ".current"); // Label currentEntityLabel = new Label(currentMsg); // currentEntityLabel.setSizeUndefined(); // currentEntityLabel.addStyleName("top-right"); // headerContainer.addComponent(currentEntityLabel); // titleContainer.setExpandRatio(currentEntityLabel, 2f); } else {/* add link to the parent entity */ String parentTitle = selectedCause.getParentTitle(); final Entity parentEntity = new Entity(selectedCause.getParentId()); parentEntity.setTitle(parentTitle); Label parentLink = OpenGroupsUtil.getLinkForEntityWithImage(parentEntity, app, OpenGroupsResources.getIconPath(OpenGroupsIconsSet.PARENT, OpenGroupsIconsSet.MEDIUM)); parentLink.setDescription(parentTitle); parentLink.setSizeUndefined(); parentLink.addStyleName(OpenGroupsStyles.TOP_RIGHT); // CssLayout imgContainer = new CssLayout(); // imgContainer.setWidth("24px"); // imgContainer.setHeight("24px"); // imgContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); // imgContainer.addComponent(parentLink); // parentInfoContainer.addComponent(imgContainer); headerContainer.addComponent(parentLink); } } /* display header actions */ if (isOpened) { UserActionList headerActions = getAvailableActions(entity, ActionLocations.HEADER); boolean allowRefresh = appConfigManager.getComplexEntityBooleanParam(entity.getComplexType(), ComplexEntityParam.ALLOW_REFRESH); boolean hasHeaderActions = headerActions != null && headerActions.getActions() != null; if (allowRefresh || hasHeaderActions) { HorizontalLayout actionsContainer = new HorizontalLayout(); actionsContainer.addStyleName(OpenGroupsStyles.TOP_RIGHT); actionsContainer.setSpacing(true); // /* add refresh button */ // if (allowRefresh) { // actionsContainer.addComponent(getRefreshButton(entity, app)); // } // if (hasHeaderActions) { // for (final UserAction ha : // headerActions.getActions().values()) { // Button actButton = getButtonForAction(ha, entity, app); // actionsContainer.addComponent(actButton); // } // } headerContainer.addComponent(actionsContainer); // headerContainer.setColumnExpandRatio(1, 1f); // headerContainer.setComponentAlignment(actionsContainer, // Alignment.TOP_RIGHT); entity.setHeaderActionLinksContainer(actionsContainer); refreshHeaderActionLinks(entity, app, actionContext); } } /* display tags */ List<Tag> tags = entity.getTags(); if (tags != null) { if (tags.size() > 0) { String tagsList = ""; for (int i = 0; i < tags.size(); i++) { Tag tag = tags.get(i); tagsList += tag.getTagName(); if ((tags.size() - i) > 1) { tagsList += ", "; } } String tagsLabelString = app.getMessage("tags.label") + tagsList; currentContainer.addComponent(new Label(tagsLabelString)); } } CssLayout statusPane = new CssLayout(); statusPane.addStyleName("entity-status-pane"); currentContainer.addComponent(statusPane); if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.SHOW_POST_INFO)) { String insertDateString = entity.getInsertDate().toString(); Label insertDate = new Label(app.getMessage("posted") + DateUtil.removeNanos(insertDateString)); statusPane.addComponent(insertDate); // statusPane.setColumnExpandRatio(0, 1f); } CssLayout statsSummaryPane = new CssLayout(); statsSummaryPane.addStyleName("entity-stats-summary-pane"); // statsSummaryPane.setSizeFull(); // statsSummaryPane.setWidth("100%"); currentContainer.addComponent(statsSummaryPane); /* add votes */ if (appConfigManager.getComplexEntityBooleanParam(complexEntityType, ComplexEntityParam.ALLOW_VOTING)) { // HorizontalLayout votesPane = new HorizontalLayout(); // votesPane.setMargin(false); // votesPane.addStyleName("middle-left"); // votesPane.addStyleName("margin-right"); // statsSummaryPane.addComponent(votesPane); // statsSummaryPane.setExpandRatio(votesPane, 1f); // statsSummaryPane.setComponentAlignment(votesPane, // Alignment.MIDDLE_LEFT); Label votesLabel = new Label(app.getMessage("votes") + ": "); votesLabel.setContentMode(Label.CONTENT_XHTML); votesLabel.setSizeUndefined(); votesLabel.addStyleName("middle-left"); // votesPane.addComponent(votesLabel); Label proVotes = FormatingUtils.coloredLabel(entity.getProVotes(), "336633"); proVotes.addStyleName("middle-left"); proVotes.setSizeUndefined(); // votesPane.addComponent(proVotes); Label dash = new Label("-"); dash.addStyleName("middle-left"); dash.setSizeUndefined(); // votesPane.addComponent(new Label("-")); Label opposedVotes = FormatingUtils.coloredLabel(entity.getOpposedVotes(), "660000"); // votesPane.addComponent(opposedVotes); opposedVotes.addStyleName("middle-left"); opposedVotes.addStyleName("right-margin-10"); opposedVotes.setSizeUndefined(); statsSummaryPane.addComponent(votesLabel); statsSummaryPane.addComponent(proVotes); statsSummaryPane.addComponent(dash); statsSummaryPane.addComponent(opposedVotes); } List<TypeRelationConfig> subtypes = appConfigManager.getSubtypesForType(entity.getComplexTypeId()); // if (subtyesList != null) { if (subtypes != null) { Map<String, Long> firstLevelSubtypesCount = entity.getSubtypeEntitiesCount(); Map<String, Long> allSubtypesCount = entity.getRecursiveSubtypeEntitiesCount(); // for (String s : subtyesList) { // String subtype = s.toLowerCase(); for (TypeRelationConfig trc : subtypes) { String targetComplexType = trc.getTargetComplexType(); String subtype = targetComplexType.toLowerCase(); String displayName = app.getMessage("subtype." + subtype); Entity refEntity = new Entity(entity.getId()); refEntity.getState().setDesiredActionsPath( targetComplexType + Defaults.getDefaultActionForEntityType(targetComplexType)); Label subtypeLink = OpenGroupsUtil.getLinkForEntity(refEntity, app, displayName); String valueString = ": " + firstLevelSubtypesCount.get(subtype); // if (getAppConfigManager().getComplexEntityBooleanParam(s, // ComplexEntityParam.ALLOW_RECURSIVE_LIST)) { if (appConfigManager.getTypeRelationBooleanConfigParam(trc.getId(), TypeRelationConfigParam.ALLOW_RECURSIVE_LIST)) { Long recCount = allSubtypesCount.get(subtype); if (recCount != null) { valueString += " / " + recCount; } } Label sl = new Label(valueString); sl.setWidth(null); sl.addStyleName("middle-left"); sl.addStyleName("right-margin-10"); subtypeLink.setWidth(null); subtypeLink.addStyleName("middle-left"); statsSummaryPane.addComponent(subtypeLink); statsSummaryPane.addComponent(sl); // statsSummaryPane.setExpandRatio(sl, 1f); // statsSummaryPane.setComponentAlignment(sl, // Alignment.MIDDLE_LEFT); } } displaySummaryActions(entity, app, statsSummaryPane, actionContext); // statusPane.addComponent(statsSummaryPane, 1, 0); // statusPane.setColumnExpandRatio(1, 1.8f); // statusPane.setComponentAlignment(statsSummaryPane, // Alignment.MIDDLE_RIGHT); // summaryLayout.setComponentAlignment(statsSummaryPane, // Alignment.MIDDLE_RIGHT); /* add the content */ Object contentObj = entity.getContent(); if (contentObj != null) { // content.setSizeFull(); Panel contentContainer = new Panel(); // CssLayout contentContainer = new CssLayout(); contentContainer.addStyleName("text-content"); currentContainer.addComponent(contentContainer); Label content = new Label(contentObj.toString()); content.setContentMode(Label.CONTENT_XHTML); // content.addStyleName("text-label"); contentContainer.addComponent(content); /* if the content is visible, display footer actions */ displayFooterActions(entity, app, currentContainer, actionContext); } }