public class FileExportsPreferences implements BasePreference<FileExportsPreferences> { @Property(bundleKey = "FileExport.PdfOrientation.Text", helpBundleKey = "FileExport.PdfOrientation.Help", validators = PdfOrientationValidator.class) String pdfOrientation; @Property(bundleKey = "FileExport.PdfUnit.Text", helpBundleKey = "FileExport.PdfUnit.Help", validators = PdfUnitValidator.class) String pdfUnit; @Property(bundleKey = "FileExport.PdfFormat.Text", helpBundleKey = "FileExport.PdfFormat.Help", validators = PdfFormatValidator.class)
public PropertyData(final Element element, final Property propertyAnnotation, final AnnotationMirror propertyAnnotationMirror, final Elements elementUtils) { fieldName = element.getSimpleName().toString(); typeFullName = element.asType().toString(); final char elementNameFirstLetter = fieldName.charAt(0); final char elementNameCapitalizedFirstLetter = Character.toUpperCase(elementNameFirstLetter); final String nameWithoutFirstLetter = fieldName.substring(1); capitalizedFieldName = elementNameCapitalizedFirstLetter + nameWithoutFirstLetter; shared = propertyAnnotation.shared(); final TypeElement typeElement = elementUtils.getTypeElement(element.asType().toString()); subPreference = typeElement != null && typeElement.getAnnotation(WorkbenchPreference.class) != null; formType = propertyAnnotation.formType(); privateAccess = element.getModifiers().contains(Modifier.PRIVATE); typeKind = element.asType().getKind(); setupValidators(propertyAnnotationMirror, elementUtils); }
if (propertyAnnotation != null) { String propertyBundleKey = ""; if (!propertyAnnotation.bundleKey().isEmpty()) { propertyBundleKey = propertyAnnotation.bundleKey(); propertyAnnotation.shared(), false, propertyBundleKey, propertyAnnotation.helpBundleKey()); hierarchyElement.addPropertyFormOptions(field.getName(), propertyAnnotation.formOptions());
private <U extends BasePreference<U>, T extends BasePreferencePortable<U>> void save(final Class<U> clazz, final T portablePreference, final PreferenceScope scope) throws IllegalAccessException { for (Field field : portablePreference.getPojoClass().getDeclaredFields()) { Property propertyAnnotation = field.getAnnotation(Property.class); if (propertyAnnotation != null) { if (field.getType().isAnnotationPresent(WorkbenchPreference.class)) { boolean shared = propertyAnnotation.shared(); field.setAccessible(true); if (shared) { saveSharedPreference(portablePreference, field, scope); } else { saveSubPreference(portablePreference, field, scope); } } } } }
private <U extends BasePreference<U>, T extends BasePreferencePortable<U>> T load(final Class<U> clazz, T portablePreference, final PreferenceScopeResolutionStrategyInfo scopeResolutionStrategyInfo) throws IllegalAccessException { if (portablePreference == null) { portablePreference = lookupPortablePreference(clazz); } for (Field field : portablePreference.getPojoClass().getDeclaredFields()) { Property propertyAnnotation = field.getAnnotation(Property.class); if (propertyAnnotation != null) { if (field.getType().isAnnotationPresent(WorkbenchPreference.class)) { final Class<? extends BasePreference<?>> propertyType = (Class<? extends BasePreference<?>>) field.getType(); boolean shared = propertyAnnotation.shared(); field.setAccessible(true); if (shared) { BasePreferencePortable<?> loadedSharedProperty = loadSharedPreference(field, scopeResolutionStrategyInfo); field.set(portablePreference, loadedSharedProperty); } else { final BasePreferencePortable<?> subPreferenceValue = loadSubPreferenceValue(portablePreference, field, scopeResolutionStrategyInfo); field.set(portablePreference, subPreferenceValue); } } } } return portablePreference; }
/** * Created to be used in tests, and to avoid Errai errors due to unimplemented * interfaces used in portable classes. */ @Vetoed public class PortablePreferenceMock implements BasePreference<PortablePreferenceMock> { @Property(validators = NotEmptyValidator.class) String property; }
public PropertyData(final Element element, final Property propertyAnnotation, final AnnotationMirror propertyAnnotationMirror, final Elements elementUtils) { fieldName = element.getSimpleName().toString(); typeFullName = element.asType().toString(); final char elementNameFirstLetter = fieldName.charAt(0); final char elementNameCapitalizedFirstLetter = Character.toUpperCase(elementNameFirstLetter); final String nameWithoutFirstLetter = fieldName.substring(1); capitalizedFieldName = elementNameCapitalizedFirstLetter + nameWithoutFirstLetter; shared = propertyAnnotation.shared(); final TypeElement typeElement = elementUtils.getTypeElement(element.asType().toString()); subPreference = typeElement != null && typeElement.getAnnotation(WorkbenchPreference.class) != null; formType = propertyAnnotation.formType(); privateAccess = element.getModifiers().contains(Modifier.PRIVATE); typeKind = element.asType().getKind(); setupValidators(propertyAnnotationMirror, elementUtils); }
public class FileExportsPreferences implements BasePreference<FileExportsPreferences> { @Property(bundleKey = "FileExport.PdfOrientation.Text", helpBundleKey = "FileExport.PdfOrientation.Help", validators = PdfOrientationValidator.class) String pdfOrientation; @Property(bundleKey = "FileExport.PdfUnit.Text", helpBundleKey = "FileExport.PdfUnit.Help", validators = PdfUnitValidator.class) String pdfUnit; @Property(bundleKey = "FileExport.PdfFormat.Text", helpBundleKey = "FileExport.PdfFormat.Help", validators = PdfFormatValidator.class)
/** * Created to be used in tests, and to avoid Errai errors due to unimplemented * interfaces used in portable classes. */ @Vetoed public class PortablePreferenceMock implements BasePreference<PortablePreferenceMock> { @Property(validators = NotEmptyValidator.class) String property; }
@WorkbenchPreference(identifier = "WorkspaceManagerPreferences", bundleKey = "WorkspaceManagerPreferences.Label") public class WorkspaceManagerPreferences implements BasePreference<WorkspaceManagerPreferences> { @Property(bundleKey = "WorkspaceManagerPreferences.CacheMaximumSize") private int cacheMaximumSize; @Property(bundleKey = "WorkspaceManagerPreferences.CacheExpirationTime") private int cacheExpirationTime; @Property(bundleKey = "WorkspaceManagerPreferences.CacheExpirationUnit") private String cacheExpirationUnit;
@WorkbenchPreference(identifier = "ArtifactRepositoryPreference", bundleKey = "ArtifactRepositoryPreference.Label") public class ArtifactRepositoryPreference implements BasePreference<ArtifactRepositoryPreference> { @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDir") private String globalM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean globalM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDir") private String workspaceM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean workspaceM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.DistributionManagementM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean distributionManagementM2RepoDirEnabled;
@WorkbenchPreference(identifier = "ArtifactRepositoryPreference", bundleKey = "ArtifactRepositoryPreference.Label") public class ArtifactRepositoryPreference implements BasePreference<ArtifactRepositoryPreference> { @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDir", validators = NotEmptyValidator.class) private String globalM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean globalM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDir", validators = NotEmptyValidator.class) private String workspaceM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean workspaceM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.DistributionManagementM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean distributionManagementM2RepoDirEnabled;
@WorkbenchPreference(identifier = "ArtifactRepositoryPreference", bundleKey = "ArtifactRepositoryPreference.Label") public class ArtifactRepositoryPreference implements BasePreference<ArtifactRepositoryPreference> { @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDir", validators = NotEmptyValidator.class) private String globalM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.GlobalM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean globalM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDir", validators = NotEmptyValidator.class) private String workspaceM2RepoDir; @Property(bundleKey = "ArtifactRepositoryPreference.WorkspaceM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean workspaceM2RepoDirEnabled; @Property(bundleKey = "ArtifactRepositoryPreference.DistributionManagementM2RepoDirEnabled", formType = PropertyFormType.BOOLEAN) private boolean distributionManagementM2RepoDirEnabled;
static final String CHILD_GAV_EDIT_ENABLED = "org.guvnor.project.gav.child.edit.enabled"; @Property(bundleKey = "GAVPreferences.ConflictingGAVCheckDisabled.Label", helpBundleKey = "GAVPreferences.ConflictingGAVCheckDisabled.Help", formType = PropertyFormType.BOOLEAN) private boolean conflictingGAVCheckDisabled; @Property(bundleKey = "GAVPreferences.ChildGAVEditEnabled.Label", helpBundleKey = "GAVPreferences.ChildGAVEditEnabled.Help", formType = PropertyFormType.BOOLEAN)
static final String CHILD_GAV_EDIT_ENABLED = "org.guvnor.project.gav.child.edit.enabled"; @Property(bundleKey = "GAVPreferences.ConflictingGAVCheckDisabled.Label", helpBundleKey = "GAVPreferences.ConflictingGAVCheckDisabled.Help", formType = PropertyFormType.BOOLEAN) private boolean conflictingGAVCheckDisabled; @Property(bundleKey = "GAVPreferences.ChildGAVEditEnabled.Label", helpBundleKey = "GAVPreferences.ChildGAVEditEnabled.Help", formType = PropertyFormType.BOOLEAN)
@WorkbenchPreference(identifier = "ManagePreferences", bundleKey = "ManagePreferences.Label") public class ManagePreferences implements BasePreference<ManagePreferences> { public static List<Integer> PAGINATION_OPTIONS = Arrays.asList(10, 20, 50, 100); public static Integer DEFAULT_PAGINATION_OPTION = 10; @Property(bundleKey = "ManagePreferences.ItemsPerPage", helpBundleKey = "ManagePreferences.ItemsPerPage.Help", formType = PropertyFormType.NATURAL_NUMBER, validators = ItemPerPageValidator.class) private Integer itemsPerPage; @Override public ManagePreferences defaultValue(final ManagePreferences defaultValue) { defaultValue.itemsPerPage = DEFAULT_PAGINATION_OPTION; return defaultValue; } public Integer getItemsPerPage() { return itemsPerPage; } public void setItemsPerPage(Integer itemsPerPage) { this.itemsPerPage = itemsPerPage; } }
/** * Provisioning management related preferences. */ @WorkbenchPreference(identifier = "ProvisioningPreferences") public class ProvisioningPreferences implements BasePreference<ProvisioningPreferences> { @Property private Map<ProviderType, Boolean> providerTypeEnablements; public Map<ProviderType, Boolean> getProviderTypeEnablements() { return providerTypeEnablements; } public void setProviderTypeEnablements(final Map<ProviderType, Boolean> providerTypeEnablements) { this.providerTypeEnablements = providerTypeEnablements; } @Override public ProvisioningPreferences defaultValue(final ProvisioningPreferences defaultValue) { defaultValue.setProviderTypeEnablements(new HashMap<>()); return defaultValue; } }
/** * Provisioning management related preferences. */ @WorkbenchPreference(identifier = "ProvisioningPreferences") public class ProvisioningPreferences implements BasePreference<ProvisioningPreferences> { @Property private Map<ProviderType, Boolean> providerTypeEnablements; public Map<ProviderType, Boolean> getProviderTypeEnablements() { return providerTypeEnablements; } public void setProviderTypeEnablements(final Map<ProviderType, Boolean> providerTypeEnablements) { this.providerTypeEnablements = providerTypeEnablements; } @Override public ProvisioningPreferences defaultValue(final ProvisioningPreferences defaultValue) { defaultValue.setProviderTypeEnablements(new HashMap<>()); return defaultValue; } }
@WorkbenchPreference(identifier = "ManagePreferences", bundleKey = "ManagePreferences.Label") public class ManagePreferences implements BasePreference<ManagePreferences> { public static List<Integer> PAGINATION_OPTIONS = Arrays.asList(10, 20, 50, 100); public static Integer DEFAULT_PAGINATION_OPTION = 10; @Property(bundleKey = "ManagePreferences.ItemsPerPage", helpBundleKey = "ManagePreferences.ItemsPerPage.Help", formType = PropertyFormType.NATURAL_NUMBER, validators = ItemPerPageValidator.class) private Integer itemsPerPage; @Override public ManagePreferences defaultValue(final ManagePreferences defaultValue) { defaultValue.itemsPerPage = DEFAULT_PAGINATION_OPTION; return defaultValue; } public Integer getItemsPerPage() { return itemsPerPage; } public void setItemsPerPage(Integer itemsPerPage) { this.itemsPerPage = itemsPerPage; } }
@WorkbenchPreference(identifier = "MySharedPreference", bundleKey = "MySharedPreference.Label") public class MySharedPreference implements BasePreference<MySharedPreference> { @Property(bundleKey = "MySharedPreference.Text") String text; @Property(bundleKey = "MySharedPreference.MyInnerPreference2") MyInnerPreference2 myInnerPreference2; }