Java Code Examples for org.eclipse.ui.texteditor.ITextEditor#isEditable()
The following examples show how to use
org.eclipse.ui.texteditor.ITextEditor#isEditable() .
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 Project: APICloud-Studio File: ExpandSnippetVerifyKeyListener.java License: GNU General Public License v3.0 | 6 votes |
private boolean canModifyEditor(ITextEditor editor) { if (editor instanceof ITextEditorExtension2) { return ((ITextEditorExtension2) editor).isEditorInputModifiable(); } else if (editor instanceof ITextEditorExtension) { return !((ITextEditorExtension) editor).isEditorInputReadOnly(); } else if (editor != null) { return editor.isEditable(); } return false; }
Example 2
Source Project: Pydev File: BaseAction.java License: Eclipse Public License 1.0 | 6 votes |
/** * @return true if the contents of the editor may be changed. Clients MUST call this before actually * modifying the editor. */ public static boolean canModifyEditor(ITextEditor editor) { if (editor instanceof ITextEditorExtension2) { return ((ITextEditorExtension2) editor).isEditorInputModifiable(); } else if (editor instanceof ITextEditorExtension) { return !((ITextEditorExtension) editor).isEditorInputReadOnly(); } else if (editor != null) { return editor.isEditable(); } //If we don't have the editor, let's just say it's ok (working on document). return true; }
Example 3
Source Project: xds-ide File: AddBlockCommentHandler.java License: Eclipse Public License 1.0 | 5 votes |
protected boolean validateEditorInputState(ITextEditor editor) { if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }
Example 4
Source Project: xds-ide File: RemoveBlockCommentHandler.java License: Eclipse Public License 1.0 | 5 votes |
protected boolean validateEditorInputState(ITextEditor editor) { if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }
Example 5
Source Project: Eclipse-Postfix-Code-Completion File: JavaSourceViewerConfiguration.java License: Eclipse Public License 1.0 | 5 votes |
@Override public IReconciler getReconciler(ISourceViewer sourceViewer) { final ITextEditor editor= getEditor(); if (editor != null && editor.isEditable()) { JavaCompositeReconcilingStrategy strategy= new JavaCompositeReconcilingStrategy(sourceViewer, editor, getConfiguredDocumentPartitioning(sourceViewer)); JavaReconciler reconciler= new JavaReconciler(editor, strategy, false); reconciler.setIsAllowedToModifyDocument(false); reconciler.setDelay(500); return reconciler; } return null; }
Example 6
Source Project: Eclipse-Postfix-Code-Completion File: BlockCommentAction.java License: Eclipse Public License 1.0 | 5 votes |
/** * Ensures that the editor is modifyable. If the editor is an instance of * <code>ITextEditorExtension2</code>, its <code>validateEditorInputState</code> method * is called, otherwise, the result of <code>isEditable</code> is returned. * * @param editor the editor to be checked * @return <code>true</code> if the editor is editable, <code>false</code> otherwise */ protected boolean ensureEditable(ITextEditor editor) { Assert.isNotNull(editor); if (editor instanceof ITextEditorExtension2) { ITextEditorExtension2 ext= (ITextEditorExtension2) editor; return ext.validateEditorInputState(); } return editor.isEditable(); }
Example 7
Source Project: e4macs File: EmacsPlusCmdHandler.java License: Eclipse Public License 1.0 | 5 votes |
/** * Eclipse forces us to check this ourselves * * @return true if the editor is modifiable */ private boolean getEditable() { boolean result = false; ITextEditor editor= getThisEditor(); if (editor != null) { if (editor instanceof ITextEditorExtension2) result = ((ITextEditorExtension2) editor).isEditorInputModifiable(); else if (editor instanceof ITextEditorExtension) result = !((ITextEditorExtension) editor).isEditorInputReadOnly(); else result = editor.isEditable(); } return result; }
Example 8
Source Project: xds-ide File: ToggleCommentHandler.java License: Eclipse Public License 1.0 | 3 votes |
/** * Checks and validates the editor's modifiable state. Returns <code>true</code> if an action * can proceed modifying the editor's input, <code>false</code> if it should not. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#validateEditorInputState()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #canModifyEditor()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action can proceed to modify the underlying document, <code>false</code> otherwise */ protected boolean validateEditorInputState(ITextEditor editor) { if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }
Example 9
Source Project: goclipse File: TextEditorAction_Adapter.java License: Eclipse Public License 1.0 | 3 votes |
/** * Checks the editor's modifiable state. Returns <code>true</code> if the editor can be modified, * taking in account the possible editor extensions. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#isEditorInputModifiable()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #validateEditorInputState()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action should be enabled, <code>false</code> otherwise * @since 3.0 */ protected boolean canModifyEditor() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).isEditorInputModifiable(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }
Example 10
Source Project: goclipse File: TextEditorAction_Adapter.java License: Eclipse Public License 1.0 | 3 votes |
/** * Checks and validates the editor's modifiable state. Returns <code>true</code> if an action * can proceed modifying the editor's input, <code>false</code> if it should not. * * <p>If the editor implements <code>ITextEditorExtension2</code>, * this method returns {@link ITextEditorExtension2#validateEditorInputState()};<br> else if the editor * implements <code>ITextEditorExtension</code>, it returns {@link ITextEditorExtension#isEditorInputReadOnly()};<br> * else, {@link ITextEditor#isEditable()} is returned, or <code>false</code> if the editor is <code>null</code>.</p> * * <p>There is only a difference to {@link #canModifyEditor()} if the editor implements * <code>ITextEditorExtension2</code>.</p> * * @return <code>true</code> if a modifying action can proceed to modify the underlying document, <code>false</code> otherwise * @since 3.0 */ protected boolean validateEditorInputState() { ITextEditor editor= getTextEditor(); if (editor instanceof ITextEditorExtension2) return ((ITextEditorExtension2) editor).validateEditorInputState(); else if (editor instanceof ITextEditorExtension) return !((ITextEditorExtension) editor).isEditorInputReadOnly(); else if (editor != null) return editor.isEditable(); else return false; }