KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jface > commands > PersistentState


1 /*******************************************************************************
2  * Copyright (c) 2005, 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.jface.commands;
13
14 import org.eclipse.core.commands.State;
15 import org.eclipse.jface.preference.IPreferenceStore;
16
17 /**
18  * <p>
19  * This is a state that can be made persistent. A state is persisted to a
20  * preference store.
21  * </p>
22  * <p>
23  * Clients may extend this class.
24  * </p>
25  *
26  * @since 3.2
27  */

28 public abstract class PersistentState extends State {
29
30     /**
31      * Whether this state should be persisted.
32      */

33     private boolean persisted;
34
35     /**
36      * Loads this state from the preference store, given the location at which
37      * to look. This method must be symmetric with a call to
38      * {@link #save(IPreferenceStore, String)}.
39      *
40      * @param store
41      * The store from which to read; must not be <code>null</code>.
42      * @param preferenceKey
43      * The key at which the state is stored; must not be
44      * <code>null</code>.
45      */

46     public abstract void load(final IPreferenceStore store,
47             final String JavaDoc preferenceKey);
48
49     /**
50      * Saves this state to the preference store, given the location at which to
51      * write. This method must be symmetric with a call to
52      * {@link #load(IPreferenceStore, String)}.
53      *
54      * @param store
55      * The store to which the state should be written; must not be
56      * <code>null</code>.
57      * @param preferenceKey
58      * The key at which the state should be stored; must not be
59      * <code>null</code>.
60      */

61     public abstract void save(final IPreferenceStore store,
62             final String JavaDoc preferenceKey);
63
64     /**
65      * Sets whether this state should be persisted.
66      *
67      * @param persisted
68      * Whether this state should be persisted.
69      */

70     public void setShouldPersist(final boolean persisted) {
71         this.persisted = persisted;
72     }
73
74     /**
75      * Whether this state should be persisted. Subclasses should check this
76      * method before loading or saving.
77      *
78      * @return <code>true</code> if this state should be persisted;
79      * <code>false</code> otherwise.
80      */

81     public boolean shouldPersist() {
82         return persisted;
83     }
84 }
85
Popular Tags