[573658] ReconnectionSession mechanism does not update some items after a reconnection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=573658
diff --git a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/CreateBranchActionDelegate.java b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/CreateBranchActionDelegate.java
index e14ff11..889d533 100644
--- a/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/CreateBranchActionDelegate.java
+++ b/plugins/org.eclipse.emf.cdo.ui/src/org/eclipse/emf/cdo/internal/ui/actions/delegates/CreateBranchActionDelegate.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2015 Eike Stepper (Loehne, Germany) and others.
+ * Copyright (c) 2015, 2021 Eike Stepper (Loehne, Germany) and others.
* 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
@@ -8,6 +8,7 @@
* Contributors:
* Eike Stepper - initial API and implementation
* Victor Roldan Betancort - maintenance
+ * Maxime Porhel - bug 573483
*/
package org.eclipse.emf.cdo.internal.ui.actions.delegates;
@@ -15,10 +16,13 @@
import org.eclipse.emf.cdo.common.branch.CDOBranchPoint;
import org.eclipse.emf.cdo.internal.ui.dialogs.CreateBranchDialog;
import org.eclipse.emf.cdo.internal.ui.handlers.CreateBranchHandler;
+import org.eclipse.emf.cdo.session.CDOSession;
+import org.eclipse.emf.cdo.util.CDOUtil;
import org.eclipse.net4j.util.ui.actions.LongRunningActionDelegate;
import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
@@ -77,4 +81,29 @@
name = null;
}
}
+
+ /**
+ * This method is overridden so that the action can be disabled if the branching is not supported.
+ */
+ @Override
+ public void selectionChanged(IAction action, ISelection selection)
+ {
+ super.selectionChanged(action, selection);
+
+ if (selection instanceof IStructuredSelection)
+ {
+ IStructuredSelection ssel = (IStructuredSelection)selection;
+ if (ssel.size() == 1)
+ {
+ Object element = ssel.getFirstElement();
+
+ CDOSession session = CDOUtil.getSession(element);
+ if (session != null)
+ {
+ boolean supportingBranches = session.getRepositoryInfo().isSupportingBranches();
+ action.setEnabled(supportingBranches);
+ }
+ }
+ }
+ }
}