List of usage examples for com.vaadin.ui GridLayout addComponent
public void addComponent(Component component, int column, int row) throws OverlapsException, OutOfBoundsException
From source file:org.ikasan.dashboard.ui.topology.component.ExclusionsTab.java
License:BSD License
public Layout createLayout() { this.exclusionsTable = new Table(); this.exclusionsTable.setSizeFull(); this.exclusionsTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.exclusionsTable.addContainerProperty("Module Name", String.class, null); this.exclusionsTable.addContainerProperty("Flow Name", String.class, null); this.exclusionsTable.addContainerProperty("Timestamp", String.class, null); this.exclusionsTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override//w w w . j a va 2s . c o m public void itemClick(ItemClickEvent itemClickEvent) { ExclusionEvent exclusionEvent = (ExclusionEvent) itemClickEvent.getItemId(); ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService .find(exclusionEvent.getErrorUri()); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri()); ExclusionEventViewWindow exclusionEventViewWindow = new ExclusionEventViewWindow(exclusionEvent, errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService); exclusionEventViewWindow.addCloseListener(new Window.CloseListener() { // inline close-listener public void windowClose(CloseEvent e) { refreshExcludedEventsTable(); } }); UI.getCurrent().addWindow(exclusionEventViewWindow); } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { exclusionsTable.removeAllItems(); ArrayList<String> modulesNames = null; if (exclusionModules.getItemIds().size() > 0) { modulesNames = new ArrayList<String>(); for (Object module : exclusionModules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } ArrayList<String> flowNames = null; if (exclusionFlows.getItemIds().size() > 0) { flowNames = new ArrayList<String>(); for (Object flow : exclusionFlows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } if (modulesNames == null && flowNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new ArrayList<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } List<ExclusionEvent> exclusionEvents = exclusionManagementService.find(modulesNames, flowNames, fromDate.getValue(), toDate.getValue(), null); for (ExclusionEvent exclusionEvent : exclusionEvents) { Date date = new Date(exclusionEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); exclusionsTable.addItem(new Object[] { exclusionEvent.getModuleName(), exclusionEvent.getFlowName(), timestamp }, exclusionEvent); } } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionModules.removeAllItems(); exclusionFlows.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(2, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); exclusionModules.setIcon(VaadinIcons.ARCHIVE); exclusionModules.addContainerProperty("Module Name", String.class, null); exclusionModules.addContainerProperty("", Button.class, null); exclusionModules.setSizeFull(); exclusionModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionModules.setDragMode(TableDragMode.ROW); exclusionModules.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Module) { final Module module = (Module) t.getItemId(); logger.info("sourceContainer.getText(): " + module.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionModules.removeItem(module); } }); exclusionModules.addItem(new Object[] { module.getName(), deleteButton }, module); for (final Flow flow : module.getFlows()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionModules, 0, 0); exclusionFlows.setIcon(VaadinIcons.AUTOMATION); exclusionFlows.addContainerProperty("Flow Name", String.class, null); exclusionFlows.addContainerProperty("", Button.class, null); exclusionFlows.setSizeFull(); exclusionFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionFlows.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); logger.info("sourceContainer.getText(): " + flow.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionFlows, 1, 0); GridLayout dateSelectLayout = new GridLayout(2, 1); dateSelectLayout.setSizeFull(); fromDate = new PopupDateField("From date"); fromDate.setResolution(Resolution.MINUTE); fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(fromDate, 0, 0); toDate = new PopupDateField("To date"); toDate.setResolution(Resolution.MINUTE); toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(toDate, 1, 0); final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); vSplitPanel.setHeight("95%"); GridLayout searchLayout = new GridLayout(2, 1); searchLayout.setSpacing(true); searchLayout.addComponent(searchButton, 0, 0); searchLayout.addComponent(clearButton, 1, 0); final Button hideFilterButton = new Button(); hideFilterButton.setIcon(VaadinIcons.MINUS); hideFilterButton.setCaption("Hide Filter"); hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK); hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); final Button showFilterButton = new Button(); showFilterButton.setIcon(VaadinIcons.PLUS); showFilterButton.setCaption("Show Filter"); showFilterButton.addStyleName(ValoTheme.BUTTON_LINK); showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); showFilterButton.setVisible(false); final HorizontalLayout hListSelectLayout = new HorizontalLayout(); hListSelectLayout.setHeight(150, Unit.PIXELS); hListSelectLayout.setWidth("100%"); hListSelectLayout.addComponent(listSelectLayout); final HorizontalLayout hDateSelectLayout = new HorizontalLayout(); hDateSelectLayout.setHeight(40, Unit.PIXELS); hDateSelectLayout.setWidth("100%"); hDateSelectLayout.addComponent(dateSelectLayout); final HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(30, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(searchLayout); hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = vSplitPanel.getSplitPosition(); splitUnit = vSplitPanel.getSplitPositionUnit(); vSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); vSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); Label filterHintLabel = new Label(); filterHintLabel.setCaptionAsHtml(true); filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag items from the topology tree to the tables below in order to narrow your search."); filterHintLabel.addStyleName(ValoTheme.LABEL_TINY); filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(filterHintLabel); layout.addComponent(hListSelectLayout); layout.addComponent(hDateSelectLayout); layout.addComponent(hSearchLayout); layout.setSizeFull(); Panel filterPanel = new Panel(); filterPanel.setHeight(300, Unit.PIXELS); filterPanel.setWidth("100%"); filterPanel.setContent(layout); filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); vSplitPanel.setFirstComponent(filterPanel); CssLayout hErrorTable = new CssLayout(); hErrorTable.setSizeFull(); hErrorTable.addComponent(this.exclusionsTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(310, Unit.PIXELS); GridLayout wrapper = new GridLayout(1, 2); wrapper.setRowExpandRatio(0, .01f); wrapper.setRowExpandRatio(1, .99f); wrapper.setSizeFull(); wrapper.addComponent(filterButtonLayout); wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT); wrapper.addComponent(vSplitPanel); return wrapper; }
From source file:org.ikasan.dashboard.ui.topology.component.WiretapTab.java
License:BSD License
public Layout createWiretapLayout() { this.wiretapTable = new Table(); this.wiretapTable.setSizeFull(); this.wiretapTable.addStyleName(ValoTheme.TABLE_SMALL); this.wiretapTable.addStyleName("ikasan"); this.wiretapTable.addContainerProperty("Module Name", String.class, null); this.wiretapTable.addContainerProperty("Flow Name", String.class, null); this.wiretapTable.addContainerProperty("Component Name", String.class, null); this.wiretapTable.addContainerProperty("Event Id / Payload Id", String.class, null); this.wiretapTable.addContainerProperty("Timestamp", String.class, null); this.wiretapTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.wiretapTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override// w ww. j a v a 2 s . c o m public void itemClick(ItemClickEvent itemClickEvent) { WiretapEvent<String> wiretapEvent = (WiretapEvent<String>) itemClickEvent.getItemId(); WiretapPayloadViewWindow wiretapPayloadViewWindow = new WiretapPayloadViewWindow(wiretapEvent); UI.getCurrent().addWindow(wiretapPayloadViewWindow); } }); final Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { ProgressBarWindow pbWindow = new ProgressBarWindow(); UI.getCurrent().addWindow(pbWindow); wiretapTable.removeAllItems(); HashSet<String> modulesNames = null; if (modules.getItemIds().size() > 0) { modulesNames = new HashSet<String>(); for (Object module : modules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } HashSet<String> flowNames = null; if (flows.getItemIds().size() > 0) { flowNames = new HashSet<String>(); for (Object flow : flows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } HashSet<String> componentNames = null; if (components.getItemIds().size() > 0) { componentNames = new HashSet<String>(); for (Object component : components.getItemIds()) { componentNames.add("before " + ((Component) component).getName()); componentNames.add("after " + ((Component) component).getName()); } } if (modulesNames == null && flowNames == null && componentNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new HashSet<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } String errorCategory = null; // TODO Need to take a proper look at the wiretap search interface. We do not need to worry about paging search // results with Vaadin. PagedSearchResult<WiretapEvent> events = wiretapDao.findWiretapEvents(0, 10000, "timestamp", false, modulesNames, flowNames, componentNames, eventId.getValue(), null, fromDate.getValue(), toDate.getValue(), payloadContent.getValue()); for (WiretapEvent<String> wiretapEvent : events.getPagedResults()) { Date date = new Date(wiretapEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); wiretapTable .addItem( new Object[] { wiretapEvent.getModuleName(), wiretapEvent.getFlowName(), wiretapEvent.getComponentName(), ((WiretapFlowEvent) wiretapEvent).getEventId(), timestamp }, wiretapEvent); } pbWindow.close(); } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeAllItems(); flows.removeAllItems(); components.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(3, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); modules.setIcon(VaadinIcons.ARCHIVE); modules.addContainerProperty("Module Name", String.class, null); modules.addContainerProperty("", Button.class, null); modules.setSizeFull(); modules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); modules.setDragMode(TableDragMode.ROW); modules.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Module) { final Module module = (Module) t.getItemId(); logger.info("sourceContainer.getText(): " + module.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { modules.removeItem(module); } }); modules.addItem(new Object[] { module.getName(), deleteButton }, module); for (final Flow flow : module.getFlows()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(modules, 0, 0); flows.setIcon(VaadinIcons.AUTOMATION); flows.addContainerProperty("Flow Name", String.class, null); flows.addContainerProperty("", Button.class, null); flows.setSizeFull(); flows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); flows.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); logger.info("sourceContainer.getText(): " + flow.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { flows.removeItem(flow); } }); flows.addItem(new Object[] { flow.getName(), deleteButton }, flow); for (final Component component : flow.getComponents()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(flows, 1, 0); components.setIcon(VaadinIcons.COG); components.setSizeFull(); components.addContainerProperty("Component Name", String.class, null); components.addContainerProperty("", Button.class, null); components.setCellStyleGenerator(new IkasanCellStyleGenerator()); components.setSizeFull(); components.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); components.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Component) { final Component component = (Component) t.getItemId(); logger.info("sourceContainer.getText(): " + component.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { components.removeItem(component); } }); components.addItem(new Object[] { component.getName(), deleteButton }, component); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(this.components, 2, 0); GridLayout dateSelectLayout = new GridLayout(2, 2); dateSelectLayout.setColumnExpandRatio(0, 0.25f); dateSelectLayout.setColumnExpandRatio(1, 0.75f); dateSelectLayout.setSizeFull(); this.fromDate = new PopupDateField("From date"); this.fromDate.setResolution(Resolution.MINUTE); this.fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(this.fromDate, 0, 0); this.toDate = new PopupDateField("To date"); this.toDate.setResolution(Resolution.MINUTE); this.toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(this.toDate, 0, 1); this.eventId = new TextField("Event Id"); this.eventId.setWidth("80%"); this.payloadContent = new TextField("Payload Content"); this.payloadContent.setWidth("80%"); this.eventId.setNullSettingAllowed(true); this.payloadContent.setNullSettingAllowed(true); dateSelectLayout.addComponent(this.eventId, 1, 0); dateSelectLayout.addComponent(this.payloadContent, 1, 1); final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); vSplitPanel.setHeight("95%"); GridLayout searchLayout = new GridLayout(2, 1); searchLayout.setSpacing(true); searchLayout.addComponent(searchButton, 0, 0); searchLayout.addComponent(clearButton, 1, 0); final Button hideFilterButton = new Button(); hideFilterButton.setIcon(VaadinIcons.MINUS); hideFilterButton.setCaption("Hide Filter"); hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK); hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); final Button showFilterButton = new Button(); showFilterButton.setIcon(VaadinIcons.PLUS); showFilterButton.setCaption("Show Filter"); showFilterButton.addStyleName(ValoTheme.BUTTON_LINK); showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); showFilterButton.setVisible(false); final HorizontalLayout hListSelectLayout = new HorizontalLayout(); hListSelectLayout.setHeight(150, Unit.PIXELS); hListSelectLayout.setWidth("100%"); hListSelectLayout.addComponent(listSelectLayout); final HorizontalLayout hDateSelectLayout = new HorizontalLayout(); hDateSelectLayout.setHeight(80, Unit.PIXELS); hDateSelectLayout.setWidth("100%"); hDateSelectLayout.addComponent(dateSelectLayout); final HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(30, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(searchLayout); hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = vSplitPanel.getSplitPosition(); splitUnit = vSplitPanel.getSplitPositionUnit(); vSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); vSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); Label filterHintLabel = new Label(); filterHintLabel.setCaptionAsHtml(true); filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag items from the topology tree to the tables below in order to narrow your search."); filterHintLabel.addStyleName(ValoTheme.LABEL_TINY); filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(filterHintLabel); layout.addComponent(hListSelectLayout); layout.addComponent(hDateSelectLayout); layout.addComponent(hSearchLayout); layout.setSizeFull(); Panel filterPanel = new Panel(); filterPanel.setHeight(340, Unit.PIXELS); filterPanel.setWidth("100%"); filterPanel.setContent(layout); filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); vSplitPanel.setFirstComponent(filterPanel); CssLayout hErrorTable = new CssLayout(); hErrorTable.setSizeFull(); hErrorTable.addComponent(this.wiretapTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(350, Unit.PIXELS); GridLayout wrapper = new GridLayout(1, 2); wrapper.setRowExpandRatio(0, .01f); wrapper.setRowExpandRatio(1, .99f); wrapper.setSizeFull(); wrapper.addComponent(filterButtonLayout); wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT); wrapper.addComponent(vSplitPanel); return wrapper; }
From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java
License:BSD License
protected void createModuleTreePanel() { this.topologyTreePanel = new Panel(); this.topologyTreePanel.addStyleName(ValoTheme.PANEL_BORDERLESS); this.topologyTreePanel.setSizeFull(); this.moduleTree = new Tree(); this.moduleTree.setImmediate(true); this.moduleTree.setSizeFull(); this.moduleTree.addActionHandler(this); this.moduleTree.setDragMode(TreeDragMode.NODE); this.moduleTree.setItemStyleGenerator(new ItemStyleGenerator() { @Override//from w ww . ja v a 2 s . c o m public String getStyle(Tree source, Object itemId) { if (itemId instanceof Flow) { Flow flow = (Flow) itemId; String state = flowStates.get(flow.getModule().getName() + "-" + flow.getName()); logger.info("State = " + state); if (state != null && state.equals(RUNNING)) { return "greenicon"; } else if (state != null && state.equals(RECOVERING)) { return "orangeicon"; } else if (state != null && state.equals(STOPPED)) { return "redicon"; } else if (state != null && state.equals(STOPPED_IN_ERROR)) { return "redicon"; } else if (state != null && state.equals(PAUSED)) { return "indigoicon"; } } return ""; } }); GridLayout layout = new GridLayout(1, 4); Label roleManagementLabel = new Label("Topology"); roleManagementLabel.setStyleName(ValoTheme.LABEL_HUGE); layout.addComponent(roleManagementLabel, 0, 0); layout.setSpacing(true); layout.setWidth("100%"); this.treeViewBusinessStreamCombo = new ComboBox("Business Stream"); this.treeViewBusinessStreamCombo.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (event.getProperty() != null && event.getProperty().getValue() != null) { businessStream = (BusinessStream) event.getProperty().getValue(); logger.info("Value changed to business stream: " + businessStream.getName()); moduleTree.removeAllItems(); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && businessStream.getName().equals("All")) { List<Server> servers = TopologyViewPanel.this.topologyService.getAllServers(); for (Server server : servers) { Set<Module> modules = server.getModules(); TopologyViewPanel.this.moduleTree.addItem(server); TopologyViewPanel.this.moduleTree.setItemCaption(server, server.getName()); TopologyViewPanel.this.moduleTree.setChildrenAllowed(server, true); TopologyViewPanel.this.moduleTree.setItemIcon(server, VaadinIcons.SERVER); for (Module module : modules) { TopologyViewPanel.this.moduleTree.addItem(module); TopologyViewPanel.this.moduleTree.setItemCaption(module, module.getName()); TopologyViewPanel.this.moduleTree.setParent(module, server); TopologyViewPanel.this.moduleTree.setChildrenAllowed(module, true); TopologyViewPanel.this.moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); Set<Flow> flows = module.getFlows(); for (Flow flow : flows) { TopologyViewPanel.this.moduleTree.addItem(flow); TopologyViewPanel.this.moduleTree.setItemCaption(flow, flow.getName()); TopologyViewPanel.this.moduleTree.setParent(flow, module); TopologyViewPanel.this.moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { TopologyViewPanel.this.moduleTree.addItem(component); TopologyViewPanel.this.moduleTree.setParent(component, flow); TopologyViewPanel.this.moduleTree.setItemCaption(component, component.getName()); TopologyViewPanel.this.moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } else if (authentication != null && !authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && businessStream.getName().equals("All")) { List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams(); for (BusinessStream businessStream : businessStreams) { if (authentication.canAccessLinkedItem( PolicyLinkTypeConstants.BUSINESS_STREAM_LINK_TYPE, businessStream.getId())) { for (BusinessStreamFlow bsFlow : businessStream.getFlows()) { Server server = bsFlow.getFlow().getModule().getServer(); Module module = bsFlow.getFlow().getModule(); Flow flow = bsFlow.getFlow(); if (!moduleTree.containsId(server)) { moduleTree.addItem(server); moduleTree.setItemCaption(server, server.getName()); moduleTree.setChildrenAllowed(server, true); moduleTree.setItemIcon(server, VaadinIcons.SERVER); } moduleTree.addItem(module); moduleTree.setItemCaption(module, module.getName()); moduleTree.setParent(module, server); moduleTree.setChildrenAllowed(module, true); moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); moduleTree.addItem(flow); moduleTree.setItemCaption(flow, flow.getName()); moduleTree.setParent(flow, module); moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { moduleTree.addItem(component); moduleTree.setParent(component, flow); moduleTree.setItemCaption(component, component.getName()); moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } else { for (BusinessStreamFlow bsFlow : businessStream.getFlows()) { Server server = bsFlow.getFlow().getModule().getServer(); Module module = bsFlow.getFlow().getModule(); Flow flow = bsFlow.getFlow(); if (!moduleTree.containsId(server)) { moduleTree.addItem(server); moduleTree.setItemCaption(server, server.getName()); moduleTree.setChildrenAllowed(server, true); moduleTree.setItemIcon(server, VaadinIcons.SERVER); } moduleTree.addItem(module); moduleTree.setItemCaption(module, module.getName()); moduleTree.setParent(module, server); moduleTree.setChildrenAllowed(module, true); moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); moduleTree.addItem(flow); moduleTree.setItemCaption(flow, flow.getName()); moduleTree.setParent(flow, module); moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { moduleTree.addItem(component); moduleTree.setParent(component, flow); moduleTree.setItemCaption(component, component.getName()); moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } } }); this.treeViewBusinessStreamCombo.setWidth("250px"); layout.addComponent(this.treeViewBusinessStreamCombo); Button discoverButton = new Button("Discover"); discoverButton.setStyleName(ValoTheme.BUTTON_SMALL); discoverButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); try { topologyService.discover(authentication); } catch (DiscoveryException e) { Notification.show("An error occurred trying to auto discover modules: " + e.getMessage(), Type.ERROR_MESSAGE); } Notification.show("Auto discovery complete!"); } }); Button refreshButton = new Button("Refresh"); refreshButton.setStyleName(ValoTheme.BUTTON_SMALL); refreshButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { refreshTree(); } }); Button newServerButton = new Button("New Server"); newServerButton.setStyleName(ValoTheme.BUTTON_SMALL); newServerButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { UI.getCurrent().addWindow(new NewServerWindow(topologyService)); } }); GridLayout buttonLayout = new GridLayout(3, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(discoverButton); buttonLayout.addComponent(refreshButton); buttonLayout.addComponent(newServerButton); layout.addComponent(buttonLayout); layout.addComponent(this.moduleTree); this.topologyTreePanel.setContent(layout); }
From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java
License:BSD License
protected Layout createSystemEventPanel() { this.systemEventTable = new Table(); this.systemEventTable.setSizeFull(); this.systemEventTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.systemEventTable.addContainerProperty("Subject", String.class, null); this.systemEventTable.setColumnExpandRatio("Subject", .3f); this.systemEventTable.addContainerProperty("Action", String.class, null); this.systemEventTable.setColumnExpandRatio("Action", .4f); this.systemEventTable.addContainerProperty("Actioned By", String.class, null); this.systemEventTable.setColumnExpandRatio("Actioned By", .15f); this.systemEventTable.addContainerProperty("Timestamp", String.class, null); this.systemEventTable.setColumnExpandRatio("Timestamp", .15f); this.systemEventTable.setStyleName("wordwrap-table"); this.systemEventTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/*from w ww . 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) { systemEventTable.removeAllItems(); PagedSearchResult<SystemEvent> systemEvents = systemEventService.listSystemEvents(0, 10000, "timestamp", true, null, null, systemEventFromDate.getValue(), systemEventToDate.getValue(), null); for (SystemEvent systemEvent : systemEvents.getPagedResults()) { SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(systemEvent.getTimestamp()); systemEventTable.addItem(new Object[] { systemEvent.getSubject(), systemEvent.getAction(), systemEvent.getActor(), timestamp }, systemEvent); } } }); GridLayout layout = new GridLayout(1, 2); GridLayout dateSelectLayout = new GridLayout(2, 2); dateSelectLayout.setColumnExpandRatio(0, 0.25f); dateSelectLayout.setSpacing(true); dateSelectLayout.setWidth("50%"); this.systemEventFromDate = new PopupDateField("From date"); this.systemEventFromDate.setResolution(Resolution.MINUTE); this.systemEventFromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(this.systemEventFromDate, 0, 0); this.systemEventToDate = new PopupDateField("To date"); this.systemEventToDate.setResolution(Resolution.MINUTE); this.systemEventToDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(this.systemEventToDate, 1, 0); dateSelectLayout.addComponent(searchButton, 0, 1, 1, 1); HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(75, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(dateSelectLayout); layout.addComponent(hSearchLayout); HorizontalLayout hErrorTable = new HorizontalLayout(); hErrorTable.setWidth("100%"); hErrorTable.setHeight(600, Unit.PIXELS); hErrorTable.addComponent(this.systemEventTable); layout.addComponent(hErrorTable); layout.setSizeFull(); return layout; }
From source file:org.ikasan.dashboard.ui.topology.window.CategorisedErrorOccurrenceViewWindow.java
License:BSD License
public void init() { this.setModal(true); this.setResizable(false); this.setHeight("90%"); this.setWidth("90%"); GridLayout layout = new GridLayout(1, 1); layout.setWidth("100%"); layout.addComponent(createErrorOccurrenceDetailsPanel(), 0, 0); this.setContent(layout); }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
@SuppressWarnings("unchecked") public void populate(Component component) { configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); if (configuration == null) { Server server = component.getFlow().getModule().getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + component.getFlow().getModule().getContextRoot() + "/rest/configuration/createConfiguration/" + component.getFlow().getModule().getName() + "/" + component.getFlow().getName() + "/" + component.getName();/* ww w. j av a 2 s .co m*/ logger.info("Configuration Url: " + url); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(), (String) authentication.getCredentials()); ClientConfig clientConfig = new ClientConfig(); clientConfig.register(feature); Client client = ClientBuilder.newClient(clientConfig); ObjectMapper mapper = new ObjectMapper(); WebTarget webTarget = client.target(url); Response response = webTarget.request().get(); if (response.getStatus() != 200) { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show("An error was received trying to create configured resource '" + component.getConfigurationId() + "': " + responseMessage, Type.ERROR_MESSAGE); } configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); } final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) configuration .getParameters(); this.layout = new GridLayout(2, parameters.size() + 6); this.layout.setSpacing(true); this.layout.setColumnExpandRatio(0, .25f); this.layout.setColumnExpandRatio(1, .75f); this.layout.setWidth("95%"); this.layout.setMargin(true); Label configurationParametersLabel = new Label("Configuration Parameters"); configurationParametersLabel.setStyleName(ValoTheme.LABEL_HUGE); this.layout.addComponent(configurationParametersLabel, 0, 0); GridLayout paramLayout = new GridLayout(2, 2); paramLayout.setSpacing(true); paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label configuredResourceIdLabel = new Label("Configured Resource Id"); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_BOLD); Label configuredResourceIdValueLabel = new Label(configuration.getConfigurationId()); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_LARGE); configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_BOLD); paramLayout.addComponent(configuredResourceIdLabel, 0, 0); paramLayout.setComponentAlignment(configuredResourceIdLabel, Alignment.TOP_RIGHT); paramLayout.addComponent(configuredResourceIdValueLabel, 1, 0); Label configurationDescriptionLabel = new Label("Description:"); configurationDescriptionLabel.setSizeUndefined(); paramLayout.addComponent(configurationDescriptionLabel, 0, 1); paramLayout.setComponentAlignment(configurationDescriptionLabel, Alignment.TOP_RIGHT); TextArea conmfigurationDescriptionTextField = new TextArea(); conmfigurationDescriptionTextField.setRows(4); conmfigurationDescriptionTextField.setWidth("80%"); paramLayout.addComponent(conmfigurationDescriptionTextField, 1, 1); this.layout.addComponent(paramLayout, 0, 1, 1, 1); int i = 2; for (ConfigurationParameter parameter : parameters) { if (parameter instanceof ConfigurationParameterIntegerImpl) { this.layout.addComponent( this.createTextAreaPanel(parameter, new IntegerValidator("Must be a valid number")), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterStringImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new StringValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new BooleanValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterLongImpl) { this.layout.addComponent(this.createTextAreaPanel(parameter, new LongValidator()), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterMapImpl) { this.layout.addComponent(this.createMapPanel((ConfigurationParameterMapImpl) parameter), 0, i, 1, i); } else if (parameter instanceof ConfigurationParameterListImpl) { this.layout.addComponent(this.createListPanel((ConfigurationParameterListImpl) parameter), 0, i, 1, i); } i++; } Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextArea textField : textFields.values()) { textField.validate(); } } catch (InvalidValueException e) { e.printStackTrace(); for (TextArea textField : textFields.values()) { textField.setValidationVisible(true); } Notification.show("There are errors on the form above", Type.ERROR_MESSAGE); return; } for (ConfigurationParameter parameter : parameters) { TextArea textField = ComponentConfigurationWindow.this.textFields.get(parameter.getName()); TextArea descriptionTextField = ComponentConfigurationWindow.this.descriptionTextFields .get(parameter.getName()); if (parameter != null && descriptionTextField != null) { parameter.setDescription(descriptionTextField.getValue()); } if (parameter instanceof ConfigurationParameterIntegerImpl) { logger.info("Setting Integer value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Integer(textField.getValue())); } else if (parameter instanceof ConfigurationParameterStringImpl) { logger.info("Setting String value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(textField.getValue()); } else if (parameter instanceof ConfigurationParameterBooleanImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Boolean(textField.getValue())); } else if (parameter instanceof ConfigurationParameterLongImpl) { logger.info("Setting Boolean value: " + textField.getValue()); if (textField.getValue() != null && textField.getValue().length() > 0) parameter.setValue(new Long(textField.getValue())); } else if (parameter instanceof ConfigurationParameterMapImpl) { ConfigurationParameterMapImpl mapParameter = (ConfigurationParameterMapImpl) parameter; HashMap<String, String> map = new HashMap<String, String>(); logger.info("Saving map: " + mapTextFields.size()); for (String key : mapTextFields.keySet()) { if (key.startsWith(parameter.getName())) { TextFieldKeyValuePair pair = mapTextFields.get(key); logger.info("Saving for key: " + key); if (pair.key.getValue() != "") { map.put(pair.key.getValue(), pair.value.getValue()); } } } parameter.setValue(map); } else if (parameter instanceof ConfigurationParameterListImpl) { ConfigurationParameterListImpl mapParameter = (ConfigurationParameterListImpl) parameter; ArrayList<String> map = new ArrayList<String>(); for (String key : valueTextFields.keySet()) { if (key.startsWith(parameter.getName())) { map.add(valueTextFields.get(key).getValue()); } } parameter.setValue(map); } } ComponentConfigurationWindow.this.configurationManagement.saveConfiguration(configuration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); Button deleteButton = new Button("Delete"); deleteButton.addStyleName(ValoTheme.BUTTON_SMALL); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { DeleteConfigurationAction action = new DeleteConfigurationAction(configuration, configurationManagement, ComponentConfigurationWindow.this); IkasanMessageDialog dialog = new IkasanMessageDialog("Delete configuration", "Are you sure you would like to delete this configuration?", action); UI.getCurrent().addWindow(dialog); } }); GridLayout buttonLayout = new GridLayout(2, 1); buttonLayout.setSpacing(true); buttonLayout.addComponent(saveButton, 0, 0); buttonLayout.addComponent(deleteButton, 1, 0); this.layout.addComponent(buttonLayout, 0, i, 1, i); this.layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER); Panel configurationPanel = new Panel(); configurationPanel.setContent(this.layout); this.setContent(configurationPanel); }
From source file:org.investovator.ui.utils.dashboard.dataplayback.BasicMainView.java
License:Open Source License
public void setupPanel() { //clear everything // content.removeAllComponents(); //add components only if components have not already been added if (content.getComponentCount() == 0) { //Main chart HorizontalLayout chartContainer = new HorizontalLayout(); chartContainer.setWidth(95, Unit.PERCENTAGE); chartContainer.setMargin(true);/* w w w .j ava2s .c o m*/ // chartContainer.setHeight(30,Unit.PERCENTAGE); mainChart = buildMainChart(); chartContainer.addComponent(mainChart); chartContainer.setComponentAlignment(mainChart, Alignment.MIDDLE_CENTER); chartContainer.setCaption(mainChart.getCaption()); // chartContainer.setCaption("Price"); // chartContainer.addStyleName("center-caption"); content.addComponent(chartContainer); content.setExpandRatio(chartContainer, 1.3f); content.setComponentAlignment(chartContainer, Alignment.MIDDLE_CENTER); //Quantity chart HorizontalLayout quantityChartContainer = new HorizontalLayout(); quantityChartContainer.setWidth(95, Unit.PERCENTAGE); // quantityChartContainer.setMargin(true); quantityChartContainer.setMargin(new MarginInfo(true, true, false, true)); // quantityChartContainer.setHeight(30,Unit.PERCENTAGE); quantityChart = buildQuantityChart(); quantityChartContainer.addComponent(quantityChart); quantityChartContainer.setComponentAlignment(quantityChart, Alignment.MIDDLE_CENTER); // quantityChartContainer.setCaption("Quantity"); // quantityChartContainer.addStyleName("center-caption"); content.addComponent(quantityChartContainer); content.setExpandRatio(quantityChartContainer, 1.0f); content.setComponentAlignment(quantityChartContainer, Alignment.MIDDLE_CENTER); //bottom row conatainer HorizontalLayout bottowRow = new HorizontalLayout(); bottowRow.setWidth(100, Unit.PERCENTAGE); content.addComponent(bottowRow); content.setExpandRatio(bottowRow, 1.0f); //Stock price table GridLayout stockPriceTableContainer = new GridLayout(1, 2); //add a caption to the table // Label tableCaption=new Label("Stock Price Table"); // stockPriceTableContainer.addComponent(tableCaption, 0, 0); // stockPriceTableContainer.setComponentAlignment(tableCaption,Alignment.MIDDLE_RIGHT); stockPriceTable = setupStockPriceTable(); stockPriceTableContainer.addComponent(stockPriceTable, 0, 1); stockPriceTableContainer.setMargin(new MarginInfo(false, true, true, true)); stockPriceTableContainer.setCaption("Stock Price Table"); stockPriceTableContainer.addStyleName("center-caption"); stockPriceTableContainer.setComponentAlignment(stockPriceTable, Alignment.MIDDLE_CENTER); bottowRow.addComponent(stockPriceTableContainer); // bottowRow.setExpandRatio(stockPriceTableContainer,1.0f); //buy-sell window GridLayout buySellWindowContainer = new GridLayout(1, 2); // //add a caption to the table // Label buySellWindowCaption=new Label("Buy/Sell Stocks"); // buySellWindowContainer.addComponent(buySellWindowCaption,0,0); // buySellWindowContainer.setComponentAlignment(buySellWindowCaption,Alignment.MIDDLE_CENTER); Component buySellWindow = setupBuySellForm(); buySellWindowContainer.addComponent(buySellWindow, 0, 1); buySellWindowContainer.setMargin(new MarginInfo(false, false, true, false)); buySellWindowContainer.setCaption("Buy/Sell Stocks"); buySellWindowContainer.addStyleName("center-caption"); buySellWindowContainer.setComponentAlignment(buySellWindow, Alignment.MIDDLE_CENTER); bottowRow.addComponent(buySellWindowContainer); // bottowRow.setExpandRatio(buySellWindowContainer,1.0f); //portfolio data // VerticalLayout myPortfolioLayout=new VerticalLayout(); // myPortfolioLayout.setMargin(new MarginInfo(false,true,true,true)); // bottowRow.addComponent(myPortfolioLayout); //add a caption to the table // Label portfolioCaption=new Label("My Portfolio"); // myPortfolioLayout.addComponent(portfolioCaption); // myPortfolioLayout.setComponentAlignment(portfolioCaption,Alignment.MIDDLE_CENTER); HorizontalLayout portfolioContainer = new HorizontalLayout(); portfolioContainer.setMargin(new MarginInfo(false, true, true, true)); portfolioContainer.setCaption("My Portfolio"); portfolioContainer.addStyleName("center-caption"); bottowRow.addComponent(portfolioContainer); // bottowRow.setExpandRatio(portfolioContainer,1.0f); //portfolio table portfolioTable = setupPortfolioTable(); portfolioContainer.addComponent(portfolioTable); // portfolioContainer.setExpandRatio(portfolioTable,1.0f); //profit chart // HorizontalLayout profitContainer = new HorizontalLayout(); // bottowRow.addComponent(profitContainer); profitChart = setupProfitChart(); profitChart.setCaption("Profit Chart"); profitChart.addStyleName("center-caption"); bottowRow.addComponent(profitChart); bottowRow.setExpandRatio(profitChart, 1.3f); // Component accountInfo=setUpAccountInfoForm(); // accountInfo.setCaption("Profit Chart"); // accountInfo.addStyleName("center-caption"); // // bottowRow.addComponent(accountInfo); // bottowRow.setExpandRatio(accountInfo,1.3f); this.setContent(content); } }
From source file:org.lunifera.examples.runtime.web.vaadin.databinding.DatabindingDemoUI.java
License:Open Source License
private void row1(GridLayout layout) { TextField textField1 = new TextField("field1"); textField1.setImmediate(true);/*w w w . j av a 2 s .c o m*/ textField1.setBuffered(false); property1 = new ObjectProperty<Object>(null, Object.class); textField1.setPropertyDataSource(property1); TextField textField2 = new TextField("field2"); textField2.setImmediate(true); textField2.setBuffered(false); property2 = new ObjectProperty<Object>(null, Object.class); textField2.setPropertyDataSource(property2); layout.addComponent(textField1, 0, 0); layout.addComponent(textField2, 1, 0); IVaadinModelObservableValue observable1 = VaadinObservables.observeValue(textField1); IVaadinModelObservableValue observable2 = VaadinObservables.observeValue(textField2); dbc.bindValue(observable2, observable1); }
From source file:org.lunifera.examples.runtime.web.vaadin.databinding.DatabindingDemoUI.java
License:Open Source License
private void row2(GridLayout layout) { CheckBox readonly = new CheckBox("readonly"); readonly.setImmediate(true);/* w w w . j a v a 2 s . com*/ readonly.setBuffered(false); TextField textField = new TextField("field2"); textField.setImmediate(true); textField.setBuffered(false); layout.addComponent(readonly, 0, 1); layout.addComponent(textField, 1, 1); dbc.bindValue(VaadinObservables.observeReadonly(textField), VaadinObservables.observeValue(readonly)); }
From source file:org.lunifera.examples.runtime.web.vaadin.databinding.DatabindingDemoUI.java
License:Open Source License
private void row3(GridLayout layout) { CheckBox required = new CheckBox("required"); required.setImmediate(true);/* w w w. ja v a 2 s. c o m*/ required.setBuffered(false); TextField requiredError = new TextField("requiredError"); requiredError.setImmediate(true); requiredError.setBuffered(false); TextField input = new TextField("input"); input.setImmediate(true); input.setBuffered(false); input.setValidationVisible(true); layout.addComponent(required, 0, 2); layout.addComponent(requiredError, 1, 2); layout.addComponent(input, 2, 2); IVaadinModelObservableValue value_requiredObservable = VaadinObservables.observeValue(required); IVaadinModelObservableValue value_errorString = VaadinObservables.observeValue(requiredError); IVaadinModelObservableValue readonly_errorString = VaadinObservables.observeReadonly(requiredError); IVaadinComponentObservableValue required_Input = VaadinObservables.observeRequired(input); IVaadinComponentObservableValue errorMessage_Input = VaadinObservables.observeRequiredError(input); dbc.bindValue(value_requiredObservable, required_Input); dbc.bindValue(value_requiredObservable, readonly_errorString); dbc.bindValue(value_errorString, errorMessage_Input); }