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.
|
1999-01-09 06:55:32 +03:00
|
|
|
*
|
1999-11-02 04:51:54 +03:00
|
|
|
* Contributor(s): Jeff Galyan <talisman@anamorphic.com>
|
1999-03-07 05:19:44 +03:00
|
|
|
* Giao Nguyen <grail@cafebabe.org>
|
|
|
|
* Edwin Woudt <edwin@woudt.nl>
|
1998-09-09 04:52:38 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
package grendel.composition;
|
|
|
|
|
|
|
|
import java.io.Serializable;
|
|
|
|
import java.awt.*;
|
1999-03-14 01:31:58 +03:00
|
|
|
import java.awt.event.*;
|
1999-01-09 06:55:32 +03:00
|
|
|
import javax.swing.*;
|
|
|
|
import javax.swing.border.*;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
1999-06-15 15:44:40 +04:00
|
|
|
import grendel.prefs.base.IdentityArray;
|
1999-03-14 14:16:50 +03:00
|
|
|
import grendel.ui.ActionFactory;
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
public class OptionsPanel extends JPanel implements Serializable {
|
1999-01-11 01:31:08 +03:00
|
|
|
// private final int BOX_WIDTH = 300;
|
|
|
|
private final int BOX_WIDTH = 160;
|
1998-09-09 04:52:38 +04:00
|
|
|
private final int BOX_HEIGHT = 30;
|
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
private GridBagConstraints c;
|
|
|
|
private GridBagLayout gridbag;
|
|
|
|
|
|
|
|
private LabeledCombo ident;
|
1999-03-14 01:31:58 +03:00
|
|
|
|
|
|
|
protected CompositionPanel mCompositionPanel;
|
1999-02-20 01:41:38 +03:00
|
|
|
|
1999-03-14 01:31:58 +03:00
|
|
|
public OptionsPanel (CompositionPanel cp) {
|
1998-09-09 04:52:38 +04:00
|
|
|
super ();
|
1999-02-20 01:41:38 +03:00
|
|
|
|
1999-03-14 01:31:58 +03:00
|
|
|
mCompositionPanel = cp;
|
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
c = new GridBagConstraints();
|
|
|
|
gridbag = new GridBagLayout();
|
|
|
|
|
|
|
|
setLayout(gridbag);
|
1998-09-09 04:52:38 +04:00
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
c.fill = GridBagConstraints.HORIZONTAL;
|
|
|
|
c.weightx = 1.0;
|
|
|
|
c.gridheight = 1;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
addCheck ("Return Receipt", "Return Receipt", 'r', false);
|
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
LabeledCombo priority = new LabeledCombo("Priority");
|
|
|
|
priority.addPossibleValue("Lowest");
|
|
|
|
priority.addPossibleValue("Low");
|
|
|
|
priority.addPossibleValue("Normal");
|
|
|
|
priority.addPossibleValue("High");
|
|
|
|
priority.addPossibleValue("Highest");
|
1999-02-20 01:41:38 +03:00
|
|
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, priority), gridbag, c);
|
|
|
|
|
|
|
|
c.gridwidth = 1;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
addCheck ("Uuencoded instead of MIME for attachments", "UUEncode", 'u', false);
|
|
|
|
|
|
|
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
LabeledCombo format = new LabeledCombo("Format");
|
|
|
|
format.addPossibleValue("Ask me");
|
|
|
|
format.addPossibleValue("Plain Text only");
|
|
|
|
format.addPossibleValue("HTML Text only");
|
|
|
|
format.addPossibleValue("Plain Text and HTML");
|
1999-02-20 01:41:38 +03:00
|
|
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, format), gridbag, c);
|
|
|
|
|
|
|
|
c.gridwidth = 1;
|
|
|
|
|
1999-02-27 06:10:41 +03:00
|
|
|
|
|
|
|
addCheck ("Signed", "Signed", 'd', false);
|
|
|
|
|
1999-02-20 01:41:38 +03:00
|
|
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
|
|
|
|
|
|
|
ident = new LabeledCombo("Identity");
|
|
|
|
|
1999-06-15 15:44:40 +04:00
|
|
|
// Read all the different identities from the preferences file
|
|
|
|
IdentityArray ia = IdentityArray.GetMaster();
|
|
|
|
for (int i=0; i<ia.size(); i++) {
|
|
|
|
ident.addPossibleValue(ia.get(i).getDescription());
|
1999-02-20 01:41:38 +03:00
|
|
|
}
|
1999-03-14 14:16:50 +03:00
|
|
|
// Select the default identity
|
|
|
|
ident.setSelectedIndex(ActionFactory.getIdent());
|
1999-02-20 01:41:38 +03:00
|
|
|
|
|
|
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, ident), gridbag, c);
|
|
|
|
|
|
|
|
c.gridwidth = GridBagConstraints.REMAINDER; //end row
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSelectedIdentity() {
|
|
|
|
return ident.getSelectedIndex();
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addToGridBag (Component aComponent, GridBagLayout gridbag, GridBagConstraints c) {
|
|
|
|
gridbag.setConstraints(aComponent, c);
|
|
|
|
add(aComponent);
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
private void addCheck (String aLabel, String aToolTip) {
|
|
|
|
addCheck (aLabel, aToolTip, ' ', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addCheck (String aLabel, String aToolTip, boolean isChecked) {
|
|
|
|
addCheck (aLabel, aToolTip, ' ', isChecked);
|
|
|
|
}
|
|
|
|
|
|
|
|
private void addCheck (String aLabel, String aToolTip, char aAccelerator, boolean isChecked) {
|
|
|
|
JCheckBox checkButton = new JCheckBox(aLabel, isChecked);
|
|
|
|
|
|
|
|
if (!aToolTip.equals ("")) checkButton.setToolTipText(aToolTip);
|
1999-01-09 06:55:32 +03:00
|
|
|
if (' ' != aAccelerator) checkButton.setMnemonic(aAccelerator);
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
//create a fixed sized panel.
|
1999-02-20 01:41:38 +03:00
|
|
|
addToGridBag(new FixedSizedPanel (BOX_WIDTH, BOX_HEIGHT, checkButton), gridbag, c);
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
class FixedSizedPanel extends JPanel {
|
|
|
|
FixedSizedPanel (int aWidth, int aHeight, Component aComp) {
|
|
|
|
setPreferredSize (new Dimension (aWidth, aHeight));
|
1999-01-11 01:31:08 +03:00
|
|
|
setMaximumSize (getPreferredSize());
|
|
|
|
// setLayout (new BorderLayout ());
|
|
|
|
setLayout (new GridLayout(1,1,5,5));
|
1998-09-09 04:52:38 +04:00
|
|
|
setBorder (BorderFactory.createEmptyBorder (0, 5, 0, 0));
|
1999-01-11 01:31:08 +03:00
|
|
|
// add ("West", aComp);
|
|
|
|
add (aComp);
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class LabeledCombo extends JPanel {
|
|
|
|
JComboBox mComboBox;
|
|
|
|
JLabel mLabel;
|
|
|
|
|
|
|
|
public LabeledCombo (String aLabel) {
|
|
|
|
|
|
|
|
mComboBox = new JComboBox ();
|
|
|
|
mLabel = new JLabel (aLabel);
|
|
|
|
|
|
|
|
mComboBox.setPreferredSize (new Dimension (150, 20));
|
|
|
|
|
|
|
|
setLayout (new BorderLayout(5, 5));
|
|
|
|
// setInsets (new Insets (5, 5, 5, 5));
|
|
|
|
|
|
|
|
add ("West", mLabel);
|
|
|
|
add ("Center", mComboBox);
|
1999-03-14 01:31:58 +03:00
|
|
|
|
|
|
|
mComboBox.addItemListener(new IdentityChangeListener());
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void addPossibleValue(String aValue) {
|
|
|
|
mComboBox.insertItemAt (aValue, mComboBox.getItemCount());
|
|
|
|
}
|
1999-02-20 01:41:38 +03:00
|
|
|
|
|
|
|
public void setSelectedIndex(int anIndex) {
|
|
|
|
mComboBox.setSelectedIndex(anIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
public int getSelectedIndex() {
|
|
|
|
return mComboBox.getSelectedIndex();
|
|
|
|
}
|
1999-03-14 01:31:58 +03:00
|
|
|
|
|
|
|
class IdentityChangeListener implements ItemListener {
|
|
|
|
|
|
|
|
private boolean first = true;
|
|
|
|
|
|
|
|
public void itemStateChanged(ItemEvent e) {
|
|
|
|
if (e.getStateChange() == e.SELECTED) {
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
mCompositionPanel.AddSignature();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
1999-03-14 01:31:58 +03:00
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|