001: package net.refractions.udig.project.ui.tool;
002:
003: import java.util.List;
004:
005: import net.refractions.udig.project.ui.internal.MapEditor;
006: import net.refractions.udig.project.ui.internal.tool.display.ActionToolCategory;
007: import net.refractions.udig.project.ui.internal.tool.display.ModalToolCategory;
008: import net.refractions.udig.project.ui.internal.tool.display.ToolCategory;
009:
010: import org.eclipse.jface.action.IAction;
011: import org.eclipse.jface.action.IMenuManager;
012: import org.eclipse.jface.action.IToolBarManager;
013: import org.eclipse.jface.action.MenuManager;
014: import org.eclipse.jface.action.SubCoolBarManager;
015: import org.eclipse.jface.viewers.ISelection;
016: import org.eclipse.swt.graphics.Cursor;
017: import org.eclipse.ui.IActionBars;
018: import org.eclipse.ui.IWorkbenchPart;
019:
020: public interface IToolManager {
021:
022: public final String XPID = "net.refractions.udig.project.ui.toolManagers"; //$NON-NLS-1$
023: /**
024: * Points to id field of extension point attribute
025: */
026: public final String ATTR_ID = "id"; //$NON-NLS-1$
027:
028: /**
029: * Points to class field of extension point attribute
030: */
031: public final String ATTR_CLASS = "class"; //$NON-NLS-1$
032:
033: /**
034: * Preference constant that can used to set and look up the default
035: * IToolManager. This can be set in plugin_customization.ini with the key
036: * "net.refractions.udig.project.ui/toolManager".
037: */
038: public final String P_TOOL_MANAGER = "toolManager"; //$NON-NLS-1$
039:
040: void setCurrentEditor(MapEditor editor);
041:
042: /**
043: * Adds an Action that executes a tool to the toolbar.
044: *
045: * @param action
046: */
047: void addToolAction(IAction action);
048:
049: /**
050: * Creates a action that acts as a proxy for the tool in the editor toolbar.
051: * <p>
052: * The client code must set the name image descriptor etc... of the Action
053: * </p>
054: *
055: * @param toolID the id of the tool
056: * @param categoryID the category the tool is part of
057: * @return a proxy action that can be put in other toolbars
058: */
059: IAction createToolAction(final String toolID,
060: final String categoryID);
061:
062: ActionToolCategory findActionCategory(String id);
063:
064: void contributeToMenu(IMenuManager manager);
065:
066: /**
067: * Contributes items from current active modal tool to the
068: * context menu if the modal tool implements <code>IContextMenuContributionTool</code>
069: * interface.
070: *
071: * @param manager
072: * a context menu manager from MapEditor.
073: */
074: void contributeActiveModalTool(IMenuManager manager);
075:
076: /**
077: * Retrieves the redo action that is used by much of the map components such as the MapEditor
078: * and the LayersView. redoes the last undone command sent to the currently active map.
079: */
080: IAction getREDOAction();
081:
082: void setREDOAction(IAction action, IWorkbenchPart part);
083:
084: /**
085: * Retrieves the undo action that is used by much of the map components such as the MapEditor
086: * and the LayersView. Undoes the last command sent to the currently active map.
087: *
088: * @param part
089: */
090: IAction getUNDOAction();
091:
092: void setUNDOAction(IAction action, IWorkbenchPart part);
093:
094: /**
095: * Retrieves the forward navigation action that is used by much of the map components such as
096: * the MapEditor and the LayersView. Executes the last undone Nav command on the current map.
097: */
098: IAction getFORWARD_HISTORYAction();
099:
100: void setFORWARDAction(IAction action, IWorkbenchPart part);
101:
102: /**
103: * Registers keybindings for tools and cut/paste with the workbench part
104: *
105: * @param part
106: */
107: void registerActionsWithPart(IWorkbenchPart part);
108:
109: /**
110: * Unregisters keybindings for tools and cut/paste with the workbench part
111: *
112: * @param part
113: */
114: public void unregisterActions(IWorkbenchPart part);
115:
116: /**
117: * Retrieves the backward navigation action that is used by much of the map components such as
118: * the MapEditor and the LayersView. Undoes the last Nav command set to the current map.
119: *
120: * @param part
121: */
122: IAction getBACKWARD_HISTORYAction();
123:
124: void setBACKAction(IAction action, IWorkbenchPart part);
125:
126: IAction getCUTAction(IWorkbenchPart part);
127:
128: void setCUTAction(IAction action, IWorkbenchPart part);
129:
130: IAction getCOPYAction(final IWorkbenchPart part);
131:
132: void setCOPYAction(IAction action, IWorkbenchPart part);
133:
134: IAction getPASTEAction(IWorkbenchPart part);
135:
136: void setPASTEAction(IAction action, IWorkbenchPart part);
137:
138: IAction getDELETEAction();
139:
140: void setDELETEAction(IAction action, IWorkbenchPart part);
141:
142: /**
143: * Adds both action tools and modal tools to the manager
144: * @deprecated
145: *
146: * @param cbmanager
147: * @param bars
148: * @see net.refractions.udig.project.ui.tool.ModalTool
149: * @see net.refractions.udig.project.ui.tool.ActionTool
150: *
151: */
152: void contributeToCoolBar(SubCoolBarManager cbmanager,
153: IActionBars bars);
154:
155: /**
156: * Adds action tools contribution items to the toolbar.
157: * <p>
158: * The actual toolbar UI elements are created and managed by the framework, IToolManager
159: * just adds action tools as contributions to the specified <code>IToolBarManager</code>.
160: *
161: * @param toolManager
162: * @param bars
163: */
164: public void contributeActionTools(IToolBarManager toolBarManager,
165: IActionBars bars);
166:
167: /**
168: * Adds modal tools contribution items to the toolbar.
169: * <p>
170: * The actual toolbar UI elements are created and managed by the framework, IToolManager
171: * just adds action tools as contributions to the specified <code>IToolBarManager</code>.
172: *
173: * @param toolManager
174: * @param bars
175: */
176: public void contributeModalTools(IToolBarManager toolBarManager,
177: IActionBars bars);
178:
179: /**
180: * Contributes the common global actions.
181: *
182: * @param bars
183: */
184: void contributeGlobalActions(IWorkbenchPart part, IActionBars bars);
185:
186: /**
187: * Returns the tool identified by an id and a category. This action cannot be modified in any way
188: * or it will throw an {@link UnsupportedOperationException}, but it can be ran with either
189: * {@link IAction#run()} or {@link IAction#runWithEvent(org.eclipse.swt.widgets.Event)}.
190: *
191: * @param toolID the id of the tool to find
192: * @param categoryID the id of the category the tool is part of
193: * @return the tool identified or null if the tool does not exist.
194: * @deprecated since 1.1, use getToolAction()
195: */
196: IAction getTool(String toolID, String categoryID);
197:
198: /**
199: * Returns the tool identified by an id and a category. This action cannot be modified in any way
200: * or it will throw an {@link UnsupportedOperationException}, but it can be ran with either
201: * {@link IAction#run()} or {@link IAction#runWithEvent(org.eclipse.swt.widgets.Event)}.
202: *
203: * @param toolID the id of the tool to find
204: * @param categoryID the id of the category the tool is part of
205: * @return the tool identified or null if the tool does not exist.
206: */
207: IAction getToolAction(String toolID, String categoryID);
208:
209: /**
210: * Returns the list of categories containing modal tools.
211: *
212: * @return the list of categories containing modal tools.
213: */
214: List<ModalToolCategory> getModalToolCategories();
215:
216: /**
217: * Returns the tool category that is currently active.
218: *
219: * @return the tool category that is currently active.
220: */
221: ToolCategory getActiveCategory();
222:
223: /**
224: * This allows for customized operation menus that are based on the currently selected tool.
225: *
226: * @param selection the selection to find operations for.
227: */
228: MenuManager createOperationsContextMenu(ISelection selection);
229:
230: /**
231: * Returns current active tool implementation object.
232: *
233: * @return
234: */
235: Tool getActiveTool();
236:
237: /**
238: * Finds tool proxy and returns the actual tool implementation
239: * object. If the tool has not been loaded yet, it is done immediatly by
240: * tool proxy and the implementation is returned.
241: *
242: * @param toolID the tool ID from extension registry.
243: * @return
244: */
245: Tool findTool(String toolID);
246:
247: /**
248: * Searches for the <code>Cursor</code> object by ID.
249: * The <code>cursorID</code> is a custom ID from extension
250: * registry or a constant from <code>ModatTool</code> interface for
251: * systems cursors.
252: *
253: * @param cursorID
254: * @return
255: */
256: public Cursor findToolCursor(String cursorID);
257:
258: }
|