summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 08:14:31 (EDT)
committerEike Stepper2007-10-11 08:14:31 (EDT)
commit1a5630f6f9a5e87401bfa870ce69c6ba5ebceda6 (patch)
treea912104e14ceb3f8b87014be559a09ac763848ea
parentc6517f0fccb9802dec214eda778ec30811387bb2 (diff)
downloadcdo-1a5630f6f9a5e87401bfa870ce69c6ba5ebceda6.zip
cdo-1a5630f6f9a5e87401bfa870ce69c6ba5ebceda6.tar.gz
cdo-1a5630f6f9a5e87401bfa870ce69c6ba5ebceda6.tar.bz2
[205668] Provide buddies example
https://bugs.eclipse.org/bugs/show_bug.cgi?id=205668
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java48
-rw-r--r--plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java8
2 files changed, 35 insertions, 21 deletions
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
index cddf40f..52b5c0c 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsPane.java
@@ -13,11 +13,13 @@ package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.BuddiesUtil;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
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.ICollaboration;
import org.eclipse.net4j.buddies.protocol.IFacility;
import org.eclipse.net4j.buddies.ui.IFacilityPaneCreator;
import org.eclipse.net4j.util.ObjectUtil;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.WrappedException;
import org.eclipse.net4j.util.container.IContainerEvent;
import org.eclipse.net4j.util.container.IContainerEventVisitor;
@@ -30,12 +32,12 @@ import org.eclipse.core.runtime.IConfigurationElement;
import org.eclipse.core.runtime.IExtensionRegistry;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IActionBars;
import java.util.ArrayList;
import java.util.HashMap;
@@ -153,26 +155,13 @@ public class CollaborationsPane extends Composite implements IListener
}
}
- public void fillLocalToolBar(IToolBarManager manager)
+ public void fillActionBars(IActionBars bars)
{
for (String type : BuddiesUtil.getFacilityTypes())
{
- final String facilityType = type;
- IAction action = new SafeAction()
- {
- @Override
- protected void safeRun() throws Exception
- {
- if (activeCollaboration != null)
- {
- IFacility facility = activeCollaboration.getFacility(facilityType);
- setActiveFacility(activeCollaboration, facility);
- }
- }
- };
-
+ IAction action = new ActivateFacilityAction(type);
activateFacilityActions.add(action);
- manager.add(action);
+ bars.getToolBarManager().add(action);
}
}
@@ -255,4 +244,29 @@ public class CollaborationsPane extends Composite implements IListener
throw new IllegalStateException("No facility pane creator for type " + type);
}
+
+ /**
+ * @author Eike Stepper
+ */
+ private final class ActivateFacilityAction extends SafeAction
+ {
+ private final String type;
+
+ private ActivateFacilityAction(String type)
+ {
+ super(StringUtil.cap(type), "Activate " + type + " facility");
+ setImageDescriptor(SharedIcons.getDescriptor(SharedIcons.OBJ_COLLABORATION));
+ this.type = type;
+ }
+
+ @Override
+ protected void safeRun() throws Exception
+ {
+ if (activeCollaboration != null)
+ {
+ IFacility facility = activeCollaboration.getFacility(type);
+ setActiveFacility(activeCollaboration, facility);
+ }
+ }
+ }
}
diff --git a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
index 91e08a2..1191de3 100644
--- a/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
+++ b/plugins/org.eclipse.net4j.util.ui/src/org/eclipse/net4j/util/ui/views/ContainerView.java
@@ -108,6 +108,10 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
Control control = createUI(composite);
control.setLayoutData(UIUtil.createGridData());
+
+ hookContextMenu();
+ hookDoubleClick();
+ contributeToActionBars();
}
protected Control createUI(Composite parent)
@@ -120,10 +124,6 @@ public abstract class ContainerView extends ViewPart implements ISetSelectionTar
resetInput();
viewer.addSelectionChangedListener(selectionListener);
getSite().setSelectionProvider(viewer);
-
- hookContextMenu();
- hookDoubleClick();
- contributeToActionBars();
return viewer.getControl();
}