01: /*******************************************************************************
02: * Copyright (c) 2000, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.pde.core;
11:
12: import java.io.PrintWriter;
13:
14: /**
15: * Models that implement this interface indicate that
16: * they can be changed. When a model is changed,
17: * it becomes 'dirty'. This state can either be reset
18: * (in case of a 'false alarm' or naturally set to
19: * false as a result of saving the changes.
20: * Models that implement this interface are expected
21: * to be able to save in ASCII file format
22: * (e.g. XML).
23: * @since 2.0
24: */
25: public interface IEditable {
26: /**
27: * Tests whether the model marked as editable can be
28: * edited. Even though a model is generally editable,
29: * it can me marked as read-only because some condition
30: * prevents it from changing state (for example,
31: * the underlying resource is locked). While
32: * read-only models can never be changed, editable
33: * models can go in and out editable state during
34: * their life cycle.
35: *
36: * @return <code>true</code> if model can be modified, <code>false</code>
37: * otherwise.
38: */
39: public boolean isEditable();
40:
41: /**
42: * Tests whether the model has been changed from the last clean
43: * state.
44: * @return <code>true</code> if the model has been changed and need saving
45: */
46: public boolean isDirty();
47:
48: /**
49: * Saves the model into the provided writer.
50: * The assumption is that the model can be
51: * persisted in an ASCII output stream (for example, an XML file).
52: * This method should clear the 'dirty' flag when
53: * done.
54: *
55: * @param writer an object that should be used to
56: * write ASCII representation of the model
57: */
58: public void save(PrintWriter writer);
59:
60: /**
61: * Sets the dirty flag of the model. This method is
62: * normally not intended to be used outside the model.
63: * Most often, a dirty model should be saved to clear the flag.
64: *
65: * @param dirty a new value for the 'dirty' flag
66: */
67: void setDirty(boolean dirty);
68: }
|