/** * 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(); }
/** * 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(); }
/** * 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(); }
/** * 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; } }
/** * 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; }
/** * 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; } }
/** * 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; }
/** * 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; }
/** * 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; } }
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.setIsIncrementalReconciler(false); reconciler.setIsAllowedToModifyDocument(false); reconciler.setProgressMonitor(new NullProgressMonitor()); reconciler.setDelay(500); return reconciler; } return null; }
@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; }
@Override public void update() { super.update(); if (!isEnabled()) return; if (!canModifyEditor()) { setEnabled(false); return; } ITextEditor editor= getTextEditor(); setEnabled(editor.isEditable()); }
public void update() { super.update(); if (!isEnabled()) return; if (!canModifyEditor()) { setEnabled(false); return; } ITextEditor editor= getTextEditor(); setEnabled(editor.isEditable()); }
@Override public void update() { super.update(); if (!isEnabled()) return; if (!canModifyEditor()) { setEnabled(false); return; } ITextEditor editor= getTextEditor(); setEnabled(editor.isEditable()); }
@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; }
/** * Returns whether quick diff info should be visible upon opening an editor * according to the preference store settings. * * @return <code>true</code> if the line numbers should be visible */ private boolean getQuickDiffPreference() { if (fForwarder != null) return fForwarder.isQuickDiffEnabled(); IPreferenceStore store= getPreferenceStore(); boolean setting= store != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false; if (!setting) return false; boolean modifiable; ITextEditor editor= getEditor(); if (editor instanceof ITextEditorExtension2) { ITextEditorExtension2 ext= (ITextEditorExtension2) editor; modifiable= ext.isEditorInputModifiable(); } else if (editor instanceof ITextEditorExtension) { ITextEditorExtension ext= (ITextEditorExtension) editor; modifiable= ext.isEditorInputReadOnly(); } else if (editor != null) { modifiable= editor.isEditable(); } else { modifiable= true; } return modifiable; }
/** * Returns whether quick diff info should be visible upon opening an editor * according to the preference store settings. * * @return <code>true</code> if the line numbers should be visible */ private boolean getQuickDiffPreference() { if (fForwarder != null) return fForwarder.isQuickDiffEnabled(); IPreferenceStore store= getPreferenceStore(); boolean setting= store != null ? store.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.QUICK_DIFF_ALWAYS_ON) : false; if (!setting) return false; boolean modifiable; ITextEditor editor= getEditor(); if (editor instanceof ITextEditorExtension2) { ITextEditorExtension2 ext= (ITextEditorExtension2) editor; modifiable= ext.isEditorInputModifiable(); } else if (editor instanceof ITextEditorExtension) { ITextEditorExtension ext= (ITextEditorExtension) editor; modifiable= ext.isEditorInputReadOnly(); } else if (editor != null) { modifiable= editor.isEditable(); } else { modifiable= true; } return modifiable; }
/** * @see org.eclipse.ui.IEditorActionBarContributor#setActiveEditor(IEditorPart) */ public void setActiveEditor(IEditorPart activeEditor) { if (getActiveEditorPart() == activeEditor) { return; } super.setActiveEditor(activeEditor); IActionBars actionBars = getActionBars(); if (actionBars != null) { IStatusLineManager statusLineManager = actionBars.getStatusLineManager(); if (statusLineManager != null) { statusLineManager.setMessage(null); statusLineManager.setErrorMessage(null); } } ITextEditor textEditor = getTextEditor(activeEditor); fShowTooltipAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_INFORMATION)); fContentAssist.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CONTENTASSIST_PROPOSALS)); fCleanupDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_CLEANUP_DOCUMENT)); fFormatDocument.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_DOCUMENT)); fFormatActiveElements.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FORMAT_ACTIVE_ELEMENTS)); fCleanupDocument.setEnabled((textEditor != null) && textEditor.isEditable()); fFormatDocument.setEnabled((textEditor != null) && textEditor.isEditable()); fFormatActiveElements.setEnabled((textEditor != null) && textEditor.isEditable()); fOpenFileAction.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_OPEN_FILE)); fFindOccurrences.setAction(getAction(textEditor, StructuredTextEditorActionConstants.ACTION_NAME_FIND_OCCURRENCES)); }