Implemented signature replacement code. When changing identities now, the sig will change. Also the sig will be automatically added when composing a message.

This commit is contained in:
edwin%woudt.nl 1999-03-13 22:31:58 +00:00
Родитель dabafbc386
Коммит 82e30a35da
4 изменённых файлов: 61 добавлений и 10 удалений

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

@ -17,6 +17,7 @@
* Netscape Communications Corporation. All Rights Reserved.
*
* Contributors: Jeff Galyan <talisman@anamorphic.com>
* Edwin Woudt <edwin@woudt.nl>
*/
package grendel.composition;
@ -29,7 +30,7 @@ public class AddressBar extends NSTabbedPane {
AttachmentsList mAttachmentsList;
OptionsPanel mOptionsPanel;
public AddressBar() {
public AddressBar(CompositionPanel cp) {
// address panel
ImageIcon addressIcon = new ImageIcon(getClass().getResource("images/small_address.gif"));
mAddressList = new AddressList ();
@ -40,7 +41,7 @@ public class AddressBar extends NSTabbedPane {
// options panel
ImageIcon optionsIcon = new ImageIcon(getClass().getResource("images/small_otpions.gif"));
mOptionsPanel = new OptionsPanel();
mOptionsPanel = new OptionsPanel(cp);
// tabbed panel holds address, attachments and otpions.
addTab("", addressIcon, mAddressList);

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

@ -126,6 +126,8 @@ public class Composition extends GeneralFrame {
fPanel.add(mCompositionPanel);
restoreBounds();
mCompositionPanel.AddSignature();
}
public void dispose() {

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

@ -124,7 +124,7 @@ public class CompositionPanel extends GeneralPanel {
//toolbar buttons
fToolBar = createToolbar();
mAddressBar = new AddressBar();
mAddressBar = new AddressBar(this);
mAddressList = mAddressBar.getAddressList();
mAttachmentsList = mAddressBar.getAttachmentsList();
@ -199,6 +199,15 @@ public class CompositionPanel extends GeneralPanel {
qot.actionPerformed(new ActionEvent(this,0,""));
}
/**
* Add a signature
*/
public void AddSignature() {
AddSignatureAction asa = new AddSignatureAction();
asa.actionPerformed(new ActionEvent(this,0,""));
}
protected void notifySendingMail() {
Object[] listeners = mListeners.getListenerList();
ChangeEvent changeEvent = null;
@ -256,7 +265,7 @@ public class CompositionPanel extends GeneralPanel {
public static final String sendNowTag ="sendNow";
public static final String sendLaterTag ="sendLater";
public static final String quoteOriginalTextTag ="quoteOriginalText";
public static final String addSignatureTag ="addSignature";
public static final String addSignatureTag ="addSignatureAction";
public static final String selectAddressesTag ="selectAddresses";
public static final String goOfflineTag ="goOffline";
public static final String closeWindowTag ="closeWindow";
@ -645,8 +654,8 @@ public class CompositionPanel extends GeneralPanel {
/**
* Add a signature
*/
class AddSignature extends UIAction {
AddSignature() {
class AddSignatureAction extends UIAction {
AddSignatureAction() {
super(addSignatureTag);
this.setEnabled(true);
}
@ -658,6 +667,19 @@ public class CompositionPanel extends GeneralPanel {
Document doc = mEditor.getDocument();
int oldPosition = mEditor.getCaretPosition();
for (int i=0; i<doc.getLength()-3;i++) {
try {
if (doc.getText(i,1).equals("\n")) {
if (doc.getText(i+1,3).equals("-- ")) {
doc.remove(i, doc.getLength()-i);
}
}
} catch (BadLocationException ble) {
ble.printStackTrace();
}
}
int position = doc.getEndPosition().getOffset() - 1;
try {
@ -671,7 +693,9 @@ public class CompositionPanel extends GeneralPanel {
s = sigReader.readLine();
}
} catch (FileNotFoundException fnfe) {
fnfe.printStackTrace();
//this can mean two things: either there's no signature specified
//or the file is missing. I the last case we should do
//something sensible.
} catch (IOException ioe) {
ioe.printStackTrace();
} catch (BadLocationException ble) {
@ -852,8 +876,8 @@ public class CompositionPanel extends GeneralPanel {
"security", "Show security Information");
addToolbarButton(toolBar, null,
"stop", "Stop the current Transfer (ESC)" );
addToolbarButton(toolBar, new AddSignature(),
"signature", "Add the signature of the current personality" );
//addToolbarButton(toolBar, new AddSignatureAction(),
// "signature", "Add the signature of the current personality" );
return toolBar;
}

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

@ -25,6 +25,7 @@ package grendel.composition;
import java.io.Serializable;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.border.*;
@ -40,10 +41,14 @@ public class OptionsPanel extends JPanel implements Serializable {
private GridBagLayout gridbag;
private LabeledCombo ident;
protected CompositionPanel mCompositionPanel;
public OptionsPanel () {
public OptionsPanel (CompositionPanel cp) {
super ();
mCompositionPanel = cp;
c = new GridBagConstraints();
gridbag = new GridBagLayout();
@ -157,6 +162,8 @@ public class OptionsPanel extends JPanel implements Serializable {
add ("West", mLabel);
add ("Center", mComboBox);
mComboBox.addItemListener(new IdentityChangeListener());
}
public void addPossibleValue(String aValue) {
@ -170,5 +177,22 @@ public class OptionsPanel extends JPanel implements Serializable {
public int getSelectedIndex() {
return mComboBox.getSelectedIndex();
}
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();
}
}
}
}
}
}