Jskad/source/org/thdl/quilldriver/QDShell.java
dchandler 403f21c8db Added Javadoc files overview.html and several package.html files.
Added a "Quit" option to Savant's File menu.  Factored out the Close
option in doing so.

Exceptions in many action listeners are now handled by
org.thdl.util.ThdlActionListener or org.thdl.util.ThdlAbstractAction.

Many exceptions that we used to just log now optionally cause aborts.
This option is on by default for developers using 'ant savant-run'-style
targets, but it is off for users.

An erroneous CLASSPATH now causes a useful error message in almost
all situations.

Fixed some typos and bad links in Javadoc comments.

Added a simple assertion facility, but the overhead is suffered even in
release builds.

Factored out the code that sets up log files like savant.log and jskad.log.
2002-10-06 18:23:27 +00:00

178 lines
5.2 KiB
Java

/*
The contents of this file are subject to the THDL Open Community 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 on the THDL web site
(http://www.thdl.org/).
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 terms governing rights and limitations under the
License.
The Initial Developer of this software is the Tibetan and Himalayan Digital
Library (THDL). Portions created by the THDL are Copyright 2001 THDL.
All Rights Reserved.
Contributor(s): ______________________________________.
*/
package org.thdl.quilldriver;
import java.io.*;
import java.awt.*;
import java.net.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import javax.swing.text.*;
import javax.swing.text.rtf.*;
import org.thdl.util.ThdlDebug;
import org.thdl.util.ThdlActionListener;
public class QDShell extends JFrame {
ResourceBundle messages = null;
QD qd = null;
public static void main(String[] args) {
try {
ThdlDebug.attemptToSetUpLogFile("qd.log");
Locale locale;
if (args.length == 2) {
locale = new Locale(new String(args[0]), new String(args[1]));
Locale[] locales = Locale.getAvailableLocales();
for (int k=0; k<locales.length; k++)
if (locales[k].equals(locale)) {
JComponent.setDefaultLocale(locale);
break;
}
}
else
locale = Locale.getDefault();
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
}
QDShell qdsh = new QDShell(locale);
qdsh.setVisible(true);
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("QuillDriver's CLASSPATH", err);
}
}
public QDShell(Locale locale) {
setTitle("QuillDriver");
/*
// Code for Merlin
if (getToolkit().isFrameStateSupported(Frame.MAXIMIZED_BOTH))
{
setLocation(0,0);
setSize(getToolkit().getScreenSize().width,getToolkit().getScreenSize().height);
setVisible(true);
setExtendedState(Frame.MAXIMIZED_BOTH);
} else {
*/
Dimension gs = getToolkit().getScreenSize();
setLocation(0,0);
setSize(new Dimension(gs.width, gs.height));
setVisible(true);
// }
messages = ResourceBundle.getBundle("MessageBundle", locale);
setJMenuBar(getQDShellMenu());
qd = new QD(messages);
getContentPane().add(qd);
addWindowListener(new WindowAdapter () {
public void windowClosing (WindowEvent e) {
qd.getSave();
//should only system exit if no cancel!!
System.exit(0);
}
});
}
public JMenuBar getQDShellMenu() {
JMenu projectMenu = new JMenu(messages.getString("Project"));
JMenuItem newItem = new JMenuItem(messages.getString("New"));
JMenuItem openItem = new JMenuItem(messages.getString("Open"));
openItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
qd.getOpen();
}
});
JMenuItem closeItem = new JMenuItem(messages.getString("Close"));
JMenuItem saveItem = new JMenuItem(messages.getString("Save"));
saveItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
qd.getSave();
}
});
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
quitItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
qd.getSave();
//should only system exit if no cancel!!
System.exit(0);
}
});
projectMenu.add(newItem);
projectMenu.add(openItem);
projectMenu.add(closeItem);
projectMenu.addSeparator();
projectMenu.add(saveItem);
projectMenu.addSeparator();
projectMenu.add(quitItem);
//Tibetan-specific value: remove in non-Tibetan version
//non-Tibetan specific version would have Transcription Language option here instead
JRadioButton wylieButton = new JRadioButton("THDL Extended Wylie");
JRadioButton sambhotaButton = new JRadioButton("Sambhota Keymap One");
JRadioButton tcc1Button = new JRadioButton("TCC Keyboard 1");
JRadioButton tcc2Button = new JRadioButton("TCC Keyboard 2");
wylieButton.setActionCommand("wylie");
sambhotaButton.setActionCommand("sambhota1");
tcc1Button.setActionCommand("tcc1");
tcc2Button.setActionCommand("tcc2");
RadioListener l = new RadioListener();
wylieButton.addActionListener(l);
sambhotaButton.addActionListener(l);
tcc1Button.addActionListener(l);
tcc2Button.addActionListener(l);
wylieButton.setSelected(true);
ButtonGroup bg = new ButtonGroup();
bg.add(wylieButton);
bg.add(sambhotaButton);
bg.add(tcc1Button);
bg.add(tcc2Button);
JPanel buttons = new JPanel(new GridLayout(0,1));
buttons.add(wylieButton);
buttons.add(sambhotaButton);
buttons.add(tcc1Button);
buttons.add(tcc2Button);
JMenu keyboardMenu = new JMenu(messages.getString("Keyboard"));
keyboardMenu.add(buttons);
JMenu preferencesMenu = new JMenu(messages.getString("Preferences"));
preferencesMenu.add(keyboardMenu);
JMenuBar bar = new JMenuBar();
bar.add(projectMenu);
bar.add(preferencesMenu);
return bar;
}
class RadioListener extends ThdlActionListener {
public void theRealActionPerformed(ActionEvent e) {
qd.changeKeyboard(e);
}
}
}