001: // The contents of this file are subject to the Mozilla Public License Version
002: // 1.1
003: //(the "License"); you may not use this file except in compliance with the
004: //License. You may obtain a copy of the License at http://www.mozilla.org/MPL/
005: //
006: //Software distributed under the License is distributed on an "AS IS" basis,
007: //WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
008: //for the specific language governing rights and
009: //limitations under the License.
010: //
011: //The Original Code is "The Columba Project"
012: //
013: //The Initial Developers of the Original Code are Frederik Dietz and Timo
014: // Stich.
015: //Portions created by Frederik Dietz and Timo Stich are Copyright (C) 2003.
016: //
017: //All Rights Reserved.
018:
019: package org.columba.mail.gui.messageframe;
020:
021: import java.awt.BorderLayout;
022: import java.io.IOException;
023: import java.io.InputStream;
024:
025: import javax.swing.JComponent;
026: import javax.swing.JPanel;
027:
028: import org.columba.api.gui.frame.IContainer;
029: import org.columba.api.gui.frame.IDock;
030: import org.columba.api.gui.frame.IDockable;
031: import org.columba.core.gui.frame.FrameManager;
032: import org.columba.core.io.DiskIO;
033: import org.columba.mail.command.IMailFolderCommandReference;
034: import org.columba.mail.gui.frame.AbstractMailFrameController;
035: import org.columba.mail.gui.frame.TableViewOwner;
036: import org.columba.mail.gui.frame.ThreePaneMailFrameController;
037: import org.columba.mail.gui.table.ITableController;
038: import org.columba.mail.util.MailResourceLoader;
039:
040: /**
041: * Mail frame controller which contains a message viewer only.
042: * <p>
043: * Note that this frame depends on its parent frame controller for viewing
044: * messages.
045: *
046: * @see org.columba.mail.gui.action.NextMessageAction
047: * @see org.columba.mail.gui.action.PreviousMessageAction
048: * @see org.columba.mail.gui.action.NextUnreadMessageAction
049: * @see org.columba.mail.gui.action.PreviousMessageAction
050: *
051: * @author fdietz
052: */
053: public class MessageFrameController extends AbstractMailFrameController
054: implements TableViewOwner {
055:
056: IMailFolderCommandReference treeReference;
057:
058: IMailFolderCommandReference tableReference;
059:
060: FixedTableSelectionHandler tableSelectionHandler;
061:
062: private ThreePaneMailFrameController parentController;
063:
064: private IDockable messageViewerDockable;
065:
066: /**
067: * @param viewItem
068: */
069: public MessageFrameController() {
070: super (FrameManager.getInstance().createCustomViewItem(
071: "Messageframe"));
072:
073: // messageViewerDockable = registerDockable("mail_messageviewer", MailResourceLoader.getString(
074: // "global", "dockable_messageviewer"),
075: // messageController, null);
076:
077: tableSelectionHandler = new FixedTableSelectionHandler(
078: tableReference);
079: getSelectionManager()
080: .addSelectionHandler(tableSelectionHandler);
081:
082: }
083:
084: /**
085: * @param parent
086: * parent frame controller
087: */
088: public MessageFrameController(ThreePaneMailFrameController parent) {
089: this ();
090:
091: this .parentController = parent;
092:
093: }
094:
095: /**
096: *
097: * @see org.columba.mail.gui.frame.MailFrameInterface#getTableSelection()
098: */
099: public IMailFolderCommandReference getTableSelection() {
100: return tableReference;
101: }
102:
103: /**
104: *
105: * @see org.columba.mail.gui.frame.MailFrameInterface#getTreeSelection()
106: */
107: public IMailFolderCommandReference getTreeSelection() {
108: return treeReference;
109: }
110:
111: /**
112: * @param references
113: */
114: public void setTreeSelection(IMailFolderCommandReference references) {
115: treeReference = references;
116: }
117:
118: /**
119: * @param references
120: */
121: public void setTableSelection(IMailFolderCommandReference references) {
122: tableReference = references;
123:
124: // TODO: re-enable feature, the following code violates our
125: // design, accessing folders is only allowed in Command.execute()
126: /*
127: * try { // Get the subject from the cached Header AbstractMessageFolder
128: * folder = (AbstractMessageFolder) references .getSourceFolder();
129: * IColumbaHeader header = folder.getHeaderList().get(
130: * references.getUids()[0]); String subject = (String)
131: * header.get("columba.subject");
132: *
133: * getContainer().getFrame().setTitle(subject); } catch (Exception e) {
134: * LOG.warning(e.toString()); }
135: */
136:
137: tableSelectionHandler.setSelection(tableReference);
138: }
139:
140: /**
141: * @see org.columba.mail.gui.frame.TableViewOwner#getTableController()
142: */
143: public ITableController getTableController() {
144: if (parentController == null)
145: return null;
146:
147: // pass it along to parent frame
148: return parentController.getTableController();
149: }
150:
151: /**
152: * @see org.columba.api.gui.frame.IContentPane#getComponent()
153: */
154: // public JComponent getComponent() {
155: // JPanel panel = new JPanel();
156: // panel.setLayout(new BorderLayout());
157: //
158: // panel.add(messageController, BorderLayout.CENTER);
159: //
160: //
161: //
162: // return panel;
163: // }
164: /**
165: * @see org.columba.api.gui.frame.IFrameMediator#getString(java.lang.String,
166: * java.lang.String, java.lang.String)
167: */
168: public String getString(String sPath, String sName, String sID) {
169: return MailResourceLoader.getString(sPath, sName, sID);
170: }
171:
172: /**
173: * @see org.columba.core.gui.frame.DockFrameController#loadDefaultPosition()
174: */
175: public void loadDefaultPosition() {
176:
177: //super.dock(messageViewerDockable, IDock.REGION.CENTER);
178:
179: }
180:
181: /** *********************** container callbacks ************* */
182:
183: /**
184: * @see org.columba.api.gui.frame.IFrameMediator#extendMenu(org.columba.api.gui.frame.IContainer)
185: */
186: public void extendMenu(IContainer container) {
187: try {
188: InputStream is = DiskIO
189: .getResourceStream("org/columba/mail/action/messageframe_menu.xml");
190:
191: container.extendMenu(this , is);
192:
193: } catch (IOException e) {
194: e.printStackTrace();
195: }
196: }
197:
198: /**
199: * @see org.columba.api.gui.frame.IFrameMediator#extendToolBar(org.columba.api.gui.frame.IContainer)
200: */
201: public void extendToolBar(IContainer container) {
202: try {
203: InputStream is = DiskIO
204: .getResourceStream("org/columba/mail/config/messageframe_toolbar.xml");
205:
206: container.extendToolbar(this , is);
207:
208: } catch (IOException e) {
209: e.printStackTrace();
210: }
211: }
212:
213: @Override
214: public JPanel getContentPane() {
215: JPanel panel = new JPanel();
216: panel.setLayout(new BorderLayout());
217:
218: panel.add(messageController, BorderLayout.CENTER);
219:
220: return panel;
221: }
222:
223: }
|