@Nullable private static String calculateOverridingSiblingMethodTooltip(@NotNull PsiMethod method) { Pair<PsiMethod, PsiClass> pair = FindSuperElementsHelper.getSiblingInheritedViaSubClass(method, FindSuperElementsHelper.createSubClassCache()); if (pair == null) return null; PsiMethod superMethod = pair.getFirst(); PsiClass subClass = pair.getSecond(); boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT); boolean isSuperAbstract = superMethod.hasModifierProperty(PsiModifier.ABSTRACT); String postfix = MessageFormat.format(" via sub-class <a href=\"#javaClass/{0}\">{0}</a>", ClassPresentationUtil.getNameForClass(subClass, true)); @NonNls String pattern = DaemonBundle.message(isSuperAbstract && !isAbstract ? "method.implements" : "method.overrides") + postfix; return composeText(new PsiElement[]{superMethod}, "", pattern, IdeActions.ACTION_GOTO_SUPER); }
private static String getOverriddenMethodTooltip(@NotNull PsiMethod method) { PsiElementProcessor.CollectElementsWithLimit<PsiMethod> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiMethod>(5); OverridingMethodsSearch.search(method, true).forEach(new PsiElementProcessorAdapter<PsiMethod>(processor)); boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT); if (processor.isOverflow()){ return isAbstract ? DaemonBundle.message("method.is.implemented.too.many") : DaemonBundle.message("method.is.overridden.too.many"); } PsiMethod[] overridings = processor.toArray(PsiMethod.EMPTY_ARRAY); if (overridings.length == 0) { final PsiClass aClass = method.getContainingClass(); if (aClass != null && FunctionalExpressionSearch.search(aClass).findFirst() != null) { return "Has functional implementations"; } return null; } Comparator<PsiMethod> comparator = new MethodCellRenderer(false).getComparator(); Arrays.sort(overridings, comparator); String start = isAbstract ? DaemonBundle.message("method.is.implemented.header") : DaemonBundle.message("method.is.overriden.header"); @NonNls String pattern = " <a href=\"#javaClass/{1}\">{1}</a>"; return composeText(overridings, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION); }
public void testResolvedDtdElementReferences() throws Exception { configureByFile(BASE_PATH + getTestName(false)+".dtd"); doDoTest(true, false); final String text = myEditor.getDocument().getText(); WriteCommandAction.runWriteCommandAction(null, new Runnable() { @Override public void run() { myEditor.getSelectionModel().setSelection(0, myEditor.getDocument().getTextLength()); } }); AnAction action = ActionManager.getInstance().getAction(IdeActions.ACTION_COMMENT_BLOCK); action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); assertNotSame(text,myEditor.getDocument().getText()); PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); Collection<HighlightInfo> infos = doHighlighting(); assertEquals(0, infos.size()); action.actionPerformed(AnActionEvent.createFromAnAction(action, null, "", DataManager.getInstance().getDataContext())); assertEquals(text,myEditor.getDocument().getText().trim()); PsiDocumentManager.getInstance(myProject).commitDocument(myEditor.getDocument()); infos = doHighlighting(); assertEquals(0, infos.size()); }
@Override protected void createTrees(@NotNull final Map<String, JTree> type2TreeMap) { ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_CALL_HIERARCHY_POPUP); final JTree tree1 = createTree(false); PopupHandler.installPopupHandler(tree1, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); final BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree1); type2TreeMap.put(CALLEE_TYPE, tree1); final JTree tree2 = createTree(false); PopupHandler.installPopupHandler(tree2, group, ActionPlaces.CALL_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_CALL_HIERARCHY).getShortcutSet(), tree2); type2TreeMap.put(CALLER_TYPE, tree2); }
public void testNoCompletion() throws Exception { String text = "abc abd a<caret> abx"; myFixture.configureByText("x.txt", text); int offset = myFixture.getEditor().getCaretModel().getOffset(); createGuard(offset - 1, myFixture.getFile().getTextLength()).setGreedyToRight(true); assertNull(myFixture.completeBasic()); myFixture.checkResult(text); //no hippie completion myFixture.performEditorAction(IdeActions.ACTION_HIPPIE_BACKWARD_COMPLETION); assertNull(LookupManager.getInstance(getProject()).getActiveLookup()); myFixture.checkResult(text); //no completion at the file end myFixture.getEditor().getCaretModel().moveToOffset(myFixture.getFile().getTextLength()); assertNull(myFixture.completeBasic()); myFixture.checkResult("abc abd a abx<caret>"); //completion at the beginning of the guard fragment myFixture.getEditor().getCaretModel().moveToOffset(offset - 1); assertNotNull(myFixture.completeBasic()); }
@NotNull private TabbedPaneWrapper.AsJBTabs createTabbedPaneWrapper(FileEditor[] editors) { PrevNextActionsDescriptor descriptor = new PrevNextActionsDescriptor(IdeActions.ACTION_NEXT_EDITOR_TAB, IdeActions.ACTION_PREVIOUS_EDITOR_TAB); final TabbedPaneWrapper.AsJBTabs wrapper = new TabbedPaneWrapper.AsJBTabs(myFileEditorManager.getProject(), SwingConstants.BOTTOM, descriptor, this); wrapper.getTabs().getPresentation().setPaintBorder(0, 0, 0, 0).setTabSidePaintBorder(1).setGhostsAlwaysVisible(true).setUiDecorator(new UiDecorator() { @Override @NotNull public UiDecoration getDecoration() { return new UiDecoration(null, new Insets(0, 8, 0, 8)); } }); wrapper.getTabs().getComponent().setBorder(new EmptyBorder(0, 0, 1, 0)); boolean firstEditor = true; for (FileEditor editor : editors) { JComponent component = firstEditor && myComponent != null ? (JComponent)myComponent.getComponent(0) : createEditorComponent(editor); wrapper.addTab(getDisplayName(editor), component); firstEditor = false; } wrapper.addChangeListener(new MyChangeListener()); return wrapper; }
private void doTest(String prefix) { int oldReformat = CodeInsightSettings.getInstance().REFORMAT_ON_PASTE; try { CodeInsightSettings.getInstance().REFORMAT_ON_PASTE = CodeInsightSettings.NO_REFORMAT; String name = getTestName(false); myFixture.configureByFile("copyPaste/" + prefix + name + ".src.py"); myFixture.performEditorAction(IdeActions.ACTION_EDITOR_COPY); myFixture.configureByFile("copyPaste/" + prefix + name + ".dst.py"); myFixture.performEditorAction(IdeActions.ACTION_EDITOR_PASTE); myFixture.checkResultByFile("copyPaste/" + prefix + name + ".after.py", true); } finally { CodeInsightSettings.getInstance().REFORMAT_ON_PASTE = oldReformat; } }
public DefaultActionGroup createDefaultFileSystemActions(FileSystemTree fileSystemTree) { DefaultActionGroup group = new DefaultActionGroup(); final ActionManager actionManager = ActionManager.getInstance(); group.add(actionManager.getAction("FileChooser.GotoHome")); group.add(actionManager.getAction("FileChooser.GotoProject")); group.addSeparator(); group.add(actionManager.getAction("FileChooser.NewFolder")); group.add(actionManager.getAction("FileChooser.Delete")); group.addSeparator(); SynchronizeAction action1 = new SynchronizeAction(); AnAction original = actionManager.getAction(IdeActions.ACTION_SYNCHRONIZE); action1.copyFrom(original); action1.registerCustomShortcutSet(original.getShortcutSet(), fileSystemTree.getTree()); group.add(action1); group.addSeparator(); group.add(actionManager.getAction("FileChooser.ShowHiddens")); return group; }
@Override public void executeWriteAction(@NotNull Editor editor, Caret caret, DataContext dataContext) { final Document document = editor.getDocument(); final int caretOffset = editor.getCaretModel().getOffset(); if (caretOffset < 1) { return; } final SelectionModel selectionModel = editor.getSelectionModel(); final CharSequence text = document.getCharsSequence(); final char c = text.charAt(caretOffset - 1); if (!selectionModel.hasSelection() && StringUtil.isWhiteSpace(c)) { int startOffset = CharArrayUtil.shiftBackward(text, caretOffset - 2, "\t \n") + 1; document.deleteString(startOffset, caretOffset); } else { final EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_BACKSPACE); handler.execute(editor, caret, dataContext); } }
@NotNull @Override protected AnAction getPasteAction(@NotNull final Editor editor, boolean recreateCaretsAction) { if (recreateCaretsAction) { return new DuplicateForClipboardCaretsAction(true,true); } else { return ActionManager.getInstance().getAction(IdeActions.ACTION_PASTE); } }
@Override public void initActions(RunContentDescriptor content, DefaultActionGroup actionGroup) { Executor executor = myExecutionEnvironment.getExecutor(); actionGroup.add(ActionManager.getInstance().getAction(IdeActions.ACTION_RERUN), Constraints.FIRST); actionGroup.add(new CloseAction(executor, content, myExecutionEnvironment.getProject())); actionGroup.add(new ContextHelpAction(executor.getHelpId())); }
@Override public String handleEmptyLookup(@NotNull final CompletionParameters parameters, final Editor editor) { if (!(parameters.getOriginalFile() instanceof PsiJavaFile)) return null; if (shouldShowSecondSmartCompletionHint(parameters)) { return LangBundle.message("completion.no.suggestions") + "; " + StringUtil.decapitalize( CompletionBundle.message("completion.class.name.hint.2", getActionShortcut(IdeActions.ACTION_CODE_COMPLETION))); } return null; }
@Override public void fillCompletionVariants(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) { PsiElement position = parameters.getPosition(); JavaClassReference reference = findJavaClassReference(position.getContainingFile(), parameters.getOffset()); if (reference == null) { return; } String[] extendClassNames = reference.getExtendClassNames(); PsiElement context = reference.getCompletionContext(); if (extendClassNames != null && context instanceof PsiPackage) { if (parameters.getCompletionType() == CompletionType.SMART) { JavaClassReferenceSet set = reference.getJavaClassReferenceSet(); int setStart = set.getRangeInElement().getStartOffset() + set.getElement().getTextRange().getStartOffset(); String fullPrefix = parameters.getPosition().getContainingFile().getText().substring(setStart, parameters.getOffset()); reference.processSubclassVariants((PsiPackage)context, extendClassNames, result.withPrefixMatcher(fullPrefix)); return; } result.addLookupAdvertisement("Press " + getActionShortcut(IdeActions.ACTION_SMART_TYPE_COMPLETION) + " to see inheritors of " + StringUtil.join(extendClassNames, ", ")); } if (parameters.getCompletionType() == CompletionType.SMART) { return; } if (parameters.isExtendedCompletion() || parameters.getCompletionType() == CompletionType.CLASS_NAME) { JavaClassNameCompletionContributor.addAllClasses(parameters, result); } else { LegacyCompletionContributor.completeReference(parameters, result); } result.stopHere(); }
@Override public void renderElement(LookupElementPresentation presentation) { super.renderElement(presentation); char shortcut = getTemplateShortcut(); presentation.setItemText(getItemText()); if (sudden) { presentation.setItemTextBold(true); if (!presentation.isReal() || !((RealLookupElementPresentation)presentation).isLookupSelectionTouched()) { if (shortcut == TemplateSettings.DEFAULT_CHAR) { shortcut = TemplateSettings.getInstance().getDefaultShortcutChar(); } if (shortcut != TemplateSettings.CUSTOM_CHAR) { presentation.setTypeText(" [" + KeyEvent.getKeyText(shortcut) + "] "); } else { String shortcutText = KeymapUtil.getFirstKeyboardShortcutText(ActionManager.getInstance().getAction(IdeActions.ACTION_EXPAND_LIVE_TEMPLATE_CUSTOM)); if (StringUtil.isNotEmpty(shortcutText)) { presentation.setTypeText(" [" + shortcutText + "] "); } } } if (StringUtil.isNotEmpty(myDescription)) { presentation.setTailText(" (" + myDescription + ")", true); } } else { presentation.setTypeText(myDescription); } }
private void showHint(boolean shouldImport) { if (!myHintShown && !shouldImport) { final String shortcut = CompletionContributor.getActionShortcut(IdeActions.ACTION_SHOW_INTENTION_ACTIONS); if (shortcut != null) { CompletionService.getCompletionService().setAdvertisementText("To import a method statically, press " + shortcut); } myHintShown = true; } }
public void testMovingCaretWhenSelectionExists() throws Exception { prepareText("RRR"); right(); right(); executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT_WITH_SELECTION); checkResult("R<selection>R</selection>R"); right(); assertVisualCaretLocation(2, true); }
private void doTest(String before, String after) { SmartBackspaceMode savedMode = CodeInsightSettings.getInstance().getBackspaceMode(); try { CodeInsightSettings.getInstance().setBackspaceMode(SmartBackspaceMode.INDENT); configureFromFileText(getTestName(false) + ".txt", before); executeAction(IdeActions.ACTION_EDITOR_BACKSPACE); checkResultByText(after); } finally { CodeInsightSettings.getInstance().setBackspaceMode(savedMode); } }
public static String getSubclassedClassTooltip(@NotNull PsiClass aClass) { PsiElementProcessor.CollectElementsWithLimit<PsiClass> processor = new PsiElementProcessor.CollectElementsWithLimit<PsiClass>(5, new THashSet<PsiClass>()); ClassInheritorsSearch.search(aClass, true).forEach(new PsiElementProcessorAdapter<PsiClass>(processor)); if (processor.isOverflow()) { return aClass.isInterface() ? DaemonBundle.message("interface.is.implemented.too.many") : DaemonBundle.message("class.is.subclassed.too.many"); } PsiClass[] subclasses = processor.toArray(PsiClass.EMPTY_ARRAY); if (subclasses.length == 0) { final PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression> functionalImplementations = new PsiElementProcessor.CollectElementsWithLimit<PsiFunctionalExpression>(2, new THashSet<PsiFunctionalExpression>()); FunctionalExpressionSearch.search(aClass).forEach(new PsiElementProcessorAdapter<PsiFunctionalExpression>(functionalImplementations)); if (!functionalImplementations.getCollection().isEmpty()) { return "Has functional implementations"; } return null; } Comparator<PsiClass> comparator = new PsiClassListCellRenderer().getComparator(); Arrays.sort(subclasses, comparator); String start = aClass.isInterface() ? DaemonBundle.message("interface.is.implemented.by.header") : DaemonBundle.message("class.is.subclassed.by.header"); @NonNls String pattern = " <a href=\"#javaClass/{0}\">{0}</a>"; return composeText(subclasses, start, pattern, IdeActions.ACTION_GOTO_IMPLEMENTATION); }
@Override public boolean doEnter(Editor editor, PsiElement psiElement, boolean isModified) { PsiElement parent = psiElement.getParent(); if (!(parent instanceof PsiCodeBlock)) { return false; } final ASTNode node = psiElement.getNode(); if (node != null && CONTROL_FLOW_ELEMENT_TYPES.contains(node.getElementType())) { return false; } boolean leaveCodeBlock = isControlFlowBreak(psiElement); if (!leaveCodeBlock) { return false; } final int offset = parent.getTextRange().getEndOffset(); // Check if there is empty line after the code block. Just move caret there in the case of the positive answer. final CharSequence text = editor.getDocument().getCharsSequence(); if (offset < text.length() - 1) { final int i = CharArrayUtil.shiftForward(text, offset + 1, " \t"); if (i < text.length() && text.charAt(i) == '\n') { editor.getCaretModel().moveToOffset(offset + 1); EditorActionManager actionManager = EditorActionManager.getInstance(); EditorActionHandler actionHandler = actionManager.getActionHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END); final DataContext dataContext = DataManager.getInstance().getDataContext(editor.getComponent()); if (dataContext != null) { actionHandler.execute(editor, dataContext); return true; } } } editor.getCaretModel().moveToOffset(offset); return false; }
public void testTextStartEndWithSelection() throws Exception { prepareText("RR"); myEditor.getCaretModel().moveToOffset(1); executeAction(IdeActions.ACTION_EDITOR_TEXT_START_WITH_SELECTION); assertVisualCaretLocation(0, false); checkResult("<selection>R</selection>R"); executeAction(IdeActions.ACTION_EDITOR_TEXT_END_WITH_SELECTION); assertVisualCaretLocation(2, false); checkResult("R<selection>R</selection>"); }
static boolean expandCodeBlock(Editor editor, PsiElement psiElement) { PsiCodeBlock block = getControlStatementBlock(editor.getCaretModel().getOffset(), psiElement); if (processExistingBlankLine(editor, block, psiElement)) { return true; } if (block == null) { return false; } EditorActionHandler enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_START_NEW_LINE); PsiElement firstElement = block.getFirstBodyElement(); if (firstElement == null) { firstElement = block.getRBrace(); // Plain enter processor inserts enter after the end of line, hence, we don't want to use it here because the line ends with // the empty braces block. So, we get the following in case of default handler usage: // Before: // if (condition[caret]) {} // After: // if (condition) {} // [caret] enterHandler = getEnterHandler(IdeActions.ACTION_EDITOR_ENTER); } editor.getCaretModel().moveToOffset(firstElement != null ? firstElement.getTextRange().getStartOffset() : block.getTextRange().getEndOffset()); enterHandler.execute(editor, ((EditorEx)editor).getDataContext()); return true; }
protected void createTrees(@NotNull Map<String, JTree> trees) { final JTree tree = createTree(false); ActionGroup group = (ActionGroup)ActionManager.getInstance().getAction(IdeActions.GROUP_METHOD_HIERARCHY_POPUP); PopupHandler.installPopupHandler(tree, group, ActionPlaces.METHOD_HIERARCHY_VIEW_POPUP, ActionManager.getInstance()); final BaseOnThisMethodAction baseOnThisMethodAction = new BaseOnThisMethodAction(); baseOnThisMethodAction .registerCustomShortcutSet(ActionManager.getInstance().getAction(IdeActions.ACTION_METHOD_HIERARCHY).getShortcutSet(), tree); trees.put(METHOD_TYPE, tree); }
private String getShowMoreShortCut() { if (myShortcutText == null) { final KeymapManager keymapManager = KeymapManager.getInstance(); if (keymapManager != null) { final Keymap keymap = keymapManager.getActiveKeymap(); myShortcutText = keymap == null ? "" : "(" + KeymapUtil.getShortcutsText(keymap.getShortcuts(IdeActions.ACTION_SHOW_ERROR_DESCRIPTION)) + ")"; } else { myShortcutText = ""; } } return myShortcutText; }
public void testUpWithSelectionOnCaretInsideSelection() throws Exception { initText("blah blah\n" + "blah <selection>bl<caret>ah</selection>\n" + "blah blah"); executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_UP_WITH_SELECTION); checkResultByText("blah bl<selection><caret>ah\n" + "blah blah</selection>\n" + "blah blah"); }
@Override public String advertise(@NotNull final CompletionParameters parameters) { if (isXmlNameCompletion(parameters) && parameters.getCompletionType() == CompletionType.BASIC) { if (FeatureUsageTracker.getInstance().isToBeAdvertisedInLookup(TAG_NAME_COMPLETION_FEATURE, parameters.getPosition().getProject())) { final String shortcut = getActionShortcut(IdeActions.ACTION_CODE_COMPLETION); return XmlBundle.message("tag.name.completion.hint", shortcut); } } return super.advertise(parameters); }
private void doTest(@NotNull String newFolder, @Nullable final Runnable invokeAfterTemplate, @NotNull String after, String afterPath, @NotNull VirtualFile resourceFile, final boolean closePopup) { myFixture.configureFromExistingVirtualFile(resourceFile); final PsiFile xmlFile = myFixture.getFile(); final OverrideResourceAction action = new OverrideResourceAction(); OverrideResourceAction.ourTargetFolderName = newFolder; assertTrue(action.isAvailable(myFixture.getProject(), myFixture.getEditor(), xmlFile)); CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() { @Override public void run() { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { action.invoke(myFixture.getProject(), myFixture.getEditor(), xmlFile); if (invokeAfterTemplate != null) { invokeAfterTemplate.run(); } } }); if (closePopup) { myFixture.performEditorAction(IdeActions.ACTION_EDITOR_ESCAPE); } } }, "", ""); myFixture.checkResultByFile(afterPath, BASE_PATH + after, false); }
public void testCollapseAllHappensBeforeFirstCodeFoldingPass() throws Exception { init("class Foo {\n" + " void m() {\n" + " System.out.println();\n" + " System.out.println();\n" + " }\n" + "}", TestFileType.JAVA); buildInitialFoldRegions(); executeAction(IdeActions.ACTION_COLLAPSE_ALL_REGIONS); runFoldingPass(true); assertEquals(1, myEditor.getFoldingModel().getAllFoldRegions().length); }
public void testStopEditing() { doTestStopEditing(new Pass<AbstractInplaceIntroducer>() { @Override public void pass(AbstractInplaceIntroducer introducer) { invokeEditorAction(IdeActions.ACTION_EDITOR_MOVE_CARET_LEFT); invokeEditorAction(IdeActions.ACTION_EDITOR_ENTER); invokeEditorAction(IdeActions.ACTION_EDITOR_ENTER); } }); }
@NotNull private static BrowseMode getBrowseMode(@JdkConstants.InputEventMask int modifiers) { if (modifiers != 0) { final Keymap activeKeymap = KeymapManager.getInstance().getActiveKeymap(); if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_DECLARATION)) return BrowseMode.Declaration; if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_TYPE_DECLARATION)) return BrowseMode.TypeDeclaration; if (KeymapUtil.matchActionMouseShortcutsModifiers(activeKeymap, modifiers, IdeActions.ACTION_GOTO_IMPLEMENTATION)) return BrowseMode.Implementation; if (modifiers == InputEvent.CTRL_MASK || modifiers == InputEvent.META_MASK) return BrowseMode.Declaration; } return BrowseMode.None; }
public void testMovingCaretWhenSelectionStartsOnDirectionBoundary() throws Exception { prepareText("LR"); right(); right(); executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_RIGHT_WITH_SELECTION); right(); assertVisualCaretLocation(2, true); }
public CloseTabToolbarAction() { copyFrom(ActionManager.getInstance().getAction(IdeActions.ACTION_CLOSE_ACTIVE_TAB)); Presentation presentation = getTemplatePresentation(); presentation.setIcon(AllIcons.Actions.Cancel); presentation.setText(CommonBundle.getCloseButtonText()); presentation.setDescription(null); }
public void testPasteInOneLineMode() throws Exception { init("", TestFileType.TEXT); ((EditorEx)myEditor).setOneLineMode(true); CopyPasteManager.getInstance().setContents(new StringSelection("a\rb")); executeAction(IdeActions.ACTION_EDITOR_PASTE); checkResultByText("a b<caret>"); }
@Override public JComponent createComponent() { if (myViewPanel == null) { myViewPanel = new ScopeTreeViewPanel(myProject); Disposer.register(this, myViewPanel); myViewPanel.initListeners(); myTree = myViewPanel.getTree(); CustomizationUtil.installPopupHandler(myTree, IdeActions.GROUP_SCOPE_VIEW_POPUP, ActionPlaces.SCOPE_VIEW_POPUP); enableDnD(); } myViewPanel.selectScope(NamedScopesHolder.getScope(myProject, getSubId())); return myViewPanel.getPanel(); }
public void testDownWithSelectionOnCaretInsideSelection() throws Exception { initText("blah blah\n" + "blah <selection>bl<caret>ah</selection>\n" + "blah blah"); executeAction(IdeActions.ACTION_EDITOR_MOVE_CARET_DOWN_WITH_SELECTION); checkResultByText("blah blah\n" + "blah <selection>blah\n" + "blah bl<caret></selection>ah"); }
public void testSwapSelectionBoundariesWithStickySelection() throws IOException { initText("a<selection>b<caret></selection>c"); ((EditorEx)myEditor).setStickySelection(true); executeAction(IdeActions.ACTION_EDITOR_SWAP_SELECTION_BOUNDARIES); left(); checkResultByText("<selection><caret>ab</selection>c"); }
protected void advertiseActions(@NotNull JComponent splitters, @NotNull UIUtil.TextPainter painter) { appendSearchEverywhere(painter); appendToolWindow(painter, "Project View", ToolWindowId.PROJECT_VIEW, splitters); appendAction(painter, "Go to File", getActionShortcutText("GotoFile")); appendAction(painter, "Recent Files", getActionShortcutText(IdeActions.ACTION_RECENT_FILES)); appendAction(painter, "Navigation Bar", getActionShortcutText("ShowNavBar")); appendDnd(painter); }
@NotNull private Editor createEditor(){ Editor editor = EditorFactory.getInstance().createEditor(myDocument, myProject); ((EditorMarkupModel) editor.getMarkupModel()).setErrorStripeVisible(true); EditorHighlighter highlighter = EditorHighlighterFactory.getInstance().createEditorHighlighter(myFile, EditorColorsManager.getInstance().getGlobalScheme(), myProject); ((EditorEx) editor).setHighlighter(highlighter); ((EditorEx) editor).setFile(myFile); ((EditorEx)editor).setContextMenuGroupId(IdeActions.GROUP_EDITOR_POPUP); ((EditorImpl) editor).setDropHandler(new FileDropHandler(editor)); TextEditorProvider.putTextEditor(editor, myTextEditor); return editor; }
private void doTest() { final String testName = getTestName(true); myFixture.configureByFile("mover/" + testName + ".py"); myFixture.performEditorAction(IdeActions.ACTION_MOVE_STATEMENT_UP_ACTION); myFixture.checkResultByFile("mover/" + testName + "_afterUp.py", true); FileDocumentManager.getInstance().reloadFromDisk(myFixture.getDocument(myFixture.getFile())); myFixture.configureByFile("mover/" + getTestName(true) + ".py"); myFixture.performEditorAction(IdeActions.ACTION_MOVE_STATEMENT_DOWN_ACTION); myFixture.checkResultByFile("mover/" + testName + "_afterDown.py", true); }
@Override public void executeWriteAction(Editor editor, Caret caret, DataContext dataContext) { editor.getSelectionModel().removeSelection(); LogicalPosition caretPosition = editor.getCaretModel().getLogicalPosition(); final int line = caretPosition.line; int lineStartOffset = editor.getDocument().getLineStartOffset(line); editor.getCaretModel().moveToOffset(lineStartOffset); getHandler(IdeActions.ACTION_EDITOR_ENTER).execute(editor, caret, dataContext); editor.getCaretModel().moveToOffset(editor.getDocument().getLineStartOffset(line)); getHandler(IdeActions.ACTION_EDITOR_MOVE_LINE_END).execute(editor, caret, dataContext); }
@Override public void selectWordAtCaret(final boolean honorCamelWordsSettings) { validateContext(true); myEditor.getCaretModel().doWithCaretMerging(new Runnable() { @Override public void run() { removeSelection(); final EditorSettings settings = myEditor.getSettings(); boolean camelTemp = settings.isCamelWords(); final boolean needOverrideSetting = camelTemp && !honorCamelWordsSettings; if (needOverrideSetting) { settings.setCamelWords(false); } try { EditorActionHandler handler = EditorActionManager.getInstance().getActionHandler(IdeActions.ACTION_EDITOR_SELECT_WORD_AT_CARET); handler.execute(myEditor, CaretImpl.this, myEditor.getDataContext()); } finally { if (needOverrideSetting) { settings.resetCamelWords(); } } } }); }