1998-09-09 04:52:38 +04:00
|
|
|
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License
|
|
|
|
* Version 1.0 (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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Original Code is the Grendel mail/news client.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is Netscape Communications
|
|
|
|
* Corporation. Portions created by Netscape are Copyright (C) 1997
|
|
|
|
* Netscape Communications Corporation. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Created: Will Scullin <scullin@netscape.com>, 18 Nov 1997.
|
1999-03-07 22:58:40 +03:00
|
|
|
*
|
|
|
|
* 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.Folder;
|
|
|
|
import javax.mail.Message;
|
|
|
|
import javax.mail.MessagingException;
|
|
|
|
|
|
|
|
import grendel.view.ViewedMessage;
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
import javax.swing.event.ChangeEvent;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
import grendel.ui.UIAction;
|
1998-09-09 04:52:38 +04:00
|
|
|
import grendel.widgets.StatusEvent;
|
|
|
|
import grendel.widgets.TreePath;
|
|
|
|
|
|
|
|
public class FolderFrame extends GeneralFrame {
|
|
|
|
static Vector fFolderFrames = new Vector();
|
|
|
|
FolderPanel fFolderPanel;
|
|
|
|
|
|
|
|
public FolderFrame(Folder aFolder) {
|
1999-06-15 15:44:40 +04:00
|
|
|
super("folderFrameLabel", "folder");
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
fFolderPanel = new FolderPanel();
|
|
|
|
fFolderPanel.addFolderPanelListener(new MessageSelectionListener());
|
|
|
|
fPanel.add(fFolderPanel);
|
1999-01-09 06:55:32 +03:00
|
|
|
// fMenu = buildMenu("folderMain", Util.MergeActions(actions,
|
|
|
|
// fFolderPanel.getActions()));
|
1999-01-20 09:40:01 +03:00
|
|
|
fMenu = buildMenu("menus.xml",
|
|
|
|
Util.MergeActions(actions, fFolderPanel.getActions()));
|
|
|
|
getRootPane().setJMenuBar(fMenu);
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
fToolBar = fFolderPanel.getToolBar();
|
1999-01-09 06:55:32 +03:00
|
|
|
// 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);
|
|
|
|
|
|
|
|
setFolder(aFolder);
|
|
|
|
|
|
|
|
fFolderFrames.addElement(this);
|
|
|
|
|
|
|
|
restoreBounds();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void dispose() {
|
|
|
|
saveBounds();
|
|
|
|
fFolderFrames.removeElement(this);
|
|
|
|
|
|
|
|
fFolderPanel.dispose();
|
|
|
|
|
|
|
|
super.dispose();
|
|
|
|
}
|
|
|
|
|
|
|
|
public Folder getFolder() {
|
|
|
|
return fFolderPanel.getFolder();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setFolder(Folder aFolder) {
|
|
|
|
setTitle(fLabels.getString("folderFrameLabel"));
|
|
|
|
fFolderPanel.setFolder(aFolder);
|
|
|
|
if (aFolder != null) {
|
|
|
|
setTitle(aFolder.getName() + fLabels.getString("folderSuffixFrameLabel"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public static FolderFrame FindFolderFrame(Folder aFolder) {
|
|
|
|
Enumeration frames = fFolderFrames.elements();
|
|
|
|
while (frames.hasMoreElements()) {
|
|
|
|
FolderFrame frame = (FolderFrame) frames.nextElement();
|
|
|
|
if (frame.getFolder() == aFolder) {
|
|
|
|
return frame;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// MessageSelectionListener class
|
|
|
|
//
|
|
|
|
|
|
|
|
class MessageSelectionListener implements FolderPanelListener {
|
|
|
|
public void loadingFolder(ChangeEvent aEvent) {
|
|
|
|
startAnimation();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void folderLoaded(ChangeEvent aEvent) {
|
|
|
|
stopAnimation();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void folderStatus(StatusEvent aEvent) {
|
|
|
|
setStatusText(aEvent.getStatus());
|
|
|
|
}
|
|
|
|
|
|
|
|
public void folderSelectionChanged(ChangeEvent aEvent) {
|
|
|
|
}
|
|
|
|
public void folderSelectionDoubleClicked(ChangeEvent aEvent) {
|
|
|
|
TreePath path = null;
|
|
|
|
Enumeration selection = ((FolderPanel)aEvent.getSource()).getSelection();
|
|
|
|
|
|
|
|
MessageDisplayManager master = MultiMessageDisplayManager.Get();
|
|
|
|
|
|
|
|
while (selection.hasMoreElements()) {
|
|
|
|
path = (TreePath) selection.nextElement();
|
|
|
|
if (path != null) {
|
|
|
|
ViewedMessage node = (ViewedMessage) path.getTip();
|
|
|
|
master.displayMessage(node.getMessage());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
1999-01-09 06:55:32 +03:00
|
|
|
UIAction actions[] = { ActionFactory.GetExitAction(),
|
1998-09-09 04:52:38 +04:00
|
|
|
ActionFactory.GetNewMailAction(),
|
|
|
|
ActionFactory.GetComposeMessageAction()};
|
|
|
|
}
|