类org.eclipse.ui.texteditor.ITextEditorExtension2源码实例Demo

下面列出了怎么用org.eclipse.ui.texteditor.ITextEditorExtension2的API类实例代码及写法,或者点击链接到github查看源代码。

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;
}
 
源代码2 项目: Pydev   文件: BaseAction.java
/**
 * @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;
}
 
源代码3 项目: xds-ide   文件: AddBlockCommentHandler.java
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;
}
 
源代码4 项目: xds-ide   文件: RemoveBlockCommentHandler.java
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;
}
 
/**
 * 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();
}
 
源代码6 项目: e4macs   文件: EmacsPlusCmdHandler.java
/**
 * 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;
}
 
源代码7 项目: Pydev   文件: PyEdit.java
public static void checkValidateState(IEditorPart iEditorPart) {
    if (iEditorPart instanceof ITextEditorExtension2) {
        ITextEditorExtension2 editor = (ITextEditorExtension2) iEditorPart;
        editor.validateEditorInputState();

    }
}
 
源代码8 项目: xds-ide   文件: ToggleCommentHandler.java
/**
 * 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;
}
 
源代码9 项目: goclipse   文件: TextEditorAction_Adapter.java
/**
 * 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;
}
 
源代码10 项目: goclipse   文件: TextEditorAction_Adapter.java
/**
 * 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;
}
 
 类所在包
 类方法
 同包方法