Bug 321623 - [api] Provide a TextOperationTargetAction (was: TextViewerAction duplicates)
Summary: [api] Provide a TextOperationTargetAction (was: TextViewerAction duplicates)
Status: ASSIGNED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: ---   Edit
Assignee: Platform-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: api
Depends on:
Blocks:
 
Reported: 2010-08-03 11:53 EDT by Chris Aniszczyk CLA
Modified: 2019-09-06 15:29 EDT (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Chris Aniszczyk CLA 2010-08-03 11:53:30 EDT
There are at least four copies of TextViewerAction in the platform.

org.eclipse.ui.console.actions.TextViewerAction (this is bad since this is API)
org.eclipse.jdt.internal.ui.preferences.EditTemplateDialog.TextViewerAction
org.eclipse.ui.texteditor.templates.TemplatePreferencePage.EditTemplateDialog...
org.eclipse.team.internal.ccvs.ui.TextViewerAction

Is there a better way to do this now or should we come up with API?
Comment 1 Dani Megert CLA 2010-08-03 15:05:45 EDT
What's the point of this question? Do you have the need for something specific? If not, did you compare them? Are they similar?
Comment 2 Chris Aniszczyk CLA 2010-08-03 15:33:25 EDT
Yes, they are all the same...

private class TextViewerAction extends Action implements IUpdate {

			private int fOperationCode= -1;
			private ITextOperationTarget fOperationTarget;

			/**
			 * Creates a new action.
			 *
			 * @param viewer the viewer
			 * @param operationCode the opcode
			 */
			public TextViewerAction(ITextViewer viewer, int operationCode) {
				fOperationCode= operationCode;
				fOperationTarget= viewer.getTextOperationTarget();
				update();
			}

			/**
			 * Updates the enabled state of the action.
			 * Fires a property change if the enabled state changes.
			 *
			 * @see Action#firePropertyChange(String, Object, Object)
			 */
			public void update() {
				// XXX: workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=206111
				if (fOperationCode == ITextOperationTarget.REDO)
					return;

				boolean wasEnabled= isEnabled();
				boolean isEnabled= (fOperationTarget != null && fOperationTarget.canDoOperation(fOperationCode));
				setEnabled(isEnabled);

				if (wasEnabled != isEnabled) {
					firePropertyChange(ENABLED, wasEnabled ? Boolean.TRUE : Boolean.FALSE, isEnabled ? Boolean.TRUE : Boolean.FALSE);
				}
			}

			/**
			 * @see Action#run()
			 */
			public void run() {
				if (fOperationCode != -1 && fOperationTarget != null) {
					fOperationTarget.doOperation(fOperationCode);
				}
			}
		}
Comment 3 Eclipse Webmaster CLA 2019-09-06 15:29:57 EDT
This bug hasn't had any activity in quite some time. Maybe the problem got resolved, was a duplicate of something else, or became less pressing for some reason - or maybe it's still relevant but just hasn't been looked at yet.

If you have further information on the current state of the bug, please add it. The information can be, for example, that the problem still occurs, that you still want the feature, that more information is needed, or that the bug is (for whatever reason) no longer relevant.