Example usage for com.vaadin.ui TextField getValue

List of usage examples for com.vaadin.ui TextField getValue

Introduction

In this page you can find the example usage for com.vaadin.ui TextField getValue.

Prototype

@Override
    public String getValue() 

Source Link

Usage

From source file:org.airline.CelestiaLogin.java

@Override
protected void init(VaadinRequest request) {
    //Vista final para la UI
    final VerticalLayout layout = new VerticalLayout();

    Panel loginPanel = new Panel("Login");
    CustomLayout login = new CustomLayout("LoginLayout");
    //Seccin de Vista del Login
    //VerticalLayout login=new VerticalLayout(); 
    Label label = new Label("Iniciar Sesin / Registrarse");
    TextField user = new TextField("", "Usuario");
    TextField passwd = new TextField("", "Contrasea");

    Button init_session = new Button("Iniciar Sesin");
    init_session.setStyleName(ValoTheme.BUTTON_PRIMARY);
    init_session.addClickListener(cliqueo -> {
        Notification.show("Bienvenido " + user.getValue());
    });/*from   w  w  w  .j  a va 2  s  .c  o  m*/

    login.addComponent(label);
    login.addComponent(user);
    login.addComponent(passwd);
    login.addComponent(init_session);
    login.setWidth("500px");
    //login.setMargin(true);
    login.setResponsive(true);

    layout.addComponent(login);
    layout.setComponentAlignment(login, Alignment.MIDDLE_CENTER);
    setContent(login);
}

From source file:org.apache.ace.webui.vaadin.AddArtifactWindow.java

License:Apache License

/**
 * Creates a new {@link AddArtifactWindow} instance.
 * //from  w  ww  .jav a 2 s  . c  om
 * @param sessionDir
 *            the session directory to temporary place artifacts in;
 * @param obrUrl
 *            the URL of the OBR to use.
 */
public AddArtifactWindow(File sessionDir, URL obrUrl, String repositoryXML) {
    super("Add artifact");

    m_sessionDir = sessionDir;
    m_obrUrl = obrUrl;
    m_repositoryXML = repositoryXML;

    setModal(true);
    setWidth("50em");
    setCloseShortcut(KeyCode.ESCAPE);

    m_artifactsTable = new Table("Artifacts in repository");
    m_artifactsTable.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null);
    m_artifactsTable.addContainerProperty(PROPERTY_VERSION, String.class, null);
    m_artifactsTable.addContainerProperty(PROPERTY_PURGE, Button.class, null);
    m_artifactsTable.setSizeFull();
    m_artifactsTable.setSelectable(true);
    m_artifactsTable.setMultiSelect(true);
    m_artifactsTable.setImmediate(true);
    m_artifactsTable.setHeight("15em");

    final Table uploadedArtifacts = new Table("Uploaded artifacts");
    uploadedArtifacts.addContainerProperty(PROPERTY_SYMBOLIC_NAME, String.class, null);
    uploadedArtifacts.addContainerProperty(PROPERTY_VERSION, String.class, null);
    uploadedArtifacts.setSizeFull();
    uploadedArtifacts.setSelectable(false);
    uploadedArtifacts.setMultiSelect(false);
    uploadedArtifacts.setImmediate(true);
    uploadedArtifacts.setHeight("15em");

    final GenericUploadHandler uploadHandler = new GenericUploadHandler(m_sessionDir) {
        @Override
        public void updateProgress(long readBytes, long contentLength) {
            // TODO Auto-generated method stub
        }

        @Override
        protected void artifactsUploaded(List<UploadHandle> uploads) {
            for (UploadHandle handle : uploads) {
                try {
                    URL artifact = handle.getFile().toURI().toURL();

                    Item item = uploadedArtifacts.addItem(artifact);
                    item.getItemProperty(PROPERTY_SYMBOLIC_NAME).setValue(handle.getFilename());
                    item.getItemProperty(PROPERTY_VERSION).setValue("");

                    m_uploadedArtifacts.add(handle.getFile());
                } catch (MalformedURLException e) {
                    showErrorNotification("Upload artifact processing failed",
                            "<br />Reason: " + e.getMessage());
                    logError("Processing of " + handle.getFilename() + " failed.", e);
                }
            }
        }
    };

    final Upload uploadArtifact = new Upload();
    uploadArtifact.setCaption("Upload Artifact");
    uploadHandler.install(uploadArtifact);

    final DragAndDropWrapper finalUploadedArtifacts = new DragAndDropWrapper(uploadedArtifacts);
    finalUploadedArtifacts.setDropHandler(new ArtifactDropHandler(uploadHandler));

    addListener(new Window.CloseListener() {
        public void windowClose(CloseEvent e) {
            for (File artifact : m_uploadedArtifacts) {
                artifact.delete();
            }
        }
    });

    HorizontalLayout searchBar = new HorizontalLayout();
    searchBar.setMargin(false);
    searchBar.setSpacing(true);

    final TextField searchField = new TextField();
    searchField.setImmediate(true);
    searchField.setValue("");

    final IndexedContainer dataSource = (IndexedContainer) m_artifactsTable.getContainerDataSource();

    m_searchButton = new Button("Search", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            String searchValue = (String) searchField.getValue();

            dataSource.removeAllContainerFilters();

            if (searchValue != null && searchValue.trim().length() > 0) {
                dataSource.addContainerFilter(PROPERTY_SYMBOLIC_NAME, searchValue, true /* ignoreCase */,
                        false /* onlyMatchPrefix */);
            }
        }
    });
    m_searchButton.setImmediate(true);

    searchBar.addComponent(searchField);
    searchBar.addComponent(m_searchButton);

    m_addButton = new Button("Add", new ClickListener() {
        public void buttonClick(ClickEvent event) {
            // Import all "local" (existing) bundles...
            importLocalBundles(m_artifactsTable);
            // Import all "remote" (non existing) bundles...
            importRemoteBundles(m_uploadedArtifacts);

            close();
        }
    });
    m_addButton.setImmediate(true);
    m_addButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    m_addButton.setClickShortcut(KeyCode.ENTER);

    VerticalLayout layout = (VerticalLayout) getContent();
    layout.setMargin(true);
    layout.setSpacing(true);

    layout.addComponent(searchBar);
    layout.addComponent(m_artifactsTable);
    layout.addComponent(uploadArtifact);
    layout.addComponent(finalUploadedArtifacts);
    // The components added to the window are actually added to the window's
    // layout; you can use either. Alignments are set using the layout
    layout.addComponent(m_addButton);
    layout.setComponentAlignment(m_addButton, Alignment.MIDDLE_RIGHT);

    searchField.focus();
}

From source file:org.apache.ace.webui.vaadin.LoginWindow.java

License:Apache License

/**
 * Creates a new {@link LoginWindow} instance.
 * /*from  ww w . jav a 2 s.c  o  m*/
 * @param log
 *            the log service to use;
 * @param loginFunction
 *            the login callback to use.
 */
public LoginWindow(LogService log, LoginFunction loginFunction) {
    super("Apache ACE Login");

    m_log = log;
    m_loginFunction = loginFunction;

    setResizable(false);
    setClosable(false);
    setModal(true);
    setWidth("20em");

    m_additionalInfo = new Label("");
    m_additionalInfo.setImmediate(true);
    m_additionalInfo.setStyleName("alert");
    m_additionalInfo.setHeight("1.2em");
    // Ensures the information message disappears when starting typing...
    FieldEvents.TextChangeListener changeListener = new FieldEvents.TextChangeListener() {
        @Override
        public void textChange(TextChangeEvent event) {
            m_additionalInfo.setValue("");
        }
    };

    final TextField nameField = new TextField("Name", "");
    nameField.addListener(changeListener);
    nameField.setImmediate(true);
    nameField.setWidth("100%");

    final PasswordField passwordField = new PasswordField("Password", "");
    passwordField.addListener(changeListener);
    passwordField.setImmediate(true);
    passwordField.setWidth("100%");

    Button loginButton = new Button("Login");
    loginButton.setImmediate(true);
    // Allow enter to be used to login directly...
    loginButton.setClickShortcut(KeyCode.ENTER);
    // Highlight this button as the default one...
    loginButton.addStyleName(Reindeer.BUTTON_DEFAULT);

    loginButton.addListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            Button button = event.getButton();
            button.setEnabled(false);

            try {
                String username = (String) nameField.getValue();
                String password = (String) passwordField.getValue();

                if (m_loginFunction.login(username, password)) {
                    m_log.log(LogService.LOG_INFO, "Apache Ace WebUI succesfull login by user: " + username);

                    closeWindow();
                } else {
                    m_log.log(LogService.LOG_WARNING, "Apache Ace WebUI invalid username or password entered.");

                    m_additionalInfo.setValue("Invalid username or password!");

                    nameField.focus();
                    nameField.selectAll();
                }
            } finally {
                button.setEnabled(true);
            }
        }
    });

    final VerticalLayout content = (VerticalLayout) getContent();
    content.setSpacing(true);
    content.setMargin(true);
    content.setSizeFull();

    content.addComponent(nameField);
    content.addComponent(passwordField);
    content.addComponent(m_additionalInfo);
    content.addComponent(loginButton);

    content.setComponentAlignment(loginButton, Alignment.BOTTOM_CENTER);

    nameField.focus();
}

From source file:org.asi.ui.pagedtable.PagedTable.java

License:Apache License

public HorizontalLayout createControls(PagedControlConfig config) {
    Label itemsPerPageLabel = new Label(config.getItemsPerPage(), ContentMode.HTML);
    itemsPerPageLabel.setSizeUndefined();
    final ComboBox itemsPerPageSelect = new ComboBox();

    for (Integer i : config.getPageLengths()) {
        itemsPerPageSelect.addItem(i);//  w  ww .j  av  a  2s  . c o m
        itemsPerPageSelect.setItemCaption(i, String.valueOf(i));
    }
    itemsPerPageSelect.setImmediate(true);
    itemsPerPageSelect.setNullSelectionAllowed(false);
    itemsPerPageSelect.setWidth(null);
    itemsPerPageSelect.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            setPageLength((Integer) event.getProperty().getValue());
        }
    });
    if (itemsPerPageSelect.containsId(getPageLength())) {
        itemsPerPageSelect.select(getPageLength());
    } else {
        itemsPerPageSelect.select(itemsPerPageSelect.getItemIds().iterator().next());
    }
    Label pageLabel = new Label(config.getPage(), ContentMode.HTML);
    final TextField currentPageTextField = new TextField();
    currentPageTextField.setValue(String.valueOf(getCurrentPage()));
    currentPageTextField.setConverter(new StringToIntegerConverter() {
        @Override
        protected NumberFormat getFormat(Locale locale) {
            NumberFormat result = super.getFormat(UI.getCurrent().getLocale());
            result.setGroupingUsed(false);
            return result;
        }
    });
    Label separatorLabel = new Label("&nbsp;/&nbsp;", ContentMode.HTML);
    final Label totalPagesLabel = new Label(String.valueOf(getTotalAmountOfPages()), ContentMode.HTML);
    currentPageTextField.setStyleName(Reindeer.TEXTFIELD_SMALL);
    currentPageTextField.setImmediate(true);
    currentPageTextField.addValueChangeListener(new Property.ValueChangeListener() {
        private static final long serialVersionUID = -2255853716069800092L;

        @Override
        public void valueChange(com.vaadin.data.Property.ValueChangeEvent event) {
            if (currentPageTextField.isValid() && currentPageTextField.getValue() != null) {
                int page = Integer.valueOf(String.valueOf(currentPageTextField.getValue()));
                setCurrentPage(page);
            }
        }
    });
    pageLabel.setWidth(null);
    currentPageTextField.setColumns(3);
    separatorLabel.setWidth(null);
    totalPagesLabel.setWidth(null);

    HorizontalLayout controlBar = new HorizontalLayout();
    HorizontalLayout pageSize = new HorizontalLayout();
    HorizontalLayout pageManagement = new HorizontalLayout();
    final Button first = new Button(config.getFirst(), new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(0);
        }
    });
    final Button previous = new Button(config.getPrevious(), new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            previousPage();
        }
    });
    final Button next = new Button(config.getNext(), new Button.ClickListener() {
        private static final long serialVersionUID = -1927138212640638452L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            nextPage();
        }
    });
    final Button last = new Button(config.getLast(), new Button.ClickListener() {
        private static final long serialVersionUID = -355520120491283992L;

        @Override
        public void buttonClick(Button.ClickEvent event) {
            setCurrentPage(getTotalAmountOfPages());
        }
    });
    first.setStyleName(Reindeer.BUTTON_LINK);
    previous.setStyleName(Reindeer.BUTTON_LINK);
    next.setStyleName(Reindeer.BUTTON_LINK);
    last.setStyleName(Reindeer.BUTTON_LINK);

    itemsPerPageLabel.addStyleName("pagedtable-itemsperpagecaption");
    itemsPerPageSelect.addStyleName("pagedtable-itemsperpagecombobox");
    pageLabel.addStyleName("pagedtable-pagecaption");
    currentPageTextField.addStyleName("pagedtable-pagefield");
    separatorLabel.addStyleName("pagedtable-separator");
    totalPagesLabel.addStyleName("pagedtable-total");
    first.addStyleName("pagedtable-first");
    previous.addStyleName("pagedtable-previous");
    next.addStyleName("pagedtable-next");
    last.addStyleName("pagedtable-last");

    itemsPerPageLabel.addStyleName("pagedtable-label");
    itemsPerPageSelect.addStyleName("pagedtable-combobox");
    pageLabel.addStyleName("pagedtable-label");
    currentPageTextField.addStyleName("pagedtable-label");
    separatorLabel.addStyleName("pagedtable-label");
    totalPagesLabel.addStyleName("pagedtable-label");
    first.addStyleName("pagedtable-button");
    previous.addStyleName("pagedtable-button");
    next.addStyleName("pagedtable-button");
    last.addStyleName("pagedtable-button");

    pageSize.addComponent(itemsPerPageLabel);
    pageSize.addComponent(itemsPerPageSelect);
    pageSize.setComponentAlignment(itemsPerPageLabel, Alignment.MIDDLE_LEFT);
    pageSize.setComponentAlignment(itemsPerPageSelect, Alignment.MIDDLE_LEFT);
    pageSize.setSpacing(true);
    pageManagement.addComponent(first);
    pageManagement.addComponent(previous);
    pageManagement.addComponent(pageLabel);
    pageManagement.addComponent(currentPageTextField);
    pageManagement.addComponent(separatorLabel);
    pageManagement.addComponent(totalPagesLabel);
    pageManagement.addComponent(next);
    pageManagement.addComponent(last);
    pageManagement.setComponentAlignment(first, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(previous, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(pageLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(currentPageTextField, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(separatorLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(totalPagesLabel, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(next, Alignment.MIDDLE_LEFT);
    pageManagement.setComponentAlignment(last, Alignment.MIDDLE_LEFT);
    pageManagement.setWidth(null);
    pageManagement.setSpacing(true);
    controlBar.addComponent(pageSize);
    controlBar.addComponent(pageManagement);
    controlBar.setComponentAlignment(pageManagement, Alignment.MIDDLE_CENTER);
    controlBar.setWidth(100, Sizeable.Unit.PERCENTAGE);
    controlBar.setExpandRatio(pageSize, 1);

    if (container != null) {
        first.setEnabled(container.getStartIndex() > 0);
        previous.setEnabled(container.getStartIndex() > 0);
        next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
        last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
    }

    addListener(new PageChangeListener() {
        private boolean inMiddleOfValueChange;

        @Override
        public void pageChanged(PagedTableChangeEvent event) {
            if (!inMiddleOfValueChange) {
                inMiddleOfValueChange = true;
                first.setEnabled(container.getStartIndex() > 0);
                previous.setEnabled(container.getStartIndex() > 0);
                next.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
                last.setEnabled(container.getStartIndex() < container.getRealSize() - getPageLength());
                currentPageTextField.setValue(String.valueOf(getCurrentPage()));
                totalPagesLabel.setValue(Integer.toString(getTotalAmountOfPages()));
                itemsPerPageSelect.setValue(getPageLength());
                inMiddleOfValueChange = false;
            }
        }
    });
    return controlBar;
}

From source file:org.bitpimp.VaadinCurrencyConverter.MyVaadinApplication.java

License:Apache License

@Override
protected void init(VaadinRequest request) {
    // Set the window or tab title
    getPage().setTitle("Yahoo Currency Converter");

    // Create the content root layout for the UI
    final FormLayout content = new FormLayout();
    content.setMargin(true);/*w w  w  . j  a va  2  s.c  om*/
    final Panel panel = new Panel(content);
    panel.setWidth("500");
    panel.setHeight("400");
    final VerticalLayout root = new VerticalLayout();
    root.addComponent(panel);
    root.setComponentAlignment(panel, Alignment.MIDDLE_CENTER);
    root.setSizeFull();
    root.setMargin(true);

    setContent(root);

    content.addComponent(new Embedded("",
            new ExternalResource("https://vaadin.com/vaadin-theme/images/vaadin/vaadin-logo-color.png")));
    content.addComponent(new Embedded("",
            new ExternalResource("http://images.wikia.com/logopedia/images/e/e4/YahooFinanceLogo.png")));

    // Display the greeting
    final Label heading = new Label("<b>Simple Currency Converter " + "Using YQL/Yahoo Finance Service</b>",
            ContentMode.HTML);
    heading.setWidth(null);
    content.addComponent(heading);

    // Build the set of fields for the converter form
    final TextField fromField = new TextField("From Currency", "AUD");
    fromField.setRequired(true);
    fromField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false));
    content.addComponent(fromField);

    final TextField toField = new TextField("To Currency", "USD");
    toField.setRequired(true);
    toField.addValidator(new StringLengthValidator(CURRENCY_CODE_REQUIRED, 3, 3, false));
    content.addComponent(toField);

    final TextField resultField = new TextField("Result");
    resultField.setEnabled(false);
    content.addComponent(resultField);

    final TextField timeField = new TextField("Time");
    timeField.setEnabled(false);
    content.addComponent(timeField);

    final Button submitButton = new Button("Submit", new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // Do the conversion
            final String result = converter.convert(fromField.getValue().toUpperCase(),
                    toField.getValue().toUpperCase());
            if (result != null) {
                resultField.setValue(result);
                timeField.setValue(new Date().toString());
            }
        }
    });
    content.addComponent(submitButton);

    // Configure the error handler for the UI
    UI.getCurrent().setErrorHandler(new DefaultErrorHandler() {
        @Override
        public void error(com.vaadin.server.ErrorEvent event) {
            // Find the final cause
            String cause = "<b>The operation failed :</b><br/>";
            Throwable th = Throwables.getRootCause(event.getThrowable());
            if (th != null)
                cause += th.getClass().getName() + "<br/>";

            // Display the error message in a custom fashion
            content.addComponent(new Label(cause, ContentMode.HTML));

            // Do the default error handling (optional)
            doDefault(event);
        }
    });
}

From source file:org.casbah.ui.IssuedCertificateList.java

License:Open Source License

private void collectKeyCertificateInfo() throws CAProviderException {
    final Window principalWindow = new Window("Specify Certificate Details");
    principalWindow.setPositionX(200);/*from   ww  w  . j  av a2 s. com*/
    principalWindow.setPositionY(100);
    principalWindow.setWidth("600px");
    principalWindow.setHeight("500px");
    principalWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            parentApplication.getMainWindow().removeWindow(principalWindow);

        }
    });

    VerticalLayout vl = new VerticalLayout();
    final PrincipalComponent pc = new PrincipalComponent();
    Principal parentPrincipal = new Principal(provider.getCACertificate().getSubjectX500Principal());
    pc.init(new Principal(parentPrincipal, provider.getRuleMap()));
    vl.addComponent(pc);
    HorizontalLayout passLayout = new HorizontalLayout();
    vl.addComponent(passLayout);
    final TextField pass1 = new TextField("Private key/keystore passphrase");
    pass1.setSecret(true);
    final TextField pass2 = new TextField();
    pass2.setSecret(true);
    passLayout.addComponent(pass1);
    passLayout.addComponent(pass2);
    passLayout.setComponentAlignment(pass1, Alignment.BOTTOM_CENTER);
    passLayout.setComponentAlignment(pass2, Alignment.BOTTOM_CENTER);

    final OptionGroup type = new OptionGroup("Bundle Type");
    type.addItem(BundleType.OPENSSL);
    type.addItem(BundleType.PKCS12);
    type.addItem(BundleType.JKS);
    type.setValue(BundleType.OPENSSL);
    vl.addComponent(type);

    HorizontalLayout buttonsLayout = new HorizontalLayout();
    buttonsLayout.addComponent(new Button("Create", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (pass1.getValue().equals(pass2.getValue())) {
                try {
                    createKeyCertificatePair(pc.toPrincipal(), (String) pass1.getValue(),
                            (BundleType) type.getValue());
                    parentApplication.getMainWindow().removeWindow(principalWindow);
                } catch (Exception e) {
                    logger.severe(e.getMessage());
                    parentApplication.getMainWindow().showNotification(
                            "An error prevented the correct creation of the key/certificate pair",
                            Notification.TYPE_ERROR_MESSAGE);
                }
            } else {
                parentApplication.getMainWindow().showNotification("Passphrases do not match",
                        Notification.TYPE_ERROR_MESSAGE);
            }
        }
    }));
    buttonsLayout.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            parentApplication.getMainWindow().removeWindow(principalWindow);
        }
    }));

    vl.addComponent(buttonsLayout);
    principalWindow.setContent(vl);
    parentApplication.getMainWindow().addWindow(principalWindow);
}

From source file:org.casbah.ui.MainCAView.java

License:Open Source License

private void uploadAndSignCsr() throws CAProviderException {
    final Window csrWindow = new Window("Upload CSR");
    csrWindow.setPositionX(200);/*from   w w w .j a  v a  2s . co m*/
    csrWindow.setPositionY(100);
    csrWindow.setWidth("800px");
    csrWindow.setHeight("300px");
    csrWindow.addListener(new Window.CloseListener() {

        private static final long serialVersionUID = 1L;

        public void windowClose(CloseEvent e) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    });

    final TextField csrData = new TextField("DER Encoded CSR");
    csrData.setColumns(80);
    csrData.setRows(20);
    csrData.setWordwrap(false);
    csrWindow.addComponent(csrData);
    HorizontalLayout hl = new HorizontalLayout();
    csrWindow.addComponent(hl);
    hl.addComponent(new Button("Cancel", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            application.getMainWindow().removeWindow(csrWindow);

        }
    }));
    hl.addComponent(new Button("Upload", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            String csr = (String) csrData.getValue();
            try {
                X509Certificate result = provider.sign(csr);
                showEncodedCertificate(result, result.getSerialNumber().toString(16));

            } catch (CAProviderException cpe) {
                cpe.printStackTrace();
            }
        }
    }));
    csrWindow.setModal(true);
    application.getMainWindow().addWindow(csrWindow);
}

From source file:org.casbah.ui.SetupCaComponent.java

License:Open Source License

public void init(final Button.ClickListener clickListener) {

    VerticalLayout mainLayout = new VerticalLayout();
    principal.init(new Principal());

    mainLayout.addComponent(//w w w.  j  a  v  a  2  s .c o m
            new Label("There is currently no CA correctly setup, please enter details to setup a new CA"));

    mainLayout.addComponent(principal);

    HorizontalLayout passwordLayout = new HorizontalLayout();

    final TextField pass1 = new TextField("CA Secret Key passphrase");
    pass1.setSecret(true);
    final TextField pass2 = new TextField();
    pass2.setSecret(true);

    passwordLayout.addComponent(pass1);
    passwordLayout.addComponent(pass2);
    passwordLayout.setComponentAlignment(pass1, Alignment.BOTTOM_CENTER);
    passwordLayout.setComponentAlignment(pass2, Alignment.BOTTOM_CENTER);

    mainLayout.addComponent(passwordLayout);

    Button okButton = new Button("Ok", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            if (pass1.getValue().equals(pass2.getValue())) {
                passphrase = (String) pass1.getValue();
                clickListener.buttonClick(event);
            } else {
                parentApplication.getMainWindow().showNotification("Passphrases must match",
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }
    });

    mainLayout.addComponent(okButton);

    setCompositionRoot(mainLayout);
}

From source file:org.diretto.web.richwebclient.view.windows.UploadSettingsWindow.java

/**
 * Constructs an {@link UploadSettingsWindow}.
 * //from w w w. jav a2s . c  om
 * @param mainWindow The corresponding {@code MainWindow}
 * @param uploadSection The corresponding {@code UploadSection}
 * @param fileInfo The {@code FileInfo} object
 * @param mediaType The {@code MediaType} of the file
 * @param uploadSettings The corresponding {@code UploadSettings}
 * @param otherFiles The names of the other upload files
 */
public UploadSettingsWindow(final MainWindow mainWindow, final UploadSection uploadSection, FileInfo fileInfo,
        MediaType mediaType, UploadSettings uploadSettings, List<String> otherFiles) {
    super("Upload Settings");

    this.mainWindow = mainWindow;

    setModal(true);
    setStyleName(Reindeer.WINDOW_BLACK);
    setWidth("940px");
    setHeight((((int) mainWindow.getHeight()) - 160) + "px");
    setResizable(false);
    setClosable(false);
    setDraggable(false);
    setPositionX((int) (mainWindow.getWidth() / 2.0f) - 470);
    setPositionY(126);

    wrapperLayout = new HorizontalLayout();
    wrapperLayout.setSizeFull();
    wrapperLayout.setMargin(true, true, true, true);
    addComponent(wrapperLayout);

    mainLayout = new VerticalLayout();
    mainLayout.setSizeFull();
    mainLayout.setSpacing(true);

    HorizontalLayout titleLayout = new HorizontalLayout();
    titleLayout.setWidth("100%");
    mainLayout.addComponent(titleLayout);

    HorizontalLayout leftTitleLayout = new HorizontalLayout();
    titleLayout.addComponent(leftTitleLayout);
    titleLayout.setComponentAlignment(leftTitleLayout, Alignment.MIDDLE_LEFT);

    Label fileNameLabel = StyleUtils.getLabelH2(fileInfo.getName());
    leftTitleLayout.addComponent(fileNameLabel);
    leftTitleLayout.setComponentAlignment(fileNameLabel, Alignment.MIDDLE_LEFT);

    Label bullLabel = StyleUtils.getLabelHTML(
            "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&bull;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
    leftTitleLayout.addComponent(bullLabel);
    leftTitleLayout.setComponentAlignment(bullLabel, Alignment.MIDDLE_LEFT);

    Label titleLabel = StyleUtils.getLabelHTML("<b>Title</b>&nbsp;&nbsp;&nbsp;");
    leftTitleLayout.addComponent(titleLabel);
    leftTitleLayout.setComponentAlignment(titleLabel, Alignment.MIDDLE_LEFT);

    final TextField titleField = new TextField();
    titleField.setMaxLength(50);
    titleField.setWidth("100%");
    titleField.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getTitle() != null) {
        titleField.setValue(uploadSettings.getTitle());
    }

    titleField.focus();
    titleField.setCursorPosition(((String) titleField.getValue()).length());

    titleLayout.addComponent(titleField);
    titleLayout.setComponentAlignment(titleField, Alignment.MIDDLE_RIGHT);

    titleLayout.setExpandRatio(leftTitleLayout, 0);
    titleLayout.setExpandRatio(titleField, 1);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    GridLayout topGridLayout = new GridLayout(2, 3);
    topGridLayout.setColumnExpandRatio(0, 1.0f);
    topGridLayout.setColumnExpandRatio(1, 0.0f);
    topGridLayout.setWidth("100%");
    topGridLayout.setSpacing(true);
    mainLayout.addComponent(topGridLayout);

    Label descriptionLabel = StyleUtils.getLabelBold("Description");
    topGridLayout.addComponent(descriptionLabel, 0, 0);

    final TextArea descriptionArea = new TextArea();
    descriptionArea.setSizeFull();
    descriptionArea.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getDescription() != null) {
        descriptionArea.setValue(uploadSettings.getDescription());
    }

    topGridLayout.addComponent(descriptionArea, 0, 1);

    VerticalLayout tagsWrapperLayout = new VerticalLayout();
    tagsWrapperLayout.setHeight("30px");
    tagsWrapperLayout.setSpacing(false);
    topGridLayout.addComponent(tagsWrapperLayout, 0, 2);

    HorizontalLayout tagsLayout = new HorizontalLayout();
    tagsLayout.setWidth("100%");
    tagsLayout.setSpacing(true);

    Label tagsLabel = StyleUtils.getLabelBoldHTML("Tags&nbsp;");
    tagsLabel.setSizeUndefined();
    tagsLayout.addComponent(tagsLabel);
    tagsLayout.setComponentAlignment(tagsLabel, Alignment.MIDDLE_LEFT);

    addTagField = new TextField();
    addTagField.setImmediate(true);
    addTagField.setInputPrompt("Enter new Tag");

    addTagField.addShortcutListener(new ShortcutListener(null, KeyCode.ENTER, new int[0]) {
        private static final long serialVersionUID = -4767515198819351723L;

        @Override
        public void handleAction(Object sender, Object target) {
            if (target == addTagField) {
                addTag();
            }
        }
    });

    tagsLayout.addComponent(addTagField);
    tagsLayout.setComponentAlignment(addTagField, Alignment.MIDDLE_LEFT);

    tabSheet = new TabSheet();

    tabSheet.setStyleName(Reindeer.TABSHEET_SMALL);
    tabSheet.addStyleName("view");

    tabSheet.addListener(new ComponentDetachListener() {
        private static final long serialVersionUID = -657657505471281795L;

        @Override
        public void componentDetachedFromContainer(ComponentDetachEvent event) {
            tags.remove(tabSheet.getTab(event.getDetachedComponent()).getCaption());
        }
    });

    Button addTagButton = new Button("Add", new Button.ClickListener() {
        private static final long serialVersionUID = 5914473126402594623L;

        @Override
        public void buttonClick(ClickEvent event) {
            addTag();
        }
    });

    addTagButton.setStyleName(Reindeer.BUTTON_DEFAULT);

    tagsLayout.addComponent(addTagButton);
    tagsLayout.setComponentAlignment(addTagButton, Alignment.MIDDLE_LEFT);

    Label spaceLabel = StyleUtils.getLabelHTML("");
    spaceLabel.setSizeUndefined();
    tagsLayout.addComponent(spaceLabel);
    tagsLayout.setComponentAlignment(spaceLabel, Alignment.MIDDLE_LEFT);

    tagsLayout.addComponent(tabSheet);
    tagsLayout.setComponentAlignment(tabSheet, Alignment.MIDDLE_LEFT);
    tagsLayout.setExpandRatio(tabSheet, 1.0f);

    tagsWrapperLayout.addComponent(tagsLayout);
    tagsWrapperLayout.setComponentAlignment(tagsLayout, Alignment.TOP_LEFT);

    if (uploadSettings != null && uploadSettings.getTags() != null && uploadSettings.getTags().size() > 0) {
        for (String tag : uploadSettings.getTags()) {
            addTagField.setValue(tag);

            addTag();
        }
    }

    Label presettingLabel = StyleUtils.getLabelBold("Presetting");
    topGridLayout.addComponent(presettingLabel, 1, 0);

    final TwinColSelect twinColSelect;

    if (otherFiles != null && otherFiles.size() > 0) {
        twinColSelect = new TwinColSelect(null, otherFiles);
    } else {
        twinColSelect = new TwinColSelect();
    }

    twinColSelect.setWidth("400px");
    twinColSelect.setRows(10);
    topGridLayout.addComponent(twinColSelect, 1, 1);
    topGridLayout.setComponentAlignment(twinColSelect, Alignment.TOP_RIGHT);

    Label otherFilesLabel = StyleUtils
            .getLabelSmallHTML("Select the files which should get the settings of this file as presetting.");
    otherFilesLabel.setSizeUndefined();
    topGridLayout.addComponent(otherFilesLabel, 1, 2);
    topGridLayout.setComponentAlignment(otherFilesLabel, Alignment.MIDDLE_CENTER);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    final UploadGoogleMap googleMap;

    if (uploadSettings != null && uploadSettings.getTopographicPoint() != null) {
        googleMap = new UploadGoogleMap(mediaType, 12, uploadSettings.getTopographicPoint().getLatitude(),
                uploadSettings.getTopographicPoint().getLongitude(), MapType.HYBRID);
    } else {
        googleMap = new UploadGoogleMap(mediaType, 12, 48.42255269321401d, 9.956477880477905d, MapType.HYBRID);
    }

    googleMap.setWidth("100%");
    googleMap.setHeight("300px");
    mainLayout.addComponent(googleMap);

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    GridLayout bottomGridLayout = new GridLayout(3, 3);
    bottomGridLayout.setSizeFull();
    bottomGridLayout.setSpacing(true);
    mainLayout.addComponent(bottomGridLayout);

    Label licenseLabel = StyleUtils.getLabelBold("License");
    bottomGridLayout.addComponent(licenseLabel, 0, 0);

    final TextArea licenseArea = new TextArea();
    licenseArea.setWidth("320px");
    licenseArea.setHeight("175px");
    licenseArea.setImmediate(true);

    if (uploadSettings != null && uploadSettings.getLicense() != null) {
        licenseArea.setValue(uploadSettings.getLicense());
    }

    bottomGridLayout.addComponent(licenseArea, 0, 1);

    final Label startTimeLabel = StyleUtils.getLabelBold("Earliest possible Start Date");
    startTimeLabel.setSizeUndefined();
    bottomGridLayout.setComponentAlignment(startTimeLabel, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(startTimeLabel, 1, 0);

    final InlineDateField startTimeField = new InlineDateField();
    startTimeField.setImmediate(true);
    startTimeField.setResolution(InlineDateField.RESOLUTION_SEC);

    boolean currentTimeAdjusted = false;

    if (uploadSettings != null && uploadSettings.getTimeRange() != null
            && uploadSettings.getTimeRange().getStartDateTime() != null) {
        startTimeField.setValue(uploadSettings.getTimeRange().getStartDateTime().toDate());
    } else {
        currentTimeAdjusted = true;

        startTimeField.setValue(new Date());
    }

    bottomGridLayout.setComponentAlignment(startTimeField, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(startTimeField, 1, 1);

    final CheckBox exactTimeCheckBox = new CheckBox("This is the exact point in time.");
    exactTimeCheckBox.setImmediate(true);
    bottomGridLayout.setComponentAlignment(exactTimeCheckBox, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(exactTimeCheckBox, 1, 2);

    final Label endTimeLabel = StyleUtils.getLabelBold("Latest possible Start Date");
    endTimeLabel.setSizeUndefined();
    bottomGridLayout.setComponentAlignment(endTimeLabel, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(endTimeLabel, 2, 0);

    final InlineDateField endTimeField = new InlineDateField();
    endTimeField.setImmediate(true);
    endTimeField.setResolution(InlineDateField.RESOLUTION_SEC);

    if (uploadSettings != null && uploadSettings.getTimeRange() != null
            && uploadSettings.getTimeRange().getEndDateTime() != null) {
        endTimeField.setValue(uploadSettings.getTimeRange().getEndDateTime().toDate());
    } else {
        endTimeField.setValue(startTimeField.getValue());
    }

    bottomGridLayout.setComponentAlignment(endTimeField, Alignment.TOP_CENTER);
    bottomGridLayout.addComponent(endTimeField, 2, 1);

    if (!currentTimeAdjusted && ((Date) startTimeField.getValue()).equals((Date) endTimeField.getValue())) {
        exactTimeCheckBox.setValue(true);

        endTimeLabel.setEnabled(false);
        endTimeField.setEnabled(false);
    }

    exactTimeCheckBox.addListener(new ValueChangeListener() {
        private static final long serialVersionUID = 7193545421803538364L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            if ((Boolean) event.getProperty().getValue()) {
                endTimeLabel.setEnabled(false);
                endTimeField.setEnabled(false);
            } else {
                endTimeLabel.setEnabled(true);
                endTimeField.setEnabled(true);
            }
        }
    });

    mainLayout.addComponent(StyleUtils.getHorizontalLine());

    HorizontalLayout buttonLayout = new HorizontalLayout();
    buttonLayout.setMargin(true, false, false, false);
    buttonLayout.setSpacing(false);

    HorizontalLayout uploadButtonLayout = new HorizontalLayout();
    uploadButtonLayout.setMargin(false, true, false, false);

    uploadButton = new Button("Upload File", new Button.ClickListener() {
        private static final long serialVersionUID = 8013811216568950479L;

        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(ClickEvent event) {
            String titleValue = titleField.getValue().toString().trim();
            Date startTimeValue = (Date) startTimeField.getValue();
            Date endTimeValue = (Date) endTimeField.getValue();
            boolean exactTimeValue = (Boolean) exactTimeCheckBox.getValue();

            if (titleValue.equals("")) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field",
                        StyleUtils.getLabelHTML("A title entry is required."));

                mainWindow.addWindow(confirmWindow);
            } else if (titleValue.length() < 5 || titleValue.length() > 50) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Title Field", StyleUtils
                        .getLabelHTML("The number of characters of the title has to be between 5 and 50."));

                mainWindow.addWindow(confirmWindow);
            } else if (!exactTimeValue && startTimeValue.after(endTimeValue)) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries",
                        StyleUtils.getLabelHTML("The second date has to be after the first date."));

                mainWindow.addWindow(confirmWindow);
            } else if (startTimeValue.after(new Date())
                    || (!exactTimeValue && endTimeValue.after(new Date()))) {
                ConfirmWindow confirmWindow = new ConfirmWindow(mainWindow, "Date Entries",
                        StyleUtils.getLabelHTML("The dates are not allowed to be in the future."));

                mainWindow.addWindow(confirmWindow);
            } else {
                disableButtons();

                String descriptionValue = descriptionArea.getValue().toString().trim();
                String licenseValue = licenseArea.getValue().toString().trim();
                TopographicPoint topographicPointValue = googleMap.getMarkerPosition();
                Collection<String> presettingValues = (Collection<String>) twinColSelect.getValue();

                if (exactTimeValue) {
                    endTimeValue = startTimeValue;
                }

                TimeRange timeRange = new TimeRange(new DateTime(startTimeValue), new DateTime(endTimeValue));

                UploadSettings uploadSettings = new UploadSettings(titleValue, descriptionValue, licenseValue,
                        new Vector<String>(tags), topographicPointValue, timeRange);

                mainWindow.removeWindow(event.getButton().getWindow());

                requestRepaint();

                uploadSection.upload(uploadSettings, new Vector<String>(presettingValues));
            }
        }
    });

    uploadButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    uploadButtonLayout.addComponent(uploadButton);
    buttonLayout.addComponent(uploadButtonLayout);

    HorizontalLayout cancelButtonLayout = new HorizontalLayout();
    cancelButtonLayout.setMargin(false, true, false, false);

    cancelButton = new Button("Cancel", new Button.ClickListener() {
        private static final long serialVersionUID = -2565870159504952913L;

        @Override
        public void buttonClick(ClickEvent event) {
            disableButtons();

            mainWindow.removeWindow(event.getButton().getWindow());

            requestRepaint();

            uploadSection.cancelUpload();
        }
    });

    cancelButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    cancelButtonLayout.addComponent(cancelButton);
    buttonLayout.addComponent(cancelButtonLayout);

    cancelAllButton = new Button("Cancel All", new Button.ClickListener() {
        private static final long serialVersionUID = -8578124709201789182L;

        @Override
        public void buttonClick(ClickEvent event) {
            disableButtons();

            mainWindow.removeWindow(event.getButton().getWindow());

            requestRepaint();

            uploadSection.cancelAllUploads();
        }
    });

    cancelAllButton.setStyleName(Reindeer.BUTTON_DEFAULT);
    buttonLayout.addComponent(cancelAllButton);

    mainLayout.addComponent(buttonLayout);
    mainLayout.setComponentAlignment(buttonLayout, Alignment.BOTTOM_CENTER);

    wrapperLayout.addComponent(mainLayout);
}

From source file:org.eclipse.emf.ecp.controls.vaadin.internal.PrimitiveListVaadinRenderer.java

License:Open Source License

private Object getConvertedValue(TextField textField) {
    final Converter<String, Object> converter = textField.getConverter();
    if (converter == null) {
        return textField.getValue();
    }//from   w  w  w  .j a  va2 s  .co m

    return textField.getConvertedValue();
}