summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-07 06:46:06 (EDT)
committerEike Stepper2007-10-07 06:46:06 (EDT)
commit0e751ec3f70d9a0c0cfe9be100b3d93d09bd2ba3 (patch)
tree54cf4df0f6830e82c2f72db2dcc4715c1dc78676
parent831f8aa68633869726ada59819d9bddbc2c8c844 (diff)
downloadcdo-0e751ec3f70d9a0c0cfe9be100b3d93d09bd2ba3.zip
cdo-0e751ec3f70d9a0c0cfe9be100b3d93d09bd2ba3.tar.gz
cdo-0e751ec3f70d9a0c0cfe9be100b3d93d09bd2ba3.tar.bz2
[205661] Use colors in CDOEditor to show dirty objects and conflicts
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205661
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java11
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOEditor.java19
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOLabelProvider.java125
3 files changed, 132 insertions, 23 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
index 0943747..6b5627e 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/ItemsProcessor.java
@@ -102,13 +102,14 @@ public abstract class ItemsProcessor
InternalCDOObject cdoObject = getCDOObject(object);
if (cdoObject != null)
{
- if (ids == null)
- {
- processCDOObject(viewer, cdoObject);
- }
- else if (ids.contains(cdoObject.cdoID()))
+ if (ids == null || ids.contains(cdoObject.cdoID()))
{
processCDOObject(viewer, cdoObject);
+ InternalCDOObject container = getCDOObject(cdoObject.eContainer());
+ if (container != null)
+ {
+ processCDOObject(viewer, container);
+ }
}
}
}
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 e7b69d6..a96d2d0 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
@@ -58,7 +58,6 @@ import org.eclipse.emf.internal.cdo.CDOLegacyImpl;
import org.eclipse.emf.internal.cdo.CDOStateMachine;
import org.eclipse.emf.internal.cdo.CDOTransactionImpl;
import org.eclipse.emf.internal.cdo.InternalCDOObject;
-import org.eclipse.emf.internal.cdo.util.FSMUtil;
import org.eclipse.net4j.util.ObjectUtil;
import org.eclipse.net4j.util.transaction.TransactionException;
@@ -1152,23 +1151,7 @@ public class CDOEditor extends MultiPageEditorPart implements IEditingDomainProv
setCurrentViewer(selectionViewer);
selectionViewer.setContentProvider(new AdapterFactoryContentProvider(adapterFactory));
- selectionViewer.setLabelProvider(new AdapterFactoryLabelProvider(adapterFactory)
- {
- @Override
- public String getColumnText(Object object, int columnIndex)
- {
- try
- {
- InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
- return super.getColumnText(object, columnIndex) + " [" + cdoObject.cdoID() + "]";
- }
- catch (RuntimeException ex)
- {
- return super.getColumnText(object, columnIndex);
- }
- }
- });
-
+ selectionViewer.setLabelProvider(new CDOLabelProvider(adapterFactory, view, selectionViewer));
selectionViewer.setInput(viewerInput);
// selectionViewer.setSelection(new StructuredSelection(viewerInput),
// true);
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOLabelProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOLabelProvider.java
new file mode 100644
index 0000000..3d3dbb7
--- /dev/null
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOLabelProvider.java
@@ -0,0 +1,125 @@
+package org.eclipse.emf.cdo.internal.ui.editor;
+
+import org.eclipse.emf.cdo.CDOView;
+
+import org.eclipse.emf.common.notify.AdapterFactory;
+import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider;
+import org.eclipse.emf.internal.cdo.InternalCDOObject;
+import org.eclipse.emf.internal.cdo.util.FSMUtil;
+
+import org.eclipse.net4j.util.ui.UIUtil;
+
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * @author Eike Stepper
+ */
+public class CDOLabelProvider extends AdapterFactoryLabelProvider implements IColorProvider, IFontProvider
+{
+ private static final Color GRAY = UIUtil.getDisplay().getSystemColor(SWT.COLOR_GRAY);
+
+ private static final Color RED = UIUtil.getDisplay().getSystemColor(SWT.COLOR_RED);
+
+ private Font bold;
+
+ private CDOView view;
+
+ private TreeViewer viewer;
+
+ public CDOLabelProvider(AdapterFactory adapterFactory, CDOView view, TreeViewer viewer)
+ {
+ super(adapterFactory);
+ this.view = view;
+ this.viewer = viewer;
+
+ Control control = viewer.getControl();
+ FontData[] datas = control.getFont().getFontData().clone();
+ datas[0].setStyle(SWT.BOLD);
+ Display display = control.getShell().getDisplay();
+ bold = new Font(display, datas);
+ }
+
+ public CDOView getView()
+ {
+ return view;
+ }
+
+ public TreeViewer getViewer()
+ {
+ return viewer;
+ }
+
+ @Override
+ public void dispose()
+ {
+ bold.dispose();
+ super.dispose();
+ }
+
+ @Override
+ public String getColumnText(Object object, int columnIndex)
+ {
+ try
+ {
+ InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
+ return super.getColumnText(object, columnIndex) + " [" + cdoObject.cdoID() + "]";
+ }
+ catch (RuntimeException ex)
+ {
+ return super.getColumnText(object, columnIndex);
+ }
+ }
+
+ public Color getBackground(Object object)
+ {
+ return null;
+ }
+
+ public Color getForeground(Object object)
+ {
+ try
+ {
+ InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
+ switch (cdoObject.cdoState())
+ {
+ case PROXY:
+ return GRAY;
+
+ case CONFLICT:
+ return RED;
+ }
+ }
+ catch (RuntimeException ignore)
+ {
+ }
+
+ return null;
+ }
+
+ public Font getFont(Object object)
+ {
+ try
+ {
+ InternalCDOObject cdoObject = FSMUtil.adapt(object, view);
+ switch (cdoObject.cdoState())
+ {
+ case NEW:
+ case DIRTY:
+ return bold;
+ }
+ }
+ catch (RuntimeException ignore)
+ {
+ }
+
+ return null;
+ }
+} \ No newline at end of file