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>, 8 Sep 1997.
|
1999-03-07 22:58:40 +03:00
|
|
|
*
|
|
|
|
* Contributors: Jeff Galyan <talisman@anamorphic.com>
|
|
|
|
* Giao Nguyen <grail@cafebabe.org>
|
1999-03-14 14:16:50 +03:00
|
|
|
* Edwin Woudt <edwin@woudt.nl>
|
1998-09-09 04:52:38 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
package grendel.ui;
|
|
|
|
|
|
|
|
import java.awt.Component;
|
|
|
|
import java.awt.Frame;
|
|
|
|
import java.awt.event.ActionEvent;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.text.MessageFormat;
|
|
|
|
import java.util.Enumeration;
|
|
|
|
import java.util.ResourceBundle;
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
import javax.swing.JFrame;
|
|
|
|
import javax.swing.ToolTipManager;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
import calypso.util.Preferences;
|
|
|
|
import calypso.util.PreferencesFactory;
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
//import netscape.orion.uimanager.AbstractUICmd;
|
|
|
|
//import netscape.orion.uimanager.IUICmd;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
import grendel.storage.MailDrop;
|
|
|
|
import grendel.search.SearchFrame;
|
|
|
|
import grendel.filters.FilterMaster;
|
|
|
|
|
|
|
|
import grendel.composition.Composition;
|
1999-01-09 06:55:32 +03:00
|
|
|
import grendel.ui.UIAction;
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
public class ActionFactory {
|
1999-01-09 06:55:32 +03:00
|
|
|
static ExitAction fExitAction = new ExitAction();
|
|
|
|
static NewMailAction fNewMailAction = new NewMailAction();
|
|
|
|
static ComposeMessageAction fComposeMessageAction = new ComposeMessageAction();
|
|
|
|
static PreferencesAction fPrefsAction = new PreferencesAction();
|
|
|
|
static SearchAction fSearchAction = new SearchAction();
|
|
|
|
static RunFiltersAction fRunFiltersAction = new RunFiltersAction();
|
|
|
|
static ShowTooltipsAction fShowTooltipsAction = new ShowTooltipsAction();
|
1999-03-14 14:16:50 +03:00
|
|
|
|
|
|
|
static int fIdent = 0;
|
|
|
|
|
|
|
|
static Runnable fComposeMessageThread = new DummyComposeMessageThread();
|
1999-01-09 06:55:32 +03:00
|
|
|
|
|
|
|
static public ExitAction GetExitAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fExitAction;
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public NewMailAction GetNewMailAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fNewMailAction;
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public ComposeMessageAction GetComposeMessageAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fComposeMessageAction;
|
|
|
|
}
|
|
|
|
|
1999-03-14 14:16:50 +03:00
|
|
|
static public void SetComposeMessageThread(Runnable aThread) {
|
|
|
|
fComposeMessageThread = aThread;
|
|
|
|
}
|
|
|
|
|
|
|
|
static public void setIdent(int aIdent) {
|
|
|
|
System.out.println("setIdent "+aIdent);
|
|
|
|
fIdent = aIdent;
|
|
|
|
}
|
|
|
|
|
|
|
|
static public int getIdent() {
|
|
|
|
System.out.println("getIdent "+fIdent);
|
|
|
|
return fIdent;
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public PreferencesAction GetPreferencesAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fPrefsAction;
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public SearchAction GetSearchAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fSearchAction;
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public RunFiltersAction GetRunFiltersAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fRunFiltersAction;
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
static public ShowTooltipsAction GetShowTooltipsAction() {
|
1998-09-09 04:52:38 +04:00
|
|
|
return fShowTooltipsAction;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class ExitAction extends UIAction {
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
public ExitAction() {
|
|
|
|
super("appExit");
|
|
|
|
|
|
|
|
setEnabled(true);
|
|
|
|
}
|
1999-01-09 06:55:32 +03:00
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
GeneralFrame.CloseAllFrames();
|
|
|
|
|
|
|
|
if (GeneralFrame.GetFrameList().length == 0) {
|
|
|
|
System.exit(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class NewMailAction extends UIAction {
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
public NewMailAction() {
|
|
|
|
super("msgGetNew");
|
|
|
|
|
|
|
|
setEnabled(true);
|
|
|
|
}
|
1999-01-09 06:55:32 +03:00
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
ProgressFactory.NewMailProgress();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class ComposeMessageAction extends UIAction {
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
public ComposeMessageAction() {
|
|
|
|
super("msgNew");
|
|
|
|
|
|
|
|
setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
1999-03-14 14:16:50 +03:00
|
|
|
new Thread(ActionFactory.fComposeMessageThread, "Composition Starter").start();
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
1999-03-14 14:16:50 +03:00
|
|
|
}
|
1998-09-09 04:52:38 +04:00
|
|
|
|
1999-03-14 14:16:50 +03:00
|
|
|
class DummyComposeMessageThread implements Runnable {
|
|
|
|
public void run() {
|
|
|
|
System.out.println("This should not happen! DummyComposeMessageThread called.");
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class PreferencesAction extends UIAction {
|
1998-09-09 04:52:38 +04:00
|
|
|
PreferencesAction fThis;
|
|
|
|
|
|
|
|
public PreferencesAction() {
|
|
|
|
super("appPrefs");
|
|
|
|
fThis = this;
|
|
|
|
|
|
|
|
setEnabled(true);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
Object source = aEvent.getSource();
|
|
|
|
if (source instanceof Component) {
|
|
|
|
Frame frame = Util.GetParentFrame((Component) source);
|
|
|
|
if (frame instanceof JFrame) {
|
|
|
|
new Thread(new PrefThread((JFrame) frame), "Prefs").start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
class PrefThread implements Runnable {
|
|
|
|
JFrame fFrame;
|
|
|
|
PrefThread(JFrame aFrame) {
|
|
|
|
fFrame = aFrame;
|
|
|
|
}
|
|
|
|
public void run() {
|
|
|
|
synchronized(fThis) {
|
|
|
|
setEnabled(false);
|
1999-02-25 10:44:11 +03:00
|
|
|
new PrefsDialog(fFrame);
|
1998-09-09 04:52:38 +04:00
|
|
|
setEnabled(true);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class SearchAction extends UIAction {
|
1998-09-09 04:52:38 +04:00
|
|
|
SearchAction() {
|
|
|
|
super("appSearch");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
Frame frame = new SearchFrame();
|
|
|
|
frame.show();
|
|
|
|
frame.toFront();
|
|
|
|
frame.requestFocus();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class RunFiltersAction extends UIAction {
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
RunFiltersAction() {
|
|
|
|
super("appRunFilters");
|
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
FilterMaster fm = FilterMaster.Get();
|
|
|
|
fm.applyFiltersToTestInbox();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
class ShowTooltipsAction extends UIAction {
|
|
|
|
|
1998-09-09 04:52:38 +04:00
|
|
|
ShowTooltipsAction() {
|
|
|
|
super("appShowTooltips");
|
|
|
|
|
|
|
|
boolean enabled =
|
|
|
|
PreferencesFactory.Get().getBoolean("app.tooltips", true);
|
|
|
|
ToolTipManager.sharedInstance().setEnabled(enabled);
|
|
|
|
|
1999-01-09 06:55:32 +03:00
|
|
|
// setSelected(enabled ? AbstractUICmd.kSelected : AbstractUICmd.kUnselected);
|
1998-09-09 04:52:38 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent aEvent) {
|
|
|
|
boolean enabled = !ToolTipManager.sharedInstance().isEnabled();
|
|
|
|
ToolTipManager.sharedInstance().setEnabled(enabled);
|
1999-01-09 06:55:32 +03:00
|
|
|
// setSelected(enabled ? AbstractUICmd.kSelected : AbstractUICmd.kUnselected);
|
1998-09-09 04:52:38 +04:00
|
|
|
PreferencesFactory.Get().putBoolean("app.tooltips", enabled);
|
|
|
|
}
|
|
|
|
}
|