List of usage examples for com.vaadin.ui Panel setHeight
@Override public void setHeight(float height, Unit unit)
From source file:org.ikasan.dashboard.ui.topology.component.ActionedExclusionTab.java
License:BSD License
public Layout createLayout() { this.actionedExclusionsTable = new Table(); this.actionedExclusionsTable.setSizeFull(); this.actionedExclusionsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.actionedExclusionsTable.addContainerProperty("Module Name", String.class, null); this.actionedExclusionsTable.addContainerProperty("Flow Name", String.class, null); this.actionedExclusionsTable.addContainerProperty("Action", String.class, null); this.actionedExclusionsTable.addContainerProperty("Actioned By", String.class, null); this.actionedExclusionsTable.addContainerProperty("Timestamp", String.class, null); this.actionedExclusionsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/* www. jav a 2s .co m*/ public void itemClick(ItemClickEvent itemClickEvent) { ExclusionEventAction exclusionEventAction = (ExclusionEventAction) itemClickEvent.getItemId(); ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService .find(exclusionEventAction.getErrorUri()); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEventAction.getErrorUri()); ActionedExclusionEventViewWindow actionExclusionEventViewWindow = new ActionedExclusionEventViewWindow( errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService); UI.getCurrent().addWindow(actionExclusionEventViewWindow); } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { actionedExclusionsTable.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<ExclusionEventAction> exclusionEventActions = hospitalManagementService .getActionedExclusions(modulesNames, flowNames, fromDate.getValue(), toDate.getValue()); for (ExclusionEventAction exclusionEventAction : exclusionEventActions) { Date date = new Date(exclusionEventAction.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); actionedExclusionsTable .addItem( new Object[] { exclusionEventAction.getModuleName(), exclusionEventAction.getFlowName(), exclusionEventAction.getAction(), exclusionEventAction.getActionedBy(), timestamp }, exclusionEventAction); } } }); 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(); 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.actionedExclusionsTable); 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.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 ww. j ava2s . 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 w w w . j a va 2 s.co m*/ 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 ava2 s. c om*/ 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// www .j av a2s.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.milleni.dunning.ui.customer.form.CustomProcessInstanceDetailPanel.java
License:Apache License
protected void addProcessImage() { ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) ((RepositoryServiceImpl) repositoryService) .getDeployedProcessDefinition(processDefinition.getId()); // Only show when graphical notation is defined if (processDefinitionEntity != null) { boolean didDrawImage = false; if (ExplorerApp.get().isUseJavascriptDiagram()) { try { final InputStream definitionStream = repositoryService.getResourceAsStream( processDefinition.getDeploymentId(), processDefinition.getResourceName()); XMLInputFactory xif = XMLInputFactory.newInstance(); XMLStreamReader xtr = xif.createXMLStreamReader(definitionStream); BpmnModel bpmnModel = new BpmnXMLConverter().convertToBpmnModel(xtr); if (bpmnModel.getFlowLocationMap().size() > 0) { int maxX = 0; int maxY = 0; for (String key : bpmnModel.getLocationMap().keySet()) { GraphicInfo graphicInfo = bpmnModel.getGraphicInfo(key); double elementX = graphicInfo.getX() + graphicInfo.getWidth(); if (maxX < elementX) { maxX = (int) elementX; }//from w ww .j av a 2 s. c om double elementY = graphicInfo.getY() + graphicInfo.getHeight(); if (maxY < elementY) { maxY = (int) elementY; } } Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); URL explorerURL = ExplorerApp.get().getURL(); URL url = new URL(explorerURL.getProtocol(), explorerURL.getHost(), explorerURL.getPort(), explorerURL.getPath().replace("/ui", "") + "diagram-viewer/index.html?processDefinitionId=" + processDefinition.getId() + "&processInstanceId=" + processInstance.getId()); Embedded browserPanel = new Embedded("", new ExternalResource(url)); browserPanel.setType(Embedded.TYPE_BROWSER); browserPanel.setWidth(maxX + 350 + "px"); browserPanel.setHeight(maxY + 220 + "px"); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(browserPanel); panelLayout.addComponent(imagePanel); didDrawImage = true; } } catch (Exception e) { LOGGER.error("Error loading process diagram component", e); } } if (didDrawImage == false && processDefinitionEntity.isGraphicalNotationDefined()) { StreamResource diagram = new ProcessDefinitionImageStreamResourceBuilder() .buildStreamResource(processInstance, repositoryService, runtimeService); if (diagram != null) { Label header = new Label(i18nManager.getMessage(Messages.PROCESS_HEADER_DIAGRAM)); header.addStyleName(ExplorerLayout.STYLE_H3); header.addStyleName(ExplorerLayout.STYLE_DETAIL_BLOCK); header.addStyleName(ExplorerLayout.STYLE_NO_LINE); panelLayout.addComponent(header); Embedded embedded = new Embedded(null, diagram); embedded.setType(Embedded.TYPE_IMAGE); embedded.setSizeUndefined(); Panel imagePanel = new Panel(); // using panel for scrollbars imagePanel.setScrollable(true); imagePanel.addStyleName(Reindeer.PANEL_LIGHT); imagePanel.setWidth(100, UNITS_PERCENTAGE); imagePanel.setHeight(100, UNITS_PERCENTAGE); HorizontalLayout panelLayoutT = new HorizontalLayout(); panelLayoutT.setSizeUndefined(); imagePanel.setContent(panelLayoutT); imagePanel.addComponent(embedded); panelLayout.addComponent(imagePanel); } } } }
From source file:org.semanticsoft.vaaclipse.presentation.renderers.WorkbenchWindowRenderer.java
License:Open Source License
@Override public void createWidget(MUIElement element, MElementContainer<MUIElement> parent) { if (element instanceof MWindow) { final MWindow mWindow = (MWindow) element; Component currentMainWindow = vaadinUI.getContent(); if (element.getTags().contains(Tags.MAIN_WINDOW)) { Panel window = new Panel(); window.setContent(new TrimmedWindowContent()); vaadinUI.getPage().setTitle(mWindow.getLocalizedLabel()); element.setWidget(window);// www . j av a 2 s.com ((MWindow) element).getContext().set(Panel.class, window); window.setSizeFull(); vaadinUI.setContent(window); app.setSelectedElement(mWindow); mWindow.getContext().activate(); } else {// case child windows if (currentMainWindow != null) { Window window = new Window(); window.setContent(new TrimmedWindowContent()); window.setImmediate(true); window.setPositionX(mWindow.getX()); window.setPositionY(mWindow.getY()); window.setWidth(mWindow.getWidth(), Unit.PIXELS); window.setHeight(mWindow.getHeight(), Unit.PIXELS); window.setCaption(mWindow.getLocalizedLabel()); element.setWidget(window); ((MWindow) element).getContext().set(Panel.class, window); vaadinUI.addWindow(window); } else { throw new IllegalStateException( "Can not add child window because application has not main window"); } } IEclipseContext localContext = getContext(element); localContext.set(ISaveHandler.class, new ISaveHandler() { public Save promptToSave(MPart dirtyPart) { // Object[] elements = // promptForSave(Collections.singleton(dirtyPart)); // if (elements == null) { // return Save.CANCEL; // } // return elements.length == 0 ? Save.NO : Save.YES; if (saveCandidate == null) { saveCandidate = dirtyPart; PartRenderer partRenderer = (PartRenderer) saveCandidate.getRenderer(); SavePromptSetup setup = partRenderer.getSavePromptSetup(saveCandidate); String caption = setup.getCaption() != null ? setup.getCaption() : "Save"; String msg = setup.getMessage() != null ? setup.getMessage() : String.format("%s has been modified. Save changes?", saveCandidate instanceof MInputPart ? ((MInputPart) saveCandidate).getInputURI() : "Data"); OptionDialog.show(vaadinUI, caption, msg, new String[] { "Yes", "No", "Cancel" }, 400, 80, Component.UNITS_PIXELS, new OptionDialog.OptionListener() { @Override public void optionSelected(OptionDialog dlg, int optionId) { switch (optionId) { case 0: s = Save.YES; break; case 1: s = Save.NO; break; case 2: s = Save.CANCEL; break; default: s = null; } if (partService.savePart(saveCandidate, true)) { partService.hidePart(saveCandidate); } saveCandidate = null; dlg.close(); } }); return Save.CANCEL; } else { return s; } } public Save[] promptToSave(Collection<MPart> dirtyParts) { // List<MPart> parts = new ArrayList<MPart>(dirtyParts); // // Save[] response = new Save[dirtyParts.size()]; // Object[] elements = promptForSave(parts); // if (elements == null) { // Arrays.fill(response, Save.CANCEL); // } else { // Arrays.fill(response, Save.NO); // for (int i = 0; i < elements.length; i++) { // response[parts.indexOf(elements[i])] = Save.YES; // } // } // return response; throw new RuntimeException("Multiple saving is not implemented yet"); } }); } }
From source file:pt.ist.vaadinframework.terminal.DefaultSystemErrorWindow.java
License:Open Source License
@Override protected void setErrorContext(Throwable systemError) { removeAllComponents();//from w w w .ja v a 2s . c om setCaption(VaadinResources.getString(ERROR_WINDOW_TITLE)); getContent().setSizeUndefined(); setModal(true); center(); setBorder(Window.BORDER_NONE); setClosable(false); setCloseShortcut(KeyCode.ESCAPE); setResizable(false); ((MarginHandler) getContent()).setMargin(new MarginInfo(true)); ((SpacingHandler) getContent()).setSpacing(true); addComponent(new Label(VaadinResources.getString(ERROR_WINDOW_ANNOUNCEMENT_LABEL))); Panel scroll = new Panel(); addComponent(scroll); scroll.setWidth(450, UNITS_PIXELS); scroll.setHeight(450, UNITS_PIXELS); stacktrace = new Label(); scroll.addComponent(stacktrace); ByteArrayOutputStream stream = null; try { stream = new ByteArrayOutputStream(); systemError.printStackTrace(new PrintStream(stream)); stacktrace.setValue(stream.toString()); } finally { if (stream != null) { try { stream.close(); } catch (IOException e) { } } } }
From source file:ru.codeinside.gses.webui.form.PrintPanel.java
License:Mozilla Public License
PrintPanel(String content, Application app) { try {/*from ww w . j a va2 s. c o m*/ htmlFile = Streams.createTempFile("form-", ".html"); String classId = "doc" + SERIAL.incrementAndGet(); Button print = new Button("", new PrintAction(classId)); print.setStyleName("img-button"); print.setIcon(PRINT_ICON); print.setImmediate(true); buildHtmlFile(content); Panel documentPanel = createDocumentPanel(app, classId); documentPanel.setHeight(500, UNITS_PIXELS); HorizontalLayout buttons = new HorizontalLayout(); buttons.setImmediate(true); buttons.setSpacing(true); buttons.addComponent(print); VerticalLayout printLayout = new VerticalLayout(); printLayout.setSizeFull(); printLayout.addComponent(buttons); printLayout.addComponent(documentPanel); printLayout.setExpandRatio(documentPanel, 1f); setCompositionRoot(printLayout); } catch (IOException e) { e.printStackTrace(); } }