Issue #716 fix disabled toolbar

Change-Id: I464d0560cf7462b37d324db368411f3867e53602

Former-commit-id: c3c4a8519a [formerly d2bb1b6e0c] [formerly 0c869f599e [formerly d32771cbbe72a32965c50aacd7ede3383a5fff23]]
Former-commit-id: 0c869f599e
Former-commit-id: ea33fc82fe
This commit is contained in:
Nate Jensen 2012-06-11 17:26:36 -05:00
parent 4b5af450d1
commit 38a3e93585

View file

@ -222,6 +222,10 @@ public class CollaborationGroupView extends CaveFloatingView implements
// add some actions to the menubar // add some actions to the menubar
createMenubar(); createMenubar();
openConnection();
}
private void openConnection() {
CollaborationConnection connection = CollaborationConnection CollaborationConnection connection = CollaborationConnection
.getConnection(); .getConnection();
if (connection == null) { if (connection == null) {
@ -243,6 +247,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
return; return;
} }
} }
// add a part listener so that we can check when things about the view // add a part listener so that we can check when things about the view
// change // change
getViewSite().getWorkbenchWindow().getPartService() getViewSite().getWorkbenchWindow().getPartService()
@ -257,7 +262,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
} }
populateTree(); populateTree();
usersTreeViewer.refresh(); usersTreeViewer.refresh();
parent.layout(); parent.layout();
} }
@ -288,9 +292,6 @@ public class CollaborationGroupView extends CaveFloatingView implements
}; };
createSessionAction.setImageDescriptor(IconUtil.getImageDescriptor( createSessionAction.setImageDescriptor(IconUtil.getImageDescriptor(
bundle, "add_collaborate.gif")); bundle, "add_collaborate.gif"));
createSessionAction.setDisabledImageDescriptor(IconUtil
.getImageDescriptor(bundle, "add_collaborate_disabled.png"));
this.disableOrEnableSessionAction();
linkToEditorAction = new Action("Link Editor to Chat Session", linkToEditorAction = new Action("Link Editor to Chat Session",
Action.AS_CHECK_BOX) { Action.AS_CHECK_BOX) {
@ -452,7 +453,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
@Override @Override
public void run() { public void run() {
if (usersTreeViewer == null) { if (usersTreeViewer == null) {
createPartControl(parent); openConnection();
} }
} }
}; };
@ -556,6 +557,8 @@ public class CollaborationGroupView extends CaveFloatingView implements
collapseAllAction.setImageDescriptor(IconUtil.getImageDescriptor( collapseAllAction.setImageDescriptor(IconUtil.getImageDescriptor(
bundle, "collapseall.gif")); bundle, "collapseall.gif"));
this.disableOrEnableToolbarActions();
IMenuCreator creator = new IMenuCreator() { IMenuCreator creator = new IMenuCreator() {
Menu menu; Menu menu;
@ -736,7 +739,7 @@ public class CollaborationGroupView extends CaveFloatingView implements
// enable the tree, and then refresh it just to be safe // enable the tree, and then refresh it just to be safe
usersTreeViewer.getTree().setEnabled(true); usersTreeViewer.getTree().setEnabled(true);
usersTreeViewer.refresh(topLevel, true); usersTreeViewer.refresh(topLevel, true);
this.disableOrEnableSessionAction(); this.disableOrEnableToolbarActions();
createArchiveViewerAction.setEnabled(true); createArchiveViewerAction.setEnabled(true);
} }
@ -1482,12 +1485,14 @@ public class CollaborationGroupView extends CaveFloatingView implements
} }
/** /**
* Enables or disables the Creation session button / menu option depending * Enables or disables the toolbar buttons based on whether or not the user
* on whether or not the user is connected to the xmpp server. * is connected to the xmpp server.
*/ */
private void disableOrEnableSessionAction() { private void disableOrEnableToolbarActions() {
boolean isSessionEnabled = (CollaborationConnection.getConnection() != null); boolean enabled = (CollaborationConnection.getConnection() != null);
createSessionAction.setEnabled(isSessionEnabled); createSessionAction.setEnabled(enabled);
linkToEditorAction.setEnabled(enabled);
collapseAllAction.setEnabled(enabled);
} }
/** /**