Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-02-09 08:59:43 +0000
committerEike Stepper2015-02-18 14:40:52 +0000
commitbe4a714a1d9b2bdad7d45eaf4fb1714130e0f748 (patch)
treed20ee6a33c831449790b5a1f7e996d32034968da /plugins/org.eclipse.emf.cdo.ui
parent8f64246fab05a52e74011c1d4d1aa6cc58189ee2 (diff)
downloadcdo-be4a714a1d9b2bdad7d45eaf4fb1714130e0f748.tar.gz
cdo-be4a714a1d9b2bdad7d45eaf4fb1714130e0f748.tar.xz
cdo-be4a714a1d9b2bdad7d45eaf4fb1714130e0f748.zip
[458349] Consolidate UI
Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=458349
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOPropertyAdapterFactory.java92
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java21
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java19
3 files changed, 121 insertions, 11 deletions
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 804ec76461..ade6f3e084 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
@@ -10,6 +10,8 @@
*/
package org.eclipse.emf.cdo.internal.ui;
+import org.eclipse.emf.cdo.edit.CDOItemProviderAdapter.CDOPropertyDescriptor;
+import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.session.CDOSession;
import org.eclipse.emf.cdo.view.CDOView;
@@ -22,9 +24,19 @@ import org.eclipse.net4j.util.ui.DefaultActionFilter;
import org.eclipse.net4j.util.ui.DefaultPropertySource;
import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
+import org.eclipse.emf.edit.provider.IItemPropertyDescriptor;
+import org.eclipse.emf.edit.provider.IItemPropertySource;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
import org.eclipse.ui.IActionFilter;
import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* @author Eike Stepper
@@ -38,6 +50,8 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory
private static final IActionFilter OBJECT_ACTION_FILTER = new DefaultActionFilter<EObject>(ObjectProperties.INSTANCE);
+ private static final String CATEGORY_EMF = "EMF"; //$NON-NLS-1$
+
public CDOPropertyAdapterFactory()
{
}
@@ -57,7 +71,83 @@ public class CDOPropertyAdapterFactory extends AbstractPropertyAdapterFactory
if (object instanceof EObject)
{
- return new DefaultPropertySource<EObject>((EObject)object, ObjectProperties.INSTANCE);
+ EObject eObject = (EObject)object;
+
+ final Map<String, Object> propertyValues = new HashMap<String, Object>();
+ DefaultPropertySource<EObject> result = new DefaultPropertySource<EObject>(eObject, ObjectProperties.INSTANCE)
+ {
+ @Override
+ public Object getPropertyValue(Object id)
+ {
+ Object value = propertyValues.get(id);
+ if (value != null)
+ {
+ return value;
+ }
+
+ return super.getPropertyValue(id);
+ }
+ };
+
+ ComposedAdapterFactory adapterFactory = null;
+ AdapterFactoryLabelProvider labelProvider = null;
+
+ try
+ {
+ adapterFactory = CDOEditor.createAdapterFactory(false);
+
+ IItemPropertySource propertySource = (IItemPropertySource)adapterFactory.adapt(eObject,
+ IItemPropertySource.class);
+ if (propertySource != null)
+ {
+ List<IItemPropertyDescriptor> propertyDescriptors = propertySource.getPropertyDescriptors(eObject);
+ if (propertyDescriptors != null)
+ {
+ labelProvider = new AdapterFactoryLabelProvider(adapterFactory);
+
+ for (IItemPropertyDescriptor propertyDescriptor : propertyDescriptors)
+ {
+ if (propertyDescriptor instanceof CDOPropertyDescriptor)
+ {
+ continue;
+ }
+
+ String id = "___EMF___" + propertyDescriptor.getId(eObject);
+ String displayName = propertyDescriptor.getDisplayName(eObject);
+ String description = propertyDescriptor.getDescription(eObject);
+
+ PropertyDescriptor descriptor = result.addDescriptor(CATEGORY_EMF, id, displayName, description);
+
+ Object value = propertyDescriptor.getPropertyValue(eObject);
+ propertyValues.put(id, value);
+
+ final String text = labelProvider.getText(value);
+ descriptor.setLabelProvider(new LabelProvider()
+ {
+ @Override
+ public String getText(Object element)
+ {
+ return text;
+ }
+ });
+ }
+ }
+ }
+ }
+ finally
+ {
+ if (labelProvider != null)
+ {
+ labelProvider.dispose();
+ }
+
+ if (adapterFactory != null)
+ {
+ adapterFactory.dispose();
+ }
+ }
+
+ return result;
}
return null;
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
index c0dd97af26..ff93a5c1dd 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java
@@ -762,10 +762,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
*/
protected void initializeEditingDomain()
{
- ComposedAdapterFactory.Descriptor.Registry registry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
- adapterFactory = new ComposedAdapterFactory(registry);
- adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
- adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+ adapterFactory = createAdapterFactory(true);
}
/**
@@ -2518,6 +2515,22 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
/**
* @ADDED
*/
+ public static ComposedAdapterFactory createAdapterFactory(boolean reflective)
+ {
+ ComposedAdapterFactory.Descriptor.Registry registry = EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry();
+ ComposedAdapterFactory adapterFactory = new ComposedAdapterFactory(registry);
+ adapterFactory.addAdapterFactory(new ResourceItemProviderAdapterFactory());
+ if (reflective)
+ {
+ adapterFactory.addAdapterFactory(new ReflectiveItemProviderAdapterFactory());
+ }
+
+ return adapterFactory;
+ }
+
+ /**
+ * @ADDED
+ */
public static String getLabelText(AdapterFactory adapterFactory, Object object)
{
try
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
index 0ab7145821..1d7fb3273e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOWatchListView.java
@@ -15,6 +15,7 @@ import org.eclipse.emf.cdo.CDOObject;
import org.eclipse.emf.cdo.internal.ui.actions.RemoveAllContainerItemAction;
import org.eclipse.emf.cdo.internal.ui.actions.RemoveContainerItemAction;
import org.eclipse.emf.cdo.internal.ui.dnd.CDOObjectDropAdapter;
+import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
import org.eclipse.emf.cdo.internal.ui.messages.Messages;
import org.eclipse.emf.cdo.transaction.CDOCommitContext;
import org.eclipse.emf.cdo.transaction.CDODefaultTransactionHandler2;
@@ -40,7 +41,6 @@ import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.impl.AdapterImpl;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
-import org.eclipse.emf.edit.EMFEditPlugin;
import org.eclipse.emf.edit.provider.ComposedAdapterFactory;
import org.eclipse.emf.edit.provider.IItemLabelProvider;
import org.eclipse.emf.edit.ui.provider.AdapterFactoryContentProvider;
@@ -101,13 +101,13 @@ public class CDOWatchListView extends ViewPart implements ISelectionProvider
public static final String ID = "org.eclipse.emf.cdo.ui.CDOWatchListView"; //$NON-NLS-1$
- private WatchedObjectsDataRegistry dataRegistry = new WatchedObjectsDataRegistry();
+ private final ComposedAdapterFactory adapterFactory;
- private TableViewer viewer;
+ private final CDOObjectContainer container = new CDOObjectContainer();
- private CDOObjectContainer container = new CDOObjectContainer();
+ private final WatchedObjectsDataRegistry dataRegistry = new WatchedObjectsDataRegistry();
- private ComposedAdapterFactory adapterFactory;
+ private TableViewer viewer;
private IPropertySheetPage propertySheetPage;
@@ -121,10 +121,17 @@ public class CDOWatchListView extends ViewPart implements ISelectionProvider
public CDOWatchListView()
{
- adapterFactory = new ComposedAdapterFactory(EMFEditPlugin.getComposedAdapterFactoryDescriptorRegistry());
+ adapterFactory = CDOEditor.createAdapterFactory(true);
container.addListener(getDataRegistry());
}
+ @Override
+ public void dispose()
+ {
+ adapterFactory.dispose();
+ super.dispose();
+ }
+
public WatchedObjectsDataRegistry getDataRegistry()
{
return dataRegistry;

Back to the top