KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > openharmonise > him > actions > sync > ActionDiscard


1 /*
2  * The contents of this file are subject to the
3  * Mozilla Public License Version 1.1 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at http://www.mozilla.org/MPL/
6  *
7  * Software distributed under the License is distributed on an "AS IS"
8  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
9  * See the License for the specific language governing rights and
10  * limitations under the License.
11  *
12  * The Initial Developer of the Original Code is Simulacra Media Ltd.
13  * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
14  *
15  * All Rights Reserved.
16  *
17  * Contributor(s):
18  */

19 package org.openharmonise.him.actions.sync;
20
21 import java.awt.event.ActionEvent JavaDoc;
22
23 import javax.swing.Icon JavaDoc;
24
25 import org.openharmonise.him.actions.*;
26 import org.openharmonise.him.context.StateHandler;
27 import org.openharmonise.him.window.session.*;
28 import org.openharmonise.vfs.*;
29 import org.openharmonise.vfs.context.*;
30 import org.openharmonise.vfs.gui.*;
31
32
33 /**
34  * Action to discard the changes to a virtual file. Used in the session
35  * window.
36  *
37  * @author Matthew Large
38  * @version $Revision: 1.1 $
39  *
40  */

41 public class ActionDiscard extends AbstractHIMAction implements HIMAction {
42
43     /**
44      * Session window.
45      */

46     private SessionWindow m_session = null;
47
48     /**
49      *
50      */

51     public ActionDiscard(SessionWindow session) {
52         super();
53         this.m_session = session;
54     }
55
56     /**
57      * @param vfFile
58      */

59     private ActionDiscard(VirtualFile vfFile) {
60         super(vfFile);
61     }
62
63     /* (non-Javadoc)
64      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
65      */

66     public void actionPerformed(ActionEvent JavaDoc arg0) {
67         StateHandler.getInstance().addWait("DISCARD-ACTION");
68         try {
69             this.m_session.getSelectedEntry().getVFS().discardFileChanges(this.m_session.getSelectedEntry().getPath());
70             this.m_session.removeEntry(this.m_session.getSelectedEntry());
71         } catch (Exception JavaDoc e) {
72             e.printStackTrace(System.err);
73         } finally {
74             StateHandler.getInstance().removeWait("DISCARD-ACTION");
75         }
76     }
77
78     /* (non-Javadoc)
79      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getText()
80      */

81     public String JavaDoc getText() {
82         return "Reject changes";
83     }
84
85     /* (non-Javadoc)
86      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getToolTip()
87      */

88     public String JavaDoc getToolTip() {
89         return this.getDescription();
90     }
91
92     /* (non-Javadoc)
93      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getIcon()
94      */

95     public Icon JavaDoc getIcon() {
96         return IconManager.getInstance().getIcon("16-command-exit.gif");
97     }
98
99     /* (non-Javadoc)
100      * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getMnemonic()
101      */

102     public String JavaDoc getMnemonic() {
103         return "R";
104     }
105
106     /* (non-Javadoc)
107      * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
108      */

109     public String JavaDoc getDescription() {
110         return "Rejects the changes to the currently selected resource";
111     }
112
113     /* (non-Javadoc)
114      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
115      */

116     public int getAcceleratorKeycode() {
117         return 0;
118     }
119
120     /* (non-Javadoc)
121      * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
122      */

123     public int getAcceleratorMask() {
124         return 0;
125     }
126
127 }
128
Popular Tags