List of usage examples for com.vaadin.ui GridLayout setMargin
@Override public void setMargin(MarginInfo marginInfo)
From source file:org.ikasan.dashboard.ui.topology.component.CategorisedErrorTab.java
License:BSD License
public Layout createCategorisedErrorLayout() { this.categorizedErrorOccurenceTable = new FilterTable(); this.categorizedErrorOccurenceTable.setSizeFull(); this.categorizedErrorOccurenceTable.addContainerProperty("", Label.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("", .03f); this.categorizedErrorOccurenceTable.addContainerProperty("Module Name", String.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("Module Name", .15f); this.categorizedErrorOccurenceTable.addContainerProperty("Flow Name", String.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("Flow Name", .18f); this.categorizedErrorOccurenceTable.addContainerProperty("Component Name", String.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("Component Name", .2f); this.categorizedErrorOccurenceTable.addContainerProperty("Error Message", String.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("Error Message", .33f); this.categorizedErrorOccurenceTable.addContainerProperty("Timestamp", String.class, null); this.categorizedErrorOccurenceTable.setColumnExpandRatio("Timestamp", .1f); this.categorizedErrorOccurenceTable.addStyleName("wordwrap-table"); this.categorizedErrorOccurenceTable.addStyleName(ValoTheme.TABLE_NO_STRIPES); // this.categorizedErrorOccurenceTable.setFilterBarVisible(true); this.categorizedErrorOccurenceTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/* w w w . j a v a 2 s . co m*/ public void itemClick(ItemClickEvent itemClickEvent) { CategorisedErrorOccurrence errorOccurrence = (CategorisedErrorOccurrence) itemClickEvent .getItemId(); CategorisedErrorOccurrenceViewWindow errorOccurrenceViewWindow = new CategorisedErrorOccurrenceViewWindow( errorOccurrence, serialiserFactory); UI.getCurrent().addWindow(errorOccurrenceViewWindow); } }); this.categorizedErrorOccurenceTable.setCellStyleGenerator(new CustomTable.CellStyleGenerator() { @Override public String getStyle(CustomTable source, Object itemId, Object propertyId) { CategorisedErrorOccurrence categorisedErrorOccurrence = (CategorisedErrorOccurrence) itemId; if (propertyId == null) { // Styling for row if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { return "ikasan-green-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { return "ikasan-green-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { return "ikasan-orange-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { return "ikasan-red-small"; } } if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { return "ikasan-green-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { return "ikasan-green-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { return "ikasan-orange-small"; } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { return "ikasan-red-small"; } return "ikasan-small"; } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { categorizedErrorOccurenceTable.removeAllItems(); ArrayList<String> modulesNames = null; if (errorOccurenceModules.getItemIds().size() > 0) { modulesNames = new ArrayList<String>(); for (Object module : errorOccurenceModules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } ArrayList<String> flowNames = null; if (errorOccurenceFlows.getItemIds().size() > 0) { flowNames = new ArrayList<String>(); for (Object flow : errorOccurenceFlows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } ArrayList<String> componentNames = null; if (errorOccurenceComponents.getItemIds().size() > 0) { componentNames = new ArrayList<String>(); for (Object component : errorOccurenceComponents.getItemIds()) { componentNames.add(((Component) component).getName()); } } if (modulesNames == null && flowNames == null && componentNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new ArrayList<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } String errorCategory = null; if (errorCategoryCombo != null && errorCategoryCombo.getValue() != null) { errorCategory = (String) errorCategoryCombo.getValue(); } List<CategorisedErrorOccurrence> categorisedErrorOccurences = errorCategorisationService .findCategorisedErrorOccurences(modulesNames, flowNames, componentNames, "", "", errorCategory, errorFromDate.getValue(), errorToDate.getValue()); for (CategorisedErrorOccurrence categorisedErrorOccurrence : categorisedErrorOccurences) { ErrorOccurrence errorOccurrence = categorisedErrorOccurrence.getErrorOccurrence(); Date date = new Date(errorOccurrence.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); Label categoryLabel = new Label(); if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { categoryLabel = new Label(VaadinIcons.BAN.getHtml(), ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { categoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml(), ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { categoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml(), ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { categoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml(), ContentMode.HTML); } categorizedErrorOccurenceTable .addItem( new Object[] { categoryLabel, errorOccurrence.getModuleName(), errorOccurrence.getFlowName(), errorOccurrence.getFlowElementName(), categorisedErrorOccurrence.getErrorCategorisation() .getErrorDescription(), timestamp }, categorisedErrorOccurrence); } } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { errorOccurenceModules.removeAllItems(); errorOccurenceFlows.removeAllItems(); errorOccurenceComponents.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(); errorOccurenceModules.setIcon(VaadinIcons.ARCHIVE); errorOccurenceModules.addContainerProperty("Module Name", String.class, null); errorOccurenceModules.addContainerProperty("", Button.class, null); errorOccurenceModules.setSizeFull(); errorOccurenceModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceModules.setDragMode(TableDragMode.ROW); errorOccurenceModules.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) { errorOccurenceModules.removeItem(module); } }); errorOccurenceModules.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) { errorOccurenceFlows.removeItem(flow); } }); errorOccurenceFlows.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(errorOccurenceModules, 0, 0); errorOccurenceFlows.setIcon(VaadinIcons.AUTOMATION); errorOccurenceFlows.addContainerProperty("Flow Name", String.class, null); errorOccurenceFlows.addContainerProperty("", Button.class, null); errorOccurenceFlows.setSizeFull(); errorOccurenceFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceFlows.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) { errorOccurenceFlows.removeItem(flow); } }); errorOccurenceFlows.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(errorOccurenceFlows, 1, 0); errorOccurenceComponents.setIcon(VaadinIcons.COG); errorOccurenceComponents.setSizeFull(); errorOccurenceComponents.addContainerProperty("Component Name", String.class, null); errorOccurenceComponents.addContainerProperty("", Button.class, null); errorOccurenceComponents.setCellStyleGenerator(new IkasanCellStyleGenerator()); errorOccurenceComponents.setSizeFull(); errorOccurenceComponents.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceComponents.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(this.errorOccurenceComponents, 2, 0); errorCategoryCombo = new ComboBox("Error Category"); errorCategoryCombo.setNullSelectionAllowed(true); errorCategoryCombo.addItem(ErrorCategorisation.TRIVIAL); errorCategoryCombo.setItemIcon(ErrorCategorisation.TRIVIAL, VaadinIcons.ARROW_DOWN); errorCategoryCombo.addItem(ErrorCategorisation.MAJOR); errorCategoryCombo.setItemIcon(ErrorCategorisation.MAJOR, VaadinIcons.ARROW_UP); errorCategoryCombo.addItem(ErrorCategorisation.CRITICAL); errorCategoryCombo.setItemIcon(ErrorCategorisation.CRITICAL, VaadinIcons.EXCLAMATION_CIRCLE_O); errorCategoryCombo.addItem(ErrorCategorisation.BLOCKER); errorCategoryCombo.setItemIcon(ErrorCategorisation.BLOCKER, VaadinIcons.BAN); GridLayout dateSelectLayout = new GridLayout(3, 1); dateSelectLayout.addComponent(errorCategoryCombo, 2, 0); dateSelectLayout.setSizeFull(); errorFromDate = new PopupDateField("From date"); errorFromDate.setResolution(Resolution.MINUTE); errorFromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(errorFromDate, 0, 0); errorToDate = new PopupDateField("To date"); errorToDate.setResolution(Resolution.MINUTE); errorToDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(errorToDate, 1, 0); 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(40, 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(300, 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.categorizedErrorOccurenceTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(310, 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.component.ErrorOccurrenceTab.java
License:BSD License
public Layout createCategorisedErrorLayout() { this.errorOccurenceTable = new Table(); this.errorOccurenceTable.setSizeFull(); this.errorOccurenceTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.errorOccurenceTable.addStyleName(ValoTheme.TABLE_SMALL); this.errorOccurenceTable.addStyleName("ikasan"); this.errorOccurenceTable.addContainerProperty("Module Name", String.class, null); this.errorOccurenceTable.setColumnExpandRatio("Module Name", .14f); this.errorOccurenceTable.addContainerProperty("Flow Name", String.class, null); this.errorOccurenceTable.setColumnExpandRatio("Flow Name", .18f); this.errorOccurenceTable.addContainerProperty("Component Name", String.class, null); this.errorOccurenceTable.setColumnExpandRatio("Component Name", .2f); this.errorOccurenceTable.addContainerProperty("Error Message", String.class, null); this.errorOccurenceTable.setColumnExpandRatio("Error Message", .33f); this.errorOccurenceTable.addContainerProperty("Timestamp", String.class, null); this.errorOccurenceTable.setColumnExpandRatio("Timestamp", .1f); this.errorOccurenceTable.addStyleName("wordwrap-table"); this.errorOccurenceTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/*from ww w . j a v a 2 s. c om*/ public void itemClick(ItemClickEvent itemClickEvent) { ErrorOccurrence errorOccurrence = (ErrorOccurrence) itemClickEvent.getItemId(); ErrorOccurrenceViewWindow errorOccurrenceViewWindow = new ErrorOccurrenceViewWindow( errorOccurrence); UI.getCurrent().addWindow(errorOccurrenceViewWindow); } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { errorOccurenceTable.removeAllItems(); ArrayList<String> modulesNames = null; if (errorOccurenceModules.getItemIds().size() > 0) { modulesNames = new ArrayList<String>(); for (Object module : errorOccurenceModules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } ArrayList<String> flowNames = null; if (errorOccurenceFlows.getItemIds().size() > 0) { flowNames = new ArrayList<String>(); for (Object flow : errorOccurenceFlows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } ArrayList<String> componentNames = null; if (errorOccurenceComponents.getItemIds().size() > 0) { componentNames = new ArrayList<String>(); for (Object component : errorOccurenceComponents.getItemIds()) { componentNames.add(((Component) component).getName()); } } if (modulesNames == null && flowNames == null && componentNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new ArrayList<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } List<ErrorOccurrence> errorOccurences = errorReportingService.find(modulesNames, flowNames, componentNames, errorFromDate.getValue(), errorToDate.getValue()); for (ErrorOccurrence errorOccurrence : errorOccurences) { Date date = new Date(errorOccurrence.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); errorOccurenceTable.addItem(new Object[] { errorOccurrence.getModuleName(), errorOccurrence.getFlowName(), errorOccurrence.getFlowElementName(), errorOccurrence.getErrorMessage(), timestamp }, errorOccurrence); } } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { errorOccurenceModules.removeAllItems(); errorOccurenceFlows.removeAllItems(); errorOccurenceComponents.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(); errorOccurenceModules.setIcon(VaadinIcons.ARCHIVE); errorOccurenceModules.addContainerProperty("Module Name", String.class, null); errorOccurenceModules.addContainerProperty("", Button.class, null); errorOccurenceModules.setSizeFull(); errorOccurenceModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceModules.setDragMode(TableDragMode.ROW); errorOccurenceModules.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) { errorOccurenceModules.removeItem(module); } }); errorOccurenceModules.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) { errorOccurenceFlows.removeItem(flow); } }); errorOccurenceFlows.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(errorOccurenceModules, 0, 0); errorOccurenceFlows.setIcon(VaadinIcons.AUTOMATION); errorOccurenceFlows.addContainerProperty("Flow Name", String.class, null); errorOccurenceFlows.addContainerProperty("", Button.class, null); errorOccurenceFlows.setSizeFull(); errorOccurenceFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceFlows.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) { errorOccurenceFlows.removeItem(flow); } }); errorOccurenceFlows.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(errorOccurenceFlows, 1, 0); errorOccurenceComponents.setIcon(VaadinIcons.COG); errorOccurenceComponents.setSizeFull(); errorOccurenceComponents.addContainerProperty("Component Name", String.class, null); errorOccurenceComponents.addContainerProperty("", Button.class, null); errorOccurenceComponents.setCellStyleGenerator(new IkasanCellStyleGenerator()); errorOccurenceComponents.setSizeFull(); errorOccurenceComponents.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); errorOccurenceComponents.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) { errorOccurenceComponents.removeItem(component); } }); errorOccurenceComponents.addItem(new Object[] { component.getName(), deleteButton }, component); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(this.errorOccurenceComponents, 2, 0); GridLayout dateSelectLayout = new GridLayout(2, 1); dateSelectLayout.setSizeFull(); errorFromDate = new PopupDateField("From date"); errorFromDate.setResolution(Resolution.MINUTE); errorFromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(errorFromDate, 0, 0); errorToDate = new PopupDateField("To date"); errorToDate.setResolution(Resolution.MINUTE); errorToDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(errorToDate, 1, 0); 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(40, 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(300, 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.errorOccurenceTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(310, 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.component.ExclusionsTab.java
License:BSD License
public Layout createLayout() { this.exclusionsTable = new Table(); this.exclusionsTable.setSizeFull(); this.exclusionsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.exclusionsTable.addContainerProperty("Module Name", String.class, null); this.exclusionsTable.addContainerProperty("Flow Name", String.class, null); this.exclusionsTable.addContainerProperty("Timestamp", String.class, null); this.exclusionsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override// w w w . j a va 2 s. c o m public void itemClick(ItemClickEvent itemClickEvent) { ExclusionEvent exclusionEvent = (ExclusionEvent) itemClickEvent.getItemId(); ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService .find(exclusionEvent.getErrorUri()); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri()); ExclusionEventViewWindow exclusionEventViewWindow = new ExclusionEventViewWindow(exclusionEvent, errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService); exclusionEventViewWindow.addCloseListener(new Window.CloseListener() { // inline close-listener public void windowClose(CloseEvent e) { refreshExcludedEventsTable(); } }); UI.getCurrent().addWindow(exclusionEventViewWindow); } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { exclusionsTable.removeAllItems(); ArrayList<String> modulesNames = null; if (exclusionModules.getItemIds().size() > 0) { modulesNames = new ArrayList<String>(); for (Object module : exclusionModules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } ArrayList<String> flowNames = null; if (exclusionFlows.getItemIds().size() > 0) { flowNames = new ArrayList<String>(); for (Object flow : exclusionFlows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } if (modulesNames == null && flowNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new ArrayList<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } List<ExclusionEvent> exclusionEvents = exclusionManagementService.find(modulesNames, flowNames, fromDate.getValue(), toDate.getValue(), null); for (ExclusionEvent exclusionEvent : exclusionEvents) { Date date = new Date(exclusionEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); exclusionsTable.addItem(new Object[] { exclusionEvent.getModuleName(), exclusionEvent.getFlowName(), timestamp }, exclusionEvent); } } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionModules.removeAllItems(); exclusionFlows.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(2, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); exclusionModules.setIcon(VaadinIcons.ARCHIVE); exclusionModules.addContainerProperty("Module Name", String.class, null); exclusionModules.addContainerProperty("", Button.class, null); exclusionModules.setSizeFull(); exclusionModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionModules.setDragMode(TableDragMode.ROW); exclusionModules.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) { exclusionModules.removeItem(module); } }); exclusionModules.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) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionModules, 0, 0); exclusionFlows.setIcon(VaadinIcons.AUTOMATION); exclusionFlows.addContainerProperty("Flow Name", String.class, null); exclusionFlows.addContainerProperty("", Button.class, null); exclusionFlows.setSizeFull(); exclusionFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionFlows.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) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionFlows, 1, 0); GridLayout dateSelectLayout = new GridLayout(2, 1); dateSelectLayout.setSizeFull(); fromDate = new PopupDateField("From date"); fromDate.setResolution(Resolution.MINUTE); fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(fromDate, 0, 0); toDate = new PopupDateField("To date"); toDate.setResolution(Resolution.MINUTE); toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(toDate, 1, 0); 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(40, 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(300, 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.exclusionsTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(310, 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.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//from w w w .ja v a 2s .c o m 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.ActionedExclusionEventViewWindow.java
License:BSD License
protected Panel createExclusionEventDetailsPanel() { Panel exclusionEventDetailsPanel = new Panel(); exclusionEventDetailsPanel.setSizeFull(); exclusionEventDetailsPanel.setStyleName("dashboard"); GridLayout layout = new GridLayout(4, 7); layout.setSpacing(true);//from w ww . j a va 2 s . c o m layout.setColumnExpandRatio(0, .10f); layout.setColumnExpandRatio(1, .30f); layout.setColumnExpandRatio(2, .05f); layout.setColumnExpandRatio(3, .30f); layout.setWidth("100%"); Label exclusionEvenDetailsLabel = new Label("Actioned Exclusion Event Details"); exclusionEvenDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(exclusionEvenDetailsLabel, 0, 0, 3, 0); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.action.getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.action.getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Event Id:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.errorOccurrence.getEventLifeIdentifier()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.action.getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); label = new Label("Error URI:"); label.setSizeUndefined(); layout.addComponent(label, 0, 5); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf5 = new TextField(); tf5.setValue(this.action.getErrorUri()); tf5.setReadOnly(true); tf5.setWidth("80%"); layout.addComponent(tf5, 1, 5); label = new Label("Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf6 = new TextField(); if (this.action != null) { tf6.setValue(action.getAction()); } tf6.setReadOnly(true); tf6.setWidth("80%"); layout.addComponent(tf6, 3, 1); label = new Label("Actioned By:"); label.setSizeUndefined(); layout.addComponent(label, 2, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf7 = new TextField(); if (this.action != null) { tf7.setValue(action.getActionedBy()); } tf7.setReadOnly(true); tf7.setWidth("80%"); layout.addComponent(tf7, 3, 2); label = new Label("Actioned Time:"); label.setSizeUndefined(); layout.addComponent(label, 2, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); final TextField tf8 = new TextField(); if (this.action != null) { tf8.setValue(new Date(action.getTimestamp()).toString()); } tf8.setReadOnly(true); tf8.setWidth("80%"); layout.addComponent(tf8, 3, 3); AceEditor eventEditor = new AceEditor(); eventEditor.setCaption("Event Payload"); Object event = this.serialiserFactory.getDefaultSerialiser().deserialise(this.action.getEvent()); eventEditor.setValue(event.toString()); eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setWidth("100%"); eventEditor.setHeight(600, Unit.PIXELS); HorizontalLayout eventEditorLayout = new HorizontalLayout(); eventEditorLayout.setSizeFull(); eventEditorLayout.setMargin(true); eventEditorLayout.addComponent(eventEditor); AceEditor errorEditor = new AceEditor(); errorEditor.setCaption("Error Details"); errorEditor.setValue(this.errorOccurrence.getErrorDetail()); errorEditor.setReadOnly(true); errorEditor.setMode(AceMode.xml); errorEditor.setTheme(AceTheme.eclipse); errorEditor.setWidth("100%"); errorEditor.setHeight(600, Unit.PIXELS); HorizontalLayout errorEditorLayout = new HorizontalLayout(); errorEditorLayout.setSizeFull(); errorEditorLayout.setMargin(true); errorEditorLayout.addComponent(errorEditor); VerticalSplitPanel splitPanel = new VerticalSplitPanel(); splitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); splitPanel.setWidth("100%"); splitPanel.setHeight(800, Unit.PIXELS); splitPanel.setFirstComponent(eventEditorLayout); splitPanel.setSecondComponent(errorEditorLayout); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(220, Unit.PIXELS); formLayout.addComponent(layout); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); wrapperLayout.addComponent(formLayout); wrapperLayout.addComponent(splitPanel); exclusionEventDetailsPanel.setContent(wrapperLayout); return exclusionEventDetailsPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java
License:BSD License
protected Panel createErrorOccurrenceDetailsPanel() { Panel errorOccurrenceDetailsPanel = new Panel(); GridLayout layout = new GridLayout(4, 7); layout.setWidth("100%"); layout.setSpacing(true);/*from w w w.ja v a2 s . c o m*/ layout.setColumnExpandRatio(0, .10f); layout.setColumnExpandRatio(1, .30f); layout.setColumnExpandRatio(2, .05f); layout.setColumnExpandRatio(3, .30f); Label errorOccurrenceDetailsLabel = new Label(" Categorised Error Occurence Details", ContentMode.HTML); Label errorCategoryLabel = new Label(); if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.BLOCKER)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.BAN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.BAN.getHtml() + " Blocker", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.CRITICAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.EXCLAMATION.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.EXCLAMATION.getHtml() + " Critical", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.MAJOR)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_UP.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_UP.getHtml() + " Major", ContentMode.HTML); } else if (categorisedErrorOccurrence.getErrorCategorisation().getErrorCategory() .equals(ErrorCategorisation.TRIVIAL)) { errorOccurrenceDetailsLabel = new Label( VaadinIcons.ARROW_DOWN.getHtml() + " Categorised Error Occurence Details", ContentMode.HTML); errorCategoryLabel = new Label(VaadinIcons.ARROW_DOWN.getHtml() + " Trivial", ContentMode.HTML); } errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 3, 0); Label label = new Label("Module Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf1 = new TextField(); tf1.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getModuleName()); tf1.setReadOnly(true); tf1.setWidth("80%"); layout.addComponent(tf1, 1, 1); label = new Label("Flow Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf2 = new TextField(); tf2.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowName()); tf2.setReadOnly(true); tf2.setWidth("80%"); layout.addComponent(tf2, 1, 2); label = new Label("Component Name:"); label.setSizeUndefined(); layout.addComponent(label, 0, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf3 = new TextField(); tf3.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getFlowElementName()); tf3.setReadOnly(true); tf3.setWidth("80%"); layout.addComponent(tf3, 1, 3); label = new Label("Date/Time:"); label.setSizeUndefined(); layout.addComponent(label, 0, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField tf4 = new TextField(); tf4.setValue(new Date(this.categorisedErrorOccurrence.getErrorOccurrence().getTimestamp()).toString()); tf4.setReadOnly(true); tf4.setWidth("80%"); layout.addComponent(tf4, 1, 4); GridLayout wrapperLayout = new GridLayout(1, 4); wrapperLayout.setMargin(true); wrapperLayout.setWidth("100%"); Label errorMessageLabel = new Label("Error Message:"); errorMessageLabel.setSizeUndefined(); layout.addComponent(errorMessageLabel, 0, 5); layout.setComponentAlignment(errorMessageLabel, Alignment.TOP_RIGHT); final TextArea errorMessageTextArea = new TextArea(); errorMessageTextArea.setWidth("650px"); errorMessageTextArea.setRows(6); errorMessageTextArea .setValue(this.categorisedErrorOccurrence.getErrorCategorisation().getErrorDescription()); layout.addComponent(errorMessageTextArea, 1, 5, 3, 5); AceEditor editor = new AceEditor(); editor.setCaption("Error Details"); editor.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getErrorDetail()); editor.setReadOnly(true); editor.setMode(AceMode.xml); editor.setTheme(AceTheme.eclipse); editor.setHeight(470, Unit.PIXELS); editor.setWidth("100%"); label = new Label("Error Category:"); label.setSizeUndefined(); layout.addComponent(label, 2, 1); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); layout.addComponent(errorCategoryLabel, 3, 1); layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_LEFT); label = new Label("System Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 2); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField systemAction = new TextField(); systemAction.setValue(this.categorisedErrorOccurrence.getErrorOccurrence().getAction()); systemAction.setReadOnly(true); systemAction.setWidth("80%"); layout.addComponent(systemAction, 3, 2); label = new Label("User Action:"); label.setSizeUndefined(); layout.addComponent(label, 2, 3); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); TextField userAction = new TextField(); userAction.setValue(""); userAction.setReadOnly(true); userAction.setWidth("80%"); layout.addComponent(userAction, 3, 3); label = new Label("User Action By:"); label.setSizeUndefined(); layout.addComponent(label, 2, 4); layout.setComponentAlignment(label, Alignment.MIDDLE_RIGHT); Label userActionBy = new Label(); userActionBy.setValue(""); userActionBy.setReadOnly(true); userActionBy.setWidth("80%"); layout.addComponent(userActionBy, 3, 4); AceEditor eventEditor = new AceEditor(); eventEditor.setCaption("Event Payload"); if (this.categorisedErrorOccurrence.getErrorOccurrence().getEvent() != null) { eventEditor .setValue(new String((byte[]) this.categorisedErrorOccurrence.getErrorOccurrence().getEvent())); } eventEditor.setReadOnly(true); eventEditor.setMode(AceMode.java); eventEditor.setTheme(AceTheme.eclipse); eventEditor.setHeight(470, Unit.PIXELS); eventEditor.setWidth("100%"); HorizontalLayout formLayout = new HorizontalLayout(); formLayout.setWidth("100%"); formLayout.setHeight(300, Unit.PIXELS); formLayout.addComponent(layout); wrapperLayout.addComponent(formLayout, 0, 0); // VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); // vSplitPanel.setWidth("100%"); // vSplitPanel.setHeight(800, Unit.PIXELS); // vSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); TabSheet tabsheet = new TabSheet(); tabsheet.setSizeFull(); HorizontalLayout h1 = new HorizontalLayout(); h1.setSizeFull(); h1.setMargin(true); h1.addComponent(eventEditor); // vSplitPanel.setFirstComponent(h1); HorizontalLayout h2 = new HorizontalLayout(); h2.setSizeFull(); h2.setMargin(true); h2.addComponent(editor); // vSplitPanel.setSecondComponent(h2); tabsheet.addTab(h2, "Error Details"); tabsheet.addTab(h1, "Event Payload"); wrapperLayout.addComponent(tabsheet, 0, 1); // wrapperLayout.addComponent(vSplitPanel, 0, 1); errorOccurrenceDetailsPanel.setContent(wrapperLayout); return errorOccurrenceDetailsPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
@SuppressWarnings("unchecked") public void populate(Component component) { configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); if (configuration == null) { Server server = component.getFlow().getModule().getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + component.getFlow().getModule().getContextRoot() + "/rest/configuration/createConfiguration/" + component.getFlow().getModule().getName() + "/" + component.getFlow().getName() + "/" + component.getName();//from w ww .jav a 2 s . com logger.info("Configuration Url: " + url); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(), (String) authentication.getCredentials()); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); Client client = ClientBuilder.newClient(clientConfig); ObjectMapper mapper = new ObjectMapper(); WebTarget webTarget = client.target(url); Response response = webTarget.request().get(); if (response.getStatus() != 200) { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show("An error was received trying to create configured resource '" + component.getConfigurationId() + "': " + responseMessage, Type.ERROR_MESSAGE); } configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); } final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) configuration .getParameters(); this.layout = new GridLayout(2, parameters.size() + 6); this.layout.setSpacing(true); this.layout.setColumnExpandRatio(0, .25f); this.layout.setColumnExpandRatio(1, .75f); this.layout.setWidth("95%"); this.layout.setMargin(true); Label configurationParametersLabel = new Label("Configuration Parameters"); configurationParametersLabel.setStyleName(ValoTheme.LABEL_HUGE); this.layout.addComponent(configurationParametersLabel, 0, 0); GridLayout paramLayout = new GridLayout(2, 2); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label configuredResourceIdLabel = new Label("Configured Resource Id"); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_BOLD); Label configuredResourceIdValueLabel = new Label(configuration.getConfigurationId()); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_BOLD); paramLayout.addComponent(configuredResourceIdLabel, 0, 0); paramLayout.setComponentAlignment(configuredResourceIdLabel, Alignment.TOP_RIGHT); paramLayout.addComponent(configuredResourceIdValueLabel, 1, 0); Label configurationDescriptionLabel = new Label("Description:"); configurationDescriptionLabel.setSizeUndefined(); paramLayout.addComponent(configurationDescriptionLabel, 0, 1); paramLayout.setComponentAlignment(configurationDescriptionLabel, Alignment.TOP_RIGHT); TextArea conmfigurationDescriptionTextField = new TextArea(); conmfigurationDescriptionTextField.setRows(4); conmfigurationDescriptionTextField.setWidth("80%"); paramLayout.addComponent(conmfigurationDescriptionTextField, 1, 1); this.layout.addComponent(paramLayout, 0, 1, 1, 1); int i = 2; for (ConfigurationParameter parameter : parameters) { if (parameter instanceof ConfigurationParameterIntegerImpl) { this.layout.addComponent( this.createTextAreaPanel(parameter, new IntegerValidator("Must be a valid number")), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterStringImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new StringValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new BooleanValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterLongImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new LongValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterMapImpl) { this.layout.addComponent(this.createMapPanel((ConfigurationParameterMapImpl) parameter), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterListImpl) { this.layout.addComponent(this.createListPanel((ConfigurationParameterListImpl) parameter), 0, i, 1, i); } i++; } Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextArea textField : textFields.values()) { textField.validate(); } } catch (InvalidValueException e) { e.printStackTrace(); for (TextArea textField : textFields.values()) { textField.setValidationVisible(true); } Notification.show("There are errors on the form above", Type.ERROR_MESSAGE); return; } for (ConfigurationParameter parameter : parameters) { TextArea textField = ComponentConfigurationWindow.this.textFields.get(parameter.getName()); TextArea descriptionTextField = ComponentConfigurationWindow.this.descriptionTextFields .get(parameter.getName()); if (parameter != null && descriptionTextField != null) { parameter.setDescription(descriptionTextField.getValue()); } if (parameter instanceof ConfigurationParameterIntegerImpl) { logger.info("Setting Integer value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Integer(textField.getValue())); } else if (parameter instanceof ConfigurationParameterStringImpl) { logger.info("Setting String value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(textField.getValue()); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Boolean(textField.getValue())); } else if (parameter instanceof ConfigurationParameterLongImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Long(textField.getValue())); } else if (parameter instanceof ConfigurationParameterMapImpl) { ConfigurationParameterMapImpl mapParameter = (ConfigurationParameterMapImpl) parameter; HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); } else if (parameter instanceof ConfigurationParameterListImpl) { ConfigurationParameterListImpl mapParameter = (ConfigurationParameterListImpl) parameter; ArrayList<String> map = new ArrayList<String>(); for (String key : valueTextFields.keySet()) { if (key.startsWith(parameter.getName())) { map.add(valueTextFields.get(key).getValue()); } } parameter.setValue(map); } } ComponentConfigurationWindow.this.configurationManagement.saveConfiguration(configuration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); Button deleteButton = new Button("Delete"); deleteButton.addStyleName(ValoTheme.BUTTON_SMALL); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { DeleteConfigurationAction action = new DeleteConfigurationAction(configuration, configurationManagement, ComponentConfigurationWindow.this); IkasanMessageDialog dialog = new IkasanMessageDialog("Delete configuration", "Are you sure you would like to delete this configuration?", action); UI.getCurrent().addWindow(dialog); } }); GridLayout buttonLayout = new GridLayout(2, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton, 0, 0); buttonLayout.addComponent(deleteButton, 1, 0); this.layout.addComponent(buttonLayout, 0, i, 1, i); this.layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); Panel configurationPanel = new Panel(); configurationPanel.setContent(this.layout); this.setContent(configurationPanel); }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createTextAreaPanel(ConfigurationParameter parameter, Validator validator) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);// ww w. jav a 2 s. com paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); logger.info(parameter.getName() + " " + parameter.getValue()); Label valueLabel = new Label("Value:"); valueLabel.setSizeUndefined(); TextArea textField = new TextArea(); textField.addValidator(validator); textField.setNullSettingAllowed(true); textField.setNullRepresentation(""); textField.setValidationVisible(false); textField.setRows(4); textField.setWidth("80%"); textField.setId(parameter.getName()); if (parameter instanceof ConfigurationParameterIntegerImpl) { StringToIntegerConverter plainIntegerConverter = new StringToIntegerConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields textField.setConverter(plainIntegerConverter); } else if (parameter instanceof ConfigurationParameterLongImpl) { StringToLongConverter plainLongConverter = new StringToLongConverter() { protected java.text.NumberFormat getFormat(Locale locale) { NumberFormat format = super.getFormat(locale); format.setGroupingUsed(false); return format; }; }; // either set for the field or in your field factory for multiple fields textField.setConverter(plainLongConverter); } textFields.put(parameter.getName(), textField); BeanItem<ConfigurationParameter> parameterItem = new BeanItem<ConfigurationParameter>(parameter); if (parameter.getValue() != null) { textField.setPropertyDataSource(parameterItem.getItemProperty("value")); } paramLayout.addComponent(valueLabel, 0, 1); paramLayout.addComponent(textField, 1, 1); paramLayout.setComponentAlignment(valueLabel, Alignment.TOP_RIGHT); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } paramPanel.setContent(paramLayout); return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/*from w ww. j a v a 2 s . co m*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setMargin(true); mapLayout.setSpacing(true); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Key"); final Label valueLabel = new Label("Value"); final TextField keyField = new TextField(); keyField.setValue(key); final TextField valueField = new TextField(); valueField.setValue(valueMap.get(key)); mapLayout.addComponent(keyLabel, 0, i); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Key"); final Label valueLabel = new Label("Value"); final TextField keyField = new TextField(); final TextField valueField = new TextField(); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName("dashboard"); mapPanel.setContent(mapLayout); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } return paramPanel; }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
protected Panel createListPanel(final ConfigurationParameterListImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/*from w ww. j a v a 2 s . c om*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label(parameter.getName()); label.setIcon(VaadinIcons.COG); label.addStyleName(ValoTheme.LABEL_LARGE); label.addStyleName(ValoTheme.LABEL_BOLD); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final List<String> valueList = parameter.getValue(); final GridLayout listLayout = new GridLayout(3, (valueList.size() != 0 ? valueList.size() : 1) + 1); listLayout.setWidth("450px"); listLayout.setMargin(true); listLayout.setSpacing(true); listLayout.setColumnExpandRatio(0, 0.25f); listLayout.setColumnExpandRatio(1, 0.5f); listLayout.setColumnExpandRatio(2, 0.25f); int i = 0; for (final String value : valueList) { final Label valueLabel = new Label("Value"); final TextField valueField = new TextField(); valueField.setValue(value); valueField.setWidth("90%"); listLayout.addComponent(valueLabel, 0, i); listLayout.addComponent(valueField, 1, i); final String mapKey = parameter.getName() + i; this.valueTextFields.put(mapKey, valueField); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueList.remove(value); listLayout.removeComponent(valueLabel); listLayout.removeComponent(valueField); listLayout.removeComponent(removeButton); valueTextFields.remove(mapKey); } }); listLayout.addComponent(removeButton, 2, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label valueLabel = new Label("Value"); final TextField valueField = new TextField(); valueField.setWidth("90%"); listLayout.insertRow(listLayout.getRows()); listLayout.removeComponent(addButton); listLayout.addComponent(valueLabel, 0, listLayout.getRows() - 2); listLayout.addComponent(valueField, 1, listLayout.getRows() - 2); final String mapKey = parameter.getName() + valueTextFields.size(); valueTextFields.put(mapKey, valueField); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { listLayout.removeComponent(valueLabel); listLayout.removeComponent(valueField); listLayout.removeComponent(removeButton); valueTextFields.remove(mapKey); } }); listLayout.addComponent(removeButton, 2, listLayout.getRows() - 2); listLayout.addComponent(addButton, 0, listLayout.getRows() - 1); } }); listLayout.addComponent(addButton, 0, listLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName("dashboard"); mapPanel.setContent(listLayout); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); Label paramDescriptionLabel = new Label("Description:"); paramDescriptionLabel.setSizeUndefined(); TextArea descriptionTextField = new TextArea(); descriptionTextField.setRows(4); descriptionTextField.setWidth("80%"); descriptionTextField.setId(parameter.getName()); paramLayout.addComponent(paramDescriptionLabel, 0, 2); paramLayout.addComponent(descriptionTextField, 1, 2); paramLayout.setComponentAlignment(paramDescriptionLabel, Alignment.TOP_RIGHT); descriptionTextFields.put(parameter.getName(), descriptionTextField); if (parameter.getDescription() != null) { descriptionTextField.setValue(parameter.getDescription()); } return paramPanel; }