Example usage for com.vaadin.ui TextArea setWordWrap

List of usage examples for com.vaadin.ui TextArea setWordWrap

Introduction

In this page you can find the example usage for com.vaadin.ui TextArea setWordWrap.

Prototype

public void setWordWrap(boolean wordWrap) 

Source Link

Document

Sets the text area's word-wrap mode on or off.

Usage

From source file:org.apache.ace.log.server.ui.LogViewerExtension.java

License:Apache License

/**
 * Creates a {@link TextArea} with a dump of the given event's properties.
 * /* ww w . j  a v  a2 s  . c  o m*/
 * @param event
 *            the event to create a textarea for, cannot be <code>null</code>.
 * @return a {@link TextArea} instance, never <code>null</code>.
 */
final TextArea getProperties(Event event) {
    Map<String, String> props = event.getProperties();

    TextArea area = new TextArea("", dumpProperties(props));
    area.setWidth(FILL_AREA);
    area.setRows(props.size());
    area.setWordwrap(false);
    area.setReadOnly(true);
    area.setImmediate(true);
    return area;
}

From source file:org.apache.usergrid.chop.webapp.view.util.UIUtil.java

License:Apache License

public static TextArea addTextArea(AbsoluteLayout parent, String caption, String position, String width,
        String height, boolean readOnly) {

    TextArea textArea = new TextArea(caption);
    textArea.setWidth(width);//from   ww  w .  j  a  v  a 2 s.  co m
    textArea.setHeight(height);
    textArea.setWordwrap(false);
    textArea.setReadOnly(readOnly);

    parent.addComponent(textArea, position);

    return textArea;
}

From source file:org.ikasan.dashboard.ui.administration.panel.UserDirectoriesPanel.java

License:BSD License

protected void populateDirectoryTable(final AuthenticationMethod authenticationMethod) {
    Button test = new Button("Test");
    test.setStyleName(BaseTheme.BUTTON_LINK);
    test.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                authenticationProviderFactory.testAuthenticationConnection(authenticationMethod);
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);/*from w w w  .ja v a 2  s  . co  m*/

                Notification.show("Error occurred while testing connection!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while testing connection!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Connection Successful!");
        }
    });

    final Button enableDisableButton = new Button();

    if (authenticationMethod.isEnabled()) {
        enableDisableButton.setCaption("Disable");
    } else {
        enableDisableButton.setCaption("Enable");
    }
    enableDisableButton.setStyleName(BaseTheme.BUTTON_LINK);
    enableDisableButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                if (authenticationMethod.isEnabled()) {
                    authenticationMethod.setEnabled(false);
                } else {
                    authenticationMethod.setEnabled(true);
                }

                securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                populateAll();
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error trying to enable/disable the authentication method!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            if (authenticationMethod.isEnabled()) {
                enableDisableButton.setCaption("Disable");
                Notification.show("Enabled!");
            } else {
                enableDisableButton.setCaption("Enable");
                Notification.show("Disabled!");
            }
        }
    });

    Button delete = new Button("Delete");
    delete.setStyleName(BaseTheme.BUTTON_LINK);
    delete.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                securityService.deleteAuthenticationMethod(authenticationMethod);

                List<AuthenticationMethod> authenticationMethods = securityService.getAuthenticationMethods();

                directoryTable.removeAllItems();

                long order = 1;

                for (final AuthenticationMethod authenticationMethod : authenticationMethods) {
                    authenticationMethod.setOrder(order++);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);
                }

                populateAll();
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error trying to delete the authentication method!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Deleted!");
        }
    });

    Button edit = new Button("Edit");
    edit.setStyleName(BaseTheme.BUTTON_LINK);
    edit.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            UserDirectoryManagementPanel authMethodPanel = new UserDirectoryManagementPanel(
                    authenticationMethod, securityService, authenticationProviderFactory, ldapService);

            Window window = new Window("Configure User Directory");
            window.setModal(true);
            window.setHeight("90%");
            window.setWidth("90%");

            window.setContent(authMethodPanel);

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

    Button synchronise = new Button("Synchronise");
    synchronise.setStyleName(BaseTheme.BUTTON_LINK);

    synchronise.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                ldapService.synchronize(authenticationMethod);

                authenticationMethod.setLastSynchronised(new Date());
                securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                populateAll();
            } catch (UnexpectedRollbackException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                logger.error("Most specific cause: " + e.getMostSpecificCause());
                e.getMostSpecificCause().printStackTrace();
                logger.error("Most specific cause: " + e.getRootCause());
                e.getRootCause().printStackTrace();

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (RuntimeException e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            } catch (Exception e) {
                StringWriter sw = new StringWriter();
                PrintWriter pw = new PrintWriter(sw);
                e.printStackTrace(pw);

                Notification.show("Error occurred while synchronizing!", sw.toString(),
                        Notification.Type.ERROR_MESSAGE);

                return;
            }

            Notification.show("Synchronized!");
        }
    });

    GridLayout operationsLayout = new GridLayout(9, 2);
    operationsLayout.setWidth("250px");
    operationsLayout.addComponent(enableDisableButton, 0, 0);
    operationsLayout.addComponent(new Label(" "), 1, 0);
    operationsLayout.addComponent(edit, 2, 0);
    operationsLayout.addComponent(new Label(" "), 3, 0);
    operationsLayout.addComponent(delete, 4, 0);
    operationsLayout.addComponent(new Label(" "), 5, 0);
    operationsLayout.addComponent(test, 6, 0);
    operationsLayout.addComponent(new Label(" "), 7, 0);
    operationsLayout.addComponent(synchronise, 8, 0);

    TextArea synchronisedTextArea = new TextArea();
    synchronisedTextArea.setRows(3);
    synchronisedTextArea.setWordwrap(true);

    if (authenticationMethod.getLastSynchronised() != null) {
        synchronisedTextArea.setValue(
                "This directory was last synchronised at " + authenticationMethod.getLastSynchronised());
    } else {
        synchronisedTextArea.setValue("This directory has not been synchronised");
    }

    synchronisedTextArea.setSizeFull();
    synchronisedTextArea.setReadOnly(true);

    operationsLayout.addComponent(synchronisedTextArea, 0, 1, 8, 1);

    HorizontalLayout orderLayout = new HorizontalLayout();
    orderLayout.setWidth("50%");

    if (authenticationMethod.getOrder() != 1) {
        Button upArrow = new Button(VaadinIcons.ARROW_UP);
        upArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        upArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS);
        upArrow.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                if (authenticationMethod.getOrder() != 1) {
                    AuthenticationMethod upAuthMethod = securityService
                            .getAuthenticationMethodByOrder(authenticationMethod.getOrder() - 1);

                    upAuthMethod.setOrder(authenticationMethod.getOrder());
                    authenticationMethod.setOrder(authenticationMethod.getOrder() - 1);

                    securityService.saveOrUpdateAuthenticationMethod(upAuthMethod);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                    populateAll();
                }
            }
        });

        orderLayout.addComponent(upArrow);
    }

    long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods();

    if (authenticationMethod.getOrder() != numberOfAuthMethods) {
        Button downArrow = new Button(VaadinIcons.ARROW_DOWN);
        downArrow.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
        downArrow.addStyleName(ValoTheme.BUTTON_BORDERLESS);
        downArrow.addClickListener(new Button.ClickListener() {
            public void buttonClick(ClickEvent event) {
                long numberOfAuthMethods = securityService.getNumberOfAuthenticationMethods();

                if (authenticationMethod.getOrder() != numberOfAuthMethods) {
                    AuthenticationMethod downAuthMethod = securityService
                            .getAuthenticationMethodByOrder(authenticationMethod.getOrder() + 1);

                    downAuthMethod.setOrder(authenticationMethod.getOrder());
                    authenticationMethod.setOrder(authenticationMethod.getOrder() + 1);

                    securityService.saveOrUpdateAuthenticationMethod(downAuthMethod);
                    securityService.saveOrUpdateAuthenticationMethod(authenticationMethod);

                    populateAll();
                }
            }
        });

        orderLayout.addComponent(downArrow);
    }

    this.directoryTable.addItem(new Object[] { authenticationMethod.getName(), "Microsoft Active Directory",
            orderLayout, operationsLayout }, authenticationMethod);
}

From source file:org.opennms.features.pluginmgr.vaadin.pluginmanager.ErrorMessageWindow.java

License:Apache License

public ErrorMessageWindow(SystemMessages systemMessages) {
    super("Full Log Message"); // Set window caption
    center();//from ww  w . j a v  a  2s . c om
    setHeight("75%");
    setWidth("75%");

    // Some basic content for the window
    VerticalLayout content = new VerticalLayout();
    content.setSizeFull();

    TextArea ta = new TextArea();
    ta.setWordwrap(true);
    ta.setImmediate(true);
    ta.setWidth("100%");
    ta.setHeight("100%");
    content.addComponent(ta);
    content.setExpandRatio(ta, 1.0f);

    if (systemMessages != null) {
        ta.setValue(systemMessages.getLongMessage());
    } else {
        ta.setValue("Error: systemMessages should not be null");
        LOG.error("Error: systemMessages should not be null");
    }
    ta.setReadOnly(false);

    content.setMargin(true);
    setContent(content);

    // Disable the close button
    setClosable(false);

    // Trivial logic for closing the sub-window
    Button ok = new Button("OK");
    ok.addClickListener(new ClickListener() {
        private static final long serialVersionUID = 1L;

        public void buttonClick(ClickEvent event) {
            close(); // Close the sub-window
        }
    });
    content.addComponent(ok);
}

From source file:org.vaadin.addons.serverpush.samples.chat.ChatLayout.java

License:Apache License

public ChatLayout(final User user, final User from) {
    setSizeFull();//from ww w.j a  v  a  2 s .co  m
    Table table = new Table();
    table.setSizeFull();
    table.setContainerDataSource(new MessageContainer(user, from));
    table.addListener(new Container.ItemSetChangeListener() {
        public void containerItemSetChange(Container.ItemSetChangeEvent event) {
            ((Pushable) getApplication()).push();
        }
    });
    table.setVisibleColumns(new String[] { "from", "to", "received", "message" });

    addComponent(table);

    HorizontalLayout hl = new HorizontalLayout();
    hl.setWidth("100%");
    final TextArea textArea = new TextArea();
    textArea.setRows(5);
    textArea.setSizeFull();
    textArea.setWordwrap(true);
    textArea.setValue("");
    hl.addComponent(textArea);

    Button sendButton = new Button("Send");
    sendButton.setWidth("120px");
    sendButton.setImmediate(true);
    sendButton.addListener(new Button.ClickListener() {
        public void buttonClick(Button.ClickEvent event) {
            Message msg = new Message();
            msg.setFrom(from);
            msg.setTo(user);
            msg.setMessage(textArea.getValue().toString());
            MessageManager.getInstance().addMessage(msg);
            textArea.setValue("");
        }
    });
    hl.addComponent(sendButton);
    hl.setComponentAlignment(sendButton, Alignment.BOTTOM_RIGHT);
    hl.setExpandRatio(textArea, 1);
    addComponent(hl);

    setExpandRatio(table, 1);
}