Java Code Examples for com.intellij.openapi.editor.Editor#isViewer()
The following examples show how to use
com.intellij.openapi.editor.Editor#isViewer() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DiffPanelImpl.java From consulo with Apache License 2.0 | 5 votes |
@Nullable private static String addReadOnly(@Nullable String title, @Nullable Editor editor) { if (editor == null || title == null) { return title; } boolean readonly = editor.isViewer() || !editor.getDocument().isWritable(); if (readonly) { title += " " + DiffBundle.message("diff.content.read.only.content.title.suffix"); } return title; }
Example 2
Source File: Change.java From consulo with Apache License 2.0 | 5 votes |
public boolean canHasActions(FragmentSide fromSide) { FragmentSide targetSide = fromSide.otherSide(); Document targetDocument = getChangeList().getDocument(targetSide); if (!targetDocument.isWritable()) return false; Editor targetEditor = getHighlighterHolder(targetSide).getEditor(); return !targetEditor.isViewer(); }
Example 3
Source File: MultiplePasteAction.java From consulo with Apache License 2.0 | 5 votes |
private static boolean isEnabled(AnActionEvent e) { Object component = e.getData(PlatformDataKeys.CONTEXT_COMPONENT); if (!(component instanceof JComponent)) return false; Editor editor = e.getData(CommonDataKeys.EDITOR); if (editor != null) return !editor.isViewer(); Action pasteAction = ((JComponent)component).getActionMap().get(DefaultEditorKit.pasteAction); return pasteAction != null; }
Example 4
Source File: BaseIndentEnterHandler.java From consulo with Apache License 2.0 | 5 votes |
protected Result shouldSkipWithResult(@Nonnull final PsiFile file, @Nonnull final Editor editor, @Nonnull final DataContext dataContext) { final Project project = dataContext.getData(CommonDataKeys.PROJECT); if (project == null) { return Result.Continue; } if (!file.getViewProvider().getLanguages().contains(myLanguage)) { return Result.Continue; } if (editor.isViewer()) { return Result.Continue; } final Document document = editor.getDocument(); if (!document.isWritable()) { return Result.Continue; } PsiDocumentManager.getInstance(project).commitDocument(document); int caret = editor.getCaretModel().getOffset(); if (caret == 0) { return Result.DefaultSkipIndent; } if (caret <= 0) { return Result.Continue; } return null; }
Example 5
Source File: BaseMoveHandler.java From consulo with Apache License 2.0 | 5 votes |
@Override public boolean isEnabledForCaret(@Nonnull Editor editor, @Nonnull Caret caret, DataContext dataContext) { if (editor.isViewer() || editor.isOneLineMode()) return false; final Project project = editor.getProject(); if (project == null || project.isDisposed()) return false; return true; }
Example 6
Source File: MergeOperations.java From consulo with Apache License 2.0 | 4 votes |
private boolean isWritable(FragmentSide side) { Editor editor = myDiffPanel.getEditor(side); return !editor.isViewer() && canMakeWritable(editor.getDocument()); }
Example 7
Source File: BasePasteHandler.java From consulo with Apache License 2.0 | 4 votes |
@Override public boolean isEnabledForCaret(@Nonnull Editor editor, @Nonnull Caret caret, DataContext dataContext) { return !editor.isViewer(); }
Example 8
Source File: CodeCompletionHandlerBase.java From consulo with Apache License 2.0 | 4 votes |
private void invokeCompletion(@Nonnull Project project, @Nonnull Editor editor, int time, boolean hasModifiers, @Nonnull Caret caret) { markCaretAsProcessed(caret); if (invokedExplicitly) { StatisticsUpdate.applyLastCompletionStatisticsUpdate(); } checkNoWriteAccess(); CompletionAssertions.checkEditorValid(editor); int offset = editor.getCaretModel().getOffset(); if (editor.isViewer() || editor.getDocument().getRangeGuard(offset, offset) != null) { editor.getDocument().fireReadOnlyModificationAttempt(); EditorModificationUtil.checkModificationAllowed(editor); return; } if (!FileDocumentManager.getInstance().requestWriting(editor.getDocument(), project)) { return; } CompletionPhase phase = CompletionServiceImpl.getCompletionPhase(); boolean repeated = phase.indicator != null && phase.indicator.isRepeatedInvocation(completionType, editor); final int newTime = phase.newCompletionStarted(time, repeated); if (invokedExplicitly) { time = newTime; } final int invocationCount = time; if (CompletionServiceImpl.isPhase(CompletionPhase.InsertedSingleItem.class)) { CompletionServiceImpl.setCompletionPhase(CompletionPhase.NoCompletion); } CompletionServiceImpl.assertPhase(CompletionPhase.NoCompletion.getClass(), CompletionPhase.CommittingDocuments.class); if (invocationCount > 1 && completionType == CompletionType.BASIC) { FeatureUsageTracker.getInstance().triggerFeatureUsed(CodeCompletionFeatures.SECOND_BASIC_COMPLETION); } long startingTime = System.currentTimeMillis(); Runnable initCmd = () -> { CompletionInitializationContextImpl context = withTimeout(calcSyncTimeOut(startingTime), () -> CompletionInitializationUtil.createCompletionInitializationContext(project, editor, caret, invocationCount, completionType)); boolean hasValidContext = context != null; if (!hasValidContext) { final PsiFile psiFile = PsiUtilBase.getPsiFileInEditor(caret, project); context = new CompletionInitializationContextImpl(editor, caret, psiFile, completionType, invocationCount); } doComplete(context, hasModifiers, hasValidContext, startingTime); }; try { if (autopopup) { CommandProcessor.getInstance().runUndoTransparentAction(initCmd); } else { CommandProcessor.getInstance().executeCommand(project, initCmd, null, null, editor.getDocument()); } } catch (IndexNotReadyException e) { if (invokedExplicitly) { DumbService.getInstance(project).showDumbModeNotification("Code completion is not available here while indices are being built"); } } }
Example 9
Source File: BraceHighlightingHandler.java From consulo with Apache License 2.0 | 4 votes |
private static boolean isValidEditor(@Nonnull Editor editor) { Project editorProject = editor.getProject(); return editorProject != null && !editorProject.isDisposed() && !editor.isDisposed() && editor.getComponent().isShowing() && !editor.isViewer(); }
Example 10
Source File: CodeInsightUtilBase.java From consulo with Apache License 2.0 | 4 votes |
public static boolean prepareEditorForWrite(@Nonnull Editor editor) { if (!editor.isViewer()) return true; showReadOnlyViewWarning(editor); return false; }