/* -*- 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 * Giao Nguyen * Edwin Woudt */ 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.CollapsiblePanel; import grendel.widgets.GrendelToolBar; import grendel.ui.FolderPanel; import grendel.ui.GeneralFrame; import grendel.ui.StoreFactory; 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) // fMenu = buildMenu("mainMenubar", // mCompositionPanel.getActions()); fMenu = buildMenu("menus.xml", mCompositionPanel.getActions()); getRootPane().setJMenuBar(fMenu); fToolBar = mCompositionPanel.getToolBar(); fToolBar.add(fToolBar.makeNewSpring()); // fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(ToolBarLayout.CreateSpring(), // null)); // fToolBar.addItem(ToolbarFactory.MakeINSToolbarItem(fAnimation, null)); mAddressBar = mCompositionPanel.getAddressBar(); //top collapsible item fToolBarPanelConstraints.anchor = GridBagConstraints.WEST; fToolBarPanelConstraints.fill = GridBagConstraints.HORIZONTAL; // fToolBarPanelConstraints.weightx = 1.0; fToolBarPanel.add(fToolBar, fToolBarPanelConstraints); fToolBarPanelConstraints.anchor = GridBagConstraints.EAST; fToolBarPanelConstraints.fill = GridBagConstraints.NONE; fToolBarPanelConstraints.weightx = 1.0; fToolBarPanelConstraints.gridwidth = GridBagConstraints.REMAINDER; fToolBarPanel.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(); } 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