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 Stich.
13: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
14: //
15: //All Rights Reserved.
16:
17: package org.columba.mail.mailchecking;
18:
19: import java.util.Observable;
20: import java.util.Observer;
21:
22: import org.columba.api.gui.frame.IFrameMediator;
23: import org.columba.core.gui.action.AbstractColumbaAction;
24: import org.columba.core.gui.menu.IMenu;
25: import org.columba.mail.util.MailResourceLoader;
26:
27: /**
28: * Provides a menu item for each mail account enabling users to fetch new
29: * messages.
30: */
31:
32: public class FetchMessageSubMenu extends IMenu implements Observer {
33: //private POP3ServerCollection popServer;
34:
35: public FetchMessageSubMenu(IFrameMediator controller) {
36: super (controller, MailResourceLoader.getString("menu",
37: "mainframe", "menu_file_checkmessage"),
38: "menu_file_checkmessage");
39:
40: createMenu();
41:
42: // register interest on account changes
43: MailCheckingManager.getInstance().addObserver(this );
44: }
45:
46: protected void createMenu() {
47: // remove all items
48: removeAll();
49:
50: MailCheckingManager mailCheckingManager = MailCheckingManager
51: .getInstance();
52: AbstractColumbaAction[] actions = mailCheckingManager
53: .getActions();
54:
55: for (int i = 0; i < actions.length; i++) {
56: add(actions[i]);
57: }
58: }
59:
60: /**
61: * Listening for account changes here.
62: *
63: * @see java.util.Observer#update(java.util.Observable, java.lang.Object)
64: */
65: public void update(Observable observable, Object arg1) {
66: // recreate menu
67: createMenu();
68: }
69: }
|