summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2007-10-11 15:03:53 (EDT)
committerEike Stepper2007-10-11 15:03:53 (EDT)
commitf3c4ef6c57cedef17d5f343461c7e53cde97af66 (patch)
tree20dfade4563026cdf73cb99fcf5a72eb737e254b
parentd4447288d6f23ec586978bd1c2c40786998d5c94 (diff)
downloadcdo-f3c4ef6c57cedef17d5f343461c7e53cde97af66.zip
cdo-f3c4ef6c57cedef17d5f343461c7e53cde97af66.tar.gz
cdo-f3c4ef6c57cedef17d5f343461c7e53cde97af66.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.java36
-rw-r--r--plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java3
2 files changed, 35 insertions, 4 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 999650f..787756e 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
@@ -30,7 +30,6 @@ import org.eclipse.core.runtime.CoreException;
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.resource.ImageDescriptor;
import org.eclipse.jface.viewers.ISelectionChangedListener;
import org.eclipse.jface.viewers.SelectionChangedEvent;
@@ -67,7 +66,7 @@ public class CollaborationsPane extends Composite implements IListener
private Map<IFacility, FacilityPane> facilityPanes = new HashMap<IFacility, FacilityPane>();
- private List<IAction> activateFacilityActions = new ArrayList<IAction>();
+ private List<ActivateFacilityAction> activateFacilityActions = new ArrayList<ActivateFacilityAction>();
private StackLayout paneStack;
@@ -110,6 +109,8 @@ public class CollaborationsPane extends Composite implements IListener
else
{
}
+
+ updateState();
}
public void setActiveCollaboration(IBuddyCollaboration collaboration)
@@ -165,7 +166,7 @@ public class CollaborationsPane extends Composite implements IListener
String type = element.getAttribute("type");
String icon = element.getAttribute("icon");
ImageDescriptor descriptor = AbstractUIPlugin.imageDescriptorFromPlugin(OM.BUNDLE_ID, icon);
- IAction action = new ActivateFacilityAction(type, descriptor);
+ ActivateFacilityAction action = new ActivateFacilityAction(type, descriptor);
activateFacilityActions.add(action);
bars.getToolBarManager().add(action);
}
@@ -217,11 +218,13 @@ public class CollaborationsPane extends Composite implements IListener
}
collaboration.addListener(this);
+ updateState();
}
protected void collaborationRemoved(IBuddyCollaboration collaboration)
{
collaboration.removeListener(this);
+ updateState();
}
protected void facilityInstalled(final IFacility facility, boolean fromRemote)
@@ -260,6 +263,8 @@ public class CollaborationsPane extends Composite implements IListener
setActiveCollaboration(collaboration);
setActiveFacility(collaboration, facility);
}
+
+ updateState();
}
protected FacilityPane addFacilityPane(IFacility facility)
@@ -295,6 +300,26 @@ public class CollaborationsPane extends Composite implements IListener
throw new IllegalStateException("No facility pane creator for type " + type);
}
+ protected void updateState()
+ {
+ for (ActivateFacilityAction action : activateFacilityActions)
+ {
+ if (activeCollaboration == null)
+ {
+ action.setEnabled(false);
+ }
+ else
+ {
+ String type = action.getType();
+ boolean installed = activeCollaboration.getFacility(type) != null;
+ action.setEnabled(!installed);
+
+ IFacility activeFacility = activeFacilities.get(activeCollaboration);
+ action.setChecked(ObjectUtil.equals(activeFacility.getType(), type));
+ }
+ }
+ }
+
/**
* @author Eike Stepper
*/
@@ -310,6 +335,11 @@ public class CollaborationsPane extends Composite implements IListener
this.type = type;
}
+ public String getType()
+ {
+ return type;
+ }
+
@Override
protected void safeRun() throws Exception
{
diff --git a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
index 01fec70..06a02fe 100644
--- a/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
+++ b/plugins/org.eclipse.net4j.buddies.ui/src/org/eclipse/net4j/buddies/internal/ui/views/CollaborationsView.java
@@ -12,6 +12,7 @@ package org.eclipse.net4j.buddies.internal.ui.views;
import org.eclipse.net4j.buddies.IBuddyCollaboration;
import org.eclipse.net4j.buddies.internal.ui.bundle.OM;
+import org.eclipse.net4j.util.StringUtil;
import org.eclipse.net4j.util.container.ContainerUtil;
import org.eclipse.net4j.util.container.IContainer;
import org.eclipse.net4j.util.event.IEvent;
@@ -133,7 +134,7 @@ public class CollaborationsView extends SessionManagerView
private InstallFacilityAction(IBuddyCollaboration collaboration, String type, ImageDescriptor descriptor)
{
- super("Install " + type, AS_RADIO_BUTTON);
+ super("Install " + StringUtil.cap(type), AS_RADIO_BUTTON);
setToolTipText("Install " + type + " facility");
setImageDescriptor(descriptor);
this.collaboration = collaboration;