Jskad/source/org/thdl/quilldriver/QDShell.java

179 lines
5.2 KiB
Java
Raw Normal View History

/*
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): ______________________________________.
*/
2002-09-28 00:53:39 +00:00
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;
2002-09-28 00:53:39 +00:00
public class QDShell extends JFrame {
ResourceBundle messages = null;
QD qd = null;
public static void main(String[] args) {
2002-09-28 00:53:39 +00:00
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();
2002-09-28 00:53:39 +00:00
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
}
catch (Exception e) {
2002-09-28 00:53:39 +00:00
}
QDShell qdsh = new QDShell(locale);
qdsh.setVisible(true);
} catch (NoClassDefFoundError err) {
ThdlDebug.handleClasspathError("QuillDriver's CLASSPATH", err);
2002-09-28 00:53:39 +00:00
}
}
2002-09-28 00:53:39 +00:00
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) {
2002-09-28 00:53:39 +00:00
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) {
2002-09-28 00:53:39 +00:00
qd.getSave();
}
});
JMenuItem quitItem = new JMenuItem(messages.getString("Quit"));
quitItem.addActionListener(new ThdlActionListener() {
public void theRealActionPerformed(ActionEvent e) {
2002-09-28 00:53:39 +00:00
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) {
2002-09-28 00:53:39 +00:00
qd.changeKeyboard(e);
}
}
}