1 package org.argeo.cms.ui.eclipse.forms; 2 3 import org.eclipse.jface.viewers.ISelection; 4 import org.eclipse.swt.custom.ScrolledComposite; 5 //import org.eclipse.ui.forms.widgets.FormToolkit; 6 //import org.eclipse.ui.forms.widgets.ScrolledForm; 7 8 /** 9 * Managed form wraps a form widget and adds life cycle methods for form parts. 10 * A form part is a portion of the form that participates in form life cycle 11 * events. 12 * <p> 13 * There is no 1/1 mapping between widgets and form parts. A widget like Section 14 * can be a part by itself, but a number of widgets can gather around one form 15 * part. 16 * <p> 17 * This interface should not be extended or implemented. New form instances 18 * should be created using ManagedForm. 19 * 20 * @see ManagedForm 21 * @since 1.0 22 * @noimplement This interface is not intended to be implemented by clients. 23 * @noextend This interface is not intended to be extended by clients. 24 */ 25 public interface IManagedForm { 26 /** 27 * Initializes the form by looping through the managed parts and 28 * initializing them. Has no effect if already called once. 29 */ 30 public void initialize(); 31 32 /** 33 * Returns the toolkit used by this form. 34 * 35 * @return the toolkit 36 */ 37 public FormToolkit getToolkit(); 38 39 /** 40 * Returns the form widget managed by this form. 41 * 42 * @return the form widget 43 */ 44 public ScrolledComposite getForm(); 45 46 /** 47 * Reflows the form as a result of the layout change. 48 * 49 * @param changed 50 * if <code>true</code>, discard cached layout information 51 */ 52 public void reflow(boolean changed); 53 54 /** 55 * A part can use this method to notify other parts that implement 56 * IPartSelectionListener about selection changes. 57 * 58 * @param part 59 * the part that broadcasts the selection 60 * @param selection 61 * the selection in the part 62 */ 63 public void fireSelectionChanged(IFormPart part, ISelection selection); 64 65 /** 66 * Returns all the parts currently managed by this form. 67 * 68 * @return the managed parts 69 */ 70 IFormPart[] getParts(); 71 72 /** 73 * Adds the new part to the form. 74 * 75 * @param part 76 * the part to add 77 */ 78 void addPart(IFormPart part); 79 80 /** 81 * Removes the part from the form. 82 * 83 * @param part 84 * the part to remove 85 */ 86 void removePart(IFormPart part); 87 88 /** 89 * Sets the input of this page to the provided object. 90 * 91 * @param input 92 * the new page input 93 * @return <code>true</code> if the form contains this object, 94 * <code>false</code> otherwise. 95 */ 96 boolean setInput(Object input); 97 98 /** 99 * Returns the current page input. 100 * 101 * @return page input object or <code>null</code> if not applicable. 102 */ 103 Object getInput(); 104 105 /** 106 * Tests if form is dirty. A managed form is dirty if at least one managed 107 * part is dirty. 108 * 109 * @return <code>true</code> if at least one managed part is dirty, 110 * <code>false</code> otherwise. 111 */ 112 boolean isDirty(); 113 114 /** 115 * Notifies the form that the dirty state of one of its parts has changed. 116 * The global dirty state of the form can be obtained by calling 'isDirty'. 117 * 118 * @see #isDirty 119 */ 120 void dirtyStateChanged(); 121 122 /** 123 * Commits the dirty form. All pending changes in the widgets are flushed 124 * into the model. 125 * 126 * @param onSave 127 */ 128 void commit(boolean onSave); 129 130 /** 131 * Tests if form is stale. A managed form is stale if at least one managed 132 * part is stale. This can happen when the underlying model changes, 133 * resulting in the presentation of the part being out of sync with the 134 * model and needing refreshing. 135 * 136 * @return <code>true</code> if the form is stale, <code>false</code> 137 * otherwise. 138 */ 139 boolean isStale(); 140 141 /** 142 * Notifies the form that the stale state of one of its parts has changed. 143 * The global stale state of the form can be obtained by calling 'isStale'. 144 */ 145 void staleStateChanged(); 146 147 /** 148 * Refreshes the form by refreshing every part that is stale. 149 */ 150 void refresh(); 151 152 /** 153 * Sets the container that owns this form. Depending on the context, the 154 * container may be wizard, editor page, editor etc. 155 * 156 * @param container 157 * the container of this form 158 */ 159 void setContainer(Object container); 160 161 /** 162 * Returns the container of this form. 163 * 164 * @return the form container 165 */ 166 Object getContainer(); 167 168 /** 169 * Returns the message manager that will keep track of messages in this 170 * form. 171 * 172 * @return the message manager instance 173 */ 174 // IMessageManager getMessageManager(); 175 }