com.vaadin.ui.AbstractSelect.ItemCaptionMode Java Examples

The following examples show how to use com.vaadin.ui.AbstractSelect.ItemCaptionMode. 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: SelectPDPGroupWindow.java    From XACML with MIT License 5 votes vote down vote up
private void initializeSelect(Set<PDPGroup> groups) {
	//
	// Initialize GUI properties
	//
	this.listSelectPDPGroup.setImmediate(true);
	this.listSelectPDPGroup.setItemCaptionMode(ItemCaptionMode.EXPLICIT);
	this.listSelectPDPGroup.setNullSelectionAllowed(false);
	this.listSelectPDPGroup.setNewItemsAllowed(false);
	this.listSelectPDPGroup.setMultiSelect(false);
	//
	// Add items
	//
	for (PDPGroup group : groups) {
		this.listSelectPDPGroup.addItem(group);
		this.listSelectPDPGroup.setItemCaption(group, group.getName());
	}
	//
	// Listen to events
	//
	this.listSelectPDPGroup.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			self.setupButtons();
		}
	});
}
 
Example #2
Source File: PolicyEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeSelect() {
	this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
	this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
	this.listSelectAlgorithm.setNullSelectionAllowed(false);
	
	if (this.policy.getRuleCombiningAlgId() == null) {
		this.policy.setRuleCombiningAlgId(XACML3.ID_RULE_FIRST_APPLICABLE.stringValue());
	}
	this.listSelectAlgorithm.setValue(JPAUtils.findRuleAlgorithm(this.policy.getRuleCombiningAlgId()).getId());
}
 
Example #3
Source File: PolicySetEditorWindow.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeSelect() {
	this.listSelectAlgorithm.setContainerDataSource(this.algorithms);
	this.listSelectAlgorithm.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.listSelectAlgorithm.setItemCaptionPropertyId("xacmlId");
	this.listSelectAlgorithm.setNullSelectionAllowed(false);
	
	if (this.policySet.getPolicyCombiningAlgId() == null) {
		this.policySet.setPolicyCombiningAlgId(XACML3.ID_POLICY_FIRST_APPLICABLE.stringValue());
	}
	this.listSelectAlgorithm.setValue(JPAUtils.findPolicyAlgorithm(this.policySet.getPolicyCombiningAlgId()).getId());
}
 
Example #4
Source File: AttributeStandardSelectorComponent.java    From XACML with MIT License 5 votes vote down vote up
private void initializeCategories() {
	//
	// Remove any filters
	//
	AttributeStandardSelectorComponent.categories.removeAllContainerFilters();
	//
	// Initialize data source & GUI properties
	//
	this.comboBoxCategories.setContainerDataSource(AttributeStandardSelectorComponent.categories);
	this.comboBoxCategories.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.comboBoxCategories.setItemCaptionPropertyId("xacmlId");
	this.comboBoxCategories.setImmediate(true);
	this.comboBoxCategories.setNullSelectionAllowed(false);
	//
	// Set default selection
	//
	Category defaultCategory;
	if (this.attribute == null || this.attribute.getCategoryBean() == null) {
		defaultCategory = JPAUtils.findCategory(XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT);
	} else {
		defaultCategory = this.attribute.getCategoryBean();
	}
	if (defaultCategory != null) {
		this.comboBoxCategories.select(defaultCategory.getId());
	}
	//
	// Respond to events
	//
	this.comboBoxCategories.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			self.setupAttributeIDs();
			self.fireAttributeChanged(self.getAttribute());
		}
	});
}
 
Example #5
Source File: AttributeDictionarySelectorComponent.java    From XACML with MIT License 5 votes vote down vote up
protected void initializeCategoryFilter() {
	//
	// Remove any filters
	//
	AttributeDictionarySelectorComponent.categories.removeAllContainerFilters();
	//
	// Initialize data source and GUI properties
	//
	this.comboBoxCategoryFilter.setContainerDataSource(AttributeDictionarySelectorComponent.categories);
	this.comboBoxCategoryFilter.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.comboBoxCategoryFilter.setItemCaptionPropertyId("xacmlId");
	this.comboBoxCategoryFilter.setImmediate(true);
	//
	// Respond to events
	//
	this.comboBoxCategoryFilter.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			//
			// Clear any existing filters
			//
			AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
			//
			// Get the current selection
			//
			Object id = self.comboBoxCategoryFilter.getValue();
			//
			// Is anything currently selected?
			//
			if (id != null) {
				//
				// Yes - add the new filter into the container
				//
				AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("categoryBean", AttributeDictionarySelectorComponent.categories.getItem(id).getEntity()));
			}
		}
	});
}
 
Example #6
Source File: ComboBoxFieldBuilder.java    From jdal with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
public Field<?> build(Class<?> clazz, String name) {
	ComboBox combo = new ComboBox();
	fillComboBox(combo, clazz, name);
	combo.setItemCaptionMode(ItemCaptionMode.ID);
	
	return combo;
}
 
Example #7
Source File: AttributeValueEditorWindow.java    From XACML with MIT License 4 votes vote down vote up
protected void initializeCombo() {
	this.comboBoxDatatype.setContainerDataSource(((XacmlAdminUI) UI.getCurrent()).getDatatypes());
	this.comboBoxDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.comboBoxDatatype.setItemCaptionPropertyId("xacmlId");
	this.comboBoxDatatype.setFilteringMode(FilteringMode.CONTAINS);
	this.comboBoxDatatype.setImmediate(true);
	this.comboBoxDatatype.setNullSelectionAllowed(false);
	this.comboBoxDatatype.setConverter(new SingleSelectConverter<Object>(this.comboBoxDatatype));
	//
	// Select a value if its defined
	//
	if (this.datatypeRestriction != null) {
		this.comboBoxDatatype.select(this.datatypeRestriction.getId());
	} else if (this.value.getDataType() != null) {
		this.comboBoxDatatype.select(JPAUtils.findDatatype(this.value.getDataType()).getId());
	}
	//
	// Can the user change the datatype?
	//
	if (this.datatypeRestriction != null) {
		this.comboBoxDatatype.setEnabled(false);
		return;
	}
	//
	// Listen to events
	//
	this.comboBoxDatatype.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			Object id = self.comboBoxDatatype.getValue();
			assert (id != null);
			//
			// Get the entity and save it
			//
			EntityItem<Datatype> entity = ((XacmlAdminUI) UI.getCurrent()).getDatatypes().getItem(id);
			self.value.setDataType(entity.getEntity().getXacmlId());
			//
			// Reset the validator
			//
			self.textFieldValue.removeAllValidators();
			Validator validator = ValidatorFactory.newInstance(entity.getEntity());
			if (validator != null) {
				self.textFieldValue.addValidator(validator);
			}
		}
	});
}
 
Example #8
Source File: AttributeDictionarySelectorComponent.java    From XACML with MIT License 4 votes vote down vote up
protected void initializeAttributes() {
	//
	// Remove any filters
	//
	AttributeDictionarySelectorComponent.attributes.removeAllContainerFilters();
	//
	// Initialize data source and GUI properties
	//
	this.listSelectAttribute.setContainerDataSource(AttributeDictionarySelectorComponent.attributes);
	this.listSelectAttribute.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.listSelectAttribute.setItemCaptionPropertyId("xacmlId");
	this.listSelectAttribute.setImmediate(true);
	this.listSelectAttribute.setHeight(7, Unit.EM);
	//
	// Filter by datatype
	//
	if (this.datatype != null) {
		AttributeDictionarySelectorComponent.attributes.addContainerFilter(new Compare.Equal("datatypeBean", this.datatype));
	}
	//
	// Is there a default selection?
	//
	if (this.initialAttribute != null) {
		//
		// Make sure it has an id. Do I really need to check?
		//
		if (this.initialAttribute.getId() != 0) {
			this.listSelectAttribute.select(this.initialAttribute.getId());
		}
	}
	//
	// Respond to events
	//
	this.listSelectAttribute.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;

		@Override
		public void valueChange(ValueChangeEvent event) {
			self.fireAttributeChanged(self.getAttribute());
		}
	});
}
 
Example #9
Source File: AttributeDictionary.java    From XACML with MIT License 4 votes vote down vote up
protected void initializeCategoryComboFilter() {
	//
	// Set data source
	//
	this.comboBoxFilterCategory.setContainerDataSource(self.categories);
	this.comboBoxFilterCategory.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.comboBoxFilterCategory.setItemCaptionPropertyId("xacmlId");
	//
	// Initialize GUI properties
	//
	this.comboBoxFilterCategory.setNullSelectionAllowed(true);
	this.comboBoxFilterCategory.setImmediate(true);
	//
	// Respond to value changes
	//
	this.comboBoxFilterCategory.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;
		Filter currentFilter = null;

		@Override
		public void valueChange(ValueChangeEvent event) {
			//
			// Remove filter
			//
			if (currentFilter != null) {
				self.attributes.removeContainerFilter(this.currentFilter);
				this.currentFilter = null;
			}
			//
			// Set the new one
			//
			Object id = self.comboBoxFilterCategory.getValue();
			if (id == null) {
				return;
			}
			Category cat = self.categories.getItem(id).getEntity();
			this.currentFilter = new Compare.Equal("categoryBean", cat);
			self.attributes.addContainerFilter(this.currentFilter);
		}
	});
}
 
Example #10
Source File: AttributeDictionary.java    From XACML with MIT License 4 votes vote down vote up
protected void initializeDatatypeComboFilter() {
	//
	// Set data source
	//
	this.comboBoxFilterDatatype.setContainerDataSource(self.datatypes);
	this.comboBoxFilterDatatype.setItemCaptionMode(ItemCaptionMode.PROPERTY);
	this.comboBoxFilterDatatype.setItemCaptionPropertyId("xacmlId");
	//
	// Initialize GUI properties
	//
	this.comboBoxFilterDatatype.setNullSelectionAllowed(true);
	this.comboBoxFilterDatatype.setImmediate(true);
	//
	// Respond to value changes
	//
	this.comboBoxFilterDatatype.addValueChangeListener(new ValueChangeListener() {
		private static final long serialVersionUID = 1L;
		Filter currentFilter = null;

		@Override
		public void valueChange(ValueChangeEvent event) {
			//
			// Remove filter
			//
			if (currentFilter != null) {
				self.attributes.removeContainerFilter(this.currentFilter);
				this.currentFilter = null;
			}
			//
			// Set the new one
			//
			Object id = self.comboBoxFilterDatatype.getValue();
			if (id == null) {
				return;
			}
			Datatype cat = self.datatypes.getItem(id).getEntity();
			this.currentFilter = new Compare.Equal("datatypeBean", cat);
			self.attributes.addContainerFilter(this.currentFilter);
		}
	});
}
 
Example #11
Source File: FormUtils.java    From jdal with Apache License 2.0 4 votes vote down vote up
/**
 * Add a List of objects to a combo
 * @param combo combo to add items
 * @param items items to add
 */
public static void addItemList(AbstractSelect combo, List<?> items) {
	combo.setItemCaptionMode(ItemCaptionMode.ID);
	for (Object item : items)
		combo.addItem(item);
}