Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.ui/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.egit.ui/plugin.properties2
-rw-r--r--org.eclipse.egit.ui/plugin.xml81
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java58
4 files changed, 93 insertions, 49 deletions
diff --git a/org.eclipse.egit.ui/META-INF/MANIFEST.MF b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
index 74ea01a2a3..62525f3379 100644
--- a/org.eclipse.egit.ui/META-INF/MANIFEST.MF
+++ b/org.eclipse.egit.ui/META-INF/MANIFEST.MF
@@ -32,6 +32,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.12.0,4.0.0)",
org.eclipse.osgi.services;bundle-version="[3.5.100,4.0.0)",
org.eclipse.e4.core.contexts;bundle-version="[1.5.1,2.0.0)",
org.eclipse.e4.ui.workbench;bundle-version="[1.4.0,2.0.0)",
+ org.eclipse.ui.workbench;bundle-version="[3.108.0,4.0.0)",
org.apache.ant;bundle-version="[1.10.5,2.0.0)"
Bundle-ActivationPolicy: lazy
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index a267684e69..a341477a9e 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -296,9 +296,7 @@ CreateRepositoryGroupCommand.name = Create a Repository Group
CreateRepositoryGroupCommand.label = Create a Repository &Group...
CreateRepositoryGroupCommand.description = Create a repository group for structuring repositories in the Git Repositories view
DeleteRepositoryGroupCommand.label = &Delete Repository Group...
-RenameRepositoryGroupCommand.name = Rename Repository Group...
RenameRepositoryGroupCommand.label = &Rename Repository Group...
-RenameRepositoryGroupCommand.description = Change the name of the repository group
RepositoryGroupMenu.label = Repository &Groups
RepoViewAddRepository.tooltip = Add an existing local Git Repository to this view
RepoViewCloneRepository.tooltip = Clone a Git Repository and add the clone to this view
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index 435fbfde68..4de2676861 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -1947,26 +1947,28 @@
</activeWhen>
</handler>
<handler
+ commandId="org.eclipse.ui.edit.rename">
+ <class
+ class="org.eclipse.egit.ui.internal.repository.tree.command.RenameBranchCommand">
+ </class>
+ <activeWhen>
+ <reference
+ definitionId="org.eclipse.egit.ui.singleRefNode">
+ </reference>
+ </activeWhen>
+ </handler>
+ <handler
commandId="org.eclipse.egit.ui.team.RenameBranch">
<class
class="org.eclipse.egit.ui.internal.repository.tree.command.RenameBranchCommand">
</class>
<activeWhen>
- <or>
- <reference
- definitionId="org.eclipse.egit.ui.singleRefNode">
- </reference>
- <and>
- <count
- value="1">
- </count>
- <iterate>
- <instanceof
- value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode">
- </instanceof>
- </iterate>
- </and>
- </or>
+ <and>
+ <count value="1" />
+ <iterate>
+ <instanceof value="org.eclipse.egit.ui.internal.repository.tree.RepositoryNode" />
+ </iterate>
+ </and>
</activeWhen>
</handler>
<handler
@@ -3069,7 +3071,7 @@
</activeWhen>
</handler>
<handler
- commandId="org.eclipse.egit.ui.RepositoriesRenameGroup">
+ commandId="org.eclipse.ui.edit.rename">
<class
class="org.eclipse.egit.ui.internal.repository.tree.command.RenameRepositoryGroupCommand">
</class>
@@ -3735,26 +3737,25 @@
style="push">
<visibleWhen checkEnabled="true" />
</command>
+ <!-- These two rename commands are never active simultaneously. -->
<command
- commandId="org.eclipse.egit.ui.team.RenameBranch"
+ commandId="org.eclipse.ui.edit.rename"
icon="icons/obj16/editconfig.png"
label="%RepoViewRenameBranch.label"
style="push">
- <visibleWhen
- checkEnabled="false">
- <and>
- <count
- value="1">
- </count>
- <iterate>
- <instanceof
- value="org.eclipse.egit.ui.internal.repository.tree.RefNode">
- </instanceof>
- </iterate>
- </and>
+ <visibleWhen>
+ <reference
+ definitionId="org.eclipse.egit.ui.singleRefNode">
+ </reference>
</visibleWhen>
</command>
<command
+ commandId="org.eclipse.egit.ui.team.RenameBranch"
+ label="%RepoViewRenameBranch.label"
+ style="push">
+ <visibleWhen checkEnabled="true" />
+ </command>
+ <command
commandId="org.eclipse.egit.ui.RepositoriesViewConfigureBranch"
label="%ConfigurBranchCommand.label"
style="push">
@@ -4223,10 +4224,15 @@
</visibleWhen>
</command>
<command
- commandId="org.eclipse.egit.ui.RepositoriesRenameGroup"
+ commandId="org.eclipse.ui.edit.rename"
label="%RenameRepositoryGroupCommand.label"
style="push">
- <visibleWhen checkEnabled="true"/>
+ <visibleWhen>
+ <and>
+ <count value="1"/>
+ <reference definitionId="org.eclipse.egit.ui.repoGroups.onlyGroupsSelected"/>
+ </and>
+ </visibleWhen>
</command>
</menuContribution>
<menuContribution
@@ -6027,12 +6033,6 @@
</command>
<command
categoryId="org.eclipse.egit.ui.commandCategory"
- id="org.eclipse.egit.ui.RepositoriesRenameGroup"
- name="%RenameRepositoryGroupCommand.name"
- description="%RenameRepositoryGroupCommand.description">
- </command>
- <command
- categoryId="org.eclipse.egit.ui.commandCategory"
defaultHandler="org.eclipse.egit.ui.internal.repository.tree.command.ToggleBranchHierarchyCommand"
id="org.eclipse.egit.ui.RepositoriesToggleBranchHierarchy"
name="%ToggleLayoutCommand.name">
@@ -6792,7 +6792,7 @@
</key>
<key
commandId="org.eclipse.egit.ui.team.RenameBranch"
- contextId="org.eclipse.egit.ui.RepositoriesView"
+ contextId="org.eclipse.egit.ui.RepositoriesView.SingleRepository"
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="F2">
</key>
@@ -6941,6 +6941,11 @@
parentId="org.eclipse.ui.contexts.window">
</context>
<context
+ id="org.eclipse.egit.ui.RepositoriesView.SingleRepository"
+ name="%RepositoriesViewContext.name"
+ parentId="org.eclipse.egit.ui.RepositoriesView">
+ </context>
+ <context
id="org.eclipse.egit.ui.ReflogView"
name="%ReflogViewContext"
parentId="org.eclipse.ui.contexts.window">
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
index 4d8d3c0241..20db2aa713 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java
@@ -114,6 +114,8 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.DisposeEvent;
import org.eclipse.swt.events.DisposeListener;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.events.FocusListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
@@ -134,6 +136,7 @@ import org.eclipse.ui.IWorkbenchPartSite;
import org.eclipse.ui.IWorkbenchWindow;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextActivation;
import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.forms.events.HyperlinkAdapter;
import org.eclipse.ui.forms.events.HyperlinkEvent;
@@ -174,9 +177,13 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
/** "fetch" */
public static final String FETCH = "fetch"; //$NON-NLS-1$
- /** view id */
+ /** View id; also doubles as context id. */
public static final String VIEW_ID = "org.eclipse.egit.ui.RepositoriesView"; //$NON-NLS-1$
+ /** Sub-context active when a single repository is selected. */
+ private static final String SINGLE_REPO_CONTEXT_ID = VIEW_ID
+ + ".SingleRepository"; //$NON-NLS-1$
+
private static final long DEFAULT_REFRESH_DELAY = 1000;
private final Set<Repository> repositories = new HashSet<>();
@@ -264,6 +271,10 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
private final IPreferenceChangeListener configurationListener;
+ private IContextActivation renameContext;
+
+ private IContextService ctxSrv;
+
/**
* The default constructor
*/
@@ -496,6 +507,22 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
executeOpenCommand(element);
}
});
+ ctxSrv = CommonUtils.getService(getSite(), IContextService.class);
+ viewer.addSelectionChangedListener(event -> {
+ handleSingleRepositoryContext(event.getSelection(), viewer);
+ });
+ viewer.getTree().addFocusListener(new FocusListener() {
+
+ @Override
+ public void focusLost(FocusEvent e) {
+ handleSingleRepositoryContext(null, viewer);
+ }
+
+ @Override
+ public void focusGained(FocusEvent e) {
+ handleSingleRepositoryContext(viewer.getSelection(), viewer);
+ }
+ });
// react on selection changes
ISelectionService srv = CommonUtils.getService(getSite(), ISelectionService.class);
srv.addPostSelectionListener(selectionChangedListener);
@@ -503,7 +530,7 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
repositoryUtil.getPreferences().addPreferenceChangeListener(
configurationListener);
initRepositoriesAndListeners();
- activateContextService();
+ ctxSrv.activateContext(VIEW_ID);
// link with editor
viewer.addPostSelectionChangedListener(event -> {
if (!((Boolean) reactOnSelection.getValue()).booleanValue()) {
@@ -523,6 +550,7 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
showEditor((FileNode) selected);
}
});
+
emptyArea.setBackground(viewer.getControl().getBackground());
if (!repositories.isEmpty())
layout.topControl = viewer.getControl();
@@ -532,6 +560,25 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
return viewer;
}
+ private void handleSingleRepositoryContext(ISelection selection,
+ CommonViewer viewer) {
+ boolean activate = false;
+ if (selection != null && !selection.isEmpty()
+ && (selection instanceof StructuredSelection)) {
+ StructuredSelection sel = (StructuredSelection) selection;
+ Object item = sel.getFirstElement();
+ activate = sel.size() == 1 && (item instanceof RepositoryNode);
+ }
+ if (!activate) {
+ if (renameContext != null) {
+ ctxSrv.deactivateContext(renameContext);
+ renameContext = null;
+ }
+ } else if (viewer.getTree().isFocusControl() && renameContext == null) {
+ renameContext = ctxSrv.activateContext(SINGLE_REPO_CONTEXT_ID);
+ }
+ }
+
private void executeOpenCommandWithConfirmation(RepositoryTreeNode element,
String refName) {
if (!BranchOperationUI.checkoutWillShowQuestionDialog(refName)) {
@@ -581,13 +628,6 @@ public class RepositoriesView extends CommonNavigator implements IShowInSource,
new StructuredSelection(node));
}
- private void activateContextService() {
- IContextService contextService = CommonUtils.getService(getSite(), IContextService.class);
- if (contextService != null) {
- contextService.activateContext(VIEW_ID);
- }
- }
-
private void initRepositoriesAndListeners() {
synchronized (repositories) {
repositories.clear();

Back to the top