List of usage examples for com.vaadin.ui VerticalSplitPanel setSplitPosition
public void setSplitPosition(float pos, boolean reverse)
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 ava2 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/*from w w w . j av a 2 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/*w w w . java 2 s . c om*/ public void itemClick(ItemClickEvent itemClickEvent) { WiretapEvent<String> wiretapEvent = (WiretapEvent<String>) itemClickEvent.getItemId(); WiretapPayloadViewWindow wiretapPayloadViewWindow = new WiretapPayloadViewWindow(wiretapEvent); UI.getCurrent().addWindow(wiretapPayloadViewWindow); } }); final Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { ProgressBarWindow pbWindow = new ProgressBarWindow(); UI.getCurrent().addWindow(pbWindow); wiretapTable.removeAllItems(); HashSet<String> modulesNames = null; if (modules.getItemIds().size() > 0) { modulesNames = new HashSet<String>(); for (Object module : modules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } HashSet<String> flowNames = null; if (flows.getItemIds().size() > 0) { flowNames = new HashSet<String>(); for (Object flow : flows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } HashSet<String> componentNames = null; if (components.getItemIds().size() > 0) { componentNames = new HashSet<String>(); for (Object component : components.getItemIds()) { componentNames.add("before " + ((Component) component).getName()); componentNames.add("after " + ((Component) component).getName()); } } if (modulesNames == null && flowNames == null && componentNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new HashSet<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } String errorCategory = null; // TODO Need to take a proper look at the wiretap search interface. We do not need to worry about paging search // results with Vaadin. PagedSearchResult<WiretapEvent> events = wiretapDao.findWiretapEvents(0, 10000, "timestamp", false, modulesNames, flowNames, componentNames, eventId.getValue(), null, fromDate.getValue(), toDate.getValue(), payloadContent.getValue()); for (WiretapEvent<String> wiretapEvent : events.getPagedResults()) { Date date = new Date(wiretapEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); wiretapTable .addItem( new Object[] { wiretapEvent.getModuleName(), wiretapEvent.getFlowName(), wiretapEvent.getComponentName(), ((WiretapFlowEvent) wiretapEvent).getEventId(), timestamp }, wiretapEvent); } pbWindow.close(); } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeAllItems(); flows.removeAllItems(); components.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(3, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); modules.setIcon(VaadinIcons.ARCHIVE); modules.addContainerProperty("Module Name", String.class, null); modules.addContainerProperty("", Button.class, null); modules.setSizeFull(); modules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); modules.setDragMode(TableDragMode.ROW); modules.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Module) { final Module module = (Module) t.getItemId(); logger.info("sourceContainer.getText(): " + module.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeItem(module); } }); modules.addItem(new Object[] { module.getName(), deleteButton }, module); for (final Flow flow : module.getFlows()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(modules, 0, 0); flows.setIcon(VaadinIcons.AUTOMATION); flows.addContainerProperty("Flow Name", String.class, null); flows.addContainerProperty("", Button.class, null); flows.setSizeFull(); flows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); flows.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); logger.info("sourceContainer.getText(): " + flow.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(flows, 1, 0); components.setIcon(VaadinIcons.COG); components.setSizeFull(); components.addContainerProperty("Component Name", String.class, null); components.addContainerProperty("", Button.class, null); components.setCellStyleGenerator(new IkasanCellStyleGenerator()); components.setSizeFull(); components.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); components.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Component) { final Component component = (Component) t.getItemId(); logger.info("sourceContainer.getText(): " + component.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(this.components, 2, 0); GridLayout dateSelectLayout = new GridLayout(2, 2); dateSelectLayout.setColumnExpandRatio(0, 0.25f); dateSelectLayout.setColumnExpandRatio(1, 0.75f); dateSelectLayout.setSizeFull(); this.fromDate = new PopupDateField("From date"); this.fromDate.setResolution(Resolution.MINUTE); this.fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(this.fromDate, 0, 0); this.toDate = new PopupDateField("To date"); this.toDate.setResolution(Resolution.MINUTE); this.toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(this.toDate, 0, 1); this.eventId = new TextField("Event Id"); this.eventId.setWidth("80%"); this.payloadContent = new TextField("Payload Content"); this.payloadContent.setWidth("80%"); this.eventId.setNullSettingAllowed(true); this.payloadContent.setNullSettingAllowed(true); dateSelectLayout.addComponent(this.eventId, 1, 0); dateSelectLayout.addComponent(this.payloadContent, 1, 1); final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); vSplitPanel.setHeight("95%"); GridLayout searchLayout = new GridLayout(2, 1); searchLayout.setSpacing(true); searchLayout.addComponent(searchButton, 0, 0); searchLayout.addComponent(clearButton, 1, 0); final Button hideFilterButton = new Button(); hideFilterButton.setIcon(VaadinIcons.MINUS); hideFilterButton.setCaption("Hide Filter"); hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK); hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); final Button showFilterButton = new Button(); showFilterButton.setIcon(VaadinIcons.PLUS); showFilterButton.setCaption("Show Filter"); showFilterButton.addStyleName(ValoTheme.BUTTON_LINK); showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); showFilterButton.setVisible(false); final HorizontalLayout hListSelectLayout = new HorizontalLayout(); hListSelectLayout.setHeight(150, Unit.PIXELS); hListSelectLayout.setWidth("100%"); hListSelectLayout.addComponent(listSelectLayout); final HorizontalLayout hDateSelectLayout = new HorizontalLayout(); hDateSelectLayout.setHeight(80, Unit.PIXELS); hDateSelectLayout.setWidth("100%"); hDateSelectLayout.addComponent(dateSelectLayout); final HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(30, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(searchLayout); hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = vSplitPanel.getSplitPosition(); splitUnit = vSplitPanel.getSplitPositionUnit(); vSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); vSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); Label filterHintLabel = new Label(); filterHintLabel.setCaptionAsHtml(true); filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag items from the topology tree to the tables below in order to narrow your search."); filterHintLabel.addStyleName(ValoTheme.LABEL_TINY); filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(filterHintLabel); layout.addComponent(hListSelectLayout); layout.addComponent(hDateSelectLayout); layout.addComponent(hSearchLayout); layout.setSizeFull(); Panel filterPanel = new Panel(); filterPanel.setHeight(340, Unit.PIXELS); filterPanel.setWidth("100%"); filterPanel.setContent(layout); filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); vSplitPanel.setFirstComponent(filterPanel); CssLayout hErrorTable = new CssLayout(); hErrorTable.setSizeFull(); hErrorTable.addComponent(this.wiretapTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(350, Unit.PIXELS); GridLayout wrapper = new GridLayout(1, 2); wrapper.setRowExpandRatio(0, .01f); wrapper.setRowExpandRatio(1, .99f); wrapper.setSizeFull(); wrapper.addComponent(filterButtonLayout); wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT); wrapper.addComponent(vSplitPanel); return wrapper; }
From source file:org.jumpmind.metl.ui.views.design.EditFlowPanel.java
License:Open Source License
public EditFlowPanel(ApplicationContext context, String flowId, DesignNavigator designNavigator, TabbedPanel tabs) {/*from www.jav a 2s. co m*/ this.configurationService = context.getConfigurationService(); this.flow = configurationService.findFlow(flowId); this.readOnly = context.isReadOnly(configurationService.findProjectVersion(flow.getProjectVersionId()), Privilege.DESIGN); this.context = context; this.tabs = tabs; this.designNavigator = designNavigator; this.propertySheet = new PropertySheet(context, tabs, readOnly); this.propertySheet.setListener((components) -> { List<FlowStep> steps = new ArrayList<FlowStep>(); for (Component c : components) { steps.add(EditFlowPanel.this.flow.findFlowStepWithComponentId(c.getId())); } refreshStepOnDiagram(steps); }); this.propertySheet.setCaption("Property Sheet"); this.componentPalette = new EditFlowPalette(this, context, flow.getProjectVersionId()); addComponent(componentPalette); VerticalLayout rightLayout = new VerticalLayout(); rightLayout.setSizeFull(); rightLayout.addComponent(buildButtonBar()); VerticalSplitPanel splitPanel = new VerticalSplitPanel(); splitPanel.setSizeFull(); splitPanel.setSplitPosition(50, Unit.PERCENTAGE); diagramLayout = new VerticalLayout(); diagramLayout.setWidth(10000, Unit.PIXELS); diagramLayout.setHeight(10000, Unit.PIXELS); DragAndDropWrapper wrapper = new DragAndDropWrapper(diagramLayout); wrapper.setSizeUndefined(); wrapper.setDropHandler(new DropHandler()); flowPanel = new Panel(); flowPanel.setSizeFull(); flowPanel.addStyleName(ValoTheme.PANEL_WELL); flowPanel.setContent(wrapper); splitPanel.addComponent(flowPanel); splitPanel.addComponent(propertySheet); rightLayout.addComponent(splitPanel); rightLayout.setExpandRatio(splitPanel, 1); addComponent(rightLayout); setExpandRatio(rightLayout, 1); if (flow.getFlowSteps().size() > 0) { selected = new ArrayList<AbstractObject>(); selected.add(flow.getFlowSteps().get(0)); propertySheet.setSource(selected); } redrawFlow(); }
From source file:org.opennms.features.topology.app.internal.TopologyUI.java
License:Open Source License
/** * Updates the bottom widget area with the registered widgets * //w w w. j a va 2s. com * Any widget with the service property of 'location=bottom' are * included. * * @param widgetManager The WidgetManager. */ private void updateWidgetView(WidgetManager widgetManager) { synchronized (m_layout) { m_layout.removeAllComponents(); if (widgetManager.widgetCount() == 0) { m_layout.addComponent(m_treeMapSplitPanel); } else { VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel(); bottomLayoutBar.setFirstComponent(m_treeMapSplitPanel); // Split the screen 70% top, 30% bottom bottomLayoutBar.setSplitPosition(70, Unit.PERCENTAGE); bottomLayoutBar.setSizeFull(); bottomLayoutBar.setSecondComponent(getTabSheet(widgetManager, this)); m_layout.addComponent(bottomLayoutBar); updateTabVisibility(); } m_layout.markAsDirty(); } m_layout.markAsDirty(); }
From source file:org.opennms.features.topology.app.internal.TopologyWidgetTestApplication.java
License:Open Source License
/** * Updates the bottom widget area with the registered widgets * //from w ww .j av a2 s . c om * Any widget with the service property of 'location=bottom' are * included. * * @param widgetManager */ private void updateWidgetView(WidgetManager widgetManager) { synchronized (m_layout) { m_layout.removeAllComponents(); if (widgetManager.widgetCount() == 0) { m_layout.addComponent(m_treeMapSplitPanel, getBelowMenuPosition()); } else { VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel(); bottomLayoutBar.setFirstComponent(m_treeMapSplitPanel); // Split the screen 70% top, 30% bottom bottomLayoutBar.setSplitPosition(70, Sizeable.UNITS_PERCENTAGE); bottomLayoutBar.setSizeFull(); bottomLayoutBar.setSecondComponent(getTabSheet(widgetManager, this)); m_layout.addComponent(bottomLayoutBar, getBelowMenuPosition()); } m_layout.requestRepaint(); } if (m_contextMenu != null && m_contextMenu.getParent() == null) { getMainWindow().addComponent(m_contextMenu); } }
From source file:org.opennms.features.vaadin.app.TopologyWidgetTestApplication.java
License:Open Source License
@Override public void init() { //This timer is a hack at the moment to disable and enable menuItems m_timer.scheduleAtFixedRate(new TimerTask() { @Override/*from w w w. ja va2 s. c o m*/ public void run() { List<MenuItem> items = m_menuBar.getItems(); for (MenuItem item : items) { if (item.getText().equals("Device")) { List<MenuItem> children = item.getChildren(); for (MenuItem child : children) { if (m_graphContainer.getSelectedVertexIds().size() > 0) { if (!child.isEnabled()) { child.setEnabled(true); } } else { if (child.isEnabled()) { child.setEnabled(false); } } } } } } }, 1000, 1000); m_commandManager.addCommand(new Command("Redo Layout") { ; @Override public void doCommand(Object target) { m_graphContainer.redoLayout(); } @Override public boolean appliesToTarget(Object target) { //Applies to background as a whole return target == null; } }, true); m_commandManager.addCommand(new Command("Open") { @Override public void doCommand(Object target) { m_graphContainer.load("graph.xml"); } }, false, "File"); m_commandManager.addCommand(new Command("Save") { @Override public void doCommand(Object target) { m_graphContainer.save("graph.xml"); } }, false, "File"); m_commandManager.addCommand(new Command("Add Vertex") { @Override public boolean appliesToTarget(Object itemId) { return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId); } @Override public void doCommand(Object vertexId) { if (vertexId == null) { addRandomVertex(); } else { connectNewVertexTo(vertexId.toString(), SERVER_ICON); } m_graphContainer.redoLayout(); } }, true, "File"); m_commandManager.addCommand(new Command("Lock") { @Override public boolean appliesToTarget(Object itemId) { if (m_graphContainer.getVertexContainer().containsId(itemId)) { Item v = m_graphContainer.getVertexContainer().getItem(itemId); return !(Boolean) v.getItemProperty("locked").getValue(); } return false; } @Override public void doCommand(Object vertexId) { Item v = m_graphContainer.getVertexContainer().getItem(vertexId); v.getItemProperty("locked").setValue(true); } }, true); m_commandManager.addCommand(new Command("Unlock") { @Override public boolean appliesToTarget(Object itemId) { if (m_graphContainer.getVertexContainer().containsId(itemId)) { Item v = m_graphContainer.getVertexContainer().getItem(itemId); return (Boolean) v.getItemProperty("locked").getValue(); } return false; } @Override public void doCommand(Object vertexId) { Item v = m_graphContainer.getVertexContainer().getItem(vertexId); v.getItemProperty("locked").setValue(false); } }, true); m_commandManager.addCommand(new Command("Add Switch Vertex") { @Override public boolean appliesToTarget(Object itemId) { return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId); } @Override public void doCommand(Object vertexId) { if (vertexId == null) { addRandomVertex(); } else { connectNewVertexTo(vertexId.toString(), SWITCH_ICON); } m_graphContainer.redoLayout(); } }, true); m_commandManager.addCommand(new Command("Remove Vertex") { @Override public boolean appliesToTarget(Object itemId) { return itemId == null || m_graphContainer.getVertexContainer().containsId(itemId); } @Override public void doCommand(Object vertexId) { if (vertexId == null) { System.err.println("need to handle selection!!!"); } else { m_graphContainer.removeVertex(vertexId.toString()); m_graphContainer.redoLayout(); } } }, true, "File"); m_commandManager.addCommand(new Command("Connect") { @Override public boolean appliesToTarget(Object itemId) { return m_graphContainer.getSelectedVertexIds().size() == 2; } @Override public void doCommand(Object unused) { List<Object> endPoints = new ArrayList<Object>(m_graphContainer.getSelectedVertexIds()); m_graphContainer.connectVertices(m_graphContainer.getNextEdgeId(), (String) endPoints.get(0), (String) endPoints.get(1)); } }, true, "File"); m_commandManager.addCommand(new Command("Create Group") { @Override public boolean appliesToTarget(Object itemId) { return m_graphContainer.getSelectedVertexIds().size() > 0; } @Override public void doCommand(Object vertexId) { String groupId = m_graphContainer.getNextGroupId(); m_graphContainer.addGroup(groupId, GROUP_ICON); m_graphContainer.getVertexContainer().setParent(groupId, ROOT_GROUP_ID); for (Object itemId : m_graphContainer.getSelectedVertexIds()) { m_graphContainer.getVertexContainer().setParent(itemId, groupId); } } }, true, "Edit"); m_commandManager.addCommand(new Command("Manual Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new ManualLayoutAlgorithm()); } }, false, "Edit|Layout"); m_commandManager.addCommand(new Command("Balloon Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new BalloonLayoutAlgorithm(CENTER_VERTEX_ID)); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("Circle Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new CircleLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("DAG Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new DAGLayoutAlgorithm(CENTER_VERTEX_ID)); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("Radial Tree Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new RadialTreeLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("Tree Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new TreeLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("Simple Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new SimpleLayoutAlgorithm()); } }, false, "Edit|Layout"); m_commandManager.addCommand(new Command("Spring Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new SpringLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("KK Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new KKLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("ISOM Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new ISOMLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("FR Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new FRLayoutAlgorithm()); } }, false, "Edit|Layout|JUNG"); m_commandManager.addCommand(new Command("Other Layout") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { m_graphContainer.setLayoutAlgorithm(new AlternativeLayoutAlgorithm()); } }, false, "Edit|Layout"); m_commandManager.addCommand(new Command("Reset") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { resetView(); } }, false, null); m_commandManager.addCommand(new Command("History") { @Override public boolean appliesToTarget(Object target) { return true; } @Override public void doCommand(Object target) { showHistoryList(m_commandManager.getHistoryList()); } }, false, null); m_commandManager.addCommand(new Command("Show Map") { @Override public void doCommand(Object target) { getMainWindow().showNotification("This has not been implemented yet"); } }, false, "View"); m_commandManager.addCommand(new Command("Get Info") { @Override public boolean appliesToTarget(Object itemId) { return itemId == null || m_graphContainer.getEdgeContainer().containsId(itemId); } @Override public void doCommand(Object target) { getMainWindow().showNotification("This has not been implemented yet"); } }, true, "Device"); AbsoluteLayout layout = new AbsoluteLayout(); layout.setSizeFull(); m_window = new Window("Topology Widget Test"); m_window.setContent(layout); setMainWindow(m_window); m_graphContainer.addGroup(ROOT_GROUP_ID, GROUP_ICON); m_graphContainer.addVertex(CENTER_VERTEX_ID, 50, 50, SERVER_ICON); m_graphContainer.getVertexContainer().setParent(CENTER_VERTEX_ID, ROOT_GROUP_ID); m_graphContainer.setLayoutAlgorithm(new KKLayoutAlgorithm()); m_topologyComponent = new TopologyComponent(m_graphContainer); m_commandManager.addActionHandlers(m_topologyComponent); m_topologyComponent.setSizeFull(); final Property scale = m_graphContainer.getProperty("scale"); final Slider slider = new Slider(1, 4); slider.setResolution(2); slider.setHeight("300px"); slider.setOrientation(Slider.ORIENTATION_VERTICAL); slider.addListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { scale.setValue((Double) slider.getValue()); } }); slider.setImmediate(true); m_tree = createTree(); Label semanticZoomLabel = new Label(); final Property zoomLevel = m_graphContainer.getProperty("semanticZoomLevel"); semanticZoomLabel.setPropertyDataSource(zoomLevel); Button zoomInBtn = new Button("Zoom In"); zoomInBtn.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { int szl = (Integer) zoomLevel.getValue(); szl++; zoomLevel.setValue(szl); m_graphContainer.redoLayout(); } }); Button zoomOutBtn = new Button("Zoom Out"); zoomOutBtn.addListener(new ClickListener() { public void buttonClick(ClickEvent event) { int szl = (Integer) zoomLevel.getValue(); szl--; zoomLevel.setValue(szl); m_graphContainer.redoLayout(); } }); VerticalLayout vLayout = new VerticalLayout(); vLayout.setWidth("100%"); vLayout.setHeight("100%"); vLayout.addComponent(m_tree); AbsoluteLayout mapLayout = new AbsoluteLayout(); mapLayout.addComponent(m_topologyComponent, "top:0px; left: 0px; right: 0px; bottom: 0px;"); mapLayout.addComponent(slider, "top: 20px; left: 20px; z-index:1000;"); mapLayout.addComponent(semanticZoomLabel, "bottom: 10px; right: 10px; z-index: 2000;"); mapLayout.setSizeFull(); HorizontalSplitPanel treeMapSplitPanel = new HorizontalSplitPanel(); treeMapSplitPanel.setFirstComponent(vLayout); treeMapSplitPanel.setSecondComponent(mapLayout); treeMapSplitPanel.setSplitPosition(100, Sizeable.UNITS_PIXELS); treeMapSplitPanel.setSizeFull(); VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel(); bottomLayoutBar.setFirstComponent(treeMapSplitPanel); VerticalLayout zoomLayout = new VerticalLayout(); zoomLayout.addComponent(zoomInBtn); zoomLayout.addComponent(zoomOutBtn); bottomLayoutBar.setSecondComponent(zoomLayout); bottomLayoutBar.setSplitPosition(80, Sizeable.UNITS_PERCENTAGE); bottomLayoutBar.setSizeFull(); m_menuBar = m_commandManager.getMenuBar(); m_menuBar.setWidth("100%"); layout.addComponent(m_menuBar, "top: 0px; left: 0px; right:0px;"); layout.addComponent(bottomLayoutBar, "top: 23px; left: 0px; right:0px; bottom:0px;"); }
From source file:org.opennms.features.vaadin.nodemaps.internal.NodeMapsApplication.java
License:Open Source License
private void updateWidgetView() { final VerticalSplitPanel bottomLayoutBar = new VerticalSplitPanel(); bottomLayoutBar.setFirstComponent(m_mapWidgetComponent); // Split the screen 70% top, 30% bottom bottomLayoutBar.setSplitPosition(70, Unit.PERCENTAGE); bottomLayoutBar.setSizeFull();//from w ww . j av a 2 s . co m bottomLayoutBar.setSecondComponent(getTabSheet()); m_layout.addComponent(bottomLayoutBar); m_layout.markAsDirty(); }
From source file:pt.yellowduck.ramboia.RamboiaApplication.java
License:Open Source License
private void buildMainLayout() { VerticalSplitPanel vSplit = new VerticalSplitPanel(); vSplit.setSplitPosition(15, Sizeable.UNITS_PERCENTAGE); vSplit.setSizeFull();//from w w w . j a v a 2 s.co m HorizontalSplitPanel hSplit_top = new HorizontalSplitPanel(); hSplit_top.setSizeFull(); hSplit_top.setSplitPosition(50, Sizeable.UNITS_PERCENTAGE); hSplit_top.setFirstComponent(viewPlayer); hSplit_top.setSecondComponent(viewUpload); hSplit_top.setLocked(true); vSplit.setFirstComponent(hSplit_top); HorizontalSplitPanel hSplit_bottom = new HorizontalSplitPanel(); hSplit_bottom.setSizeFull(); hSplit_bottom.setSplitPosition(75, Sizeable.UNITS_PERCENTAGE); hSplit_bottom.setFirstComponent(viewLibrary); hSplit_bottom.setSecondComponent(viewPlaylist); hSplit_bottom.setLocked(true); vSplit.setSecondComponent(hSplit_bottom); mainWindow.setContent(vSplit); }