KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > ui > ISaveablePart


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-v10.html
7  *
8  * Contributors:
9  * IBM Corporation - initial API and implementation
10  *******************************************************************************/

11
12 package org.eclipse.ui;
13
14 import org.eclipse.core.runtime.IProgressMonitor;
15
16 /**
17  * Workbench parts implement or adapt to this interface to participate
18  * in the enablement and execution of the <code>Save</code> and
19  * <code>Save As</code> actions.
20  *
21  * @since 2.1
22  * @see org.eclipse.ui.IEditorPart
23  */

24 public interface ISaveablePart {
25
26     /**
27      * The property id for <code>isDirty</code>.
28      */

29     public static final int PROP_DIRTY = IWorkbenchPartConstants.PROP_DIRTY;
30
31     /**
32      * Saves the contents of this part.
33      * <p>
34      * If the save is successful, the part should fire a property changed event
35      * reflecting the new dirty state (<code>PROP_DIRTY</code> property).
36      * </p>
37      * <p>
38      * If the save is cancelled through user action, or for any other reason, the
39      * part should invoke <code>setCancelled</code> on the <code>IProgressMonitor</code>
40      * to inform the caller.
41      * </p>
42      * <p>
43      * This method is long-running; progress and cancellation are provided
44      * by the given progress monitor.
45      * </p>
46      *
47      * @param monitor the progress monitor
48      */

49     public void doSave(IProgressMonitor monitor);
50
51     /**
52      * Saves the contents of this part to another object.
53      * <p>
54      * Implementors are expected to open a "Save As" dialog where the user will
55      * be able to select a new name for the contents. After the selection is made,
56      * the contents should be saved to that new name. During this operation a
57      * <code>IProgressMonitor</code> should be used to indicate progress.
58      * </p>
59      * <p>
60      * If the save is successful, the part fires a property changed event
61      * reflecting the new dirty state (<code>PROP_DIRTY</code> property).
62      * </p>
63      */

64     public void doSaveAs();
65
66     /**
67      * Returns whether the contents of this part have changed since the last save
68      * operation. If this value changes the part must fire a property listener
69      * event with <code>PROP_DIRTY</code>.
70      * <p>
71      * <b>Note:</b> this method is called often on a part open or part
72      * activation switch, for example by actions to determine their
73      * enabled status.
74      * </p>
75      *
76      * @return <code>true</code> if the contents have been modified and need
77      * saving, and <code>false</code> if they have not changed since the last
78      * save
79      */

80     public boolean isDirty();
81
82     /**
83      * Returns whether the "Save As" operation is supported by this part.
84      *
85      * @return <code>true</code> if "Save As" is supported, and <code>false</code>
86      * if not supported
87      */

88     public boolean isSaveAsAllowed();
89
90     /**
91      * Returns whether the contents of this part should be saved when the part
92      * is closed.
93      *
94      * @return <code>true</code> if the contents of the part should be saved on
95      * close, and <code>false</code> if the contents are expendable
96      */

97     public boolean isSaveOnCloseNeeded();
98 }
99
Popular Tags