Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2011-08-23 12:40:09 -0400
committerEike Stepper2011-08-23 12:40:09 -0400
commit763bd76462dfc27b1ed0d26d5765487eddddc3d9 (patch)
tree8aef9876ff704c003688eb84231e99a272d345bb
parent9da9b11b475f7dee7e8d8e32dcbfcc380bcb7e73 (diff)
downloadcdo-763bd76462dfc27b1ed0d26d5765487eddddc3d9.tar.gz
cdo-763bd76462dfc27b1ed0d26d5765487eddddc3d9.tar.xz
cdo-763bd76462dfc27b1ed0d26d5765487eddddc3d9.zip
[355535] Redesign PropertyTesters and IPropertySourceProviders
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355535
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF8
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/plugin.xml11
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java48
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties32
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOPropertySource.java71
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java254
-rw-r--r--plugins/org.eclipse.emf.cdo/plugin.xml12
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties36
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionPropertyTester.java271
-rw-r--r--plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/ViewPropertyTester.java139
-rw-r--r--plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF2
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java (renamed from plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionAdapterFactory.java)28
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DefaultPropertySource.java210
-rw-r--r--plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF4
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/DefaultPropertyTester.java71
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/PropertiesProvider.java24
-rw-r--r--plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Property.java96
17 files changed, 867 insertions, 450 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
index 356f819a5a..c157a490dc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.emf.cdo.ui/META-INF/MANIFEST.MF
@@ -10,6 +10,7 @@ Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";resolution:=optional;visibility:=reexport,
org.eclipse.core.resources;bundle-version="[3.4.0,4.0.0)";resolution:=optional;visibility:=reexport,
org.eclipse.ui.ide;bundle-version="[3.4.0,4.0.0)";resolution:=optional;visibility:=reexport,
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
@@ -78,13 +79,6 @@ Export-Package: org.eclipse.emf.cdo.internal.ui;version="4.0.100";
org.eclipse.emf.cdo.tests.ui,
org.eclipse.emf.cdo.dawn.ui,
org.eclipse.emf.cdo.explorer",
- org.eclipse.emf.cdo.internal.ui.properties;version="4.0.100";
- x-friends:="org.eclipse.emf.cdo.ui.defs,
- org.eclipse.emf.cdo.ui.ide,
- org.eclipse.emf.cdo.ui.location,
- org.eclipse.emf.cdo.tests.ui,
- org.eclipse.emf.cdo.dawn.ui,
- org.eclipse.emf.cdo.explorer",
org.eclipse.emf.cdo.internal.ui.views;version="4.0.100";
x-friends:="org.eclipse.emf.cdo.ui.defs,
org.eclipse.emf.cdo.ui.ide,
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index c70c0e3a4c..7ae48a363e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -135,10 +135,13 @@
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="org.eclipse.emf.cdo.session.CDOSession"
- class="org.eclipse.emf.cdo.internal.ui.properties.CDOSessionAdapterFactory">
- <adapter
- type="org.eclipse.ui.views.properties.IPropertySourceProvider">
- </adapter>
+ class="org.eclipse.emf.cdo.internal.ui.CDOPropertyAdapterFactory">
+ <adapter type="org.eclipse.ui.views.properties.IPropertySourceProvider"/>
+ </factory>
+ <factory
+ adaptableType="org.eclipse.emf.cdo.view.CDOView"
+ class="org.eclipse.emf.cdo.internal.ui.CDOPropertyAdapterFactory">
+ <adapter type="org.eclipse.ui.views.properties.IPropertySourceProvider"/>
</factory>
</extension>
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java
new file mode 100644
index 0000000000..4fb823fe11
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java
@@ -0,0 +1,48 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.cdo.internal.ui;
+
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.internal.cdo.session.SessionPropertyTester;
+import org.eclipse.emf.internal.cdo.view.ViewPropertyTester;
+
+import org.eclipse.net4j.util.ui.AbstractPropertyAdapterFactory;
+import org.eclipse.net4j.util.ui.DefaultPropertySource;
+
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory
+{
+ public CDOPropertyAdapterFactory()
+ {
+ }
+
+ @Override
+ protected IPropertySource createPropertySource(Object object)
+ {
+ if (object instanceof CDOSession)
+ {
+ return new DefaultPropertySource<CDOSession>((CDOSession)object, new SessionPropertyTester());
+ }
+
+ if (object instanceof CDOView)
+ {
+ return new DefaultPropertySource<CDOView>((CDOView)object, new ViewPropertyTester());
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
index 3a466e8a32..cf828eca0a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/messages/messages.properties
@@ -62,38 +62,6 @@ CDOPreferencePage.7=EMF invalidation notifications:
CDORemoteSessionsView_0=Message from {0}
CDORemoteSessionsView_1=Message to {0}
CDORemoteSessionsView_2=Message:
-CDOSessionPropertySource_0=ID
-CDOSessionPropertySource_10=Name
-CDOSessionPropertySource_11=The name of the repository of this session.
-CDOSessionPropertySource_12=UUID
-CDOSessionPropertySource_13=The UUID of the repository of this session.
-CDOSessionPropertySource_14=Type
-CDOSessionPropertySource_15=The type of the repository of this session. One of MASTER, BACKUP, CLONE.
-CDOSessionPropertySource_16=State
-CDOSessionPropertySource_17=The state of the repository of this session. One of OFFLINE, SYNCING, ONLINE.
-CDOSessionPropertySource_18=Creation Time
-CDOSessionPropertySource_19=The creation time of the repository of this session.
-CDOSessionPropertySource_20=Supporting Audits
-CDOSessionPropertySource_21=Whether the repository of this session is supporting auditing.
-CDOSessionPropertySource_22=Supporting Branches
-CDOSessionPropertySource_23=Whether the repository of this session is supporting branching.
-CDOSessionPropertySource_24=Store Type
-CDOSessionPropertySource_25=The type of the store that backs the repository of this session.
-CDOSessionPropertySource_26=Object ID Types
-CDOSessionPropertySource_27=The types of object IDs created by the store that backs the repository of this session.
-CDOSessionPropertySource_28=Supporting Ecore
-CDOSessionPropertySource_29=Whether the repository of this session is supporting Ecore instances.
-CDOSessionPropertySource_30=Ensure Referential Integrity
-CDOSessionPropertySource_31=Whether the repository of this session is ensuring referential integrity.
-CDOSessionPropertySource_32=ID Generation Location
-CDOSessionPropertySource_33=One of STORE, CLIENT.
-CDOSessionPropertySource_3=The ID of this session.
-CDOSessionPropertySource_4=User
-CDOSessionPropertySource_5=The ID of the authenticated user of this session.
-CDOSessionPropertySource_6=Passive Updates Enabled
-CDOSessionPropertySource_7=Whether this session is receiving passive updates from the repository.
-CDOSessionPropertySource_8=Passive Updates Mode
-CDOSessionPropertySource_9=One of INVALIDATIONS, CHANGES, ADDITIONS.
CDOStateFilter.0=conflict
CDOStateFilter.1=transient
CDOStateFilter.2=new
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOPropertySource.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOPropertySource.java
deleted file mode 100644
index 2d03bf112a..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOPropertySource.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/**
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.ui.properties;
-
-import org.eclipse.ui.views.properties.IPropertyDescriptor;
-import org.eclipse.ui.views.properties.IPropertySource;
-import org.eclipse.ui.views.properties.PropertyDescriptor;
-
-import java.util.ArrayList;
-import java.util.List;
-
-/**
- * @author Eike Stepper
- */
-public abstract class CDOPropertySource<OBJECT> implements IPropertySource
-{
- private List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
-
- private OBJECT object;
-
- public CDOPropertySource(OBJECT object)
- {
- this.object = object;
- }
-
- public OBJECT getObject()
- {
- return object;
- }
-
- public IPropertyDescriptor[] getPropertyDescriptors()
- {
- return descriptors.toArray(new IPropertyDescriptor[descriptors.size()]);
- }
-
- public PropertyDescriptor addPropertyDescriptor(String category, Object id, String displayName, String description)
- {
- PropertyDescriptor descriptor = new PropertyDescriptor(id, displayName);
- descriptor.setCategory(category);
- descriptor.setDescription(description);
-
- descriptors.add(descriptor);
- return descriptor;
- }
-
- public boolean isPropertySet(Object id)
- {
- return true;
- }
-
- public void resetPropertyValue(Object id)
- {
- }
-
- public void setPropertyValue(Object id, Object value)
- {
- }
-
- public Object getEditableValue()
- {
- return null;
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java
deleted file mode 100644
index b483f05bee..0000000000
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionPropertySource.java
+++ /dev/null
@@ -1,254 +0,0 @@
-/**
- * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Eike Stepper - initial API and implementation
- */
-package org.eclipse.emf.cdo.internal.ui.properties;
-
-import org.eclipse.emf.cdo.common.CDOCommonSession.Options.PassiveUpdateMode;
-import org.eclipse.emf.cdo.common.id.CDOID;
-import org.eclipse.emf.cdo.internal.ui.messages.Messages;
-import org.eclipse.emf.cdo.session.CDOSession;
-
-import java.util.Date;
-
-/**
- * @author Eike Stepper
- */
-public class CDOSessionPropertySource extends CDOPropertySource<CDOSession>
-{
- private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$
-
- private static final String CATEGORY_REPOSITORY = "Repository"; //$NON-NLS-1$
-
- private static final String SESSION_ID = "sessionID"; //$NON-NLS-1$
-
- private static final String USER_ID = "userID"; //$NON-NLS-1$
-
- private static final String PASSIVE_UPDATE_ENABLED = "passiveUpdateEnabled"; //$NON-NLS-1$
-
- private static final String PASSIVE_UPDATE_MODE = "passiveUpdateMode"; //$NON-NLS-1$
-
- private static final String REPOSITORY_NAME = "repositoryName"; //$NON-NLS-1$
-
- private static final String REPOSITORY_UUID = "repositoryUUID"; //$NON-NLS-1$
-
- private static final String REPOSITORY_TYPE = "repositoryType"; //$NON-NLS-1$
-
- private static final String REPOSITORY_STATE = "repositoryState"; //$NON-NLS-1$
-
- private static final String REPOSITORY_CREATION_TIME = "repositoryCreationTime"; //$NON-NLS-1$
-
- private static final String SUPPORTING_AUDITS = "supportingAudits"; //$NON-NLS-1$
-
- private static final String SUPPORTING_BRANCHES = "supportingBranches"; //$NON-NLS-1$
-
- private static final String SUPPORTING_ECORE = "supportingEcore"; //$NON-NLS-1$
-
- private static final String ENSURE_REFERENTIAL_INTEGRITY = "ensureReferentialIntegrity"; //$NON-NLS-1$
-
- private static final String ID_GENERATION_LOCATION = "idGenerationLocation"; //$NON-NLS-1$
-
- private static final String STORE_TYPE = "storeType"; //$NON-NLS-1$
-
- private static final String OBJECT_ID_TYPES = "objectIDTypes"; //$NON-NLS-1$
-
- public CDOSessionPropertySource(CDOSession object)
- {
- super(object);
-
- addPropertyDescriptor(CATEGORY_SESSION, SESSION_ID,//
- Messages.getString("CDOSessionPropertySource_0"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_3")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_SESSION, USER_ID, //
- Messages.getString("CDOSessionPropertySource_4"), Messages.getString("CDOSessionPropertySource_5")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_SESSION, PASSIVE_UPDATE_ENABLED, //
- Messages.getString("CDOSessionPropertySource_6"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_7")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_SESSION, PASSIVE_UPDATE_MODE, //
- Messages.getString("CDOSessionPropertySource_8"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_9")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, REPOSITORY_NAME, //
- Messages.getString("CDOSessionPropertySource_10"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_11")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, REPOSITORY_UUID, //
- Messages.getString("CDOSessionPropertySource_12"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_13")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, REPOSITORY_TYPE, //
- Messages.getString("CDOSessionPropertySource_14"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_15")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, REPOSITORY_STATE, //
- Messages.getString("CDOSessionPropertySource_16"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_17")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, REPOSITORY_CREATION_TIME, //
- Messages.getString("CDOSessionPropertySource_18"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_19")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, SUPPORTING_AUDITS, //
- Messages.getString("CDOSessionPropertySource_20"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_21")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, SUPPORTING_BRANCHES, //
- Messages.getString("CDOSessionPropertySource_22"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_23")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, SUPPORTING_ECORE, //
- Messages.getString("CDOSessionPropertySource_28"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_29")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, ENSURE_REFERENTIAL_INTEGRITY, //
- Messages.getString("CDOSessionPropertySource_30"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_31")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, ID_GENERATION_LOCATION, //
- Messages.getString("CDOSessionPropertySource_32"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_33")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, STORE_TYPE, //
- Messages.getString("CDOSessionPropertySource_24"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_25")); //$NON-NLS-1$
-
- addPropertyDescriptor(CATEGORY_REPOSITORY, OBJECT_ID_TYPES, //
- Messages.getString("CDOSessionPropertySource_26"), //$NON-NLS-1$
- Messages.getString("CDOSessionPropertySource_27")); //$NON-NLS-1$
- }
-
- public Object getPropertyValue(Object id)
- {
- CDOSession session = getObject();
- if (SESSION_ID.equals(id))
- {
- return session.getSessionID();
- }
-
- if (USER_ID.equals(id))
- {
- return session.getUserID();
- }
-
- if (PASSIVE_UPDATE_ENABLED.equals(id))
- {
- return session.options().isPassiveUpdateEnabled();
- }
-
- if (PASSIVE_UPDATE_MODE.equals(id))
- {
- return session.options().getPassiveUpdateMode().toString();
- }
-
- if (REPOSITORY_NAME.equals(id))
- {
- return session.getRepositoryInfo().getName();
- }
-
- if (REPOSITORY_UUID.equals(id))
- {
- return session.getRepositoryInfo().getUUID();
- }
-
- if (REPOSITORY_TYPE.equals(id))
- {
- return session.getRepositoryInfo().getType().toString();
- }
-
- if (REPOSITORY_STATE.equals(id))
- {
- return session.getRepositoryInfo().getState().toString();
- }
-
- if (REPOSITORY_CREATION_TIME.equals(id))
- {
- return new Date(session.getRepositoryInfo().getCreationTime());
- }
-
- if (SUPPORTING_AUDITS.equals(id))
- {
- return session.getRepositoryInfo().isSupportingAudits();
- }
-
- if (SUPPORTING_BRANCHES.equals(id))
- {
- return session.getRepositoryInfo().isSupportingBranches();
- }
-
- if (ENSURE_REFERENTIAL_INTEGRITY.equals(id))
- {
- return session.getRepositoryInfo().isEnsuringReferentialIntegrity();
- }
-
- if (ID_GENERATION_LOCATION.equals(id))
- {
- return session.getRepositoryInfo().getIDGenerationLocation();
- }
-
- if (STORE_TYPE.equals(id))
- {
- return session.getRepositoryInfo().getStoreType();
- }
-
- if (OBJECT_ID_TYPES.equals(id))
- {
- StringBuilder builder = new StringBuilder();
- for (CDOID.ObjectType objectIDType : session.getRepositoryInfo().getObjectIDTypes())
- {
- if (builder.length() != 0)
- {
- builder.append(", "); //$NON-NLS-1$
- }
-
- builder.append(objectIDType);
- }
-
- return builder.toString();
- }
-
- return null;
- }
-
- @Override
- public void resetPropertyValue(Object id)
- {
- if (PASSIVE_UPDATE_ENABLED.equals(id))
- {
- getObject().options().setPassiveUpdateEnabled(true);
- }
- else if (PASSIVE_UPDATE_MODE.equals(id))
- {
- getObject().options().setPassiveUpdateMode(PassiveUpdateMode.INVALIDATIONS);
- }
- else
- {
- super.resetPropertyValue(id);
- }
- }
-
- @Override
- public void setPropertyValue(Object id, Object value)
- {
- if (PASSIVE_UPDATE_ENABLED.equals(id))
- {
- getObject().options().setPassiveUpdateEnabled((Boolean)value);
- }
- else if (PASSIVE_UPDATE_MODE.equals(id))
- {
- getObject().options().setPassiveUpdateMode((PassiveUpdateMode)value);
- }
- else
- {
- super.setPropertyValue(id, value);
- }
- }
-}
diff --git a/plugins/org.eclipse.emf.cdo/plugin.xml b/plugins/org.eclipse.emf.cdo/plugin.xml
index fb13317a0d..eea8a20174 100644
--- a/plugins/org.eclipse.emf.cdo/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo/plugin.xml
@@ -43,10 +43,14 @@
id="org.eclipse.emf.cdo.SessionTester"
type="org.eclipse.emf.cdo.session.CDOSession"
namespace="org.eclipse.emf.cdo.session"
- properties="sessionID,userID,passiveUpdateEnabled,passiveUpdateMode,supportingAudits,supportingBranches,repositoryName,repositoryUUID,repositoryType,repositoryState,repositoryCreationTime"
- class="org.eclipse.emf.internal.cdo.session.SessionPropertyTester">
- </propertyTester>
+ properties="open,sessionID,userID,passiveUpdateEnabled,passiveUpdateMode,supportingAudits,supportingBranches,repositoryName,repositoryUUID,repositoryType,repositoryState,repositoryCreationTime"
+ class="org.eclipse.emf.internal.cdo.session.SessionPropertyTester"/>
+ <propertyTester
+ id="org.eclipse.emf.cdo.ViewTester"
+ type="org.eclipse.emf.cdo.view.CDOView"
+ namespace="org.eclipse.emf.cdo.view"
+ properties="open,viewID,branchName,branchPath,timeStamp,readOnly,dirty,durable,sessionID,userID"
+ class="org.eclipse.emf.internal.cdo.view.ViewPropertyTester"/>
</extension>
-
</plugin>
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
index 764439111e..13a00933cf 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/messages/messages.properties
@@ -90,3 +90,39 @@ InvalidURIException.0=Invalid URI "{0}": {1}
OpenSessionRequest.0=Repository {0} not found
OpenSessionRequest.3=Failed to open session for repository {0}
SyncRevisionsRequest.2=Did not expect to receive object with id {0}
+SessionPropertyTester_0=ID
+SessionPropertyTester_10=Name
+SessionPropertyTester_11=The name of the repository of this session.
+SessionPropertyTester_12=UUID
+SessionPropertyTester_13=The UUID of the repository of this session.
+SessionPropertyTester_14=Type
+SessionPropertyTester_15=The type of the repository of this session. One of MASTER, BACKUP, CLONE.
+SessionPropertyTester_16=State
+SessionPropertyTester_17=The state of the repository of this session. One of OFFLINE, SYNCING, ONLINE.
+SessionPropertyTester_18=Creation Time
+SessionPropertyTester_19=The creation time of the repository of this session.
+SessionPropertyTester_20=Supporting Audits
+SessionPropertyTester_21=Whether the repository of this session is supporting auditing.
+SessionPropertyTester_22=Supporting Branches
+SessionPropertyTester_23=Whether the repository of this session is supporting branching.
+SessionPropertyTester_24=Store Type
+SessionPropertyTester_25=The type of the store that backs the repository of this session.
+SessionPropertyTester_26=Object ID Types
+SessionPropertyTester_27=The types of object IDs created by the store that backs the repository of this session.
+SessionPropertyTester_28=Supporting Ecore
+SessionPropertyTester_29=Whether the repository of this session is supporting Ecore instances.
+SessionPropertyTester_30=Ensure Referential Integrity
+SessionPropertyTester_31=Whether the repository of this session is ensuring referential integrity.
+SessionPropertyTester_32=ID Generation Location
+SessionPropertyTester_33=One of STORE, CLIENT.
+SessionPropertyTester_34=Open
+SessionPropertyTester_35=Whether this session is open or not.
+SessionPropertyTester_36=Last Update
+SessionPropertyTester_37=The time stamp of the last passive update.
+SessionPropertyTester_3=The ID of this session.
+SessionPropertyTester_4=User
+SessionPropertyTester_5=The ID of the authenticated user of this session.
+SessionPropertyTester_6=Passive Updates Enabled
+SessionPropertyTester_7=Whether this session is receiving passive updates from the repository.
+SessionPropertyTester_8=Passive Updates Mode
+SessionPropertyTester_9=One of INVALIDATIONS, CHANGES, ADDITIONS.
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionPropertyTester.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionPropertyTester.java
index 39b240582a..207ccbb14c 100644
--- a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionPropertyTester.java
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/session/SessionPropertyTester.java
@@ -10,90 +10,233 @@
*/
package org.eclipse.emf.internal.cdo.session;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
import org.eclipse.emf.cdo.session.CDOSession;
-import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.emf.internal.cdo.messages.Messages;
-import org.eclipse.core.expressions.PropertyTester;
+import org.eclipse.net4j.util.properties.DefaultPropertyTester;
+import org.eclipse.net4j.util.properties.Property;
/**
* @author Eike Stepper
*/
-public class SessionPropertyTester extends PropertyTester
+public class SessionPropertyTester extends DefaultPropertyTester<CDOSession>
{
- public SessionPropertyTester()
- {
- }
+ private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$
- public boolean test(Object receiver, String property, Object[] args, Object expectedValue)
+ private static final String CATEGORY_REPOSITORY = "Repository"; //$NON-NLS-1$
+
+ public SessionPropertyTester()
{
- CDOSession session = (CDOSession)receiver;
- if ("sessionID".equals(property)) //$NON-NLS-1$
+ add(new Property<CDOSession>("open", Messages.getString("SessionPropertyTester_34"),//
+ Messages.getString("SessionPropertyTester_35"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- int expected = (Integer)expectedValue;
- return session.getSessionID() == expected;
- }
-
- if ("userID".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return !session.isClosed();
+ }
+ });
+
+ add(new Property<CDOSession>("sessionID", Messages.getString("SessionPropertyTester_0"),//
+ Messages.getString("SessionPropertyTester_3"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.getUserID(), expected);
- }
-
- if ("passiveUpdateEnabled".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getSessionID();
+ }
+ });
+
+ add(new Property<CDOSession>("userID", Messages.getString("SessionPropertyTester_4"), //
+ Messages.getString("SessionPropertyTester_5"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- boolean expected = (Boolean)expectedValue;
- return session.options().isPassiveUpdateEnabled() == expected;
- }
-
- if ("passiveUpdateMode".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getUserID();
+ }
+ });
+
+ add(new Property<CDOSession>("passiveUpdateEnabled", Messages.getString("SessionPropertyTester_6"), //
+ Messages.getString("SessionPropertyTester_7"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.options().getPassiveUpdateMode().toString(), expected);
- }
-
- if ("supportingAudits".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.options().isPassiveUpdateEnabled();
+ }
+ });
+
+ add(new Property<CDOSession>("lastUpdateTime", Messages.getString("SessionPropertyTester_36"), //
+ Messages.getString("SessionPropertyTester_37"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- boolean expected = (Boolean)expectedValue;
- return session.getRepositoryInfo().isSupportingAudits() == expected;
- }
-
- if ("supportingBranches".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return CDOCommonUtil.formatTimeStamp(session.getLastUpdateTime());
+ }
+ });
+
+ add(new Property<CDOSession>("passiveUpdateMode", Messages.getString("SessionPropertyTester_8"), //
+ Messages.getString("SessionPropertyTester_9"), //$NON-NLS-1$
+ CATEGORY_SESSION)
{
- boolean expected = (Boolean)expectedValue;
- return session.getRepositoryInfo().isSupportingBranches() == expected;
- }
-
- if ("repositoryName".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.options().getPassiveUpdateMode();
+ }
+ });
+
+ add(new Property<CDOSession>("repositoryName", Messages.getString("SessionPropertyTester_10"), //
+ Messages.getString("SessionPropertyTester_11"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.getRepositoryInfo().getName(), expected);
- }
-
- if ("repositoryUUID".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getName();
+ }
+ });
+
+ add(new Property<CDOSession>("repositoryUUID", Messages.getString("SessionPropertyTester_12"), //
+ Messages.getString("SessionPropertyTester_13"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.getRepositoryInfo().getUUID(), expected);
- }
-
- if ("repositoryType".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getUUID();
+ }
+ });
+
+ add(new Property<CDOSession>("repositoryType", Messages.getString("SessionPropertyTester_14"), //
+ Messages.getString("SessionPropertyTester_15"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.getRepositoryInfo().getType().toString(), expected);
- }
-
- if ("repositoryState".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getType();
+ }
+ });
+
+ add(new Property<CDOSession>("repositoryState", Messages.getString("SessionPropertyTester_16"), //
+ Messages.getString("SessionPropertyTester_17"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
{
- String expected = (String)expectedValue;
- return ObjectUtil.equals(session.getRepositoryInfo().getState().toString(), expected);
- }
-
- if ("repositoryCreationTime".equals(property)) //$NON-NLS-1$
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getState();
+ }
+ });
+
+ add(new Property<CDOSession>("repositoryCreationTime", Messages.getString("SessionPropertyTester_18"), //
+ Messages.getString("SessionPropertyTester_19"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
{
- long expected = (Long)expectedValue;
- return session.getRepositoryInfo().getCreationTime() == expected;
- }
-
- return false;
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return CDOCommonUtil.formatTimeStamp(session.getRepositoryInfo().getCreationTime());
+ }
+ });
+
+ add(new Property<CDOSession>("supportingAudits", Messages.getString("SessionPropertyTester_20"), //
+ Messages.getString("SessionPropertyTester_21"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().isSupportingAudits();
+ }
+ });
+
+ add(new Property<CDOSession>("supportingBranches", Messages.getString("SessionPropertyTester_22"), //
+ Messages.getString("SessionPropertyTester_23"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().isSupportingBranches();
+ }
+ });
+
+ add(new Property<CDOSession>("supportingEcore", Messages.getString("SessionPropertyTester_28"), //
+ Messages.getString("SessionPropertyTester_29"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().isSupportingEcore();
+ }
+ });
+
+ add(new Property<CDOSession>("ensureReferentialIntegrity", Messages.getString("SessionPropertyTester_30"), //
+ Messages.getString("SessionPropertyTester_31"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().isEnsuringReferentialIntegrity();
+ }
+ });
+
+ add(new Property<CDOSession>("idGenerationLocation", Messages.getString("SessionPropertyTester_32"), //
+ Messages.getString("SessionPropertyTester_33"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getIDGenerationLocation();
+ }
+ });
+
+ add(new Property<CDOSession>("storeType", Messages.getString("SessionPropertyTester_24"), //
+ Messages.getString("SessionPropertyTester_25"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ return session.getRepositoryInfo().getStoreType();
+ }
+ });
+
+ add(new Property<CDOSession>("objectIDTypes", Messages.getString("SessionPropertyTester_26"), //
+ Messages.getString("SessionPropertyTester_27"), //$NON-NLS-1$
+ CATEGORY_REPOSITORY)
+ {
+ @Override
+ protected Object eval(CDOSession session)
+ {
+ StringBuilder builder = new StringBuilder();
+ for (CDOID.ObjectType objectIDType : session.getRepositoryInfo().getObjectIDTypes())
+ {
+ if (builder.length() != 0)
+ {
+ builder.append(", "); //$NON-NLS-1$
+ }
+
+ builder.append(objectIDType);
+ }
+
+ return builder;
+ }
+ });
}
}
diff --git a/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/ViewPropertyTester.java b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/ViewPropertyTester.java
new file mode 100644
index 0000000000..0902c07c51
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo/src/org/eclipse/emf/internal/cdo/view/ViewPropertyTester.java
@@ -0,0 +1,139 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.emf.internal.cdo.view;
+
+import org.eclipse.emf.cdo.common.util.CDOCommonUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.net4j.util.properties.DefaultPropertyTester;
+import org.eclipse.net4j.util.properties.Property;
+
+/**
+ * @author Eike Stepper
+ */
+public class ViewPropertyTester extends DefaultPropertyTester<CDOView>
+{
+ private static final String CATEGORY_VIEW = "View"; //$NON-NLS-1$
+
+ private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$
+
+ public ViewPropertyTester()
+ {
+ add(new Property<CDOView>("open", //$NON-NLS-1$
+ "Open", "Whether this view is open or not.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return !view.isClosed();
+ }
+ });
+
+ add(new Property<CDOView>("viewID", //$NON-NLS-1$
+ "ID", "The ID of this view.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getViewID();
+ }
+ });
+
+ add(new Property<CDOView>("branchName") //$NON-NLS-1$
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getBranch().getName();
+ }
+ });
+
+ add(new Property<CDOView>("branch", //$NON-NLS-1$
+ "Branch", "The branch of this view.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getBranch().getPathName();
+ }
+ });
+
+ add(new Property<CDOView>("timeStamp", //$NON-NLS-1$
+ "Time Stamp", "The time stamp of this view.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return CDOCommonUtil.formatTimeStamp(view.getTimeStamp());
+ }
+ });
+
+ add(new Property<CDOView>("lastUpdateTime", //$NON-NLS-1$
+ "Last Update", "The time stamp of the last passive update.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return CDOCommonUtil.formatTimeStamp(view.getLastUpdateTime());
+ }
+ });
+
+ add(new Property<CDOView>("readOnly", //$NON-NLS-1$
+ "Read-Only", "Whether this view is read-only or not.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.isReadOnly();
+ }
+ });
+
+ add(new Property<CDOView>("dirty", //$NON-NLS-1$
+ "Dirty", "Whether this view is dirty or not.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.isDirty();
+ }
+ });
+
+ add(new Property<CDOView>("durable", //$NON-NLS-1$
+ "Durable", "Whether this view is durable or not.", CATEGORY_VIEW)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getDurableLockingID() != null;
+ }
+ });
+
+ add(new Property<CDOView>("sessionID", //$NON-NLS-1$
+ "Session ID", "The ID of the session of this view.", CATEGORY_SESSION)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getSession().getSessionID();
+ }
+ });
+
+ add(new Property<CDOView>("userID", //$NON-NLS-1$
+ "User ID", "The user ID of the session of this view.", CATEGORY_SESSION)
+ {
+ @Override
+ protected Object eval(CDOView view)
+ {
+ return view.getSession().getUserID();
+ }
+ });
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
index 03b87f98e5..3fec0aa4dd 100644
--- a/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util.ui/META-INF/MANIFEST.MF
@@ -10,6 +10,8 @@ Bundle-Activator: org.eclipse.net4j.util.internal.ui.bundle.OM$Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)",
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
+ org.eclipse.ui.views;bundle-version="[3.4.0,4.0.0)";resolution:=optional;visibility:=reexport,
org.eclipse.ui;bundle-version="[3.4.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.util;bundle-version="[3.0.0,4.0.0)";visibility:=reexport,
org.eclipse.net4j.ui.shared;bundle-version="[4.0.0,5.0.0)"
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionAdapterFactory.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java
index 3f044c8f0a..675ae0c99a 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/properties/CDOSessionAdapterFactory.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/AbstractPropertyAdapterFactory.java
@@ -8,9 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
*/
-package org.eclipse.emf.cdo.internal.ui.properties;
-
-import org.eclipse.emf.cdo.session.CDOSession;
+package org.eclipse.net4j.util.ui;
import org.eclipse.core.runtime.IAdapterFactory;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -18,27 +16,34 @@ import org.eclipse.ui.views.properties.IPropertySourceProvider;
/**
* @author Eike Stepper
+ * @since 3.2
*/
@SuppressWarnings("rawtypes")
-public class CDOSessionAdapterFactory implements IAdapterFactory
+public abstract class AbstractPropertyAdapterFactory implements IAdapterFactory
{
- public static final Class[] CLASSES = { IPropertySourceProvider.class };
+ private static final Class[] CLASSES = { IPropertySourceProvider.class };
- public CDOSessionAdapterFactory()
+ public AbstractPropertyAdapterFactory()
+ {
+ }
+
+ public Class[] getAdapterList()
{
+ return CLASSES;
}
public Object getAdapter(Object adaptableObject, Class adapterType)
{
- if (adaptableObject instanceof CDOSession)
+ if (adapterType == CLASSES[0])
{
- if (adapterType == CLASSES[0])
+ final IPropertySource propertySource = createPropertySource(adaptableObject);
+ if (propertySource != null)
{
return new IPropertySourceProvider()
{
public IPropertySource getPropertySource(Object object)
{
- return new CDOSessionPropertySource((CDOSession)object);
+ return propertySource;
}
};
}
@@ -47,8 +52,5 @@ public class CDOSessionAdapterFactory implements IAdapterFactory
return null;
}
- public Class[] getAdapterList()
- {
- return CLASSES;
- }
+ protected abstract IPropertySource createPropertySource(Object object);
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DefaultPropertySource.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DefaultPropertySource.java
new file mode 100644
index 0000000000..4eefdb6f0e
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/DefaultPropertySource.java
@@ -0,0 +1,210 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.ui;
+
+import org.eclipse.net4j.util.properties.PropertiesProvider;
+import org.eclipse.net4j.util.properties.Property;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public class DefaultPropertySource<RECEIVER> implements IPropertySource
+{
+ private List<IPropertyDescriptor> descriptors = new ArrayList<IPropertyDescriptor>();
+
+ private RECEIVER receiver;
+
+ public DefaultPropertySource(RECEIVER receiver)
+ {
+ this.receiver = receiver;
+ }
+
+ public DefaultPropertySource(RECEIVER object, PropertiesProvider<RECEIVER> provider)
+ {
+ this(object);
+ addDescriptors(provider);
+ }
+
+ public RECEIVER getReceiver()
+ {
+ return receiver;
+ }
+
+ public PropertyDescriptor addDescriptor(String category, Object id, String displayName, String description)
+ {
+ PropertyDescriptor descriptor = new PropertyDescriptor(id, displayName);
+ descriptor.setCategory(category);
+ descriptor.setDescription(description);
+
+ descriptors.add(descriptor);
+ return descriptor;
+ }
+
+ public void addDescriptors(PropertiesProvider<RECEIVER> provider)
+ {
+ for (Property<RECEIVER> property : provider.getProperties())
+ {
+ if (property.getLabel() != null)
+ {
+ descriptors.add(new DelegatingPropertyDescriptor<RECEIVER>(property));
+ }
+ }
+ }
+
+ public IPropertyDescriptor[] getPropertyDescriptors()
+ {
+ return descriptors.toArray(new IPropertyDescriptor[descriptors.size()]);
+ }
+
+ public IPropertyDescriptor getPropertyDescriptor(Object id)
+ {
+ IPropertyDescriptor[] propertyDescriptors = getPropertyDescriptors();
+ for (int i = 0; i < propertyDescriptors.length; i++)
+ {
+ IPropertyDescriptor propertyDescriptor = propertyDescriptors[i];
+ if (propertyDescriptor.getId().equals(id))
+ {
+ return propertyDescriptor;
+ }
+ }
+
+ return null;
+ }
+
+ public Property<RECEIVER> getProperty(Object id)
+ {
+ IPropertyDescriptor propertyDescriptor = getPropertyDescriptor(id);
+ if (propertyDescriptor instanceof DelegatingPropertyDescriptor)
+ {
+ @SuppressWarnings("unchecked")
+ DelegatingPropertyDescriptor<RECEIVER> delegating = (DelegatingPropertyDescriptor<RECEIVER>)propertyDescriptor;
+ return delegating.getProperty();
+ }
+
+ return null;
+ }
+
+ public Object getPropertyValue(Object id)
+ {
+ Property<RECEIVER> property = getProperty(id);
+ if (property != null)
+ {
+ return property.getValue(receiver);
+ }
+
+ return null;
+ }
+
+ public boolean isPropertySet(Object id)
+ {
+ return true;
+ }
+
+ public void resetPropertyValue(Object id)
+ {
+ }
+
+ public void setPropertyValue(Object id, Object value)
+ {
+ }
+
+ public Object getEditableValue()
+ {
+ return null;
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class DelegatingPropertyDescriptor<RECEIVER> implements IPropertyDescriptor
+ {
+ private final Property<RECEIVER> property;
+
+ private ILabelProvider labelProvider;
+
+ public DelegatingPropertyDescriptor(Property<RECEIVER> property)
+ {
+ this.property = property;
+ }
+
+ public Property<RECEIVER> getProperty()
+ {
+ return property;
+ }
+
+ public String getCategory()
+ {
+ return property.getCategory();
+ }
+
+ public String getId()
+ {
+ return property.getName();
+ }
+
+ public String getDisplayName()
+ {
+ return property.getLabel();
+ }
+
+ public String getDescription()
+ {
+ return property.getDescription();
+ }
+
+ public boolean isCompatibleWith(IPropertyDescriptor anotherProperty)
+ {
+ return anotherProperty.getCategory().equals(getCategory()) && anotherProperty.getId().equals(getId());
+ }
+
+ public ILabelProvider getLabelProvider()
+ {
+ if (labelProvider != null)
+ {
+ return labelProvider;
+ }
+
+ return new LabelProvider();
+ }
+
+ public void setLabelProvider(ILabelProvider labelProvider)
+ {
+ this.labelProvider = labelProvider;
+ }
+
+ public Object getHelpContextIds()
+ {
+ return null;
+ }
+
+ public String[] getFilterFlags()
+ {
+ return null;
+ }
+
+ public CellEditor createPropertyEditor(Composite parent)
+ {
+ return null;
+ }
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
index 955a58e1a9..1b9d218b9e 100644
--- a/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.net4j.util/META-INF/MANIFEST.MF
@@ -9,7 +9,8 @@ Bundle-ActivationPolicy: lazy
Bundle-Activator: org.eclipse.net4j.internal.util.bundle.OM$Activator
Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ClassPath: .
-Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional
+Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.4.0,4.0.0)";resolution:=optional,
+ org.eclipse.core.expressions;bundle-version="[3.4.0,4.0.0)";resolution:=optional
Import-Package: org.eclipse.osgi.service.debug;version="[1.0.0,2.0.0)";resolution:=optional,
org.osgi.framework;version="[1.3.0,2.0.0)";resolution:=optional,
org.osgi.service.log;version="[1.3.0,2.0.0)";resolution:=optional,
@@ -36,6 +37,7 @@ Export-Package: org.eclipse.net4j.internal.util.bundle;version="3.2.0";x-friends
org.eclipse.net4j.util.om.pref;version="3.2.0",
org.eclipse.net4j.util.om.trace;version="3.2.0",
org.eclipse.net4j.util.options;version="3.2.0",
+ org.eclipse.net4j.util.properties;version="3.2.0",
org.eclipse.net4j.util.ref;version="3.2.0",
org.eclipse.net4j.util.registry;version="3.2.0",
org.eclipse.net4j.util.security;version="3.2.0",
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/DefaultPropertyTester.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/DefaultPropertyTester.java
new file mode 100644
index 0000000000..a169946c02
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/DefaultPropertyTester.java
@@ -0,0 +1,71 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.properties;
+
+import org.eclipse.net4j.util.CheckUtil;
+
+import org.eclipse.core.expressions.PropertyTester;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Tests properties of receiver objects against expected values
+ *
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public class DefaultPropertyTester<RECEIVER> extends PropertyTester implements PropertiesProvider<RECEIVER>
+{
+ private List<Property<RECEIVER>> properties = new ArrayList<Property<RECEIVER>>();
+
+ public DefaultPropertyTester()
+ {
+ }
+
+ public final void add(Property<RECEIVER> property)
+ {
+ CheckUtil.checkArg(property, "property");
+ CheckUtil.checkArg(property.getName(), "property.getName()");
+ properties.add(property);
+ }
+
+ public final List<Property<RECEIVER>> getProperties()
+ {
+ return properties;
+ }
+
+ public final Property<RECEIVER> getProperty(String name)
+ {
+ for (Property<RECEIVER> property : properties)
+ {
+ if (property.getName().equals(name))
+ {
+ return property;
+ }
+ }
+
+ return null;
+ }
+
+ public boolean test(Object receiver, String propertyName, Object[] args, Object expectedValue)
+ {
+ Property<RECEIVER> property = getProperty(propertyName);
+ if (property == null)
+ {
+ return false;
+ }
+
+ @SuppressWarnings("unchecked")
+ RECEIVER typed = (RECEIVER)receiver;
+ return property.testValue(typed, args, expectedValue);
+ }
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/PropertiesProvider.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/PropertiesProvider.java
new file mode 100644
index 0000000000..33f7030fe5
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/PropertiesProvider.java
@@ -0,0 +1,24 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.properties;
+
+import java.util.List;
+
+/**
+ * Provides a list of {@link Property property descriptors}.
+ *
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public interface PropertiesProvider<RECEIVER>
+{
+ public List<Property<RECEIVER>> getProperties();
+}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Property.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Property.java
new file mode 100644
index 0000000000..2c8c660dfe
--- /dev/null
+++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Property.java
@@ -0,0 +1,96 @@
+/**
+ * Copyright (c) 2004 - 2011 Eike Stepper (Berlin, Germany) and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Eike Stepper - initial API and implementation
+ */
+package org.eclipse.net4j.util.properties;
+
+import org.eclipse.net4j.util.ObjectUtil;
+
+/**
+ * Describes a property of a receiver object and extracts its value.
+ *
+ * @author Eike Stepper
+ * @since 3.2
+ */
+public abstract class Property<RECEIVER>
+{
+ private final String name;
+
+ private final String label;
+
+ private final String description;
+
+ private final String category;
+
+ public Property(String name, String label, String description, String category)
+ {
+ this.name = name;
+ this.label = label;
+ this.description = description;
+ this.category = category;
+ }
+
+ public Property(String name, String label, String description)
+ {
+ this(name, label, description, null);
+ }
+
+ public Property(String name)
+ {
+ this(name, null, null);
+ }
+
+ public final String getName()
+ {
+ return name;
+ }
+
+ public final String getLabel()
+ {
+ return label;
+ }
+
+ public final String getDescription()
+ {
+ return description;
+ }
+
+ public final String getCategory()
+ {
+ return category;
+ }
+
+ public boolean testValue(RECEIVER receiver, Object[] args, Object expectedValue)
+ {
+ Object value = getValue(receiver);
+ return ObjectUtil.equals(value, expectedValue);
+ }
+
+ public final Object getValue(RECEIVER receiver)
+ {
+ Object value = eval(receiver);
+ if (value == null || value.getClass().isPrimitive())
+ {
+ return value;
+ }
+
+ if (value.getClass().isPrimitive())
+ {
+ return value;
+ }
+
+ return value.toString();
+ }
+
+ /**
+ * Returns the receiver's value for this property, either a {@link String} or a boxed primitive type. Return values of
+ * all other types are converted with {@link #toString()} in {@link #eval(Object)}.
+ */
+ protected abstract Object eval(RECEIVER receiver);
+}

Back to the top