IDEA-85810 vcs: allow to assign shortcut on 'show current change popup'
authorAleksey Pivovarov <AMPivovarov@gmail.com>
Fri, 6 Feb 2015 09:15:19 +0000 (12:15 +0300)
committerAleksey Pivovarov <AMPivovarov@gmail.com>
Fri, 6 Feb 2015 10:29:03 +0000 (13:29 +0300)
platform/platform-resources-en/src/messages/ActionsBundle.properties
platform/platform-resources/src/idea/VcsActions.xml
platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCurrentChangeMarkerAction.java [new file with mode: 0644]
platform/vcs-impl/src/com/intellij/openapi/vcs/ex/LineStatusTrackerDrawing.java

index 86a59d14664d0a8c49ca5ea9ad3735040c572e39..e74333c58c503701b7f9c341340255ee2af8e769 100644 (file)
@@ -504,6 +504,8 @@ action.PreviousOccurence.text=Previ_ous Occurrence
 action.PreviousOccurence.description=Navigate to the previous occurrence
 action.NextOccurence.text=Ne_xt Occurrence
 action.NextOccurence.description=Navigate to the next occurrence
 action.PreviousOccurence.description=Navigate to the previous occurrence
 action.NextOccurence.text=Ne_xt Occurrence
 action.NextOccurence.description=Navigate to the next occurrence
+action.VcsShowCurrentChangeMarker.text=C_hange under caret
+action.VcsShowCurrentChangeMarker.description=Show popup for currently selected change
 action.VcsShowNextChangeMarker.text=Next C_hange
 action.VcsShowNextChangeMarker.description=Go to next change
 action.VcsShowPrevChangeMarker.text=Previous Ch_ange
 action.VcsShowNextChangeMarker.text=Next C_hange
 action.VcsShowNextChangeMarker.description=Go to next change
 action.VcsShowPrevChangeMarker.text=Previous Ch_ange
index 8e9ed0e9f90f1824168c2dbd47ad7c27b353f67d..fcbc746c0a0a74b0c080a0df1a8bcf7c0942385c 100644 (file)
@@ -36,6 +36,7 @@
 
       <add-to-group group-id="GoToMenu" anchor="last"/>
     </group>
 
       <add-to-group group-id="GoToMenu" anchor="last"/>
     </group>
+    <action id="VcsShowCurrentChangeMarker" class="com.intellij.openapi.vcs.actions.ShowCurrentChangeMarkerAction"/>
 
     <!-- Main menu | Version Control -->
     <group id="VcsGroups" popup="true">
 
     <!-- Main menu | Version Control -->
     <group id="VcsGroups" popup="true">
@@ -89,7 +90,7 @@
       <action id="ChangesView.Diff" class="com.intellij.openapi.vcs.changes.actions.diff.ShowDiffAction"
               icon="AllIcons.Actions.Diff"/>
     </group>
       <action id="ChangesView.Diff" class="com.intellij.openapi.vcs.changes.actions.diff.ShowDiffAction"
               icon="AllIcons.Actions.Diff"/>
     </group>
-    
+
     <group id="AlienCommitChangesDialog.AdditionalActions"/>
 
     <group id="ChangesViewPopupMenu">
     <group id="AlienCommitChangesDialog.AdditionalActions"/>
 
     <group id="ChangesViewPopupMenu">
       <action id="CommittedChanges.Clear" class="com.intellij.openapi.vcs.changes.committed.ClearCommittedAction"
               icon="AllIcons.Vcs.Remove"/>
     </group>
       <action id="CommittedChanges.Clear" class="com.intellij.openapi.vcs.changes.committed.ClearCommittedAction"
               icon="AllIcons.Vcs.Remove"/>
     </group>
-    
+
     <group id="RepositoryChangesBrowserToolbar">
     </group>
 
     <group id="RepositoryChangesBrowserToolbar">
     </group>
 
diff --git a/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCurrentChangeMarkerAction.java b/platform/vcs-impl/src/com/intellij/openapi/vcs/actions/ShowCurrentChangeMarkerAction.java
new file mode 100644 (file)
index 0000000..0deb6eb
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2000-2015 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.openapi.vcs.actions;
+
+import com.intellij.openapi.editor.Editor;
+import com.intellij.openapi.vcs.ex.LineStatusTracker;
+import com.intellij.openapi.vcs.ex.LineStatusTrackerDrawing;
+import com.intellij.openapi.vcs.ex.Range;
+import org.jetbrains.annotations.NotNull;
+
+public class ShowCurrentChangeMarkerAction extends ShowChangeMarkerAction {
+
+  public ShowCurrentChangeMarkerAction(final Range range, final LineStatusTracker lineStatusTracker, final Editor editor) {
+    super(range, lineStatusTracker, editor);
+  }
+
+  public ShowCurrentChangeMarkerAction() {
+  }
+
+  protected Range extractRange(LineStatusTracker lineStatusTracker, int line, Editor editor) {
+    return lineStatusTracker.getRangeForLine(line);
+  }
+
+  @Override
+  protected void actionPerformed(@NotNull VcsContext context) {
+    Editor editor = myChangeMarkerContext.getEditor(context);
+    LineStatusTracker lineStatusTracker = myChangeMarkerContext.getLineStatusTracker(context);
+    Range range = myChangeMarkerContext.getRange(context);
+
+
+    LineStatusTrackerDrawing.showHint(range, editor, lineStatusTracker);
+  }
+}
index 8e44d9b960ea3778c89758d6a2e5bb9c4da9c0c0..4e8962494f08d5bbbb85c5c47fe74910c9dd50ba 100644 (file)
@@ -306,9 +306,13 @@ public class LineStatusTrackerDrawing {
     editor.getCaretModel().moveToOffset(lastOffset);
     editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
 
     editor.getCaretModel().moveToOffset(lastOffset);
     editor.getScrollingModel().scrollToCaret(ScrollType.CENTER);
 
+    showHint(range, editor, tracker);
+  }
+
+  public static void showHint(final Range range, final Editor editor, final LineStatusTracker tracker) {
     editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
       public void run() {
     editor.getScrollingModel().runActionOnScrollingFinished(new Runnable() {
       public void run() {
-        Point p = editor.visualPositionToXY(editor.offsetToVisualPosition(lastOffset));
+        Point p = editor.visualPositionToXY(editor.getCaretModel().getVisualPosition());
         final JComponent editorComponent = editor.getContentComponent();
         final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
         p = SwingUtilities.convertPoint(editorComponent, 0, p.y, layeredPane);
         final JComponent editorComponent = editor.getContentComponent();
         final JLayeredPane layeredPane = editorComponent.getRootPane().getLayeredPane();
         p = SwingUtilities.convertPoint(editorComponent, 0, p.y, layeredPane);