summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-11-12 05:42:18 (EST)
committerEike Stepper2007-11-12 05:42:18 (EST)
commit58e93080c332a30d5506b5bbab74218bb809f199 (patch)
treee6ec8368a78605d1c22a109c23ec51612a32177a
parent7a158500c5f872a917db5ae2f36350e70e2e068e (diff)
downloadcdo-58e93080c332a30d5506b5bbab74218bb809f199.zip
cdo-58e93080c332a30d5506b5bbab74218bb809f199.tar.gz
cdo-58e93080c332a30d5506b5bbab74218bb809f199.tar.bz2
*** empty log message ***
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/AbstractItemProvider.java230
1 files changed, 0 insertions, 230 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/AbstractItemProvider.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/AbstractItemProvider.java
deleted file mode 100644
index e37a717..0000000
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/AbstractItemProvider.java
+++ /dev/null
@@ -1,230 +0,0 @@
-/***************************************************************************
- * Copyright (c) 2004 - 2007 Eike Stepper, Germany.
- * 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.net4j.buddies.internal.ui.views;
-
-import org.eclipse.net4j.buddies.IBuddyCollaboration;
-import org.eclipse.net4j.buddies.internal.ui.SharedIcons;
-import org.eclipse.net4j.buddies.protocol.IBuddy;
-import org.eclipse.net4j.buddies.protocol.ICollaboration;
-import org.eclipse.net4j.buddies.protocol.IMembership;
-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.actions.SafeAction;
-import org.eclipse.net4j.util.ui.views.ContainerItemProvider;
-import org.eclipse.net4j.util.ui.views.ContainerView;
-import org.eclipse.net4j.util.ui.views.IElementFilter;
-
-import org.eclipse.jface.action.IMenuManager;
-import org.eclipse.jface.action.Separator;
-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;
-
-/**
- * @author Eike Stepper
- */
-public abstract class AbstractItemProvider extends ContainerItemProvider<IContainer<Object>>
-{
- public static final Color GRAY = UIUtil.getDisplay().getSystemColor(SWT.COLOR_GRAY);
-
- private Font bold;
-
- public AbstractItemProvider()
- {
- }
-
- public AbstractItemProvider(IElementFilter rootElementFilter)
- {
- super(rootElementFilter);
- }
-
- @Override
- public void dispose()
- {
- UIUtil.dispose(bold);
- super.dispose();
- }
-
- public Font getBold()
- {
- return bold;
- }
-
- @Override
- protected Node createNode(Node parent, Object element)
- {
- if (element instanceof IMembership)
- {
- IMembership membership = (IMembership)element;
- return createMembershipNode(parent, membership);
- }
-
- return super.createNode(parent, element);
- }
-
- protected abstract Node createMembershipNode(Node parent, IMembership membership);
-
- @Override
- public String getText(Object obj)
- {
- if (obj instanceof IBuddy)
- {
- IBuddy buddy = (IBuddy)obj;
- return buddy.getUserID();
- }
-
- if (obj instanceof ICollaboration)
- {
- ICollaboration collaboration = (ICollaboration)obj;
- return collaboration.getTitle();
- }
-
- if (obj instanceof IMembership)
- {
- IMembership membership = (IMembership)obj;
- return getText(membership);
- }
-
- return super.getText(obj);
- }
-
- protected abstract String getText(IMembership membership);
-
- @Override
- public Image getImage(Object obj)
- {
- if (obj instanceof IBuddy)
- {
- IBuddy buddy = (IBuddy)obj;
- switch (buddy.getState())
- {
- 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);
-
- case DO_NOT_DISTURB:
- return SharedIcons.getImage(SharedIcons.OBJ_BUDDY_DO_NOT_DISTURB);
- }
- }
-
- if (obj instanceof ICollaboration)
- {
- return SharedIcons.getImage(SharedIcons.OBJ_COLLABORATION);
- }
-
- if (obj instanceof IMembership)
- {
- IMembership membership = (IMembership)obj;
- return getImage(membership);
- }
-
- return super.getImage(obj);
- }
-
- protected abstract Image getImage(IMembership membership);
-
- @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)
- {
- manager.add(new Separator());
- if (selection.size() == 1)
- {
- Object obj = selection.getFirstElement();
- if (obj instanceof IBuddy)
- {
- manager.add(new RemoveAction(obj));
- }
- else if (obj instanceof IBuddyCollaboration)
- {
- final IBuddyCollaboration collaboration = (IBuddyCollaboration)obj;
- manager.add(new SafeAction("Leave", "Leave this collaboration")
- {
- @Override
- protected void safeRun() throws Exception
- {
- collaboration.leave();
- }
- });
- }
- }
- }
-
- @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
- */
- public class RemoveAction extends LongRunningAction
- {
- private Object object;
-
- public RemoveAction(Object object)
- {
- super("Remove", "Remove", ContainerView.getDeleteImageDescriptor());
- this.object = object;
- }
-
- @Override
- protected void doRun() throws Exception
- {
- LifecycleUtil.deactivateNoisy(object);
- }
- }
-}