diff options
author | Eike Stepper | 2011-08-24 05:18:49 +0000 |
---|---|---|
committer | Eike Stepper | 2011-08-24 05:18:49 +0000 |
commit | 8e776e7fe308d7c61de2a58782902b4b6ecb340f (patch) | |
tree | 00a2148718d475381525363cdf965560ef24fb19 | |
parent | 987279667d35b82f90a1a14400a25fac412b3fb1 (diff) | |
download | cdo-8e776e7fe308d7c61de2a58782902b4b6ecb340f.tar.gz cdo-8e776e7fe308d7c61de2a58782902b4b6ecb340f.tar.xz cdo-8e776e7fe308d7c61de2a58782902b4b6ecb340f.zip |
make properties static
13 files changed, 402 insertions, 282 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.workspace/src/org/eclipse/emf/cdo/ui/internal/workspace/WorkspacePropertyAdapterFactory.java b/plugins/org.eclipse.emf.cdo.ui.workspace/src/org/eclipse/emf/cdo/ui/internal/workspace/WorkspacePropertyAdapterFactory.java index 44734bf49b..60f9fbffc3 100644 --- a/plugins/org.eclipse.emf.cdo.ui.workspace/src/org/eclipse/emf/cdo/ui/internal/workspace/WorkspacePropertyAdapterFactory.java +++ b/plugins/org.eclipse.emf.cdo.ui.workspace/src/org/eclipse/emf/cdo/ui/internal/workspace/WorkspacePropertyAdapterFactory.java @@ -10,7 +10,7 @@ */ package org.eclipse.emf.cdo.ui.internal.workspace; -import org.eclipse.emf.cdo.internal.workspace.WorkspacePropertyTester; +import org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties; import org.eclipse.emf.cdo.workspace.CDOWorkspace; import org.eclipse.net4j.util.ui.AbstractPropertyAdapterFactory; @@ -32,7 +32,7 @@ public class WorkspacePropertyAdapterFactory extends AbstractPropertyAdapterFact { if (object instanceof CDOWorkspace) { - return new DefaultPropertySource<CDOWorkspace>((CDOWorkspace)object, new WorkspacePropertyTester()); + return new DefaultPropertySource<CDOWorkspace>((CDOWorkspace)object, WorkspaceProperties.INSTANCE); } return null; 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 index 4fb823fe11..1fed090660 100644 --- 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 @@ -13,8 +13,8 @@ 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.emf.internal.cdo.session.SessionProperties; +import org.eclipse.emf.internal.cdo.view.ViewProperties; import org.eclipse.net4j.util.ui.AbstractPropertyAdapterFactory; import org.eclipse.net4j.util.ui.DefaultPropertySource; @@ -35,12 +35,12 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory { if (object instanceof CDOSession) { - return new DefaultPropertySource<CDOSession>((CDOSession)object, new SessionPropertyTester()); + return new DefaultPropertySource<CDOSession>((CDOSession)object, SessionProperties.INSTANCE); } if (object instanceof CDOView) { - return new DefaultPropertySource<CDOView>((CDOView)object, new ViewPropertyTester()); + return new DefaultPropertySource<CDOView>((CDOView)object, ViewProperties.INSTANCE); } return null; diff --git a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml index 745de35a63..ddd24b9567 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml @@ -28,7 +28,7 @@ type="org.eclipse.emf.cdo.workspace.CDOWorkspace" namespace="org.eclipse.emf.cdo.workspace" properties="open,branchPath,timeStamp,fixed,dirty" - class="org.eclipse.emf.cdo.internal.workspace.WorkspacePropertyTester"/> + class="org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties$Tester"/> </extension> </plugin> diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspacePropertyTester.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java index 7848073b21..80eabd33a8 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspacePropertyTester.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspaceProperties.java @@ -15,14 +15,18 @@ import org.eclipse.emf.cdo.spi.workspace.InternalCDOWorkspace; import org.eclipse.emf.cdo.workspace.CDOWorkspace; import org.eclipse.net4j.util.properties.DefaultPropertyTester; +import org.eclipse.net4j.util.properties.IProperties; +import org.eclipse.net4j.util.properties.Properties; import org.eclipse.net4j.util.properties.Property; /** * @author Eike Stepper */ -public class WorkspacePropertyTester extends DefaultPropertyTester<CDOWorkspace> +public class WorkspaceProperties extends Properties<CDOWorkspace> { - public WorkspacePropertyTester() + public static final IProperties<CDOWorkspace> INSTANCE = new WorkspaceProperties(); + + private WorkspaceProperties() { add(new Property<CDOWorkspace>("open", //$NON-NLS-1$ "Open", "Whether this workspace is open or not.") @@ -114,4 +118,15 @@ public class WorkspacePropertyTester extends DefaultPropertyTester<CDOWorkspace> } }); } + + /** + * @author Eike Stepper + */ + public static final class Tester extends DefaultPropertyTester<CDOWorkspace> + { + public Tester() + { + super(INSTANCE); + } + } } diff --git a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java index b0bbe66f93..83e87cbe6f 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/workspace/CDOWorkspaceUtil.java @@ -15,12 +15,14 @@ import org.eclipse.emf.cdo.common.branch.CDOBranchPoint; import org.eclipse.emf.cdo.common.id.CDOID; import org.eclipse.emf.cdo.common.revision.CDORevision; import org.eclipse.emf.cdo.internal.workspace.FolderCDOWorkspaceBase; +import org.eclipse.emf.cdo.internal.workspace.WorkspaceProperties; import org.eclipse.emf.cdo.server.IStore; import org.eclipse.emf.cdo.session.CDOSessionConfigurationFactory; import org.eclipse.emf.cdo.util.CDOUtil; import org.eclipse.emf.cdo.view.CDOView; import org.eclipse.net4j.util.event.IListener; +import org.eclipse.net4j.util.properties.IProperties; import org.eclipse.emf.ecore.EObject; @@ -34,6 +36,11 @@ import java.util.Set; */ public final class CDOWorkspaceUtil { + /** + * @since 4.1 + */ + public static final IProperties<CDOWorkspace> PROPERTIES = WorkspaceProperties.INSTANCE; + private CDOWorkspaceUtil() { } diff --git a/plugins/org.eclipse.emf.cdo/plugin.xml b/plugins/org.eclipse.emf.cdo/plugin.xml index eea8a20174..f2fa1e0a02 100644 --- a/plugins/org.eclipse.emf.cdo/plugin.xml +++ b/plugins/org.eclipse.emf.cdo/plugin.xml @@ -44,13 +44,13 @@ type="org.eclipse.emf.cdo.session.CDOSession" namespace="org.eclipse.emf.cdo.session" properties="open,sessionID,userID,passiveUpdateEnabled,passiveUpdateMode,supportingAudits,supportingBranches,repositoryName,repositoryUUID,repositoryType,repositoryState,repositoryCreationTime" - class="org.eclipse.emf.internal.cdo.session.SessionPropertyTester"/> + class="org.eclipse.emf.internal.cdo.session.SessionProperties$Tester"/> <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"/> + class="org.eclipse.emf.internal.cdo.view.ViewProperties$Tester"/> </extension> </plugin> 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/SessionProperties.java index 207ccbb14c..c237c38a31 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/SessionProperties.java @@ -1,242 +1,257 @@ -/** - * 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.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.emf.internal.cdo.messages.Messages; - -import org.eclipse.net4j.util.properties.DefaultPropertyTester; -import org.eclipse.net4j.util.properties.Property; - -/** - * @author Eike Stepper - */ -public class SessionPropertyTester extends DefaultPropertyTester<CDOSession> -{ - private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$ - - private static final String CATEGORY_REPOSITORY = "Repository"; //$NON-NLS-1$ - - public SessionPropertyTester() - { - add(new Property<CDOSession>("open", Messages.getString("SessionPropertyTester_34"),// - Messages.getString("SessionPropertyTester_35"), //$NON-NLS-1$ - CATEGORY_SESSION) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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) - { - @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; - } - }); - } -} +/**
+ * 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.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.emf.internal.cdo.messages.Messages;
+
+import org.eclipse.net4j.util.properties.DefaultPropertyTester;
+import org.eclipse.net4j.util.properties.IProperties;
+import org.eclipse.net4j.util.properties.Properties;
+import org.eclipse.net4j.util.properties.Property;
+
+/**
+ * @author Eike Stepper
+ */
+public class SessionProperties extends Properties<CDOSession>
+{
+ public static final IProperties<CDOSession> INSTANCE = new SessionProperties();
+
+ private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$
+
+ private static final String CATEGORY_REPOSITORY = "Repository"; //$NON-NLS-1$
+
+ private SessionProperties()
+ {
+ add(new Property<CDOSession>("open", Messages.getString("SessionPropertyTester_34"),//
+ Messages.getString("SessionPropertyTester_35"), //$NON-NLS-1$
+ CATEGORY_SESSION)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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)
+ {
+ @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;
+ }
+ });
+ }
+
+ /**
+ * @author Eike Stepper
+ */
+ public static final class Tester extends DefaultPropertyTester<CDOSession>
+ {
+ public Tester()
+ {
+ super(INSTANCE);
+ }
+ }
+}
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/ViewProperties.java index 0902c07c51..bce3e50d90 100644 --- 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/ViewProperties.java @@ -14,18 +14,22 @@ 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.IProperties; +import org.eclipse.net4j.util.properties.Properties; import org.eclipse.net4j.util.properties.Property; /** * @author Eike Stepper */ -public class ViewPropertyTester extends DefaultPropertyTester<CDOView> +public class ViewProperties extends Properties<CDOView> { + public static final IProperties<CDOView> INSTANCE = new ViewProperties(); + private static final String CATEGORY_VIEW = "View"; //$NON-NLS-1$ private static final String CATEGORY_SESSION = "Session"; //$NON-NLS-1$ - public ViewPropertyTester() + private ViewProperties() { add(new Property<CDOView>("open", //$NON-NLS-1$ "Open", "Whether this view is open or not.", CATEGORY_VIEW) @@ -136,4 +140,15 @@ public class ViewPropertyTester extends DefaultPropertyTester<CDOView> } }); } + + /** + * @author Eike Stepper + */ + public static final class Tester extends DefaultPropertyTester<CDOView> + { + public Tester() + { + super(INSTANCE); + } + } } 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 index 4eefdb6f0e..e10faf59ae 100644 --- 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 @@ -10,7 +10,7 @@ */ package org.eclipse.net4j.util.ui; -import org.eclipse.net4j.util.properties.PropertiesProvider; +import org.eclipse.net4j.util.properties.IPropertyProvider; import org.eclipse.net4j.util.properties.Property; import org.eclipse.jface.viewers.CellEditor; @@ -39,7 +39,7 @@ public class DefaultPropertySource<RECEIVER> implements IPropertySource this.receiver = receiver; } - public DefaultPropertySource(RECEIVER object, PropertiesProvider<RECEIVER> provider) + public DefaultPropertySource(RECEIVER object, IPropertyProvider<RECEIVER> provider) { this(object); addDescriptors(provider); @@ -60,7 +60,7 @@ public class DefaultPropertySource<RECEIVER> implements IPropertySource return descriptor; } - public void addDescriptors(PropertiesProvider<RECEIVER> provider) + public void addDescriptors(IPropertyProvider<RECEIVER> provider) { for (Property<RECEIVER> property : provider.getProperties()) { 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 index a169946c02..1473d062a0 100644 --- 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 @@ -10,50 +10,38 @@ */ 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 + * Tests properties of receiver objects against expected values. * * @author Eike Stepper * @since 3.2 */ -public class DefaultPropertyTester<RECEIVER> extends PropertyTester implements PropertiesProvider<RECEIVER> +public class DefaultPropertyTester<RECEIVER> extends PropertyTester implements IProperties<RECEIVER> { - private List<Property<RECEIVER>> properties = new ArrayList<Property<RECEIVER>>(); + private final IProperties<RECEIVER> properties; - public DefaultPropertyTester() + public DefaultPropertyTester(IProperties<RECEIVER> properties) { + this.properties = properties; } - public final void add(Property<RECEIVER> property) + public Property<RECEIVER> getProperty(String name) { - CheckUtil.checkArg(property, "property"); - CheckUtil.checkArg(property.getName(), "property.getName()"); - properties.add(property); + return properties.getProperty(name); } - public final List<Property<RECEIVER>> getProperties() + public List<Property<RECEIVER>> getProperties() { - return properties; + return properties.getProperties(); } - public final Property<RECEIVER> getProperty(String name) + public void add(Property<RECEIVER> property) { - for (Property<RECEIVER> property : properties) - { - if (property.getName().equals(name)) - { - return property; - } - } - - return null; + properties.add(property); } public boolean test(Object receiver, String propertyName, Object[] args, Object expectedValue) diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/IProperties.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/IProperties.java new file mode 100644 index 0000000000..9248b3a265 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/IProperties.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; + +/** + * Contains a list of {@link Property properties}. + * + * @author Eike Stepper + * @since 3.2 + */ +public interface IProperties<RECEIVER> extends IPropertyProvider<RECEIVER> +{ + public Property<RECEIVER> getProperty(String name); + + public void add(Property<RECEIVER> property); +} 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/IPropertyProvider.java index 33f7030fe5..fffef7f132 100644 --- 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/IPropertyProvider.java @@ -18,7 +18,7 @@ import java.util.List; * @author Eike Stepper
* @since 3.2
*/
-public interface PropertiesProvider<RECEIVER>
+public interface IPropertyProvider<RECEIVER>
{
public List<Property<RECEIVER>> getProperties();
}
diff --git a/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Properties.java b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Properties.java new file mode 100644 index 0000000000..10e80333f6 --- /dev/null +++ b/plugins/org.eclipse.net4j.util/src/org/eclipse/net4j/util/properties/Properties.java @@ -0,0 +1,56 @@ +/** + * 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 java.util.ArrayList; +import java.util.List; + +/** + * Contains a list of {@link Property properties}. + * + * @author Eike Stepper + * @since 3.2 + */ +public class Properties<RECEIVER> implements IProperties<RECEIVER> +{ + private List<Property<RECEIVER>> properties = new ArrayList<Property<RECEIVER>>(); + + public Properties() + { + } + + 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; + } +} |