summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-07-05 06:23:37 (EDT)
committerEike Stepper2007-07-05 06:23:37 (EDT)
commitf6254bd6eba7d5dae89234684f7ed88f631f098d (patch)
treeb421e4fb35e9c8a231e19bf46acb9166c5cdb80f
parentd06b59b1f0cc24c04adbe5b4735ad0e789ee7001 (diff)
downloadcdo-f6254bd6eba7d5dae89234684f7ed88f631f098d.zip
cdo-f6254bd6eba7d5dae89234684f7ed88f631f098d.tar.gz
cdo-f6254bd6eba7d5dae89234684f7ed88f631f098d.tar.bz2
task 1: Develop 0.8.0
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java47
-rw-r--r--plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java58
2 files changed, 103 insertions, 2 deletions
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
index e07da4b..1fec147 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/views/CDOItemProvider.java
@@ -12,6 +12,9 @@ package org.eclipse.emf.cdo.internal.ui.views;
import org.eclipse.emf.cdo.CDOSession;
import org.eclipse.emf.cdo.CDOView;
+import org.eclipse.emf.cdo.CDOViewCommittedEvent;
+import org.eclipse.emf.cdo.CDOViewDirtyEvent;
+import org.eclipse.emf.cdo.CDOViewEvent;
import org.eclipse.emf.cdo.internal.ui.LabelUtil;
import org.eclipse.emf.cdo.internal.ui.bundle.SharedIcons;
import org.eclipse.emf.cdo.internal.ui.editor.CDOEditor;
@@ -45,6 +48,37 @@ public class CDOItemProvider extends ContainerItemProvider
private Map<CDOView, CDOViewHistory> viewHistories = new HashMap();
+ private IListener viewListener = new IListener()
+ {
+ public void notifyEvent(IEvent event)
+ {
+ if (event instanceof CDOViewDirtyEvent || event instanceof CDOViewCommittedEvent)
+ {
+ try
+ {
+ CDOViewEvent e = (CDOViewEvent)event;
+ final CDOView view = e.getView();
+ getViewer().getControl().getDisplay().syncExec(new Runnable()
+ {
+ public void run()
+ {
+ try
+ {
+ fireLabelProviderChanged(view);
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ });
+ }
+ catch (Exception ignore)
+ {
+ }
+ }
+ }
+ };
+
private IListener historyListener = new IListener()
{
public void notifyEvent(IEvent event)
@@ -133,6 +167,15 @@ public class CDOItemProvider extends ContainerItemProvider
text = super.getText(obj);
}
+ if (obj instanceof CDOView && text != null)
+ {
+ CDOView view = (CDOView)obj;
+ if (view.isDirty())
+ {
+ text = "*" + text;
+ }
+ }
+
return text;
}
@@ -303,6 +346,8 @@ public class CDOItemProvider extends ContainerItemProvider
if (element instanceof CDOView)
{
CDOView view = (CDOView)element;
+ view.addListener(viewListener);
+
CDOViewHistory history = new CDOViewHistory(view);
history.addListener(historyListener);
viewHistories.put(view, history);
@@ -316,6 +361,8 @@ public class CDOItemProvider extends ContainerItemProvider
if (element instanceof CDOView)
{
CDOView view = (CDOView)element;
+ view.removeListener(viewListener);
+
CDOViewHistory history = viewHistories.remove(view);
history.removeListener(historyListener);
history.dispose();
diff --git a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java
index 91902ae..9a5fec7 100644
--- a/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java
+++ b/plugins/org.eclipse.net4j.ui/src/org/eclipse/net4j/ui/views/ItemProvider.java
@@ -10,6 +10,7 @@
**************************************************************************/
package org.eclipse.net4j.ui.views;
+import org.eclipse.net4j.internal.ui.bundle.Net4jUI;
import org.eclipse.net4j.ui.StructuredContentProvider;
import org.eclipse.jface.action.IMenuManager;
@@ -17,6 +18,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -61,17 +63,69 @@ public abstract class ItemProvider<INPUT> extends StructuredContentProvider<INPU
return true;
}
+ public ILabelProviderListener[] getListeners()
+ {
+ synchronized (listeners)
+ {
+ return listeners.toArray(new ILabelProviderListener[listeners.size()]);
+ }
+ }
+
public void addListener(ILabelProviderListener listener)
{
- listeners.add(listener);
+ synchronized (listeners)
+ {
+ listeners.add(listener);
+ }
}
public void removeListener(ILabelProviderListener listener)
{
- listeners.remove(listener);
+ synchronized (listeners)
+ {
+ listeners.remove(listener);
+ }
}
protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
{
}
+
+ protected void fireLabelProviderChanged()
+ {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(this));
+ }
+
+ protected void fireLabelProviderChanged(Object element)
+ {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(this, element));
+ }
+
+ protected void fireLabelProviderChanged(Object[] elements)
+ {
+ fireLabelProviderChanged(new LabelProviderChangedEvent(this, elements));
+ }
+
+ /**
+ * Fires a label provider changed event to all registered listeners Only
+ * listeners registered at the time this method is called are notified.
+ *
+ * @param event
+ * a label provider changed event
+ * @see ILabelProviderListener#labelProviderChanged
+ */
+ private void fireLabelProviderChanged(LabelProviderChangedEvent event)
+ {
+ for (ILabelProviderListener listener : getListeners())
+ {
+ try
+ {
+ listener.labelProviderChanged(event);
+ }
+ catch (Exception ex)
+ {
+ Net4jUI.LOG.error(ex);
+ }
+ }
+ }
} \ No newline at end of file