Example usage for com.vaadin.ui TextField selectAll

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

Introduction

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

Prototype

public void selectAll() 

Source Link

Document

Selects all text in the field.

Usage

From source file:com.rdonasco.datamanager.listeditor.controller.ListEditorViewPanelController.java

License:Apache License

private void configureEditorTableBehavior() {
    if (null == getVisibleColumns()) {
        throw new IllegalStateException("visibleColumns not yet set");
    }/* w  w  w  .j a v  a2  s.c om*/
    if (null == getColumnHeaders()) {
        throw new IllegalStateException("columnHeaders not yet set");
    }
    getEditorViewPanel().getEditorTable().setContainerDataSource(dataContainer);
    realVisibleColumns.add(TABLE_PROPERTY_ICON);
    realVisibleColumns.addAll(Arrays.asList(getVisibleColumns()));
    getEditorViewPanel().getEditorTable().setVisibleColumns(getEditableVisibleColumn());
    List<String> realColumnHeaders = new ArrayList<String>();
    realColumnHeaders.add(""); // empty header for the icon
    realColumnHeaders.addAll(Arrays.asList(getColumnHeaders()));
    getEditorViewPanel().getEditorTable().setColumnHeaders(realColumnHeaders.toArray(new String[0]));
    setupDefaultCellStyleGenerator();
    getEditorViewPanel().getEditorTable().setReadOnly(false);

    Table.ColumnGenerator columnGenerator = new Table.ColumnGenerator() {
        private static final long serialVersionUID = 1L;

        @Override
        public Object generateCell(final Table source, final Object itemId, final Object columnId) {
            final TextField textField = new TextField();
            try {
                textField.setPropertyDataSource(source.getContainerProperty(itemId, columnId));
            } catch (Exception ex) {
                LOG.log(Level.SEVERE, ex.getMessage(), ex);
            }
            textField.setReadOnly(true);
            textField.setWriteThrough(true);
            textField.setWidth(100f, TextField.UNITS_PERCENTAGE);
            addFieldToFieldCache(itemId, columnId, textField);
            textField.addListener(new FieldEvents.BlurListener() {
                private static final long serialVersionUID = 1L;

                @Override
                public void blur(FieldEvents.BlurEvent event) {
                    if (!textField.isReadOnly()) {
                        try {
                            BeanItem<VO> itemToUpdate = (BeanItem) source.getItem(itemId);
                            textField.commit();
                            if (null != itemToUpdate) {
                                dataContainer.updateItem(itemToUpdate.getBean());
                            } else {
                                LOG.log(Level.FINER, "warning, itemToUpdate is null");
                            }
                            textField.setReadOnly(true);
                        } catch (Exception ex) {
                            LOG.log(Level.SEVERE, ex.getMessage(), ex);
                            getPopupProvider().popUpError(I18NResource
                                    .localizeWithParameter("unable.to.update.record._", getItemName()));
                            textField.focus();
                            textField.selectAll();

                        }
                    }
                }
            });
            return textField;
        }
    };
    if (!getEditorViewPanel().isReadOnly()) {
        for (String propertyName : getVisibleColumns()) {
            getEditorViewPanel().getEditorTable().addGeneratedColumn(propertyName, columnGenerator);
        }
    }

    getEditorViewPanel().getEditorTable().addListener(tableClickListener);
    TableHelper.setupTable(getEditorViewPanel().getEditorTable());
}

From source file:com.rdonasco.datamanager.listeditor.controller.ListEditorViewPanelController.java

License:Apache License

private void addNewResourceItemVO() {
    try {/*w  ww . j  a v a  2  s . c  o  m*/
        Embedded icon = createDeleteIcon();
        VO resourceItemVO = createNewListEditorItem();
        setupDeleteIconClickListener(icon, resourceItemVO);
        resourceItemVO.setIcon(icon);
        BeanItem<VO> beanItem = dataContainer.addItem(resourceItemVO);
        getEditorViewPanel().getEditorTable().setCurrentPageFirstItemId(beanItem.getBean());
        getEditorViewPanel().getEditorTable().select(resourceItemVO);
        TextField field = getFirstFieldFromCacheFor(resourceItemVO);
        field.setReadOnly(false);
        field.focus();
        field.selectAll();
    } catch (RuntimeException e) {
        LOG.log(Level.SEVERE, e.getMessage(), e);
        getPopupProvider()
                .popUpError(I18NResource.localizeWithParameter("unable to add new item on", getListName()));
    }

}

From source file:com.swifta.mats.web.usermanagement.UserDetailsModule.java

private HorizontalLayout getPC() {

    VerticalLayout cAgentInfo = new VerticalLayout();
    final HorizontalLayout cPlaceholder = new HorizontalLayout();
    cAgentInfo.setMargin(new MarginInfo(true, true, true, true));
    cAgentInfo.setStyleName("c_details_test");

    final VerticalLayout cLBody = new VerticalLayout();

    cLBody.setStyleName("c_body_visible");
    tb = new Table("Linked child accounts");
    // addLinksTable();

    final VerticalLayout cAllProf = new VerticalLayout();

    HorizontalLayout cProfActions = new HorizontalLayout();
    final FormLayout cProfName = new FormLayout();

    cProfName.setStyleName("frm_profile_name");
    cProfName.setSizeUndefined();/*from  w  w w  .j  av  a2  s.com*/

    final Label lbProf = new Label();
    final TextField tFProf = new TextField();

    lbProf.setCaption("Profile Name: ");
    lbProf.setValue("Certified Authorized User.");

    tFProf.setCaption(lbProf.getCaption());
    cProfName.addComponent(lbProf);

    final Button btnEdit = new Button();
    btnEdit.setIcon(FontAwesome.EDIT);
    btnEdit.setStyleName("btn_link");
    btnEdit.setDescription("Edit profile name");

    final Button btnCancel = new Button();
    btnCancel.setIcon(FontAwesome.UNDO);
    btnCancel.setStyleName("btn_link");
    btnCancel.setDescription("Cancel Profile name editting.");

    Button btnAdd = new Button("+");
    // btnAdd.setIcon(FontAwesome.EDIT);
    btnAdd.setStyleName("btn_link");
    btnAdd.setDescription("Set new profile");

    Button btnRemove = new Button("-");
    // btnRemove.setIcon(FontAwesome.EDIT);
    btnRemove.setStyleName("btn_link");
    btnRemove.setDescription("Remove current profile");

    // cProf.addComponent(cProfName);
    cProfActions.addComponent(btnEdit);
    cProfActions.addComponent(btnCancel);
    cProfActions.addComponent(btnAdd);
    cProfActions.addComponent(btnRemove);

    btnCancel.setVisible(false);

    cAllProf.addComponent(cProfName);
    cAllProf.addComponent(cProfActions);
    cAllProf.setComponentAlignment(cProfActions, Alignment.TOP_CENTER);

    cLBody.addComponent(cAllProf);

    // cLBody.addComponent(tb);

    tb.setSelectable(true);

    cAgentInfo.addComponent(cLBody);

    btnLink = new Button("Add New Link");
    btnLink.setIcon(FontAwesome.LINK);
    btnLink.setDescription("Link new account.");

    // cLBody.addComponent(btnLink);
    // cLBody.setComponentAlignment(btnLink, Alignment.TOP_LEFT);
    btnLink.addClickListener(new LinkClickHandler());

    cPlaceholder.setVisible(false);
    addLinkUserContainer();
    cPlaceholder.setWidth("100%");

    cLBody.addComponent(cPlaceholder);
    cLBody.setComponentAlignment(cPlaceholder, Alignment.TOP_CENTER);
    HorizontalLayout c = new HorizontalLayout();
    c.addComponent(cAgentInfo);

    btnEdit.addClickListener(new Button.ClickListener() {

        private static final long serialVersionUID = -8427226211153164650L;

        @Override
        public void buttonClick(ClickEvent event) {

            if (btnEdit.getIcon().equals(FontAwesome.EDIT)) {

                tFProf.setValue(lbProf.getValue());
                tFProf.selectAll();
                cProfName.replaceComponent(lbProf, tFProf);
                btnEdit.setIcon(FontAwesome.SAVE);
                btnCancel.setVisible(true);
                return;

            } else if (btnEdit.getIcon().equals(FontAwesome.SAVE)) {

                lbProf.setValue(tFProf.getValue());
                cProfName.replaceComponent(tFProf, lbProf);
                btnEdit.setIcon(FontAwesome.EDIT);
                btnCancel.setVisible(false);

                return;
            }
            lbProf.setValue(tFProf.getValue());
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnCancel.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = -2870045546205986347L;

        @Override
        public void buttonClick(ClickEvent event) {
            cProfName.replaceComponent(tFProf, lbProf);
            btnEdit.setIcon(FontAwesome.EDIT);
            btnCancel.setVisible(false);

        }
    });

    btnAdd.addClickListener(new AddProfileHandler(cAllProf, cPlaceholder));

    btnRemove.addClickListener(new RemoveProfileHandler(pop));

    return c;

}

From source file:fr.amapj.view.engine.grid.ShortCutManager.java

License:Open Source License

protected void processAction(Key key, Object target) {
    if ((target instanceof TextField) == false) {
        return;//from   w  w w . j  av  a  2 s .c o  m
    }

    TextField from = (TextField) target;
    GridIJData fromIJ = (GridIJData) from.getData();
    GridIJData toIJ = findNext(key, fromIJ);
    if (toIJ != null) {
        TextField to = cells.get(toIJ);
        to.selectAll();
        to.focus();
    }
}

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

License:Apache License

/**
 * Creates a new {@link LoginWindow} instance.
 * //from w ww  . j a v a 2 s . co 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();
}