mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
package com.intellij.codeInsight.intention.impl;
|
||||
|
||||
import com.intellij.codeInsight.editorActions.FixDocCommentAction;
|
||||
import com.intellij.codeInsight.intention.LowPriorityAction;
|
||||
import com.intellij.codeInsight.intention.PsiElementBaseIntentionAction;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -26,7 +27,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
/**
|
||||
* @author Dmitry Batkovich
|
||||
*/
|
||||
public class AddJavadocIntention extends PsiElementBaseIntentionAction {
|
||||
public class AddJavadocIntention extends PsiElementBaseIntentionAction implements LowPriorityAction {
|
||||
@Override
|
||||
public void invoke(@NotNull final Project project, final Editor editor, @NotNull final PsiElement element) throws IncorrectOperationException {
|
||||
final PsiDocCommentOwner docCommentOwner = (PsiDocCommentOwner)element.getParent();
|
||||
|
||||
@@ -348,6 +348,9 @@ public class JavaFindUsagesHandler extends FindUsagesHandler{
|
||||
}
|
||||
else if (classOptions.isImplementingClasses){
|
||||
if (!addImplementingClasses(psiClass, processor, classOptions)) return false;
|
||||
}
|
||||
|
||||
if (classOptions.isImplementingClasses) {
|
||||
FunctionalExpressionSearch.search(psiClass, classOptions.searchScope).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>(
|
||||
new PsiElementProcessor<PsiFunctionalExpression>() {
|
||||
@Override
|
||||
|
||||
@@ -23,15 +23,15 @@ import com.intellij.refactoring.HelpID;
|
||||
import com.intellij.refactoring.JavaRefactoringSettings;
|
||||
import com.intellij.refactoring.RefactoringBundle;
|
||||
|
||||
public class InlineLocalDialog extends InlineOptionsDialog {
|
||||
public class InlineLocalDialog extends AbstractInlineLocalDialog {
|
||||
public static final String REFACTORING_NAME = RefactoringBundle.message("inline.method.title");
|
||||
|
||||
private final PsiVariable myVariable;
|
||||
|
||||
private int myOccurrencesNumber = -1;
|
||||
|
||||
public InlineLocalDialog(Project project, PsiVariable variable, PsiJavaCodeReferenceElement ref, int occurrencesCount) {
|
||||
super(project, true, variable);
|
||||
public InlineLocalDialog(Project project, PsiVariable variable, final PsiJavaCodeReferenceElement ref, int occurrencesCount) {
|
||||
super(project, variable, ref, occurrencesCount);
|
||||
myVariable = variable;
|
||||
myInvokedOnReference = ref != null;
|
||||
|
||||
|
||||
@@ -26,6 +26,7 @@ import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.editor.colors.EditorColors;
|
||||
import com.intellij.openapi.editor.colors.EditorColorsManager;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.editor.markup.TextAttributes;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
@@ -147,15 +148,18 @@ public class InlineLocalHandler extends JavaInlineActionHandler {
|
||||
final Ref<Boolean> inlineAll = new Ref<Boolean>(true);
|
||||
if (editor != null && !ApplicationManager.getApplication().isUnitTestMode()) {
|
||||
int occurrencesCount = refsToInlineList.size();
|
||||
final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount);
|
||||
inlineLocalDialog.show();
|
||||
if (!inlineLocalDialog.isOK()){
|
||||
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
|
||||
return;
|
||||
}
|
||||
if (refExpr != null && inlineLocalDialog.isInlineThis()) {
|
||||
refsToInlineList = Collections.<PsiElement>singletonList(refExpr);
|
||||
inlineAll.set(false);
|
||||
if (refExpr != null && occurrencesCount > 1 || EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog()) {
|
||||
final InlineLocalDialog inlineLocalDialog = new InlineLocalDialog(project, local, refExpr, occurrencesCount);
|
||||
inlineLocalDialog.show();
|
||||
if (!inlineLocalDialog.isOK()){
|
||||
WindowManager.getInstance().getStatusBar(project).setInfo(RefactoringBundle.message("press.escape.to.remove.the.highlighting"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (refExpr != null && inlineLocalDialog.isInlineThis()) {
|
||||
refsToInlineList = Collections.<PsiElement>singletonList(refExpr);
|
||||
inlineAll.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-1
@@ -417,7 +417,7 @@
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="70a4f" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<grid id="70a4f" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
@@ -444,6 +444,14 @@
|
||||
<text resource-bundle="messages/ApplicationBundle" key="checkbox.rename.local.variables.preselect"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="b2798" class="javax.swing.JCheckBox" binding="myShowInlineDialogForCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Show inline dialog for local variables"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="62a96" layout-manager="GridLayoutManager" row-count="1" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
|
||||
@@ -97,6 +97,7 @@ public class EditorOptionsPanel {
|
||||
private JBLabel myQuickDocDelayLabel;
|
||||
private JTextField myQuickDocDelayTextField;
|
||||
private JComboBox myRichCopyColorSchemeComboBox;
|
||||
private JCheckBox myShowInlineDialogForCheckBox;
|
||||
|
||||
private static final String ACTIVE_COLOR_SCHEME = ApplicationBundle.message("combobox.richcopy.color.scheme.active");
|
||||
|
||||
@@ -206,6 +207,7 @@ public class EditorOptionsPanel {
|
||||
|
||||
myCbRenameLocalVariablesInplace.setSelected(editorSettings.isVariableInplaceRenameEnabled());
|
||||
myPreselectCheckBox.setSelected(editorSettings.isPreselectRename());
|
||||
myShowInlineDialogForCheckBox.setSelected(editorSettings.isShowInlineLocalDialog());
|
||||
|
||||
myShowReformatCodeDialogCheckBox.setSelected(editorSettings.getOptions().SHOW_REFORMAT_DIALOG);
|
||||
myShowOptimizeImportsDialogCheckBox.setSelected(editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG);
|
||||
@@ -301,6 +303,7 @@ public class EditorOptionsPanel {
|
||||
|
||||
editorSettings.setVariableInplaceRenameEnabled(myCbRenameLocalVariablesInplace.isSelected());
|
||||
editorSettings.setPreselectRename(myPreselectCheckBox.isSelected());
|
||||
editorSettings.setShowInlineLocalDialog(myShowInlineDialogForCheckBox.isSelected());
|
||||
|
||||
editorSettings.getOptions().SHOW_REFORMAT_DIALOG = myShowReformatCodeDialogCheckBox.isSelected();
|
||||
editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG = myShowOptimizeImportsDialogCheckBox.isSelected();
|
||||
@@ -442,6 +445,7 @@ public class EditorOptionsPanel {
|
||||
isModified |= isModified(myCommandsHistoryLimitField, UISettings.getInstance().CONSOLE_COMMAND_HISTORY_LIMIT);
|
||||
isModified |= isModified(myCbRenameLocalVariablesInplace, editorSettings.isVariableInplaceRenameEnabled());
|
||||
isModified |= isModified(myPreselectCheckBox, editorSettings.isPreselectRename());
|
||||
isModified |= isModified(myShowInlineDialogForCheckBox, editorSettings.isShowInlineLocalDialog());
|
||||
|
||||
isModified |= isModified(myShowReformatCodeDialogCheckBox, editorSettings.getOptions().SHOW_REFORMAT_DIALOG);
|
||||
isModified |= isModified(myShowOptimizeImportsDialogCheckBox, editorSettings.getOptions().SHOW_OPIMIZE_IMPORTS_DIALOG);
|
||||
|
||||
+16
-6
@@ -40,6 +40,7 @@ import com.intellij.openapi.options.FontSize;
|
||||
import com.intellij.openapi.ui.popup.JBPopup;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.wm.ex.WindowManagerEx;
|
||||
import com.intellij.pom.Navigatable;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -65,6 +66,7 @@ import javax.swing.event.HyperlinkListener;
|
||||
import javax.swing.text.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Stack;
|
||||
@@ -98,6 +100,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
private final JComponent mySettingsPanel;
|
||||
private final MyShowSettingsButton myShowSettingsButton;
|
||||
private boolean myIgnoreFontSizeSliderChange;
|
||||
private String myEffectiveExternalUrl;
|
||||
|
||||
private static class Context {
|
||||
final SmartPsiElementPointer element;
|
||||
@@ -461,7 +464,7 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
myForwardStack.clear();
|
||||
}
|
||||
updateControlState();
|
||||
setData(element, text, clearHistory);
|
||||
setData(element, text, clearHistory, null);
|
||||
if (clean) {
|
||||
myIsEmpty = false;
|
||||
}
|
||||
@@ -480,7 +483,8 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
myBackStack.clear();
|
||||
}
|
||||
|
||||
public void setData(PsiElement _element, String text, final boolean clearHistory) {
|
||||
public void setData(PsiElement _element, String text, final boolean clearHistory, String effectiveExternalUrl) {
|
||||
myEffectiveExternalUrl = effectiveExternalUrl;
|
||||
if (myElement != null) {
|
||||
myBackStack.push(saveContext());
|
||||
myForwardStack.clear();
|
||||
@@ -683,10 +687,16 @@ public class DocumentationComponent extends JPanel implements Disposable, DataPr
|
||||
}
|
||||
|
||||
if (!processed) {
|
||||
final List<String> urls = provider.getUrlFor(element, originalElement);
|
||||
assert urls != null : provider;
|
||||
assert !urls.isEmpty() : provider;
|
||||
ExternalJavaDocAction.showExternalJavadoc(urls);
|
||||
final Component component = PlatformDataKeys.CONTEXT_COMPONENT.getData(e.getDataContext());
|
||||
final List<String> urls;
|
||||
if (!StringUtil.isEmptyOrSpaces(myEffectiveExternalUrl)) {
|
||||
urls = Collections.singletonList(myEffectiveExternalUrl);
|
||||
} else {
|
||||
urls = provider.getUrlFor(element, originalElement);
|
||||
assert urls != null : provider;
|
||||
assert !urls.isEmpty() : provider;
|
||||
}
|
||||
ExternalJavaDocAction.showExternalJavadoc(urls, component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+131
-94
@@ -615,99 +615,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
}
|
||||
|
||||
private DocumentationCollector getDefaultCollector(@NotNull final PsiElement element, @Nullable final PsiElement originalElement) {
|
||||
return new DocumentationCollector() {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getDocumentation() throws Exception {
|
||||
final DocumentationProvider provider = ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<DocumentationProvider>() {
|
||||
@Override
|
||||
public DocumentationProvider compute() {
|
||||
return getProviderFromElement(element, originalElement);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (myParameterInfoController != null) {
|
||||
final String doc = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return generateParameterInfoDocumentation(provider);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (doc != null) return doc;
|
||||
}
|
||||
if (provider instanceof ExternalDocumentationProvider) {
|
||||
final List<String> urls = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<List<String>>() {
|
||||
@Override
|
||||
public List<String> compute() {
|
||||
final SmartPsiElementPointer originalElementPtr = element.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
final PsiElement originalElement = originalElementPtr != null ? originalElementPtr.getElement() : null;
|
||||
if (((ExternalDocumentationProvider)provider).hasDocumentationFor(element, originalElement)) {
|
||||
return provider.getUrlFor(element, originalElement);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
if (urls != null) {
|
||||
final String doc = ((ExternalDocumentationProvider)provider).fetchExternalDocumentation(myProject, element, urls);
|
||||
if (doc != null) return doc;
|
||||
}
|
||||
}
|
||||
return ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<String>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public String compute() {
|
||||
final SmartPsiElementPointer originalElement = element.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
return provider.generateDoc(element, originalElement != null ? originalElement.getElement() : null);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String generateParameterInfoDocumentation(DocumentationProvider provider) {
|
||||
final Object[] objects = myParameterInfoController.getSelectedElements();
|
||||
|
||||
if (objects.length > 0) {
|
||||
@NonNls StringBuffer sb = null;
|
||||
|
||||
for (Object o : objects) {
|
||||
PsiElement parameter = null;
|
||||
if (o instanceof PsiElement) {
|
||||
parameter = (PsiElement)o;
|
||||
}
|
||||
|
||||
if (parameter != null) {
|
||||
final SmartPsiElementPointer originalElement = parameter.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
final String str2 = provider.generateDoc(parameter, originalElement != null ? originalElement.getElement() : null);
|
||||
if (str2 == null) continue;
|
||||
if (sb == null) sb = new StringBuffer();
|
||||
sb.append(str2);
|
||||
sb.append("<br>");
|
||||
}
|
||||
else {
|
||||
sb = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sb != null) return sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement getElement() {
|
||||
return element.isValid() ? element : null;
|
||||
}
|
||||
};
|
||||
return new DefaultDocumentationCollector(element, originalElement);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -813,7 +721,7 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
component.setText(component.getText(), element, true, clearHistory);
|
||||
}
|
||||
else {
|
||||
component.setData(element, documentationText, clearHistory);
|
||||
component.setData(element, documentationText, clearHistory, provider.getEffectiveExternalUrl());
|
||||
}
|
||||
|
||||
final AbstractPopup jbPopup = (AbstractPopup)getDocInfoHint();
|
||||
@@ -945,6 +853,12 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
public PsiElement getElement() {
|
||||
return psiElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getEffectiveExternalUrl() {
|
||||
return url;
|
||||
}
|
||||
}, component);
|
||||
processed = true;
|
||||
}
|
||||
@@ -992,6 +906,12 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
|
||||
return psiElement;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getEffectiveExternalUrl() {
|
||||
return url;
|
||||
}
|
||||
}, component);
|
||||
}
|
||||
}
|
||||
@@ -1062,5 +982,122 @@ public class DocumentationManager extends DockablePopupManager<DocumentationComp
|
||||
String getDocumentation() throws Exception;
|
||||
@Nullable
|
||||
PsiElement getElement();
|
||||
@Nullable
|
||||
String getEffectiveExternalUrl();
|
||||
}
|
||||
|
||||
private class DefaultDocumentationCollector implements DocumentationCollector {
|
||||
|
||||
private final PsiElement myElement;
|
||||
private final PsiElement myOriginalElement;
|
||||
|
||||
private String myEffectiveUrl;
|
||||
|
||||
public DefaultDocumentationCollector(PsiElement element, PsiElement originalElement) {
|
||||
myElement = element;
|
||||
myOriginalElement = originalElement;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public String getDocumentation() throws Exception {
|
||||
final DocumentationProvider provider = ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<DocumentationProvider>() {
|
||||
@Override
|
||||
public DocumentationProvider compute() {
|
||||
return getProviderFromElement(myElement, myOriginalElement);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (myParameterInfoController != null) {
|
||||
final String doc = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<String>() {
|
||||
@Override
|
||||
public String compute() {
|
||||
return generateParameterInfoDocumentation(provider);
|
||||
}
|
||||
}
|
||||
);
|
||||
if (doc != null) return doc;
|
||||
}
|
||||
if (provider instanceof ExternalDocumentationProvider) {
|
||||
final List<String> urls = ApplicationManager.getApplication().runReadAction(
|
||||
new NullableComputable<List<String>>() {
|
||||
@Override
|
||||
public List<String> compute() {
|
||||
final SmartPsiElementPointer originalElementPtr = myElement.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
final PsiElement originalElement = originalElementPtr != null ? originalElementPtr.getElement() : null;
|
||||
if (((ExternalDocumentationProvider)provider).hasDocumentationFor(myElement, originalElement)) {
|
||||
return provider.getUrlFor(myElement, originalElement);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
);
|
||||
if (urls != null) {
|
||||
for (String url : urls) {
|
||||
final String doc = ((ExternalDocumentationProvider)provider).fetchExternalDocumentation(myProject, myElement, Collections.singletonList(url));
|
||||
if (doc != null) {
|
||||
myEffectiveUrl = url;
|
||||
return doc;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return ApplicationManager.getApplication().runReadAction(
|
||||
new Computable<String>() {
|
||||
@Override
|
||||
@Nullable
|
||||
public String compute() {
|
||||
final SmartPsiElementPointer originalElement = myElement.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
return provider.generateDoc(myElement, originalElement != null ? originalElement.getElement() : null);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private String generateParameterInfoDocumentation(DocumentationProvider provider) {
|
||||
final Object[] objects = myParameterInfoController.getSelectedElements();
|
||||
|
||||
if (objects.length > 0) {
|
||||
@NonNls StringBuffer sb = null;
|
||||
|
||||
for (Object o : objects) {
|
||||
PsiElement parameter = null;
|
||||
if (o instanceof PsiElement) {
|
||||
parameter = (PsiElement)o;
|
||||
}
|
||||
|
||||
if (parameter != null) {
|
||||
final SmartPsiElementPointer originalElement = parameter.getUserData(ORIGINAL_ELEMENT_KEY);
|
||||
final String str2 = provider.generateDoc(parameter, originalElement != null ? originalElement.getElement() : null);
|
||||
if (str2 == null) continue;
|
||||
if (sb == null) sb = new StringBuffer();
|
||||
sb.append(str2);
|
||||
sb.append("<br>");
|
||||
}
|
||||
else {
|
||||
sb = null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (sb != null) return sb.toString();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public PsiElement getElement() {
|
||||
return myElement.isValid() ? myElement : null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
public String getEffectiveExternalUrl() {
|
||||
return myEffectiveUrl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,6 +37,7 @@ import com.intellij.psi.PsiReference;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.awt.*;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
@@ -79,7 +80,7 @@ public class ExternalJavaDocAction extends AnAction {
|
||||
|
||||
final List<String> urls = provider.getUrlFor(element, originalElement);
|
||||
if (urls != null && !urls.isEmpty()) {
|
||||
showExternalJavadoc(urls);
|
||||
showExternalJavadoc(urls, PlatformDataKeys.CONTEXT_COMPONENT.getData(dataContext));
|
||||
}
|
||||
else if (provider instanceof ExternalDocumentationProvider) {
|
||||
final ExternalDocumentationProvider externalDocumentationProvider = (ExternalDocumentationProvider)provider;
|
||||
@@ -89,7 +90,7 @@ public class ExternalJavaDocAction extends AnAction {
|
||||
}
|
||||
}
|
||||
|
||||
public static void showExternalJavadoc(List<String> urls) {
|
||||
public static void showExternalJavadoc(List<String> urls, Component component) {
|
||||
final HashSet<String> set = new HashSet<String>(urls);
|
||||
if (set.size() > 1) {
|
||||
JBPopupFactory.getInstance().createListPopup(new BaseListPopupStep<String>("Choose external documentation root", ArrayUtil.toStringArray(set)) {
|
||||
@@ -98,7 +99,7 @@ public class ExternalJavaDocAction extends AnAction {
|
||||
BrowserUtil.browse(selectedValue);
|
||||
return FINAL_CHOICE;
|
||||
}
|
||||
}).showInBestPositionFor(DataManager.getInstance().getDataContext());
|
||||
}).showInBestPositionFor(DataManager.getInstance().getDataContext(component));
|
||||
}
|
||||
else if (set.size() == 1) {
|
||||
BrowserUtil.browse(urls.get(0));
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
/*
|
||||
* Copyright 2000-2014 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.refactoring.inline;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import com.intellij.openapi.editor.ex.EditorSettingsExternalizable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiReference;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class AbstractInlineLocalDialog extends InlineOptionsDialog {
|
||||
public AbstractInlineLocalDialog(Project project, PsiElement variable, final PsiReference ref, int occurrencesCount) {
|
||||
super(project, true, variable);
|
||||
if (ref == null || occurrencesCount == 1) {
|
||||
setDoNotAskOption(new DoNotAskOption() {
|
||||
@Override
|
||||
public boolean isToBeShown() {
|
||||
return EditorSettingsExternalizable.getInstance().isShowInlineLocalDialog();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setToBeShown(boolean value, int exitCode) {
|
||||
EditorSettingsExternalizable.getInstance().setShowInlineLocalDialog(value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBeHidden() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldSaveOptionsOnCancel() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getDoNotShowMessage() {
|
||||
return CommonBundle.message("dialog.options.do.not.show");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
+12
@@ -73,6 +73,8 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex
|
||||
|
||||
public boolean RENAME_VARIABLES_INPLACE = true;
|
||||
public boolean PRESELECT_RENAME = true;
|
||||
public boolean SHOW_INLINE_DIALOG = true;
|
||||
|
||||
public boolean REFRAIN_FROM_SCROLLING = false;
|
||||
|
||||
public boolean SHOW_REFORMAT_DIALOG = true;
|
||||
@@ -522,4 +524,14 @@ public class EditorSettingsExternalizable implements NamedJDOMExternalizable, Ex
|
||||
public void setPreselectRename(final boolean val) {
|
||||
myOptions.PRESELECT_RENAME = val;
|
||||
}
|
||||
|
||||
public boolean isShowInlineLocalDialog() {
|
||||
return myOptions.SHOW_INLINE_DIALOG;
|
||||
}
|
||||
|
||||
public void setShowInlineLocalDialog(final boolean val) {
|
||||
myOptions.SHOW_INLINE_DIALOG = val;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user