List of usage examples for com.vaadin.ui Button setStyleName
@Override public void setStyleName(String style)
From source file:org.ikasan.dashboard.ui.administration.panel.PlatformConfigurationPanel.java
License:BSD License
protected Panel createMapPanel(final ConfigurationParameterMapImpl parameter) { Panel paramPanel = new Panel(); paramPanel.setStyleName("dashboard"); paramPanel.setWidth("100%"); GridLayout paramLayout = new GridLayout(2, 3); paramLayout.setSpacing(true);/* w w w . j av a 2 s . com*/ paramLayout.setSizeFull(); paramLayout.setMargin(true); paramLayout.setColumnExpandRatio(0, .25f); paramLayout.setColumnExpandRatio(1, .75f); Label label = new Label("Platform Configuration"); label.addStyleName(ValoTheme.LABEL_HUGE); label.setSizeUndefined(); paramLayout.addComponent(label, 0, 0, 1, 0); paramLayout.setComponentAlignment(label, Alignment.TOP_LEFT); final Map<String, String> valueMap = parameter.getValue(); final GridLayout mapLayout = new GridLayout(5, (valueMap.size() != 0 ? valueMap.size() : 1) + 1); mapLayout.setColumnExpandRatio(0, .05f); mapLayout.setColumnExpandRatio(1, .425f); mapLayout.setColumnExpandRatio(2, .05f); mapLayout.setColumnExpandRatio(3, .425f); mapLayout.setColumnExpandRatio(4, .05f); mapLayout.setMargin(true); mapLayout.setSpacing(true); mapLayout.setWidth("100%"); int i = 0; for (final String key : valueMap.keySet()) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setValue(key); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setValue(valueMap.get(key)); valueField.setNullSettingAllowed(false); valueField.addValidator(new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.addComponent(keyLabel, 0, i); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, i); mapLayout.addComponent(valueLabel, 2, i); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, i); final String mapKey = parameter.getName() + i; TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; this.mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { valueMap.remove(key); mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, i); i++; } final Button addButton = new Button("add"); addButton.setStyleName(ValoTheme.BUTTON_LINK); addButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { final Label keyLabel = new Label("Name:"); final Label valueLabel = new Label("Value:"); final TextField keyField = new TextField(); keyField.setWidth("100%"); keyField.setNullSettingAllowed(false); keyField.addValidator( new NonZeroLengthStringValidator("Then configuration value name cannot be empty!")); keyField.setValidationVisible(false); final TextField valueField = new TextField(); valueField.setWidth("100%"); valueField.setNullSettingAllowed(false); valueField.addValidator( new NonZeroLengthStringValidator("Then configuration value cannot be empty!")); valueField.setValidationVisible(false); mapLayout.insertRow(mapLayout.getRows()); mapLayout.removeComponent(addButton); mapLayout.addComponent(keyLabel, 0, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(keyLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(keyField, 1, mapLayout.getRows() - 2); mapLayout.addComponent(valueLabel, 2, mapLayout.getRows() - 2); mapLayout.setComponentAlignment(valueLabel, Alignment.MIDDLE_RIGHT); mapLayout.addComponent(valueField, 3, mapLayout.getRows() - 2); final String mapKey = parameter.getName() + mapTextFields.size(); TextFieldKeyValuePair pair = new TextFieldKeyValuePair(); pair.key = keyField; pair.value = valueField; mapTextFields.put(mapKey, pair); final Button removeButton = new Button("remove"); removeButton.setStyleName(ValoTheme.BUTTON_LINK); removeButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { mapLayout.removeComponent(keyLabel); mapLayout.removeComponent(valueLabel); mapLayout.removeComponent(keyField); mapLayout.removeComponent(valueField); mapLayout.removeComponent(removeButton); mapTextFields.remove(mapKey); } }); mapLayout.addComponent(removeButton, 4, mapLayout.getRows() - 2); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); } }); mapLayout.addComponent(addButton, 0, mapLayout.getRows() - 1); Panel mapPanel = new Panel(); mapPanel.setStyleName(ValoTheme.PANEL_BORDERLESS); mapPanel.setContent(mapLayout); Button saveButton = new Button("Save"); saveButton.addStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.validate(); textField.value.validate(); } } catch (InvalidValueException e) { for (TextFieldKeyValuePair textField : mapTextFields.values()) { textField.key.setValidationVisible(true); textField.value.setValidationVisible(true); } Notification.show("Validation errors have occurred!", Type.ERROR_MESSAGE); return; } 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); PlatformConfigurationPanel.this.configurationManagement.saveConfiguration(platformConfiguration); Notification notification = new Notification("Saved", "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE); notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE); notification.show(Page.getCurrent()); } }); paramLayout.addComponent(mapPanel, 0, 1, 1, 1); paramLayout.setComponentAlignment(mapPanel, Alignment.TOP_CENTER); paramLayout.addComponent(saveButton, 0, 2, 1, 2); paramLayout.setComponentAlignment(saveButton, Alignment.TOP_CENTER); paramPanel.setContent(paramLayout); return paramPanel; }
From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java
License:BSD License
protected void populateDirectoryTable(final AuthenticationMethod authenticationMethod) { Button test = new Button("Test"); test.setStyleName(BaseTheme.BUTTON_LINK); test.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { authenticationProviderFactory.testAuthenticationConnection(authenticationMethod); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw);//from w ww.j av a 2 s . c o m Notification.show("Error occurred while testing connection!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while testing connection!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Connection Successful!"); } }); final Button enableDisableButton = new Button(); if (authenticationMethod.isEnabled()) { enableDisableButton.setCaption("Disable"); } else { enableDisableButton.setCaption("Enable"); } enableDisableButton.setStyleName(BaseTheme.BUTTON_LINK); enableDisableButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { if (authenticationMethod.isEnabled()) { authenticationMethod.setEnabled(false); } else { authenticationMethod.setEnabled(true); } securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to enable/disable the authentication method!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } if (authenticationMethod.isEnabled()) { enableDisableButton.setCaption("Disable"); Notification.show("Enabled!"); } else { enableDisableButton.setCaption("Enable"); Notification.show("Disabled!"); } } }); Button delete = new Button("Delete"); delete.setStyleName(BaseTheme.BUTTON_LINK); delete.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { securityService.deleteAuthenticationMethod(authenticationMethod); List<AuthenticationMethod> authenticationMethods = securityService.getAuthenticationMethods(); directoryTable.removeAllItems(); long order = 1; for (final AuthenticationMethod authenticationMethod : authenticationMethods) { authenticationMethod.setOrder(order++); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); } populateAll(); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to delete the authentication method!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Deleted!"); } }); Button edit = new Button("Edit"); edit.setStyleName(BaseTheme.BUTTON_LINK); edit.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel( authenticationMethod, securityService, authenticationProviderFactory, ldapService); Window window = new Window("Configure User Directory"); window.setModal(true); window.setHeight("90%"); window.setWidth("90%"); window.setContent(authMethodPanel); UI.getCurrent().addWindow(window); } }); Button synchronise = new Button("Synchronise"); synchronise.setStyleName(BaseTheme.BUTTON_LINK); synchronise.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { ldapService.synchronize(authenticationMethod); authenticationMethod.setLastSynchronised(new Date()); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } catch (UnexpectedRollbackException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); logger.error("Most specific cause: " + e.getMostSpecificCause()); e.getMostSpecificCause().printStackTrace(); logger.error("Most specific cause: " + e.getRootCause()); e.getRootCause().printStackTrace(); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } catch (Exception e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error occurred while synchronizing!", sw.toString(), Notification.Type.ERROR_MESSAGE); return; } Notification.show("Synchronized!"); } }); GridLayout operationsLayout = new GridLayout(9, 2); operationsLayout.setWidth("250px"); operationsLayout.addComponent(enableDisableButton, 0, 0); operationsLayout.addComponent(new Label(" "), 1, 0); operationsLayout.addComponent(edit, 2, 0); operationsLayout.addComponent(new Label(" "), 3, 0); operationsLayout.addComponent(delete, 4, 0); operationsLayout.addComponent(new Label(" "), 5, 0); operationsLayout.addComponent(test, 6, 0); operationsLayout.addComponent(new Label(" "), 7, 0); operationsLayout.addComponent(synchronise, 8, 0); TextArea synchronisedTextArea = new TextArea(); synchronisedTextArea.setRows(3); synchronisedTextArea.setWordwrap(true); if (authenticationMethod.getLastSynchronised() != null) { synchronisedTextArea.setValue( "This directory was last synchronised at " + authenticationMethod.getLastSynchronised()); } else { synchronisedTextArea.setValue("This directory has not been synchronised"); } synchronisedTextArea.setSizeFull(); synchronisedTextArea.setReadOnly(true); operationsLayout.addComponent(synchronisedTextArea, 0, 1, 8, 1); HorizontalLayout orderLayout = new HorizontalLayout(); orderLayout.setWidth("50%"); if (authenticationMethod.getOrder() != 1) { Button upArrow = new Button(VaadinIcons.ARROW_UP); upArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY); upArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS); upArrow.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { if (authenticationMethod.getOrder() != 1) { AuthenticationMethod upAuthMethod = securityService .getAuthenticationMethodByOrder(authenticationMethod.getOrder() - 1); upAuthMethod.setOrder(authenticationMethod.getOrder()); authenticationMethod.setOrder(authenticationMethod.getOrder() - 1); securityService.saveOrUpdateAuthenticationMethod(upAuthMethod); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } } }); orderLayout.addComponent(upArrow); } long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods(); if (authenticationMethod.getOrder() != numberOfAuthMethods) { Button downArrow = new Button(VaadinIcons.ARROW_DOWN); downArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY); downArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS); downArrow.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods(); if (authenticationMethod.getOrder() != numberOfAuthMethods) { AuthenticationMethod downAuthMethod = securityService .getAuthenticationMethodByOrder(authenticationMethod.getOrder() + 1); downAuthMethod.setOrder(authenticationMethod.getOrder()); authenticationMethod.setOrder(authenticationMethod.getOrder() + 1); securityService.saveOrUpdateAuthenticationMethod(downAuthMethod); securityService.saveOrUpdateAuthenticationMethod(authenticationMethod); populateAll(); } } }); orderLayout.addComponent(downArrow); } this.directoryTable.addItem(new Object[] { authenticationMethod.getName(), "Microsoft Active Directory", orderLayout, operationsLayout }, authenticationMethod); }
From source file:org.ikasan.dashboard.ui.framework.panel.PersistanceSetupPanel.java
License:BSD License
protected void createNotCreatedView() { VerticalLayout verticalLayout = new VerticalLayout(); verticalLayout.setWidth("100%"); verticalLayout.setHeight("100%"); verticalLayout.setMargin(true);/*from w ww.j av a 2s . c om*/ Label ikasanWelcomeLabel1 = new Label("Welcome to Ikasan!"); ikasanWelcomeLabel1.setStyleName("xlarge"); ikasanWelcomeLabel1.setWidth("100%"); ikasanWelcomeLabel1.setHeight("30px"); Label ikasanWelcomeLabel2 = new Label("It appears that you are setting up Ikasan for the" + " first time and we need to create some database tables. If this is not the first time accessing the " + "Ikasan Console, it appears that there is an issue with the Ikasan database. If this is the case please " + "contact your local database administrator."); ikasanWelcomeLabel2.setStyleName("large"); ikasanWelcomeLabel2.setWidth("60%"); ikasanWelcomeLabel2.setHeight("70px"); verticalLayout.addComponent(ikasanWelcomeLabel1); verticalLayout.addComponent(ikasanWelcomeLabel2); verticalLayout.addComponent(persistanceStoreTypeCombo); persistanceStoreTypeCombo.setHeight("30px"); Button button = new Button("Create"); button.setStyleName(ValoTheme.BUTTON_SMALL); button.setHeight("30px"); button.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { String persistenceProvider = (String) PersistanceSetupPanel.this.persistanceStoreTypeCombo .getValue(); if (persistenceProvider == null) { Notification.show("Please select a database type!"); return; } PersistenceService persistanceService = persistenceServiceFactory .getPersistenceService(persistenceProvider); try { persistanceService.createPersistence(); persistanceService.createAdminAccount(); } catch (RuntimeException e) { StringWriter sw = new StringWriter(); PrintWriter pw = new PrintWriter(sw); e.printStackTrace(pw); Notification.show("Error trying to create Ikasan database!", sw.toString(), Notification.Type.ERROR_MESSAGE); } Notification.show("Database successfully created!"); } }); verticalLayout.addComponent(button); this.setContent(verticalLayout); }
From source file:org.ikasan.dashboard.ui.framework.window.IkasanMessageDialog.java
License:BSD License
/** * Helper method to initialise this object. * /*from w w w . java 2 s.c o m*/ * @param message */ protected void init(String message) { super.setModal(true); super.setResizable(false); super.center(); FormLayout layout = new FormLayout(); layout.setMargin(true); layout.addComponent(new Label(message)); Button okButton = new Button("OK"); okButton.setStyleName(ValoTheme.BUTTON_SMALL); okButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { action.exectuteAction(); close(); } }); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { action.ignoreAction(); close(); } }); HorizontalLayout wrapper = new HorizontalLayout(); wrapper.setWidth(100, Unit.PERCENTAGE); HorizontalLayout hlayout = new HorizontalLayout(); wrapper.addComponent(hlayout); wrapper.setComponentAlignment(hlayout, Alignment.MIDDLE_CENTER); hlayout.addComponent(okButton); hlayout.addComponent(cancelButton); layout.addComponent(wrapper); super.setContent(layout); }
From source file:org.ikasan.dashboard.ui.framework.window.LoginDialog.java
License:BSD License
/** * Helper method to initialise this object. * /*from w w w .j av a 2s. c o m*/ * @param userService * @param authProvider * @param visibilityGroup * @param userDetailsHelper * @param commitHandler */ protected void init(AuthenticationService authenticationService, VisibilityGroup visibilityGroup, final NavigationPanel commitHandler) { super.setModal(true); super.setResizable(false); super.center(); this.setWidth(300, Unit.PIXELS); this.setHeight(200, Unit.PIXELS); PropertysetItem item = new PropertysetItem(); item.addItemProperty(LoginFieldGroup.USERNAME, new ObjectProperty<String>("")); item.addItemProperty(LoginFieldGroup.PASSWORD, new ObjectProperty<String>("")); GridLayout form = new GridLayout(2, 4); form.setColumnExpandRatio(0, .15f); form.setColumnExpandRatio(1, .85f); form.setWidth(100, Unit.PERCENTAGE); form.setMargin(true); form.setSpacing(true); Label newTypeLabel = new Label("Login"); newTypeLabel.setStyleName(ValoTheme.LABEL_HUGE); form.addComponent(newTypeLabel, 0, 0, 1, 0); Label usernameLabel = new Label("Username:"); usernameLabel.setSizeUndefined(); form.addComponent(usernameLabel, 0, 1); form.setComponentAlignment(usernameLabel, Alignment.MIDDLE_RIGHT); final TextField userNameField = new TextField(); userNameField.addValidator(new StringLengthValidator("The username must not be empty", 1, null, true)); userNameField.setValidationVisible(false); userNameField.setStyleName("ikasan"); form.addComponent(userNameField, 1, 1); Label passwordLabel = new Label("Password:"); passwordLabel.setSizeUndefined(); form.addComponent(passwordLabel, 0, 2); form.setComponentAlignment(passwordLabel, Alignment.MIDDLE_RIGHT); final PasswordField passwordField = new PasswordField(); passwordField.setStyleName("ikasan"); passwordField.addValidator(new StringLengthValidator("The password must not be empty", 1, null, true)); passwordField.setValidationVisible(false); form.addComponent(passwordField, 1, 2); final LoginFieldGroup binder = new LoginFieldGroup(item, visibilityGroup, authenticationService); binder.bind(userNameField, LoginFieldGroup.USERNAME); binder.bind(passwordField, LoginFieldGroup.PASSWORD); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button loginButton = new Button("Login"); loginButton.addStyleName(ValoTheme.BUTTON_SMALL); loginButton.setClickShortcut(KeyCode.ENTER); loginButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { userNameField.validate(); passwordField.validate(); } catch (InvalidValueException e) { userNameField.setValidationVisible(true); passwordField.setValidationVisible(true); return; } try { binder.commit(); userNameField.setValue(""); passwordField.setValue(""); close(); commitHandler.postCommit(); } catch (CommitException e) { Notification.show(e.getMessage(), Notification.Type.ERROR_MESSAGE); } } }); buttons.addComponent(loginButton); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { close(); binder.discard(); } }); buttons.addComponent(cancelButton); form.addComponent(buttons, 0, 3, 1, 3); form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); this.setContent(form); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationSearchPanel.java
License:BSD License
/** * Helper method to initialise this object. */// w w w . ja v a 2 s . c o m @SuppressWarnings("serial") protected void init() { this.addStyleName(ValoTheme.PANEL_BORDERLESS); final Label typeLabel = new Label("Type:"); final Label sourceContextLabel = new Label("Source Context:"); final Label targetContextLabel = new Label("Target Context:"); final GridLayout contentLayout = new GridLayout(4, 6); contentLayout.setColumnExpandRatio(0, .15f); contentLayout.setColumnExpandRatio(1, .35f); contentLayout.setColumnExpandRatio(2, .05f); contentLayout.setColumnExpandRatio(3, .45f); contentLayout.setWidth("100%"); contentLayout.setSpacing(true); Label errorOccurrenceDetailsLabel = new Label("Mapping Configuration Search"); errorOccurrenceDetailsLabel.setStyleName(ValoTheme.LABEL_HUGE); contentLayout.addComponent(errorOccurrenceDetailsLabel, 0, 0, 1, 0); Label clientLabel = new Label("Client:"); clientLabel.setSizeUndefined(); contentLayout.addComponent(clientLabel, 0, 1); contentLayout.setComponentAlignment(clientLabel, Alignment.MIDDLE_RIGHT); this.clientComboBox.setWidth(80, Unit.PERCENTAGE); this.clientComboBox.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { if (event.getProperty() != null && event.getProperty().getValue() != null) { typeComboBox.refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName()); sourceContextComboBox .refresh(((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null); targetContextComboBox.refresh( ((ConfigurationServiceClient) event.getProperty().getValue()).getName(), null, null); typeLabel.setVisible(true); typeComboBox.setVisible(true); } } }); contentLayout.addComponent(clientComboBox, 1, 1); typeLabel.setSizeUndefined(); contentLayout.addComponent(typeLabel, 0, 2); contentLayout.setComponentAlignment(typeLabel, Alignment.MIDDLE_RIGHT); typeLabel.setVisible(false); this.typeComboBox.setWidth(80, Unit.PERCENTAGE); this.typeComboBox.setVisible(false); this.typeComboBox.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { String client = null; if (clientComboBox.getValue() != null) { client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName(); } if (event.getProperty() != null && event.getProperty().getValue() != null) { sourceContextComboBox.refresh(client, ((ConfigurationType) event.getProperty().getValue()).getName()); targetContextComboBox.refresh(client, ((ConfigurationType) event.getProperty().getValue()).getName(), null); sourceContextLabel.setVisible(true); sourceContextComboBox.setVisible(true); } } }); contentLayout.addComponent(this.typeComboBox, 1, 2); sourceContextLabel.setSizeUndefined(); contentLayout.addComponent(sourceContextLabel, 0, 3); contentLayout.setComponentAlignment(sourceContextLabel, Alignment.MIDDLE_RIGHT); sourceContextLabel.setVisible(false); this.sourceContextComboBox.setWidth(80, Unit.PERCENTAGE); this.sourceContextComboBox.setVisible(false); this.sourceContextComboBox.addValueChangeListener(new ValueChangeListener() { public void valueChange(ValueChangeEvent event) { String type = null; String client = null; if (typeComboBox.getValue() != null) { type = ((ConfigurationType) typeComboBox.getValue()).getName(); } if (clientComboBox.getValue() != null) { client = ((ConfigurationServiceClient) clientComboBox.getValue()).getName(); } if (event.getProperty() != null && event.getProperty().getValue() != null) { targetContextComboBox.refresh(client, type, ((ConfigurationContext) event.getProperty().getValue()).getName()); targetContextLabel.setVisible(true); targetContextComboBox.setVisible(true); } } }); contentLayout.addComponent(this.sourceContextComboBox, 1, 3); targetContextLabel.setSizeUndefined(); contentLayout.addComponent(targetContextLabel, 0, 4); contentLayout.setComponentAlignment(targetContextLabel, Alignment.MIDDLE_RIGHT); targetContextLabel.setVisible(false); this.targetContextComboBox.setWidth(80, Unit.PERCENTAGE); this.targetContextComboBox.setVisible(false); contentLayout.addComponent(this.targetContextComboBox, 1, 4); Label actionsLabel = newActions.getActionsLabel(); actionsLabel.setStyleName(ValoTheme.LABEL_HUGE); contentLayout.addComponent(actionsLabel, 2, 0, 3, 0); Label createNewClientLabel = newActions.getNewClientLabel(); createNewClientLabel.setSizeUndefined(); contentLayout.addComponent(createNewClientLabel, 2, 1); contentLayout.setComponentAlignment(createNewClientLabel, Alignment.MIDDLE_RIGHT); contentLayout.addComponent(newActions.getNewClientButton(), 3, 1); contentLayout.setComponentAlignment(newActions.getNewClientButton(), Alignment.MIDDLE_LEFT); Label createNewTypeLabel = newActions.getNewTypeLabel(); createNewTypeLabel.setSizeUndefined(); contentLayout.addComponent(createNewTypeLabel, 2, 2); contentLayout.setComponentAlignment(createNewTypeLabel, Alignment.MIDDLE_RIGHT); contentLayout.addComponent(newActions.getNewTypeButton(), 3, 2); contentLayout.setComponentAlignment(newActions.getNewTypeButton(), Alignment.MIDDLE_LEFT); Label createContextTypeLabel = newActions.getNewContextLabel(); createContextTypeLabel.setSizeUndefined(); contentLayout.addComponent(createContextTypeLabel, 2, 3); contentLayout.setComponentAlignment(createContextTypeLabel, Alignment.MIDDLE_RIGHT); contentLayout.addComponent(newActions.getNewContextButton(), 3, 3); contentLayout.setComponentAlignment(newActions.getNewContextButton(), Alignment.MIDDLE_LEFT); Label createMappingConfigurationLabel = newActions.getNewMappingConfigurationLabel(); createMappingConfigurationLabel.setSizeUndefined(); contentLayout.addComponent(createMappingConfigurationLabel, 2, 4); contentLayout.setComponentAlignment(createMappingConfigurationLabel, Alignment.MIDDLE_RIGHT); contentLayout.addComponent(newActions.getNewMappingConfigurationButton(), 3, 4); contentLayout.setComponentAlignment(newActions.getNewMappingConfigurationButton(), Alignment.MIDDLE_LEFT); Label importMappingConfigurationLabel = newActions.getImportMappingConfigurationLabel(); importMappingConfigurationLabel.setSizeUndefined(); contentLayout.addComponent(importMappingConfigurationLabel, 2, 5); contentLayout.setComponentAlignment(importMappingConfigurationLabel, Alignment.MIDDLE_RIGHT); contentLayout.addComponent(newActions.getImportMappingConfigurationButton(), 3, 5); contentLayout.setComponentAlignment(newActions.getImportMappingConfigurationButton(), Alignment.MIDDLE_LEFT); Button button = new Button("Search"); button.setStyleName(ValoTheme.BUTTON_SMALL); button.addClickListener(searchButtonClickListener); contentLayout.addComponent(button, 1, 5); this.setContent(contentLayout); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.panel.MappingConfigurationView.java
License:BSD License
/** * Helper method to initialise this object. *///from w w w . j a va2s. c om protected void init() { this.setSizeFull(); HorizontalLayout topContainer = new HorizontalLayout(); topContainer.setSizeFull(); topContainer.setMargin(true); topContainer.addComponent(this.searchPanel); HorizontalLayout bottomContainer = new HorizontalLayout(); bottomContainer.setMargin(true); bottomContainer.setSizeFull(); bottomContainer.addComponent(this.viewComponentContainer); 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); hideFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(false); showFilterButton.setVisible(true); splitPosition = verticalSplitPanel.getSplitPosition(); splitUnit = verticalSplitPanel.getSplitPositionUnit(); verticalSplitPanel.setSplitPosition(0, Unit.PIXELS); } }); showFilterButton.addClickListener(new Button.ClickListener() { public void buttonClick(ClickEvent event) { hideFilterButton.setVisible(true); showFilterButton.setVisible(false); verticalSplitPanel.setSplitPosition(splitPosition, splitUnit); } }); GridLayout filterButtonLayout = new GridLayout(2, 1); filterButtonLayout.setHeight(25, Unit.PIXELS); filterButtonLayout.addComponent(hideFilterButton, 0, 0); filterButtonLayout.addComponent(showFilterButton, 1, 0); this.verticalSplitPanel = new VerticalSplitPanel(topContainer, bottomContainer); this.verticalSplitPanel.addStyleName(ValoTheme.SPLITPANEL_LARGE); this.verticalSplitPanel.setSizeFull(); this.verticalSplitPanel.setSplitPosition(260, 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(verticalSplitPanel); this.setContent(wrapper); }
From source file:org.ikasan.dashboard.ui.mappingconfiguration.window.MappingConfigurationImportWindow.java
License:BSD License
/** * Helper method to initialise this object. */// ww w .j a va 2s . c om 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. *///from w w w .j a v a2 s .c om 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.mappingconfiguration.window.NewClientWindow.java
License:BSD License
/** * Helper method to initialise this object. *//* ww w . j a v a 2s. co m*/ protected void init() { this.setStyleName("dashboard"); this.setModal(true); this.setWidth(800, Unit.PIXELS); this.setHeight(180, Unit.PIXELS); PropertysetItem item = new PropertysetItem(); item.addItemProperty(NewClientFieldGroup.NAME, new ObjectProperty<String>("")); item.addItemProperty(NewClientFieldGroup.KEY_LOCATION_QUERY_PROCESSOR_TYPE, new ObjectProperty<String>( "org.ikasan.mapping.keyQueryProcessor.impl.XPathKeyLocationQueryProcessor")); GridLayout form = new GridLayout(2, 4); form.setWidth(100, Unit.PERCENTAGE); form.setMargin(true); form.setSpacing(true); Label newClientLabel = new Label("New Mapping Configuration Client"); newClientLabel.setStyleName(ValoTheme.LABEL_HUGE); form.addComponent(newClientLabel, 0, 0, 1, 0); Label nameLabel = new Label("Name:"); nameLabel.setSizeUndefined(); form.addComponent(nameLabel, 0, 1); form.setComponentAlignment(nameLabel, Alignment.MIDDLE_RIGHT); nameField.addValidator(new StringLengthValidator("The name must not be blank!", 1, 256, true)); nameField.setValidationVisible(false); nameField.setStyleName("ikasan"); form.addComponent(nameField, 1, 1); Label keyLocationLabel = new Label("Key Location Query Processor Type:"); keyLocationLabel.setSizeUndefined(); form.addComponent(keyLocationLabel, 0, 2); form.setComponentAlignment(keyLocationLabel, Alignment.MIDDLE_RIGHT); TextField keyLocationQueryProcessorTypeField = new TextField(); keyLocationQueryProcessorTypeField.setStyleName("ikasan"); keyLocationQueryProcessorTypeField.setWidth(500, Unit.PIXELS); form.addComponent(keyLocationQueryProcessorTypeField, 1, 2); final NewClientFieldGroup binder = new NewClientFieldGroup(item, this.refreshGroup, this.mappingConfigurationService, this.systemEventService); binder.bind(nameField, "name"); binder.bind(keyLocationQueryProcessorTypeField, "keyLocationQueryProcessorType"); keyLocationQueryProcessorTypeField.setReadOnly(true); HorizontalLayout buttons = new HorizontalLayout(); buttons.setSpacing(true); Button saveButton = new Button("Save"); saveButton.setStyleName(ValoTheme.BUTTON_SMALL); saveButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { try { nameField.validate(); } catch (InvalidValueException e) { nameField.setValidationVisible(true); return; } try { binder.commit(); UI.getCurrent().getNavigator().navigateTo("emptyPanel"); nameField.setValue(""); Notification.show("New Mapping Configuration Client Successfully Created!"); saveRequiredMonitor.setSaveRequired(false); close(); } catch (CommitException e) { Notification.show("An error has occurred saving a new client: " + e.getMessage()); } } }); buttons.addComponent(saveButton); Button cancelButton = new Button("Cancel"); cancelButton.setStyleName(ValoTheme.BUTTON_SMALL); cancelButton.addClickListener(new ClickListener() { @Override public void buttonClick(ClickEvent event) { UI.getCurrent().getNavigator().navigateTo("emptyPanel"); binder.discard(); saveRequiredMonitor.setSaveRequired(false); close(); } }); buttons.addComponent(cancelButton); form.addComponent(buttons, 0, 3, 1, 3); form.setComponentAlignment(buttons, Alignment.MIDDLE_CENTER); this.setContent(form); }