Example usage for com.vaadin.ui TextField setValue

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

Introduction

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

Prototype

@Override
public void setValue(String value) 

Source Link

Document

Sets the value of this text field.

Usage

From source file:org.activiti.kickstart.ui.table.TaskTable.java

License:Apache License

protected Object addTaskRow(Object previousTaskItemId, String taskName, String taskAssignee, String taskGroups,
        String taskDescription, Boolean startWithPrevious) {

    Object newItemId = null;//from   w ww .ja va 2  s  .  c o  m
    if (previousTaskItemId == null) { // add at the end of list
        newItemId = addItem();
    } else {
        newItemId = addItemAfter(previousTaskItemId);
    }
    Item newItem = getItem(newItemId);

    // name
    newItem.getItemProperty("name").setValue(taskName == null ? "my task" : taskName);

    // assignee
    newItem.getItemProperty("assignee").setValue(taskAssignee == null ? "" : taskAssignee);

    // groups
    newItem.getItemProperty("groups").setValue(taskGroups == null ? "" : taskGroups);

    // description
    TextField descriptionTextField = new TextField();
    descriptionTextField.setColumns(16);
    descriptionTextField.setRows(1);
    if (taskDescription != null) {
        descriptionTextField.setValue(taskDescription);
    }
    newItem.getItemProperty("description").setValue(descriptionTextField);

    // concurrency
    CheckBox startWithPreviousCheckBox = new CheckBox("start with previous");
    startWithPreviousCheckBox.setValue(startWithPrevious == null ? false : startWithPrevious);
    newItem.getItemProperty("startWithPrevious").setValue(startWithPreviousCheckBox);

    // actions
    newItem.getItemProperty("actions").setValue(generateActionButtons(newItemId));

    return newItemId;
}

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

License:Apache License

/**
 * Creates a new {@link AddArtifactWindow} instance.
 * /*  w w  w  .j a  v  a 2 s  .  com*/
 * @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.openaz.xacml.admin.view.components.RangeEditorComponent.java

License:Apache License

private void setupComboText(final ComboBox box, final TextField text) {
    ///*from  ww  w .j  a va2 s.c  o  m*/
    // Respond to combo changes
    //
    box.addValueChangeListener(new ValueChangeListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void valueChange(ValueChangeEvent event) {
            //
            // Get the new value
            //
            String property = (String) box.getValue();
            //
            // Get our constraint object
            //
            ConstraintValue value = (ConstraintValue) box.getData();
            //
            // Update our object
            //
            if (property == null) {
                //
                // Clear the text field and disable it
                //
                text.setEnabled(false);
                text.setValue(null);
            } else {
                //
                // Change the property name
                //
                value.setProperty(property);
                //
                // Focus to the text field and enable it
                //
                text.setEnabled(true);
                text.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);//from w  ww.java  2s  .  co 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);/*from   w  w  w. j a va 2  s  .co  m*/
    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.MainCAView.java

License:Open Source License

public void init() throws CAProviderException {

    final X509Certificate caCert = provider.getCACertificate();
    Panel panel = new Panel("CA Details");
    VerticalLayout mainLayout = new VerticalLayout();
    panel.setContent(mainLayout);//from  w w  w .j a  v  a 2 s  . com
    mainLayout.setSizeFull();
    VerticalLayout caInfo = new VerticalLayout();
    TextField name = new TextField("Distinguished Name");
    String nameValue = caCert.getSubjectX500Principal().getName();
    name.setValue(nameValue);
    name.setColumns(50);
    name.setReadOnly(true);

    TextField issuer = new TextField("Issuer");
    issuer.setColumns(50);
    issuer.setValue(caCert.getIssuerX500Principal().getName());
    issuer.setReadOnly(true);

    DateField expDate = new DateField("Expiration Date");
    expDate.setResolution(DateField.RESOLUTION_SEC);
    expDate.setValue(caCert.getNotAfter());
    expDate.setReadOnly(true);

    TextField serial = new TextField("Serial");
    serial.setValue(caCert.getSerialNumber().toString(16));
    serial.setReadOnly(true);

    caInfo.addComponent(name);
    caInfo.addComponent(issuer);
    caInfo.addComponent(expDate);
    caInfo.addComponent(serial);
    caInfo.setSizeFull();

    HorizontalLayout caButtons = new HorizontalLayout();
    caButtons.addComponent(new Button("View Certificate", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                showEncodedCertificate(caCert, caCert.getSerialNumber().toString(16));
            } catch (CAProviderException e) {
                e.printStackTrace();
            }

        }
    }));
    caButtons.addComponent(new Button("Download Certificate", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                downloadEncodedCertificate(caCert, caCert.getSerialNumber().toString(16));
            } catch (CAProviderException e) {
                e.printStackTrace();
            }
        }
    }));

    caButtons.addComponent(new Button("Sign a CSR", new Button.ClickListener() {

        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            try {
                uploadAndSignCsr();
            } catch (CAProviderException pe) {
                pe.printStackTrace();
            }

        }

    }));

    caButtons.addComponent(new Button("Get CRL", new Button.ClickListener() {
        private static final long serialVersionUID = 1L;

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                downloadCrlList(provider.getLatestCrl(false));
            } catch (CAProviderException pe) {
                logger.log(Level.SEVERE, "Could not retrieve CRL", pe);
                getWindow().showNotification("An error occurred while retrieving the CRL",
                        Notification.TYPE_ERROR_MESSAGE);
            }

        }

    }));

    panel.addComponent(caInfo);
    panel.addComponent(caButtons);
    panel.setSizeFull();
    setSizeFull();
    setCompositionRoot(panel);

}

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

/**
 * Constructs an {@link UploadSettingsWindow}.
 * /*from   w  w w  .  jav a 2 s.  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.view.core.vaadin.VaadinWidgetFactory.java

License:Open Source License

/**
 * Creates a add button for a list.//from w w w  . j  a  va2 s.c o  m
 *
 * @param setting the setting
 * @param textField the textfield
 * @return the button
 */
public static Button createListAddButton(final Setting setting, final TextField textField) {
    final Button add = new Button();
    add.addStyleName("list-add"); //$NON-NLS-1$
    add.addClickListener(new ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            try {
                addItem(setting, textField.getConvertedValue());
            } catch (final Converter.ConversionException e) {
                return;
            }
            textField.setValue(""); //$NON-NLS-1$
            textField.focus();
        }
    });
    return add;
}

From source file:org.eclipse.hawkbit.ui.artifacts.upload.UploadConfirmationWindow.java

License:Open Source License

private void addFileNameLayout(final Item newItem, final String baseSoftwareModuleNameVersion,
        final String customFileName, final String itemId) {
    final HorizontalLayout horizontalLayout = new HorizontalLayout();
    final TextField fileNameTextField = createTextField(
            baseSoftwareModuleNameVersion + "/" + customFileName + "/customFileName");
    fileNameTextField.setData(baseSoftwareModuleNameVersion + "/" + customFileName);
    fileNameTextField.setValue(customFileName);

    newItem.getItemProperty(FILE_NAME).setValue(fileNameTextField.getValue());

    final Label warningIconLabel = getWarningLabel();
    warningIconLabel.setId(baseSoftwareModuleNameVersion + "/" + customFileName + "/icon");
    setWarningIcon(warningIconLabel, fileNameTextField.getValue(), itemId);
    newItem.getItemProperty(WARNING_ICON).setValue(warningIconLabel);

    horizontalLayout.addComponent(fileNameTextField);
    horizontalLayout.setComponentAlignment(fileNameTextField, Alignment.MIDDLE_LEFT);
    horizontalLayout.addComponent(warningIconLabel);
    horizontalLayout.setComponentAlignment(warningIconLabel, Alignment.MIDDLE_RIGHT);
    newItem.getItemProperty(FILE_NAME_LAYOUT).setValue(horizontalLayout);

    fileNameTextField.addTextChangeListener(event -> onFileNameChange(event, warningIconLabel, newItem));
}

From source file:org.eclipse.hawkbit.ui.management.targettable.TargetDetails.java

License:Open Source License

private HorizontalLayout getSecurityTokenLayout(final String securityToken) {
    final HorizontalLayout securityTokenLayout = new HorizontalLayout();

    final Label securityTableLbl = new Label(
            SPUIComponentProvider.getBoldHTMLText(getI18n().getMessage("label.target.security.token")),
            ContentMode.HTML);/*from   w ww  .j  a v  a  2 s.  c  om*/
    securityTableLbl.addStyleName(SPUIDefinitions.TEXT_STYLE);
    securityTableLbl.addStyleName("label-style");

    final TextField securityTokentxt = new TextField();
    securityTokentxt.addStyleName(ValoTheme.TEXTFIELD_BORDERLESS);
    securityTokentxt.addStyleName(ValoTheme.TEXTFIELD_TINY);
    securityTokentxt.addStyleName("targetDtls-securityToken");
    securityTokentxt.addStyleName(SPUIDefinitions.TEXT_STYLE);
    securityTokentxt.setCaption(null);
    securityTokentxt.setNullRepresentation("");
    securityTokentxt.setValue(securityToken);
    securityTokentxt.setReadOnly(true);

    securityTokenLayout.addComponent(securityTableLbl);
    securityTokenLayout.addComponent(securityTokentxt);
    return securityTokenLayout;
}