Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2016-11-11 00:52:21 -0500
committerEike Stepper2016-11-11 00:52:21 -0500
commit7b509f423332eb4199e3a07b3e13f0ece39d50a9 (patch)
tree69b443740452c836a2c68abeaa8504c248d25047 /plugins
parent7659226151059d8e487f462ea63dbb879b99260b (diff)
downloadcdo-7b509f423332eb4199e3a07b3e13f0ece39d50a9.tar.gz
cdo-7b509f423332eb4199e3a07b3e13f0ece39d50a9.tar.xz
cdo-7b509f423332eb4199e3a07b3e13f0ece39d50a9.zip
[507387] [Security] Provide getChoiceOfValues() for PackageFilters and ClassFilters
https://bugs.eclipse.org/bugs/show_bug.cgi?id=507387
Diffstat (limited to 'plugins')
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassFilterItemProvider.java28
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java37
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackageFilterItemProvider.java30
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java23
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityEditPlugin.java67
6 files changed, 118 insertions, 69 deletions
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF
index 9f4d3cfc5f..5e23abf652 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.security.edit/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.emf.cdo.security.edit;singleton:=true
-Bundle-Version: 4.3.200.qualifier
+Bundle-Version: 4.4.0.qualifier
Bundle-ClassPath: .
Bundle-Activator: org.eclipse.emf.cdo.security.provider.SecurityEditPlugin$Implementation
Bundle-Vendor: %providerName
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassFilterItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassFilterItemProvider.java
index bd3e30a822..2fafade08f 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassFilterItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassFilterItemProvider.java
@@ -13,6 +13,7 @@ package org.eclipse.emf.cdo.security.provider;
import org.eclipse.emf.cdo.security.ClassFilter;
import org.eclipse.emf.cdo.security.PermissionFilter;
import org.eclipse.emf.cdo.security.SecurityPackage;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
@@ -67,15 +68,30 @@ public class ClassFilterItemProvider extends PermissionFilterItemProvider
* This adds a property descriptor for the Applicable Class feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
protected void addApplicableClassPropertyDescriptor(Object object)
{
- itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
- getString("_UI_ClassFilter_applicableClass_feature"), //$NON-NLS-1$
- getString("_UI_PropertyDescriptor_description", "_UI_ClassFilter_applicableClass_feature", //$NON-NLS-1$//$NON-NLS-2$
- "_UI_ClassFilter_type"), //$NON-NLS-1$
- SecurityPackage.Literals.CLASS_FILTER__APPLICABLE_CLASS, true, false, true, null, null, null));
+ itemPropertyDescriptors.add(new ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_ClassFilter_applicableClass_feature"), getString("_UI_PropertyDescriptor_description", "_UI_ClassFilter_applicableClass_feature", //$NON-NLS-2$//$NON-NLS-3$
+ "_UI_ClassFilter_type"),
+ SecurityPackage.Literals.CLASS_FILTER__APPLICABLE_CLASS, true, false, true, null, null, null)
+ {
+ @Override
+ public Collection<?> getChoiceOfValues(Object object)
+ {
+ if (object instanceof ClassFilter)
+ {
+ CDOView view = ((ClassFilter)object).cdoView();
+ if (view != null)
+ {
+ return SecurityEditPlugin.getSortedClasses(view);
+ }
+ }
+
+ return super.getChoiceOfValues(object);
+ }
+ });
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java
index 16d9bf00e1..a68ba0bd4d 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.cdo.security.provider;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.security.Access;
import org.eclipse.emf.cdo.security.ClassPermission;
import org.eclipse.emf.cdo.security.SecurityPackage;
@@ -19,15 +18,11 @@ import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
/**
@@ -86,38 +81,10 @@ public class ClassPermissionItemProvider extends PermissionItemProvider
{
if (object instanceof ClassPermission)
{
- ClassPermission classPermission = (ClassPermission)object;
- CDOView view = classPermission.cdoView();
+ CDOView view = ((ClassPermission)object).cdoView();
if (view != null)
{
- List<EClass> result = new ArrayList<EClass>();
- for (CDOPackageInfo packageInfo : view.getSession().getPackageRegistry().getPackageInfos())
- {
- for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
- {
- if (classifier instanceof EClass)
- {
- result.add((EClass)classifier);
-
- }
- }
- }
-
- Collections.sort(result, new Comparator<EClass>()
- {
- public int compare(EClass c1, EClass c2)
- {
- int comparison = c1.getName().compareTo(c2.getName());
- if (comparison == 0)
- {
- comparison = c1.getEPackage().getNsURI().compareTo(c2.getEPackage().getNsURI());
- }
-
- return comparison;
- }
- });
-
- return result;
+ return SecurityEditPlugin.getSortedClasses(view);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackageFilterItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackageFilterItemProvider.java
index a9153cf0dd..f060419109 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackageFilterItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackageFilterItemProvider.java
@@ -10,13 +10,16 @@
*/
package org.eclipse.emf.cdo.security.provider;
+import org.eclipse.emf.cdo.security.PackageFilter;
import org.eclipse.emf.cdo.security.PermissionFilter;
import org.eclipse.emf.cdo.security.SecurityPackage;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.notify.AdapterFactory;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
import java.util.Collection;
import java.util.List;
@@ -63,15 +66,30 @@ public class PackageFilterItemProvider extends PermissionFilterItemProvider
* This adds a property descriptor for the Applicable Package feature.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
protected void addApplicablePackagePropertyDescriptor(Object object)
{
- itemPropertyDescriptors.add(createItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
- getString("_UI_PackageFilter_applicablePackage_feature"), //$NON-NLS-1$
- getString("_UI_PropertyDescriptor_description", "_UI_PackageFilter_applicablePackage_feature", //$NON-NLS-1$//$NON-NLS-2$
- "_UI_PackageFilter_type"), //$NON-NLS-1$
- SecurityPackage.Literals.PACKAGE_FILTER__APPLICABLE_PACKAGE, true, false, true, null, null, null));
+ itemPropertyDescriptors.add(new ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory).getRootAdapterFactory(), getResourceLocator(),
+ getString("_UI_PackageFilter_applicablePackage_feature"), getString("_UI_PropertyDescriptor_description", "_UI_PackageFilter_applicablePackage_feature", //$NON-NLS-2$//$NON-NLS-3$
+ "_UI_PackageFilter_type"),
+ SecurityPackage.Literals.PACKAGE_FILTER__APPLICABLE_PACKAGE, true, false, true, null, null, null)
+ {
+ @Override
+ public Collection<?> getChoiceOfValues(Object object)
+ {
+ if (object instanceof PackageFilter)
+ {
+ CDOView view = ((PackageFilter)object).cdoView();
+ if (view != null)
+ {
+ return SecurityEditPlugin.getSortedPackages(view);
+ }
+ }
+
+ return super.getChoiceOfValues(object);
+ }
+ });
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java
index a9953010f2..b60b7f9258 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java
@@ -10,7 +10,6 @@
*/
package org.eclipse.emf.cdo.security.provider;
-import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.security.Access;
import org.eclipse.emf.cdo.security.PackagePermission;
import org.eclipse.emf.cdo.security.SecurityPackage;
@@ -23,10 +22,7 @@ import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
import org.eclipse.emf.edit.provider.ItemPropertyDescriptor;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
import java.util.List;
/**
@@ -85,25 +81,10 @@ public class PackagePermissionItemProvider extends PermissionItemProvider
{
if (object instanceof PackagePermission)
{
- PackagePermission packagePermission = (PackagePermission)object;
- CDOView view = packagePermission.cdoView();
+ CDOView view = ((PackagePermission)object).cdoView();
if (view != null)
{
- List<EPackage> result = new ArrayList<EPackage>();
- for (CDOPackageInfo packageInfo : view.getSession().getPackageRegistry().getPackageInfos())
- {
- result.add(packageInfo.getEPackage());
- }
-
- Collections.sort(result, new Comparator<EPackage>()
- {
- public int compare(EPackage p1, EPackage p2)
- {
- return p1.getNsURI().compareTo(p2.getNsURI());
- }
- });
-
- return result;
+ return SecurityEditPlugin.getSortedPackages(view);
}
}
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityEditPlugin.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityEditPlugin.java
index 80a8d70d0a..623be4f5dc 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityEditPlugin.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/SecurityEditPlugin.java
@@ -10,13 +10,23 @@
*/
package org.eclipse.emf.cdo.security.provider;
+import org.eclipse.emf.cdo.common.model.CDOPackageInfo;
import org.eclipse.emf.cdo.edit.CDOEditPlugin;
import org.eclipse.emf.cdo.expressions.provider.ExpressionsEditPlugin;
+import org.eclipse.emf.cdo.view.CDOView;
import org.eclipse.emf.common.EMFPlugin;
import org.eclipse.emf.common.util.ResourceLocator;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EClassifier;
+import org.eclipse.emf.ecore.EPackage;
import org.eclipse.emf.ecore.provider.EcoreEditPlugin;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
/**
* This is the central singleton for the Security edit plugin.
* <!-- begin-user-doc -->
@@ -78,6 +88,63 @@ public final class SecurityEditPlugin extends EMFPlugin
}
/**
+ * @since 4.4
+ */
+ public static List<EPackage> getSortedPackages(CDOView view)
+ {
+ List<EPackage> result = new ArrayList<EPackage>();
+ for (CDOPackageInfo packageInfo : view.getSession().getPackageRegistry().getPackageInfos())
+ {
+ result.add(packageInfo.getEPackage());
+ }
+
+ Collections.sort(result, new Comparator<EPackage>()
+ {
+ public int compare(EPackage p1, EPackage p2)
+ {
+ return p1.getNsURI().compareTo(p2.getNsURI());
+ }
+ });
+
+ return result;
+ }
+
+ /**
+ * @since 4.4
+ */
+ public static List<EClass> getSortedClasses(CDOView view)
+ {
+ List<EClass> result = new ArrayList<EClass>();
+ for (CDOPackageInfo packageInfo : view.getSession().getPackageRegistry().getPackageInfos())
+ {
+ for (EClassifier classifier : packageInfo.getEPackage().getEClassifiers())
+ {
+ if (classifier instanceof EClass)
+ {
+ result.add((EClass)classifier);
+
+ }
+ }
+ }
+
+ Collections.sort(result, new Comparator<EClass>()
+ {
+ public int compare(EClass c1, EClass c2)
+ {
+ int comparison = c1.getName().compareTo(c2.getName());
+ if (comparison == 0)
+ {
+ comparison = c1.getEPackage().getNsURI().compareTo(c2.getEPackage().getNsURI());
+ }
+
+ return comparison;
+ }
+ });
+
+ return result;
+ }
+
+ /**
* The actual implementation of the Eclipse <b>Plugin</b>.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->

Back to the top