List of usage examples for com.vaadin.ui Button.ClickListener Button.ClickListener
Button.ClickListener
From source file:net.gvcc.jgoffice.components.CommandBar.java
License:Open Source License
/** * The constructor should first build the main layout, set the composition * root and then do any custom initialization. * <p/>/* w ww . ja v a 2s . c o m*/ * The constructor will not be automatically regenerated by the visual * editor. */ public CommandBar() { buildMainLayout(); setCompositionRoot(mainLayout); programList.setMargin(new MarginInfo(false, true, false, false)); btnLogout.setStyleName(LINK_BUTTONSTYLE); btnLogout.addClickListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { // Close the VaadinSession ConfirmDialog.show(getUI(), "Confirm...", "Session will be closed. Continue?", "Continue", "Abort", new ConfirmDialog.Listener() { @Override public void onClose(ConfirmDialog arg0) { if (arg0.isConfirmed()) { // Redirect from the page getUI().getPage().setLocation("jGOffice/logoutpage.html"); getUI().getSession().close(); } else { } } }); } }); }
From source file:org.apache.tamaya.ui.mutableconfig.ConfigEditorWidget.java
License:Apache License
private void initActions() { updateButton.addClickListener(new Button.ClickListener() { @Override/*from w ww .j a va2 s.c om*/ public void buttonClick(Button.ClickEvent clickEvent) { if (mutableConfig.isWritable(configKey.getValue())) { mutableConfig.put(configKey.getValue(), configValue.getValue()); Notification.show("Added " + configKey.getValue() + " = " + configValue.getValue(), Notification.Type.TRAY_NOTIFICATION); logWriter.println(" - PUT " + configKey.getValue() + " = " + configValue.getValue()); configKey.setValue(""); configValue.setValue(""); } else { Notification.show("Could not add " + configKey.getValue() + " = " + configValue.getValue(), Notification.Type.ERROR_MESSAGE); logWriter.println(" - PUT " + configKey.getValue() + " rejected - not writable."); } taWidget.update(); } }); removeButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (mutableConfig.isRemovable(configKey.getValue())) { mutableConfig.remove(configKey.getValue()); logWriter.println(" - DEL " + configKey.getValue()); Notification.show("Removed " + configKey.getValue(), Notification.Type.TRAY_NOTIFICATION); configKey.setValue(""); configValue.setValue(""); } else { Notification.show("Could not remove " + configKey.getValue(), Notification.Type.ERROR_MESSAGE); logWriter.println(" - DEL " + configKey.getValue() + " rejected - not removable."); } taWidget.update(); } }); readButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { if (mutableConfig.isExisting(configKey.getValue())) { String key = configKey.getValue(); configValue.setValue(mutableConfig.get(key)); Notification.show("Successfully read " + configKey.getValue(), Notification.Type.TRAY_NOTIFICATION); logWriter.println(" - GET " + key + " = " + configValue.getValue()); logWriter.println(" - removable: " + mutableConfig.isRemovable(key)); logWriter.println(" - writable : " + mutableConfig.isWritable(key)); } else { Notification.show("Could not read " + configKey.getValue(), Notification.Type.ERROR_MESSAGE); logWriter.println(" - GET " + configKey.getValue() + " rejected - not existing."); } taWidget.update(); } }); }
From source file:org.apache.tamaya.ui.mutableconfig.TransactionControlWidget.java
License:Apache License
private void initActions() { autoCommit.addValueChangeListener(new Property.ValueChangeListener() { @Override//from ww w . j a v a2 s . c o m public void valueChange(Property.ValueChangeEvent valueChangeEvent) { mutableConfig.setAutoCommit(autoCommit.getValue()); if (mutableConfig.getAutoCommit()) { Notification.show("Autocommit is now ON.", Notification.Type.TRAY_NOTIFICATION); } else { Notification.show("Autocommit is now OFF.", Notification.Type.TRAY_NOTIFICATION); } logWriter.println(" - Set Auto-Commit to " + autoCommit.getValue()); } }); changePropagationPolicy.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { changePropagationPolicyOther.setEnabled(false); changePropagationPolicyOther.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(Property.ValueChangeEvent valueChangeEvent) { String className = changePropagationPolicyOther.getValue(); try { mutableConfig.setChangePropagationPolicy( (ChangePropagationPolicy) Class.forName(className).newInstance()); logWriter.println(" - Set ChangePropagationPolicy " + className); Notification.show("ChangePropagationPolicy is now CUSTOM: " + className); } catch (Exception e) { Notification.show("Failed to apply change policy: " + className + ": " + e, Notification.Type.ERROR_MESSAGE); } } }); switch ((String) changePropagationPolicy.getValue()) { case "MOST_SIGNIFICANT_ONLY": mutableConfig.setChangePropagationPolicy( MutableConfigurationProvider.getApplyMostSignificantOnlyChangePolicy()); Notification.show("ChangePropagationPolicy is now MOST_SIGNIFICANT_ONLY.", Notification.Type.TRAY_NOTIFICATION); logWriter.println(" - Set ChangePropagationPolicy to MOST_SIGNIFICANT_ONLY."); break; case "NONE": Notification.show("Applying none equals being your config READ-ONLY.", Notification.Type.ASSISTIVE_NOTIFICATION); mutableConfig.setChangePropagationPolicy(MutableConfigurationProvider.getApplyNonePolicy()); Notification.show("ChangePropagationPolicy is now NONE.", Notification.Type.TRAY_NOTIFICATION); logWriter.println(" - Set ChangePropagationPolicy to NONE."); break; case "CUSTOM": changePropagationPolicyOther.setEnabled(true); break; case "ALL": default: mutableConfig .setChangePropagationPolicy(MutableConfigurationProvider.getApplyAllChangePolicy()); Notification.show("ChangePropagationPolicy is now ALL.", Notification.Type.TRAY_NOTIFICATION); logWriter.println(" - Set ChangePropagationPolicy to ALL."); } } }); startTAButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String taId = mutableConfig.startTransaction(); update(); Notification.show("Transaction started: " + taId, Notification.Type.TRAY_NOTIFICATION); logWriter.println("Started Transaction: " + taId); } }); rollbackTAButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String taId = mutableConfig.getTransactionId(); mutableConfig.rollbackTransaction(); update(); Notification.show("Transaction rolled back: " + taId, Notification.Type.TRAY_NOTIFICATION); logWriter.println("Rolled back Transaction: " + taId); } }); commitTAButton.addClickListener(new Button.ClickListener() { @Override public void buttonClick(Button.ClickEvent clickEvent) { String taId = mutableConfig.getTransactionId(); mutableConfig.commitTransaction(); update(); Notification.show("Transaction comitted: " + taId, Notification.Type.TRAY_NOTIFICATION); logWriter.println("Committed Transaction: " + taId); } }); }
From source file:org.apache.tamaya.ui.views.ConfigView.java
License:Apache License
private Component createFilters() { HorizontalLayout filters = new HorizontalLayout(); Button filterButton = new Button("Filter", new Button.ClickListener() { @Override/*from w w w. j av a 2 s .c om*/ public void buttonClick(Button.ClickEvent clickEvent) { fillTree(); } }); filters.setDefaultComponentAlignment(Alignment.BOTTOM_LEFT); filters.addComponents(keyFilter, valueFilter, filterButton); filters.setSpacing(true); return filters; }
From source file:org.apache.usergrid.chop.webapp.view.main.Header.java
License:Apache License
private void addRunnersButton() { Button button = UIUtil.addButton(this, "Runners", "left: 840px; top: 10px;", "80px"); button.setStyleName(Reindeer.BUTTON_LINK); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { showWindow(new RunnersWindow()); }// w ww . java2 s. co m }); }
From source file:org.apache.usergrid.chop.webapp.view.main.Header.java
License:Apache License
private void addManageButton() { Button button = UIUtil.addButton(this, "Manage", "left: 940px; top: 10px;", "80px"); button.setStyleName(Reindeer.BUTTON_LINK); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { showWindow(new UserSubwindow()); }//from www.j av a2 s . c om }); }
From source file:org.apache.usergrid.chop.webapp.view.user.GroupSubwindow.java
License:Apache License
private void initButtons() { addNewGroupButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { /*/*w ww. ja v a2 s. co m*/ * Rows in the Container data model are called Item. Here we add * a new row in the beginning of the list. */ groupContainer.removeAllContainerFilters(); Object contactId = groupContainer.addItemAt(0); /* * Each Item has a set of Properties that hold values. Here we * set a couple of those. */ groupContainer.getContainerProperty(contactId, GROUP).setValue("New Group"); /* Lets choose the newly created contact to edit it. */ groupList.select(contactId); } }); removeGroupButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Object contactId = groupList.getValue(); groupList.removeItem(contactId); } }); cancelButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { close(); // Close the sub-window } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { /*Set<String> groups = MyShiroRealm.getUserRoles(username); groups.clear(); for(Object itemId : groupList.getItemIds()){ String gname = (String) groupList.getItem(itemId).getItemProperty(GROUP).getValue(); groups.add(gname); } close(); // Close the sub-window MyShiroRealm.saveRealm();*/ } }); }
From source file:org.apache.usergrid.chop.webapp.view.user.KeyListLayout.java
License:Apache License
private void addKeyRemoveButton(final String keyName, int top) { String position = String.format("left: 0px; top: %spx;", top); Button button = UIUtil.addButton(this, "[X]", position, "25px"); button.setStyleName(Reindeer.BUTTON_LINK); button.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { removeKey(keyName);//from w w w . j av a 2 s.c o m } }); keyRemoveButtons.add(button); }
From source file:org.apache.usergrid.chop.webapp.view.user.UserSubwindow.java
License:Apache License
private void initButtons() { addNewUserButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { /*//from w w w . j a v a2 s. c o m * Rows in the Container data model are called Item. Here we add * a new row in the beginning of the list. */ userContainer.removeAllContainerFilters(); Object contactId = userContainer.addItemAt(0); /* * Each Item has a set of Properties that hold values. Here we * set a couple of those. */ userList.getContainerProperty(contactId, USERNAME).setValue("Username"); userList.getContainerProperty(contactId, PASSWORD).setValue("Password"); /* Lets choose the newly created contact to edit it. */ userList.select(contactId); } }); removeUserButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { Object contactId = userList.getValue(); userList.removeItem(contactId); String username = (String) userList.getItem(contactId).getItemProperty(USERNAME).getValue(); userDao.delete(username); } }); closeButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { close(); } }); saveButton.addClickListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { for (Object itemId : userList.getItemIds()) { String username = (String) userList.getItem(itemId).getItemProperty(USERNAME).getValue(); String password = (String) userList.getItem(itemId).getItemProperty(PASSWORD).getValue(); String instanceType = (String) userList.getItem(itemId).getItemProperty(INSTANCE_TYPE) .getValue(); String accessKey = (String) userList.getItem(itemId).getItemProperty(ACCESS_KEY).getValue(); String secretKey = (String) userList.getItem(itemId).getItemProperty(SECRET_KEY).getValue(); String imageId = (String) userList.getItem(itemId).getItemProperty(IMAGE_ID).getValue(); String keyPairName = (String) userList.getItem(itemId).getItemProperty(KEY_PAIR_NAME) .getValue(); try { userDao.save(new User(username, password)); BasicProviderParams pParams = new BasicProviderParams(username, instanceType, accessKey, secretKey, imageId, keyPairName); ProviderParams old = providerParamsDao.getByUser(username); if (old != null) { pParams.setKeys(old.getKeys()); } providerParamsDao.save(pParams); } catch (Exception e) { LOG.error("Error while saving a user: ", e); } } close(); } }); }
From source file:org.axonframework.examples.addressbook.vaadin.ui.SearchView.java
License:Apache License
public SearchView() { setCaption("Search for contacts"); setSizeFull();/*from ww w . ja v a2s . c o m*/ FormLayout formLayout = new FormLayout(); setContent(formLayout); tf = new TextField("Search term"); fieldToSearch = new NativeSelect("Field to search"); saveSearch = new CheckBox("Save search"); searchName = new TextField("Search name"); Button search = new Button("Search"); search.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { performSearch(); } }); for (int i = 0; i < ContactContainer.NATURAL_COL_ORDER.length; i++) { fieldToSearch.addItem(ContactContainer.NATURAL_COL_ORDER[i]); fieldToSearch.setItemCaption(ContactContainer.NATURAL_COL_ORDER[i], ContactContainer.COL_HEADERS_ENGLISH[i]); } fieldToSearch.setValue("name"); fieldToSearch.setNullSelectionAllowed(false); saveSearch.setValue(true); addComponent(tf); addComponent(fieldToSearch); addComponent(saveSearch); addComponent(searchName); addComponent(search); saveSearch.setImmediate(true); saveSearch.addListener(new Button.ClickListener() { public void buttonClick(Button.ClickEvent event) { searchName.setVisible(event.getButton().booleanValue()); } }); }