List of usage examples for com.vaadin.ui Button setDisableOnClick
public void setDisableOnClick(boolean disableOnClick)
From source file:org.apache.ace.webui.vaadin.VaadinClient.java
License:Apache License
/** * @return a button to approve one or more targets. *///from ww w.j a v a 2 s . c o m private Button createApproveTargetsButton() { final Button button = new Button("A"); button.setDisableOnClick(true); button.setImmediate(true); button.setEnabled(false); button.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { m_targetsPanel.approveSelectedTargets(); } }); m_targetsPanel.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { TargetsPanel targetsPanel = (TargetsPanel) event.getProperty(); Collection<?> itemIDs = (Collection<?>) targetsPanel.getValue(); boolean enabled = false; for (Object itemID : itemIDs) { if (targetsPanel.isItemApproveNeeded(itemID)) { enabled = true; break; } } button.setEnabled(enabled); } }); return button; }
From source file:org.apache.ace.webui.vaadin.VaadinClient.java
License:Apache License
private Button createRegisterTargetsButton() { final Button button = new Button("R"); button.setDisableOnClick(true); button.setImmediate(true);//from w ww .j av a2 s . c o m button.setEnabled(false); button.addListener(new Button.ClickListener() { @Override public void buttonClick(ClickEvent event) { m_targetsPanel.registerSelectedTargets(); } }); m_targetsPanel.addListener(new ValueChangeListener() { @Override public void valueChange(ValueChangeEvent event) { TargetsPanel targetsPanel = (TargetsPanel) event.getProperty(); Collection<?> itemIDs = (Collection<?>) targetsPanel.getValue(); boolean enabled = false; for (Object itemID : itemIDs) { if (targetsPanel.isItemRegistrationNeeded(itemID)) { enabled = true; break; } } button.setEnabled(enabled); } }); return button; }
From source file:org.lucidj.vaadinui.Login.java
License:Apache License
@Override // LoginForm protected Component createContent(TextField userNameField, PasswordField passwordField, Button loginButton) { // Save the predefined components this.userNameField = userNameField; this.passwordField = passwordField; this.loginButton = loginButton; // Make LoginForm container full-screen setSizeFull();//from w w w .j ava 2 s. co m VerticalLayout layout = new VerticalLayout(); layout.setSizeFull(); layout.addStyleName("login-wallpaper"); final VerticalLayout loginPanel = new VerticalLayout(); loginPanel.setSizeUndefined(); loginPanel.setMargin(true); loginPanel.setSpacing(true); Responsive.makeResponsive(loginPanel); loginPanel.addStyleName("card"); //-------- // HEADER //-------- final HorizontalLayout labels = new HorizontalLayout(); labels.setWidth("100%"); final Label title = new Label("<h3><strong>LucidJ</strong> Console</h3>", ContentMode.HTML); labels.addComponent(title); labels.setExpandRatio(title, 1); loginPanel.addComponent(labels); //-------- // FIELDS //-------- HorizontalLayout fields = new HorizontalLayout(); fields.setSpacing(true); fields.addStyleName("fields"); userNameField.setImmediate(true); userNameField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER); final ShortcutListener username_enter_listener = new ShortcutListener("Next field (Tab)", ShortcutAction.KeyCode.ENTER, null) { @Override public void handleAction(Object o, Object o1) { passwordField.setValue(""); passwordField.focus(); } }; userNameField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { show_default_message(); int new_username_length = textChangeEvent.getText().length(); // Check for autofill if (userNameField.isEmpty() && new_username_length > 1 && !userNameField_filling) { // This is autofill userNameField.removeShortcutListener(username_enter_listener); userNameField.setCursorPosition(new_username_length); userNameField.setSelectionRange(0, new_username_length); } else { userNameField_filling = true; passwordField.setValue(""); userNameField.addShortcutListener(username_enter_listener); } } }); userNameField.addFocusListener(new FieldEvents.FocusListener() { @Override public void focus(FieldEvents.FocusEvent focusEvent) { // Cursor on username, Enter jump to password loginButton.removeClickShortcut(); userNameField.addShortcutListener(username_enter_listener); } }); userNameField.addBlurListener(new FieldEvents.BlurListener() { @Override public void blur(FieldEvents.BlurEvent blurEvent) { // Cursor on password or elsewhere, enter submits userNameField.removeShortcutListener(username_enter_listener); loginButton.setClickShortcut(ShortcutAction.KeyCode.ENTER); } }); passwordField.setImmediate(true); passwordField.setTextChangeEventMode(AbstractTextField.TextChangeEventMode.EAGER); passwordField.addTextChangeListener(new FieldEvents.TextChangeListener() { @Override public void textChange(FieldEvents.TextChangeEvent textChangeEvent) { show_default_message(); } }); loginButton.addStyleName(ValoTheme.BUTTON_PRIMARY); loginButton.setDisableOnClick(true); fields.addComponents(userNameField, passwordField, loginButton); fields.setComponentAlignment(loginButton, Alignment.BOTTOM_LEFT); loginPanel.addComponent(fields); //-------- // FOOTER //-------- loginPanel.addComponent(new CheckBox("Remember me", true)); loginPanel.addComponent(message_label); show_default_message(); layout.addComponent(loginPanel); layout.setComponentAlignment(loginPanel, Alignment.MIDDLE_CENTER); return (layout); }
From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditor.java
License:Open Source License
/** * Returns a button component. On click, it triggers adding a bundle descriptor. * @return a button for adding a descriptor to a bundle. *//*from w w w .j av a 2s. co m*/ @SuppressWarnings("serial") private Component createAddDescriptorButton() { Button addDescriptorButton = CmsToolBar.createButton(FontOpenCms.COPY_LOCALE, m_messages.key(Messages.GUI_ADD_DESCRIPTOR_0)); addDescriptorButton.setDisableOnClick(true); addDescriptorButton.addClickListener(new ClickListener() { @SuppressWarnings("synthetic-access") public void buttonClick(ClickEvent event) { Map<Object, Object> filters = getFilters(); m_table.clearFilters(); if (!m_model.addDescriptor()) { CmsVaadinUtils.showAlert(m_messages.key(Messages.ERR_BUNDLE_DESCRIPTOR_CREATION_FAILED_0), m_messages.key(Messages.ERR_BUNDLE_DESCRIPTOR_CREATION_FAILED_DESCRIPTION_0), null); } else { IndexedContainer newContainer = null; try { newContainer = m_model.getContainerForCurrentLocale(); m_table.setContainerDataSource(newContainer); initFieldFactories(); initStyleGenerators(); setEditMode(EditMode.MASTER); m_table.setColumnCollapsingAllowed(true); adjustVisibleColumns(); m_options.updateShownOptions(m_model.hasMasterMode(), m_model.canAddKeys()); m_options.setEditMode(m_model.getEditMode()); } catch (IOException | CmsException e) { // Can never appear here, since container is created by addDescriptor already. LOG.error(e.getLocalizedMessage(), e); } } setFilters(filters); } }); return addDescriptorButton; }
From source file:org.opencms.ui.editors.messagebundle.CmsMessageBundleEditor.java
License:Open Source License
/** * Creates the button for converting an XML bundle in a property bundle. * @return the created button./*w ww .j ava2s .c o m*/ */ private Component createConvertToPropertyBundleButton() { Button addDescriptorButton = CmsToolBar.createButton(FontOpenCms.SETTINGS, m_messages.key(Messages.GUI_CONVERT_TO_PROPERTY_BUNDLE_0)); addDescriptorButton.setDisableOnClick(true); addDescriptorButton.addClickListener(new ClickListener() { private static final long serialVersionUID = 1L; public void buttonClick(ClickEvent event) { try { m_model.saveAsPropertyBundle(); Notification.show("Conversion successful."); } catch (CmsException | IOException e) { CmsVaadinUtils.showAlert("Conversion failed", e.getLocalizedMessage(), null); } } }); addDescriptorButton.setDisableOnClick(true); return addDescriptorButton; }
From source file:org.ripla.web.demo.widgets.views.ButtonWidgetsView.java
License:Open Source License
public ButtonWidgetsView() { super();/*from w ww . jav a2s. c om*/ final IMessages lMessages = Activator.getMessages(); final VerticalLayout lLayout = initLayout(lMessages, "widgets.title.page.button"); //$NON-NLS-1$ lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.button"))); //$NON-NLS-1$ final Button lButton = new Button(lMessages.getMessage("widgets.view.button.label.save")); //$NON-NLS-1$ lButton.setDescription(lMessages.getMessage("widgets.view.button.descr.normal")); //$NON-NLS-1$ lButton.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.normal"))); //$NON-NLS-1$ lLayout.addComponent(lButton); lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.label.image"))); //$NON-NLS-1$ final Button lButton2 = new Button(lMessages.getMessage("widgets.view.button.label.save")); //$NON-NLS-1$ lButton2.setIcon(new ThemeResource("../runo/icons/16/ok.png")); //$NON-NLS-1$ lButton2.setDescription(lMessages.getMessage("widgets.view.button.label.image")); //$NON-NLS-1$ lButton2.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.image"))); //$NON-NLS-1$ lLayout.addComponent(lButton2); lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.disable"))); //$NON-NLS-1$ lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.disable"))); //$NON-NLS-1$ final Button lButton3 = new Button(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$ lButton3.setDisableOnClick(true); lButton3.setDescription(lMessages.getMessage("widgets.view.button.descr.disable")); //$NON-NLS-1$ lButton3.addClickListener(new Button.ClickListener() { @Override public void buttonClick(final ClickEvent inEvent) { try { Thread.sleep(3000); } catch (final InterruptedException exc) { } Notification.show(lMessages.getMessage("widgets.view.button.feedback.disable"), Notification.Type.TRAY_NOTIFICATION); inEvent.getButton().setEnabled(true); } }); lLayout.addComponent(lButton3); lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.link"))); //$NON-NLS-1$ final Button lButton4 = new Button(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$ lButton4.setStyleName(BaseTheme.BUTTON_LINK); lButton4.addClickListener(new Listener(lMessages.getMessage("widgets.view.button.feedback.link"))); //$NON-NLS-1$ lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.link"))); //$NON-NLS-1$ lLayout.addComponent(lButton4); lLayout.addComponent(getSubtitle(lMessages.getMessage("widgets.view.button.subtitle.check"))); //$NON-NLS-1$ lLayout.addComponent(new Label(lMessages.getMessage("widgets.view.button.label.check"))); //$NON-NLS-1$ final CheckBox lCheckbox = new CheckBox(lMessages.getMessage("widgets.view.button.label.click")); //$NON-NLS-1$ lCheckbox.setImmediate(true); lCheckbox.addValueChangeListener(new Property.ValueChangeListener() { @Override public void valueChange(final ValueChangeEvent inEvent) { Notification.show(lMessages.getMessage("widgets.view.button.feedback.check"), Notification.Type.TRAY_NOTIFICATION); } }); lLayout.addComponent(lCheckbox); }
From source file:org.rubicone.poc.vpush.uil.sending.SendingUI.java
License:Apache License
private FormLayout createPushMessageSendingForm() { FormLayout pushMessageSendingForm = new FormLayout(); Panel pushMessageSendingPanel = new Panel("push message sending form"); pushMessageSendingPanel.setContent(pushMessageSendingForm); TextField inputField = new TextField("text to send"); inputField.setValueChangeMode(ValueChangeMode.EAGER); pushMessageSendingForm.addComponent(inputField); Button sendButton = new Button("send", VaadinIcons.LOCATION_ARROW); sendButton.setDisableOnClick(true); sendButton.setEnabled(false);/*from w w w .j a va2 s . c o m*/ sendButton.addClickListener(event -> { this.broadcaster.broadcast(inputField.getValue()); this.sentMessages.addComponent(new Label(new Date() + ": " + inputField.getValue())); inputField.setValue(""); }); inputField.addValueChangeListener(event -> { sendButton.setEnabled(!event.getValue().isEmpty()); }); pushMessageSendingForm.addComponent(sendButton); return pushMessageSendingForm; }