Presentation is loading. Please wait.

Presentation is loading. Please wait.

1 org.eclipse.ui.texteditor-api l Provides a framework for text editors obeying to the desktop rules. org.eclipse.ui.texteditor.

Similar presentations


Presentation on theme: "1 org.eclipse.ui.texteditor-api l Provides a framework for text editors obeying to the desktop rules. org.eclipse.ui.texteditor."— Presentation transcript:

1 1 org.eclipse.ui.texteditor-api l Provides a framework for text editors obeying to the desktop rules. org.eclipse.ui.texteditor

2 2 package Description l ITextEditor extends IEditorPart with text editor specific functionality. l Text editors use source viewers (ISourceViewer) for displaying and editing the given editor input. l In order to translate the editor input into a document and vice versa (e.g., for saving a change), a text editor uses document providers (IDocumentProvider). l A document provider is responsible not just for providing the document for a given editor input but for the complete translation between the domain model and the editor's internal document-based model. l Document provider can be shared between editors. l The package provides a default implementation of ITextEditor (AbstractTextEditor). l This default implementation also covers the editor's complete action management and activation. The package contains a number of configurable and predefined actions. AbstractMarkerAnnotationModel establishs a link between text annotations (Annotation) and desktop markers (IMarker).

3 3 ITextEditor l Highlight management l void setHighlightRange(int offset, int length, boolean moveCursor) l IRegion getHighlightRange() »Sets/get the highlighted range of this text editor to the specified region. l void resetHighlightRange() »Resets the highlighted range of this text editor. l void showHighlightRangeOnly(boolean showHighlightRangeOnly) »Configures this text editor to show only the highlighted range of the text. l boolean showsHighlightRangeOnly() »Returns whether this text editor is configured to show only the highlighted range of the text.

4 4 org.eclipse.jface.action.IAction l Non-UI side of a command which can be triggered by the end user. l Typically associated with buttons, menu items, and items in tool bars. l The controls for a command are built by some container, which furnished the context where these controls appear and configures them with data from properties declared by the action. When the end user triggers the command via its control, the action's run method is invoked to do the real work.

5 5 Properties of IAction l description : String // text Description l text, toolTipText, l id: int l actionDefinitionId : String l accelerator : int // key code l chencked : boolean // fire Property change if changed style : one of AS_PUSH_BUTTON, AS_CHECK_BOX, and AS_DROP_DOWN. l disabledImageDescriptor, HoverImageDescriptor, imageDescriptor :ImageDescriptor

6 6 Methods provided by IAction l listener management: »add/remove HelpListener, PropertyChangeListener l main methods: »void run() » this method is invoked whenever the action is triggered. »public void runWithEvent(Event event) » Runs this action, passing the triggering SWT event.

7 7 org.eclipse.jface.util. IPropertyChangeListener l Listener for property changes. Usage: IPropertyChangeListener listener = new IPropertyChangeListener() { public void propertyChange(PropertyChangeEvent event) {... // code to deal with occurrence of property change } }; emitter.addPropertyChangeListener(listener);... emitter.removePropertyChangeListener(listener);

8 8 org.eclipse.jface.util. IPropertyChangeEvent l extends EventObject l describing a change to a named property. l class designed to be instantiated, but may also be subclassed if required. The JFace frameworks contain classes that report property change events for internal state changes that may be of interest to external parties. A special listener interface ( IPropertyChangeListener ) is defined for this purpose, and a typical class allow listeners to be registered via an addPropertyChangeListener method.

9 9 > IPropertyChangeListener Property Change Listener (listener) Source : s client 1. addPropertyChangeListener(l) 2. porpertyChange(e) 3. removePropertyChangeListener(l) internal property change ==> fire propertyChange(…)

10 10

11 11 PropertyChangeEvent l extends EventObject l Constructors l PropertyChangeEvent(Object source, String property, Object oldValue, Object newValue) »Creates a new property change event. l Methods »Object getNewValue() » Returns the new value of the property. l Object getOldValue() » Returns the old value of the property. l String getProperty() » Returns the name of the property that changed.


Download ppt "1 org.eclipse.ui.texteditor-api l Provides a framework for text editors obeying to the desktop rules. org.eclipse.ui.texteditor."

Similar presentations


Ads by Google