Example usage for com.vaadin.ui Button addListener

List of usage examples for com.vaadin.ui Button addListener

Introduction

In this page you can find the example usage for com.vaadin.ui Button addListener.

Prototype

@Override
    public Registration addListener(Component.Listener listener) 

Source Link

Usage

From source file:de.escidoc.admintool.view.context.ContextAddView.java

License:Open Source License

private void addAdminDescriptorField() {
    adminDescriptorAccordion = new Accordion();
    adminDescriptorAccordion.setWidth(ViewConstants.FIELD_WIDTH);
    adminDescriptorAccordion.setSizeFull();

    final Panel accordionPanel = new Panel();
    accordionPanel.setContent(adminDescriptorAccordion);
    accordionPanel.setSizeFull();/*  w  w  w.j  a  va 2s . co m*/
    accordionPanel.setWidth(ViewConstants.FIELD_WIDTH);

    final Button addButton = new Button(ViewConstants.ADD_LABEL);
    final Button editButton = new Button(ViewConstants.EDIT_LABEL);
    final Button delButton = new Button(ViewConstants.REMOVE_LABEL);

    addButton.setStyleName("small");
    editButton.setStyleName("small");
    delButton.setStyleName("small");

    addButton.addListener(new NewAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    editButton.addListener(new EditAdminDescriptorListener(mainWindow, adminDescriptorAccordion));
    delButton.addListener(new RemoveAdminDescriptorListener(adminDescriptorAccordion));

    panel.addComponent(LayoutHelper.create("Admin Descriptors", accordionPanel, LABEL_WIDTH + 2, 300, false,
            new Button[] { addButton, editButton, delButton }));
}

From source file:de.escidoc.admintool.view.resource.FreeFormWindow.java

License:Open Source License

private void configureTextArea() {
    final TextField key = new TextField();
    key.setWidth(100, Sizeable.UNITS_PIXELS);
    final TextField value = new TextField();
    value.setWidth(200, Sizeable.UNITS_PIXELS);
    freeForm.addComponent(key);/*from www .java2s  . c  o m*/
    freeForm.addComponent(value);
    final Button addMoreField = new Button("+");
    freeForm.addComponent(addMoreField);

    addMoreField.addListener(new AddMoreFieldListener());
    fl.addComponent(freeForm);
}

From source file:de.escidoc.admintool.view.user.UserAddView.java

License:Open Source License

private void addCancelButton() {
    final Button modalWindowCancelButton = new Button(ViewConstants.CANCEL);
    modalWindowCancelButton.addListener(new CloseOrgUnitSelectionWidget(this));
    buttons.addComponent(modalWindowCancelButton);
}

From source file:de.escidoc.admintool.view.user.UserAddView.java

License:Open Source License

private void addOkButton() {
    final Button okButton = new Button(ViewConstants.OK_LABEL);
    okButton.addListener(new AddOrgUnitsToTable(app.getMainWindow(), modalWindow, orgUnitTreeView,
            orgUnitWidget.getTable()));/*from  ww w .j  a v a2 s .c  o m*/
    buttons.addComponent(okButton);
}

From source file:de.escidoc.admintool.view.util.dialog.ErrorDialog.java

License:Open Source License

/**
 * Displays an error message dialog to the customer.
 * //from w ww  . j a va2  s  .  c  o  m
 * @param mainWindow
 *            the main window of the application.
 * @param caption
 *            the headline.
 * @param errorMessage
 *            the message, describing what went wrong.
 * @param width
 *            the width of the window.
 * @param height
 *            the height of the window.
 */
public ErrorDialog(final Window mainWindow, final String caption, final String errorMessage, final int width,
        final int height) {

    Preconditions.checkNotNull(mainWindow, "mainWindow can not be null: %s", mainWindow);
    Preconditions.checkNotNull(caption, "caption can not be null: %s", caption);
    Preconditions.checkNotNull(mainWindow, "errorMessage can not be null: %s", errorMessage);

    this.mainWindow = mainWindow;
    super.setWidth(width + "px");
    super.setHeight(height + "px");
    super.setCaption(caption);
    super.setModal(true);

    final Label errorMassageLabel = new Label(errorMessage);
    layout.addComponent(errorMassageLabel);
    layout.setExpandRatio(errorMassageLabel, 1);
    // layout.addComponent(LayoutHelper.createContextView("", new
    // Label(errorMessage),
    // 10, false));
    final Button button = new Button("OK");
    layout.addComponent(LayoutHelper.create("", button, 10, false));
    button.addListener(this);
    super.addComponent(layout);
}

From source file:de.flapdoodle.mongoui.MongoUIApplication.java

License:Apache License

@Override
public void init() {
    final Window window = new Window("My Vaadin Application");
    setMainWindow(window);/*from   ww w .j av  a2s  .co  m*/
    Button button = new Button("Click Me");
    button.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            window.addComponent(new Label("Thank you for clicking: " + "Fuh"));
        }
    });
    window.addComponent(button);

    window.addComponent(new ConfigDatabase());
    window.addComponent(new VaadinUIComp());
}

From source file:de.flapdoodle.mongoui.ui.ConfigDatabase.java

License:Apache License

public ConfigDatabase() {
    final FormData data = new FormData();
    final DatabaseForm form = new DatabaseForm(new BeanItem<ConfigDatabase.FormData>(data));
    HorizontalLayout footer = new HorizontalLayout();
    Button button = new Button("Verbinden");
    button.addListener(new ClickListener() {

        @Override/*from w  ww .  jav a2s.  com*/
        public void buttonClick(ClickEvent event) {
            form.commit();
            System.out.println("Connect to: " + data.getDatabaseName() + ":" + data.getPort());

        }
    });
    footer.addComponent(button);
    form.setFooter(footer);
    addComponent(form);
}

From source file:de.fzi.fhemapi.view.vaadin.ui.devicepanels.OnOffDetails.java

License:Apache License

@Override
public List<DeviceDetailEntry> getDeviceDetails() {
    List<DeviceDetailEntry> entries = new LinkedList<DeviceDetailEntry>();

    final Button switchButton = new Button();
    switchButton.setImmediate(true);/*from w ww. ja  v  a2  s . co  m*/
    String buttonLabel = "?";
    if (((OnOffActuator) device).state != null)
        buttonLabel = ((OnOffActuator) device).state ? "An" : "Aus";
    switchButton.setCaption(buttonLabel);
    switchButton.addListener(new Button.ClickListener() {

        public void buttonClick(ClickEvent event) {
            if (((OnOffActuator) device).state) {
                ((OnOffActuator) device).turnOff();
            } else {
                ((OnOffActuator) device).turnOn();
            }

            String buttonLabel = "?";
            if (((OnOffActuator) device).state != null)
                buttonLabel = ((OnOffActuator) device).state ? "An" : "Aus";
            switchButton.setCaption(buttonLabel);
            parent.reloadPage();
        }
    });

    entries.add(new DeviceDetailEntry("Schalten", switchButton));

    return entries;
}

From source file:de.fzi.fhemapi.view.vaadin.ui.HWindow.java

License:Apache License

private void openConfig() {
    VerticalLayout layout = new VerticalLayout();

    final TextArea area = new TextArea(null, server.getConfigManager().getConfigFile());
    //      area.setHeight("100%");
    area.setRows(100);//from  w w  w  . ja  va2  s .c  o  m
    area.setWidth("100%");

    layout.addComponent(area);

    Button saveButton = new Button("Speichern");
    saveButton.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            server.setFHEMCfg(((String) area.getValue()));
            getWindow().showNotification(server.rereadConfiguration().toString(),
                    Notification.TYPE_TRAY_NOTIFICATION);
            server.getConfigManager().update();
        }
    });
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.TOP_CENTER);
    mainSplitPanel.setSecondComponent(layout);
}

From source file:de.fzi.fhemapi.view.vaadin.ui.NewDevicePanel.java

License:Apache License

@AutoGenerated
private VerticalLayout buildMainLayout() {
    VerticalLayout layout = new VerticalLayout();

    HorizontalLayout titleLabel = getTitlePanel();
    layout.addComponent(titleLabel);/*from w  w w. ja  v  a2 s .c  o  m*/
    layout.setComponentAlignment(titleLabel, Alignment.TOP_CENTER);

    nameField = new TextField();
    HorizontalLayout nameLayout = UIHelper.buildAttributePanel("Name", nameField);
    layout.addComponent(nameLayout);
    layout.setComponentAlignment(nameLayout, Alignment.TOP_CENTER);

    typeComboBox = new ComboBox();
    for (String name : DeviceFactory.getAvailableDevicetypes()) {
        typeComboBox.addItem(name);
    }

    HorizontalLayout typelayout = UIHelper.buildAttributePanel("Typ", typeComboBox);
    layout.addComponent(typelayout);
    layout.setComponentAlignment(typelayout, Alignment.TOP_CENTER);

    parameterType = new ComboBox();
    String[] manufacturers = ManufacturerManager.getClassNames();
    for (String name : manufacturers) {
        parameterType.addItem(name);
    }

    parameterType.addListener(new Property.ValueChangeListener() {

        @Override
        public void valueChange(ValueChangeEvent event) {
            fillManufacturerDetails((String) event.getProperty().getValue());
        }
    });
    parameterType.setImmediate(true);

    HorizontalLayout parameterTypeLayout = UIHelper.buildAttributePanel("Hersteller", parameterType);
    layout.addComponent(parameterTypeLayout);
    layout.setComponentAlignment(parameterTypeLayout, Alignment.TOP_CENTER);

    manufacturerLayout = new VerticalLayout();
    layout.addComponent(manufacturerLayout);
    layout.setComponentAlignment(manufacturerLayout, Alignment.TOP_CENTER);

    Button saveButton = new Button("Speichern");
    layout.addComponent(saveButton);
    layout.setComponentAlignment(saveButton, Alignment.TOP_CENTER);
    saveButton.addListener(new Button.ClickListener() {

        @Override
        public void buttonClick(ClickEvent event) {
            if (allParametersMatches()) {
                String[] parameters = new String[currentManufacturerTextFields.size() + 1];
                parameters[0] = (String) nameField.getValue();
                for (int i = 1; i < parameters.length; i++) {
                    parameters[i] = (String) currentManufacturerTextFields.get(i - 1).getValue();
                }

                ActuatorParameters params = ParameterExtractor
                        .getJavaParameters((String) parameterType.getValue(), parameters);

                MessageResponse response = parent.server.getDeviceManager().createNewActuatorAsMessage(params);
                getWindow().showNotification(response.toString(), Notification.TYPE_TRAY_NOTIFICATION);
                parent.server.getDeviceManager().update();
                parent.server.getDeviceManager().getDevice(params.get(FHEMParameters.NAME))
                        .setDeviceType((String) typeComboBox.getValue());
                parent.reloadTree();
            }
        }
    });
    return layout;
}