mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge branch 'master' of git.labs.intellij.net:idea/community
This commit is contained in:
@@ -248,6 +248,9 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
public void showRunContent(@NotNull final Executor executor, final RunContentDescriptor descriptor) {
|
||||
if(ApplicationManager.getApplication().isUnitTestMode()) return;
|
||||
|
||||
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
|
||||
final boolean wasInActiveWindow = toolWindow != null && toolWindow.isActive();
|
||||
|
||||
final ContentManager contentManager = getContentManagerForRunner(executor);
|
||||
RunContentDescriptor oldDescriptor = chooseReuseContentForDescriptor(contentManager, descriptor);
|
||||
|
||||
@@ -303,8 +306,12 @@ public class RunContentManagerImpl implements RunContentManager, Disposable {
|
||||
|
||||
ApplicationManager.getApplication().invokeLater(new Runnable() {
|
||||
public void run() {
|
||||
final ToolWindow toolWindow = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
|
||||
toolWindow.show(null);
|
||||
ToolWindow window = ToolWindowManager.getInstance(myProject).getToolWindow(executor.getToolWindowId());
|
||||
if (wasInActiveWindow) {
|
||||
window.activate(null, true, false);
|
||||
} else {
|
||||
window.show(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -18,10 +18,7 @@ package com.intellij.internal.psiView;
|
||||
import com.intellij.lang.ASTNode;
|
||||
import com.intellij.lang.Language;
|
||||
import com.intellij.lang.LanguageUtil;
|
||||
import com.intellij.openapi.actionSystem.AnAction;
|
||||
import com.intellij.openapi.actionSystem.AnActionEvent;
|
||||
import com.intellij.openapi.actionSystem.DefaultActionGroup;
|
||||
import com.intellij.openapi.actionSystem.Presentation;
|
||||
import com.intellij.openapi.actionSystem.*;
|
||||
import com.intellij.openapi.actionSystem.ex.ComboBoxAction;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
@@ -59,6 +56,7 @@ import com.intellij.ui.treeStructure.Tree;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import com.intellij.util.ui.tree.TreeUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
@@ -76,7 +74,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author Konstantin Bulenkov
|
||||
*/
|
||||
public class PsiViewerDialog extends DialogWrapper {
|
||||
public class PsiViewerDialog extends DialogWrapper implements DataProvider {
|
||||
private final Project myProject;
|
||||
|
||||
private final Tree myTree;
|
||||
@@ -479,6 +477,36 @@ public class PsiViewerDialog extends DialogWrapper {
|
||||
myTree.setRootVisible(false);
|
||||
}
|
||||
|
||||
public Object getData(@NonNls String dataId) {
|
||||
if (PlatformDataKeys.NAVIGATABLE.is(dataId)) {
|
||||
String fqn = null;
|
||||
if (myTree.hasFocus()) {
|
||||
final TreePath path = myTree.getSelectionPath();
|
||||
if (path != null) {
|
||||
DefaultMutableTreeNode node = (DefaultMutableTreeNode)path.getLastPathComponent();
|
||||
if (!(node.getUserObject() instanceof ViewerNodeDescriptor)) return null;
|
||||
ViewerNodeDescriptor descriptor = (ViewerNodeDescriptor)node.getUserObject();
|
||||
Object elementObject = descriptor.getElement();
|
||||
final PsiElement element = elementObject instanceof PsiElement
|
||||
? (PsiElement)elementObject
|
||||
: elementObject instanceof ASTNode ? ((ASTNode)elementObject).getPsi() : null;
|
||||
if (element != null) {
|
||||
fqn = element.getClass().getName();
|
||||
}
|
||||
}
|
||||
} else if (myRefs.hasFocus()) {
|
||||
final Object value = myRefs.getSelectedValue();
|
||||
if (value instanceof String) {
|
||||
fqn = (String)value;
|
||||
}
|
||||
}
|
||||
if (fqn != null) {
|
||||
return getContainingFileForClass(fqn);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private class MyTreeSelectionListener implements TreeSelectionListener {
|
||||
private final TextAttributes myAttributes;
|
||||
|
||||
@@ -518,7 +546,7 @@ public class PsiViewerDialog extends DialogWrapper {
|
||||
final int textLength = myEditor.getDocument().getTextLength();
|
||||
if (end <= textLength) {
|
||||
myEditor.getMarkupModel()
|
||||
.addRangeHighlighter(start, end, HighlighterLayer.FIRST + 1, myAttributes, HighlighterTargetArea.EXACT_RANGE);
|
||||
.addRangeHighlighter(start, end, HighlighterLayer.LAST, myAttributes, HighlighterTargetArea.EXACT_RANGE);
|
||||
if (myTree.hasFocus()) {
|
||||
myEditor.getCaretModel().moveToOffset(start);
|
||||
myEditor.getScrollingModel().scrollToCaret(ScrollType.MAKE_VISIBLE);
|
||||
@@ -594,6 +622,24 @@ public class PsiViewerDialog extends DialogWrapper {
|
||||
return index >= elements.length ? null : elements[index];
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private PsiFile getContainingFileForClass(String fqn) {
|
||||
String filename = fqn;
|
||||
if (fqn.contains(".")) {
|
||||
filename = fqn.substring(fqn.lastIndexOf('.') + 1);
|
||||
}
|
||||
if (filename.contains("$")) {
|
||||
filename = filename.substring(0, filename.indexOf('$'));
|
||||
}
|
||||
filename += ".java";
|
||||
final PsiFile[] files = FilenameIndex.getFilesByName(myProject, filename, GlobalSearchScope.allScope(myProject));
|
||||
if (files != null && files.length > 0) {
|
||||
return files[0];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public static TreeNode findNodeWithObject(final Object object, final TreeModel model, final Object parent) {
|
||||
for (int i = 0; i < model.getChildCount(parent); i++) {
|
||||
@@ -637,18 +683,8 @@ public class PsiViewerDialog extends DialogWrapper {
|
||||
final Object value = myRefs.getSelectedValue();
|
||||
if (value instanceof String) {
|
||||
final String fqn = (String)value;
|
||||
String filename = fqn;
|
||||
if (fqn.contains(".")) {
|
||||
filename = fqn.substring(fqn.lastIndexOf('.') + 1);
|
||||
}
|
||||
if (filename.contains("$")) {
|
||||
filename = filename.substring(0, filename.indexOf('$'));
|
||||
}
|
||||
filename += ".java";
|
||||
final PsiFile[] files = FilenameIndex.getFilesByName(myProject, filename, GlobalSearchScope.allScope(myProject));
|
||||
if (files != null && files.length > 0) {
|
||||
files[0].navigate(true);
|
||||
}
|
||||
final PsiFile file = getContainingFileForClass(fqn);
|
||||
if (file != null) file.navigate(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ actionSystem.playback.useTypingTargets=true
|
||||
actionSystem.focusIdleTimeout=20
|
||||
actionSystem.mac.screenMenuNotUpdatedFix=false
|
||||
actionSystem.keyGestures.enabled=false
|
||||
actionSystem.suspendFocusTransferIfApplicationInactive=false
|
||||
actionSystem.suspendFocusTransferIfApplicationInactive=true
|
||||
actionSystem.noContextComponentWhileFocusTransfer=true
|
||||
|
||||
ide.debugMode=true
|
||||
|
||||
Reference in New Issue
Block a user