List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
From source file:com.mycollab.module.user.accountsettings.view.AccountModuleImpl.java
License:Open Source License
@Override public MHorizontalLayout buildMenu() { if (serviceMenuContainer == null) { serviceMenuContainer = new MHorizontalLayout(); serviceMenu = new ServiceMenu(); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PROJECT), new Button.ClickListener() { @Override/*from w w w .j a va2 s. c om*/ public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance() .post(new ShellEvent.GotoProjectModule(this, new String[] { "dashboard" })); serviceMenu.selectService(0); } }); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_CRM), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoCrmModule(this, null)); } }); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_DOCUMENT), new Button.ClickListener() { private static final long serialVersionUID = 1L; @Override public void buttonClick(final Button.ClickEvent event) { EventBusFactory.getInstance().post(new ShellEvent.GotoFileModule(this, null)); } }); serviceMenu.addService(UserUIContext.getMessage(GenericI18Enum.MODULE_PEOPLE), new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { EventBusFactory.getInstance().post( new ShellEvent.GotoUserAccountModule(this, new String[] { "user", "list" })); } }); serviceMenuContainer.with(serviceMenu); } serviceMenu.selectService(3); return serviceMenuContainer; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.components.SearchEngineMetaDescription.java
License:Open Source License
private Component createSEOProgressBar() { ProgressBar seoProgressBar = new ProgressBar(); seoProgressBar.setWidth("250px"); seoProgressBar.setValue(0.5f);//from w w w. jav a2s.com HorizontalLayout layout = new HorizontalLayout(); layout.addComponent(new Label("SEO Rating:")); layout.addComponent(seoProgressBar); layout.setSpacing(true); layout.setMargin(new MarginInfo(false, false, true, false)); NativeButton addUpdateButton = new NativeButton("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // do nothing } }); addUpdateButton.addStyleName("update-button"); addUpdateButton.setHeight("28px"); addUpdateButton.setCaption("Update"); addUpdateButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { updateMetaDescriptionPreview(textArea.getValue()); } }); layout.addComponent(addUpdateButton); return layout; }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.TaggingViewImpl.java
License:Open Source License
private void buildCustomTagsLayout() { final VerticalLayout customTags = new VerticalLayout(); customTags.setCaption("Custom Tags"); final HorizontalLayout newTagLayout = new HorizontalLayout(); newTagLayout.setSizeUndefined();//from w w w . j ava 2 s . c o m final TextField newTagTextField = new TextField(); newTagTextField.addStyleName("new-tag-textfield"); newTagTextField.setHeight("52px"); newTagTextField.setWidth("320px"); newTagTextField.setNullRepresentation(""); newTagTextField.setInputPrompt("Add new tag"); NativeButton addTagButton = new NativeButton("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { addCustomTag(newTagTextField); } }); addTagButton.addStyleName("add-tag-button"); newTagLayout.addComponent(newTagTextField); newTagLayout.addComponent(addTagButton); newTagLayout.setExpandRatio(newTagTextField, 1f); /* NativeButton addGenerateTagsButton = new NativeButton("", new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { // Generate Tags } }); addGenerateTagsButton.addStyleName("generate-tags-button"); addGenerateTagsButton.setCaption("Generate Tags"); newTagLayout.addComponent(addGenerateTagsButton); */ customTags.addComponent(newTagLayout); customTags.addComponent(customTagLayout); this.tagLayout.addComponent(customTags); }
From source file:com.nfl.dm.clubsites.cms.articles.subapp.articleeditor.tagging.TaggingViewImpl.java
License:Open Source License
private void addTagToLayout(CssLayout layout, final Tag tag) { layout.addComponent(new TagField(tag, new Button.ClickListener() { @Override//from w w w.j a va2 s. co m public void buttonClick(Button.ClickEvent event) { listener.onTagRemoved(tag); } })); }
From source file:com.peter.vaadin.components.vaadin.chart.timeline.Monitor.java
public Monitor() { // Create the container ds = new IndexedContainer(); // Add the required property ids, we use the default ones here ds.addContainerProperty(Timeline.PropertyId.TIMESTAMP, Date.class, null); ds.addContainerProperty(Timeline.PropertyId.VALUE, Float.class, 0f); // Create a timeline to display data timeline = new Timeline("Monitor"); timeline.setImmediate(true);/*from w w w . ja v a 2 s . c o m*/ timeline.addGraphDataSource(ds); timeline.setSizeFull(); timeline.setBrowserSelectionLock(false); timeline.setVerticalAxisRange(0f, 110f); timeline.setZoomLevelsVisible(false); timeline.setDateSelectVisible(false); timeline.setGraphOutlineThickness(4); timeline.setGraphFillColor(ds, new SolidColor(0, 30, 220, 128)); timeline.setGraphOutlineColor(ds, SolidColor.RED); addComponent(timeline); HorizontalLayout controls = new HorizontalLayout(); controls.setSpacing(true); addComponent(controls); ProgressIndicator pi = new ProgressIndicator(); pi.setIndeterminate(true); pi.setPollingInterval(1000); pi.setHeight("0px"); pi.setWidth("0px"); controls.addComponent(pi); final Button start = new Button("Start updates", new Button.ClickListener() { public void buttonClick(ClickEvent event) { try { updateTimer.cancel(); } catch (Exception e) { } updateTimer = new Timer(); updateTimer.scheduleAtFixedRate(new TimerTask() { public void run() { updateDataContainer(); } }, new Date(), 1000L); } }); controls.addComponent(start); Button stop = new Button("Stop updates", new Button.ClickListener() { public void buttonClick(ClickEvent event) { updateTimer.cancel(); } }); controls.addComponent(stop); CheckBox lock = new CheckBox("Selection lock", false); lock.setImmediate(true); lock.addListener(new Property.ValueChangeListener() { public void valueChange(ValueChangeEvent event) { timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue()); } }); controls.addComponent(lock); setExpandRatio(timeline, 1); }
From source file:com.peter.vaadin.components.vaadin.chart.timeline.MyTimelineDemo.java
public MyTimelineDemo() { timeline = new Timeline("My graph"); timeline.setSizeFull();//from www. j a v a 2 s . com timeline.setVerticalAxisRange(-1f, 2f); timeline.setZoomLevelsVisible(false); timeline.setDateSelectVisible(false); // Create the data sources firstDataSource = createGraphDataSource(); datasourcesList.add(firstDataSource); final Container.Indexed markerDataSource = createMarkerDataSource(); final Container.Indexed eventDataSource = createEventDataSource(); // Add our data sources timeline.addGraphDataSource(firstDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.VALUE); // Markers and events timeline.setMarkerDataSource(markerDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION, Timeline.PropertyId.VALUE); timeline.setEventDataSource(eventDataSource, Timeline.PropertyId.TIMESTAMP, Timeline.PropertyId.CAPTION); // Set the caption of the graph timeline.setGraphLegend(firstDataSource, "Our cool graph"); // Set the color of the graph timeline.setGraphOutlineColor(firstDataSource, SolidColor.RED); // Set the fill color of the graph timeline.setGraphFillColor(firstDataSource, new SolidColor(255, 0, 0, 128)); // Set the width of the graph timeline.setGraphOutlineThickness(1); // Set the color of the browser graph timeline.setBrowserOutlineColor(firstDataSource, SolidColor.BLACK); // Set the fill color of the graph timeline.setBrowserFillColor(firstDataSource, new SolidColor(0, 0, 0, 128)); // Add some zoom levels timeline.addZoomLevel("Day", 86400000L); timeline.addZoomLevel("Week", 7 * 86400000L); timeline.addZoomLevel("Month", 2629743830L); // Listen to click events from events timeline.addListener(new Timeline.EventClickListener() { @Override public void eventClick(EventButtonClickEvent event) { Item item = eventDataSource.getItem(event.getItemIds().iterator().next()); Date sunday = (Date) item.getItemProperty(Timeline.PropertyId.TIMESTAMP).getValue(); SimpleDateFormat formatter = new SimpleDateFormat("EEE, MMM d, ''yy"); Notification.show(formatter.format(sunday)); } }); addComponent(timeline); HorizontalLayout addDateForm = new HorizontalLayout(); final DateField dateField = new DateField(); dateField.setImmediate(true); addDateForm.addComponent(dateField); final TextField valueField = new TextField(); valueField.setImmediate(true); addDateForm.addComponent(valueField); Button addBtn = new Button("Add", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { java.util.Date d = dateField.getValue(); Date date = new Date(d.getTime()); float value = Float.valueOf(valueField.getValue().toString()); // Create a point in time Item item = firstDataSource.addItem(date.getTime()); if (item == null) { item = firstDataSource.getItem(date.getTime()); } // Set the timestamp property item.getItemProperty(Timeline.PropertyId.TIMESTAMP).setValue(date); // Set the value property item.getItemProperty(Timeline.PropertyId.VALUE).setValue(value); } }); addDateForm.addComponent(addBtn); addComponent(addDateForm); Button addGraphDataSource = new Button("Add graph data source", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { Container.Indexed ds = createGraphDataSource(); datasourcesList.add(ds); timeline.addGraphDataSource(ds); timeline.setGraphFillColor(ds, SolidColor.BLACK); } }); addComponent(addGraphDataSource); Button removeGraphDataSource = new Button("Remove graph data source", new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (datasourcesList.size() > 1) { Container.Indexed ds = datasourcesList.get(datasourcesList.size() - 1); timeline.removeGraphDataSource(ds); datasourcesList.remove(ds); } } }); addComponent(removeGraphDataSource); CheckBox stacked = new CheckBox("Stacked graphs", false); stacked.setImmediate(true); stacked.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { timeline.setGraphStacking((Boolean) event.getProperty().getValue()); } }); addComponent(stacked); CheckBox lock = new CheckBox("Selection lock", true); lock.setImmediate(true); lock.addListener(new Property.ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { timeline.setBrowserSelectionLock((Boolean) event.getProperty().getValue()); } }); addComponent(lock); setExpandRatio(timeline, 1); }
From source file:com.purebred.core.view.FormComponent.java
License:Open Source License
/** * Animate the component by visually wrapping it with a layout and button for toggling * the component's visibility. This allows the user to expand/collapse the given component in order * to free space for viewing other components. * * @param component component to show/hide * @param useVerticalLayout true if toggle button should be laid out vertically next to animated component * * @return the newly created layout that contains the toggle button and animated component *///w w w . ja va2 s . c o m protected Component animate(Component component, boolean useVerticalLayout) { final Animator formAnimator = new Animator(component); formAnimator.setSizeUndefined(); AbstractOrderedLayout animatorLayout; if (useVerticalLayout) { animatorLayout = new VerticalLayout(); } else { animatorLayout = new HorizontalLayout(); } animatorLayout.setMargin(false, false, false, false); animatorLayout.setSpacing(false); toggleFormVisibilityButton = new Button(null, new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { formAnimator.setRolledUp(!formAnimator.isRolledUp()); if (formAnimator.isRolledUp()) { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/expand-icon.png")); } else { event.getButton().setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); } } }); toggleFormVisibilityButton .setDescription(uiMessageSource.getMessage("entryPoint.toggleSearchForm.description")); toggleFormVisibilityButton.setIcon(new ThemeResource("../pureCrudTheme/icons/collapse-icon.png")); toggleFormVisibilityButton.addStyleName("borderless"); if (useVerticalLayout) { HorizontalLayout toggleFormButtonAndCaption = new HorizontalLayout(); toggleFormButtonAndCaption.setSizeUndefined(); toggleFormButtonAndCaption.addComponent(toggleFormVisibilityButton); toggleFormButtonAndCaption.addComponent(new Label(getEntityCaption())); animatorLayout.addComponent(toggleFormButtonAndCaption); animatorLayout.addComponent(formAnimator); } else { animatorLayout.addComponent(toggleFormVisibilityButton); animatorLayout.addComponent(formAnimator); } return animatorLayout; }
From source file:com.trivago.mail.pigeon.web.components.groups.GroupList.java
License:Apache License
public GroupList() { final GroupList gl = this; final Panel rootPanel = new Panel("Groups"); rootPanel.setWidth("800px"); Button groupListNewButton = new Button("Add group"); groupListNewButton.setImmediate(true); groupListNewButton.setIcon(new ThemeResource("../runo/icons/16/document-add.png")); groupListNewButton.addListener(new Button.ClickListener() { @Override/*from w w w . j a v a 2s .co m*/ public void buttonClick(Button.ClickEvent event) { Window modalNewWindow = new ModalAddNewGroup(gl); event.getButton().getWindow().addWindow(modalNewWindow); modalNewWindow.setVisible(true); } }); viewTable = new Table(); viewTable.setWidth("100%"); final Button editButton = new Button("Edit"); editButton.setImmediate(true); editButton.setIcon(new ThemeResource("../runo/icons/16/document-txt.png")); editButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (viewTable.isEditable()) { viewTable.setEditable(false); editButton.setCaption("Edit"); viewTable.requestRepaintAll(); editButton.getWindow().showNotification("Save successful", Window.Notification.TYPE_HUMANIZED_MESSAGE); } else { viewTable.setEditable(true); editButton.setCaption("Save"); viewTable.requestRepaintAll(); } } }); viewTable.setImmediate(true); beanContainer = new BeanContainer<>(RecipientGroup.class); List<RecipientGroup> groupList = getGroupList(); for (RecipientGroup group : groupList) { beanContainer.addItem(group.getId(), group); } viewTable.setContainerDataSource(beanContainer); viewTable.addGeneratedColumn("memberNumber", new GroupColumnGenerator()); viewTable.addGeneratedColumn("Actions", new ActionButtonColumnGenerator()); // First set the vis. cols, then the headlines (the other way round leads to an exception) viewTable.setVisibleColumns(new String[] { "id", "name", "memberNumber", "Actions" }); viewTable.setColumnHeaders(new String[] { "ID", "Name", "Member #", "Actions" }); viewTable.setColumnExpandRatio(3, 2); viewTable.setColumnExpandRatio(4, 2); HorizontalLayout topButtonLayout = new HorizontalLayout(); topButtonLayout.setSpacing(true); topButtonLayout.setMargin(false, false, true, false); topButtonLayout.addComponent(groupListNewButton); topButtonLayout.addComponent(editButton); rootPanel.addComponent(topButtonLayout); rootPanel.addComponent(viewTable); setCompositionRoot(rootPanel); }
From source file:com.trivago.mail.pigeon.web.components.groups.ModalAddNewGroup.java
License:Apache License
public ModalAddNewGroup(final GroupList gl) { super();/* w w w . ja v a 2 s . co m*/ setModal(true); setWidth("300px"); setClosable(false); Panel rootPanel = new Panel("Add new group"); VerticalLayout verticalLayout = new VerticalLayout(); VerticalLayout formLayout = new VerticalLayout(); final TextField tfName = new TextField("Name"); verticalLayout.addComponent(tfName); HorizontalLayout buttonLayout = new HorizontalLayout(); Button saveButton = new Button("Save"); Button cancelButton = new Button("Cancel"); saveButton.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { if (tfName.getValue().equals("")) { tfName.setComponentError(new UserError("Name must not be empty")); } else { tfName.setComponentError(null); } /* TODO XXX check for existing group: no duplicates! */ if (!tfName.getValue().equals("")) { tfName.setComponentError(null); long groupId = Util.generateId(); try { RecipientGroup g = new RecipientGroup(groupId, tfName.getValue().toString()); event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); event.getButton().getWindow().getParent().showNotification("Saved successfully", Notification.TYPE_HUMANIZED_MESSAGE); gl.getBeanContainer().addItem(g.getId(), g); // The group select could be placed anywhere but must be reloaded to reflect the changes. GroupSelectBox.reloadSelect(); } catch (RuntimeException e) { // Should never happen ... hopefully :D } } event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } }); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } }); buttonLayout.addComponent(saveButton); buttonLayout.addComponent(cancelButton); verticalLayout.addComponent(formLayout); verticalLayout.addComponent(buttonLayout); rootPanel.addComponent(verticalLayout); this.addComponent(rootPanel); }
From source file:com.trivago.mail.pigeon.web.components.groups.ModalRecipientImportCsv.java
License:Apache License
public ModalRecipientImportCsv(final long groupId) { super();//from w w w . j a v a 2s. c o m setModal(true); setClosable(false); setWidth("600px"); Panel rootPanel = new Panel("Import Recipients via CSV"); VerticalLayout vl = new VerticalLayout(); Label infoText = new Label( "You can upload a bunch of users into a group. Create a CSV file with no! headers. \n" + "You can leave out the user_id by just setting the column empty => ,\"Firstname Lastname\",\"first.last@trivago.com\"."); Label formatInfoText = new Label("Please format you CSV like: user_id,\"user_full_name\",\"email\""); final CheckBox forceUpdate = new CheckBox("Force update of existing recipients?"); Button cancelButton = new Button("Cancel"); vl.addComponent(infoText); vl.addComponent(formatInfoText); final UploadCsvFileComponent ucsv = new UploadCsvFileComponent(); vl.addComponent(ucsv); Button importButton = new Button("Import"); importButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { if (!ucsv.isUploadFinished()) { ucsv.setComponentError(new UserError("Please upload a csv first!")); } else { ucsv.setComponentError(null); try { File uploadedFile = ucsv.getCsvFile(); Csv importer = new Csv(uploadedFile, groupId); importer.importData(forceUpdate.booleanValue()); event.getButton().getApplication().getMainWindow().showNotification("Import done", Notification.TYPE_HUMANIZED_MESSAGE); event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } catch (Exception e) { log.error("Error while importing csv", e); event.getButton().getWindow().showNotification("The import failed.", e.getLocalizedMessage(), Notification.TYPE_ERROR_MESSAGE); } } } }); cancelButton.addListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent event) { event.getButton().getWindow().setVisible(false); event.getButton().getWindow().getParent().removeComponent(event.getButton().getWindow()); } }); HorizontalLayout buttonLayout = new HorizontalLayout(); buttonLayout.setSpacing(true); buttonLayout.addComponent(importButton); buttonLayout.addComponent(cancelButton); vl.addComponent(buttonLayout); rootPanel.addComponent(vl); addComponent(rootPanel); }