本文整理汇总了Java中com.intellij.codeInsight.hint.HintManager类的典型用法代码示例。如果您正苦于以下问题:Java HintManager类的具体用法?Java HintManager怎么用?Java HintManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HintManager类属于com.intellij.codeInsight.hint包,在下文中一共展示了HintManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: invoke
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public void invoke(@NotNull Project project, Editor editor, PsiFile file) throws IncorrectOperationException {
List<String> refComponents = Arrays.asList(referenceNameToFix.split(Pattern.quote(".")));
List<ElmImportCandidate> candidates = findCandidates(project, refComponents);
if (candidates.isEmpty()) {
HintManager.getInstance().showErrorHint(editor, "No module exporting '" + referenceNameToFix + "' found");
} else if (candidates.size() == 1) {
ElmImportCandidate candidate = candidates.get(0);
fixWithCandidate(project, (ElmFile) file, refComponents, candidate);
} else {
List<ElmImportCandidate> sortedCandidates = new ArrayList<>(candidates);
sortedCandidates.sort((a,b) -> a.moduleName.compareTo(b.moduleName));
promptToSelectCandidate(project, (ElmFile) file, refComponents, sortedCandidates);
}
}
开发者ID:durkiewicz,项目名称:elm-plugin,代码行数:17,代码来源:ElmImportQuickFix.java
示例2: generateMissedTests
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private static void generateMissedTests(final PsiClass testClass, PsiClass srcClass, Editor srcEditor) {
if (testClass != null) {
final TestFramework framework = TestFrameworks.detectFramework(testClass);
if (framework != null) {
final Project project = testClass.getProject();
final Editor editor = CodeInsightUtil.positionCursorAtLBrace(project, testClass.getContainingFile(), testClass);
if (!FileModificationService.getInstance().preparePsiElementsForWrite(testClass)) return;
final MissedTestsDialog dialog = new MissedTestsDialog(project, srcClass, testClass, framework);
if (dialog.showAndGet()) {
WriteCommandAction.runWriteCommandAction(project, new Runnable() {
@Override
public void run() {
JavaTestGenerator.addTestMethods(editor, testClass, framework, dialog.getSelectedMethods(), false, false);
}
});
}
}
else {
HintManager.getInstance().showErrorHint(srcEditor, "Failed to detect test framework for " + testClass.getQualifiedName());
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:GenerateMissedTestsAction.java
示例3: createTooltip
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
public static HyperlinkLabel createTooltip(final String message) {
final HyperlinkLabel link = new HyperlinkLabel("");
link.setIcon(AllIcons.General.Help_small);
link.setUseIconAsLink(true);
link.setIconTextGap(0);
link.addHyperlinkListener(new HyperlinkAdapter() {
@Override
protected void hyperlinkActivated(HyperlinkEvent e) {
final JLabel label = new JLabel(message);
label.setBorder(HintUtil.createHintBorder());
label.setBackground(HintUtil.INFORMATION_COLOR);
label.setOpaque(true);
HintManager.getInstance()
.showHint(label, RelativePoint.getSouthEastOf(link), HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE, -1);
}
});
return link;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:TooltipUtil.java
示例4: executeWriteAction
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public void executeWriteAction(final Editor editor, DataContext dataContext) {
final SelectionModel selectionModel = editor.getSelectionModel();
int changedLines = 0;
if (selectionModel.hasSelection()) {
changedLines = performAction(editor, new TextRange(selectionModel.getSelectionStart(), selectionModel.getSelectionEnd()));
}
else {
changedLines += performAction(editor, new TextRange(0, editor.getDocument().getTextLength()));
}
if (changedLines == 0) {
HintManager.getInstance().showInformationHint(editor, "All lines already have requested indentation");
}
else {
HintManager.getInstance().showInformationHint(editor, "Changed indentation in " + changedLines + (changedLines == 1 ? " line" : " lines"));
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:ConvertIndentsActionBase.java
示例5: performHighlighting
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
protected void performHighlighting() {
boolean clearHighlights = HighlightUsagesHandler.isClearHighlights(myEditor);
EditorColorsManager manager = EditorColorsManager.getInstance();
TextAttributes attributes = manager.getGlobalScheme().getAttributes(EditorColors.SEARCH_RESULT_ATTRIBUTES);
TextAttributes writeAttributes = manager.getGlobalScheme().getAttributes(EditorColors.WRITE_SEARCH_RESULT_ATTRIBUTES);
HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
myEditor, attributes, clearHighlights, myReadUsages);
HighlightUsagesHandler.highlightRanges(HighlightManager.getInstance(myEditor.getProject()),
myEditor, writeAttributes, clearHighlights, myWriteUsages);
if (!clearHighlights) {
WindowManager.getInstance().getStatusBar(myEditor.getProject()).setInfo(myStatusText);
HighlightHandlerBase.setupFindModel(myEditor.getProject()); // enable f3 navigation
}
if (myHintText != null) {
HintManager.getInstance().showInformationHint(myEditor, myHintText);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:HighlightUsagesHandlerBase.java
示例6: doApplyInformationToEditor
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public void doApplyInformationToEditor() {
ApplicationManager.getApplication().assertIsDispatchThread();
if (!ApplicationManager.getApplication().isUnitTestMode() && !myEditor.getContentComponent().hasFocus()) return;
// do not show intentions if caret is outside visible area
LogicalPosition caretPos = myEditor.getCaretModel().getLogicalPosition();
Rectangle visibleArea = myEditor.getScrollingModel().getVisibleArea();
Point xy = myEditor.logicalPositionToXY(caretPos);
if (!visibleArea.contains(xy)) return;
TemplateState state = TemplateManagerImpl.getTemplateState(myEditor);
if (myShowBulb && (state == null || state.isFinished()) && !HintManager.getInstance().hasShownHintsThatWillHideByOtherHint(false)) {
DaemonCodeAnalyzerImpl codeAnalyzer = (DaemonCodeAnalyzerImpl)DaemonCodeAnalyzer.getInstance(myProject);
codeAnalyzer.setLastIntentionHint(myProject, myFile, myEditor, myIntentionsInfo, myHasToRecreate);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:ShowIntentionsPass.java
示例7: show
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer();
myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint);
repaintTooltipWindow();
LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, true, myPanel.getMinWidth());
LightweightHint hint = new LightweightHint(myPanel);
HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
hintManager.showEditorHint(hint, editor, p,
HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT |
HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
hint.addHintListener(new HintListener() {
@Override
public void hintHidden(EventObject event) {
if (myPanel == null) return; //double hide?
myPanel = null;
onHide.run();
}
});
return hint;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:TrafficTooltipRendererImpl.java
示例8: prepareFileForWrite
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public boolean prepareFileForWrite(@Nullable final PsiFile psiFile) {
if (psiFile == null) return false;
final VirtualFile file = psiFile.getVirtualFile();
final Project project = psiFile.getProject();
if (ReadonlyStatusHandler.ensureFilesWritable(project, file)) {
return true;
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
final Editor editor = FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, file), true);
if (editor != null && editor.getComponent().isDisplayable()) {
HintManager.getInstance().showErrorHint(editor, CodeInsightBundle.message("error.hint.file.is.readonly", file.getPresentableUrl()));
}
}
}, project.getDisposed());
return false;
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:CodeInsightUtilBase.java
示例9: applyAction
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void applyAction(final IntentionActionWithTextCaching cachedAction) {
myFinalRunnable = new Runnable() {
@Override
public void run() {
HintManager.getInstance().hideAllHints();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
if (DumbService.isDumb(myProject) && !DumbService.isDumbAware(cachedAction)) {
DumbService.getInstance(myProject).showDumbModeNotification(cachedAction.getText() + " is not available during indexing");
return;
}
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final PsiFile file = PsiUtilBase.getPsiFileInEditor(myEditor, myProject);
if (file == null) {
return;
}
ShowIntentionActionsHandler.chooseActionAndInvoke(file, myEditor, cachedAction.getAction(), cachedAction.getText());
}
});
}
};
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:27,代码来源:IntentionListStep.java
示例10: performOnElement
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void performOnElement(@NotNull final Editor editor, @NotNull T first) {
final TextRange textRange = first.getTextRange();
editor.getSelectionModel().setSelection(textRange.getStartOffset(), textRange.getEndOffset());
final String informationHint = getInformationHint(first);
if (informationHint != null) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
HintManager.getInstance().showInformationHint(editor, informationHint);
}
});
}
else {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
HintManager.getInstance().showErrorHint(editor, getErrorHint());
}
});
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:SelectionBasedPsiElementInternalAction.java
示例11: showHint
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void showHint(@Nullable final Editor editor,
@NotNull String hint,
@NotNull FindUsagesHandler handler,
@NotNull final RelativePoint popupPosition,
int maxUsages,
@NotNull FindUsagesOptions options,
boolean isWarning) {
JComponent label = createHintComponent(hint, handler, popupPosition, editor, HIDE_HINTS_ACTION, maxUsages, options, isWarning);
if (editor == null || editor.isDisposed() || !editor.getComponent().isShowing()) {
HintManager.getInstance().showHint(label, popupPosition, HintManager.HIDE_BY_ANY_KEY |
HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_SCROLLING, 0);
}
else {
HintManager.getInstance().showInformationHint(editor, label);
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:ShowUsagesAction.java
示例12: chooseAmbiguousTargetAndPerform
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
static void chooseAmbiguousTargetAndPerform(@NotNull final Project project,
final Editor editor,
@NotNull PsiElementProcessor<PsiElement> processor) {
if (editor == null) {
Messages.showMessageDialog(project, FindBundle.message("find.no.usages.at.cursor.error"), CommonBundle.getErrorTitle(),
Messages.getErrorIcon());
}
else {
int offset = editor.getCaretModel().getOffset();
boolean chosen = GotoDeclarationAction.chooseAmbiguousTarget(editor, offset, processor, FindBundle.message("find.usages.ambiguous.title"), null);
if (!chosen) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (editor.isDisposed() || !editor.getComponent().isShowing()) return;
HintManager.getInstance().showErrorHint(editor, FindBundle.message("find.no.usages.at.cursor.error"));
}
}, project.getDisposed());
}
}
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:22,代码来源:FindUsagesAction.java
示例13: showHint
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
public void showHint() {
myParentEditor.putUserData(KEY, this);
Pair<Point, Short> position = guessPosition();
JRootPane pane = myParentEditor.getComponent().getRootPane();
JComponent layeredPane = pane != null ? pane.getLayeredPane() : myParentEditor.getComponent();
HintHint hintHint = new HintHint(layeredPane, position.first)
.setAwtTooltip(true)
.setContentActive(true)
.setExplicitClose(true)
.setShowImmediately(true)
.setPreferredPosition(position.second == HintManager.ABOVE ? Balloon.Position.above : Balloon.Position.below)
.setTextBg(myParentEditor.getColorsScheme().getDefaultBackground())
.setBorderInsets(new Insets(1, 1, 1, 1));
int hintFlags = HintManager.HIDE_BY_OTHER_HINT | HintManager.HIDE_BY_ESCAPE | HintManager.UPDATE_BY_SCROLLING;
HintManagerImpl.getInstanceImpl().showEditorHint(this, myParentEditor, position.first, hintFlags, 0, false, hintHint);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:EmmetPreviewHint.java
示例14: guessPosition
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@NotNull
private Pair<Point, Short> guessPosition() {
JRootPane rootPane = myParentEditor.getContentComponent().getRootPane();
JComponent layeredPane = rootPane != null ? rootPane.getLayeredPane() : myParentEditor.getComponent();
LogicalPosition logicalPosition = myParentEditor.getCaretModel().getLogicalPosition();
LogicalPosition pos = new LogicalPosition(logicalPosition.line, logicalPosition.column);
Point p1 = HintManagerImpl.getHintPosition(this, myParentEditor, pos, HintManager.UNDER);
Point p2 = HintManagerImpl.getHintPosition(this, myParentEditor, pos, HintManager.ABOVE);
boolean p1Ok = p1.y + getComponent().getPreferredSize().height < layeredPane.getHeight();
boolean p2Ok = p2.y >= 0;
if (p1Ok) return new Pair<Point, Short>(p1, HintManager.UNDER);
if (p2Ok) return new Pair<Point, Short>(p2, HintManager.ABOVE);
int underSpace = layeredPane.getHeight() - p1.y;
int aboveSpace = p2.y;
return aboveSpace > underSpace
? new Pair<Point, Short>(new Point(p2.x, 0), HintManager.UNDER)
: new Pair<Point, Short>(p1, HintManager.ABOVE);
}
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:23,代码来源:EmmetPreviewHint.java
示例15: showHint
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public boolean showHint(@NotNull Editor editor) {
if (!SchemaSettings.getInstance().SHOW_SCHEMA_ADD_IMPORT_HINTS) return false;
if (typeRef.resolve() != null) return false;
List<String> importOptions = calculateImportOptions();
if (importOptions.isEmpty()) return false;
final String message = ShowAutoImportPass.getMessage(importOptions.size() > 1, importOptions.get(0));
final ImportTypeAction action = new ImportTypeAction((SchemaFile) typeRef.getContainingFile(), importOptions, editor);
HintManager.getInstance().showQuestionHint(editor, message,
typeRef.getTextOffset(),
typeRef.getTextRange().getEndOffset(), action);
return false;
}
开发者ID:SumoLogic,项目名称:epigraph,代码行数:17,代码来源:ImportTypeIntentionFix.java
示例16: doGenerate
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void doGenerate(final Editor editor, final PsiFile file, final PsiClass targetClass, final TestFramework framework) {
if (!CommonRefactoringUtil.checkReadOnlyStatus(file)) return;
ApplicationManager.getApplication().runWriteAction(new Runnable() {
@Override
public void run() {
try {
PsiDocumentManager.getInstance(file.getProject()).commitAllDocuments();
PsiMethod method = generateDummyMethod(editor, file);
if (method == null) return;
TestIntegrationUtils.runTestMethodTemplate(myMethodKind, framework, editor, targetClass, method, "name", false);
}
catch (IncorrectOperationException e) {
HintManager.getInstance().showErrorHint(editor, "Cannot generate method: " + e.getMessage());
LOG.warn(e);
}
}
});
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:21,代码来源:BaseGenerateTestSupportMethodAction.java
示例17: show
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public LightweightHint show(@NotNull Editor editor, @NotNull Point p, boolean alignToRight, @NotNull TooltipGroup group, @NotNull HintHint hintHint) {
myTrafficLightRenderer = (TrafficLightRenderer)((EditorMarkupModelImpl)editor.getMarkupModel()).getErrorStripeRenderer();
myPanel = new TrafficProgressPanel(myTrafficLightRenderer, editor, hintHint);
LineTooltipRenderer.correctLocation(editor, myPanel, p, alignToRight, false, -1);
LightweightHint hint = new LightweightHint(myPanel);
HintManagerImpl hintManager = (HintManagerImpl)HintManager.getInstance();
hintManager.showEditorHint(hint, editor, p,
HintManager.HIDE_BY_ANY_KEY | HintManager.HIDE_BY_TEXT_CHANGE | HintManager.HIDE_BY_OTHER_HINT |
HintManager.HIDE_BY_SCROLLING, 0, false, hintHint);
hint.addHintListener(new HintListener() {
@Override
public void hintHidden(EventObject event) {
if (myPanel == null) return; //double hide?
myPanel = null;
onHide.run();
}
});
repaintTooltipWindow();
return hint;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:23,代码来源:TrafficTooltipRendererImpl.java
示例18: prepareFileForWrite
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
@Override
public boolean prepareFileForWrite(@Nullable final PsiFile psiFile) {
if (psiFile == null) return false;
final VirtualFile file = psiFile.getVirtualFile();
final Project project = psiFile.getProject();
final Editor editor =
psiFile.isWritable() ? null : FileEditorManager.getInstance(project).openTextEditor(new OpenFileDescriptor(project, file), true);
if (!ReadonlyStatusHandler.ensureFilesWritable(project, file)) {
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (editor != null && editor.getComponent().isDisplayable()) {
HintManager.getInstance()
.showErrorHint(editor, CodeInsightBundle.message("error.hint.file.is.readonly", file.getPresentableUrl()));
}
}
});
return false;
}
return true;
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:CodeInsightUtilBase.java
示例19: applyAction
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void applyAction(final IntentionActionWithTextCaching cachedAction) {
myFinalRunnable = new Runnable() {
@Override
public void run() {
HintManager.getInstance().hideAllHints();
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
if (myProject.isDisposed()) return;
PsiDocumentManager.getInstance(myProject).commitAllDocuments();
final PsiFile file = PsiUtilBase.getPsiFileInEditor(myEditor, myProject);
if (file == null) {
return;
}
ShowIntentionActionsHandler.chooseActionAndInvoke(file, myEditor, cachedAction.getAction(), cachedAction.getText());
}
});
}
};
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:22,代码来源:IntentionListStep.java
示例20: showIntentionHintImpl
import com.intellij.codeInsight.hint.HintManager; //导入依赖的package包/类
private void showIntentionHintImpl(final boolean delay, final Point position) {
final int offset = myEditor.getCaretModel().getOffset();
myComponentHint.setShouldDelay(delay);
HintManagerImpl hintManager = HintManagerImpl.getInstanceImpl();
PriorityQuestionAction action = new PriorityQuestionAction() {
@Override
public boolean execute() {
showPopup();
return true;
}
@Override
public int getPriority() {
return -10;
}
};
if (hintManager.canShowQuestionAction(action)) {
hintManager.showQuestionHint(myEditor, position, offset, offset, myComponentHint, action, HintManager.ABOVE);
}
}
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:IntentionHintComponent.java
注:本文中的com.intellij.codeInsight.hint.HintManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论