List of usage examples for com.vaadin.ui Button setCaption
@Override public void setCaption(String caption)
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 ww w . j a v a 2 s.c o m*/ public void itemClick(ItemClickEvent itemClickEvent) { ExclusionEvent exclusionEvent = (ExclusionEvent) itemClickEvent.getItemId(); ErrorOccurrence errorOccurrence = (ErrorOccurrence) errorReportingService .find(exclusionEvent.getErrorUri()); ExclusionEventAction action = hospitalManagementService .getExclusionEventActionByErrorUri(exclusionEvent.getErrorUri()); ExclusionEventViewWindow exclusionEventViewWindow = new ExclusionEventViewWindow(exclusionEvent, errorOccurrence, serialiserFactory, action, hospitalManagementService, topologyService); exclusionEventViewWindow.addCloseListener(new Window.CloseListener() { // inline close-listener public void windowClose(CloseEvent e) { refreshExcludedEventsTable(); } }); UI.getCurrent().addWindow(exclusionEventViewWindow); } }); Button searchButton = new Button("Search"); searchButton.setStyleName(ValoTheme.BUTTON_SMALL); searchButton.addClickListener(new Button.ClickListener() { @SuppressWarnings("unchecked") public void buttonClick(ClickEvent event) { exclusionsTable.removeAllItems(); ArrayList<String> modulesNames = null; if (exclusionModules.getItemIds().size() > 0) { modulesNames = new ArrayList<String>(); for (Object module : exclusionModules.getItemIds()) { modulesNames.add(((Module) module).getName()); } } ArrayList<String> flowNames = null; if (exclusionFlows.getItemIds().size() > 0) { flowNames = new ArrayList<String>(); for (Object flow : exclusionFlows.getItemIds()) { flowNames.add(((Flow) flow).getName()); } } if (modulesNames == null && flowNames == null && !((BusinessStream) businessStreamCombo.getValue()).getName().equals("All")) { BusinessStream businessStream = ((BusinessStream) businessStreamCombo.getValue()); modulesNames = new ArrayList<String>(); for (BusinessStreamFlow flow : businessStream.getFlows()) { modulesNames.add(flow.getFlow().getModule().getName()); } } List<ExclusionEvent> exclusionEvents = exclusionManagementService.find(modulesNames, flowNames, fromDate.getValue(), toDate.getValue(), null); for (ExclusionEvent exclusionEvent : exclusionEvents) { Date date = new Date(exclusionEvent.getTimestamp()); SimpleDateFormat format = new SimpleDateFormat("yyyy MM dd HH:mm:ss"); String timestamp = format.format(date); exclusionsTable.addItem(new Object[] { exclusionEvent.getModuleName(), exclusionEvent.getFlowName(), timestamp }, exclusionEvent); } } }); Button clearButton = new Button("Clear"); clearButton.setStyleName(ValoTheme.BUTTON_SMALL); clearButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionModules.removeAllItems(); exclusionFlows.removeAllItems(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(false); layout.setHeight(270, Unit.PIXELS); GridLayout listSelectLayout = new GridLayout(2, 1); listSelectLayout.setSpacing(true); listSelectLayout.setSizeFull(); exclusionModules.setIcon(VaadinIcons.ARCHIVE); exclusionModules.addContainerProperty("Module Name", String.class, null); exclusionModules.addContainerProperty("", Button.class, null); exclusionModules.setSizeFull(); exclusionModules.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionModules.setDragMode(TableDragMode.ROW); exclusionModules.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Module) { final Module module = (Module) t.getItemId(); logger.info("sourceContainer.getText(): " + module.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionModules.removeItem(module); } }); exclusionModules.addItem(new Object[] { module.getName(), deleteButton }, module); for (final Flow flow : module.getFlows()) { deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionModules, 0, 0); exclusionFlows.setIcon(VaadinIcons.AUTOMATION); exclusionFlows.addContainerProperty("Flow Name", String.class, null); exclusionFlows.addContainerProperty("", Button.class, null); exclusionFlows.setSizeFull(); exclusionFlows.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); exclusionFlows.setDropHandler(new DropHandler() { @Override public void drop(final DragAndDropEvent dropEvent) { // criteria verify that this is safe logger.info("Trying to drop: " + dropEvent); final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); logger.info("sourceContainer.getText(): " + flow.getName()); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { exclusionFlows.removeItem(flow); } }); exclusionFlows.addItem(new Object[] { flow.getName(), deleteButton }, flow); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); listSelectLayout.addComponent(exclusionFlows, 1, 0); GridLayout dateSelectLayout = new GridLayout(2, 1); dateSelectLayout.setSizeFull(); fromDate = new PopupDateField("From date"); fromDate.setResolution(Resolution.MINUTE); fromDate.setValue(this.getMidnightToday()); dateSelectLayout.addComponent(fromDate, 0, 0); toDate = new PopupDateField("To date"); toDate.setResolution(Resolution.MINUTE); toDate.setValue(this.getTwentyThreeFixtyNineToday()); dateSelectLayout.addComponent(toDate, 1, 0); final VerticalSplitPanel vSplitPanel = new VerticalSplitPanel(); vSplitPanel.setHeight("95%"); GridLayout searchLayout = new GridLayout(2, 1); searchLayout.setSpacing(true); searchLayout.addComponent(searchButton, 0, 0); searchLayout.addComponent(clearButton, 1, 0); final Button hideFilterButton = new Button(); hideFilterButton.setIcon(VaadinIcons.MINUS); hideFilterButton.setCaption("Hide Filter"); hideFilterButton.setStyleName(ValoTheme.BUTTON_LINK); hideFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); final Button showFilterButton = new Button(); showFilterButton.setIcon(VaadinIcons.PLUS); showFilterButton.setCaption("Show Filter"); showFilterButton.addStyleName(ValoTheme.BUTTON_LINK); showFilterButton.addStyleName(ValoTheme.BUTTON_SMALL); showFilterButton.setVisible(false); final HorizontalLayout hListSelectLayout = new HorizontalLayout(); hListSelectLayout.setHeight(150, Unit.PIXELS); hListSelectLayout.setWidth("100%"); hListSelectLayout.addComponent(listSelectLayout); final HorizontalLayout hDateSelectLayout = new HorizontalLayout(); hDateSelectLayout.setHeight(40, Unit.PIXELS); hDateSelectLayout.setWidth("100%"); hDateSelectLayout.addComponent(dateSelectLayout); final HorizontalLayout hSearchLayout = new HorizontalLayout(); hSearchLayout.setHeight(30, Unit.PIXELS); hSearchLayout.setWidth("100%"); hSearchLayout.addComponent(searchLayout); hSearchLayout.setComponentAlignment(searchLayout, Alignment.MIDDLE_CENTER); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = vSplitPanel.getSplitPosition(); splitUnit = vSplitPanel.getSplitPositionUnit(); vSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); vSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); Label filterHintLabel = new Label(); filterHintLabel.setCaptionAsHtml(true); filterHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag items from the topology tree to the tables below in order to narrow your search."); filterHintLabel.addStyleName(ValoTheme.LABEL_TINY); filterHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(filterHintLabel); layout.addComponent(hListSelectLayout); layout.addComponent(hDateSelectLayout); layout.addComponent(hSearchLayout); layout.setSizeFull(); Panel filterPanel = new Panel(); filterPanel.setHeight(300, Unit.PIXELS); filterPanel.setWidth("100%"); filterPanel.setContent(layout); filterPanel.addStyleName(ValoTheme.PANEL_BORDERLESS); vSplitPanel.setFirstComponent(filterPanel); CssLayout hErrorTable = new CssLayout(); hErrorTable.setSizeFull(); hErrorTable.addComponent(this.exclusionsTable); vSplitPanel.setSecondComponent(hErrorTable); vSplitPanel.setSplitPosition(310, Unit.PIXELS); GridLayout wrapper = new GridLayout(1, 2); wrapper.setRowExpandRatio(0, .01f); wrapper.setRowExpandRatio(1, .99f); wrapper.setSizeFull(); wrapper.addComponent(filterButtonLayout); wrapper.setComponentAlignment(filterButtonLayout, Alignment.MIDDLE_RIGHT); wrapper.addComponent(vSplitPanel); return wrapper; }
From source file:org.ikasan.dashboard.ui.topology.component.WiretapTab.java
License:BSD License
public Layout createWiretapLayout() { this.wiretapTable = new Table(); this.wiretapTable.setSizeFull(); this.wiretapTable.addStyleName(ValoTheme.TABLE_SMALL); this.wiretapTable.addStyleName("ikasan"); this.wiretapTable.addContainerProperty("Module Name", String.class, null); this.wiretapTable.addContainerProperty("Flow Name", String.class, null); this.wiretapTable.addContainerProperty("Component Name", String.class, null); this.wiretapTable.addContainerProperty("Event Id / Payload Id", String.class, null); this.wiretapTable.addContainerProperty("Timestamp", String.class, null); this.wiretapTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.wiretapTable.addItemClickListener(new ItemClickEvent.ItemClickListener() { @Override/*from w w w .j a v a2s . co 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.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummaryMultiPlayerMainView.java
License:Open Source License
@Override public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity, final NativeSelect orderSide) { HorizontalLayout buttonsBar = new HorizontalLayout(); final Button buySellButton = new Button("Buy"); buySellButton.addClickListener(new Button.ClickListener() { @Override/* w ww . ja va2 s . com*/ public void buttonClick(Button.ClickEvent clickEvent) { //check for invalid orders boolean invalidOrder = false; String numericRegex = "^[0-9]+$"; //conditions to check if (stocksList.getValue() == null || quantity.getValue() == null || !quantity.getValue().toString().matches(numericRegex)) { invalidOrder = true; } //if this is a sell order else if (((OrderType) orderSide.getValue()) == OrderType.SELL) { //check if te user has this stock BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable .getContainerDataSource(); if (!beans.containsId(stocksList.getValue().toString())) { invalidOrder = true; } } if (invalidOrder) { Notification.show("Invalid Order"); return; } try { Boolean status = player.executeOrder(stocksList.getValue().toString(), Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()), userName); //if the transaction was a success if (status) { updatePortfolioTable(stocksList.getValue().toString()); //update the account balance updateAccountBalance(); } else { Notification.show(status.toString()); } } catch (InvalidOrderException e) { Notification.show(e.getMessage()); } catch (UserJoinException e) { e.printStackTrace(); } } }); orderSide.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) { buySellButton.setCaption("Buy"); } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) { buySellButton.setCaption("Sell"); } } }); buttonsBar.addComponent(buySellButton); return buttonsBar; }
From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummarySinglePlayerMainView.java
License:Open Source License
@Override public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity, final NativeSelect orderSide) { HorizontalLayout buttonsBar = new HorizontalLayout(); final Button buySellButton = new Button("Buy"); buySellButton.addClickListener(new Button.ClickListener() { @Override/* w w w . j a v a2s . c o m*/ public void buttonClick(Button.ClickEvent clickEvent) { //check for invalid orders boolean invalidOrder = false; String numericRegex = "^[0-9]+$"; //conditions to check if (stocksList.getValue() == null || quantity.getValue() == null || !quantity.getValue().toString().matches(numericRegex)) { invalidOrder = true; } //if this is a sell order else if (((OrderType) orderSide.getValue()) == OrderType.SELL) { //check if te user has this stock BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable .getContainerDataSource(); if (!beans.containsId(stocksList.getValue().toString())) { invalidOrder = true; } } if (invalidOrder) { Notification.show("Invalid Order"); return; } try { Boolean status = player.executeOrder(stocksList.getValue().toString(), Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()), userName); //if the transaction was a success if (status) { updatePortfolioTable(stocksList.getValue().toString()); updateAccountBalance(); } else { Notification.show(status.toString()); } } catch (InvalidOrderException e) { Notification.show(e.getMessage()); } catch (UserJoinException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }); orderSide.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) { buySellButton.setCaption("Buy"); } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) { buySellButton.setCaption("Sell"); } } }); Button nextDayB = new Button("Next day"); nextDayB.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { player.playNextDay(); updateProfitChart(player.getCurrentTime()); //push the changes UI.getCurrent().access(new Runnable() { @Override public void run() { getUI().push(); } }); } }); buttonsBar.addComponent(nextDayB); buttonsBar.addComponent(buySellButton); return buttonsBar; }
From source file:org.investovator.ui.dataplayback.user.dashboard.realtime.RealTimeMainView.java
License:Open Source License
@Override public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity, final NativeSelect orderSide) { HorizontalLayout buttonsBar = new HorizontalLayout(); final Button buySellButton = new Button("Buy"); buySellButton.addClickListener(new Button.ClickListener() { @Override//from w w w .ja va 2 s . c o m public void buttonClick(Button.ClickEvent clickEvent) { //check for invalid orders boolean invalidOrder = false; String numericRegex = "^[0-9]+$"; //conditions to check if (stocksList.getValue() == null || quantity.getValue() == null || !quantity.getValue().toString().matches(numericRegex)) { invalidOrder = true; } //if this is a sell order else if (((OrderType) orderSide.getValue()) == OrderType.SELL) { //check if te user has this stock BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable .getContainerDataSource(); if (!beans.containsId(stocksList.getValue().toString())) { invalidOrder = true; } } if (invalidOrder) { Notification.show("Invalid Order"); return; } try { Boolean status = player.executeOrder(stocksList.getValue().toString(), Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()), userName); //if the transaction was a success if (status) { updatePortfolioTable(stocksList.getValue().toString()); //update account info updateAccountBalance(); Notification.show("Order executed successfully", Notification.Type.TRAY_NOTIFICATION); } else { Notification.show(status.toString()); } } catch (InvalidOrderException e) { Notification.show(e.getMessage()); } catch (UserJoinException e) { e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates. } } }); orderSide.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) { buySellButton.setCaption("Buy"); } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) { buySellButton.setCaption("Sell"); } } }); buttonsBar.addComponent(buySellButton); return buttonsBar; }
From source file:org.jumpmind.vaadin.ui.common.NotifyDialog.java
License:Open Source License
public NotifyDialog(String caption, String text, final Throwable ex, Type type) { super(caption); setWidth(400, Unit.PIXELS);//from w w w . j a v a 2s . c o m setHeight(300, Unit.PIXELS); final HorizontalLayout messageArea = new HorizontalLayout(); messageArea.addStyleName("v-scrollable"); messageArea.setMargin(true); messageArea.setSpacing(true); messageArea.setSizeFull(); text = isNotBlank(text) ? text : (ex != null ? ex.getMessage() : ""); if (type == Type.ERROR_MESSAGE) { setIcon(FontAwesome.BAN); } final String message = text; final Label textLabel = new Label(message, ContentMode.HTML); messageArea.addComponent(textLabel); messageArea.setExpandRatio(textLabel, 1); content.addComponent(messageArea); content.setExpandRatio(messageArea, 1); final Button detailsButton = new Button("Details"); detailsButton.setVisible(ex != null); detailsButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(ClickEvent event) { detailsMode = !detailsMode; if (detailsMode) { String msg = "<pre>" + ExceptionUtils.getStackTrace(ex).trim() + "</pre>"; msg = msg.replace("\t", " "); textLabel.setValue(msg); detailsButton.setCaption("Message"); messageArea.setMargin(new MarginInfo(false, false, false, true)); setHeight(600, Unit.PIXELS); setWidth(1000, Unit.PIXELS); setPosition(getPositionX() - 300, getPositionY() - 150); } else { textLabel.setValue(message); detailsButton.setCaption("Details"); messageArea.setMargin(true); setWidth(400, Unit.PIXELS); setHeight(300, Unit.PIXELS); setPosition(getPositionX() + 300, getPositionY() + 150); } } }); content.addComponent(buildButtonFooter(detailsButton, buildCloseButton())); }
From source file:org.lucidj.browser.BrowserView.java
License:Apache License
private Button createButton(Layout parent, String id, Resource icon, String caption, int kc, int mk) { final Button new_button = new Button(); if (caption != null) { new_button.setCaption(caption); }/* w ww . j av a2s . co m*/ new_button.setIcon(icon); new_button.addStyleName("tiny"); new_button.addStyleName("toolbar"); new_button.setId(id); new_button.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { handle_button_click(new_button); } }); parent.addComponent(new_button); if (kc != 0) { new_button.addShortcutListener(new AbstractField.FocusShortcut(new_button, kc, mk) { @Override public void handleAction(Object sender, Object target) { handle_button_click(new_button); } }); } return (new_button); }
From source file:org.lucidj.browser.BrowserView.java
License:Apache License
private void build_toolbar() { current_toolbar = new CssLayout(); CssLayout local_toolbar = new CssLayout(); current_toolbar.addComponent(local_toolbar); CssLayout navigation = new CssLayout(); navigation.addStyleName("v-component-group"); navigation.addStyleName("ui-toolbar-spacer"); createButton(navigation, "prev-smartbox", FontAwesome.CHEVRON_LEFT, null, ShortcutAction.KeyCode.ARROW_UP, ShortcutAction.ModifierKey.CTRL); createButton(navigation, "next-smartbox", FontAwesome.CHEVRON_RIGHT, null, ShortcutAction.KeyCode.ARROW_DOWN, ShortcutAction.ModifierKey.CTRL); local_toolbar.addComponent(navigation); createButton(local_toolbar, "save", FontAwesome.SAVE).addStyleName("ui-toolbar-spacer"); // createButton (local_toolbar, "test", FontAwesome.MAGIC) // .addStyleName("ui-toolbar-spacer"); // createButton (local_toolbar, "test2", FontAwesome.FLASK) // .addStyleName("ui-toolbar-spacer"); CssLayout edition = new CssLayout(); edition.addStyleName("v-component-group"); edition.addStyleName("ui-toolbar-spacer"); createButton(edition, "undo-cell-edit", FontAwesome.UNDO, "Undo"); createButton(edition, "redo-cell-edit", FontAwesome.REPEAT, null); createButton(edition, "delete-cell", FontAwesome.TRASH_O, null); local_toolbar.addComponent(edition); CssLayout view_controls = new CssLayout(); view_controls.addStyleName("v-component-group"); view_controls.addStyleName("ui-toolbar-spacer"); createButton(view_controls, VM_NOTEBOOK, new ExternalResource("vaadin://~/Browser_libraries/notebook-view.png")); createButton(view_controls, VM_SINGLE, new ExternalResource("vaadin://~/Browser_libraries/single-view.png"), null, ShortcutAction.KeyCode.INSERT, ShortcutAction.ModifierKey.CTRL); local_toolbar.addComponent(view_controls); // TODO: CTRL+ENTER => RUN AND SKIP TO NEXT // TODO: SELECTION + SHIFT+ENTER => RUN ONLY SELECTED STATEMENTS final Button source_view = new Button(); source_view.setId("output"); source_view.addStyleName("ui-toolbar-spacer"); source_view.setHtmlContentAllowed(true); String ico = "<path class=\"path1\" d=\"M1088 128h-64v-64c0-35.2-28.8-64-64-64h-896c-35.2 0-64 28.8-64 64v768c0 35.2 28.8 64 64 64h64v64c0 35.2 28.8 64 64 64h896c35.2 0 64-28.8 64-64v-768c0-35.2-28.8-64-64-64zM128 192v640h-63.886c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v63.884h-768c-35.2 0-64 28.8-64 64v0zM1088 959.884c-0.034 0.040-0.076 0.082-0.116 0.116h-895.77c-0.040-0.034-0.082-0.076-0.114-0.116v-767.77c0.034-0.040 0.076-0.082 0.114-0.114h895.77c0.040 0.034 0.082 0.076 0.116 0.116v767.768z\"></path>\n" + "<path class=\"path2\" d=\"M960 352c0 53.020-42.98 96-96 96s-96-42.98-96-96 42.98-96 96-96 96 42.98 96 96z\"></path>\n" + "<path class=\"path3\" d=\"M1024 896h-768v-128l224-384 256 320h64l224-192z\"></path>"; source_view.setCaption( "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1152 1024\">" + ico + "</svg>"); source_view.addStyleName("tiny"); source_view.addStyleName("toolbar"); source_view.addClickListener(new Button.ClickListener() { @Override// w w w .j a v a2 s .c o m public void buttonClick(Button.ClickEvent clickEvent) { handle_button_click(source_view); } }); local_toolbar.addComponent(source_view); // Button output_view = new Button (); // output_view.setHtmlContentAllowed(true); // String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>"; // output_view.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>"); // output_view.addStyleName("tiny"); // view_controls.addComponent (output_view); // // Button run = new Button (); // run.setHtmlContentAllowed(true); // String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; // run.setCaption("<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); // run.addStyleName("tiny"); // view_controls.addComponent (run); }
From source file:org.lucidj.html_renderer.HtmlRenderer.java
License:Apache License
private void init_toolbar() { editor_toolbar = new CssLayout(); CssLayout group = new CssLayout(); group.addStyleName("v-component-group"); Button output_view = new Button(); output_view.setHtmlContentAllowed(true); String ico2 = "<path d=\"M249.649 792.806l-107.776 166.4 11.469 54.426 54.272-11.622 107.725-166.298c-11.469-6.144-22.835-12.698-33.843-19.968-11.162-7.219-21.811-14.95-31.846-22.938zM705.943 734.694c0.717-1.485 1.178-3.123 1.843-4.71 2.714-5.99 5.12-11.981 7.066-18.278 0.307-1.126 0.461-2.253 0.819-3.277 1.997-6.963 3.686-13.824 5.018-20.89 0-0.358 0-0.614 0-1.075 9.984-59.853-7.424-126.618-47.258-186.931l56.832-87.757c65.485 8.346 122.112-8.141 149.35-50.278 47.258-72.858-10.24-194.15-128.256-271.002-118.118-76.902-252.058-80.128-299.213-7.373-27.341 42.189-19.354 100.71 15.002 157.338l-56.934 87.757c-71.117-11.93-139.059-0.819-189.594 32.768-0.307 0.102-0.666 0.205-0.87 0.41-5.888 3.994-11.622 8.397-16.998 13.005-0.87 0.717-1.894 1.382-2.611 2.099-5.018 4.301-9.523 9.114-13.875 13.926-1.024 1.229-2.458 2.304-3.43 3.584-5.427 6.195-10.445 12.749-14.848 19.712-70.861 109.21-10.394 274.483 134.81 369.101 145.306 94.618 320.512 82.637 391.219-26.573 4.454-6.912 8.55-14.131 11.93-21.555zM664.215 224.845c-45.414-29.542-67.584-76.134-49.408-104.243 18.125-28.006 69.683-26.726 114.995 2.816 45.517 29.542 67.482 76.237 49.408 104.243s-69.53 26.726-114.995-2.816z\"></path>"; output_view.setCaption( "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico2 + "</svg>"); output_view.addStyleName("tiny"); group.addComponent(output_view);// w w w .j a v a2s . c om output_view.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { show_hide_rich_text(); } }); Button run = new Button(); run.setHtmlContentAllowed(true); String ico3 = "<path class=\"path1\" d=\"M192 128l640 384-640 384z\"></path>"; run.setCaption( "<svg style=\"fill: currentColor; width: 1.5em; margin-top:0.3em;\" viewBox=\"0 0 1024 1024\">" + ico3 + "</svg>"); run.addStyleName("tiny"); group.addComponent(run); run.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { render_html_from_rich_text(); } }); run.addShortcutListener(new AbstractField.FocusShortcut(run, ShortcutAction.KeyCode.ENTER, ShortcutAction.ModifierKey.SHIFT) { @Override public void handleAction(Object sender, Object target) { render_html_from_rich_text(); } }); editor_toolbar.addComponent(group); }
From source file:org.lucidj.iconlist.renderer.IconListRenderer.java
License:Apache License
private void button_caption_wrap(Button b) { String caption = b.getCaption(); int wrap_len = 12; if (caption.length() > wrap_len) { String[] words = caption.split("\\s"); String twoliner = ""; int space_left = 0; int lines = 0; caption = ""; // Simple greedy wrapping for (String word : words) { int len = word.length(); if (len + 1 > space_left) { if (lines++ == 2) { twoliner = caption + "\u2026"; // Unicode ellipsis }/* w w w . j av a 2 s . com*/ caption += caption.isEmpty() ? word : "<br/>" + word; space_left = wrap_len - len; } else { caption += " " + word; space_left -= len + 1; } } b.setCaptionAsHtml(true); b.setCaption(twoliner.isEmpty() ? caption : twoliner); } b.setDescription(caption); }