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.hbrs.nosql.mongoweb.gui.views.UseCaseU.java

@Override
protected void setUp() {
    MongoDBConnector mongo = new MongoDBConnector();

    VerticalLayout vl = new VerticalLayout();

    //CRUD Operations
    Label lbCreate = new Label("Update:");
    addComponent(lbCreate);/*from   w ww . j  a va2s .c  o m*/

    HorizontalLayout hlCreate = new HorizontalLayout();
    TextField tfCreate = new TextField("Neues Dokument:");
    hlCreate.addComponent(tfCreate);
    Button btSaveCreate = new Button("Speichern");
    btSaveCreate.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {
            if (!tfCreate.getValue().equals("")) {
                String doc = tfCreate.getValue();
                mongo.insertNewDocumnet(doc);
            }
        }
    });

    hlCreate.addComponent(btSaveCreate);

    addComponent(hlCreate);

    //Read: All

    //Update:
    // https://www.mkyong.com/mongodb/java-mongodb-update-document/
    // http://mongodb.github.io/mongo-java-driver/3.4/driver/getting-started/quick-start/

    //Delete: Attributes or Documents

    setMargin(true);
    setSpacing(true);
}

From source file:org.hip.vif.admin.admin.ui.SendMailView.java

License:Open Source License

/** @param inGroups {@link GroupContainer}
 * @param inTask {@link SendMailTask} */
public SendMailView(final GroupContainer inGroups, final SendMailTask inTask) {
    final IMessages lMessages = Activator.getMessages();
    final VerticalLayout lLayout = initLayout(lMessages, "admin.send.mail.title.page"); //$NON-NLS-1$

    lLayout.addComponent(new Label(lMessages.getMessage("admin.send.remark"), ContentMode.HTML)); //$NON-NLS-1$
    lLayout.addComponent(RiplaViewHelper.createSpacer());

    final LabelValueTable lTable = new LabelValueTable();
    final ListSelect lGroups = new ListSelect();
    lGroups.setContainerDataSource(inGroups);
    lGroups.setRows(Math.min(SELECT_SIZE, inGroups.size()));
    lGroups.setStyleName(VIF_STYLE);//from w w  w. ja v a  2s.  c  o  m
    lGroups.setMultiSelect(true);
    lGroups.setItemCaptionMode(ItemCaptionMode.PROPERTY);
    lGroups.setItemCaptionPropertyId(GroupContainer.PROPERTY_CAPTION);
    lGroups.focus();
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.select"), lGroups); //$NON-NLS-1$

    final TextField lSubject = new TextField();
    lSubject.setWidth(WIDTH, Unit.PIXELS);
    lSubject.setStyleName(VIF_STYLE);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.subject"), lSubject); //$NON-NLS-1$

    final RichTextArea lBody = new RichTextArea();
    lBody.setStyleName("vif-editor " + VIF_STYLE); //$NON-NLS-1$
    lBody.setWidth(WIDTH, Unit.PIXELS);
    lTable.addRowEmphasized(lMessages.getMessage("admin.send.mail.label.body"), lBody); //$NON-NLS-1$
    lLayout.addComponent(lTable);

    send = new Button(lMessages.getMessage("admin.send.mail.button.send")); //$NON-NLS-1$
    // send.setClickShortcut(KeyCode.ENTER);
    send.addClickListener(new Button.ClickListener() {
        @Override
        @SuppressWarnings("unchecked")
        public void buttonClick(final ClickEvent inEvent) {
            if (!isValid(lGroups, lSubject, lBody)) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.not.valid"), //$NON-NLS-1$
                        Type.WARNING_MESSAGE);
                return;
            }
            if (!inTask.processGroups((Collection<GroupWrapper>) lGroups.getValue(),
                    lSubject.getValue().toString(), lBody.getValue())) {
                Notification.show(lMessages.getMessage("admin.send.mail.msg.errmsg"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            }
        }
    });
    lLayout.addComponent(send);
}

From source file:org.hip.vif.admin.admin.ui.SendMailView.java

License:Open Source License

@SuppressWarnings("unchecked")
private boolean isValid(final ListSelect inGroups, final TextField inSubject, final RichTextArea inBody) {
    return !(((Collection<GroupWrapper>) inGroups.getValue()).isEmpty()
            || inSubject.getValue().toString().trim().length() == 0 || inBody.getValue().trim().length() == 0);
}

From source file:org.hip.vif.forum.search.ui.SearchContentView.java

License:Open Source License

/** View constructor.
 *
 * @param inHelpContent URL/*from   w  w  w  . j  a v  a2 s  . c  o m*/
 * @param inTask {@link SearchContentTask} */
public SearchContentView(final URL inHelpContent, final SearchContentTask inTask) {
    final VerticalLayout lLayout = new VerticalLayout();
    setCompositionRoot(lLayout);

    final IMessages lMessages = Activator.getMessages();
    lLayout.setStyleName("vif-view"); //$NON-NLS-1$
    lLayout.addComponent(new Label(String.format(VIFViewHelper.TMPL_TITLE, "vif-pagetitle", //$NON-NLS-1$
            lMessages.getMessage("ui.search.view.title.page")), ContentMode.HTML)); //$NON-NLS-1$

    final HorizontalLayout lInput = new HorizontalLayout();
    lInput.setMargin(new MarginInfo(true, true, true, false));
    final Label lLabel = new Label(
            String.format("%s:&#160;", lMessages.getMessage("ui.search.view.label.input")), ContentMode.HTML); //$NON-NLS-1$ //$NON-NLS-2$
    lInput.addComponent(RiplaViewHelper.makeUndefinedWidth(lLabel));
    lInput.setComponentAlignment(lLabel, Alignment.MIDDLE_LEFT);

    final TextField lSearch = new TextField();
    lSearch.setColumns(50);
    lSearch.focus();
    lInput.addComponent(lSearch);
    lInput.addComponent(
            new HelpButton(lMessages.getMessage("ui.search.view.button.help"), inHelpContent, 700, 620)); //$NON-NLS-1$
    lLayout.addComponent(lInput);

    final Table lSearchResult = new Table();

    final Button lButton = new Button(lMessages.getMessage("ui.search.view.button.search")); //$NON-NLS-1$
    lButton.setClickShortcut(KeyCode.ENTER);
    lButton.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(final ClickEvent inEvent) {
            final String lQuery = lSearch.getValue().toString().trim();
            if (lQuery.length() <= MIN_INPUT) {
                Notification.show(lMessages.getMessage("errmsg.search.noInput"), Type.WARNING_MESSAGE); //$NON-NLS-1$
            } else {
                try {
                    initTable(inTask.search(lQuery), lSearchResult);
                    lSearchResult.setVisible(true);
                } catch (final NoHitsException exc) {
                    lSearchResult.setVisible(false);
                    Notification.show(
                            lMessages.getFormattedMessage("errmsg.search.noHits", exc.getQueryString()), //$NON-NLS-1$
                            Type.WARNING_MESSAGE);
                } catch (final Exception exc) {
                    lSearchResult.setVisible(false);
                    Notification.show(lMessages.getMessage("errmsg.search.wrongInput"), Type.WARNING_MESSAGE); //$NON-NLS-1$
                }
            }
        }
    });
    lLayout.addComponent(lButton);

    lLayout.addComponent(RiplaViewHelper.createSpacer());

    lSearchResult.setVisible(false);
    lSearchResult.setWidth("100%"); //$NON-NLS-1$
    lSearchResult.setColumnCollapsingAllowed(true);
    lSearchResult.setColumnReorderingAllowed(true);
    lSearchResult.setSelectable(true);
    lSearchResult.setImmediate(true);
    lSearchResult.addValueChangeListener(inTask);
    lLayout.addComponent(lSearchResult);
}

From source file:org.ikasan.dashboard.ui.topology.window.WiretapConfigurationWindow.java

License:BSD License

/**
  * Helper method to initialise this object.
  * //w  ww.  jav a2  s  .co m
  * @param message
  */
protected void init() {
    setModal(true);
    setHeight("90%");
    setWidth("90%");

    GridLayout layout = new GridLayout(2, 10);
    layout.setSizeFull();
    layout.setSpacing(true);
    layout.setMargin(true);
    layout.setColumnExpandRatio(0, .25f);
    layout.setColumnExpandRatio(1, .75f);

    Label wiretapLabel = new Label("Wiretap Configuration");
    wiretapLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(wiretapLabel);

    Label moduleNameLabel = new Label();
    moduleNameLabel.setContentMode(ContentMode.HTML);
    moduleNameLabel.setValue(VaadinIcons.ARCHIVE.getHtml() + " Module Name:");
    moduleNameLabel.setSizeUndefined();
    layout.addComponent(moduleNameLabel, 0, 1);
    layout.setComponentAlignment(moduleNameLabel, Alignment.MIDDLE_RIGHT);

    TextField moduleNameTextField = new TextField();
    moduleNameTextField.setRequired(true);
    moduleNameTextField.setValue(this.component.getFlow().getModule().getName());
    moduleNameTextField.setReadOnly(true);
    moduleNameTextField.setWidth("80%");
    layout.addComponent(moduleNameTextField, 1, 1);

    Label flowNameLabel = new Label();
    flowNameLabel.setContentMode(ContentMode.HTML);
    flowNameLabel.setValue(VaadinIcons.AUTOMATION.getHtml() + " Flow Name:");
    flowNameLabel.setSizeUndefined();
    layout.addComponent(flowNameLabel, 0, 2);
    layout.setComponentAlignment(flowNameLabel, Alignment.MIDDLE_RIGHT);

    TextField flowNameTextField = new TextField();
    flowNameTextField.setRequired(true);
    flowNameTextField.setValue(this.component.getFlow().getName());
    flowNameTextField.setReadOnly(true);
    flowNameTextField.setWidth("80%");
    layout.addComponent(flowNameTextField, 1, 2);

    Label componentNameLabel = new Label();
    componentNameLabel.setContentMode(ContentMode.HTML);
    componentNameLabel.setValue(VaadinIcons.COG.getHtml() + " Component Name:");
    componentNameLabel.setSizeUndefined();
    layout.addComponent(componentNameLabel, 0, 3);
    layout.setComponentAlignment(componentNameLabel, Alignment.MIDDLE_RIGHT);

    TextField componentNameTextField = new TextField();
    componentNameTextField.setRequired(true);
    componentNameTextField.setValue(this.component.getName());
    componentNameTextField.setReadOnly(true);
    componentNameTextField.setWidth("80%");
    layout.addComponent(componentNameTextField, 1, 3);

    Label errorCategoryLabel = new Label("Relationship:");
    errorCategoryLabel.setSizeUndefined();
    layout.addComponent(errorCategoryLabel, 0, 4);
    layout.setComponentAlignment(errorCategoryLabel, Alignment.MIDDLE_RIGHT);

    final ComboBox relationshipCombo = new ComboBox();
    //      relationshipCombo.addValidator(new StringLengthValidator(
    //               "An relationship must be selected!", 1, -1, false));
    relationshipCombo.setImmediate(false);
    relationshipCombo.setValidationVisible(false);
    relationshipCombo.setRequired(true);
    relationshipCombo.setRequiredError("A relationship must be selected!");
    relationshipCombo.setHeight("30px");
    relationshipCombo.setNullSelectionAllowed(false);
    layout.addComponent(relationshipCombo, 1, 4);
    relationshipCombo.addItem("before");
    relationshipCombo.setItemCaption("before", "Before");
    relationshipCombo.addItem("after");
    relationshipCombo.setItemCaption("after", "After");

    Label jobTypeLabel = new Label("Job Type:");
    jobTypeLabel.setSizeUndefined();
    layout.addComponent(jobTypeLabel, 0, 5);
    layout.setComponentAlignment(jobTypeLabel, Alignment.MIDDLE_RIGHT);

    final ComboBox jobTopCombo = new ComboBox();
    //      jobTopCombo.addValidator(new StringLengthValidator(
    //               "A job type must be selected!", 1, -1, false));
    jobTopCombo.setImmediate(false);
    jobTopCombo.setValidationVisible(false);
    jobTopCombo.setRequired(true);
    jobTopCombo.setRequiredError("A job type must be selected!");
    jobTopCombo.setHeight("30px");
    jobTopCombo.setNullSelectionAllowed(false);
    layout.addComponent(jobTopCombo, 1, 5);
    jobTopCombo.addItem("loggingJob");
    jobTopCombo.setItemCaption("loggingJob", "Logging Job");
    jobTopCombo.addItem("wiretapJob");
    jobTopCombo.setItemCaption("wiretapJob", "Wiretap Job");

    final Label timeToLiveLabel = new Label("Time to Live:");
    timeToLiveLabel.setSizeUndefined();
    timeToLiveLabel.setVisible(false);
    layout.addComponent(timeToLiveLabel, 0, 6);
    layout.setComponentAlignment(timeToLiveLabel, Alignment.MIDDLE_RIGHT);

    final TextField timeToLiveTextField = new TextField();
    timeToLiveTextField.setRequired(true);
    timeToLiveTextField.setValidationVisible(false);
    jobTopCombo.setRequiredError("A time to live value must be entered!");
    timeToLiveTextField.setVisible(false);
    timeToLiveTextField.setWidth("40%");
    layout.addComponent(timeToLiveTextField, 1, 6);

    jobTopCombo.addValueChangeListener(new ComboBox.ValueChangeListener() {

        /* (non-Javadoc)
         * @see com.vaadin.data.Property.ValueChangeListener#valueChange(com.vaadin.data.Property.ValueChangeEvent)
         */
        @Override
        public void valueChange(ValueChangeEvent event) {
            String value = (String) event.getProperty().getValue();

            if (value.equals("wiretapJob")) {
                timeToLiveLabel.setVisible(true);
                timeToLiveTextField.setVisible(true);
            } else {
                timeToLiveLabel.setVisible(false);
                timeToLiveTextField.setVisible(false);
            }
        }

    });

    GridLayout buttonLayouts = new GridLayout(3, 1);
    buttonLayouts.setSpacing(true);

    Button saveButton = new Button("Save");
    saveButton.setStyleName(ValoTheme.BUTTON_SMALL);
    saveButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            try {
                relationshipCombo.validate();
                jobTopCombo.validate();

                if (timeToLiveTextField.isVisible()) {
                    timeToLiveTextField.validate();
                }
            } catch (InvalidValueException e) {
                relationshipCombo.setValidationVisible(true);
                relationshipCombo.markAsDirty();
                jobTopCombo.setValidationVisible(true);
                jobTopCombo.markAsDirty();

                if (timeToLiveTextField.isVisible()) {
                    timeToLiveTextField.setValidationVisible(true);
                    timeToLiveTextField.markAsDirty();
                }

                Notification.show("There are errors on the wiretap creation form!", Type.ERROR_MESSAGE);
                return;
            }

            createWiretap((String) relationshipCombo.getValue(), (String) jobTopCombo.getValue(),
                    timeToLiveTextField.getValue());
        }
    });

    Button cancelButton = new Button("Cancel");
    cancelButton.setStyleName(ValoTheme.BUTTON_SMALL);
    cancelButton.addClickListener(new Button.ClickListener() {
        public void buttonClick(ClickEvent event) {
            close();
        }
    });

    buttonLayouts.addComponent(saveButton);
    buttonLayouts.addComponent(cancelButton);

    layout.addComponent(buttonLayouts, 0, 7, 1, 7);
    layout.setComponentAlignment(buttonLayouts, Alignment.MIDDLE_CENTER);

    Panel paramPanel = new Panel();
    paramPanel.setStyleName("dashboard");
    paramPanel.setWidth("100%");
    paramPanel.setContent(layout);

    triggerTable = new Table();

    Label existingWiretapLabel = new Label("Existing Wiretaps");
    existingWiretapLabel.setStyleName(ValoTheme.LABEL_HUGE);
    layout.addComponent(existingWiretapLabel, 0, 8, 1, 8);

    layout.addComponent(triggerTable, 0, 9, 1, 9);
    layout.setComponentAlignment(triggerTable, Alignment.TOP_CENTER);

    this.triggerTable.setWidth("80%");
    this.triggerTable.setHeight(150, Unit.PIXELS);
    this.triggerTable.setCellStyleGenerator(new IkasanCellStyleGenerator());
    this.triggerTable.addStyleName(ValoTheme.TABLE_SMALL);
    this.triggerTable.addStyleName("ikasan");
    this.triggerTable.addContainerProperty("Job Type", String.class, null);
    this.triggerTable.addContainerProperty("Relationship", String.class, null);
    this.triggerTable.addContainerProperty("Trigger Parameters", String.class, null);
    this.triggerTable.addContainerProperty("", Button.class, null);

    refreshTriggerTable();

    GridLayout wrapper = new GridLayout(1, 1);
    wrapper.setMargin(true);
    wrapper.setSizeFull();
    wrapper.addComponent(paramPanel);

    this.setContent(wrapper);
}

From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummaryMultiPlayerMainView.java

License:Open Source License

@Override
public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity,
        final NativeSelect orderSide) {
    HorizontalLayout buttonsBar = new HorizontalLayout();
    final Button buySellButton = new Button("Buy");
    buySellButton.addClickListener(new Button.ClickListener() {
        @Override/*from  w  w  w .j av a  2s .c o  m*/
        public void buttonClick(Button.ClickEvent clickEvent) {

            //check for invalid orders
            boolean invalidOrder = false;
            String numericRegex = "^[0-9]+$";
            //conditions to check
            if (stocksList.getValue() == null || quantity.getValue() == null
                    || !quantity.getValue().toString().matches(numericRegex)) {
                invalidOrder = true;

            }
            //if this is a sell order
            else if (((OrderType) orderSide.getValue()) == OrderType.SELL) {
                //check if te user has this stock
                BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable
                        .getContainerDataSource();

                if (!beans.containsId(stocksList.getValue().toString())) {
                    invalidOrder = true;
                }
            }

            if (invalidOrder) {
                Notification.show("Invalid Order");
                return;
            }

            try {
                Boolean status = player.executeOrder(stocksList.getValue().toString(),
                        Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()),
                        userName);
                //if the transaction was a success
                if (status) {
                    updatePortfolioTable(stocksList.getValue().toString());
                    //update the account balance
                    updateAccountBalance();
                } else {

                    Notification.show(status.toString());
                }
            } catch (InvalidOrderException e) {
                Notification.show(e.getMessage());
            } catch (UserJoinException e) {
                e.printStackTrace();
            }

        }
    });

    orderSide.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) {
                buySellButton.setCaption("Buy");
            } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) {
                buySellButton.setCaption("Sell");
            }
        }
    });

    buttonsBar.addComponent(buySellButton);

    return buttonsBar;
}

From source file:org.investovator.ui.dataplayback.user.dashboard.dailysummary.DailySummarySinglePlayerMainView.java

License:Open Source License

@Override
public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity,
        final NativeSelect orderSide) {

    HorizontalLayout buttonsBar = new HorizontalLayout();
    final Button buySellButton = new Button("Buy");
    buySellButton.addClickListener(new Button.ClickListener() {
        @Override//from   w w  w. j  a  v a 2  s .  c  o m
        public void buttonClick(Button.ClickEvent clickEvent) {

            //check for invalid orders
            boolean invalidOrder = false;
            String numericRegex = "^[0-9]+$";
            //conditions to check
            if (stocksList.getValue() == null || quantity.getValue() == null
                    || !quantity.getValue().toString().matches(numericRegex)) {
                invalidOrder = true;

            }
            //if this is a sell order
            else if (((OrderType) orderSide.getValue()) == OrderType.SELL) {
                //check if te user has this stock
                BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable
                        .getContainerDataSource();

                if (!beans.containsId(stocksList.getValue().toString())) {
                    invalidOrder = true;
                }
            }

            if (invalidOrder) {
                Notification.show("Invalid Order");
                return;
            }

            try {
                Boolean status = player.executeOrder(stocksList.getValue().toString(),
                        Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()),
                        userName);
                //if the transaction was a success
                if (status) {
                    updatePortfolioTable(stocksList.getValue().toString());

                    updateAccountBalance();
                } else {

                    Notification.show(status.toString());
                }
            } catch (InvalidOrderException e) {
                Notification.show(e.getMessage());
            } catch (UserJoinException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }
    });
    orderSide.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) {
                buySellButton.setCaption("Buy");
            } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) {
                buySellButton.setCaption("Sell");
            }
        }
    });

    Button nextDayB = new Button("Next day");
    nextDayB.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(Button.ClickEvent clickEvent) {

            player.playNextDay();
            updateProfitChart(player.getCurrentTime());

            //push the changes
            UI.getCurrent().access(new Runnable() {
                @Override
                public void run() {
                    getUI().push();
                }
            });

        }
    });

    buttonsBar.addComponent(nextDayB);

    buttonsBar.addComponent(buySellButton);

    return buttonsBar;
}

From source file:org.investovator.ui.dataplayback.user.dashboard.realtime.RealTimeMainView.java

License:Open Source License

@Override
public HorizontalLayout getBuySellForumButtons(final ComboBox stocksList, final TextField quantity,
        final NativeSelect orderSide) {
    HorizontalLayout buttonsBar = new HorizontalLayout();
    final Button buySellButton = new Button("Buy");
    buySellButton.addClickListener(new Button.ClickListener() {
        @Override/*w w  w .j a  v  a 2  s. c o  m*/
        public void buttonClick(Button.ClickEvent clickEvent) {
            //check for invalid orders
            boolean invalidOrder = false;
            String numericRegex = "^[0-9]+$";
            //conditions to check
            if (stocksList.getValue() == null || quantity.getValue() == null
                    || !quantity.getValue().toString().matches(numericRegex)) {
                invalidOrder = true;

            }
            //if this is a sell order
            else if (((OrderType) orderSide.getValue()) == OrderType.SELL) {
                //check if te user has this stock
                BeanContainer<String, PortfolioBean> beans = (BeanContainer<String, PortfolioBean>) portfolioTable
                        .getContainerDataSource();

                if (!beans.containsId(stocksList.getValue().toString())) {
                    invalidOrder = true;
                }
            }

            if (invalidOrder) {
                Notification.show("Invalid Order");
                return;
            }

            try {
                Boolean status = player.executeOrder(stocksList.getValue().toString(),
                        Integer.parseInt(quantity.getValue().toString()), ((OrderType) orderSide.getValue()),
                        userName);
                //if the transaction was a success
                if (status) {
                    updatePortfolioTable(stocksList.getValue().toString());
                    //update account info
                    updateAccountBalance();
                    Notification.show("Order executed successfully", Notification.Type.TRAY_NOTIFICATION);
                } else {

                    Notification.show(status.toString());
                }
            } catch (InvalidOrderException e) {
                Notification.show(e.getMessage());
            } catch (UserJoinException e) {
                e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
            }

        }
    });

    orderSide.addValueChangeListener(new Property.ValueChangeListener() {
        @Override
        public void valueChange(Property.ValueChangeEvent valueChangeEvent) {
            if (valueChangeEvent.getProperty().getValue() == OrderType.BUY) {
                buySellButton.setCaption("Buy");
            } else if (valueChangeEvent.getProperty().getValue() == OrderType.SELL) {
                buySellButton.setCaption("Sell");
            }
        }
    });

    buttonsBar.addComponent(buySellButton);

    return buttonsBar;
}

From source file:org.jpos.qi.Header.java

License:Open Source License

private Layout createSearch() {
    CssLayout group = new CssLayout();
    group.addStyleName("search-layout");
    group.addStyleName("v-component-group");

    TextField searchField = new TextField();
    searchField.addStyleName("inline-icon");
    searchField.addStyleName("tiny");
    searchField.setIcon(VaadinIcons.SEARCH);
    searchField.setWidth("400px");
    //TODO: vaadin8 incompatible methods
    //        searchField.setImmediate(true);
    //        searchField.addValidator(new RegexpValidator(
    //            app.getMessage("errorMessage.invalidField", app.getMessage("search")),QIResources.ALPHANUMERIC_SYMBOLS_PATTERN)
    //        );//  www  .j  ava 2  s .  co m
    //        searchField.setValidationVisible(false);
    group.addComponent(searchField);

    Button searchButton = new Button(app.getMessage("search"));
    searchButton.addClickListener(event -> {
        if (searchField.getValue() != null && !searchField.getValue().isEmpty() /*&& searchField.isValid()*/)
            app.getNavigator().navigateTo("/search/" + searchField.getValue());
        else
            app.displayNotification(app.getMessage("errorMessage.invalidField", app.getMessage("search")));
    });
    searchButton.addStyleName("tiny");

    group.addComponent(searchButton);
    return group;
}

From source file:org.jumpmind.metl.ui.views.deploy.EditAgentPanel.java

License:Open Source License

public EditAgentPanel(ApplicationContext context, TabbedPanel tabbedPanel, Agent agent) {
    this.context = context;
    this.tabbedPanel = tabbedPanel;
    this.agent = agent;
    this.backgroundRefresherService = context.getBackgroundRefresherService();

    HorizontalLayout editAgentLayout = new HorizontalLayout();
    editAgentLayout.setSpacing(true);/*w  ww .j a va  2  s .  c  o  m*/
    editAgentLayout.setMargin(new MarginInfo(true, false, false, true));
    editAgentLayout.addStyleName(ValoTheme.LAYOUT_HORIZONTAL_WRAPPING);
    addComponent(editAgentLayout);

    final ComboBox startModeCombo = new ComboBox("Start Mode");
    startModeCombo.setImmediate(true);
    startModeCombo.setNullSelectionAllowed(false);
    AgentStartMode[] modes = AgentStartMode.values();
    for (AgentStartMode agentStartMode : modes) {
        startModeCombo.addItem(agentStartMode.name());
    }
    startModeCombo.setValue(agent.getStartMode());
    startModeCombo.addValueChangeListener(event -> {
        agent.setStartMode((String) startModeCombo.getValue());
        context.getConfigurationService().save((AbstractObject) EditAgentPanel.this.agent);
    });

    editAgentLayout.addComponent(startModeCombo);
    editAgentLayout.setComponentAlignment(startModeCombo, Alignment.BOTTOM_LEFT);

    Button parameterButton = new Button("Parameters");
    parameterButton.addClickListener(new ParameterClickListener());
    editAgentLayout.addComponent(parameterButton);
    editAgentLayout.setComponentAlignment(parameterButton, Alignment.BOTTOM_LEFT);

    HorizontalLayout buttonGroup = new HorizontalLayout();

    final TextField hostNameField = new TextField("Hostname");
    hostNameField.setImmediate(true);
    hostNameField.setTextChangeEventMode(TextChangeEventMode.LAZY);
    hostNameField.setTextChangeTimeout(100);
    hostNameField.setWidth(20, Unit.EM);
    hostNameField.setNullRepresentation("");
    hostNameField.setValue(agent.getHost());
    hostNameField.addValueChangeListener(event -> {
        agent.setHost((String) hostNameField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });

    buttonGroup.addComponent(hostNameField);
    buttonGroup.setComponentAlignment(hostNameField, Alignment.BOTTOM_LEFT);

    Button getHostNameButton = new Button("Get Host");
    getHostNameButton.addClickListener(event -> hostNameField.setValue(AppUtils.getHostName()));
    buttonGroup.addComponent(getHostNameButton);
    buttonGroup.setComponentAlignment(getHostNameButton, Alignment.BOTTOM_LEFT);

    editAgentLayout.addComponent(buttonGroup);
    editAgentLayout.setComponentAlignment(buttonGroup, Alignment.BOTTOM_LEFT);

    Button exportButton = new Button("Export Agent Config", event -> exportConfiguration());
    editAgentLayout.addComponent(exportButton);
    editAgentLayout.setComponentAlignment(exportButton, Alignment.BOTTOM_LEFT);

    CheckBox autoRefresh = new CheckBox("Auto Refresh", Boolean.valueOf(agent.isAutoRefresh()));
    autoRefresh.setImmediate(true);
    autoRefresh.addValueChangeListener(event -> {
        agent.setAutoRefresh(autoRefresh.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(autoRefresh);
    editAgentLayout.setComponentAlignment(autoRefresh, Alignment.BOTTOM_LEFT);

    CheckBox allowTestFlowsField = new CheckBox("Allow Test Flows", Boolean.valueOf(agent.isAllowTestFlows()));
    allowTestFlowsField.setImmediate(true);
    allowTestFlowsField.addValueChangeListener(event -> {
        agent.setAllowTestFlows(allowTestFlowsField.getValue());
        EditAgentPanel.this.context.getConfigurationService().save((AbstractObject) agent);
        EditAgentPanel.this.context.getAgentManager().refresh(agent);
    });
    editAgentLayout.addComponent(allowTestFlowsField);
    editAgentLayout.setComponentAlignment(allowTestFlowsField, Alignment.BOTTOM_LEFT);

    ButtonBar buttonBar = new ButtonBar();
    addComponent(buttonBar);

    addDeploymentButton = buttonBar.addButton("Add Deployment", Icons.DEPLOYMENT);
    addDeploymentButton.addClickListener(new AddDeploymentClickListener());

    editButton = buttonBar.addButton("Edit", FontAwesome.EDIT);
    editButton.addClickListener(event -> editClicked());

    enableButton = buttonBar.addButton("Enable", FontAwesome.CHAIN);
    enableButton.addClickListener(event -> enableClicked());

    disableButton = buttonBar.addButton("Disable", FontAwesome.CHAIN_BROKEN);
    disableButton.addClickListener(event -> disableClicked());

    removeButton = buttonBar.addButton("Remove", FontAwesome.TRASH_O);
    removeButton.addClickListener(event -> removeClicked());

    runButton = buttonBar.addButton("Run", Icons.RUN);
    runButton.addClickListener(event -> runClicked());

    container = new BeanItemContainer<AgentDeploymentSummary>(AgentDeploymentSummary.class);
    container.setItemSorter(new TableItemSorter());

    table = new Table();
    table.setSizeFull();
    table.setCacheRate(100);
    table.setPageLength(100);
    table.setImmediate(true);
    table.setSelectable(true);
    table.setMultiSelect(true);

    table.setContainerDataSource(container);
    table.setVisibleColumns("name", "projectName", "type", "status", "logLevel", "startType",
            "startExpression");
    table.setColumnHeaders("Deployment", "Project", "Type", "Status", "Log Level", "Start Type",
            "Start Expression");
    table.addGeneratedColumn("status", new StatusRenderer());
    table.addItemClickListener(new TableItemClickListener());
    table.addValueChangeListener(new TableValueChangeListener());
    table.setSortContainerPropertyId("type");
    table.setSortAscending(true);

    addComponent(table);
    setExpandRatio(table, 1.0f);
    refresh();
    setButtonsEnabled();
    backgroundRefresherService.register(this);
}