List of usage examples for com.vaadin.ui Label setValue
public void setValue(String value)
From source file:org.opennms.features.vaadin.dashboard.dashlets.AlarmsDashlet.java
License:Open Source License
/** * Returns the component for visualising the alarms data. * * @param onmsAlarm an {@link OnmsAlarm} instance * @param onmsNode an {@link OnmsNode} instance * @return component for this alarm//from ww w . ja va 2s . co m */ public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) { Calendar calendar = Calendar.getInstance(); String ago = getHumanReadableFormat( (calendar.getTimeInMillis() / 1000) - (onmsAlarm.getLastEventTime().getTime() / 1000)); HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setWidth("100%"); horizontalLayout.addStyleName("alerts"); horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase()); Label labelAgo = new Label(); labelAgo.setSizeUndefined(); labelAgo.addStyleName("alerts-font"); labelAgo.setValue(ago); Label labelId = new Label(); labelId.setSizeUndefined(); labelId.addStyleName("alerts-font"); if (onmsNode != null) { labelId.setValue(onmsNode.getLabel() + " (" + onmsNode.getNodeId() + ")"); } else { labelId.setValue("-"); } Label labelUei = new Label(); labelUei.setSizeUndefined(); labelUei.addStyleName("alerts-font"); labelUei.setValue(onmsAlarm.getUei()); horizontalLayout.addComponent(labelAgo); horizontalLayout.addComponent(labelId); horizontalLayout.addComponent(labelUei); horizontalLayout.setExpandRatio(labelAgo, 1.0f); horizontalLayout.setExpandRatio(labelId, 3.0f); horizontalLayout.setExpandRatio(labelUei, 3.0f); return horizontalLayout; }
From source file:org.opennms.features.vaadin.dashboard.ui.HeaderLayout.java
License:Open Source License
/** * Default constructor.//w ww . j a v a 2 s . c om */ public HeaderLayout() { /** * Setting up the layout */ addStyleName("header"); setMargin(new MarginInfo(false, true, false, false)); setSpacing(true); setWidth("100%"); setHeight(64, Unit.PIXELS); /** * Adding the logo */ Label link = new Label(); link.setContentMode(ContentMode.HTML); link.setValue("<a href=\"/opennms/index.jsp\" id=\"onmslogo\"></a>"); addComponent(link); setExpandRatio(link, 1.0f); /** * Adding the selection box */ m_nativeSelect = new NativeSelect(); m_nativeSelect.setDescription("Select Ops Board configuration"); m_nativeSelect.setContainerDataSource(WallboardProvider.getInstance().getBeanContainer()); m_nativeSelect.setItemCaptionPropertyId("title"); m_nativeSelect.setNullSelectionAllowed(false); m_nativeSelect.setImmediate(true); m_nativeSelect.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { m_wallboardButton.setEnabled(true); m_dashboardButton.setEnabled(true); } }); m_dashboardButton = new Button("Ops Panel", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().getNavigator().addViewChangeListener(HeaderLayout.this); UI.getCurrent().getNavigator().navigateTo( "dashboard/" + m_nativeSelect.getContainerProperty(m_nativeSelect.getValue(), "title")); } }); m_dashboardButton.setDescription("Ops Panel view"); /** * Adding the wallboard button */ m_pauseButton = new Button("Pause", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (m_wallboardView instanceof WallboardView) { if (((WallboardView) m_wallboardView).isPaused()) { ((WallboardView) m_wallboardView).resume(); } else { ((WallboardView) m_wallboardView).pause(); } } else { if (m_wallboardView instanceof DashboardView) { ((DashboardView) m_wallboardView).updateAll(); } } updatePauseButton(); } }); /** * Adding the wallboard button */ m_wallboardButton = new Button("Ops Board", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { UI.getCurrent().getNavigator().addViewChangeListener(HeaderLayout.this); UI.getCurrent().getNavigator().navigateTo( "wallboard/" + m_nativeSelect.getContainerProperty(m_nativeSelect.getValue(), "title")); } }); m_wallboardButton.setDescription("Ops Board view"); m_pauseButton.setEnabled(false); m_wallboardButton.setEnabled(false); m_dashboardButton.setEnabled(false); addComponents(m_nativeSelect, m_dashboardButton, m_wallboardButton, m_pauseButton); setComponentAlignment(m_nativeSelect, Alignment.MIDDLE_CENTER); setComponentAlignment(m_dashboardButton, Alignment.MIDDLE_CENTER); setComponentAlignment(m_wallboardButton, Alignment.MIDDLE_CENTER); setComponentAlignment(m_pauseButton, Alignment.MIDDLE_CENTER); }
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 a2s. 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.features.vaadin.pmatrix.ui.PmatrixApplication.java
License:Open Source License
@Override protected void init(VaadinRequest request) { final VerticalLayout layout = new VerticalLayout(); layout.setWidth("-1px"); layout.setHeight("-1px"); layout.setDefaultComponentAlignment(Alignment.TOP_LEFT); layout.setMargin(true);//from w w w . j a v a 2s. c o m setContent(layout); //used to test that detach events are happening addDetachListener(new DetachListener() { @Override public void detach(DetachEvent event) { LOG.debug("Pmatrix UI instance detached:" + this); } }); Component uiComponent = uiComponentFactory.getUiComponent(request); if (uiComponent == null) { StringBuilder sb = new StringBuilder( "Error: Cannot create the UI because the URL request parameters are not recognised<BR>\n" + "you need to provide atleast '?" + UiComponentFactory.COMPONENT_REQUEST_PARAMETER + "=" + UiComponentFactory.DEFAULT_COMPONENT_REQUEST_VALUE + "'<BR>\n" + "Parameters passed in URL:<BR>\n"); for (Entry<String, String[]> entry : request.getParameterMap().entrySet()) { sb.append("parameter:'" + entry.getKey() + "' value:'"); for (String s : entry.getValue()) { sb.append("{" + s + "}"); } sb.append("'<BR>\n"); } Label label = new Label(); label.setWidth("600px"); label.setContentMode(ContentMode.HTML); label.setValue(sb.toString()); layout.addComponent(label); } else { layout.addComponent(uiComponent); // refresh interval to apply to the UI int pollInterval = uiComponentFactory.getRefreshRate(); setPollInterval(pollInterval); // display poll interval in seconds DecimalFormat dformat = new DecimalFormat("##.##"); Label label = new Label(); label.setCaption("(refresh rate:" + dformat.format(pollInterval / 1000) + " seconds)"); layout.addComponent(label); } }
From source file:org.processbase.ui.bpm.admin.ProcessDefinitionWindow.java
License:Open Source License
private void addTableMembershipRow(Membership membership) throws Exception { String uuid = membership != null ? membership.getUUID() : "NEW_MEMBERSHIP_UUID_" + UUID.randomUUID().toString(); Item woItem = tableMembership.addItem(uuid); if (membership != null) { Label groups = new Label(getGroups() .getItem(membership != null ? membership.getGroup().getUUID() : null).getItemProperty("path")); woItem.getItemProperty("group").setValue(groups); Label roles = new Label(getRoles().getItem(membership != null ? membership.getRole().getUUID() : null) .getItemProperty("name")); woItem.getItemProperty("role").setValue(roles); } else {//w w w. j a v a 2s. co m ComboBox groups = new ComboBox(); groups.setWidth("100%"); groups.setContainerDataSource(getGroups()); groups.setItemCaptionPropertyId("path"); groups.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); groups.setValue(membership != null ? membership.getGroup().getUUID() : null); woItem.getItemProperty("group").setValue(groups); ComboBox roles = new ComboBox(); roles.setWidth("100%"); roles.setContainerDataSource(getRoles()); roles.setItemCaptionPropertyId("name"); roles.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); roles.setValue(membership != null ? membership.getRole().getUUID() : null); woItem.getItemProperty("role").setValue(roles); } TableLinkButton tlb = new TableLinkButton( ProcessbaseApplication.getCurrent().getPbMessages().getString("btnDelete"), "icons/cancel.png", uuid, this, Constants.ACTION_DELETE); woItem.getItemProperty("actions").setValue(tlb); }
From source file:org.processbase.ui.bpm.admin.UserWindow.java
License:Open Source License
private void addTableMembershipRow(Membership membership) throws Exception { String uuid = membership != null ? membership.getUUID() : "NEW_MEMBERSHIP_UUID_" + UUID.randomUUID().toString(); Item woItem = tableMembership.addItem(uuid); if (membership != null) { Label groups = new Label(getGroups() .getItem(membership != null ? membership.getGroup().getUUID() : null).getItemProperty("path")); woItem.getItemProperty("group").setValue(groups); Label roles = new Label(getRoles().getItem(membership != null ? membership.getRole().getUUID() : null) .getItemProperty("name")); woItem.getItemProperty("role").setValue(roles); } else {//from w w w . ja v a 2 s . com ComboBox groups = new ComboBox(); groups.setWidth("100%"); groups.setContainerDataSource(getGroups()); groups.setItemCaptionPropertyId("path"); groups.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); groups.setValue(membership != null ? membership.getGroup().getUUID() : null); woItem.getItemProperty("group").setValue(groups); ComboBox roles = new ComboBox(); roles.setWidth("100%"); roles.setContainerDataSource(getRoles()); roles.setItemCaptionPropertyId("name"); roles.setFilteringMode(ComboBox.FILTERINGMODE_CONTAINS); roles.setValue(membership != null ? membership.getRole().getUUID() : null); woItem.getItemProperty("role").setValue(roles); } TableLinkButton tlb = new TableLinkButton(ProcessbaseApplication.getString("btnDelete"), "icons/cancel.png", uuid, this, Constants.ACTION_DELETE); woItem.getItemProperty("actions").setValue(tlb); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.AdminFormLayout.java
License:Mozilla Public License
private void init() { setMargin(true);// w w w .jav a 2s . c o m final String lblMsg = STATUS_MSG_SERVER_INACTIVE;//RepositoryClientServer.getInstance().isRepositoryServerRunning() ? STATUS_MSG_SERVER_ACTIVE : STATUS_MSG_SERVER_INACTIVE; final Label lblStatus = new Label(lblMsg); addComponent(lblStatus); final HorizontalLayout buttonBarLayout = new HorizontalLayout(); buttonBarLayout.setSpacing(true); buttonBarLayout.setHeight(BUTTON_BAR_HEIGHT); final HorizontalLayout checkinBarLayout = new HorizontalLayout(); checkinBarLayout.setSpacing(true); checkinBarLayout.setHeight(BUTTON_BAR_HEIGHT); final Button okBtn = new Button("Start Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (!RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().start(); lblStatus.setValue(STATUS_MSG_SERVER_ACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); final Button stopBtn = new Button("Stop Repository Client", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { if (RepositoryClientServer.getInstance().isRepositoryServerRunning()) { RepositoryClientServer.getInstance().stop(); lblStatus.setValue(STATUS_MSG_SERVER_INACTIVE); } } catch (final Throwable th) { lblStatus.setValue(th); } } }); buttonBarLayout.addComponent(okBtn); buttonBarLayout.addComponent(stopBtn); buttonBarLayout.setComponentAlignment(stopBtn, Alignment.TOP_RIGHT); final Button checkInButton = new Button("Do initial check-in", new Button.ClickListener() { public void buttonClick(final ClickEvent event) { try { S23MKernel.completeCellKernelInitialization(); CellPlatform.instantiateFeature(); //org.s23m.cell.test.artifactinstantiation.Test.main(null); final ArtefactContainer container = ObjectFactoryHolder.getInstance().createArtefactContainer(); container.setContentType(SerializationType.IN_MEMORY_PERSISTENCE.name()); client.put(container); lblStatus.setValue("Initial check-in done."); } catch (final Throwable th) { lblStatus.setValue(th); } } }); checkInButton.setEnabled(true); checkinBarLayout.addComponent(checkInButton); addComponent(buttonBarLayout); addComponent(checkinBarLayout); }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.layout.ImpactAnalysisFormLayout.java
License:Mozilla Public License
private void init() { setMargin(true);/* w w w. j ava2 s .c o m*/ resultsPanel = new Panel(); resultsPanel.addStyleName(Runo.PANEL_LIGHT); resultsPanel.setWidth(RESULTS_PANEL_WIDTH); resultsPanel.setHeight(RESULTS_PANEL_HEIGHT); addComponent(resultsPanel); parent.getMainApplication().getMainWindow().showNotification("Processing results..."); final List<Set> dependentInstances = doImapactAnalysis( analysedSet.identity().uniqueRepresentationReference().toString()); this.pageIndex = 0; final Label lblTitle = new Label(); lblTitle.setValue( analysedSet.identity().name() + "<br/> can impact : " + dependentInstances.size() + " instaces(s)"); lblTitle.setContentMode(Label.CONTENT_XHTML); lblTitle.setStyleName("title-label"); resultsPanel.addComponent(lblTitle); if (dependentInstances.size() > 0) { final int startIndex = pageIndex * PAGE_SIZE; final int endIndex = startIndex + PAGE_SIZE; final Panel resultsContentPanel = new Panel(); resultsContentPanel.setWidth(RESULTS_CONTENT_PANEL_WIDTH); resultsContentPanel.setHeight(RESULTS_CONTENT_PANEL_HEIGHT); resultsPanel.addComponent(resultsContentPanel); buildResultsPage(dependentInstances, resultsContentPanel, startIndex, endIndex); } }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java
License:Mozilla Public License
private void buildResultsPage(final Panel resultsPanel, final int startIndex, final int endIndex) { resultsPanel.removeAllComponents();/* w w w . ja va 2 s .c o m*/ for (int n = startIndex; (n < endIndex && n < searchResults.size()); n++) { final SearchResultType r = searchResults.get(n); final Tree cTree = application.getContainmentTreePanel().getContainmentTree(); final HorizontalLayout hl1 = new HorizontalLayout(); hl1.setData(r.getInstanceIdentity()); hl1.addListener(new LayoutClickListener() { private void expandAllAncestors(final TreeNode rootNode, final TreeNode node2Select) { if (!rootNode.equals(node2Select)) { final TreeNode parentNode = (TreeNode) cTree.getParent(node2Select); cTree.expandItem(parentNode); expandAllAncestors(rootNode, parentNode); } } public void layoutClick(final LayoutClickEvent event) { if (event.getSource() instanceof HorizontalLayout) { final HorizontalLayout layout = (HorizontalLayout) event.getSource(); final InstanceIdentityType id = (InstanceIdentityType) layout.getData(); //Fetch and deserialize outershell instances if they are not available in memory application.getContainmentTreePanel().recreateOutshellInstances(); application.getContainmentTreePanel().update(); if (cTree.rootItemIds().size() > 0) { final TreeNode rootNode = (TreeNode) cTree.rootItemIds().iterator().next(); cTree.collapseItemsRecursively(rootNode); //select a corresponding tree node final Set set = Reconstitution.getSetFromLocalMemory( Reconstitution.reconstituteIdentity(id.getName(), id.getPluralName(), UUID.fromString(id.getUuid()), UUID.fromString(id.getUuid()))); // TODO name based equivalence test needs to be replaced by isEqualToRepresentation() if (!set.identity().name() .equals((S23MSemanticDomains.semanticErr_ThisSetIsNotAvailableInMemory .identity().name()))) { TreeNode node2Select = null; if (set.properClass().isEqualTo(S23MKernel.coreGraphs.edge)) { node2Select = new TreeNode( set.container().identity().uniqueRepresentationReference().toString(), TreeNode.NO_SET); } else { node2Select = new TreeNode(id.getUuid(), TreeNode.NO_SET); } expandAllAncestors(rootNode, node2Select); cTree.setValue(node2Select); } } } }// }); final HorizontalLayout hl2 = new HorizontalLayout(); final Label lblMeta = new Label(); lblMeta.setStyleName("meta-element"); final Label lblInstance = new Label(); lblInstance.setStyleName("instance-element"); final Label lblArtifact = new StyledLabel("part of: " + r.getContainerIdentity().getName(), StyledLabel.VALUE_TAG_STYLE); final Label lblNameTag = new StyledLabel("name:", StyledLabel.NAME_TAG_STYLE); final Label lblName = new StyledLabel(r.getInstanceIdentity().getName(), StyledLabel.VALUE_TAG_STYLE); final Label lblPlNameTag = new StyledLabel("plural name:", StyledLabel.NAME_TAG_STYLE); final Label lblPlName = new StyledLabel(r.getInstanceIdentity().getPluralName(), StyledLabel.VALUE_TAG_STYLE); if (r.getMetaInstanceIdentity().getName() != null) { lblMeta.setValue(r.getMetaInstanceIdentity().getName() + " : "); } else { final Set metaSet = Reconstitution.getSetFromLocalMemory(Reconstitution.reconstituteIdentity("", "", UUID.fromString(r.getMetaInstanceIdentity().getUuid()), UUID.fromString(r.getMetaInstanceIdentity().getUuid()))); // TODO name based equivalence test needs to be replaced by isEqualToRepresentation() if (!metaSet.identity().name().equals( (S23MSemanticDomains.semanticErr_ThisSetIsNotAvailableInMemory.identity().name()))) { lblMeta.setValue(metaSet.identity().name() + " : "); } else { lblMeta.setValue(" : "); } } lblInstance.setValue(r.getInstanceIdentity().getName()); hl1.addComponent(lblMeta); hl1.addComponent(lblInstance); hl2.addComponent(lblArtifact); hl2.addComponent(lblNameTag); hl2.addComponent(lblName); hl2.addComponent(lblPlNameTag); hl2.addComponent(lblPlName); resultsPanel.addComponent(hl1); resultsPanel.addComponent(hl2); } if (searchResults.size() > PAGE_SIZE) { createPagebar(resultsPanel, searchResults.size()); } }
From source file:org.s23m.cell.editor.semanticdomain.ui.components.MultitabPanel.java
License:Mozilla Public License
public void displaySearchResults() { application.getMainWindow().showNotification("Processing results..."); this.pageIndex = 0; final RepositoryClient client = RepositoryClientImpl.getInstance(); final String inputText = application.getContainmentTreePanel().getSearchText(); final ArtefactContainer container = ObjectFactoryHolder.getInstance().createArtefactContainer(); container.setContentType(SerializationType.SEARCH_ARGUMENTS.toString()); final Content searchContent = ObjectFactoryHolder.getInstance().createArtefactContainerContent(); searchContent.setContent(inputText); container.getContent().add(searchContent); final ArtefactContainer resultsContainer = client.get(container); searchResults = new ArrayList<SearchResultType>(); for (final SearchResult sr : resultsContainer.getSearchResult()) { searchResults.add(sr);/* w ww. j a va2s.c o m*/ } searchResultPanel.removeAllComponents(); final Panel resultsPanel = new Panel(); final Label lblTitle = new Label(); lblTitle.setValue(inputText + "<br/>Returned: " + searchResults.size() + " result(s)"); lblTitle.setContentMode(Label.CONTENT_XHTML); lblTitle.setStyleName("title-label"); searchResultPanel.addComponent(lblTitle); if (searchResults.size() > 0) { //display 10 per page and put a navigation toolbar at the bottom searchResultPanel.addComponent(resultsPanel); final int startIndex = pageIndex * PAGE_SIZE; final int endIndex = startIndex + PAGE_SIZE; buildResultsPage(resultsPanel, startIndex, endIndex); } }