bug 8564 - Preferences access is broken in Composition ::: Moving Composition toolbar to XUL and uploading new toolbar buttons.

This commit is contained in:
rj.keller%beonex.com 2005-05-28 13:28:36 +00:00
Родитель 820e09bcfa
Коммит be733d72d7
19 изменённых файлов: 20 добавлений и 3107 удалений

Просмотреть файл

@ -56,7 +56,7 @@ public class AddressBook extends GeneralFrame {
// private ACS_Personal myLocalAddressBook;
private JMenuBar mMenuBarCtrl;
private GrendelToolBar mTtoolbar;
private JToolBar mTtoolbar;
// private Component mStatusbar;
private JTable mTable;
private JButton mSearchButton;
@ -694,9 +694,9 @@ public class AddressBook extends GeneralFrame {
* Create a Toolbar
* @see addToolbarButton
*/
private GrendelToolBar createToolbar() {
private JToolBar createToolbar() {
GrendelToolBar toolBar = new GrendelToolBar();
JToolBar toolBar = new JToolBar();
addToolbarButton(toolBar, new NewCard(), "moz-newcard.gif", "Create a new card");
addToolbarButton(toolBar, null, "moz-newlist.gif", "Create a new list");
addToolbarButton(toolBar, null, "moz-properties.gif", "Edit the selected card");
@ -716,7 +716,7 @@ public class AddressBook extends GeneralFrame {
* @param aToolTip The buttons tool tip. like "Save the current file".
* @see createToolbar
*/
public void addToolbarButton(GrendelToolBar aToolBar,
public void addToolbarButton(JToolBar aToolBar,
Event aActionListener,
String aImageName, String aToolTip) {
JButton b = new JButton();

Просмотреть файл

@ -1,227 +0,0 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
* Giao Nguyen <grail@cafebabe.org>
* Edwin Woudt <edwin@woudt.nl>
*/
package grendel.composition;
import calypso.util.Assert;
import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.util.Properties;
import java.util.Vector;
import javax.swing.*;
import javax.swing.event.*;
import grendel.storage.MessageExtra;
import grendel.storage.MessageExtraFactory;
import grendel.widgets.Animation;
import grendel.widgets.GrendelToolBar;
import grendel.ui.FolderPanel;
import grendel.ui.GeneralFrame;
import grendel.ui.StoreFactory;
import grendel.ui.XMLMenuBuilder;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
/**
*
* @author Lester Schueler
*/
public class Composition extends GeneralFrame {
CompositionPanel mCompositionPanel;
AddressBar mAddressBar;
public static void main(String[] args) {
//check arguments
// if (2 != args.length) {
// System.out.println ("Usage: composition mail_server_name user_name");
// System.exit(0);
// }
Composition compFrame = new Composition ();
compFrame.validate();
compFrame.pack();
compFrame.setVisible(true);
}
/**
*
*/
public Composition() {
super("Composition", "composition");
fResourceBase = "grendel.composition";
Box mBox = Box.createVerticalBox();
Session session = StoreFactory.Instance().getSession();
//session.setDebug(true);
mCompositionPanel = new CompositionPanel(session);
mCompositionPanel.addCompositionPanelListener(new PanelListener());
//create menubar (top)
XMLMenuBuilder builder = new XMLMenuBuilder(mCompositionPanel.getActions());
fMenu = builder.buildFrom("ui/grendel.xml", (JFrame)this);
getRootPane().setJMenuBar(fMenu);
fToolBar = mCompositionPanel.getToolBar();
fToolBar.add(new grendel.widgets.Spring());
mAddressBar = mCompositionPanel.getAddressBar();
//top collapsible item
fToolBarPanelConstraints.anchor = GridBagConstraints.WEST;
fToolBarPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
// fToolBarPanelConstraints.weightx = 1.0;
fToolBarPanel.setComponent(fToolBar);
fToolBarPanelConstraints.anchor = GridBagConstraints.EAST;
fToolBarPanelConstraints.fill = GridBagConstraints.NONE;
fToolBarPanelConstraints.weightx = 1.0;
fToolBarPanelConstraints.gridwidth = GridBagConstraints.REMAINDER;
fToolBar.add(fAnimation, fToolBarPanelConstraints);
mBox.add(fToolBarPanel);
//bottom item
// fToolBarPanelConstraints.gridwidth = GridBagConstraints.RELATIVE;
//fToolBarPanelConstraints.fill = GridBagConstraints.HORIZONTAL;
//fToolBarPanelConstraints.weightx = 5.0;
//fToolBarPanel.add(mAddressBar, fToolBarPanelConstraints);
mBox.add(mAddressBar);
fPanel.add(BorderLayout.NORTH, mBox);
fStatusBar = buildStatusBar();
fPanel.add(BorderLayout.SOUTH, fStatusBar);
fPanel.add(mCompositionPanel);
restoreBounds();
mCompositionPanel.AddSignature();
setSize(670, 490);
}
public void dispose() {
saveBounds();
super.dispose(); // call last
}
protected void startAnimation() {
super.startAnimation();
}
protected void stopAnimation() {
super.stopAnimation();
}
/** Initialize the headers and body of this composition as being a reply to
the given message. */
public void initializeAsReply(Message msg, boolean replyall) {
mCompositionPanel.setReferredMessage(msg);
MessageExtra mextra = MessageExtraFactory.Get(msg);
int i;
Vector dests = new Vector();
Address from[] = null;
try {
from = msg.getReplyTo();
} catch (MessagingException e) {
}
if (from == null || from.length == 0) {
try {
from = msg.getFrom();
} catch (MessagingException e) {
}
}
if (from != null) {
for (i=0 ; i<from.length ; i++) {
dests.addElement(new Addressee(from[i], Addressee.TO));
}
}
if (replyall) {
for (int w=0 ; w<2 ; w++) {
Address list[] = null;
try {
list = msg.getRecipients(w == 0 ? Message.RecipientType.TO : Message.RecipientType.CC);
} catch (MessagingException e) {
}
if (list != null) {
for (i=0 ; i<list.length ; i++) {
dests.addElement(new Addressee(list[i], Addressee.CC));
}
}
}
}
Addressee destarray[] = new Addressee[dests.size()];
dests.copyInto(destarray);
mAddressBar.getAddressList().setAddresses(destarray);
try {
mCompositionPanel.setSubject("Re: " + mextra.simplifiedSubject());
} catch (MessagingException e) {
}
// Quote the original text
mCompositionPanel.QuoteOriginalMessage();
}
/** Initialize the headers and body of this composition
as being a message that is forwarded 'quoted'. */
public void initializeAsForward(Message msg, int aScope) {
mCompositionPanel.setReferredMessage(msg);
MessageExtra mextra = MessageExtraFactory.Get(msg);
try {
mCompositionPanel.setSubject("[Fwd: " + mextra.simplifiedSubject() + "]");
} catch (MessagingException e) {
}
// Quote the original text
if (aScope == FolderPanel.kQuoted) {
mCompositionPanel.QuoteOriginalMessage();
}
if (aScope == FolderPanel.kInline) {
mCompositionPanel.InlineOriginalMessage();
}
}
class PanelListener implements CompositionPanelListener {
public void sendingMail(ChangeEvent aEvent) {
startAnimation();
}
public void doneSendingMail(ChangeEvent aEvent) {
stopAnimation();
dispose();
}
public void sendFailed(ChangeEvent aEvent) {
stopAnimation();
}
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,369 +0,0 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* Contributor(s):
*
* Created: Will Scullin <scullin@netscape.com>, 16 Oct 1997.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Giao Nguyen <grail@cafebabe.org>
*/
package grendel.prefs;
import java.awt.Component;
import java.awt.Graphics;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeSupport;
import java.beans.PropertyEditor;
import java.net.URL;
import java.util.EventObject;
import java.util.Hashtable;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.Vector;
import java.io.File;
import javax.mail.Store;
import javax.mail.URLName;
import javax.swing.AbstractListModel;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import javax.swing.JComponent;
import javax.swing.JList;
import javax.swing.JScrollPane;
import javax.swing.ListModel;
import javax.swing.text.JTextComponent;
import javax.swing.border.BevelBorder;
import javax.swing.event.EventListenerList;
import javax.swing.event.ListDataEvent;
import javax.swing.event.ListDataListener;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.table.AbstractTableModel;
//import netscape.orion.dialogs.AbstractCtrl;
//import netscape.orion.dialogs.AttrNotFoundException;
//import netscape.orion.dialogs.JLISTeditor;
//import netscape.orion.dialogs.PageModel;
//import netscape.orion.dialogs.PageUI;
//import xml.tree.XMLNode;
//import xml.tree.TreeBuilder;
import grendel.ui.EditHostDialog;
import grendel.ui.Util;
import grendel.ui.PageModel;
import grendel.ui.PageUI;
public class MailServerPrefsEditor implements PropertyEditor
{
MailServerPrefs fPrefs = new MailServerPrefs();
PropertyChangeSupport fListeners = new PropertyChangeSupport(this);
ResourceBundle fLabels =
ResourceBundle.getBundle("grendel.prefs.PrefLabels");
final static String kMailDirectoryKey = "mailDirectoryField";
final static String kLeaveOnServerKey = "leaveOnServerCheck";
final static String kSMTPHostKey = "smtpHostField";
final static String kHostListKey = "hostList";
final static String kNewKey = "newButton";
final static String kEditKey = "editButton";
final static String kDeleteKey = "deleteButton";
final static String kChooseKey = "chooseButton";
Hashtable fValues = null;
HostListModel fHostListModel = null;
PageUI fPanel;
ServerPrefsModel fModel;
class ServerPrefsModel extends PageModel {
public ServerPrefsModel() {
fValues = new Hashtable();
fValues.put(kMailDirectoryKey, "");
fValues.put(kLeaveOnServerKey, Boolean.TRUE);
fValues.put(kSMTPHostKey, "");
setStore(fValues);
}
public void actionPerformed(ActionEvent aEvent) {
String action = aEvent.getActionCommand();
if (action.equals(kNewKey)) {
EditHostDialog hostDialog =
new EditHostDialog(Util.GetParentFrame(fPanel), null);
if (hostDialog.getURLName() != null) {
fHostListModel.add(hostDialog.getURLName());
fPrefs.setStores(fHostListModel.getStores());
fListeners.firePropertyChange(null, null, fPrefs);
}
} else if (action.equals(kEditKey)) {
JList c;
c = (JList)fPanel.getCtrlByName(kHostListKey);
URLName value = (URLName)c.getSelectedValue();
if (value != null) {
EditHostDialog hostDialog =
new EditHostDialog(Util.GetParentFrame(fPanel), value);
if (hostDialog.getURLName() != null) {
fHostListModel.update(value, hostDialog.getURLName());
fPrefs.setStores(fHostListModel.getStores());
fListeners.firePropertyChange(null, null, fPrefs);
}
}
} else if (action.equals(kDeleteKey)) {
JList c;
c = (JList)fPanel.getCtrlByName(kHostListKey);
URLName value = (URLName) c.getSelectedValue();
if (value != null) {
fHostListModel.remove(value);
fPrefs.setStores(fHostListModel.getStores());
fListeners.firePropertyChange(null, null, fPrefs);
}
} else if (action.equals(kChooseKey)) {
JFileChooser chooser = new JFileChooser(fPrefs.getMailDirectory());
DirectoryFilter filter = new DirectoryFilter();
File selected;
String path;
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.setFileFilter(filter);
chooser.addChoosableFileFilter(filter);
chooser.showDialog(fPanel, "Okay");
selected = chooser.getSelectedFile();
path = selected.getAbsolutePath();
((JTextComponent)
fPanel.getCtrlByName(kMailDirectoryKey)).setText(path);
fPrefs.setMailDirectory(path);
fListeners.firePropertyChange(null, null, fPrefs);
}
}
}
class DirectoryFilter extends FileFilter {
public boolean accept(File f) {
return f.isDirectory();
}
public String getDescription() {
return "Directories";
}
}
public MailServerPrefsEditor() {
fModel = new ServerPrefsModel();
fHostListModel = new HostListModel();
URL url = getClass().getResource("PrefDialogs.xml");
//XXXrlk: why does this constructor have parameters?
// fPanel = new PageUI(url, "id", "serverPrefs", fModel, getClass());
fPanel = new PageUI();
JComponent c;
ChangeAction ca = new ChangeAction();
Prefs prefs = new Prefs();
MailServerPrefs mail = prefs.getMailServerPrefs();
setValue(mail);
c = fPanel.getCtrlByName(kSMTPHostKey);
c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kMailDirectoryKey);
c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kChooseKey);
c.addPropertyChangeListener(ca);
c = fPanel.getCtrlByName(kHostListKey);
((JList)c).setModel(fHostListModel);
((JList)c).addListSelectionListener(new ListListener());
c = fPanel.getCtrlByName(kEditKey);
c.setEnabled(false);
c = fPanel.getCtrlByName(kDeleteKey);
c.setEnabled(false);
}
public String getAsText() {
return null;
}
public Component getCustomEditor() {
return fPanel;
}
public String getJavaInitializationString() {
return "";
}
public String[] getTags() {
return null;
}
public Object getValue() {
fPanel.saveAll();
fPrefs.setMailDirectory((String) fValues.get(kMailDirectoryKey));
fPrefs.setLeaveOnServer(((Boolean) fValues.get(kLeaveOnServerKey)).booleanValue());
fPrefs.setSMTPHost((String) fValues.get(kSMTPHostKey));
fPrefs.setStores(fHostListModel.getStores());
return fPrefs;
}
public boolean isPaintable() {
return false;
}
public void paintValue (Graphics g, Rectangle r) {
}
public void setAsText(String aValue) {
}
public void setValue(Object aValue) {
if (aValue instanceof MailServerPrefs) {
MailServerPrefs oldPrefs = fPrefs;
fPrefs = (MailServerPrefs) aValue;
fValues.put(kMailDirectoryKey, fPrefs.getMailDirectory());
fValues.put(kLeaveOnServerKey, fPrefs.getLeaveOnServer() ?
Boolean.TRUE : Boolean.FALSE);
fValues.put(kSMTPHostKey, fPrefs.getSMTPHost());
fHostListModel.setStores(fPrefs.getStores());
fPanel.initAll();
fListeners.firePropertyChange(null, oldPrefs, fPrefs);
}
}
public boolean supportsCustomEditor() {
return true;
}
public void addPropertyChangeListener(PropertyChangeListener l) {
fListeners.addPropertyChangeListener(l);
}
public void removePropertyChangeListener(PropertyChangeListener l) {
fListeners.removePropertyChangeListener(l);
}
class ListListener
implements ListSelectionListener {
public void valueChanged(ListSelectionEvent e) {
System.out.println("foo");
JComponent c;
c = (JComponent)e.getSource();
boolean enabled = !(((JList)c).isSelectionEmpty());
System.out.println(((JList)c).getSelectedValue());
c = fPanel.getCtrlByName(kDeleteKey);
c.setEnabled(enabled);
c = fPanel.getCtrlByName(kEditKey);
c.setEnabled(enabled);
}
}
class HostListModel extends AbstractListModel {
URLName fStores[];
Vector fEditableStores = new Vector();
EventListenerList fListeners = new EventListenerList();
HostListModel() {
fStores = new URLName[0];
}
HostListModel(URLName aStores[]) {
fStores = aStores;
}
public void setStores(URLName aStores[]) {
int i;
fStores = aStores;
for (i = 0; i < aStores.length; i++) {
if (aStores[i] != null) {
fEditableStores.addElement(aStores[i]);
}
}
fireContentsChanged(this, 0, fEditableStores.size() - 1);
}
public URLName[] getStores() {
URLName res[] = new URLName[fEditableStores.size()];
fEditableStores.copyInto(res);
return res;
}
public void update(URLName aOld, URLName aNew) {
if (!aOld.equals(aNew)) {
int idx = fEditableStores.indexOf(aOld);
fEditableStores.removeElementAt(idx);
fEditableStores.insertElementAt(aNew, idx);
fireContentsChanged(this, idx, idx);
}
}
public void add(URLName aURLName) {
fEditableStores.addElement(aURLName);
fireIntervalAdded(this, fEditableStores.size() - 1,
fEditableStores.size() - 1);
}
public void remove(URLName aURLName) {
int idx = fEditableStores.indexOf(aURLName);
if (idx != -1) {
fEditableStores.removeElementAt(idx);
fireIntervalRemoved(this, idx, idx);
}
}
public int getSize() {
return fEditableStores.size();
}
public Object getElementAt(int index) {
return fEditableStores.elementAt(index);
}
}
class ChangeAction implements PropertyChangeListener {
void event(EventObject aEvent) {
fListeners.firePropertyChange(null, null, fPrefs);
}
public void propertyChange(PropertyChangeEvent aEvent) {
event(aEvent);
}
}
}

Просмотреть файл

@ -39,9 +39,6 @@ import java.util.ResourceBundle;
import javax.swing.JFrame;
import javax.swing.ToolTipManager;
//import netscape.orion.uimanager.AbstractUICmd;
//import netscape.orion.uimanager.IUICmd;
import grendel.prefs.base.UIPrefs;
import grendel.prefs.ui.Identities;
import grendel.prefs.ui.Servers;
@ -76,6 +73,8 @@ public class ActionFactory {
static RunUIPrefsAction fRunUIPrefsAction = new RunUIPrefsAction();
static ShowAddressBookAction fShowAddressBookAction = new ShowAddressBookAction();
private static Event[] prefEvents;
static int fIdent = 0;
static Runnable fComposeMessageThread = new DummyComposeMessageThread();
@ -141,6 +140,20 @@ public class ActionFactory {
static public ShowAddressBookAction GetShowAddressBookAction() {
return fShowAddressBookAction;
}
/**
*Returns an array of all the preferences events. Used in windows that
*don't automatically have the preferences events supplied to them.
*/
public static Event[] prefEvents() {
if (prefEvents == null) {
prefEvents = new Event[] {
ActionFactory.GetRunGeneralPrefsAction(), ActionFactory.GetRunIdentityPrefsAction(),
ActionFactory.GetRunServerPrefsAction(), ActionFactory.GetRunUIPrefsAction()
};
}
return prefEvents;
}
}
class ExitAction extends Event {

Разница между файлами не показана из-за своего большого размера Загрузить разницу

Просмотреть файл

@ -1,90 +0,0 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* Contributor(s):
*
* Created: Will Scullin <scullin@netscape.com>, 13 Oct 1997.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Edwin Woudt <edwin@woudt.nl>
*/
package grendel.ui;
import grendel.widgets.GrendelToolBar;
import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Image;
import java.awt.datatransfer.Clipboard;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;
import java.util.StringTokenizer;
import javax.swing.BorderFactory;
import javax.swing.Icon;
import javax.swing.ImageIcon;
import javax.swing.JPanel;
import javax.swing.JButton;
import javax.swing.JToolBar;
import com.trfenv.parsers.Event;
import com.trfenv.parsers.xul.XulParser;
import org.w3c.dom.Element;
import org.w3c.dom.Document;
public class GeneralPanel extends JPanel {
private final boolean DEBUG = false;
static ResourceBundle fLabels = ResourceBundle.getBundle("grendel.ui.Labels",
Locale.getDefault());
static Clipboard fPrivateClipboard = new Clipboard("Grendel");
protected String fResourceBase = "grendel.ui";
protected JToolBar fToolBar;
public GeneralPanel() {
setLayout(new BorderLayout());
setFont(new Font("Helvetica", Font.PLAIN, 12));
}
public Event[] getActions() {
return null;
}
protected JToolBar buildToolBar(String aToolbar, Event[] aActions) {
XulParser curParser = new XulParser(aActions, null);
Document doc = curParser.makeDocument("ui/grendel.xml");
Element toolbar = (Element)doc.getDocumentElement().getElementsByTagName("toolbar").
item(0);
JToolBar newToolbar = (JToolBar)curParser.parseTag(this, toolbar);
return newToolbar;
}
public JToolBar getToolBar() {
return fToolBar;
}
}

Просмотреть файл

@ -90,7 +90,6 @@ import grendel.widgets.ColumnHeader;
import grendel.widgets.ColumnModel;
import grendel.widgets.ColumnChangeListener;
import grendel.widgets.DefaultCellRenderer;
import grendel.widgets.GrendelToolBar;
import grendel.widgets.SelectionEvent;
import grendel.widgets.SelectionListener;
import grendel.widgets.SelectionManager;

Просмотреть файл

@ -71,7 +71,6 @@ import grendel.mime.parser.MimeParserFactory;
import grendel.mime.html.MimeHTMLOperatorFactory;
import grendel.storage.MessageExtra;
import grendel.storage.MessageExtraFactory;
import grendel.widgets.GrendelToolBar;
import grendel.widgets.StatusEvent;

Просмотреть файл

@ -1,211 +0,0 @@
/* -*- Mode: java; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* 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/
*
* 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.
*
* Contributor(s):
*
* Created: Will Scullin <scullin@netscape.com>, 3 Sep 1997.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Giao Nguyen <grail@cafebabe.org>
* Edwin Woudt <edwin@woudt.nl>
*/
package grendel.ui;
import java.awt.BorderLayout;
import java.util.Enumeration;
import java.util.Vector;
import javax.swing.event.ChangeEvent;
import javax.mail.Folder;
import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Store;
import grendel.view.ViewedFolder;
import grendel.view.ViewedMessage;
import javax.swing.tree.TreePath;
import com.trfenv.parsers.Event;
/**
*Main Grendel window
*/
public class MultiMessageDisplayManager extends MessageDisplayManager {
MasterFrame fMasterFrame;
static MultiMessageDisplayManager fDisplayMaster = null;
public static MultiMessageDisplayManager Get() {
if (fDisplayMaster == null) {
fDisplayMaster = new MultiMessageDisplayManager();
}
return fDisplayMaster;
}
/**
* Displays a message given a Message object.
*/
public void displayMessage(Message aMessage) {
MessageFrame frame = MessageFrame.FindMessageFrame(aMessage);
if (frame == null) {
frame = new MessageFrame(null);
}
frame.setVisible(true);
frame.toFront();
frame.requestFocus();
frame.setMessage(aMessage);
}
/**
* Displays a folder given a folder object.
*/
public void displayFolder(Folder aFolder) {
displayFolder(aFolder, null);
}
/**
* Displays folder given a Folder object and
* selects a message in that folder given a Message
* object.
*/
public void displayFolder(Folder aFolder, Message aMessage) {
FolderFrame frame = FolderFrame.FindFolderFrame(aFolder);
if (frame == null) {
frame = new FolderFrame(aFolder);
frame.setVisible(true);
}
frame.toFront();
frame.requestFocus();
if (aMessage != null) {
}
}
/**
* Displays the master.
*/
public void displayMaster() {
displayMaster(null);
}
/**
* Displays the master with the given folder selected.
*/
public void displayMaster(Folder aFolder) {
if (fMasterFrame == null) {
fMasterFrame = new MasterFrame();
}
fMasterFrame.setVisible(true);
fMasterFrame.toFront();
fMasterFrame.requestFocus();
if (aFolder != null) {
}
}
}
class MasterFrame extends GeneralFrame {
MasterPanel fMasterPanel;
public MasterFrame() {
super("masterFrameLabel", "session");
PrefsDialog.CheckPrefs(this);
fMasterPanel = new MasterPanel();
fMasterPanel.addMasterPanelListener(new FolderSelectionListener());
fPanel.add(fMasterPanel);
// fMenu = buildMenu("masterMain", actions);
XMLMenuBuilder builder = new XMLMenuBuilder(actions);
fMenu = builder.buildFrom("ui/grendel.xml", this);
getRootPane().setJMenuBar(fMenu);
fToolBar = fMasterPanel.getToolBar();
fToolBarPanel.add(fToolBar);
fStatusBar = buildStatusBar();
fPanel.add(BorderLayout.SOUTH, fStatusBar);
restoreBounds();
}
public void dispose() {
saveBounds();
fMasterPanel.dispose();
super.dispose();
}
//
// FolderSelectionListener class
//
class FolderSelectionListener implements MasterPanelListener {
public void masterSelectionChanged(ChangeEvent aEvent) {
}
public void masterSelectionDoubleClicked(ChangeEvent aEvent) {
TreePath path = null;
Enumeration selection = ((MasterPanel) aEvent.getSource()).getSelection();
MessageDisplayManager master = MultiMessageDisplayManager.Get();
while (selection.hasMoreElements()) {
path = (TreePath) selection.nextElement();
if (path != null) {
Object node = path.getPath()[path.getPath().length - 1];
Folder folder = null;
if (node instanceof ViewedFolder) {
folder = ((ViewedFolder) node).getFolder();
}
if (folder != null) {
try {
if ((folder.getType() & Folder.HOLDS_MESSAGES) == 0) {
folder = null;
}
} catch (MessagingException e) {
folder = null;
}
}
if (folder != null) {
master.displayFolder(folder);
}
}
}
}
}
// Action array
Event actions[] = { ActionFactory.GetExitAction(),
ActionFactory.GetNewMailAction(),
ActionFactory.GetComposeMessageAction()};
}

Просмотреть файл

@ -53,7 +53,6 @@ import javax.mail.MessagingException;
import grendel.prefs.base.InvisiblePrefs;
import grendel.prefs.base.UIPrefs;
import grendel.view.ViewedMessage;
import grendel.widgets.GrendelToolBar;
import grendel.widgets.Spring;
import grendel.widgets.StatusEvent;
import javax.swing.tree.TreePath;

Просмотреть файл

@ -49,8 +49,6 @@ import javax.swing.JScrollPane;
import javax.swing.JToolBar;
import javax.swing.KeyStroke;
import grendel.widgets.GrendelToolBar;
import com.trfenv.parsers.Event;
public class Util {

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл

Просмотреть файл