KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > columba > mail > gui > composer > action > SignMessageAction


1 //The contents of this file are subject to the Mozilla Public License Version 1.1
2
//(the "License"); you may not use this file except in compliance with the
3
//License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
4
//
5
//Software distributed under the License is distributed on an "AS IS" basis,
6
//WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
7
//for the specific language governing rights and
8
//limitations under the License.
9
//
10
//The Original Code is "The Columba Project"
11
//
12
//The Initial Developers of the Original Code are Frederik Dietz and Timo
13
// Stich.
14
//Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
15
//
16
//All Rights Reserved.
17
package org.columba.mail.gui.composer.action;
18
19 import java.awt.event.ActionEvent JavaDoc;
20 import java.awt.event.ItemEvent JavaDoc;
21 import java.awt.event.ItemListener JavaDoc;
22 import java.util.logging.Logger JavaDoc;
23
24 import org.columba.core.gui.action.AbstractSelectableAction;
25 import org.columba.core.resourceloader.ImageLoader;
26 import org.columba.mail.config.AccountItem;
27 import org.columba.mail.config.SecurityItem;
28 import org.columba.mail.gui.composer.AccountView;
29 import org.columba.mail.gui.composer.ComposerController;
30 import org.columba.mail.util.MailResourceLoader;
31
32 /**
33  * @author frd
34  *
35  * To change this generated comment go to Window>Preferences>Java>Code
36  * Generation>Code and Comments
37  */

38 public class SignMessageAction extends AbstractSelectableAction implements
39         ItemListener JavaDoc {
40
41     /** JDK 1.4+ logging framework logger, used for logging. */
42     private static final Logger JavaDoc LOG = Logger
43             .getLogger("org.columba.mail.gui.composer.action"); //$NON-NLS-1$
44

45     private ComposerController composerController;
46
47     public SignMessageAction(ComposerController composerController) {
48         super(composerController, MailResourceLoader.getString("menu",
49                 "composer", "menu_message_sign"));
50         this.composerController = composerController;
51
52         // tooltip text
53
putValue(SHORT_DESCRIPTION, MailResourceLoader.getString("menu",
54                 "composer", "menu_message_sign").replaceAll("&", ""));
55
56         // small icon for menu
57
//putValue(SMALL_ICON, ImageLoader.getSmallImageIcon("16_sign.png"));
58

59         composerController.getAccountController().getView().addItemListener(
60                 this);
61
62         SecurityItem item = this.composerController.getModel().getAccountItem()
63                 .getPGPItem();
64         setState(item.getBooleanWithDefault("always_sign", false));
65         LOG.info("always_sign=" + item.get("always_sign")); //$NON-NLS-1$ //$NON-NLS-2$
66

67         composerController.getModel().setSignMessage(getState());
68
69         //setEnabled(false);
70
}
71
72     /*
73      * (non-Javadoc)
74      *
75      * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
76      */

77     public void actionPerformed(ActionEvent JavaDoc evt) {
78         LOG.info("start signing...");
79
80         //ComposerModel model = (ComposerModel)
81
// ((ComposerController)getFrameController()).getModel();
82
composerController.getModel().setSignMessage(getState());
83     }
84
85     public void itemStateChanged(ItemEvent JavaDoc e) {
86         if (e.getStateChange() == ItemEvent.SELECTED) {
87             AccountItem item = (AccountItem) ((AccountView)e.getSource()).getSelectedItem();
88             SecurityItem pgp = item.getPGPItem();
89             setState(pgp.getBooleanWithDefault("always_sign", false));
90         }
91     }
92
93 }
94
Popular Tags