Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2013-01-26 10:22:51 +0000
committerEike Stepper2013-01-26 10:29:31 +0000
commit89fe2240f8e4b66754832bc7b4e3df0a5c50fd2e (patch)
tree1c63ee7c204ffa6485e820ec2ae01ab4e29d8c4b /plugins/org.eclipse.emf.cdo.security.edit
parent2a224d522dedb8c4aaa37dfecfee0b3a3feb8621 (diff)
downloadcdo-89fe2240f8e4b66754832bc7b4e3df0a5c50fd2e.tar.gz
cdo-89fe2240f8e4b66754832bc7b4e3df0a5c50fd2e.tar.xz
cdo-89fe2240f8e4b66754832bc7b4e3df0a5c50fd2e.zip
[399159] Various enhancements to the security manager
https://bugs.eclipse.org/bugs/show_bug.cgi?id=399159
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.security.edit')
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ClassPermissionItemProvider.java65
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/PackagePermissionItemProvider.java68
-rw-r--r--plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourcePermissionItemProvider.java14
3 files changed, 122 insertions, 25 deletions
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 5e43cf1e75..0dfd407256 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
@@ -2,13 +2,16 @@
*/
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;
+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.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
@@ -21,8 +24,12 @@ import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+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;
/**
@@ -68,17 +75,59 @@ public class ClassPermissionItemProvider extends PermissionItemProvider implemen
* 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_ClassPermission_applicableClass_feature"), //$NON-NLS-1$
- getString(
- "_UI_PropertyDescriptor_description", "_UI_ClassPermission_applicableClass_feature", "_UI_ClassPermission_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- SecurityPackage.Literals.CLASS_PERMISSION__APPLICABLE_CLASS, true, false, true, null, null, null));
+ itemPropertyDescriptors.add(new ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory)
+ .getRootAdapterFactory(), getResourceLocator(), getString("_UI_ClassPermission_applicableClass_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_ClassPermission_applicableClass_feature",
+ "_UI_ClassPermission_type"), SecurityPackage.Literals.CLASS_PERMISSION__APPLICABLE_CLASS, true, false,
+ true, null, null, null)
+ {
+ @Override
+ public Collection<?> getChoiceOfValues(Object object)
+ {
+ if (object instanceof ClassPermission)
+ {
+ ClassPermission classPermission = (ClassPermission)object;
+ CDOView view = classPermission.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 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 98b1126a61..de517979a3 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
@@ -2,12 +2,15 @@
*/
package org.eclipse.emf.cdo.security.provider;
-import org.eclipse.emf.cdo.security.PackagePermission;
+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;
+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.EPackage;
import org.eclipse.emf.edit.provider.ComposeableAdapterFactory;
import org.eclipse.emf.edit.provider.IEditingDomainItemProvider;
import org.eclipse.emf.edit.provider.IItemColorProvider;
@@ -20,8 +23,12 @@ import org.eclipse.emf.edit.provider.ITableItemColorProvider;
import org.eclipse.emf.edit.provider.ITableItemFontProvider;
import org.eclipse.emf.edit.provider.ITableItemLabelProvider;
import org.eclipse.emf.edit.provider.ITreeItemContentProvider;
+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;
/**
@@ -67,17 +74,46 @@ public class PackagePermissionItemProvider extends PermissionItemProvider implem
* 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_PackagePermission_applicablePackage_feature"), //$NON-NLS-1$
- getString(
- "_UI_PropertyDescriptor_description", "_UI_PackagePermission_applicablePackage_feature", "_UI_PackagePermission_type"), //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
- SecurityPackage.Literals.PACKAGE_PERMISSION__APPLICABLE_PACKAGE, true, false, true, null, null, null));
+ itemPropertyDescriptors.add(new ItemPropertyDescriptor(((ComposeableAdapterFactory)adapterFactory)
+ .getRootAdapterFactory(), getResourceLocator(), getString("_UI_PackagePermission_applicablePackage_feature"),
+ getString("_UI_PropertyDescriptor_description", "_UI_PackagePermission_applicablePackage_feature",
+ "_UI_PackagePermission_type"), SecurityPackage.Literals.PACKAGE_PERMISSION__APPLICABLE_PACKAGE, true,
+ false, true, null, null, null)
+ {
+ @Override
+ public Collection<?> getChoiceOfValues(Object object)
+ {
+ if (object instanceof PackagePermission)
+ {
+ PackagePermission packagePermission = (PackagePermission)object;
+ CDOView view = packagePermission.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 super.getChoiceOfValues(object);
+ }
+ });
}
/**
@@ -107,15 +143,21 @@ public class PackagePermissionItemProvider extends PermissionItemProvider implem
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
@Override
public String getText(Object object)
{
Access labelValue = ((PackagePermission)object).getAccess();
- String label = labelValue == null ? null : labelValue.toString();
- return label == null || label.length() == 0 ? getString("_UI_PackagePermission_type") : //$NON-NLS-1$
- getString("_UI_PackagePermission_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ EPackage applicablePackage = ((PackagePermission)object).getApplicablePackage();
+ String label = labelValue == null ? "?" : labelValue.toString(); //$NON-NLS-1$
+
+ if (applicablePackage != null)
+ {
+ label += " " + applicablePackage.getName(); //$NON-NLS-1$
+ }
+
+ return label == null || label.length() == 0 ? getString("_UI_PackagePermission_type") : label; //$NON-NLS-1$
}
/**
diff --git a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourcePermissionItemProvider.java b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourcePermissionItemProvider.java
index 15383a360c..03ee1c1b47 100644
--- a/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourcePermissionItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.security.edit/src/org/eclipse/emf/cdo/security/provider/ResourcePermissionItemProvider.java
@@ -111,15 +111,21 @@ public class ResourcePermissionItemProvider extends PermissionItemProvider imple
* This returns the label text for the adapted class.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
- * @generated
+ * @generated NOT
*/
@Override
public String getText(Object object)
{
Access labelValue = ((ResourcePermission)object).getAccess();
- String label = labelValue == null ? null : labelValue.toString();
- return label == null || label.length() == 0 ? getString("_UI_ResourcePermission_type") : //$NON-NLS-1$
- getString("_UI_ResourcePermission_type") + " " + label; //$NON-NLS-1$ //$NON-NLS-2$
+ String pattern = ((ResourcePermission)object).getPattern();
+ String label = labelValue == null ? "?" : labelValue.toString(); //$NON-NLS-1$
+
+ if (pattern != null)
+ {
+ label += " " + pattern; //$NON-NLS-1$
+ }
+
+ return label == null || label.length() == 0 ? getString("_UI_ResourcePermission_type") : label; //$NON-NLS-1$
}
/**

Back to the top