Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2015-02-20 05:42:48 +0000
committerEike Stepper2015-02-20 09:16:24 +0000
commitce3df424d86c68f64716b07e9f646bf07df0550b (patch)
tree893c78896c4cc12bd295e467c34970115906309a /plugins/org.eclipse.emf.cdo.ui
parent9d7c5cd3d524e3164c4047f6e469cb7a33a43994 (diff)
downloadcdo-ce3df424d86c68f64716b07e9f646bf07df0550b.tar.gz
cdo-ce3df424d86c68f64716b07e9f646bf07df0550b.tar.xz
cdo-ce3df424d86c68f64716b07e9f646bf07df0550b.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/plugin.xml13
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelDecorator.java59
2 files changed, 61 insertions, 11 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/plugin.xml b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
index 659dbc0468..286d5357af 100644
--- a/plugins/org.eclipse.emf.cdo.ui/plugin.xml
+++ b/plugins/org.eclipse.emf.cdo.ui/plugin.xml
@@ -114,15 +114,22 @@
<extension
point="org.eclipse.ui.decorators">
<decorator
+ adaptable="true"
class="org.eclipse.emf.cdo.ui.CDOLabelDecorator"
+ icon="icons/full/obj16/CDOModelFile.gif"
id="org.eclipse.emf.cdo.ui.CDOLabelDecorator"
label="%_UI_CDOLabelDecorator_label"
lightweight="false"
state="true">
<enablement>
- <objectClass
- name="org.eclipse.emf.cdo.CDOObject">
- </objectClass>
+ <or>
+ <objectClass
+ name="org.eclipse.emf.cdo.CDOObject">
+ </objectClass>
+ <objectClass
+ name="org.eclipse.emf.cdo.CDOElement">
+ </objectClass>
+ </or>
</enablement>
<description>
%_UI_CDOLabelDecorator_description
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelDecorator.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelDecorator.java
index 87d67086d8..f0aa625afc 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelDecorator.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/ui/CDOLabelDecorator.java
@@ -11,10 +11,15 @@
*/
package org.eclipse.emf.cdo.ui;
+import org.eclipse.emf.cdo.CDOElement;
+import org.eclipse.emf.cdo.CDOElement.StateProvider;
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.revision.CDORevision;
import org.eclipse.emf.cdo.internal.ui.bundle.OM;
+import org.eclipse.net4j.util.AdapterUtil;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.event.IEvent;
@@ -41,7 +46,7 @@ public class CDOLabelDecorator implements ILabelDecorator
{
public static final String[] DECORATION_PROPOSALS = { "${element}", "${id}", "${state}", "${created}", "${revised}" }; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$
- public static final String DEFAULT_DECORATION = DECORATION_PROPOSALS[0] + " [" + DECORATION_PROPOSALS[2] + "]"; //$NON-NLS-1$ //$NON-NLS-2$
+ public static final String DEFAULT_DECORATION = DECORATION_PROPOSALS[0] + " " + DECORATION_PROPOSALS[2]; //$NON-NLS-1$
public static final String NO_DECORATION = DECORATION_PROPOSALS[0];
@@ -101,14 +106,27 @@ public class CDOLabelDecorator implements ILabelDecorator
{
try
{
- if (pattern != null && element instanceof InternalCDOObject)
+ if (pattern != null)
{
- InternalCDOView view = ((InternalCDOObject)element).cdoView();
- InternalCDOObject obj = FSMUtil.adapt(element, view);
- CDORevision rev = obj.cdoRevision();
- long created = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getTimeStamp();
- long revised = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getRevised();
- text = MessageFormat.format(pattern, text, obj.cdoID(), obj.cdoState(), created, revised);
+ CDOElement cdoElement = AdapterUtil.adapt(element, CDOElement.class);
+ if (cdoElement != null)
+ {
+ element = cdoElement.getDelegate();
+ }
+
+ if (element instanceof InternalCDOObject)
+ {
+ InternalCDOView view = ((InternalCDOObject)element).cdoView();
+ InternalCDOObject object = FSMUtil.adapt(element, view);
+
+ CDOID id = object.cdoID();
+ String state = getObjectState(object);
+
+ CDORevision rev = object.cdoRevision();
+ long created = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getTimeStamp();
+ long revised = rev == null ? CDORevision.UNSPECIFIED_DATE : rev.getRevised();
+ text = MessageFormat.format(pattern, text, id, state, created, revised).trim();
+ }
}
}
catch (RuntimeException ignore)
@@ -132,4 +150,29 @@ public class CDOLabelDecorator implements ILabelDecorator
{
// Ignore listeners, DecoratorManager handles them.
}
+
+ /**
+ * @since 4.4
+ */
+ protected String getObjectState(InternalCDOObject object)
+ {
+ CDOState state = null;
+
+ StateProvider stateProvider = AdapterUtil.adapt(object, StateProvider.class);
+ if (stateProvider != null)
+ {
+ state = stateProvider.getState(object);
+ }
+ else
+ {
+ state = object.cdoState();
+ }
+
+ if (state == null)
+ {
+ return "";
+ }
+
+ return state.toString().toLowerCase();
+ }
}

Back to the top