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.composer.action;
017:
018: import java.awt.event.ActionEvent;
019:
020: import org.columba.api.gui.frame.IFrameMediator;
021: import org.columba.core.command.CommandProcessor;
022: import org.columba.core.gui.action.AbstractColumbaAction;
023: import org.columba.core.resourceloader.ImageLoader;
024: import org.columba.mail.command.ComposerCommandReference;
025: import org.columba.mail.command.MailFolderCommandReference;
026: import org.columba.mail.config.AccountItem;
027: import org.columba.mail.config.SpecialFoldersItem;
028: import org.columba.mail.folder.IMailbox;
029: import org.columba.mail.folder.command.MarkMessageCommand;
030: import org.columba.mail.folder.outbox.OutboxFolder;
031: import org.columba.mail.gui.composer.ComposerController;
032: import org.columba.mail.gui.composer.ComposerModel;
033: import org.columba.mail.gui.composer.command.SaveMessageCommand;
034: import org.columba.mail.gui.tree.FolderTreeModel;
035: import org.columba.mail.util.MailResourceLoader;
036:
037: /**
038: * @author frd
039: *
040: * To change this generated comment go to Window>Preferences>Java>Code
041: * Generation>Code and Comments
042: */
043: public class SendLaterAction extends AbstractColumbaAction {
044: public SendLaterAction(IFrameMediator FrameController) {
045: super (FrameController, MailResourceLoader.getString("menu",
046: "composer", "menu_file_sendlater"));
047:
048: // tooltip text
049: putValue(SHORT_DESCRIPTION, MailResourceLoader.getString(
050: "menu", "composer", "menu_file_sendlater").replaceAll(
051: "&", ""));
052:
053: // small icon for menu
054: //putValue(SMALL_ICON, ImageLoader.getSmallImageIcon("send-later-16.png"));
055: }
056:
057: /*
058: * (non-Javadoc)
059: *
060: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
061: */
062: public void actionPerformed(ActionEvent evt) {
063: final ComposerController composerController = (ComposerController) getFrameMediator();
064:
065: if (composerController.checkState()) {
066: return;
067: }
068:
069: AccountItem item = ((ComposerModel) composerController
070: .getModel()).getAccountItem();
071: SpecialFoldersItem folderItem = item.getSpecialFoldersItem();
072: OutboxFolder destFolder = (OutboxFolder) FolderTreeModel
073: .getInstance().getFolder("103");
074:
075: ComposerCommandReference r = new ComposerCommandReference(
076: composerController, destFolder);
077:
078: SaveMessageCommand c = new SaveMessageCommand(r);
079: CommandProcessor.getInstance().addOp(c);
080:
081: // -> get source reference of message
082: // when replying this is the original sender's message
083: // you selected and replied to
084: try {
085: MailFolderCommandReference ref2 = composerController
086: .getModel().getSourceReference();
087: if (ref2 != null
088: && ((IMailbox) ref2.getSourceFolder()).exists(ref2
089: .getUids()[0])) {
090: // mark message as answered
091: ref2
092: .setMarkVariant(MarkMessageCommand.MARK_AS_ANSWERED);
093: MarkMessageCommand c1 = new MarkMessageCommand(ref2);
094: CommandProcessor.getInstance().addOp(c1);
095: }
096: } catch (Exception e) {
097: }
098:
099: // close composer view
100: if (composerController.getView().getFrame() != null) {
101: composerController.getView().getFrame().setVisible(false);
102: }
103: }
104: }
|