List of usage examples for com.vaadin.server VaadinService getCurrentRequest
public static VaadinRequest getCurrentRequest()
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationPanel.java
License:BSD License
@Override public void enter(ViewChangeEvent event) { this.clientComboBox.loadClientSelectValues(); this.sourceContextComboBox.loadContextValues(); this.targetContextComboBox.loadContextValues(); this.typeComboBox.loadClientTypeValues(); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.EDIT_MAPPING_AUTHORITY) || (this.mappingConfiguration != null && authentication.canAccessLinkedItem( PolicyLinkTypeConstants.MAPPING_CONFIGURATION_LINK_TYPE, this.mappingConfiguration.getId())))) { this.mappingConfigurationFunctionalGroup.initialiseButtonState(); }// www. ja va2 s. co m }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationImportWindow.java
License:BSD License
/** * Helper method to initialise this object. *//* w w w . ja v a2 s. c o m*/ protected void init() { this.setModal(true); super.setHeight(40.0f, Unit.PERCENTAGE); super.setWidth(40.0f, Unit.PERCENTAGE); super.center(); super.setStyleName("ikasan"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(uploadLabel); final Upload upload = new Upload("", receiver); upload.addSucceededListener(receiver); upload.addFinishedListener(new Upload.FinishedListener() { public void uploadFinished(FinishedEvent event) { upload.setVisible(false); try { parseUploadFile(); } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Caught exception trying to import a Mapping Configuration!\n", sw.toString(), Notification.Type.ERROR_MESSAGE); } } }); final Button importButton = new Button("Import"); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { upload.interruptUpload(); } }); upload.addStartedListener(new Upload.StartedListener() { public void uploadStarted(StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); } }); upload.addProgressListener(new Upload.ProgressListener() { public void updateProgress(long readBytes, long contentLength) { // This method gets called several times during the update } }); importButton.setStyleName(ValoTheme.BUTTON_SMALL); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { saveImportedMappingConfiguration(); mappingConfiguration = null; progressLayout.setVisible(false); upload.setVisible(true); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Imported mapping configuration: [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]", authentication.getName()); } catch (MappingConfigurationServiceException e) { if (e.getCause() instanceof DataIntegrityViolationException) { Notification.show("Caught exception trying to save an imported Mapping Configuration!", "This is due to the fact " + "that, combined, the client, type, source and target context values are unique for a Mapping Configuration. The values" + " that are being imported and not unique.", Notification.Type.ERROR_MESSAGE); } else { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Caught exception trying to save an imported Mapping Configuration!\n", sw.toString(), Notification.Type.ERROR_MESSAGE); } } close(); } }); progressLayout.addComponent(importButton); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.addComponent(new Label("Select file to upload mapping configurations.")); layout.addComponent(upload); layout.addComponent(progressLayout); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mappingConfiguration = null; progressLayout.setVisible(false); upload.setVisible(true); close(); } }); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addComponent(cancelButton); layout.addComponent(hlayout); super.setContent(layout); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationValuesImportWindow.java
License:BSD License
/** * Helper method to initialise this object. *//*w w w . j av a 2 s .c o m*/ protected void init() { this.setModal(true); super.setHeight(40.0f, Unit.PERCENTAGE); super.setWidth(40.0f, Unit.PERCENTAGE); super.center(); super.setStyleName("ikasan"); progressLayout.setSpacing(true); progressLayout.setVisible(false); progressLayout.addComponent(uploadLabel); final Upload upload = new Upload("", receiver); upload.addSucceededListener(receiver); upload.addFinishedListener(new Upload.FinishedListener() { public void uploadFinished(FinishedEvent event) { upload.setVisible(false); parseUploadFile(); } }); final Button importButton = new Button("Import"); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { upload.interruptUpload(); } }); upload.addStartedListener(new Upload.StartedListener() { public void uploadStarted(StartedEvent event) { // This method gets called immediately after upload is started upload.setVisible(false); } }); upload.addProgressListener(new Upload.ProgressListener() { public void updateProgress(long readBytes, long contentLength) { // This method gets called several times during the update } }); importButton.setStyleName(ValoTheme.BUTTON_SMALL); importButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { saveImportedMappingConfigurationValues(); IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); systemEventService.logSystemEvent(MappingConfigurationConstants.MAPPING_CONFIGURATION_SERVICE, "Imported mapping configuration values for mapping configuration: [Client=" + mappingConfiguration.getConfigurationServiceClient().getName() + "] [Source Context=" + mappingConfiguration.getSourceContext().getName() + "] [Target Context=" + mappingConfiguration.getTargetContext().getName() + "] [Type=" + mappingConfiguration.getConfigurationType().getName() + "]", authentication.getName()); logger.info("User: " + authentication.getName() + " successfully imported the following Mapping Configuration: " + mappingConfiguration); } catch (Exception e) { Notification.show( "An error occurred trying to import a mapping configuration: " + e.getMessage(), Notification.Type.ERROR_MESSAGE); } mappingConfigurationConfigurationValuesTable.populateTable(mappingConfiguration); close(); } }); progressLayout.addComponent(importButton); VerticalLayout layout = new VerticalLayout(); layout.setMargin(true); layout.addComponent(new Label("Select file to upload mapping configurations.")); layout.addComponent(upload); layout.addComponent(progressLayout); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { close(); } }); HorizontalLayout hlayout = new HorizontalLayout(); hlayout.addComponent(cancelButton); layout.addComponent(hlayout); super.setContent(layout); }
From source file:org.ikasan.dashboard.ui.Menu.java
License:BSD License
protected void buildMenu() { menuItemsLayout.setPrimaryStyleName("valo-menuitems"); this.addComponent(menuItemsLayout); Label label = null;/* ww w . ja v a2 s . co m*/ label = new Label("General", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); final Button dashboardMenuItem = new Button("Dashboard", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("landingView"); } }); dashboardMenuItem.setHtmlContentAllowed(true); dashboardMenuItem.setPrimaryStyleName("valo-menu-item"); dashboardMenuItem.setIcon(VaadinIcons.DASHBOARD); menuItemsLayout.addComponent(dashboardMenuItem); label = null; final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_TOPOLOGY_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_MAPPING_AUTHORITY))) { label = new Label("Services", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); } label = new Label("Services", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY); this.menuComponents.put(label, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY); this.menuComponents.put(label, SecurityConstants.VIEW_MAPPING_AUTHORITY); final Button topologyMenuItem = new Button("Topology", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("topologyView"); } }); topologyMenuItem.setHtmlContentAllowed(true); topologyMenuItem.setPrimaryStyleName("valo-menu-item"); topologyMenuItem.setIcon(VaadinIcons.CONNECT_O); menuItemsLayout.addComponent(topologyMenuItem); this.menuComponents.put(topologyMenuItem, SecurityConstants.VIEW_TOPOLOGY_AUTHORITY); final Button mappingMenuItem = new Button("Mapping", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("mappingView"); loadNavigator("mapping"); } }); mappingMenuItem.setHtmlContentAllowed(true); mappingMenuItem.setPrimaryStyleName("valo-menu-item"); mappingMenuItem.setIcon(VaadinIcons.COPY_O); menuItemsLayout.addComponent(mappingMenuItem); this.menuComponents.put(mappingMenuItem, SecurityConstants.VIEW_MAPPING_AUTHORITY); final Button monitoringMenuItem = new Button("Monitoring", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("monitorView"); } }); monitoringMenuItem.setHtmlContentAllowed(true); monitoringMenuItem.setPrimaryStyleName("valo-menu-item"); monitoringMenuItem.setIcon(VaadinIcons.DESKTOP); menuItemsLayout.addComponent(monitoringMenuItem); this.menuComponents.put(monitoringMenuItem, SecurityConstants.VIEW_MONITORING_AUTHORITY); label = new Label("Administration", ContentMode.HTML); label.setPrimaryStyleName("valo-menu-subtitle"); label.addStyleName("h4"); label.setSizeUndefined(); menuItemsLayout.addComponent(label); this.menuComponents.put(label, SecurityConstants.ALL_AUTHORITY); final Button usersItem = new Button("Users", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("userPanel"); } }); usersItem.setHtmlContentAllowed(true); usersItem.setPrimaryStyleName("valo-menu-item"); usersItem.setIcon(VaadinIcons.USER); menuItemsLayout.addComponent(usersItem); this.menuComponents.put(usersItem, SecurityConstants.ALL_AUTHORITY); final Button groupsItem = new Button("Groups", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("principalManagementPanel"); } }); groupsItem.setHtmlContentAllowed(true); groupsItem.setPrimaryStyleName("valo-menu-item"); groupsItem.setIcon(VaadinIcons.USERS); menuItemsLayout.addComponent(groupsItem); this.menuComponents.put(groupsItem, SecurityConstants.ALL_AUTHORITY); final Button rolesItem = new Button("Roles", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("roleManagementPanel"); } }); rolesItem.setHtmlContentAllowed(true); rolesItem.setPrimaryStyleName("valo-menu-item"); rolesItem.setIcon(VaadinIcons.SPECIALIST); menuItemsLayout.addComponent(rolesItem); this.menuComponents.put(rolesItem, SecurityConstants.ALL_AUTHORITY); final Button policyItem = new Button("Policies", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("policyManagementPanel"); } }); policyItem.setHtmlContentAllowed(true); policyItem.setPrimaryStyleName("valo-menu-item"); policyItem.setIcon(VaadinIcons.SAFE); menuItemsLayout.addComponent(policyItem); this.menuComponents.put(policyItem, SecurityConstants.ALL_AUTHORITY); final Button authItem = new Button("User Directories", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("authenticationMethodView"); } }); authItem.setHtmlContentAllowed(true); authItem.setPrimaryStyleName("valo-menu-item"); authItem.setIcon(VaadinIcons.COG); menuItemsLayout.addComponent(authItem); this.menuComponents.put(authItem, SecurityConstants.ALL_AUTHORITY); final Button platformConfigItem = new Button("Platform Configuration", new ClickListener() { @Override public void buttonClick(final ClickEvent event) { loadTopLevelNavigator(); UI.getCurrent().getNavigator().navigateTo("platformConfigurationView"); } }); platformConfigItem.setHtmlContentAllowed(true); platformConfigItem.setPrimaryStyleName("valo-menu-item"); platformConfigItem.setIcon(VaadinIcons.LIST); menuItemsLayout.addComponent(platformConfigItem); this.menuComponents.put(platformConfigItem, SecurityConstants.ALL_AUTHORITY); }
From source file:org.ikasan.dashboard.ui.monitor.component.MonitorPanel.java
License:BSD License
protected boolean actionFlow(Flow flow, String action) { 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);//from w w w . ja v a 2s . com Client client = ClientBuilder.newClient(clientConfig); String url = "http://" + flow.getModule().getServer().getUrl() + ":" + flow.getModule().getServer().getPort() + flow.getModule().getContextRoot() + "/rest/moduleControl/controlFlowState/" + flow.getModule().getName() + "/" + flow.getName(); WebTarget webTarget = client.target(url); Response response = webTarget.request().put(Entity.entity(action, MediaType.APPLICATION_OCTET_STREAM)); if (response.getStatus() == 200) { Notification.show(flow.getName() + " flow " + action + "!"); } else { response.bufferEntity(); String responseMessage = response.readEntity(String.class); Notification.show(responseMessage, Type.ERROR_MESSAGE); return false; } return true; }
From source file:org.ikasan.dashboard.ui.topology.component.BusinessStreamTab.java
License:BSD License
public Layout createBusinessStreamLayout() { this.businessStreamTable = new Table(); this.businessStreamTable.addContainerProperty("Server Name", String.class, null); this.businessStreamTable.addContainerProperty("Module Name", String.class, null); this.businessStreamTable.addContainerProperty("Flow Name", String.class, null); this.businessStreamTable.addContainerProperty("", Button.class, null); this.businessStreamTable.setWidth("100%"); this.businessStreamTable.setHeight(600, Unit.PIXELS); this.businessStreamTable.setCellStyleGenerator(new IkasanSmallCellStyleGenerator()); this.businessStreamTable.setDragMode(TableDragMode.ROW); this.businessStreamTable.setDropHandler(new DropHandler() { @Override/* w w w .j av a2 s . c o m*/ public void drop(final DragAndDropEvent dropEvent) { final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication .hasGrantedAuthority(SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) { Notification.show("You do not have the privilege to modify a business stream."); return; } final DataBoundTransferable t = (DataBoundTransferable) dropEvent.getTransferable(); if (t.getItemId() instanceof Flow) { final Flow flow = (Flow) t.getItemId(); final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); BusinessStreamFlowKey key = new BusinessStreamFlowKey(); key.setBusinessStreamId(businessStream.getId()); key.setFlowId(flow.getId()); final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key); businessStreamFlow.setFlow(flow); businessStreamFlow.setOrder(businessStreamTable.getItemIds().size()); if (!businessStream.getFlows().contains(businessStreamFlow)) { businessStream.getFlows().add(businessStreamFlow); topologyService.saveBusinessStream(businessStream); Button deleteButton = new Button(); Resource deleteIcon = VaadinIcons.TRASH; deleteButton.setIcon(deleteIcon); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); deleteButton.setData(businessStreamFlow); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); businessStreamTable .addItem( new Object[] { flow.getModule().getServer().getName(), flow.getModule().getName(), flow.getName(), deleteButton }, businessStreamFlow); } } else if (t.getItemId() instanceof Module) { final Module sourceContainer = (Module) t.getItemId(); for (Flow flow : sourceContainer.getFlows()) { final BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); BusinessStreamFlowKey key = new BusinessStreamFlowKey(); key.setBusinessStreamId(businessStream.getId()); key.setFlowId(flow.getId()); final BusinessStreamFlow businessStreamFlow = new BusinessStreamFlow(key); businessStreamFlow.setFlow(flow); businessStreamFlow.setOrder(businessStreamTable.getItemIds().size()); if (!businessStream.getFlows().contains(businessStreamFlow)) { businessStream.getFlows().add(businessStreamFlow); topologyService.saveBusinessStream(businessStream); Button deleteButton = new Button(); Resource deleteIcon = VaadinIcons.TRASH; deleteButton.setIcon(deleteIcon); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); deleteButton.setData(businessStreamFlow); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); businessStreamTable.addItem( new Object[] { flow.getModule().getServer().getName(), flow.getModule().getName(), flow.getName(), deleteButton }, businessStreamFlow); } } } else { Notification.show("Only modules or flows can be dragged to this table."); } } @Override public AcceptCriterion getAcceptCriterion() { return AcceptAll.get(); } }); GridLayout layout = new GridLayout(1, 6); layout.setMargin(true); layout.setSpacing(true); layout.setSizeFull(); Label tableDropHintLabel = new Label(); tableDropHintLabel.setCaptionAsHtml(true); tableDropHintLabel.setCaption(VaadinIcons.QUESTION_CIRCLE_O.getHtml() + " Drag modules or flows from the topology tree to the table below to build a business stream."); tableDropHintLabel.addStyleName(ValoTheme.LABEL_TINY); tableDropHintLabel.addStyleName(ValoTheme.LABEL_LIGHT); layout.addComponent(tableDropHintLabel); GridLayout controlsLayout = new GridLayout(3, 3); controlsLayout.setColumnExpandRatio(0, .05f); controlsLayout.setColumnExpandRatio(1, .65f); controlsLayout.setColumnExpandRatio(2, .3f); controlsLayout.setWidth("100%"); controlsLayout.setSpacing(true); Label newBusinessStreamLabel = new Label("New Business Stream:"); newBusinessStreamLabel.setSizeUndefined(); controlsLayout.addComponent(newBusinessStreamLabel, 0, 0); controlsLayout.setComponentAlignment(newBusinessStreamLabel, Alignment.MIDDLE_RIGHT); Button newButton = new Button(); newButton.setIcon(VaadinIcons.PLUS); newButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); newButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); newButton.setDescription("Create a new business stream."); newButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final NewBusinessStreamWindow newBusinessStreamWindow = new NewBusinessStreamWindow(); UI.getCurrent().addWindow(newBusinessStreamWindow); newBusinessStreamWindow.addCloseListener(new Window.CloseListener() { // inline close-listener public void windowClose(CloseEvent e) { topologyService.saveBusinessStream(newBusinessStreamWindow.getBusinessStream()); businessStreamCombo.addItem(newBusinessStreamWindow.getBusinessStream()); businessStreamCombo.setItemCaption(newBusinessStreamWindow.getBusinessStream(), newBusinessStreamWindow.getBusinessStream().getName()); businessStreamCombo.select(newBusinessStreamWindow.getBusinessStream()); businessStreamTable.removeAllItems(); } }); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority(SecurityConstants.CREATE_BUSINESS_STREAM_AUTHORITY))) { newButton.setVisible(false); } controlsLayout.addComponent(newButton, 1, 0); Label businessStreamLabel = new Label("Business Stream:"); businessStreamLabel.setSizeUndefined(); final TextArea descriptionTextArea = new TextArea(); descriptionTextArea.setReadOnly(true); this.businessStreamCombo.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (event.getProperty() != null && event.getProperty().getValue() != null) { final BusinessStream businessStream = (BusinessStream) event.getProperty().getValue(); descriptionTextArea.setReadOnly(false); descriptionTextArea.setValue(businessStream.getDescription()); descriptionTextArea.setReadOnly(true); businessStreamTable.removeAllItems(); for (final BusinessStreamFlow businessStreamFlow : businessStream.getFlows()) { logger.info("Adding flow: " + businessStreamFlow); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the flow from the business stream."); // Add the delete functionality to each role that is added deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { businessStream.getFlows().remove(businessStreamFlow); topologyService.deleteBusinessStreamFlow(businessStreamFlow); topologyService.saveBusinessStream(businessStream); businessStreamTable.removeItem(businessStreamFlow.getFlow()); } }); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService .getCurrentRequest().getWrappedSession() .getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority( SecurityConstants.MODIFY_BUSINESS_STREAM_AUTHORITY))) { deleteButton.setVisible(false); } businessStreamTable.addItem( new Object[] { businessStreamFlow.getFlow().getModule().getServer().getName(), businessStreamFlow.getFlow().getName(), businessStreamFlow.getFlow().getName(), deleteButton }, businessStreamFlow); } } } }); businessStreamCombo.setWidth("100%"); controlsLayout.addComponent(businessStreamLabel, 0, 1); controlsLayout.setComponentAlignment(businessStreamLabel, Alignment.MIDDLE_RIGHT); controlsLayout.addComponent(businessStreamCombo, 1, 1); Button deleteButton = new Button(); deleteButton.setIcon(VaadinIcons.TRASH); deleteButton.addStyleName(ValoTheme.BUTTON_ICON_ONLY); deleteButton.addStyleName(ValoTheme.BUTTON_BORDERLESS); deleteButton.setDescription("Delete the selected business stream."); deleteButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { Collection<BusinessStreamFlow> businessStreamFlows = (Collection<BusinessStreamFlow>) businessStreamTable .getItemIds(); for (BusinessStreamFlow businessStreamFlow : businessStreamFlows) { topologyService.deleteBusinessStreamFlow(businessStreamFlow); } BusinessStream businessStream = (BusinessStream) businessStreamCombo.getValue(); topologyService.deleteBusinessStream(businessStream); businessStreamTable.removeAllItems(); List<BusinessStream> businessStreams = topologyService.getAllBusinessStreams(); businessStreamCombo.removeItem(businessStream); descriptionTextArea.setValue(""); } }); if (authentication != null && (!authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) && !authentication.hasGrantedAuthority(SecurityConstants.DELETE_BUSINESS_STREAM_AUTHORITY))) { deleteButton.setVisible(false); } controlsLayout.addComponent(deleteButton, 2, 1); Label descriptionLabel = new Label("Description:"); descriptionLabel.setSizeUndefined(); descriptionTextArea.setRows(4); descriptionTextArea.setWidth("100%"); controlsLayout.addComponent(descriptionLabel, 0, 2); controlsLayout.setComponentAlignment(descriptionLabel, Alignment.TOP_RIGHT); controlsLayout.addComponent(descriptionTextArea, 1, 2); layout.addComponent(controlsLayout); layout.addComponent(this.businessStreamTable); return layout; }
From source file:org.ikasan.dashboard.ui.topology.panel.TopologyViewPanel.java
License:BSD License
protected void createTabSheet() { tabsheet = new TabSheet(); tabsheet.setSizeFull();/* ww w. j av a2 s. c o m*/ final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_BUSINESS_STREAM_AUTHORITY))) { VerticalLayout tab1 = new VerticalLayout(); tab1.setSizeFull(); BusinessStreamTab businessStreamTab = new BusinessStreamTab(this.topologyService, this.businessStreamCombo); tab1.addComponent(businessStreamTab.createBusinessStreamLayout()); tabsheet.addTab(tab1, "Business Stream"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_WIRETAP_AUTHORITY))) { VerticalLayout tab2 = new VerticalLayout(); tab2.setSizeFull(); WiretapTab wiretapTab = new WiretapTab(this.wiretapDao, this.treeViewBusinessStreamCombo); tab2.addComponent(wiretapTab.createWiretapLayout()); tabsheet.addTab(tab2, "Wiretaps"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_ERRORS_AUTHORITY))) { VerticalLayout tab3 = new VerticalLayout(); tab3.setSizeFull(); ErrorOccurrenceTab errorOccurrenceTab = new ErrorOccurrenceTab(this.errorReportingService, this.treeViewBusinessStreamCombo); tab3.addComponent(errorOccurrenceTab.createCategorisedErrorLayout()); tabsheet.addTab(tab3, "Errors"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_EXCLUSION_AUTHORITY))) { final VerticalLayout tab4 = new VerticalLayout(); tab4.setSizeFull(); final ExclusionsTab actionedExclusionsTab = new ExclusionsTab(this.errorReportingService, this.exclusionManagementService, this.hospitalManagementService, this.topologyService, this.serialiserFactory, this.treeViewBusinessStreamCombo); tab4.addComponent(actionedExclusionsTab.createLayout()); tabsheet.addTab(tab4, "Exclusions"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_ACTIONED_EXCLUSIONS_AUTHORITY))) { final VerticalLayout tab5 = new VerticalLayout(); tab5.setSizeFull(); ActionedExclusionTab actionedExclusionTab = new ActionedExclusionTab(this.exclusionManagementService, this.hospitalManagementService, this.errorReportingService, this.topologyService, this.serialiserFactory, this.treeViewBusinessStreamCombo); tab5.addComponent(actionedExclusionTab.createLayout()); tabsheet.addTab(tab5, "Actioned Exclusions"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_ACTIONED_EXCLUSIONS_AUTHORITY))) { final VerticalLayout tab6 = new VerticalLayout(); tab6.setSizeFull(); tab6.addComponent(this.createSystemEventPanel()); tabsheet.addTab(tab6, "System Events"); } if (authentication != null && (authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY) || authentication.hasGrantedAuthority(SecurityConstants.VIEW_CATEGORISED_ERRORS_AUTHORITY))) { final VerticalLayout tab8 = new VerticalLayout(); tab8.setSizeFull(); CategorisedErrorTab categorisedErrorTab = new CategorisedErrorTab(this.errorCategorisationService, this.treeViewBusinessStreamCombo, this.serialiserFactory); tab8.addComponent(categorisedErrorTab.createCategorisedErrorLayout()); tabsheet.addTab(tab8, "Categorised Errors"); } this.tabsheetPanel.setContent(tabsheet); }
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 va2s. 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 void refreshTree() { this.moduleTree.removeAllItems(); final IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest() .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER); if (authentication != null && authentication.hasGrantedAuthority(SecurityConstants.ALL_AUTHORITY)) { List<Server> servers = this.topologyService.getAllServers(); for (Server server : servers) { Set<Module> modules = server.getModules(); this.moduleTree.addItem(server); this.moduleTree.setCaptionAsHtml(true); MonitorIcons icon = MonitorIcons.SERVER; icon.setSizePixels(14);/*from w w w . j ava 2s . c om*/ icon.setColor("green"); this.moduleTree.setItemCaption(server, icon.getHtml() + " " + server.getName()); this.moduleTree.setChildrenAllowed(server, true); // this.moduleTree.setItemIcon(server, icon); for (Module module : modules) { this.moduleTree.addItem(module); this.moduleTree.setItemCaption(module, module.getName()); this.moduleTree.setParent(module, server); this.moduleTree.setChildrenAllowed(module, true); this.moduleTree.setItemIcon(module, VaadinIcons.ARCHIVE); Set<Flow> flows = module.getFlows(); for (Flow flow : flows) { this.moduleTree.addItem(flow); this.moduleTree.setItemCaption(flow, flow.getName()); this.moduleTree.setParent(flow, module); this.moduleTree.setChildrenAllowed(flow, true); TopologyViewPanel.this.moduleTree.setItemIcon(flow, VaadinIcons.AUTOMATION); Set<Component> components = flow.getComponents(); for (Component component : components) { this.moduleTree.addItem(component); this.moduleTree.setParent(component, flow); this.moduleTree.setItemCaption(component, component.getName()); this.moduleTree.setChildrenAllowed(component, false); if (component.isConfigurable()) { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG); } else { TopologyViewPanel.this.moduleTree.setItemIcon(component, VaadinIcons.COG_O); } } } } } List<BusinessStream> businessStreams = this.topologyService.getAllBusinessStreams(); if (this.businessStreamCombo != null) { this.businessStreamCombo.removeAllItems(); for (BusinessStream businessStream : businessStreams) { this.businessStreamCombo.addItem(businessStream); this.businessStreamCombo.setItemCaption(businessStream, businessStream.getName()); } } this.treeViewBusinessStreamCombo.removeAllItems(); BusinessStream businessStreamAll = new BusinessStream(); businessStreamAll.setName("All"); this.treeViewBusinessStreamCombo.addItem(businessStreamAll); this.treeViewBusinessStreamCombo.setItemCaption(businessStreamAll, businessStreamAll.getName()); for (BusinessStream businessStream : businessStreams) { this.treeViewBusinessStreamCombo.addItem(businessStream); this.treeViewBusinessStreamCombo.setItemCaption(businessStream, businessStream.getName()); } this.treeViewBusinessStreamCombo.setValue(businessStreamAll); } else { List<BusinessStream> businessStreams = this.topologyService.getAllBusinessStreams(); if (this.businessStreamCombo != null) { this.businessStreamCombo.removeAllItems(); } this.treeViewBusinessStreamCombo.removeAllItems(); BusinessStream businessStreamAll = new BusinessStream(); businessStreamAll.setName("All"); this.treeViewBusinessStreamCombo.addItem(businessStreamAll); this.treeViewBusinessStreamCombo.setItemCaption(businessStreamAll, businessStreamAll.getName()); this.treeViewBusinessStreamCombo.setValue(businessStreamAll); 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.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.businessStreamCombo.addItem(businessStream); this.businessStreamCombo.setItemCaption(businessStream, businessStream.getName()); this.treeViewBusinessStreamCombo.addItem(businessStream); this.treeViewBusinessStreamCombo.setItemCaption(businessStream, businessStream.getName()); } } } } for (Iterator<?> it = this.moduleTree.rootItemIds().iterator(); it.hasNext();) { this.moduleTree.expandItemsRecursively(it.next()); } for (Iterator<?> it = this.moduleTree.getItemIds().iterator(); it.hasNext();) { Object nextItem = it.next(); if (nextItem instanceof Module) { this.moduleTree.collapseItemsRecursively(nextItem); } } }
From source file:org.ikasan.dashboard.ui.topology.window.ComponentConfigurationWindow.java
License:BSD License
@SuppressWarnings("unchecked") public void populate(Component component) { configuration = this.configurationManagement.getConfiguration(component.getConfigurationId()); if (configuration == null) { Server server = component.getFlow().getModule().getServer(); String url = "http://" + server.getUrl() + ":" + server.getPort() + component.getFlow().getModule().getContextRoot() + "/rest/configuration/createConfiguration/" + component.getFlow().getModule().getName() + "/" + component.getFlow().getName() + "/" + component.getName();/*from w w w .j ava2 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); }