aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernard Leach2011-05-14 19:35:06 (EDT)
committerMatthias Sohn2011-05-14 19:35:06 (EDT)
commit4df5e51b9583a5a34cfdfaa3170c52e8ae011f04 (patch)
treeea371e2cdb0b17c92a35e04d08810d382de941ef
parentef315c114e60b344f8c8c810861f849974dfaffe (diff)
downloadegit-4df5e51b9583a5a34cfdfaa3170c52e8ae011f04.zip
egit-4df5e51b9583a5a34cfdfaa3170c52e8ae011f04.tar.gz
egit-4df5e51b9583a5a34cfdfaa3170c52e8ae011f04.tar.bz2
Implement double-click to open compare editor in staging viewrefs/changes/55/3355/5
Change-Id: Ie6964a732c2299a4ba363364e87bbad4ba21b0c0 Signed-off-by: Matthias Sohn <matthias.sohn@sap.com>
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java13
-rw-r--r--org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java39
2 files changed, 43 insertions, 9 deletions
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
index 2e9b414..38b399c 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingEntry.java
@@ -8,12 +8,12 @@
*******************************************************************************/
package org.eclipse.egit.ui.internal.staging;
-import org.eclipse.core.resources.IContainer;
import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.IAdaptable;
-import org.eclipse.egit.core.IteratorService;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
import org.eclipse.jgit.lib.Repository;
@@ -77,13 +77,10 @@ public class StagingEntry implements IAdaptable {
public Object getAdapter(Class adapter) {
if (adapter == IResource.class) {
+ IPath absolutePath = new Path(repository.getWorkTree().getAbsolutePath()).append(path);
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
-
- IContainer findContainer = IteratorService.findContainer(root, repository.getWorkTree());
- if (findContainer != null) {
- IResource findMember = findContainer.findMember(path);
- return findMember;
- }
+ IResource resource = root.getFileForLocation(absolutePath);
+ return resource;
}
return null;
}
diff --git a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
index fee079f..264e8d4 100644
--- a/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
+++ b/org.eclipse.egit.ui/src/org/eclipse/egit/ui/internal/staging/StagingView.java
@@ -29,13 +29,16 @@ import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.egit.core.project.RepositoryMapping;
import org.eclipse.egit.ui.Activator;
import org.eclipse.egit.ui.UIText;
+import org.eclipse.egit.ui.internal.actions.ActionCommands;
import org.eclipse.egit.ui.internal.dialogs.SpellcheckableMessageArea;
import org.eclipse.egit.ui.internal.repository.tree.RepositoryTreeNode;
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.jface.layout.TableColumnLayout;
import org.eclipse.jface.util.LocalSelectionTransfer;
+import org.eclipse.jface.viewers.IOpenListener;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.OpenEvent;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.jface.viewers.TableViewer;
import org.eclipse.jgit.events.IndexChangedEvent;
@@ -161,6 +164,11 @@ public class StagingView extends ViewPart {
event.detail = DND.DROP_MOVE;
}
});
+ unstagedTableViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ compareWith(event);
+ }
+ });
Composite commitMessageComposite = new Composite(horizontalSashForm, SWT.NONE);
commitMessageComposite.setLayout(new GridLayout(2, false));
@@ -239,6 +247,11 @@ public class StagingView extends ViewPart {
event.detail = DND.DROP_MOVE;
}
});
+ stagedTableViewer.addOpenListener(new IOpenListener() {
+ public void open(OpenEvent event) {
+ compareWith(event);
+ }
+ });
selectionChangedListener = new ISelectionListener() {
public void selectionChanged(IWorkbenchPart part,
@@ -268,6 +281,29 @@ public class StagingView extends ViewPart {
getSite().setSelectionProvider(unstagedTableViewer);
}
+ private void compareWith(OpenEvent event) {
+ IStructuredSelection selection = (IStructuredSelection) event.getSelection();
+ if (selection.isEmpty())
+ return;
+ StagingEntry stagingEntry = (StagingEntry) selection.getFirstElement();
+ switch (stagingEntry.getState()) {
+ case ADDED:
+ case CHANGED:
+ case REMOVED:
+ runCommand(ActionCommands.COMPARE_INDEX_WITH_HEAD_ACTION, selection);
+ break;
+
+ case MISSING:
+ case MODIFIED:
+ case PARTIALLY_MODIFIED:
+ case CONFLICTING:
+ case UNTRACKED:
+ default:
+ // compare with index
+ runCommand(ActionCommands.COMPARE_WITH_INDEX_ACTION, selection);
+ }
+ }
+
private void reactOnSelection(ISelection selection) {
if (selection instanceof StructuredSelection) {
StructuredSelection ssel = (StructuredSelection) selection;
@@ -311,7 +347,7 @@ public class StagingView extends ViewPart {
}
private void stage(IStructuredSelection selection) {
- runCommand("org.eclipse.egit.ui.team.AddToIndex", selection); //$NON-NLS-1$
+ runCommand(ActionCommands.ADD_TO_INDEX, selection);
}
private void unstage(IStructuredSelection selection) {
@@ -333,6 +369,7 @@ public class StagingView extends ViewPart {
c = new EvaluationContext(handlerService
.createContextSnapshot(false), selection.toList());
c.addVariable(ISources.ACTIVE_CURRENT_SELECTION_NAME, selection);
+ c.removeVariable(ISources.ACTIVE_MENU_SELECTION_NAME);
}
try {
if (c != null) {