001: /*******************************************************************************
002: * Copyright (c) 2003, 2005 IBM Corporation and others.
003: * All rights reserved. This program and the accompanying materials
004: * are made available under the terms of the Eclipse Public License v1.0
005: * which accompanies this distribution, and is available at
006: * http://www.eclipse.org/legal/epl-v10.html
007: *
008: * Contributors:
009: * IBM Corporation - initial API and implementation
010: *******************************************************************************/package org.eclipse.ui.application;
011:
012: import org.eclipse.core.runtime.IStatus;
013: import org.eclipse.swt.dnd.DropTargetListener;
014: import org.eclipse.swt.dnd.Transfer;
015: import org.eclipse.swt.graphics.Point;
016: import org.eclipse.swt.widgets.Composite;
017: import org.eclipse.swt.widgets.Control;
018: import org.eclipse.swt.widgets.Menu;
019: import org.eclipse.ui.IMemento;
020: import org.eclipse.ui.IWorkbenchWindow;
021: import org.eclipse.ui.presentations.AbstractPresentationFactory;
022:
023: /**
024: * Interface providing special access for configuring workbench windows.
025: * <p>
026: * Window configurer objects are in 1-1 correspondence with the workbench
027: * windows they configure. Clients may use <code>get/setData</code> to
028: * associate arbitrary state with the window configurer object.
029: * </p>
030: * <p>
031: * Note that these objects are only available to the main application
032: * (the plug-in that creates and owns the workbench).
033: * </p>
034: * <p>
035: * This interface is not intended to be implemented by clients.
036: * </p>
037: *
038: * @see IWorkbenchConfigurer#getWindowConfigurer
039: * @see WorkbenchAdvisor#preWindowOpen
040: * @since 3.0
041: */
042: public interface IWorkbenchWindowConfigurer {
043: /**
044: * Returns the underlying workbench window.
045: *
046: * @return the workbench window
047: */
048: public IWorkbenchWindow getWindow();
049:
050: /**
051: * Returns the workbench configurer.
052: *
053: * @return the workbench configurer
054: */
055: public IWorkbenchConfigurer getWorkbenchConfigurer();
056:
057: /**
058: * Returns the action bar configurer for this workbench
059: * window.
060: *
061: * @return the action bar configurer
062: */
063: public IActionBarConfigurer getActionBarConfigurer();
064:
065: /**
066: * Returns the title of the underlying workbench window.
067: *
068: * @return the window title
069: */
070: public String getTitle();
071:
072: /**
073: * Sets the title of the underlying workbench window.
074: *
075: * @param title the window title
076: */
077: public void setTitle(String title);
078:
079: /**
080: * Returns whether the underlying workbench window has a menu bar.
081: * <p>
082: * The initial value is <code>true</code>.
083: * </p>
084: *
085: * @return <code>true</code> for a menu bar, and <code>false</code>
086: * for no menu bar
087: */
088: public boolean getShowMenuBar();
089:
090: /**
091: * Sets whether the underlying workbench window has a menu bar.
092: *
093: * @param show <code>true</code> for a menu bar, and <code>false</code>
094: * for no menu bar
095: */
096: public void setShowMenuBar(boolean show);
097:
098: /**
099: * Returns whether the underlying workbench window has a cool bar.
100: * <p>
101: * The initial value is <code>true</code>.
102: * </p>
103: *
104: * @return <code>true</code> for a cool bar, and <code>false</code>
105: * for no cool bar
106: */
107: public boolean getShowCoolBar();
108:
109: /**
110: * Sets whether the underlying workbench window has a cool bar.
111: *
112: * @param show <code>true</code> for a cool bar, and <code>false</code>
113: * for no cool bar
114: */
115: public void setShowCoolBar(boolean show);
116:
117: /**
118: * Returns whether the underlying workbench window has a status line.
119: * <p>
120: * The initial value is <code>true</code>.
121: * </p>
122: *
123: * @return <code>true</code> for a status line, and <code>false</code>
124: * for no status line
125: */
126: public boolean getShowStatusLine();
127:
128: /**
129: * Sets whether the underlying workbench window has a status line.
130: *
131: * @param show <code>true</code> for a status line, and <code>false</code>
132: * for no status line
133: */
134: public void setShowStatusLine(boolean show);
135:
136: /**
137: * Returns whether the underlying workbench window has a perspective bar (the
138: * perspective bar provides buttons to quickly switch between perspectives).
139: * <p>
140: * The initial value is <code>false</code>.
141: * </p>
142: *
143: * @return <code>true</code> for a perspective bar, and <code>false</code>
144: * for no perspective bar
145: */
146: public boolean getShowPerspectiveBar();
147:
148: /**
149: * Sets whether the underlying workbench window has a perspective bar (the
150: * perspective bar provides buttons to quickly switch between perspectives).
151: *
152: * @param show <code>true</code> for a perspective bar, and
153: * <code>false</code> for no perspective bar
154: */
155: public void setShowPerspectiveBar(boolean show);
156:
157: /**
158: * Returns whether the underlying workbench window has fast view bars.
159: * <p>
160: * The initial value is <code>false</code>.
161: * </p>
162: *
163: * @return <code>true</code> for fast view bars, and
164: * <code>false</code> for no fast view bars
165: */
166: public boolean getShowFastViewBars();
167:
168: /**
169: * Sets whether the underlying workbench window has fast view bars.
170: *
171: * @param enable <code>true</code> for fast view bars, and
172: * <code>false</code> for no fast view bars
173: */
174: public void setShowFastViewBars(boolean enable);
175:
176: /**
177: * Returns whether the underlying workbench window has a progress indicator.
178: * <p>
179: * The initial value is <code>false</code>.
180: * </p>
181: *
182: * @return <code>true</code> for a progress indicator, and <code>false</code>
183: * for no progress indicator
184: */
185: public boolean getShowProgressIndicator();
186:
187: /**
188: * Sets whether the underlying workbench window has a progress indicator.
189: *
190: * @param show <code>true</code> for a progress indicator, and <code>false</code>
191: * for no progress indicator
192: */
193: public void setShowProgressIndicator(boolean show);
194:
195: /**
196: * Returns the style bits to use for the window's shell when it is created.
197: * The default is <code>SWT.SHELL_TRIM</code>.
198: *
199: * @return the shell style bits
200: */
201: public int getShellStyle();
202:
203: /**
204: * Sets the style bits to use for the window's shell when it is created.
205: * This method has no effect after the shell is created.
206: * That is, it must be called within the <code>preWindowOpen</code>
207: * callback on <code>WorkbenchAdvisor</code>.
208: * <p>
209: * For more details on the applicable shell style bits, see the
210: * documentation for {@link org.eclipse.swt.widgets.Shell}.
211: * </p>
212: *
213: * @param shellStyle the shell style bits
214: */
215: public void setShellStyle(int shellStyle);
216:
217: /**
218: * Returns the size to use for the window's shell when it is created.
219: *
220: * @return the initial size to use for the shell
221: */
222: public Point getInitialSize();
223:
224: /**
225: * Sets the size to use for the window's shell when it is created.
226: * This method has no effect after the shell is created.
227: * That is, it must be called within the <code>preWindowOpen</code>
228: * callback on <code>WorkbenchAdvisor</code>.
229: *
230: * @param initialSize the initial size to use for the shell
231: */
232: public void setInitialSize(Point initialSize);
233:
234: /**
235: * Returns the data associated with this workbench window at the given key.
236: *
237: * @param key the key
238: * @return the data, or <code>null</code> if there is no data at the given
239: * key
240: */
241: public Object getData(String key);
242:
243: /**
244: * Sets the data associated with this workbench window at the given key.
245: *
246: * @param key the key
247: * @param data the data, or <code>null</code> to delete existing data
248: */
249: public void setData(String key, Object data);
250:
251: /**
252: * Adds the given drag and drop <code>Transfer</code> type to the ones
253: * supported for drag and drop on the editor area of this workbench window.
254: * <p>
255: * The workbench advisor would ordinarily call this method from the
256: * <code>preWindowOpen</code> callback.
257: * A newly-created workbench window supports no drag and drop transfer
258: * types. Adding <code>EditorInputTransfer.getInstance()</code>
259: * enables <code>IEditorInput</code>s to be transferred.
260: * </p>
261: * <p>
262: * Note that drag and drop to the editor area requires adding one or more
263: * transfer types (using <code>addEditorAreaTransfer</code>) and
264: * configuring a drop target listener
265: * (with <code>configureEditorAreaDropListener</code>)
266: * capable of handling any of those transfer types.
267: * </p>
268: *
269: * @param transfer a drag and drop transfer object
270: * @see #configureEditorAreaDropListener
271: * @see org.eclipse.ui.part.EditorInputTransfer
272: */
273: public void addEditorAreaTransfer(Transfer transfer);
274:
275: /**
276: * Configures the drop target listener for the editor area of this workbench window.
277: * <p>
278: * The workbench advisor ordinarily calls this method from the
279: * <code>preWindowOpen</code> callback.
280: * A newly-created workbench window has no configured drop target listener for its
281: * editor area.
282: * </p>
283: * <p>
284: * Note that drag and drop to the editor area requires adding one or more
285: * transfer types (using <code>addEditorAreaTransfer</code>) and
286: * configuring a drop target listener
287: * (with <code>configureEditorAreaDropListener</code>)
288: * capable of handling any of those transfer types.
289: * </p>
290: *
291: * @param dropTargetListener the drop target listener that will handle
292: * requests to drop an object on to the editor area of this window
293: *
294: * @see #addEditorAreaTransfer
295: */
296: public void configureEditorAreaDropListener(
297: DropTargetListener dropTargetListener);
298:
299: /**
300: * Returns the presentation factory for this window. The window consults its presentation
301: * factory for the presentation aspects of views, editors, status lines, and other components
302: * of the window.
303: * <p>
304: * If no presentation factory has been set, a default one is returned.
305: * </p>
306: *
307: * @return the presentation factory used for this window
308: *
309: * @deprecated the presentation factory is now obtained via extension point
310: * and a preference on org.eclipse.ui specifying which one to use;
311: * see IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID
312: */
313: public AbstractPresentationFactory getPresentationFactory();
314:
315: /**
316: * Sets the presentation factory. The window consults its presentation
317: * factory for the presentation aspects of views, editors, status lines, and other components
318: * of the window.
319: * <p>
320: * This must be called before the window's controls are created, for example
321: * in <code>preWindowOpen</code>.
322: * </p>
323: *
324: * @param factory the presentation factory to use for this window
325: *
326: * @deprecated the presentation factory is now obtained via extension point
327: * and a preference on org.eclipse.ui specifying which one to use;
328: * see IWorkbenchPreferenceConstants.PRESENTATION_FACTORY_ID
329: */
330: public void setPresentationFactory(
331: AbstractPresentationFactory factory);
332:
333: /**
334: * Creates the menu bar for the window's shell.
335: * <p>
336: * This should only be called if the advisor is defining custom window contents
337: * in <code>createWindowContents</code>, and may only be called once.
338: * The caller must set it in the shell using <code>Shell.setMenuBar(Menu)</code>
339: * but must not make add, remove or change items in the result.
340: * The menu bar is populated by the window's menu manager.
341: * The application can add to the menu manager in the advisor's
342: * <code>fillActionBars</code> method instead.
343: * </p>
344: *
345: * @return the menu bar, suitable for setting in the shell
346: */
347: public Menu createMenuBar();
348:
349: /**
350: * Creates the cool bar control.
351: * <p>
352: * This should only be called if the advisor is defining custom window contents
353: * in <code>createWindowContents</code>, and may only be called once.
354: * The caller must lay out the cool bar appropriately within the parent,
355: * but must not add, remove or change items in the result (hence the
356: * return type of <code>Control</code>).
357: * The cool bar is populated by the window's cool bar manager.
358: * The application can add to the cool bar manager in the advisor's
359: * <code>fillActionBars</code> method instead.
360: * </p>
361: *
362: * @param parent the parent composite
363: * @return the cool bar control, suitable for laying out in the parent
364: */
365: public Control createCoolBarControl(Composite parent);
366:
367: /**
368: * Creates the status line control.
369: * <p>
370: * This should only be called if the advisor is defining custom window contents
371: * in <code>createWindowContents</code>, and may only be called once.
372: * The caller must lay out the status line appropriately within the parent,
373: * but must not add, remove or change items in the result (hence the
374: * return type of <code>Control</code>).
375: * The status line is populated by the window's status line manager.
376: * The application can add to the status line manager in the advisor's
377: * <code>fillActionBars</code> method instead.
378: * </p>
379: *
380: * @param parent the parent composite
381: * @return the status line control, suitable for laying out in the parent
382: */
383: public Control createStatusLineControl(Composite parent);
384:
385: /**
386: * Creates the page composite, in which the window's pages, and their
387: * views and editors, appear.
388: * <p>
389: * This should only be called if the advisor is defining custom window contents
390: * in <code>createWindowContents</code>, and may only be called once.
391: * The caller must lay out the page composite appropriately within the parent,
392: * but must not add, remove or change items in the result (hence the
393: * return type of <code>Control</code>).
394: * The page composite is populated by the workbench.
395: * </p>
396: *
397: * @param parent the parent composite
398: * @return the page composite, suitable for laying out in the parent
399: */
400: public Control createPageComposite(Composite parent);
401:
402: /**
403: * Saves the current state of the window using the specified memento.
404: *
405: * @param memento the memento in which to save the window's state
406: * @return a status object indicating whether the save was successful
407: * @see IWorkbenchConfigurer#restoreWorkbenchWindow(IMemento)
408: * @since 3.1
409: */
410: public IStatus saveState(IMemento memento);
411: }
|