com.vaadin.ui.Button.ClickListener Java Examples

The following examples show how to use com.vaadin.ui.Button.ClickListener. 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: ObadviceEditorWindow.java    From XACML with MIT License 6 votes vote down vote up
private void initializeButtons() {
	this.saveButton.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				fieldGroup.commit();
				self.isSaved = true;
				self.close();
			} catch (CommitException e) {
				e.printStackTrace();
			}
		}
		
	});
}
 
Example #2
Source File: SelectPDPGroupWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			//
			// Get the selected value
			//
			self.selectedGroup = (PDPGroup) self.listSelectPDPGroup.getValue();
			assert (self.selectedGroup != null);
			//
			// Mark ourselves as saved
			//
			self.saved = true;
			//
			// Close window
			//
			self.close();
		}
	});
}
 
Example #3
Source File: VariableDefinitionEditorWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeButton() {
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit it
				//
				self.textFieldID.commit();
				//
				// Save it
				//
				self.variable.setVariableId(self.textFieldID.getValue());
				self.isSaved = true;
				//
				// Close window
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
			}
		}			
	});
}
 
Example #4
Source File: TimesheetDayChangeViewImplEx.java    From vaadinator with Apache License 2.0 6 votes vote down vote up
@Override
public void initializeUi() {
	super.initializeUi();
	// change default behavior: store the day in the section caption (and
	// hide the day field)
	super.day.setVisible(false);
	setSectionCaption(day);
	plusEntry.addClickListener(new ClickListener() {

		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			observer.onAdditionalEntry();
		}
	});
	layout.addComponent(plusEntry);
}
 
Example #5
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 #6
Source File: ColumnSelectionWindow.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeButton() {
	self.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit
				//
				self.textFieldColumn.commit();
				//
				// If we get here, the value is valid.
				// Mark ourselves as saved and close the window
				//
				self.isSaved = true;
				self.close();
			} catch (SourceException | InvalidValueException e) {
				//
				// Vaadin will display error
				//
			}
		}
	});
}
 
Example #7
Source File: SQLPIPConfigurationComponent.java    From XACML with MIT License 6 votes vote down vote up
protected void initializeButtons() {
	this.buttonTest.setImmediate(true);
	this.buttonTest.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			Object id = self.comboBoxConnectionType.getValue();
			if (id == null) {
				logger.warn("No combo box selection");
				return;
			}				
			if (id.toString().equals(SQL_TYPE_JDBC)) {
				self.testJDBCConnection();
			} else if (id.toString().equals(SQL_TYPE_JNDI)) {
				self.testJNDIConnection();
			}
		}			
	});
}
 
Example #8
Source File: ServiceDescBasic.java    From primecloud-controller with GNU General Public License v2.0 6 votes vote down vote up
private Button createLoadBalancerButton(final LoadBalancerDto loadBalancer) {
    Button button = new Button();
    button.setCaption(loadBalancer.getLoadBalancer().getLoadBalancerName());
    button.setIcon(Icons.LOADBALANCER_TAB.resource());
    button.setData(loadBalancer);
    button.addStyleName("borderless");
    button.addStyleName("loadbalancer-button");
    button.addListener(new Button.ClickListener() {
        @Override
        public void buttonClick(ClickEvent event) {
            // ロードバランサを選択
            sender.loadBalancerPanel.loadBalancerTable.select(loadBalancer);

            // ロードバランサタブに移動
            sender.tab.setSelectedTab(sender.loadBalancerPanel);
        }
    });
    return button;
}
 
Example #9
Source File: UserHomeSecuritySettingsPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the enable google auth button.
 *
 * @return the vertical layout
 */
private VerticalLayout createEnableGoogleAuthButton() {
	final VerticalLayout formLayout = new VerticalLayout();
	formLayout.setSizeFull();

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();

	formLayout.addComponent(formPanel);

	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);

	final SetGoogleAuthenticatorCredentialRequest request = new SetGoogleAuthenticatorCredentialRequest();
	request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
	request.setUserpassword("");
	final ClickListener listener = new SetGoogleAuthenticatorCredentialClickListener(request);
	getFormFactory().addRequestInputFormFields(formContent, request, SetGoogleAuthenticatorCredentialRequest.class,
			AS_LIST, ENABLE_GOOGLE_AUTHENTICATOR, listener);

	return formLayout;
}
 
Example #10
Source File: UserHomeSecuritySettingsPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the disable google auth button.
 *
 * @return the vertical layout
 */
private VerticalLayout createDisableGoogleAuthButton() {

	final VerticalLayout formLayout = new VerticalLayout();
	formLayout.setSizeFull();

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();

	formLayout.addComponent(formPanel);

	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);

	final DisableGoogleAuthenticatorCredentialRequest request = new DisableGoogleAuthenticatorCredentialRequest();
	request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
	request.setUserpassword("");
	final ClickListener listener = new DisableGoogleAuthenticatorCredentialClickListener(request);
	getFormFactory().addRequestInputFormFields(formContent, request,
			DisableGoogleAuthenticatorCredentialRequest.class, AS_LIST, DISABLE_GOOGLE_AUTHENTICATOR, listener);

	return formLayout;
}
 
Example #11
Source File: UserHomeSecuritySettingsPageModContentFactoryImpl.java    From cia with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the change password button.
 *
 * @return the vertical layout
 */
private VerticalLayout createChangePasswordButton() {

	final VerticalLayout formLayout = new VerticalLayout();
	formLayout.setSizeFull();

	final Panel formPanel = new Panel();
	formPanel.setSizeFull();

	formLayout.addComponent(formPanel);

	final FormLayout formContent = new FormLayout();
	formPanel.setContent(formContent);

	final ChangePasswordRequest request = new ChangePasswordRequest();
	request.setSessionId(RequestContextHolder.currentRequestAttributes().getSessionId());
	request.setCurrentPassword("");
	request.setNewPassword("");
	request.setRepeatNewPassword("");
	
	final ClickListener listener = new ChangePasswordClickListener(request);
	getFormFactory().addRequestInputFormFields(formContent, request,
			ChangePasswordRequest.class, Arrays.asList("currentPassword","newPassword","repeatNewPassword"), "Change password", listener);

	return formLayout;
}
 
Example #12
Source File: AdviceEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonSave.setImmediate(true);
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit
				//
				self.textFieldAdviceID.commit();
				self.optionGroupEffect.commit();
				//
				// all good, save everything
				//
				self.advice.setAdviceId(self.textFieldAdviceID.getValue());
				self.advice.setAppliesTo((EffectType) self.optionGroupEffect.getValue());
				//
				// Set ourselves as saved
				//
				self.isSaved = true;
				//
				// Close the window
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
				//
				// Vaadin displays the error
				//
			}
		}			
	});
}
 
Example #13
Source File: Parameter.java    From chipster with MIT License 5 votes vote down vote up
private Button getDeleteButton(final Object itemId) {
	Button btDelete = new Button();
	btDelete.setIcon(new ThemeResource("images/close.png"));
	btDelete.setStyleName(BaseTheme.BUTTON_LINK);
	btDelete.addClickListener(new ClickListener() {
		private static final long serialVersionUID = -3695725710938486562L;

		@Override
		public void buttonClick(ClickEvent event) {
			typeTable.removeItem(itemId);
			enumDefaultValue.removeItem(itemId);
		}
	});
	return btDelete;
}
 
Example #14
Source File: ExpressionSelectionWindow.java    From XACML with MIT License 5 votes vote down vote up
private void initializeButtons() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			self.isSaved = true;
			self.selection = self.optionGroupExpression.getValue().toString();
			self.close();
		}			
	});
}
 
Example #15
Source File: VariableReferenceEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit
				//
				self.textFieldVariable.commit();
				//
				// Now we can save
				//
				self.isSaved = true;
				self.variable.setVariableId(self.textFieldVariable.getValue());
				//
				// And close the window
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
				logger.error("Commit variable id: " + e);
			}
		}			
	});
}
 
Example #16
Source File: ToolEditorUI.java    From chipster with MIT License 5 votes vote down vote up
private HorizontalLayout getButtonPanel() {
HorizontalLayout hLayout = new HorizontalLayout();
hLayout.setSpacing(true);

btUpdateTextEditor = new Button();
btUpdateTextEditor.setDescription("Update text area");
btUpdateTextEditor.setIcon(new ThemeResource("images/arrow_down.png"));
btUpdateTextEditor.addClickListener(new CSCToolToTextClickListener(this));
hLayout.addComponent(btUpdateTextEditor);
btUpdateToolEditor = new Button();
btUpdateToolEditor.setDescription("Update tool elements");
btUpdateToolEditor.setIcon(new ThemeResource("images/arrow_up.png"));
btUpdateToolEditor.addClickListener(new CSCTextToToolClickListener(this));
hLayout.addComponent(btUpdateToolEditor);
Button btClearAll = new Button("Clear All");
btClearAll.addClickListener(new ClickListener() {
	private static final long serialVersionUID = 1487893808578560989L;

	@Override
	public void buttonClick(ClickEvent event) {
		
		ToolEditorUI.this.addWindow(new ConfirmClearAll(ToolEditorUI.this));
	}
});
hLayout.addComponent(btClearAll);
return hLayout;

  }
 
Example #17
Source File: PolicySetEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit
				//
				self.listSelectAlgorithm.commit();
				self.textFieldVersion.commit();
				self.textAreaDescription.commit();
				//
				// Save everything
				//
				self.policySet.setDescription(self.textAreaDescription.getValue());
				self.policySet.setVersion(self.textFieldVersion.getValue());
				Object id = self.listSelectAlgorithm.getValue();
				self.policySet.setPolicyCombiningAlgId(algorithms.getItem(id).getEntity().getXacmlId());
				//
				// Mark ourselves as saved
				//
				self.isSaved = true;
				//
				// Close window
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
				//
				// VAADIN will show the required error message to the user
				//
			}
		}
	});
}
 
Example #18
Source File: SubDomainEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.setEnabled(false);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Make sure the text is valid
				//
				self.textFieldSubdomain.validate();
				//
				// Parse our the subdomain parts
				//
				self.subdomain = self.textFieldSubdomain.getValue();
				self.saved = true;
				//
				// Close it up
				//
				self.close();
			} catch (InvalidValueException e) {
				logger.error(e);
			}
		}
		
	});
}
 
Example #19
Source File: RegexpEditorComponent.java    From XACML with MIT License 5 votes vote down vote up
private void initializeTestPanel() {
	this.textFieldTestValue.setNullRepresentation("");
	
	this.buttonTest.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			String testValue = self.textFieldTestValue.getValue();
			if (testValue == null || testValue.length() == 0) {
				return;
			}
			String regExp = self.textFieldExpression.getValue();
			if (regExp == null || regExp.length() == 0) {
				return;
			}
			//
			// Create a validator
			//
			Validator validator = new RegexpValidator(regExp, true, "Regular Expression does NOT match.");
			//
			// Add it
			//
			self.textFieldTestValue.addValidator(validator);
			//
			// Validate
			//
			try {
				self.textFieldTestValue.validate();
				AdminNotification.info("Success! Regular Expression Matches");
			} catch (InvalidValueException e) {
				AdminNotification.warn("Failed, Regular Expression does NOT match");
			}
			//
			// Remove the validator
			//
			self.textFieldTestValue.removeValidator(validator);
		}
	});
}
 
Example #20
Source File: PDPStatusWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonOK.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			self.close();
		}
	});
}
 
Example #21
Source File: EditPDPGroupWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Validate
				//
				self.textName.commit();
				//
				// All good save everything
				//
				self.doSave();
				//
				// mark ourselves as saved
				//
				self.isSaved = true;
				//
				// Close the window
				//
				self.close();
			} catch (InvalidValueException e) {
				//
				// Ignore, Vaadin will display our message
				//
			}
		}
	});
}
 
Example #22
Source File: ApplyEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonSelect.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			self.selected();
		}
	});
}
 
Example #23
Source File: PIPConfigurationEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.grid.setComponentAlignment(this.buttonSave, Alignment.BOTTOM_CENTER);
	this.buttonSave.setImmediate(true);
	this.buttonSave.setEnabled(false);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit changes
				//
				self.fieldGroup.commit();
				//
				// Save
				//
				self.isSaved = true;
				//
				// We can close
				//
				self.close();
			} catch (CommitException e) {
				logger.warn("Couldn't commit, the save button should NOT be enabled.");
			}
		}			
	});
}
 
Example #24
Source File: PIPParamEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit the values
				//
				self.textFieldName.commit();
				self.textFieldValue.commit();
				//
				// Done, save
				//
				self.isSaved = true;
				//
				// Close
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
				//
				// Vaadin will display error
				//
			}
		}
	});
}
 
Example #25
Source File: MatchEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			self.doSave();
		}		
	});
}
 
Example #26
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 #27
Source File: ObligationEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButton() {
	this.buttonSave.setImmediate(true);
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit
				//
				self.textFieldObligationID.commit();
				self.optionGroupFullfillOn.commit();
				//
				// all good, save everything
				//
				self.obligation.setObligationId(self.textFieldObligationID.getValue());
				self.obligation.setFulfillOn((EffectType) self.optionGroupFullfillOn.getValue());
				//
				// Set ourselves as saved
				//
				self.isSaved = true;
				//
				// Close the window
				//
				self.close();
			} catch (SourceException | InvalidValueException e) {
				//
				// Vaadin displays the error
				//
			}
		}			
	});
}
 
Example #28
Source File: PIPResolverEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.grid.setComponentAlignment(this.buttonSave, Alignment.BOTTOM_CENTER);
	this.buttonSave.setImmediate(true);
	this.buttonSave.setEnabled(false);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Commit changes
				//
				self.fieldGroup.commit();
				//
				// Save
				//
				self.isSaved = true;
				//
				// We can close
				//
				self.close();
			} catch (CommitException e) {
				logger.warn("Couldn't commit, the save button should NOT be enabled.");
			}
		}			
	});
}
 
Example #29
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 #30
Source File: AttributeValueEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeButtons() {
	this.buttonSave.setClickShortcut(KeyCode.ENTER);
	this.buttonSave.addClickListener(new ClickListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void buttonClick(ClickEvent event) {
			try {
				//
				// Make sure it validates (i.e. call the Validators)
				//
				self.comboBoxDatatype.validate();
				self.textFieldValue.validate();
				//
				// Yes
				//
				self.isSaved = true;
				//
				// Close
				//
				self.close();
			} catch (InvalidValueException e) {
				//
				// Vaadin with update GUI displaying the error
				//
			}
		}
	});
}