01: //The contents of this file are subject to the Mozilla Public License Version 1.1
02: //(the "License"); you may not use this file except in compliance with the
03: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
04: //
05: //Software distributed under the License is distributed on an "AS IS" basis,
06: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
07: //for the specific language governing rights and
08: //limitations under the License.
09: //
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;
20: import java.awt.event.ItemEvent;
21: import java.awt.event.ItemListener;
22: import java.util.logging.Logger;
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
39: implements ItemListener {
40:
41: /** JDK 1.4+ logging framework logger, used for logging. */
42: private static final Logger 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(
54: "menu", "composer", "menu_message_sign").replaceAll(
55: "&", ""));
56:
57: // small icon for menu
58: //putValue(SMALL_ICON, ImageLoader.getSmallImageIcon("16_sign.png"));
59:
60: composerController.getAccountController().getView()
61: .addItemListener(this );
62:
63: SecurityItem item = this .composerController.getModel()
64: .getAccountItem().getPGPItem();
65: setState(item.getBooleanWithDefault("always_sign", false));
66: LOG.info("always_sign=" + item.get("always_sign")); //$NON-NLS-1$ //$NON-NLS-2$
67:
68: composerController.getModel().setSignMessage(getState());
69:
70: //setEnabled(false);
71: }
72:
73: /*
74: * (non-Javadoc)
75: *
76: * @see java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
77: */
78: public void actionPerformed(ActionEvent evt) {
79: LOG.info("start signing...");
80:
81: //ComposerModel model = (ComposerModel)
82: // ((ComposerController)getFrameController()).getModel();
83: composerController.getModel().setSignMessage(getState());
84: }
85:
86: public void itemStateChanged(ItemEvent e) {
87: if (e.getStateChange() == ItemEvent.SELECTED) {
88: AccountItem item = (AccountItem) ((AccountView) e
89: .getSource()).getSelectedItem();
90: SecurityItem pgp = item.getPGPItem();
91: setState(pgp.getBooleanWithDefault("always_sign", false));
92: }
93: }
94:
95: }
|