Skip to main content

This CGIT instance is deprecated, and repositories have been moved to Gitlab or Github. See the repository descriptions for specific locations.

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2022-07-06 06:08:41 +0000
committerEike Stepper2022-07-06 06:08:41 +0000
commite66175a8e3a10c20d9887ebb8a9cd2b0c206c2fb (patch)
tree7695c9ecc8559f525c9abb1dddc0286192db4131 /plugins/org.eclipse.emf.cdo.ui/src/org
parent00b2230eed439981de5b982124ac1115f19f858a (diff)
downloadcdo-e66175a8e3a10c20d9887ebb8a9cd2b0c206c2fb.tar.gz
cdo-e66175a8e3a10c20d9887ebb8a9cd2b0c206c2fb.tar.xz
cdo-e66175a8e3a10c20d9887ebb8a9cd2b0c206c2fb.zip
580343 - Support customizeable structure providers for Net4j Introspector view
https://bugs.eclipse.org/bugs/show_bug.cgi?id=580343
Diffstat (limited to 'plugins/org.eclipse.emf.cdo.ui/src/org')
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOIntrospectionProvider.java84
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/EMFIntrospectionProvider.java98
2 files changed, 182 insertions, 0 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOIntrospectionProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOIntrospectionProvider.java
new file mode 100644
index 0000000000..588c068d5a
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/CDOIntrospectionProvider.java
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2022 Eike Stepper (Loehne, 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.CDOObject;
+import org.eclipse.emf.cdo.CDOState;
+import org.eclipse.emf.cdo.common.id.CDOID;
+import org.eclipse.emf.cdo.common.lock.CDOLockState;
+import org.eclipse.emf.cdo.common.revision.CDORevision;
+import org.eclipse.emf.cdo.common.security.CDOPermission;
+import org.eclipse.emf.cdo.util.CDOUtil;
+import org.eclipse.emf.cdo.view.CDOView;
+
+import org.eclipse.emf.ecore.EObject;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOIntrospectionProvider extends EMFIntrospectionProvider
+{
+ protected static final int PRIORITY = EMFIntrospectionProvider.PRIORITY - 20;
+
+ protected static final int CATEGORY = EMFIntrospectionProvider.CATEGORY + 10;
+
+ private final Color foreground = Display.getDefault().getSystemColor(SWT.COLOR_DARK_CYAN);
+
+ public CDOIntrospectionProvider()
+ {
+ super(CDOObject.class.getName(), "CDOObject");
+ }
+
+ @Override
+ public int getPriority()
+ {
+ return PRIORITY;
+ }
+
+ @Override
+ public boolean canHandle(Object object)
+ {
+ return getCDOObject(object) != null;
+ }
+
+ @Override
+ protected void fillRows(Object parent, List<Row> rows) throws Exception
+ {
+ super.fillRows(parent, rows);
+
+ CDOObject cdoObject = getCDOObject(parent);
+ if (cdoObject != null)
+ {
+ addRow(rows, "cdoID", cdoObject.cdoID(), CDOID.class.getName(), CATEGORY, foreground);
+ addRow(rows, "cdoLockState", cdoObject.cdoLockState(), CDOLockState.class.getName(), CATEGORY, foreground);
+ addRow(rows, "cdoPermission", cdoObject.cdoPermission(), CDOPermission.class.getName(), CATEGORY, foreground);
+ addRow(rows, "cdoRevision", cdoObject.cdoRevision(), CDORevision.class.getName(), CATEGORY, foreground);
+ addRow(rows, "cdoState", cdoObject.cdoState(), CDOState.class.getName(), CATEGORY, foreground);
+ addRow(rows, "cdoView", cdoObject.cdoView(), CDOView.class.getName(), CATEGORY, foreground);
+ }
+ }
+
+ private static CDOObject getCDOObject(Object object)
+ {
+ if (object instanceof EObject)
+ {
+ return CDOUtil.getCDOObject((EObject)object);
+ }
+
+ return null;
+ }
+}
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/EMFIntrospectionProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/EMFIntrospectionProvider.java
new file mode 100644
index 0000000000..d1f01e30bc
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/EMFIntrospectionProvider.java
@@ -0,0 +1,98 @@
+/*
+ * Copyright (c) 2022 Eike Stepper (Loehne, 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.net4j.util.ui.views.RowIntrospectionProvider;
+
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.emf.ecore.util.EcoreUtil;
+
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+import java.util.List;
+
+/**
+ * @author Eike Stepper
+ */
+public class EMFIntrospectionProvider extends RowIntrospectionProvider
+{
+ protected static final int PRIORITY = DEFAULT_PRIORITY - 20;
+
+ protected static final int CATEGORY = DEFAULT_CATEGORY - 20;
+
+ private final Color foreground = Display.getDefault().getSystemColor(SWT.COLOR_DARK_BLUE);
+
+ public EMFIntrospectionProvider()
+ {
+ super(EObject.class.getName(), "EObject");
+ }
+
+ protected EMFIntrospectionProvider(String id, String label)
+ {
+ super(id, label);
+ }
+
+ @Override
+ public int getPriority()
+ {
+ return PRIORITY;
+ }
+
+ @Override
+ public boolean canHandle(Object object)
+ {
+ return object instanceof EObject;
+ }
+
+ @Override
+ protected void fillRows(Object parent, List<Row> rows) throws Exception
+ {
+ if (parent instanceof EObject)
+ {
+ EObject eObject = (EObject)parent;
+
+ addRow(rows, "eContainer", eObject.eContainer(), EObject.class.getName(), CATEGORY, foreground);
+ addRow(rows, "uri", EcoreUtil.getURI(eObject), URI.class.getName(), CATEGORY, foreground);
+ addRow(rows, "resource", eObject.eResource(), Resource.class.getName(), CATEGORY, foreground);
+ addRow(rows, "eClass", eObject.eClass(), EClass.class.getName(), CATEGORY, foreground);
+ addRow(rows, "eIsProxy", eObject.eIsProxy(), boolean.class.getName(), CATEGORY, foreground);
+ addRow(rows, "eDeliver", eObject.eDeliver(), boolean.class.getName(), CATEGORY, foreground);
+
+ for (EStructuralFeature feature : eObject.eClass().getEAllStructuralFeatures())
+ {
+ Object value = eObject.eGet(feature);
+ rows.add(new Row(feature.getName(), value, feature.getEType().getName(), getConcreteType(value)));
+ }
+ }
+ }
+
+ protected static void addRow(List<Row> rows, String name, Object value, String declaredType, int category, Color foreground)
+ {
+ rows.add(new Row(name, value, declaredType, getConcreteType(value), category, foreground, null));
+ }
+
+ private static String getConcreteType(Object value)
+ {
+ if (value instanceof EObject)
+ {
+ EObject eObject = (EObject)value;
+ return eObject.eClass().getName();
+ }
+
+ return value == null ? "" : value.getClass().getName(); //$NON-NLS-1$
+ }
+}

Back to the top