diff options
author | Eike Stepper | 2011-08-23 16:50:06 +0000 |
---|---|---|
committer | Eike Stepper | 2011-08-23 16:50:06 +0000 |
commit | 987279667d35b82f90a1a14400a25fac412b3fb1 (patch) | |
tree | c074eb7b2b97326998b1b5f2bca546c7e730deed | |
parent | d7db03e03e68812d6502d914610cf1ab84f3fa85 (diff) | |
download | cdo-987279667d35b82f90a1a14400a25fac412b3fb1.tar.gz cdo-987279667d35b82f90a1a14400a25fac412b3fb1.tar.xz cdo-987279667d35b82f90a1a14400a25fac412b3fb1.zip |
[355539] Contribute PropertyTester and IPropertySourceProvider to CDOWorkspace
https://bugs.eclipse.org/bugs/show_bug.cgi?id=355539
5 files changed, 180 insertions, 3 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui.workspace/META-INF/MANIFEST.MF b/plugins/org.eclipse.emf.cdo.ui.workspace/META-INF/MANIFEST.MF index 0d5b615393..8509181e4e 100644 --- a/plugins/org.eclipse.emf.cdo.ui.workspace/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.emf.cdo.ui.workspace/META-INF/MANIFEST.MF @@ -1,7 +1,7 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-SymbolicName: org.eclipse.emf.cdo.ui.workspace;singleton:=true -Bundle-Version: 4.0.0.qualifier +Bundle-Version: 4.0.100.qualifier Bundle-Name: %pluginName Bundle-Vendor: %providerName Bundle-Localization: plugin @@ -10,8 +10,9 @@ Bundle-Activator: org.eclipse.emf.cdo.ui.internal.workspace.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.core.resources;bundle-version="[3.4.0,4.0.0)", org.eclipse.emf.cdo.workspace.efs;bundle-version="[4.0.0,5.0.0)", org.eclipse.emf.cdo.ui.location;bundle-version="[4.0.0,5.0.0)" -Export-Package: org.eclipse.emf.cdo.ui.internal.workspace;version="4.0.0";x-internal:=true, - org.eclipse.emf.cdo.ui.internal.workspace.bundle;version="4.0.0";x-internal:=true +Export-Package: org.eclipse.emf.cdo.ui.internal.workspace;version="4.0.100";x-internal:=true, + org.eclipse.emf.cdo.ui.internal.workspace.bundle;version="4.0.100";x-internal:=true diff --git a/plugins/org.eclipse.emf.cdo.ui.workspace/plugin.xml b/plugins/org.eclipse.emf.cdo.ui.workspace/plugin.xml index 87e45680f5..0e62cf33e1 100644 --- a/plugins/org.eclipse.emf.cdo.ui.workspace/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.ui.workspace/plugin.xml @@ -33,4 +33,13 @@ </objectContribution> </extension> + <extension + point="org.eclipse.core.runtime.adapters"> + <factory + adaptableType="org.eclipse.emf.cdo.workspace.CDOWorkspace" + class="org.eclipse.emf.cdo.ui.internal.workspace.WorkspacePropertyAdapterFactory"> + <adapter type="org.eclipse.ui.views.properties.IPropertySourceProvider"/> + </factory> + </extension> + </plugin> 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 new file mode 100644 index 0000000000..44734bf49b --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.ui.workspace/src/org/eclipse/emf/cdo/ui/internal/workspace/WorkspacePropertyAdapterFactory.java @@ -0,0 +1,40 @@ +/** + * 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.ui.internal.workspace; + +import org.eclipse.emf.cdo.internal.workspace.WorkspacePropertyTester; +import org.eclipse.emf.cdo.workspace.CDOWorkspace; + +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 WorkspacePropertyAdapterFactory extends AbstractPropertyAdapterFactory +{ + public WorkspacePropertyAdapterFactory() + { + } + + @Override + protected IPropertySource createPropertySource(Object object) + { + if (object instanceof CDOWorkspace) + { + return new DefaultPropertySource<CDOWorkspace>((CDOWorkspace)object, new WorkspacePropertyTester()); + } + + return null; + } +} diff --git a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml index f0abd93936..745de35a63 100644 --- a/plugins/org.eclipse.emf.cdo.workspace/plugin.xml +++ b/plugins/org.eclipse.emf.cdo.workspace/plugin.xml @@ -21,4 +21,14 @@ type="folder"/> </extension> + <extension + point="org.eclipse.core.expressions.propertyTesters"> + <propertyTester + id="org.eclipse.emf.cdo.workspace.WorkspaceTester" + 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"/> + </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/WorkspacePropertyTester.java new file mode 100644 index 0000000000..7848073b21 --- /dev/null +++ b/plugins/org.eclipse.emf.cdo.workspace/src/org/eclipse/emf/cdo/internal/workspace/WorkspacePropertyTester.java @@ -0,0 +1,117 @@ +/** + * 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.workspace; + +import org.eclipse.emf.cdo.common.util.CDOCommonUtil; +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.Property; + +/** + * @author Eike Stepper + */ +public class WorkspacePropertyTester extends DefaultPropertyTester<CDOWorkspace> +{ + public WorkspacePropertyTester() + { + add(new Property<CDOWorkspace>("open", //$NON-NLS-1$ + "Open", "Whether this workspace is open or not.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return !workspace.isClosed(); + } + }); + + add(new Property<CDOWorkspace>("branchPath", //$NON-NLS-1$ + "Branch", "The remote branch of this workspace.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return workspace.getBranchPath(); + } + }); + + add(new Property<CDOWorkspace>("timeStamp", //$NON-NLS-1$ + "Time Stamp", "The time stamp of this workspace.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return CDOCommonUtil.formatTimeStamp(workspace.getTimeStamp()); + } + }); + + add(new Property<CDOWorkspace>("fixed", //$NON-NLS-1$ + "Fixed", "Whether this workspace is fixed to a specific remote time stamp or not.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return workspace.isFixed(); + } + }); + + add(new Property<CDOWorkspace>("dirty", //$NON-NLS-1$ + "Dirty", "Whether this workspace is locally dirty or not.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return workspace.isDirty(); + } + }); + + add(new Property<CDOWorkspace>("idGenerationLocation", //$NON-NLS-1$ + "ID Generation Location", "One of STORE, CLIENT.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return ((InternalCDOWorkspace)workspace).getIDGenerationLocation(); + } + }); + + add(new Property<CDOWorkspace>("base", //$NON-NLS-1$ + "Base", "The base of this workspace.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return ((InternalCDOWorkspace)workspace).getBase(); + } + }); + + add(new Property<CDOWorkspace>("local", //$NON-NLS-1$ + "Local", "The local repository of this workspace.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return ((InternalCDOWorkspace)workspace).getLocalRepository(); + } + }); + + add(new Property<CDOWorkspace>("remote", //$NON-NLS-1$ + "Remote", "The remote repository of this workspace.") + { + @Override + protected Object eval(CDOWorkspace workspace) + { + return ((InternalCDOWorkspace)workspace).getRemoteSessionConfigurationFactory(); + } + }); + } +} |