Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--org.eclipse.egit.ui/plugin.properties2
-rw-r--r--org.eclipse.egit.ui/plugin.xml37
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/RepositoriesView.java10
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewActionProvider.java110
4 files changed, 32 insertions, 127 deletions
diff --git a/org.eclipse.egit.ui/plugin.properties b/org.eclipse.egit.ui/plugin.properties
index 013ebc498b..9a7824393a 100644
--- a/org.eclipse.egit.ui/plugin.properties
+++ b/org.eclipse.egit.ui/plugin.properties
@@ -250,3 +250,5 @@ CommitMessageProviderExtension-point.name = CommitMessageProvider
FetchFromGerritCommand.name = Fetch From Gerrit
FetchFromGerritCommand.label = Fetch From &Gerrit...
+
+RepositoriesViewContext.name= In Git Repositories View
diff --git a/org.eclipse.egit.ui/plugin.xml b/org.eclipse.egit.ui/plugin.xml
index 99353a6786..cde5b51bd8 100644
--- a/org.eclipse.egit.ui/plugin.xml
+++ b/org.eclipse.egit.ui/plugin.xml
@@ -1162,15 +1162,6 @@
</instanceof></possibleDropTargets>
</dropAssistant>
</navigatorContent>
- <actionProvider
- class="org.eclipse.egit.ui.internal.repository.tree.RepositoriesViewActionProvider"
- id="RepositoriesViewActionProvider">
- <enablement>
- <instanceof
- value="org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode">
- </instanceof>
- </enablement>
- </actionProvider>
</extension>
<extension
point="org.eclipse.ui.navigator.viewer">
@@ -1188,14 +1179,6 @@
</contentExtension>
</includes>
</viewerContentBinding>
- <viewerActionBinding
- viewerId="org.eclipse.egit.ui.RepositoriesView">
- <includes>
- <actionExtension
- pattern="RepositoriesViewActionProvider">
- </actionExtension>
- </includes>
- </viewerActionBinding>
</extension>
<extension
point="org.eclipse.ui.menus">
@@ -3036,6 +3019,18 @@
schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
sequence="M1+M3+M">
</key>
+ <key
+ commandId="org.eclipse.egit.ui.RepositoriesViewPaste"
+ contextId="org.eclipse.egit.ui.RepositoriesView"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+V">
+ </key>
+ <key
+ commandId="org.eclipse.egit.ui.RepositoriesViewCopyPath"
+ contextId="org.eclipse.egit.ui.RepositoriesView"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="M1+C">
+ </key>
</extension>
<extension
name="%HistoryViewCommands.extension.name"
@@ -3165,4 +3160,12 @@
</view>
</perspectiveExtension>
</extension>
+ <extension
+ point="org.eclipse.ui.contexts">
+ <context
+ id="org.eclipse.egit.ui.RepositoriesView"
+ name="%RepositoriesViewContext.name"
+ parentId="org.eclipse.ui.contexts.window">
+ </context>
+ </extension>
</plugin>
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 181c9b5297..a12de23c7a 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
@@ -73,6 +73,7 @@ import org.eclipse.ui.IViewPart;
import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.commands.ICommandService;
+import org.eclipse.ui.contexts.IContextService;
import org.eclipse.ui.handlers.IHandlerService;
import org.eclipse.ui.navigator.CommonNavigator;
import org.eclipse.ui.navigator.CommonViewer;
@@ -255,9 +256,18 @@ public class RepositoriesView extends CommonNavigator {
repositoryUtil.getPreferences().addPreferenceChangeListener(
configurationListener);
initRepositoriesAndListeners();
+ activateContextService();
return viewer;
}
+ private void activateContextService() {
+ IContextService contextService = (IContextService) getSite()
+ .getService(IContextService.class);
+ if (contextService != null)
+ contextService.activateContext(VIEW_ID);
+
+ }
+
private void initRepositoriesAndListeners() {
synchronized (repositories) {
repositories.clear();
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewActionProvider.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewActionProvider.java
deleted file mode 100644
index 9d0cdea5c5..0000000000
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/repository/tree/RepositoriesViewActionProvider.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2010 SAP AG.
- * 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
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mathias Kinzler (SAP AG) - initial implementation
- *******************************************************************************/
-package org.eclipse.egit.ui.internal.repository.tree;
-
-import org.eclipse.core.commands.Command;
-import org.eclipse.core.commands.ExecutionEvent;
-import org.eclipse.egit.ui.Activator;
-import org.eclipse.jface.action.Action;
-import org.eclipse.jface.action.IAction;
-import org.eclipse.jface.viewers.IStructuredSelection;
-import org.eclipse.ui.IActionBars;
-import org.eclipse.ui.PlatformUI;
-import org.eclipse.ui.actions.ActionFactory;
-import org.eclipse.ui.commands.ICommandService;
-import org.eclipse.ui.handlers.IHandlerService;
-import org.eclipse.ui.navigator.CommonActionProvider;
-
-/**
- * Contributes the global actions (copy/paste)
- *
- */
-public class RepositoriesViewActionProvider extends CommonActionProvider {
-
- private IAction copyAction;
-
- private IAction pasteAction;
-
- @Override
- public void fillActionBars(IActionBars actionBars) {
- if (pasteAction == null) {
- pasteAction = new Action("") { //$NON-NLS-1$
-
- @Override
- public void run() {
- IHandlerService srv = (IHandlerService) PlatformUI
- .getWorkbench().getService(IHandlerService.class);
- ICommandService csrv = (ICommandService) PlatformUI
- .getWorkbench().getService(ICommandService.class);
- Command openCommand = csrv
- .getCommand("org.eclipse.egit.ui.RepositoriesViewPaste"); //$NON-NLS-1$
- ExecutionEvent evt = srv.createExecutionEvent(openCommand,
- null);
-
- try {
- openCommand.executeWithChecks(evt);
- } catch (Exception e) {
- Activator.handleError(e.getMessage(), e, true);
- }
- }
-
- };
- }
-
- actionBars.setGlobalActionHandler(ActionFactory.PASTE.getId(),
- pasteAction);
-
- if (copyAction == null) {
- copyAction = new Action("") { //$NON-NLS-1$
-
- @Override
- public void run() {
- IHandlerService srv = (IHandlerService) PlatformUI
- .getWorkbench().getService(IHandlerService.class);
- ICommandService csrv = (ICommandService) PlatformUI
- .getWorkbench().getService(ICommandService.class);
- Command openCommand = csrv
- .getCommand("org.eclipse.egit.ui.RepositoriesViewCopyPath"); //$NON-NLS-1$
- ExecutionEvent evt = srv.createExecutionEvent(openCommand,
- null);
-
- try {
- openCommand.executeWithChecks(evt);
- } catch (Exception e) {
- Activator.handleError(e.getMessage(), e, true);
- }
- }
-
- };
- }
-
- IStructuredSelection sel = (IStructuredSelection) getActionSite()
- .getViewSite().getSelectionProvider().getSelection();
-
- if (sel.size() == 1) {
- RepositoryTreeNode node = (RepositoryTreeNode) sel
- .getFirstElement();
- if (node.getType() == RepositoryTreeNodeType.REPO
- || node.getType() == RepositoryTreeNodeType.FILE
- || node.getType() == RepositoryTreeNodeType.FOLDER) {
- copyAction.setEnabled(true);
- } else if (node.getType() == RepositoryTreeNodeType.WORKINGDIR) {
- boolean isBare = node.getRepository().isBare();
- copyAction.setEnabled(!isBare);
- } else {
- copyAction.setEnabled(false);
- }
- }
-
- actionBars.setGlobalActionHandler(ActionFactory.COPY.getId(),
- copyAction);
- }
-}

Back to the top