List of usage examples for com.vaadin.ui Label setCaption
@Override public void setCaption(String caption)
From source file:org.ikasan.dashboard.ui.topology.component.WiretapTab.java
License:BSD License
public Layout createWiretapLayout() { this.wiretapTable = new Table(); this.wiretapTable.setSizeFull(); this.wiretapTable.addStyleName(ValoTheme.TABLE_SMALL); this.wiretapTable.addStyleName("ikasan"); this.wiretapTable.addContainerProperty("Module Name", String.class, null); this.wiretapTable.addContainerProperty("Flow Name", String.class, null); this.wiretapTable.addContainerProperty("Component Name", String.class, null); this.wiretapTable.addContainerProperty("Event Id / Payload Id", String.class, null); this.wiretapTable.addContainerProperty("Timestamp", String.class, null); this.wiretapTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.wiretapTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/*w ww .j a v a 2s.c om*/ public void itemClick(ItemClickEvent itemClickEvent) { WiretapEvent<String> wiretapEvent = (WiretapEvent<String>) itemClickEvent.getItemId(); WiretapPayloadViewWindow wiretapPayloadViewWindow = new WiretapPayloadViewWindow(wiretapEvent); UI.getCurrent().addWindow(wiretapPayloadViewWindow); } }); final Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { ProgressBarWindow pbWindow = new ProgressBarWindow(); UI.getCurrent().addWindow(pbWindow); wiretapTable.removeAllItems(); HashSet<String> modulesNames = null; if (modules.getItemIds().size() > 0) { modulesNames = new HashSet<String>(); for (Object module : modules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } HashSet<String> flowNames = null; if (flows.getItemIds().size() > 0) { flowNames = new HashSet<String>(); for (Object flow : flows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } HashSet<String> componentNames = null; if (components.getItemIds().size() > 0) { componentNames = new HashSet<String>(); for (Object component : components.getItemIds()) { componentNames.add("before " + ((Component) component).getName()); componentNames.add("after " + ((Component) component).getName()); } } if (modulesNames == null && flowNames == null && componentNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new HashSet<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } String errorCategory = null; // TODO Need to take a proper look at the wiretap search interface. We do not need to worry about paging search // results with Vaadin. PagedSearchResult<WiretapEvent> events = wiretapDao.findWiretapEvents(0, 10000, "timestamp", false, modulesNames, flowNames, componentNames, eventId.getValue(), null, fromDate.getValue(), toDate.getValue(), payloadContent.getValue()); for (WiretapEvent<String> wiretapEvent : events.getPagedResults()) { Date date = new Date(wiretapEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); wiretapTable .addItem( new Object[] { wiretapEvent.getModuleName(), wiretapEvent.getFlowName(), wiretapEvent.getComponentName(), ((WiretapFlowEvent) wiretapEvent).getEventId(), timestamp }, wiretapEvent); } pbWindow.close(); } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeAllItems(); flows.removeAllItems(); components.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(3, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); modules.setIcon(VaadinIcons.ARCHIVE); modules.addContainerProperty("Module Name", String.class, null); modules.addContainerProperty("", Button.class, null); modules.setSizeFull(); modules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); modules.setDragMode(TableDragMode.ROW); modules.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Module) { final Module module = (Module) t.getItemId(); logger.info("sourceContainer.getText(): " + module.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeItem(module); } }); modules.addItem(new Object[] { module.getName(), deleteButton }, module); for (final Flow flow : module.getFlows()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(modules, 0, 0); flows.setIcon(VaadinIcons.AUTOMATION); flows.addContainerProperty("Flow Name", String.class, null); flows.addContainerProperty("", Button.class, null); flows.setSizeFull(); flows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); flows.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); logger.info("sourceContainer.getText(): " + flow.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(flows, 1, 0); components.setIcon(VaadinIcons.COG); components.setSizeFull(); components.addContainerProperty("Component Name", String.class, null); components.addContainerProperty("", Button.class, null); components.setCellStyleGenerator(new IkasanCellStyleGenerator()); components.setSizeFull(); components.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); components.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Component) { final Component component = (Component) t.getItemId(); logger.info("sourceContainer.getText(): " + component.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(this.components, 2, 0); GridLayout dateSelectLayout = new GridLayout(2, 2); dateSelectLayout.setColumnExpandRatio(0, 0.25f); dateSelectLayout.setColumnExpandRatio(1, 0.75f); dateSelectLayout.setSizeFull(); this.fromDate = new PopupDateField("From date"); this.fromDate.setResolution(Resolution.MINUTE); this.fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(this.fromDate, 0, 0); this.toDate = new PopupDateField("To date"); this.toDate.setResolution(Resolution.MINUTE); this.toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(this.toDate, 0, 1); this.eventId = new TextField("Event Id"); this.eventId.setWidth("80%"); this.payloadContent = new TextField("Payload Content"); this.payloadContent.setWidth("80%"); this.eventId.setNullSettingAllowed(true); this.payloadContent.setNullSettingAllowed(true); dateSelectLayout.addComponent(this.eventId, 1, 0); dateSelectLayout.addComponent(this.payloadContent, 1, 1); final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); vSplitPanel.setHeight("95%"); GridLayout searchLayout = new GridLayout(2, 1); searchLayout.setSpacing(true); searchLayout.addComponent(searchButton, 0, 0); searchLayout.addComponent(clearButton, 1, 0); final Button hideFilterButton = new Button(); hideFilterButton.setIcon(VaadinIcons.MINUS); hideFilterButton.setCaption("Hide Filter"); hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK); hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); final Button showFilterButton = new Button(); showFilterButton.setIcon(VaadinIcons.PLUS); showFilterButton.setCaption("Show Filter"); showFilterButton.addStyleName(ValoTheme.BUTTON_LINK); showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); showFilterButton.setVisible(false); final HorizontalLayout hListSelectLayout = new HorizontalLayout(); hListSelectLayout.setHeight(150, Unit.PIXELS); hListSelectLayout.setWidth("100%"); hListSelectLayout.addComponent(listSelectLayout); final HorizontalLayout hDateSelectLayout = new HorizontalLayout(); hDateSelectLayout.setHeight(80, Unit.PIXELS); hDateSelectLayout.setWidth("100%"); hDateSelectLayout.addComponent(dateSelectLayout); final HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(30, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(searchLayout); hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = vSplitPanel.getSplitPosition(); splitUnit = vSplitPanel.getSplitPositionUnit(); vSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); vSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); Label filterHintLabel = new Label(); filterHintLabel.setCaptionAsHtml(true); filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag items from the topology tree to the tables below in order to narrow your search."); filterHintLabel.addStyleName(ValoTheme.LABEL_TINY); filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(filterHintLabel); layout.addComponent(hListSelectLayout); layout.addComponent(hDateSelectLayout); layout.addComponent(hSearchLayout); layout.setSizeFull(); Panel filterPanel = new Panel(); filterPanel.setHeight(340, Unit.PIXELS); filterPanel.setWidth("100%"); filterPanel.setContent(layout); filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); vSplitPanel.setFirstComponent(filterPanel); CssLayout hErrorTable = new CssLayout(); hErrorTable.setSizeFull(); hErrorTable.addComponent(this.wiretapTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(350, Unit.PIXELS); GridLayout wrapper = new GridLayout(1, 2); wrapper.setRowExpandRatio(0, .01f); wrapper.setRowExpandRatio(1, .99f); wrapper.setSizeFull(); wrapper.addComponent(filterButtonLayout); wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT); wrapper.addComponent(vSplitPanel); return wrapper; }
From source file:org.ikasan.dashboard.ui.topology.window.ErrorCategorisationWindow.java
License:BSD License
/** * Helper method to initialise this object. * /*w w w. j a v a 2 s . c o m*/ * @param message */ protected void init() { setModal(true); setHeight("90%"); setWidth("90%"); this.existingCategorisedErrorsTable = new Table(); this.existingCategorisedErrorsTable.setWidth("100%"); this.existingCategorisedErrorsTable.setHeight(200, Unit.PIXELS); this.existingCategorisedErrorsTable.addContainerProperty("Module Name", String.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Module Name", .1f); this.existingCategorisedErrorsTable.addContainerProperty("Flow Name", String.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Flow Name", .1f); this.existingCategorisedErrorsTable.addContainerProperty("Component Name", String.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Component Name", .1f); this.existingCategorisedErrorsTable.addContainerProperty("Action", String.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Action", .1f); this.existingCategorisedErrorsTable.addContainerProperty("Error Category", Label.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Category", .1f); this.existingCategorisedErrorsTable.addContainerProperty("Error Message", String.class, null); this.existingCategorisedErrorsTable.setColumnExpandRatio("Error Message", .5f); this.existingCategorisedErrorsTable.addStyleName("wordwrap-table"); this.existingCategorisedErrorsTable.addStyleName(ValoTheme.TABLE_NO_STRIPES); this.existingCategorisedErrorsTable.setCellStyleGenerator(new Table.CellStyleGenerator() { @Override public String getStyle(Table source, Object itemId, Object propertyId) { ErrorCategorisationLink errorCategorisationLink = (ErrorCategorisationLink) itemId; if (propertyId == null) { // Styling for row if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { return "ikasan-green-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { return "ikasan-green-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { return "ikasan-orange-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { return "ikasan-red-small"; } } if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { return "ikasan-green-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { return "ikasan-green-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { return "ikasan-orange-small"; } else if (errorCategorisationLink.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { return "ikasan-red-small"; } return "ikasan-small"; } }); this.existingCategorisedErrorsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override public void itemClick(ItemClickEvent itemClickEvent) { logger.info("table item slected: " + (ErrorCategorisationLink) itemClickEvent.getItemId()); errorCategorisationLink = (ErrorCategorisationLink) itemClickEvent.getItemId(); errorCategorisation = errorCategorisationLink.getErrorCategorisation(); errorCategorisationItem = new BeanItem<ErrorCategorisation>(errorCategorisation); errorCategorisationLinkItem = new BeanItem<ErrorCategorisationLink>(errorCategorisationLink); moduleNameTextField .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName")); flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName")); componentNameTextField .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName")); errorCategoryCombo.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorCategory")); errorMessageTextArea .setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription")); actionCombo.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("action")); exceptionClassTextField .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass")); errorMessageTextArea.markAsDirty(); actionCombo.markAsDirty(); errorCategoryCombo.markAsDirty(); componentNameTextField.markAsDirty(); flowNameTextField.markAsDirty(); moduleNameTextField.markAsDirty(); } }); refreshExistingCategorisedErrorsTable(); layout.setSizeFull(); layout.setSpacing(true); layout.setMargin(true); layout.setColumnExpandRatio(0, .25f); layout.setColumnExpandRatio(1, .75f); if (this.errorCategorisationLink == null) { clear(); } Label configuredResourceIdLabel = new Label("Error Categorisation"); configuredResourceIdLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(configuredResourceIdLabel, 0, 0, 1, 0); if (this.module == null && this.flow == null && this.component == null) { Label errorCategorisationHintLabel = new Label(); errorCategorisationHintLabel.setCaptionAsHtml(true); errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You are creating an error categorisation for server wide errors. This categorisation will be applied" + " against errors that occur server wide, that do not have a more focused error categorisation."); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1); } else if (this.flow == null && this.component == null) { Label errorCategorisationHintLabel = new Label(); errorCategorisationHintLabel.setCaptionAsHtml(true); errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You are creating an error categorisation for module wide errors. This categorisation will be applied" + " against errors that occur within this module, that do not have a more focused error categorisation."); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1); } else if (this.component == null) { Label errorCategorisationHintLabel = new Label(); errorCategorisationHintLabel.setCaptionAsHtml(true); errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You are creating an error categorisation for flow wide errors. This categorisation will be applied" + " against errors that occur within this flow, that do not have a more focused error categorisation."); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1); } else { Label errorCategorisationHintLabel = new Label(); errorCategorisationHintLabel.setCaptionAsHtml(true); errorCategorisationHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You are creating an error categorisation against a component. This is the most focused error categorisation" + " that can be applied. This categorisation will be applied against errors that occur on this component."); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); errorCategorisationHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(errorCategorisationHintLabel, 0, 1, 1, 1); } if (this.module != null) { Label moduleNameLabel = new Label(); moduleNameLabel.setContentMode(ContentMode.HTML); moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:"); moduleNameLabel.setSizeUndefined(); layout.addComponent(moduleNameLabel, 0, 2); layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT); moduleNameTextField.setRequired(true); moduleNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("moduleName")); moduleNameTextField.setReadOnly(true); moduleNameTextField.setWidth("80%"); layout.addComponent(moduleNameTextField, 1, 2); } if (this.flow != null) { Label flowNameLabel = new Label(); flowNameLabel.setContentMode(ContentMode.HTML); flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:"); flowNameLabel.setSizeUndefined(); layout.addComponent(flowNameLabel, 0, 3); layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT); flowNameTextField.setRequired(true); flowNameTextField.setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowName")); flowNameTextField.setReadOnly(true); flowNameTextField.setWidth("80%"); layout.addComponent(flowNameTextField, 1, 3); } if (this.component != null) { Label componentNameLabel = new Label(); componentNameLabel.setContentMode(ContentMode.HTML); componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:"); componentNameLabel.setSizeUndefined(); layout.addComponent(componentNameLabel, 0, 4); layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT); componentNameTextField.setRequired(true); componentNameTextField .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("flowElementName")); componentNameTextField.setReadOnly(true); componentNameTextField.setWidth("80%"); layout.addComponent(componentNameTextField, 1, 4); } Label exceptionClassLabel = new Label(); exceptionClassLabel.setContentMode(ContentMode.HTML); exceptionClassLabel.setValue("Exception Class:"); exceptionClassLabel.setSizeUndefined(); layout.addComponent(exceptionClassLabel, 0, 5); layout.setComponentAlignment(exceptionClassLabel, Alignment.MIDDLE_RIGHT); this.exceptionClassTextField.setWidth("80%"); exceptionClassTextField .setPropertyDataSource(errorCategorisationLinkItem.getItemProperty("exceptionClass")); layout.addComponent(exceptionClassTextField, 1, 5); Label actionLabel = new Label(); actionLabel.setContentMode(ContentMode.HTML); actionLabel.setValue("Action:"); actionLabel.setSizeUndefined(); layout.addComponent(actionLabel, 0, 6); layout.setComponentAlignment(actionLabel, Alignment.MIDDLE_RIGHT); Label errorCategoryLabel = new Label("Error Category:"); errorCategoryLabel.setSizeUndefined(); layout.addComponent(errorCategoryLabel, 0, 7); layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT); this.setupComboBoxesAndItems(); Label errorMessageLabel = new Label("Error Message:"); errorMessageLabel.setSizeUndefined(); layout.addComponent(errorMessageLabel, 0, 8); layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT); errorMessageTextArea.addValidator(new StringLengthValidator( "You must define an error message between 1 and 2048 characters in length!", 1, 2048, false)); errorMessageTextArea.setValidationVisible(false); errorMessageTextArea.setPropertyDataSource(errorCategorisationItem.getItemProperty("errorDescription")); errorMessageTextArea.setRequired(true); errorMessageTextArea.setWidth("650px"); errorMessageTextArea.setRows(8); errorMessageTextArea.setRequiredError("An error message is required!"); layout.addComponent(errorMessageTextArea, 1, 8); GridLayout buttonLayouts = new GridLayout(4, 1); buttonLayouts.setSpacing(true); Button saveButton = new Button("Save"); saveButton.setStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { errorCategoryCombo.validate(); errorMessageTextArea.validate(); actionCombo.validate(); } catch (InvalidValueException e) { errorCategoryCombo.setValidationVisible(true); errorMessageTextArea.setValidationVisible(true); actionCombo.setValidationVisible(true); errorCategoryCombo.markAsDirty(); errorMessageTextArea.markAsDirty(); actionCombo.markAsDirty(); return; } try { errorCategorisationService.save(errorCategorisationItem.getBean()); errorCategorisationLink.setErrorCategorisation(errorCategorisationItem.getBean()); errorCategorisationService.save(errorCategorisationLink); } catch (Exception e) { if (e.getCause() instanceof ConstraintViolationException) { Notification.show( "An error occurred trying to save an error categorisation: Action type must be unique for a given node!", Type.ERROR_MESSAGE); } else { Notification.show( "An error occurred trying to save an error categorisation: " + e.getMessage(), Type.ERROR_MESSAGE); } } refreshExistingCategorisedErrorsTable(); Notification.show("Saved!"); } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { clear(); } }); Button deleteButton = new Button("Delete"); deleteButton.setStyleName(ValoTheme.BUTTON_SMALL); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { ErrorCategorisation ec = errorCategorisationLink.getErrorCategorisation(); errorCategorisationService.delete(errorCategorisationLink); errorCategorisationService.delete(ec); existingCategorisedErrorsTable.removeItem(errorCategorisationLink); clear(); } }); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); buttonLayouts.addComponent(saveButton); buttonLayouts.addComponent(clearButton); buttonLayouts.addComponent(deleteButton); buttonLayouts.addComponent(cancelButton); layout.addComponent(buttonLayouts, 0, 9, 1, 9); layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER); Label existingCategorisationLabel = new Label("Existing Error Categorisations"); existingCategorisationLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(existingCategorisationLabel, 0, 10, 1, 10); Label uniquenessHintLabel = new Label(); uniquenessHintLabel.setCaptionAsHtml(true); uniquenessHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You can only create one error categorisation per Action type for a give node. If you attempt to create more you will receive an error when" + " trying to save."); uniquenessHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); uniquenessHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(uniquenessHintLabel, 0, 11, 1, 11); Label editHintLabel = new Label(); editHintLabel.setCaptionAsHtml(true); editHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " You can can click on a row in the table below to edit an error categorisation."); editHintLabel.addStyleName(ValoTheme.LABEL_BOLD); editHintLabel.addStyleName(ValoTheme.LABEL_SMALL); layout.addComponent(editHintLabel, 0, 12, 1, 12); layout.addComponent(this.existingCategorisedErrorsTable, 0, 13, 1, 13); layout.setComponentAlignment(this.existingCategorisedErrorsTable, Alignment.MIDDLE_CENTER); Panel paramPanel = new Panel(); paramPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); paramPanel.setWidth("100%"); paramPanel.setContent(layout); GridLayout wrapper = new GridLayout(); // wrapper.setMargin(true); wrapper.setSizeFull(); wrapper.addComponent(paramPanel); this.setContent(wrapper); }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameConfigBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Configuration"); layout.addStyleName("center-caption"); GameTypes config = DataPlaybackEngineStates.gameConfig; //show the game description Label gameDescription = new Label(config.getDescription()); layout.addComponent(gameDescription); gameDescription.setContentMode(ContentMode.HTML); gameDescription.setWidth(320, Unit.PIXELS); gameDescription.setCaption("Game: "); //add the player type Label playerType = new Label(); layout.addComponent(playerType);//from w ww .j a va2s . c o m playerType.setCaption("Player Type: "); playerType.setValue(player.getName()); //show the attributes Label attributes = new Label(config.getInterestedAttributes().toString()); layout.addComponent(attributes); attributes.setContentMode(ContentMode.HTML); attributes.setCaption("Attributes: "); //matching attribute Label matchingAttr = new Label(config.getAttributeToMatch().toString()); layout.addComponent(matchingAttr); matchingAttr.setContentMode(ContentMode.HTML); matchingAttr.setCaption("Played On: "); return layout; }
From source file:org.investovator.ui.dataplayback.admin.DataPlaybackEngineAdminDashboard.java
License:Open Source License
public Component setupGameStatsBox() { FormLayout layout = new FormLayout(); layout.setCaption("Game Stats"); layout.addStyleName("center-caption"); //show game runtime final Label runTime = new Label(); //push the changes UI.getCurrent().access(new Runnable() { @Override//from w w w.j a v a 2s .c om public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } }); runTime.setCaption("Up Time: "); layout.addComponent(runTime); //start the time updating thread new Thread() { public void run() { //update forever while (true) { UI.getCurrent().access(new Runnable() { @Override public void run() { TimeZone defaultTz = TimeZone.getDefault(); TimeZone.setDefault(TimeZone.getTimeZone("GMT")); SimpleDateFormat sDate = new SimpleDateFormat("HH:mm:ss"); runTime.setValue(sDate.format(new Date(player.getGameRuntime()))); TimeZone.setDefault(defaultTz); getUI().push(); } }); //wait before updating try { Thread.sleep(1000); } catch (InterruptedException e) { e.printStackTrace(); } } } }.start(); //show market turnover Label turnover = new Label(Float.toString(player.getMarketTurnover())); turnover.setCaption("Market Turnover: "); layout.addComponent(turnover); //show total trades Label totalTrades = new Label(Integer.toString(player.getTotalTrades())); totalTrades.setCaption("Total Trades: "); layout.addComponent(totalTrades); return layout; }
From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummaryMultiPlayerMainView.java
License:Open Source License
public Component setUpAccountInfoForm() { FormLayout form = new FormLayout(); try {//from www.j av a 2 s . co m if (this.userName == null) { int bal = player.getInitialCredit(); Label accountBalance = new Label(Integer.toString(bal)); this.accBalance = accountBalance; accountBalance.setCaption("Account Balance"); form.addComponent(accountBalance); int max = player.getMaxOrderSize(); Label maxOrderSize = new Label(Integer.toString(max)); maxOrderSize.setCaption("Max. Order Size"); form.addComponent(maxOrderSize); } else { Double bal = player.getMyPortfolio(this.userName).getCashBalance(); Label accountBalance = new Label(bal.toString()); this.accBalance = accountBalance; accountBalance.setCaption("Account Balance"); form.addComponent(accountBalance); int max = player.getMaxOrderSize(); Label maxOrderSize = new Label(Integer.toString(max)); maxOrderSize.setCaption("Max. Order Size"); form.addComponent(maxOrderSize); } } catch (UserJoinException e) { e.printStackTrace(); } return form; }
From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummarySinglePlayerMainView.java
License:Open Source License
public Component setUpAccountInfoForm() { FormLayout form = new FormLayout(); try {/*from w w w. java 2s . c o m*/ if (this.userName == null) { int bal = this.player.getInitialCredit(); Label accountBalance = new Label(Integer.toString(bal)); this.accBalance = accountBalance; accountBalance.setCaption("Account Balance"); form.addComponent(accountBalance); int max = this.player.getMaxOrderSize(); Label maxOrderSize = new Label(Integer.toString(max)); maxOrderSize.setCaption("Max. Order Size"); form.addComponent(maxOrderSize); } else { Double bal = this.player.getMyPortfolio(this.userName).getCashBalance(); Label accountBalance = new Label(bal.toString()); this.accBalance = accountBalance; accountBalance.setCaption("Account Balance"); form.addComponent(accountBalance); int max = this.player.getMaxOrderSize(); Label maxOrderSize = new Label(Integer.toString(max)); maxOrderSize.setCaption("Max. Order Size"); form.addComponent(maxOrderSize); } } catch (UserJoinException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } return form; }
From source file:org.opennms.features.vaadin.dashboard.dashlets.AlarmDetailsDashlet.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 w w w . j av a 2 s . c o m */ @Deprecated public Component createAlarmComponent(OnmsAlarm onmsAlarm, OnmsNode onmsNode) { HorizontalLayout horizontalLayout = new HorizontalLayout(); horizontalLayout.setSizeFull(); horizontalLayout.addStyleName("alert-details"); horizontalLayout.addStyleName("alert-details-font"); horizontalLayout.addStyleName(onmsAlarm.getSeverity().name().toLowerCase()); VerticalLayout verticalLayout1 = new VerticalLayout(); VerticalLayout verticalLayout2 = new VerticalLayout(); horizontalLayout.addComponent(verticalLayout1); horizontalLayout.addComponent(verticalLayout2); Label lastEvent = new Label(); lastEvent.setSizeUndefined(); lastEvent.addStyleName("alert-details-font"); lastEvent.setCaption("Last event"); lastEvent.setValue(onmsAlarm.getLastEventTime().toString()); Label firstEvent = new Label(); firstEvent.setSizeUndefined(); firstEvent.addStyleName("alert-details-font"); firstEvent.setCaption("First event"); firstEvent.setValue(onmsAlarm.getFirstEventTime().toString()); verticalLayout1.addComponent(firstEvent); verticalLayout1.addComponent(lastEvent); Label nodeId = new Label(); nodeId.setSizeUndefined(); nodeId.addStyleName("alert-details-font"); nodeId.setCaption("Node Id"); if (onmsNode != null) { nodeId.setValue(onmsNode.getNodeId()); } else { nodeId.setValue("-"); } Label nodeLabel = new Label(); nodeLabel.setSizeUndefined(); nodeLabel.addStyleName("alert-details-font"); nodeLabel.setCaption("Node Label"); if (onmsNode != null) { nodeLabel.setValue(onmsNode.getLabel()); } else { nodeLabel.setValue("-"); } Label logMessage = new Label(); logMessage.addStyleName("alert-details-font"); logMessage.setSizeFull(); logMessage.setCaption("Log message"); logMessage.setValue(onmsAlarm.getLogMsg().replaceAll("<[^>]*>", "")); HorizontalLayout horizontalLayout2 = new HorizontalLayout(); horizontalLayout2.setSizeFull(); horizontalLayout2.setSpacing(true); horizontalLayout2.addComponent(nodeId); horizontalLayout2.addComponent(nodeLabel); verticalLayout2.addComponent(horizontalLayout2); verticalLayout2.addComponent(logMessage); horizontalLayout.setExpandRatio(verticalLayout1, 1.0f); horizontalLayout.setExpandRatio(verticalLayout2, 4.0f); return horizontalLayout; }
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 www .ja v a2s. 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.opennms.netmgt.vaadin.core.UIHelper.java
License:Open Source License
public static Label createLabel(String caption, String content) { Label label = new Label(content); label.setCaption(caption); return label; }
From source file:ru.codeinside.gses.manager.processdefeniton.ProcessDefenitionQuery.java
License:Mozilla Public License
PropertysetItem createItem(final ProcedureProcessDefinition p) { PropertysetItem item = new PropertysetItem(); ClickListener listener = new ClickListener() { private static final long serialVersionUID = -8900212370037948964L; @Override//from w w w . jav a 2s . c om public void buttonClick(ClickEvent event) { Window mainWin = event.getButton().getApplication().getMainWindow(); ProcessDefinition processDefinition = Functions.withRepository(Flash.login(), new Function<RepositoryService, ProcessDefinition>() { public ProcessDefinition apply(RepositoryService srv) { return srv.createProcessDefinitionQuery() .processDefinitionId(p.getProcessDefinitionId()).singleResult(); } }); String caption = "?? " + df.format(p.getVersion()); Window win = Components.createWindow(mainWin, caption); win.center(); ContentWindowChanger changer = new ContentWindowChanger(win); ProcessDefinitionShowUi putComponent = new ProcessDefinitionShowUi(processDefinition, changer); changer.set(putComponent, caption); } }; ObjectProperty<Component> versionProperty = Components.buttonProperty(df.format(p.getVersion()), listener); item.addItemProperty("version", versionProperty); HorizontalLayout ll = new HorizontalLayout(); ll.setSpacing(true); DefinitionStatus status = p.getStatus(); final Label label = new Label(status.getLabelName()); label.setWidth("100px"); ll.addComponent(label); final ComboBox comboBox = new ComboBox(); comboBox.setWidth("100px"); comboBox.setNullSelectionAllowed(false); for (DefinitionStatus s : status.getAvailableStatus()) { comboBox.addItem(s.getLabelName()); comboBox.setValue(s.getLabelName()); } if (!status.equals(DefinitionStatus.PathToArchive) && !status.getAvailableStatus().isEmpty()) { ll.addComponent(comboBox); Button c = new Button("ok"); c.addListener(new ClickListener() { private static final long serialVersionUID = 2966059295049064338L; @Override public void buttonClick(ClickEvent event) { Object value = comboBox.getValue(); final String newValue = value.toString(); final DefinitionStatus newStatus = DefinitionStatus.getStatusByLabelName(newValue); if (DefinitionStatus.Work.equals(newStatus)) { final List<ProcedureProcessDefinition> works = ManagerService.get() .getProcessDefenitionWithStatus(p, DefinitionStatus.Work); if (!works.isEmpty()) { final Window thisWindow = event.getButton().getWindow(); comfirmAction(thisWindow, p, label, newValue, newStatus, works); return; } } ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(), newStatus); label.setValue(null); label.setCaption(newValue); paramLazyLoadingContainer.fireItemSetChange(); proceduresContainer.fireItemSetChange(); } private void comfirmAction(final Window thisWindow, final ProcedureProcessDefinition p, final Label label, final String newValue, final DefinitionStatus newStatus, final List<ProcedureProcessDefinition> works) { final Window window = new Window(); window.setModal(true); window.setContent(new HorizontalLayout()); window.setCaption(" ? " + df.format(works.get(0).getVersion()) + " ? ?? "); Button save = new Button(""); save.addListener(new ClickListener() { private static final long serialVersionUID = 3229924940535642819L; @Override public void buttonClick(ClickEvent event) { ManagerService.get().updateProcessDefinationStatus(p.getProcessDefinitionId(), newStatus); label.setValue(null); label.setCaption(newValue); paramLazyLoadingContainer.fireItemSetChange(); proceduresContainer.fireItemSetChange(); closeWindow(thisWindow, window); } }); window.addComponent(save); Button c2 = new Button("?"); c2.addListener(new ClickListener() { private static final long serialVersionUID = 4502614143261892063L; @Override public void buttonClick(ClickEvent event) { closeWindow(thisWindow, window); } }); window.addComponent(c2); thisWindow.addWindow(window); } }); ll.addComponent(c); } item.addItemProperty("status", new ObjectProperty<Component>(ll)); item.addItemProperty("date", Components.stringProperty(formatter.format(p.getDateCreated()))); Employee creator = p.getCreator(); item.addItemProperty("user", Components.stringProperty(creator == null ? null : creator.getLogin())); Button b = new Button(""); b.addListener(new ClickListener() { private static final long serialVersionUID = 1362078893385574138L; @Override public void buttonClick(ClickEvent event) { StreamSource streamSource = new StreamSource() { private static final long serialVersionUID = 456334952891567271L; public InputStream getStream() { return Functions.withEngine(new PF<InputStream>() { private static final long serialVersionUID = 1L; public InputStream apply(ProcessEngine s) { return s.getRepositoryService().getProcessModel(p.getProcessDefinitionId()); } }); } }; final Application application = event.getButton().getApplication(); StreamResource resource = new StreamResource(streamSource, "test" + ".xml", application) { private static final long serialVersionUID = -3869546661105572851L; public DownloadStream getStream() { final StreamSource ss = getStreamSource(); if (ss == null) { return null; } final DownloadStream ds = new DownloadStream(ss.getStream(), getMIMEType(), getFilename()); ds.setBufferSize(getBufferSize()); ds.setCacheTime(getCacheTime()); ds.setParameter("Content-Disposition", "attachment; filename=" + getFilename()); return ds; } }; Window window = event.getButton().getWindow(); window.open(resource); } }); item.addItemProperty("getRoute", new ObjectProperty<Component>(b)); ObjectProperty<Component> buttonProperty = null; if (status.equals(DefinitionStatus.Debugging)) { DeploymentUploadReceiver receiver = new DeploymentUploadReceiver(); DeploymentSucceededListener succeededListener = new DeploymentSucceededListener(receiver, procedureId, p.getProcessDefinitionId()); succeededListener.addLoadingContainer(paramLazyLoadingContainer); succeededListener.addLoadingContainer(proceduresContainer); DeploymentAddUi addUi = new DeploymentAddUi(new DeploymentStartListener(), receiver, succeededListener); addUi.setSizeFull(); buttonProperty = new ObjectProperty<Component>(addUi); } else { ClickListener l = new ClickListener() { private static final long serialVersionUID = 1362078893385574138L; @Override public void buttonClick(ClickEvent event) { } }; buttonProperty = Components.buttonProperty("", l); } item.addItemProperty("download", buttonProperty); return item; }