1 package org
.argeo
.cms
.ui
.eclipse
.forms
.editor
;
3 import org
.argeo
.cms
.ui
.eclipse
.forms
.FormToolkit
;
4 import org
.eclipse
.core
.runtime
.ListenerList
;
5 import org
.eclipse
.jface
.dialogs
.IPageChangeProvider
;
6 import org
.eclipse
.jface
.dialogs
.IPageChangedListener
;
7 import org
.eclipse
.jface
.dialogs
.PageChangedEvent
;
8 import org
.eclipse
.jface
.util
.SafeRunnable
;
11 * This class forms a base of multi-page form editors that typically use one or
12 * more pages with forms and one page for raw source of the editor input.
14 * Pages are added 'lazily' i.e. adding a page reserves a tab for it but does
15 * not cause the page control to be created. Page control is created when an
16 * attempt is made to select the page in question. This allows editors with
17 * several tabs and complex pages to open quickly.
19 * Subclasses should extend this class and implement <code>addPages</code>
20 * method. One of the two <code>addPage</code> methods should be called to
21 * contribute pages to the editor. One adds complete (standalone) editors as
22 * nested tabs. These editors will be created right away and will be hooked so
23 * that key bindings, selection service etc. is compatible with the one for the
24 * standalone case. The other method adds classes that implement
25 * <code>IFormPage</code> interface. These pages will be created lazily and
26 * they will share the common key binding and selection service. Since 3.1,
27 * FormEditor is a page change provider. It allows listeners to attach to it and
28 * get notified when pages are changed. This new API in JFace allows dynamic
29 * help to update on page changes.
33 // RAP [if] As RAP is still using workbench 3.4, the implementation of
34 // IPageChangeProvider is missing from MultiPageEditorPart. Remove this code
35 // with the adoption of workbench > 3.5
36 //public abstract class FormEditor extends MultiPageEditorPart {
37 public abstract class FormEditor
implements
39 private FormToolkit formToolkit
;
42 public FormToolkit
getToolkit() {
46 public void editorDirtyStateChanged() {
50 public FormPage
getActivePageInstance() {
54 // RAP [if] As RAP is still using workbench 3.4, the implementation of
55 // IPageChangeProvider is missing from MultiPageEditorPart. Remove this code
56 // with the adoption of workbench > 3.5
57 private ListenerList pageListeners
= new ListenerList();
62 * @see org.eclipse.jface.dialogs.IPageChangeProvider#addPageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener)
64 public void addPageChangedListener(IPageChangedListener listener
) {
65 pageListeners
.add(listener
);
71 * @see org.eclipse.jface.dialogs.IPageChangeProvider#removePageChangedListener(org.eclipse.jface.dialogs.IPageChangedListener)
73 public void removePageChangedListener(IPageChangedListener listener
) {
74 pageListeners
.remove(listener
);
77 private void firePageChanged(final PageChangedEvent event
) {
78 Object
[] listeners
= pageListeners
.getListeners();
79 for (int i
= 0; i
< listeners
.length
; ++i
) {
80 final IPageChangedListener l
= (IPageChangedListener
) listeners
[i
];
81 SafeRunnable
.run(new SafeRunnable() {