001: /*
002: * The contents of this file are subject to the
003: * Mozilla Public License Version 1.1 (the "License");
004: * you may not use this file except in compliance with the License.
005: * You may obtain a copy of the License at http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied.
009: * See the License for the specific language governing rights and
010: * limitations under the License.
011: *
012: * The Initial Developer of the Original Code is Simulacra Media Ltd.
013: * Portions created by Simulacra Media Ltd are Copyright (C) Simulacra Media Ltd, 2004.
014: *
015: * All Rights Reserved.
016: *
017: * Contributor(s):
018: */
019: package org.openharmonise.him.actions.sync;
020:
021: import java.awt.event.ActionEvent;
022:
023: import javax.swing.Icon;
024:
025: import org.openharmonise.him.actions.*;
026: import org.openharmonise.him.context.StateHandler;
027: import org.openharmonise.him.window.session.*;
028: import org.openharmonise.vfs.*;
029: import org.openharmonise.vfs.context.*;
030: import org.openharmonise.vfs.gui.*;
031:
032: /**
033: * Action to discard the changes to a virtual file. Used in the session
034: * window.
035: *
036: * @author Matthew Large
037: * @version $Revision: 1.1 $
038: *
039: */
040: public class ActionDiscard extends AbstractHIMAction implements
041: HIMAction {
042:
043: /**
044: * Session window.
045: */
046: private SessionWindow m_session = null;
047:
048: /**
049: *
050: */
051: public ActionDiscard(SessionWindow session) {
052: super ();
053: this .m_session = session;
054: }
055:
056: /**
057: * @param vfFile
058: */
059: private ActionDiscard(VirtualFile vfFile) {
060: super (vfFile);
061: }
062:
063: /* (non-Javadoc)
064: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
065: */
066: public void actionPerformed(ActionEvent arg0) {
067: StateHandler.getInstance().addWait("DISCARD-ACTION");
068: try {
069: this .m_session
070: .getSelectedEntry()
071: .getVFS()
072: .discardFileChanges(
073: this .m_session.getSelectedEntry().getPath());
074: this .m_session.removeEntry(this .m_session
075: .getSelectedEntry());
076: } catch (Exception e) {
077: e.printStackTrace(System.err);
078: } finally {
079: StateHandler.getInstance().removeWait("DISCARD-ACTION");
080: }
081: }
082:
083: /* (non-Javadoc)
084: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getText()
085: */
086: public String getText() {
087: return "Reject changes";
088: }
089:
090: /* (non-Javadoc)
091: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getToolTip()
092: */
093: public String getToolTip() {
094: return this .getDescription();
095: }
096:
097: /* (non-Javadoc)
098: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getIcon()
099: */
100: public Icon getIcon() {
101: return IconManager.getInstance().getIcon("16-command-exit.gif");
102: }
103:
104: /* (non-Javadoc)
105: * @see com.simulacramedia.contentmanager.actions.AbstractCMAction#getMnemonic()
106: */
107: public String getMnemonic() {
108: return "R";
109: }
110:
111: /* (non-Javadoc)
112: * @see com.simulacramedia.contentmanager.actions.CMAction#getDescription()
113: */
114: public String getDescription() {
115: return "Rejects the changes to the currently selected resource";
116: }
117:
118: /* (non-Javadoc)
119: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorKeycode()
120: */
121: public int getAcceleratorKeycode() {
122: return 0;
123: }
124:
125: /* (non-Javadoc)
126: * @see com.simulacramedia.contentmanager.actions.CMAction#getAcceleratorMask()
127: */
128: public int getAcceleratorMask() {
129: return 0;
130: }
131:
132: }
|