Java Code Examples for org.eclipse.jface.text.ITextViewer#getTextOperationTarget()

The following examples show how to use org.eclipse.jface.text.ITextViewer#getTextOperationTarget() . 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: TextViewerOperationAction.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
/**
 * The <code>TextOperationAction</code> implementation of this <code>IUpdate</code> method discovers the operation
 * through the current editor's <code>ITextOperationTarget</code> adapter, and sets the enabled state accordingly.
 */
@Override
public void update() {
	if (!fAllowUpdate)
		return;

	super.update();

	if (!fRunsOnReadOnly && !canModifyViewer()) {
		setEnabled(false);
		return;
	}

	ITextViewer viewer = getTextViewer();
	if (fOperationTarget == null && viewer != null && fOperationCode != -1)
		fOperationTarget = viewer.getTextOperationTarget();

	boolean isEnabled = (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
	setEnabled(isEnabled);
}
 
Example 2
Source File: TextViewerShiftAction.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public void update() {
	super.update();
	if (!isEnabled())
		return;

	if (!canModifyViewer()) {
		setEnabled(false);
		return;
	}

	ITextViewer viewer = getTextViewer();
	if (fOperationTarget == null && viewer != null && fOperationCode != -1)
		fOperationTarget = viewer.getTextOperationTarget();

}
 
Example 3
Source File: TextViewerShiftAction.java    From xtext-eclipse with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public boolean isEnabled(boolean isWritable) {

	if (!isWritable)
		return false;

	/*
	 * Note that this implementation still honors the result returned by canDoOperation.
	 * I.e. if the viewer is set to read-only, this method still returns false.
	 * It covers the case in which the viewer is also writable.
	 *
	 */
	ITextViewer viewer = getTextViewer();
	if (fOperationTarget == null && viewer != null && fOperationCode != -1)
		fOperationTarget = viewer.getTextOperationTarget();

	return (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
}
 
Example 4
Source File: TextViewerAction.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
public TextViewerAction(ITextViewer viewer, int operationCode) {
	this.operationCode = operationCode;
	operationTarget = viewer.getTextOperationTarget();
	update();
}
 
Example 5
Source File: EditTemplateDialog.java    From typescript.java with MIT License 2 votes vote down vote up
/**
 * Creates a new action.
 * 
 * @param viewer
 *            the viewer
 * @param operationCode
 *            the opcode
 */
public TextViewerAction(ITextViewer viewer, int operationCode) {
	fOperationCode = operationCode;
	fOperationTarget = viewer.getTextOperationTarget();
	update();
}
 
Example 6
Source File: EditTemplateDialog.java    From Eclipse-Postfix-Code-Completion with Eclipse Public License 1.0 2 votes vote down vote up
/**
 * Creates a new action.
 *
 * @param viewer the viewer
 * @param operationCode the opcode
 */
public TextViewerAction(ITextViewer viewer, int operationCode) {
	fOperationCode= operationCode;
	fOperationTarget= viewer.getTextOperationTarget();
	update();
}