gecko-dev/grendel/ui/MessageFrame.java

134 строки
3.8 KiB
Java
Исходник Обычный вид История

1998-09-09 04:52:38 +04:00
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
1999-11-02 04:51:54 +03:00
* The contents of this file are subject to the Mozilla Public
* License Version 1.1 (the "License"); you may not use this file
* except in compliance with the License. You may obtain a copy of
* the License at http://www.mozilla.org/MPL/
1998-09-09 04:52:38 +04:00
*
1999-11-02 04:51:54 +03:00
* Software distributed under the License is distributed on an "AS
* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
* implied. See the License for the specific language governing
* rights and limitations under the License.
1998-09-09 04:52:38 +04:00
*
* The Original Code is the Grendel mail/news client.
*
* The Initial Developer of the Original Code is Netscape Communications
1999-11-02 04:51:54 +03:00
* Corporation. Portions created by Netscape are
* Copyright (C) 1997 Netscape Communications Corporation. All
* Rights Reserved.
*
* Contributor(s):
1998-09-09 04:52:38 +04:00
*
* Created: Will Scullin <scullin@netscape.com>, 18 Nov 1997.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Giao Nguyen <grail@cafebabe.org>
1999-06-15 15:44:40 +04:00
* Edwin Woudt <edwin@woudt.nl>
1998-09-09 04:52:38 +04:00
*/
package grendel.ui;
import java.awt.BorderLayout;
import java.util.Enumeration;
import java.util.Vector;
import javax.mail.Message;
import javax.mail.MessagingException;
//import netscape.orion.toolbars.ToolbarFactory;
//import netscape.orion.toolbars.ToolBarLayout;
//import netscape.orion.uimanager.AbstractUICmd;
//import netscape.orion.uimanager.IUICmd;
1998-09-09 04:52:38 +04:00
public class MessageFrame extends GeneralFrame {
static Vector fMessageFrames = new Vector();
MessagePanel fMessagePanel;
/**
* Creates a MessageFrame displaying the given message.
*/
public MessageFrame(Message aMessage) {
1999-06-15 15:44:40 +04:00
super("messageFrameLabel", "message");
1998-09-09 04:52:38 +04:00
fMessagePanel = new MessagePanel();
fPanel.add(fMessagePanel);
// fMenu = buildMenu("messageMain", Util.MergeActions(actions,
// fMessagePanel.getActions()));
1999-01-20 09:40:01 +03:00
fMenu = buildMenu("menus.xml",
Util.MergeActions(actions,
fMessagePanel.getActions()));
getRootPane().setJMenuBar(fMenu);
1998-09-09 04:52:38 +04:00
fToolBar = fMessagePanel.getToolBar();
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(ToolBarLayout.CreateSpring(),
// null));
// fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(fAnimation, null));
1998-09-09 04:52:38 +04:00
fToolBarPanel.add(fToolBar);
fStatusBar = buildStatusBar();
fPanel.add(BorderLayout.SOUTH, fStatusBar);
setMessage(aMessage);
restoreBounds();
fMessageFrames.addElement(this);
}
public void dispose() {
saveBounds();
fMessageFrames.removeElement(this);
fMessagePanel.dispose();
super.dispose();
}
/**
* Returns the current message, which may not be fully loaded or
* displayed.
*/
public Message getMessage() {
return fMessagePanel.getMessage();
}
/**
* Sets the current message, which will result in the message being
* loaded and displayed.
*/
public void setMessage(Message aMessage) {
setTitle(fLabels.getString("messageFrameLabel"));
fMessagePanel.setMessage(aMessage);
if (aMessage != null) {
try {
setTitle(aMessage.getSubject() +
fLabels.getString("messageSuffixFrameLabel"));
} catch (MessagingException e) {
}
}
}
/**
* Returns the frame displaying, or in the process of displaying,
* the given message.
*/
public static MessageFrame FindMessageFrame(Message aMessage) {
Enumeration frames = fMessageFrames.elements();
while (frames.hasMoreElements()) {
MessageFrame frame = (MessageFrame) frames.nextElement();
if (frame.getMessage() == aMessage) {
return frame;
}
}
return null;
}
1999-01-20 09:40:01 +03:00
UIAction actions[] = { ActionFactory.GetExitAction(),
1998-09-09 04:52:38 +04:00
ActionFactory.GetComposeMessageAction() };
}