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.eclipse.hawkbit.ui.rollout.rollout.AddUpdateRolloutWindowLayout.java

License:Open Source License

private TextField createErrorThreshold() {
    final TextField errorField = createIntegerTextField("prompt.error.threshold",
            UIComponentIdProvider.ROLLOUT_ERROR_THRESOLD_ID);
    errorField.addValidator(new ThresholdFieldValidator());
    errorField.setMaxLength(7);/*from   w w  w. j a  v a  2 s  . co m*/
    errorField.setValue(defaultRolloutGroupConditions.getErrorConditionExp());
    return errorField;
}

From source file:org.eclipse.hawkbit.ui.rollout.rollout.AddUpdateRolloutWindowLayout.java

License:Open Source License

private TextField createTriggerThreshold() {
    final TextField thresholdField = createIntegerTextField("prompt.tigger.threshold",
            UIComponentIdProvider.ROLLOUT_TRIGGER_THRESOLD_ID);
    thresholdField.addValidator(new ThresholdFieldValidator());
    thresholdField.setValue(defaultRolloutGroupConditions.getSuccessConditionExp());
    return thresholdField;
}

From source file:org.eclipse.skalli.view.component.LinkWindow.java

License:Open Source License

/**
 * Render the window// w  w  w. j  ava2s. c  om
 */
@SuppressWarnings("serial")
private void createContents(String title) {
    setModal(true);
    setCaption(title);

    setWidth("400px"); //$NON-NLS-1$
    setHeight("300px"); //$NON-NLS-1$

    root = new VerticalLayout();
    root.setMargin(true);
    root.setSpacing(true);

    final ComboBox cbLinkGroup = new ComboBox("Link Group");
    cbLinkGroup.setInputPrompt("Enter a new group name or select from the list");
    cbLinkGroup.setWidth("100%"); //$NON-NLS-1$
    for (String groupName : knownGroups) {
        cbLinkGroup.addItem(groupName);
    }
    if (oldGroup != null && knownGroups.contains(oldGroup.getCaption())) {
        cbLinkGroup.select(oldGroup.getCaption());
    }
    cbLinkGroup.setImmediate(true);
    cbLinkGroup.setNullSelectionAllowed(false);
    cbLinkGroup.setNewItemsAllowed(true);
    cbLinkGroup.setNewItemHandler(new NewItemHandler() {
        @Override
        public void addNewItem(String newGroupName) {
            cbLinkGroup.removeAllItems();
            for (String groupName : knownGroups) {
                cbLinkGroup.addItem(groupName);
            }
            if (!cbLinkGroup.containsId(newGroupName)) {
                cbLinkGroup.addItem(newGroupName);
            }
            cbLinkGroup.select(newGroupName);
        }
    });
    cbLinkGroup.setRequired(true);
    cbLinkGroup.addValidator(new StringValidator());
    root.addComponent(cbLinkGroup);

    final TextField tfLinkCaption = new TextField("Page Title");
    tfLinkCaption.setInputPrompt("Enter a descriptive name for the page");
    tfLinkCaption.setWidth("100%"); //$NON-NLS-1$
    tfLinkCaption.setImmediate(true);
    tfLinkCaption.setRequired(true);
    tfLinkCaption.addValidator(new StringValidator());
    if (link != null) {
        tfLinkCaption.setValue(link.getLabel());
    }
    root.addComponent(tfLinkCaption);

    final TextField tfLinkURL = new TextField("URL");
    tfLinkURL.setInputPrompt("e.g. http://www.your-site.domain/path");
    tfLinkURL.setWidth("100%"); //$NON-NLS-1$
    tfLinkURL.setImmediate(true);
    tfLinkURL.setRequired(true);
    tfLinkURL.addValidator(new StringValidator());
    tfLinkURL.addValidator(new URLValidator());
    if (link != null) {
        tfLinkURL.setValue(link.getUrl());
    }
    root.addComponent(tfLinkURL);

    final Button okAndCloseButton = new Button("OK & Close");
    okAndCloseButton.setIcon(ICON_BUTTON_OK);
    okAndCloseButton.setDescription("Performs the action and closes the dialog.");
    okAndCloseButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            validateInput(cbLinkGroup);
            validateInput(tfLinkURL);
            validateInput(tfLinkCaption);

            if (cbLinkGroup.isValid() && tfLinkURL.isValid() && tfLinkCaption.isValid()) {
                String groupName = String.valueOf(cbLinkGroup.getValue());
                String linkLabel = String.valueOf(tfLinkCaption.getValue());
                String linkUrl = String.valueOf(tfLinkURL.getValue());

                if (linkAddedHandler != null) {
                    Link link = new Link(linkUrl, linkLabel);
                    linkAddedHandler.onLinkAdded(groupName, link);
                    close();
                }

                if (linkModifiedHandler != null) {
                    boolean linkModified = !link.getLabel().equals(linkLabel) || !link.getUrl().equals(linkUrl);
                    link.setLabel(linkLabel);
                    link.setUrl(linkUrl);
                    linkModifiedHandler.onLinkModified(oldGroup, groupName, link, linkModified);
                    close();
                }
            }
        }
    });
    root.addComponent(okAndCloseButton);

    root.setSizeFull();
    setContent(root);
}

From source file:org.eclipse.skalli.view.component.MultiTextField.java

License:Open Source License

private TextField createTextField(String value) {
    TextField tf = new TextField();
    tf.setImmediate(true);/*from w w w.  j av  a  2s  . co  m*/
    if (columns > 0) {
        tf.setColumns(columns);
    }
    if (description != null) {
        tf.setDescription(description);
    }
    if (inputPrompt != null) {
        tf.setInputPrompt(inputPrompt);
    }
    if (validator != null) {
        tf.addValidator(validator);
        tf.setValidationVisible(false);
    }
    if (value != null) {
        tf.setValue(value);
    }
    return tf;
}

From source file:org.escidoc.browser.ui.listeners.OnContextAdminDescriptor.java

License:Open Source License

/**
 * Editing since it has a parameter/*from   ww w . j a v a 2 s.  c  o  m*/
 * 
 * @param adminDescriptor
 */
public void adminDescriptorForm(AdminDescriptor adminDescriptor) {

    // Editing
    final Window subwindow = new Window("A modal subwindow");
    subwindow.setModal(true);
    subwindow.setWidth("650px");

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

    final TextField txtName = new TextField("Name");
    txtName.setValue(adminDescriptor.getName());
    txtName.setImmediate(true);
    txtName.setValidationVisible(true);
    final TextArea txtContent = new TextArea("Content");
    txtContent.setColumns(30);
    txtContent.setRows(40);
    try {
        txtContent.setValue(adminDescriptor.getContentAsString());
    } catch (Exception e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
    txtContent.setColumns(30);

    Button addAdmDescButton = new Button("Add Description");
    addAdmDescButton.addListener(new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {

            if (txtName.getValue().toString() == null) {
                router.getMainWindow().showNotification(ViewConstants.PLEASE_ENTER_A_NAME,
                        Notification.TYPE_ERROR_MESSAGE);

            } else if (!XmlUtil.isWellFormed(txtContent.getValue().toString())) {
                router.getMainWindow().showNotification(ViewConstants.XML_IS_NOT_WELL_FORMED,
                        Notification.TYPE_ERROR_MESSAGE);
            } else {
                controller.addAdminDescriptor(txtName.getValue().toString(), txtContent.getValue().toString());
                (subwindow.getParent()).removeWindow(subwindow);
                router.getMainWindow().showNotification("Addedd Successfully",
                        Notification.TYPE_HUMANIZED_MESSAGE);
            }
        }
    });

    subwindow.addComponent(txtName);
    subwindow.addComponent(txtContent);
    subwindow.addComponent(addAdmDescButton);

    Button close = new Button(ViewConstants.CLOSE, new Button.ClickListener() {
        @Override
        public void buttonClick(@SuppressWarnings("unused") ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    layout.addComponent(close);
    layout.setComponentAlignment(close, Alignment.TOP_RIGHT);

    router.getMainWindow().addWindow(subwindow);

}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

private void handleLayoutListeners() {
    if (contextController.canUpdateContext()) {
        headerLayout.addListener(new LayoutClickListener() {

            @Override/*  ww w.  jav  a 2s. com*/
            public void layoutClick(final LayoutClickEvent event) {
                if (event.getChildComponent() != null) {
                    // Is Label?
                    if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") {
                        final Label child = (Label) event.getChildComponent();
                        if ((child.getDescription() == ViewConstants.RESOURCE_NAME_CONTEXT)) {
                            reSwapComponents();
                            oldComponent = event.getClickedComponent();
                            swapComponent = editName(child.getValue().toString()
                                    .replace(ViewConstants.RESOURCE_NAME_CONTEXT, ""),
                                    ViewConstants.RESOURCE_NAME_CONTEXT);
                            headerLayout.replaceComponent(oldComponent, swapComponent);
                        }
                    }
                } else {
                    reSwapComponents();
                }
            }

            private Component editName(String name, String description) {
                final TextField txtType = new TextField();
                txtType.setInvalidAllowed(false);
                txtType.setValue(name);
                txtType.setDescription(description);

                return txtType;
            }
        });

        vlLeft.addListener(new LayoutClickListener() {
            private static final long serialVersionUID = 1L;

            @Override
            public void layoutClick(final LayoutClickEvent event) {
                if (event.getChildComponent() != null) {
                    // Is Label?
                    if (event.getChildComponent().getClass().getCanonicalName() == "com.vaadin.ui.Label") {
                        final Label child = (Label) event.getChildComponent();

                        if ((child.getDescription() == ViewConstants.CONTEXT_TYPE)) {
                            reSwapComponents();
                            oldComponent = event.getClickedComponent();
                            swapComponent = editType(
                                    child.getValue().toString().replace(ViewConstants.CONTEXT_TYPE, ""),
                                    ViewConstants.CONTEXT_TYPE);
                            vlLeft.replaceComponent(oldComponent, swapComponent);
                        } else if ((child.getDescription() == ViewConstants.DESC_STATUS) && (!child.getValue()
                                .equals(resourceProxy.getType().getLabel() + " is closed"))) {
                            reSwapComponents();
                            oldComponent = event.getClickedComponent();
                            swapComponent = editStatus(child.getValue().toString()
                                    .replace(resourceProxy.getType().getLabel() + " is ", ""));
                            vlLeft.replaceComponent(oldComponent, swapComponent);
                        }
                    }
                } else {
                    reSwapComponents();
                }
            }

            private ComboBox cmbStatus;

            private Component editStatus(final String lockStatus) {
                cmbStatus = new ComboBox();
                cmbStatus.setNullSelectionAllowed(false);
                if (lockStatus.contains(CREATED)) {
                    cmbStatus.addItem(PublicStatus.OPENED.toString().toLowerCase());
                } else {
                    cmbStatus.addItem(PublicStatus.CLOSED.toString().toLowerCase());
                }
                cmbStatus.select(Integer.valueOf(1));
                return cmbStatus;
            }

        });
    }

}

From source file:org.escidoc.browser.ui.maincontent.ContextView.java

License:Open Source License

private static TextField editType(final String contextType, String description) {
    final TextField txtType = new TextField();
    txtType.setInvalidAllowed(false);/*w  ww .  j a v  a  2  s.  c o  m*/
    txtType.setValue(contextType);
    txtType.setDescription(description);

    return txtType;
}

From source file:org.escidoc.browser.ui.tools.ImportView.java

License:Open Source License

private void addContent() {
    final Label urlLabel = new Label(ViewConstants.URL);
    final TextField sourceUrlField = new TextField();
    sourceUrlField.setWidth("400px");
    sourceUrlField.setValue(ViewConstants.DEFAULT_CONTENT_MODEL_URI);
    final Button importButton = new Button(ViewConstants.IMPORT);
    importButton.setStyleName(Reindeer.BUTTON_SMALL);
    importButton.addListener(new ImportListener(sourceUrlField));

    final HorizontalLayout hl = new HorizontalLayout();
    hl.setSpacing(true);/*w  w w  .j a v a2 s. co m*/
    hl.addComponent(urlLabel);
    hl.addComponent(sourceUrlField);
    hl.addComponent(importButton);
    addComponent(hl);
}

From source file:org.escidoc.browser.ui.tools.RepositoryInfoView.java

License:Open Source License

private static TextField createReadOnlyField(final Entry<String, String> entry) {
    final TextField textField = new TextField();
    textField.setCaption(entry.getKey());
    textField.setValue(entry.getValue());
    textField.setWidth(400, UNITS_PIXELS);
    textField.setReadOnly(true);/* w  ww  . jav  a  2 s . com*/
    return textField;
}

From source file:org.escidoc.browser.ui.view.helpers.ChangeComponentCategoryTypeHelper.java

License:Open Source License

public void showWindow() {

    subwindow = new Window("Change Category Type");
    subwindow.setModal(true);//from  w w  w .  j  a v  a 2  s.  com

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

    final TextField txtField = new TextField("Change Category Type");
    txtField.setValue(categoryType);
    subwindow.addComponent(txtField);

    Button close = new Button("Close", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    Button save = new Button("Save", new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            String newCatType = txtField.getValue().toString();
            controller.updateComponentCategory(componentId, newCatType, itemId);
            (subwindow.getParent()).removeWindow(subwindow);
        }
    });
    HorizontalLayout hl = new HorizontalLayout();
    hl.addComponent(save);
    hl.addComponent(close);

    layout.addComponent(hl);
    subwindow.setWidth("350px");
    subwindow.addComponent(layout);
    router.getMainWindow().addWindow(subwindow);

}