Example usage for com.vaadin.server Page getCurrent

List of usage examples for com.vaadin.server Page getCurrent

Introduction

In this page you can find the example usage for com.vaadin.server Page getCurrent.

Prototype

public static Page getCurrent() 

Source Link

Document

Gets the Page to which the current uI belongs.

Usage

From source file:org.geant.sat.ui.MainUI.java

License:BSD License

/**
 * Method to load language resources.//from   w  w w .j ava2 s  . c  om
 */
protected void initLanguageBundle() {
    Locale locale = Locale.ENGLISH;
    if (Page.getCurrent() != null && Page.getCurrent().getWebBrowser() != null
            && Page.getCurrent().getWebBrowser().getLocale() != null) {
        locale = Page.getCurrent().getWebBrowser().getLocale();
    }
    try {
        languageBundle = ResourceBundle.getBundle("Language", locale);
    } catch (MissingResourceException e) {
        LOG.debug("language file for " + locale + " not found, reverting to default");
        languageBundle = ResourceBundle.getBundle("Language", Locale.ROOT);
    }
}

From source file:org.groom.shell.Shell.java

License:Apache License

/**
 * Executes requested shell command./*from w  w  w . j a  v  a2  s  .c o m*/
 *
 * @param cmd the shell command to execute
 */
public static String execute(final String cmd, final String path) {
    LOGGER.debug("Executing shell command: " + cmd);
    try {

        if (UI.getCurrent() != null) {
            Notification.show(cmd, Notification.Type.TRAY_NOTIFICATION);
        }

        List<String> commands = new ArrayList<String>();
        if (PropertiesUtil.getProperty("groom", "os").equals("windows")) {
            commands.add("cmd");
            commands.add("/c");
            commands.add(cmd);
        } else {
            commands.add("/bin/sh");
            commands.add("-c");
            commands.add(cmd);
        }

        SystemCommandExecutor commandExecutor = new SystemCommandExecutor(path, commands);
        commandExecutor.executeCommand();

        StringBuilder errorOutput = commandExecutor.getErrorOutput();
        if (errorOutput.length() > 0) {
            LOGGER.error(errorOutput);
            {
                if (UI.getCurrent() != null) {
                    final Notification notification = new Notification("Shell", errorOutput.toString(),
                            Notification.Type.WARNING_MESSAGE);
                    notification.setDelayMsec(5000);
                    notification.setPosition(Position.BOTTOM_RIGHT);
                    notification.show(Page.getCurrent());
                }
            }
        }
        StringBuilder standardOutput = commandExecutor.getStandardOutput();
        if (standardOutput == null) {
            return "";
        }

        return standardOutput.toString();
    } catch (final Throwable t) {
        LOGGER.error("Error executing shell command: " + cmd, t);
        return "";
    }
}

From source file:org.hip.vif.admin.admin.ui.ReindexView.java

License:Open Source License

/** Constructor
 *
 * @param inTask {@link RefreshIndexTask} */
public ReindexView(final RefreshIndexTask inTask) {
    super();//from w  w  w .j  a v a  2 s .  c o m
    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "admin.reindex.title.page"); //$NON-NLS-1$

    final CheckBox lContentIndex = createCheckbox(lMessages.getMessage("admin.reindex.check.content"), //$NON-NLS-1$
            Constants.INDEX_CONTENT);
    lContentIndex.focus();
    lLayout.addComponent(lContentIndex);
    lLayout.addComponent(
            new Label(String.format(FORMAT_LABEL, lMessages.getMessage("admin.reindex.label.content")), //$NON-NLS-1$
                    ContentMode.HTML));
    final CheckBox lPersonIndex = createCheckbox(lMessages.getMessage("admin.reindex.check.person"), //$NON-NLS-1$
            Constants.INDEX_MEMBER);
    lLayout.addComponent(lPersonIndex);
    lLayout.addComponent(new Label(
            String.format(FORMAT_LABEL, lMessages.getMessage("admin.reindex.label.person")), ContentMode.HTML)); //$NON-NLS-1$

    lLayout.addComponent(RiplaViewHelper.createSpacer());
    reindex = new Button(lMessages.getMessage("admin.reindex.button.start")); //$NON-NLS-1$
    reindex.setClickShortcut(KeyCode.ENTER);
    reindex.setEnabled(false);
    reindex.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) { // NOPMD
            try {
                final String lFeedback = inTask.reindex(checkBoxes);
                new Notification(lMessages.getMessage("admin.reindex.check.content"), lFeedback,
                        Type.TRAY_NOTIFICATION, true).show(Page.getCurrent());
            } catch (final Exception exc) { // NOPMD
                LOG.error("Error encountered during search index refresh!", exc);
                Notification.show(lMessages.getMessage("errmsg.reindex"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });

    lLayout.addComponent(reindex);
}

From source file:org.hip.vif.app.admin.AdminApplication.java

License:Open Source License

@Override
protected void beforeInitializeLayout() { // NOPMD
    VIFAppHelper.initializeContext();/*w  ww . j  av  a 2s  .  co  m*/
    Page.getCurrent().setTitle(APP_NAME);

    eventDispatcher = new VIFEventDispatcher();
    eventDispatcher.setApplication(this);
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(IVIFEventDispatcher.class, eventDispatcher);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
    final DBConnectionProber lDBProber = new DBConnectionProber();
    if (lDBProber.isReady()) {
        initializePermissions();
    }
    super.beforeInitializeLayout();
}

From source file:org.hip.vif.app.forum.ForumApplication.java

License:Open Source License

@Override
protected void beforeInitializeLayout() { // NOPMD
    VIFAppHelper.initializeContext();/*from   w ww . j a  va2s . co  m*/
    Page.getCurrent().setTitle(APP_NAME);

    eventDispatcher = new VIFEventDispatcher();
    try {
        VaadinSession.getCurrent().getLockInstance().lock();
        VaadinSession.getCurrent().setAttribute(IVIFEventDispatcher.class, eventDispatcher);
    } finally {
        VaadinSession.getCurrent().getLockInstance().unlock();
    }
    initializePermissions();
    super.beforeInitializeLayout();
}

From source file:org.hip.vif.web.util.VIFAppHelper.java

License:Open Source License

/** Creates an instance of <code>IAuthenticator</code> for the <code>org.ripla.interfaces.IAppConfiguration</code>.
 *
 * @return {@link IAuthenticator} */
public static IAuthenticator createLoginAuthenticator() {
    return new IAuthenticator() {

        @Override/*from  w w  w .  java2  s.com*/
        public User authenticate(final String inName, // NOPMD
                final String inPassword, final UserAdmin inUserAdmin) throws LoginException {
            try {
                // first we check whether the user can be authenticated
                // this will create an OSGi user object when the VIF user is set to the context
                MemberUtility.INSTANCE.getActiveAuthenticator().checkAuthentication(inName, inPassword);
                // if authentication is successful, we can retrieve the OSGi user object from the user admin
                // instance
                return inUserAdmin.getUser(ApplicationConstants.VIF_USER, inName);
            } catch (final InvalidAuthenticationException exc) {
                final StringBuilder lLog = new StringBuilder(200);
                lLog.append(NL).append("   Note: Invalid try to authenticate:").append(NL).append("   User: ")
                        .append(inName).append(NL).append("   IP number: ")
                        .append(Page.getCurrent().getWebBrowser().getAddress()).append(NL);
                LOG.warn(new String(lLog));
                throw new LoginException(exc.getMessage()); // NOPMD
            } catch (final VException | SQLException exc) {
                LOG.warn("Problem during login encoutered!", exc);
                throw new LoginException(exc.getMessage()); // NOPMD
            }
        }
    };
}

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);//from  w  w  w.  j av a2s .  co  m
    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.framework.action.LogoutAction.java

License:BSD License

@Override
public void exectuteAction() {
    VaadinService.getCurrentRequest().getWrappedSession().setAttribute(DashboardSessionValueConstants.USER,
            null);//from   www.  j  a  va 2  s  .co  m
    this.visibilityGroup.setVisible();
    this.editableGroup.setEditable(false);

    layout.removeComponent(this.logOutButton);
    layout.addComponent(this.loginButton, 2, 0);
    layout.addComponent(this.setupButton, 3, 0);
    layout.setComponentAlignment(this.setupButton, Alignment.MIDDLE_RIGHT);
    layout.setComponentAlignment(this.loginButton, Alignment.MIDDLE_RIGHT);
    this.layout.removeComponent(userLabel);

    VaadinSession vSession = VaadinSession.getCurrent();
    WrappedSession httpSession = vSession.getSession();

    this.navigationPanel.reset();

    //Invalidate HttpSession
    httpSession.invalidate();
    vSession.close();
    //Redirect the user to the login/default Page
    Page.getCurrent().setLocation("/ikasan-dashboard");
}

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 www  .  ja v a 2 s .  co m

        logger.info("Configuration Url: " + url);

        IkasanAuthentication authentication = (IkasanAuthentication) VaadinService.getCurrentRequest()
                .getWrappedSession().getAttribute(DashboardSessionValueConstants.USER);

        HttpAuthenticationFeature feature = HttpAuthenticationFeature.basic(authentication.getName(),
                (String) authentication.getCredentials());

        ClientConfig clientConfig = new ClientConfig();
        clientConfig.register(feature);

        Client client = ClientBuilder.newClient(clientConfig);

        ObjectMapper mapper = new ObjectMapper();

        WebTarget webTarget = client.target(url);

        Response response = webTarget.request().get();

        if (response.getStatus() != 200) {
            response.bufferEntity();

            String responseMessage = response.readEntity(String.class);
            Notification.show("An error was received trying to create configured resource '"
                    + component.getConfigurationId() + "': " + responseMessage, Type.ERROR_MESSAGE);
        }

        configuration = this.configurationManagement.getConfiguration(component.getConfigurationId());
    }

    final List<ConfigurationParameter> parameters = (List<ConfigurationParameter>) configuration
            .getParameters();

    this.layout = new GridLayout(2, parameters.size() + 6);
    this.layout.setSpacing(true);
    this.layout.setColumnExpandRatio(0, .25f);
    this.layout.setColumnExpandRatio(1, .75f);

    this.layout.setWidth("95%");
    this.layout.setMargin(true);

    Label configurationParametersLabel = new Label("Configuration Parameters");
    configurationParametersLabel.setStyleName(ValoTheme.LABEL_HUGE);
    this.layout.addComponent(configurationParametersLabel, 0, 0);

    GridLayout paramLayout = new GridLayout(2, 2);
    paramLayout.setSpacing(true);
    paramLayout.setSizeFull();
    paramLayout.setMargin(true);
    paramLayout.setColumnExpandRatio(0, .25f);
    paramLayout.setColumnExpandRatio(1, .75f);

    Label configuredResourceIdLabel = new Label("Configured Resource Id");
    configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_LARGE);
    configuredResourceIdLabel.addStyleName(ValoTheme.LABEL_BOLD);
    Label configuredResourceIdValueLabel = new Label(configuration.getConfigurationId());
    configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_LARGE);
    configuredResourceIdValueLabel.addStyleName(ValoTheme.LABEL_BOLD);

    paramLayout.addComponent(configuredResourceIdLabel, 0, 0);
    paramLayout.setComponentAlignment(configuredResourceIdLabel, Alignment.TOP_RIGHT);
    paramLayout.addComponent(configuredResourceIdValueLabel, 1, 0);

    Label configurationDescriptionLabel = new Label("Description:");
    configurationDescriptionLabel.setSizeUndefined();
    paramLayout.addComponent(configurationDescriptionLabel, 0, 1);
    paramLayout.setComponentAlignment(configurationDescriptionLabel, Alignment.TOP_RIGHT);

    TextArea conmfigurationDescriptionTextField = new TextArea();
    conmfigurationDescriptionTextField.setRows(4);
    conmfigurationDescriptionTextField.setWidth("80%");
    paramLayout.addComponent(conmfigurationDescriptionTextField, 1, 1);

    this.layout.addComponent(paramLayout, 0, 1, 1, 1);

    int i = 2;

    for (ConfigurationParameter parameter : parameters) {
        if (parameter instanceof ConfigurationParameterIntegerImpl) {
            this.layout.addComponent(
                    this.createTextAreaPanel(parameter, new IntegerValidator("Must be a valid number")), 0, i,
                    1, i);
        } else if (parameter instanceof ConfigurationParameterStringImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new StringValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterBooleanImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new BooleanValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterLongImpl) {
            this.layout.addComponent(this.createTextAreaPanel(parameter, new LongValidator()), 0, i, 1, i);
        } else if (parameter instanceof ConfigurationParameterMapImpl) {
            this.layout.addComponent(this.createMapPanel((ConfigurationParameterMapImpl) parameter), 0, i, 1,
                    i);
        } else if (parameter instanceof ConfigurationParameterListImpl) {
            this.layout.addComponent(this.createListPanel((ConfigurationParameterListImpl) parameter), 0, i, 1,
                    i);
        }

        i++;
    }

    Button saveButton = new Button("Save");
    saveButton.addStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                for (TextArea textField : textFields.values()) {
                    textField.validate();
                }
            } catch (InvalidValueException e) {
                e.printStackTrace();
                for (TextArea textField : textFields.values()) {
                    textField.setValidationVisible(true);
                }

                Notification.show("There are errors on the form above", Type.ERROR_MESSAGE);

                return;
            }

            for (ConfigurationParameter parameter : parameters) {
                TextArea textField = ComponentConfigurationWindow.this.textFields.get(parameter.getName());
                TextArea descriptionTextField = ComponentConfigurationWindow.this.descriptionTextFields
                        .get(parameter.getName());

                if (parameter != null && descriptionTextField != null) {
                    parameter.setDescription(descriptionTextField.getValue());
                }

                if (parameter instanceof ConfigurationParameterIntegerImpl) {
                    logger.info("Setting Integer value: " + textField.getValue());

                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Integer(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterStringImpl) {
                    logger.info("Setting String value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(textField.getValue());
                } else if (parameter instanceof ConfigurationParameterBooleanImpl) {
                    logger.info("Setting Boolean value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Boolean(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterLongImpl) {
                    logger.info("Setting Boolean value: " + textField.getValue());
                    if (textField.getValue() != null && textField.getValue().length() > 0)
                        parameter.setValue(new Long(textField.getValue()));
                } else if (parameter instanceof ConfigurationParameterMapImpl) {
                    ConfigurationParameterMapImpl mapParameter = (ConfigurationParameterMapImpl) parameter;

                    HashMap<String, String> map = new HashMap<String, String>();

                    logger.info("Saving map: " + mapTextFields.size());

                    for (String key : mapTextFields.keySet()) {
                        if (key.startsWith(parameter.getName())) {
                            TextFieldKeyValuePair pair = mapTextFields.get(key);

                            logger.info("Saving for key: " + key);

                            if (pair.key.getValue() != "") {
                                map.put(pair.key.getValue(), pair.value.getValue());
                            }
                        }
                    }

                    parameter.setValue(map);
                } else if (parameter instanceof ConfigurationParameterListImpl) {
                    ConfigurationParameterListImpl mapParameter = (ConfigurationParameterListImpl) parameter;

                    ArrayList<String> map = new ArrayList<String>();

                    for (String key : valueTextFields.keySet()) {
                        if (key.startsWith(parameter.getName())) {
                            map.add(valueTextFields.get(key).getValue());
                        }
                    }

                    parameter.setValue(map);
                }

            }

            ComponentConfigurationWindow.this.configurationManagement.saveConfiguration(configuration);

            Notification notification = new Notification("Saved",
                    "The configuration has been saved successfully!", Type.HUMANIZED_MESSAGE);
            notification.setStyleName(ValoTheme.NOTIFICATION_CLOSABLE);
            notification.show(Page.getCurrent());
        }
    });

    Button deleteButton = new Button("Delete");
    deleteButton.addStyleName(ValoTheme.BUTTON_SMALL);
    deleteButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            DeleteConfigurationAction action = new DeleteConfigurationAction(configuration,
                    configurationManagement, ComponentConfigurationWindow.this);

            IkasanMessageDialog dialog = new IkasanMessageDialog("Delete configuration",
                    "Are you sure you would like to delete this configuration?", action);

            UI.getCurrent().addWindow(dialog);
        }
    });

    GridLayout buttonLayout = new GridLayout(2, 1);
    buttonLayout.setSpacing(true);
    buttonLayout.addComponent(saveButton, 0, 0);
    buttonLayout.addComponent(deleteButton, 1, 0);

    this.layout.addComponent(buttonLayout, 0, i, 1, i);
    this.layout.setComponentAlignment(buttonLayout, Alignment.MIDDLE_CENTER);

    Panel configurationPanel = new Panel();
    configurationPanel.setContent(this.layout);

    this.setContent(configurationPanel);
}

From source file:org.jdal.vaadin.VaadinUtils.java

License:Apache License

/**
 * Exit application//from w w w . ja  va2s .  c o m
 */
public static void exit() {
    UI.getCurrent().close();
    VaadinSession.getCurrent().close();
    Page page = Page.getCurrent();
    String location = StringUtils.substringBeforeLast(page.getLocation().toString(), page.getUriFragment());
    location = StringUtils.substringAfterLast(location, "#");
    page.setLocation(location);

}