summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-08 06:50:49 (EDT)
committerEike Stepper2007-10-08 06:50:49 (EDT)
commit7385129e5a0bcbbc5b6cc7dd8ba5390d563ab9b5 (patch)
tree8ab9245385cbdb58e046d632a054bea2cf0815d9
parent761a831aa71491c77de52250e23de8aef21f15cb (diff)
downloadcdo-7385129e5a0bcbbc5b6cc7dd8ba5390d563ab9b5.zip
cdo-7385129e5a0bcbbc5b6cc7dd8ba5390d563ab9b5.tar.gz
cdo-7385129e5a0bcbbc5b6cc7dd8ba5390d563ab9b5.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/editor/CDOLabelProvider.java10
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/icons/full/obj16/buddy_lonesome.gifbin0 -> 334 bytes
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SharedIcons.java2
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java60
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java14
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java20
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java9
7 files changed, 99 insertions, 16 deletions
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
index af4d0fe..59e0d78 100644
--- 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
@@ -16,9 +16,6 @@ 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
@@ -40,12 +37,7 @@ public class CDOLabelProvider extends AdapterFactoryLabelProvider implements ICo
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);
+ bold = UIUtil.getBoldFont(viewer.getControl());
}
public CDOView getView()
diff --git a/plugins/org.eclipse.net4j.buddies.ui/icons/full/obj16/buddy_lonesome.gif b/plugins/org.eclipse.net4j.buddies.ui/icons/full/obj16/buddy_lonesome.gif
new file mode 100644
index 0000000..1b87e3c
--- /dev/null
+++ b/plugins/org.eclipse.net4j.buddies.ui/icons/full/obj16/buddy_lonesome.gif
Binary files differ
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SharedIcons.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SharedIcons.java
index aee44cd..f09c096 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SharedIcons.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/SharedIcons.java
@@ -39,6 +39,8 @@ public class SharedIcons
public static final String OBJ_BUDDY = OBJ + "buddy";
+ public static final String OBJ_BUDDY_LONESOME = OBJ + "buddy_lonesome";
+
public static final String OBJ_BUDDY_AWAY = OBJ + "buddy_away";
public static final String OBJ_BUDDY_DO_NOT_DISTURB = OBJ + "buddy_do_not_disturb";
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java
index d9830e0..4a088d8 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesItemProvider.java
@@ -14,6 +14,7 @@ import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
import org.eclipse.net4j.buddies.protocol.IBuddy;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.lifecycle.LifecycleUtil;
+import org.eclipse.net4j.util.ui.UIUtil;
import org.eclipse.net4j.util.ui.actions.LongRunningAction;
import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
import org.eclipse.net4j.util.ui.views.ContainerView;
@@ -21,6 +22,10 @@ import org.eclipse.net4j.util.ui.views.IElementFilter;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
/**
@@ -28,6 +33,10 @@ import org.eclipse.swt.graphics.Image;
*/
public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object>>
{
+ private static final Color GRAY = UIUtil.getDisplay().getSystemColor(SWT.COLOR_GRAY);
+
+ private Font bold;
+
public BuddiesItemProvider()
{
}
@@ -38,6 +47,13 @@ public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object
}
@Override
+ public void dispose()
+ {
+ UIUtil.dispose(bold);
+ super.dispose();
+ }
+
+ @Override
public String getText(Object obj)
{
if (obj instanceof IBuddy)
@@ -60,6 +76,9 @@ public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object
case AVAILABLE:
return SharedIcons.getImage(SharedIcons.OBJ_BUDDY);
+ case LONESOME:
+ return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_LONESOME);
+
case AWAY:
return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_AWAY);
@@ -72,6 +91,39 @@ public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object
}
@Override
+ public Color getForeground(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ switch (buddy.getState())
+ {
+ case AWAY:
+ case DO_NOT_DISTURB:
+ return GRAY;
+ }
+ }
+
+ return super.getForeground(obj);
+ }
+
+ @Override
+ public Font getFont(Object obj)
+ {
+ if (obj instanceof IBuddy)
+ {
+ IBuddy buddy = (IBuddy)obj;
+ switch (buddy.getState())
+ {
+ case LONESOME:
+ return bold;
+ }
+ }
+
+ return super.getFont(obj);
+ }
+
+ @Override
protected void fillContextMenu(IMenuManager manager, ITreeSelection selection)
{
if (selection.size() == 1)
@@ -84,6 +136,14 @@ public class BuddiesItemProvider extends ContainerItemProvider<IContainer<Object
}
}
+ @Override
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput)
+ {
+ UIUtil.dispose(bold);
+ super.inputChanged(viewer, oldInput, newInput);
+ bold = UIUtil.getBoldFont(getViewer().getControl());
+ }
+
/**
* @author Eike Stepper
*/
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
index 4446395..b1948b6 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/BuddiesView.java
@@ -7,7 +7,6 @@ import org.eclipse.net4j.buddies.IBuddySession;
import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
import org.eclipse.net4j.buddies.protocol.IBuddy;
-import org.eclipse.net4j.buddies.protocol.IBuddyStateChangedEvent;
import org.eclipse.net4j.buddies.protocol.IBuddy.State;
import org.eclipse.net4j.internal.buddies.Self;
import org.eclipse.net4j.util.container.ContainerUtil;
@@ -35,6 +34,8 @@ public class BuddiesView extends ContainerView implements IListener
private StateAction availableAction = new StateAction("Available", State.AVAILABLE, SharedIcons.OBJ_BUDDY);
+ private StateAction lonesomeAction = new StateAction("Lonesome", State.LONESOME, SharedIcons.OBJ_BUDDY);
+
private StateAction awayAction = new StateAction("Away", State.AWAY, SharedIcons.OBJ_BUDDY_AWAY);
private StateAction doNotDisturbAction = new StateAction("Do Not Disturb", State.DO_NOT_DISTURB,
@@ -171,11 +172,11 @@ public class BuddiesView extends ContainerView implements IListener
}
}
}
- else if (event instanceof IBuddyStateChangedEvent)
- {
- IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
- updateLabels(e.getBuddy());
- }
+ // else if (event instanceof IBuddyStateChangedEvent)
+ // {
+ // IBuddyStateChangedEvent e = (IBuddyStateChangedEvent)event;
+ // updateLabels(e.getBuddy());
+ // }
}
protected void closeView()
@@ -218,6 +219,7 @@ public class BuddiesView extends ContainerView implements IListener
protected void fillLocalToolBar(IToolBarManager manager)
{
manager.add(availableAction);
+ manager.add(lonesomeAction);
manager.add(awayAction);
manager.add(doNotDisturbAction);
super.fillLocalToolBar(manager);
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
index 01540e1..87b002e 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/UIUtil.java
@@ -14,8 +14,11 @@ import org.eclipse.net4j.util.internal.ui.security.InteractiveCredentialsProvide
import org.eclipse.net4j.util.security.IPasswordCredentialsProvider;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.PlatformUI;
@@ -28,6 +31,23 @@ public final class UIUtil
{
}
+ public static void dispose(Font font)
+ {
+ if (font!= null)
+ {
+ font.dispose();
+ }
+ }
+
+ public static Font getBoldFont(Control control)
+ {
+ FontData[] datas = control.getFont().getFontData().clone();
+ datas[0].setStyle(SWT.BOLD);
+ Display display = control.getShell().getDisplay();
+ Font font = new Font(display, datas);
+ return font;
+ }
+
public static Display getDisplay()
{
Display display = Display.getCurrent();
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
index f14c0ed..d85d9a7 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ItemProvider.java
@@ -16,6 +16,7 @@ import org.eclipse.net4j.util.ui.StructuredContentProvider;
import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IFontProvider;
import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.jface.viewers.ILabelProviderListener;
import org.eclipse.jface.viewers.ITreeContentProvider;
@@ -23,6 +24,7 @@ import org.eclipse.jface.viewers.ITreeSelection;
import org.eclipse.jface.viewers.LabelProviderChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.Image;
import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
@@ -31,7 +33,7 @@ import java.util.ArrayList;
import java.util.List;
public abstract class ItemProvider<INPUT> extends StructuredContentProvider<INPUT> implements ITreeContentProvider,
- ILabelProvider, IColorProvider
+ ILabelProvider, IColorProvider, IFontProvider
{
public static final Object[] NO_ELEMENTS = {};
@@ -77,6 +79,11 @@ public abstract class ItemProvider<INPUT> extends StructuredContentProvider<INPU
return null;
}
+ public Font getFont(Object element)
+ {
+ return null;
+ }
+
public boolean isLabelProperty(Object element, String property)
{
return true;