Java Code Examples for com.vaadin.ui.Button#addClickListener()

The following examples show how to use com.vaadin.ui.Button#addClickListener() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: VaadinLocaleDemo.java    From viritin with Apache License 2.0 6 votes vote down vote up
@Override
public Component getTestComponent() {
    dateField.setValue(LocalDate.now());
    localeSelect.setId("language-selection");
    localeSelect.addValueChangeListener(e
            -> vaadinLocale.setLocale(e.getValue())
    );
    Button addNewComponent = new Button("Create new component");

    final MVerticalLayout layout = new MVerticalLayout(localeSelect,
            dateField, new VaadinLocaleDemoComponent(), addNewComponent);

    addNewComponent.addClickListener(
            new ClickListener() {
        @Override
        public void buttonClick(ClickEvent event
        ) {
            layout.add(new VaadinLocaleDemoComponent());
        }
    }
    );
    return layout;
}
 
Example 2
Source File: TargetDetails.java    From hawkbit with Eclipse Public License 1.0 6 votes vote down vote up
private Button buildRequestAttributesUpdateButton(final String controllerId, final boolean isRequestAttributes) {
    final Button requestAttributesUpdateButton = SPUIComponentProvider.getButton(
            UIComponentIdProvider.TARGET_ATTRIBUTES_UPDATE, "", "", "", false, FontAwesome.REFRESH,
            SPUIButtonStyleNoBorder.class);

    requestAttributesUpdateButton.addClickListener(e -> targetManagement.requestControllerAttributes(controllerId));

    if (isRequestAttributes) {
        requestAttributesUpdateButton
                .setDescription(getI18n().getMessage("tooltip.target.attributes.update.requested"));
        requestAttributesUpdateButton.setEnabled(false);
    } else {
        requestAttributesUpdateButton
                .setDescription(getI18n().getMessage("tooltip.target.attributes.update.request"));
        requestAttributesUpdateButton.setEnabled(true);
    }

    return requestAttributesUpdateButton;
}
 
Example 3
Source File: JobsTable.java    From chipster with MIT License 6 votes vote down vote up
public Component generateCell(Table source, final Object itemId,
		Object columnId) {

	Button link = new Button("Cancel");
	link.setStyleName(BaseTheme.BUTTON_LINK);
	link.setDescription("Cancel running job");

	link.addClickListener(new Button.ClickListener() {

		public void buttonClick(ClickEvent event) {

			select(itemId);
			
			if (itemId instanceof JobsEntry) {
				JobsEntry job = (JobsEntry) itemId;
				
				view.cancel(job);
			}
		}
	});

	return link;
}
 
Example 4
Source File: ModuleLayout.java    From usergrid with Apache License 2.0 6 votes vote down vote up
public void loadData( Table userTable ){
    ModuleDao moduleDao = InjectorFactory.getInstance( ModuleDao.class );
    List<Module> modules = moduleDao.getAll();
    for( final Module module : modules ) {
        Label groupLabel = new Label( module.getGroupId( ) );
        Label artifactLabel = new Label( module.getArtifactId( ) );
        Label versionLabel = new Label( module.getVersion( ) );

        Button detailsField = new Button( "show details" );
        detailsField.addStyleName( "link" );
        detailsField.addClickListener( new Button.ClickListener( ) {
            @Override
            public void buttonClick( Button.ClickEvent event ) {
                onItemClick( module.getId() );
            }
        } );
        userTable.addItem( new Object[]{ groupLabel, artifactLabel, versionLabel, detailsField }, module.getId( ) );
    }
}
 
Example 5
Source File: SubSetSelector.java    From viritin with Apache License 2.0 5 votes vote down vote up
/**
 * Generates the tool cell content in the listing of selected items. By
 * default contains button to remove selection. Overridden implementation
 * can add other stuff there as well, like edit button.
 *
 * @param entity the entity for which the cell content is created
 * @return the content (String or Component)
 */
protected Object getToolColumnContent(final ET entity) {
    Button button = new Button(VaadinIcons.MINUS);
    button.setDescription("Removes the selection from the list");
    button.addStyleName(ValoTheme.BUTTON_ICON_ONLY);
    button.addClickListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            removeSelectedOption(entity);
        }
    });
    button.setStyleName(ValoTheme.BUTTON_SMALL);
    return button;

}
 
Example 6
Source File: AgentOperationsOverviewPageModContentFactoryImpl.java    From cia with Apache License 2.0 5 votes vote down vote up
@Secured({ "ROLE_ADMIN" })
@Override
public Layout createContent(final String parameters, final MenuBar menuBar, final Panel panel) {
	final VerticalLayout content = createPanelContent();

	getMenuItemFactory().createMainPageMenuBar(menuBar);

	LabelFactory.createHeader2Label(content,ADMIN_AGENT_OPERATION);
			
	final VerticalLayout overviewLayout = new VerticalLayout();
	overviewLayout.setSizeFull();
	content.addComponent(overviewLayout);
	content.setExpandRatio(overviewLayout, ContentRatio.LARGE);

	final ResponsiveRow grid = RowUtil.createGridLayout(overviewLayout);

	for (final DataAgentTarget dataAgentTarget : DataAgentTarget.values()) {
		final Button importDataButton = new Button(MessageFormat.format(BUTTON_PATTERN, DataAgentOperation.IMPORT, dataAgentTarget) , VaadinIcons.BULLSEYE);
		importDataButton.addClickListener(new StartAgentClickListener(dataAgentTarget, DataAgentOperation.IMPORT));
		importDataButton.setId(MessageFormat.format(BUTTON_ID_PATTERN, ViewAction.START_AGENT_BUTTON, DataAgentOperation.IMPORT, dataAgentTarget));
		RowUtil.createRowItem(grid, importDataButton, WILL_FETCH_DATA_FROM_SOURCE);
	}
	
	final String pageId = getPageId(parameters);
	getPageActionEventHelper().createPageEvent(ViewAction.VISIT_ADMIN_AGENT_OPERATION_VIEW, ApplicationEventGroup.ADMIN,
			NAME, null, pageId);


	return content;
}
 
Example 7
Source File: GitPushWindow.java    From XACML with MIT License 5 votes vote down vote up
protected Object generateUncommittedEntry(final GitEntry entry) {
	Button commit = new Button("Commit");
	commit.setImmediate(true);
	commit.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
		}
	});
	return commit;
}
 
Example 8
Source File: AbstractTableHeader.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button createBulkUploadIcon() {
    final Button button = SPUIComponentProvider.getButton(getBulkUploadIconId(), "",
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_BULK_UPLOAD), null, false, FontAwesome.UPLOAD,
            SPUIButtonStyleNoBorder.class);
    button.addClickListener(this::bulkUpload);
    return button;
}
 
Example 9
Source File: ConfirmationDialog.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button createOkButton(final String okLabel) {
    final Button button = SPUIComponentProvider.getButton(UIComponentIdProvider.OK_BUTTON, okLabel, "",
            ValoTheme.BUTTON_PRIMARY, false, null, SPUIButtonStyleTiny.class);
    button.addClickListener(this);
    button.setClickShortcut(KeyCode.ENTER);
    return button;
}
 
Example 10
Source File: FormUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new cancel button
 * @param f form holding the button
 * @return new cancel button
 */
private static Button newCancelButton(final Form f) {
	Button cancel = new Button(StaticMessageSource.getMessage("cancel"));
	cancel.addClickListener(new ClickListener() {
		
		public void buttonClick(ClickEvent event) {
			f.discard();
		}
	});
	
	return cancel;
}
 
Example 11
Source File: MyUI.java    From framework-spring-tutorial with Apache License 2.0 5 votes vote down vote up
private Button createNavigationButton(String caption,
        final String viewName) {
    Button button = new Button(caption);
    button.addStyleName(ValoTheme.BUTTON_SMALL);
    // If you didn't choose Java 8 when creating the project, convert this
    // to an anonymous listener class
    button.addClickListener(
            event -> getUI().getNavigator().navigateTo(viewName));
    return button;
}
 
Example 12
Source File: LoginView.java    From gazpachoquest with GNU General Public License v3.0 5 votes vote down vote up
protected HorizontalLayout createCompositionRootx() {
    VerticalLayout loginPanel = new VerticalLayout();
    loginPanel.setSpacing(true);
    loginPanel.setWidth("400px");

    Label header = new Label("Enter your invitation to start the questionnair");
    header.addStyleName(Reindeer.LABEL_H1);
    loginPanel.addComponent(header);

    invitation = new TextField("Invitation");
    invitation.setWidth("100%");
    invitation.focus();
    invitation.setValue("YAS5ICHRBE");
    loginPanel.addComponent(invitation);

    HorizontalLayout buttons = new HorizontalLayout();
    buttons.setSpacing(true);
    loginPanel.addComponent(buttons);
    loginPanel.setComponentAlignment(buttons, Alignment.MIDDLE_RIGHT);

    login = new Button("Start");
    login.setClickShortcut(KeyCode.ENTER);
    login.addStyleName(Reindeer.BUTTON_DEFAULT);
    login.addClickListener(createLoginButtonListener());
    buttons.addComponent(login);

    HorizontalLayout viewLayout = new HorizontalLayout();
    viewLayout.addComponent(loginPanel);
    viewLayout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER);
    viewLayout.setSizeFull();
    viewLayout.addStyleName(Reindeer.LAYOUT_BLUE);
    setSizeFull();

    return viewLayout;
}
 
Example 13
Source File: TargetFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button customFilterDistributionSetButton(final Long itemId) {
    final Item row1 = getItem(itemId);
    final ProxyDistribution distSet = (ProxyDistribution) row1
            .getItemProperty(SPUILabelDefinitions.AUTO_ASSIGN_DISTRIBUTION_SET).getValue();
    final ActionType actionType = (ActionType) row1.getItemProperty(SPUILabelDefinitions.AUTO_ASSIGN_ACTION_TYPE)
            .getValue();

    final String buttonId = "distSetButton";
    Button updateIcon;
    if (distSet == null) {
        updateIcon = SPUIComponentProvider.getButton(buttonId,
                i18n.getMessage(UIMessageIdProvider.BUTTON_NO_AUTO_ASSIGNMENT),
                i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false, null,
                SPUIButtonStyleNoBorder.class);
    } else {
        updateIcon = actionType == ActionType.FORCED
                ? SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(),
                        i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false,
                        FontAwesome.BOLT, SPUIButtonStyleNoBorderWithIcon.class)
                : SPUIComponentProvider.getButton(buttonId, distSet.getNameVersion(),
                        i18n.getMessage(UIMessageIdProvider.BUTTON_AUTO_ASSIGNMENT_DESCRIPTION), null, false, null,
                        SPUIButtonStyleNoBorder.class);
        updateIcon.setSizeUndefined();
    }

    updateIcon.addClickListener(this::onClickOfDistributionSetButton);
    updateIcon.setData(row1);
    updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");

    return updateIcon;
}
 
Example 14
Source File: TargetFilterTable.java    From hawkbit with Eclipse Public License 1.0 5 votes vote down vote up
private Button customFilterDetailButton(final Long itemId) {
    final Item row1 = getItem(itemId);
    final String tfName = (String) row1.getItemProperty(SPUILabelDefinitions.NAME).getValue();

    final Button updateIcon = SPUIComponentProvider.getButton(getDetailLinkId(tfName), tfName,
            i18n.getMessage(UIMessageIdProvider.TOOLTIP_UPDATE_CUSTOM_FILTER), null, false, null,
            SPUIButtonStyleNoBorder.class);
    updateIcon.setData(tfName);
    updateIcon.addStyleName(ValoTheme.LINK_SMALL + " " + "on-focus-no-border link");
    updateIcon.addClickListener(this::onClickOfDetailButton);
    return updateIcon;
}
 
Example 15
Source File: PopupWindow.java    From usergrid with Apache License 2.0 5 votes vote down vote up
private void addCloseButton(AbsoluteLayout mainLayout) {

        Button closeButton = new Button( "Close" );

        closeButton.addClickListener( new Button.ClickListener() {
            public void buttonClick( Button.ClickEvent event ) {
                close();
            }
        } );

        mainLayout.addComponent( closeButton, "left: 220px; top: 425px;" );
    }
 
Example 16
Source File: AdminUI.java    From sensorhub with Mozilla Public License 2.0 5 votes vote down vote up
protected Component buildToolbar()
{
    HorizontalLayout toolbar = new HorizontalLayout();
    toolbar.setWidth(100.0f, Unit.PERCENTAGE);
    
    // apply changes button
    Button saveButton = new Button("Save Config");
    saveButton.setDescription("Save Config");
    saveButton.setIcon(UIConstants.APPLY_ICON);
    saveButton.addStyleName(UIConstants.STYLE_SMALL);
    saveButton.setWidth(100.0f, Unit.PERCENTAGE);
    
    // apply button action
    saveButton.addClickListener(new Button.ClickListener() {
        private static final long serialVersionUID = 1L;
        public void buttonClick(ClickEvent event)
        {
            try
            {
                SensorHub.getInstance().getModuleRegistry().saveModulesConfiguration();
            }
            catch (Exception e)
            {
                AdminUI.log.error("Error while saving SensorHub configuration", e);
                Notification.show("Error", e.getMessage(), Notification.Type.ERROR_MESSAGE);
            }
        }
    });        

    toolbar.addComponent(saveButton);
    return toolbar;
}
 
Example 17
Source File: FormUtils.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * Creates a new OK Button
 * @param f form holding the button
 * @return new OK Button
 */
private static Button newOKButton(final Form f) {
	Button ok = new Button(StaticMessageSource.getMessage("ok"));
	ok.addClickListener(new ClickListener() {
		
		public void buttonClick(ClickEvent event) {
			f.commit();
		}
	});
	
	return ok;
}
 
Example 18
Source File: VaadinPaginator.java    From jdal with Apache License 2.0 4 votes vote down vote up
public void setLast(Button last) {
	this.last = last;
	last.addClickListener(buttonClickListener);
}
 
Example 19
Source File: HeaderWrapExtensionLayout.java    From GridExtensionPack with Apache License 2.0 4 votes vote down vote up
public HeaderWrapExtensionLayout() {

		setMargin(true);

		final SelectGrid<RowData> grid = new SelectGrid<>();
		final WrappingGrid wrap = WrappingGrid.extend(grid);

		TableSelectionModel<RowData> selectionModel = new TableSelectionModel<>();
		selectionModel.setMode(TableSelectionMode.SHIFT);
		grid.setSelectionModel(selectionModel);

		generateData(grid, 5, 100);

		HeaderRow headerRow = grid.prependHeaderRow();
		headerRow.join(grid.getColumns().get(1), grid.getColumns().get(2));

		HeaderRow headerRow1 = grid.appendHeaderRow();
		headerRow1.join(grid.getColumns().get(2), grid.getColumns().get(3));

		grid.setWidth("100%");
		grid.setHeight("100%");

		final Button button = new Button(BUTTON_WRAPPING_DISABLED_TEXT);
		button.addClickListener(new Button.ClickListener() {
			int state = 0;

			public void buttonClick(ClickEvent event) {
				state = (state + 1) % 2;
				switch (state) {
				case 0:
					// Disable wrapping, attempt to restore original behavior
					wrap.setWrapping(false);
					button.setCaption(BUTTON_WRAPPING_DISABLED_TEXT);
					break;
				case 1:
					// Apply wrapping rules
					wrap.setWrapping(true);
					button.setCaption(BUTTON_WRAPPING_ENABLED_TEXT);
					break;
				}
			}
		});

		addComponent(button);
		addComponent(grid);

		CacheStrategyExtension.extend(grid, 5, 0.2d);

	}
 
Example 20
Source File: StorageAdminPanel.java    From sensorhub with Mozilla Public License 2.0 4 votes vote down vote up
@Override
public void build(final MyBeanItem<ModuleConfig> beanItem, final IRecordStorageModule<?> storage)
{
    super.build(beanItem, storage);       
    
    if (storage != null)
    {            
        // section layout
        final GridLayout form = new GridLayout();
        form.setWidth(100.0f, Unit.PERCENTAGE);
        form.setMargin(false);
        form.setSpacing(true);
        
        // section title
        form.addComponent(new Label(""));
        HorizontalLayout titleBar = new HorizontalLayout();
        titleBar.setSpacing(true);
        Label sectionLabel = new Label("Data Store Content");
        sectionLabel.addStyleName(STYLE_H3);
        sectionLabel.addStyleName(STYLE_COLORED);
        titleBar.addComponent(sectionLabel);
        titleBar.setComponentAlignment(sectionLabel, Alignment.MIDDLE_LEFT);
        
        // refresh button to show latest record
        Button refreshButton = new Button("Refresh");
        refreshButton.setDescription("Reload data from storage");
        refreshButton.setIcon(REFRESH_ICON);
        refreshButton.addStyleName(STYLE_QUIET);
        titleBar.addComponent(refreshButton);
        titleBar.setComponentAlignment(refreshButton, Alignment.MIDDLE_LEFT);
        refreshButton.addClickListener(new ClickListener() {
            private static final long serialVersionUID = 1L;
            @Override
            public void buttonClick(ClickEvent event)
            {
                buildDataPanel(form, storage);
            }
        });
                
        form.addComponent(titleBar);
        
        // add I/O panel
        buildDataPanel(form, storage);
        addComponent(form);
    }
}