001: //The contents of this file are subject to the Mozilla Public License Version 1.1
002: //(the "License"); you may not use this file except in compliance with the
003: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
004: //
005: //Software distributed under the License is distributed on an "AS IS" basis,
006: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
007: //for the specific language governing rights and
008: //limitations under the License.
009: //
010: //The Original Code is "The Columba Project"
011: //
012: //The Initial Developers of the Original Code are Frederik Dietz and Timo Stich.
013: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
014: //
015: //All Rights Reserved.
016: package org.columba.mail.gui.table.action;
017:
018: import java.awt.Toolkit;
019: import java.awt.event.ActionEvent;
020: import java.awt.event.KeyEvent;
021:
022: import javax.swing.KeyStroke;
023:
024: import org.columba.api.gui.frame.IFrameMediator;
025: import org.columba.api.selection.ISelectionListener;
026: import org.columba.api.selection.SelectionChangedEvent;
027: import org.columba.core.command.CommandProcessor;
028: import org.columba.core.gui.action.AbstractColumbaAction;
029: import org.columba.core.resourceloader.ImageLoader;
030: import org.columba.mail.command.IMailFolderCommandReference;
031: import org.columba.mail.folder.IMailFolder;
032: import org.columba.mail.folder.command.MoveMessageCommand;
033: import org.columba.mail.gui.frame.MailFrameMediator;
034: import org.columba.mail.gui.table.selection.TableSelectionChangedEvent;
035: import org.columba.mail.gui.tree.util.SelectFolderDialog;
036: import org.columba.mail.resourceloader.MailImageLoader;
037: import org.columba.mail.util.MailResourceLoader;
038:
039: /**
040: * @author frd
041: *
042: * To change this generated comment go to Window>Preferences>Java>Code
043: * Generation>Code and Comments
044: */
045: public class MoveMessageAction extends AbstractColumbaAction implements
046: ISelectionListener {
047: public MoveMessageAction(IFrameMediator frameMediator) {
048: super (frameMediator, MailResourceLoader.getString("menu",
049: "mainframe", "menu_message_move"));
050:
051: // toolbar text
052: putValue(TOOLBAR_NAME, MailResourceLoader.getString("menu",
053: "mainframe", "menu_message_move_toolbar"));
054:
055: // tooltip text
056: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
057: "menu", "mainframe", "menu_message_move_tooltip")
058: .replaceAll("&", ""));
059:
060: putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_Y,
061: Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()
062: | ActionEvent.SHIFT_MASK));
063:
064: putValue(SMALL_ICON, MailImageLoader
065: .getSmallIcon("message-move.png"));
066: putValue(LARGE_ICON, MailImageLoader
067: .getIcon("message-move.png"));
068:
069: // disable toolbar text
070: setShowToolBarText(false);
071:
072: setEnabled(false);
073:
074: ((MailFrameMediator) frameMediator)
075: .registerTableSelectionListener(this );
076: }
077:
078: /*
079: * (non-Javadoc)
080: *
081: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
082: */
083: public void actionPerformed(ActionEvent evt) {
084: SelectFolderDialog dialog = new SelectFolderDialog(
085: getFrameMediator());
086:
087: if (dialog.success()) {
088: IMailFolder destFolder = (IMailFolder) dialog
089: .getSelectedFolder();
090:
091: IMailFolderCommandReference result = ((MailFrameMediator) getFrameMediator())
092: .getTableSelection();
093: result.setDestinationFolder(destFolder);
094:
095: MoveMessageCommand c = new MoveMessageCommand(result);
096:
097: CommandProcessor.getInstance().addOp(c);
098: }
099: }
100:
101: /*
102: * (non-Javadoc)
103: *
104: * @see org.columba.core.gui.util.ISelectionListener#selectionChanged(org.columba.core.gui.util.SelectionChangedEvent)
105: */
106: public void selectionChanged(SelectionChangedEvent e) {
107: setEnabled(((TableSelectionChangedEvent) e).getUids().length > 0);
108: }
109: }
|