Updated the build system so that you must do a cvs checkout of the
'Fonts' module inside the 'Jskad' module. I.e., you must now have the tree like so: Jskad/ source/ dist/ Fonts/ TibetanMachineWeb/ . . . This is because the THDL tools now optionally (and by default) load the TibetanMachineWeb fonts automatically. Updated the build system so that the 'web-start-releases' and 'self-contained-dist' targets JAR up optional JARs to create double-clickable, self-contained joy. Even the TMW fonts are in the JARs now. Changed the strings describing two Jskad keyboards so that "keyboard" is no longer in the description. It's in the label next to the combo box. Jskad now saves preferences on exit or when the user selects a menu item (that is there for debugging mainly) to ~/my_thdl_preferences.txt on *nix or C:\my_thdl_preferences.txt on Win32. I don't know the correct Mac location. There's a new paradigm for telling org.thdl.util.ThdlOptions that a user preference has been changed. If, for example, a combo box is manipulated so that the ACIP keyboard is selected, then you must call a certain method in ThdlOptions.
This commit is contained in:
parent
77b8c5e424
commit
d200b03d66
12 changed files with 529 additions and 93 deletions
|
@ -495,6 +495,20 @@ public class DuffPane extends TibetanPane implements KeyListener, FocusListener
|
|||
getTibDoc().setTibetanFontSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Like {@link #setTibetanFontSize(int)}, but should be called only
|
||||
* when the user has somewhat explicitly chosen the font size.
|
||||
* This will set the font size but also record this as a user
|
||||
* preference. Then you can choose to save the user preferences
|
||||
* via {@link org.thdl.util.ThdlOptions.saveUserPreferences()}.
|
||||
*
|
||||
* @param size a point size
|
||||
*/
|
||||
public void setByUserTibetanFontSize(int size) {
|
||||
ThdlOptions.setUserPreference("thdl.default.tibetan.font.size", size);
|
||||
setTibetanFontSize(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current point size for Tibetan text.
|
||||
* @return the current default font size for Tibetan
|
||||
|
@ -517,6 +531,15 @@ public class DuffPane extends TibetanPane implements KeyListener, FocusListener
|
|||
StyleConstants.setFontSize(romanAttributeSet, size);
|
||||
}
|
||||
|
||||
/** Like {@link #setRomanAttributeSet}, but allows for noting the
|
||||
* (explicit or implicit) choice in the user's preferences
|
||||
* file. */
|
||||
public void setByUserRomanAttributeSet(String font, int size) {
|
||||
ThdlOptions.setUserPreference("thdl.default.roman.font.face", font);
|
||||
ThdlOptions.setUserPreference("thdl.default.roman.font.size", size);
|
||||
setRomanAttributeSet(font, size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the current point size for non-Tibetan text.
|
||||
* @return the current default font size for non-Tibetan
|
||||
|
|
|
@ -112,7 +112,18 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
|
||||
/** Do not use this JPanel constructor. */
|
||||
private Jskad(LayoutManager lm, boolean isDB) { super(lm, isDB); }
|
||||
|
||||
|
||||
/** Saves user preferences to disk if possible. */
|
||||
private static void savePreferencesAction() {
|
||||
try {
|
||||
ThdlOptions.saveUserPreferences();
|
||||
} catch (IOException ioe) {
|
||||
System.out.println("IO Exception saving user preferences to " + ThdlOptions.getUserPreferencesPath());
|
||||
ioe.printStackTrace();
|
||||
ThdlDebug.noteIffyCode();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param parent the object that embeds this instance of Jskad.
|
||||
|
@ -249,16 +260,28 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
editMenu.add(selectallItem);
|
||||
}
|
||||
|
||||
JMenuItem preferencesItem = new JMenuItem("Preferences");
|
||||
preferencesItem.addActionListener(new ThdlActionListener() {
|
||||
public void theRealActionPerformed(ActionEvent e) {
|
||||
getPreferences();
|
||||
}
|
||||
});
|
||||
editMenu.addSeparator();
|
||||
editMenu.add(preferencesItem);
|
||||
{
|
||||
JMenuItem preferencesItem = new JMenuItem("Preferences");
|
||||
preferencesItem.addActionListener(new ThdlActionListener() {
|
||||
public void theRealActionPerformed(ActionEvent e) {
|
||||
getPreferences();
|
||||
}
|
||||
});
|
||||
editMenu.addSeparator();
|
||||
editMenu.add(preferencesItem);
|
||||
}
|
||||
|
||||
menuBar.add(editMenu);
|
||||
{
|
||||
JMenuItem preferencesItem = new JMenuItem("Save preferences to " + ThdlOptions.getUserPreferencesPath());
|
||||
preferencesItem.addActionListener(new ThdlActionListener() {
|
||||
public void theRealActionPerformed(ActionEvent e) {
|
||||
savePreferencesAction();
|
||||
}
|
||||
});
|
||||
editMenu.add(preferencesItem);
|
||||
}
|
||||
|
||||
menuBar.add(editMenu);
|
||||
|
||||
JMenu toolsMenu = new JMenu("Tools");
|
||||
|
||||
|
@ -347,6 +370,15 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
|
||||
menuBar.add(infoMenu);
|
||||
|
||||
/* Initialize dp before calling
|
||||
JskadKeyboard.activate(DuffPane) or dp.toggleLanguage(). */
|
||||
if (ThdlOptions.getBooleanOption(Jskad.enableKeypressStatusProp)) {
|
||||
dp = new DuffPane(statusBar);
|
||||
} else {
|
||||
dp = new DuffPane();
|
||||
}
|
||||
|
||||
|
||||
JToolBar toolBar = new JToolBar();
|
||||
toolBar.setBorder(null);
|
||||
toolBar.addSeparator();
|
||||
|
@ -355,9 +387,30 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
|
||||
String[] input_modes = {"Tibetan","Roman"};
|
||||
final JComboBox inputmethods = new JComboBox(input_modes);
|
||||
|
||||
int initialInputMethod
|
||||
= ThdlOptions.getIntegerOption("thdl.Jskad.input.method", 0);
|
||||
if (!dp.isRomanEnabled() && 1 == initialInputMethod) {
|
||||
initialInputMethod = 0;
|
||||
System.out.println("Hey yo! Roman input mode is not enabled, but your preference is for Roman mode at startup. Sorry!");
|
||||
ThdlDebug.noteIffyCode();
|
||||
}
|
||||
try {
|
||||
inputmethods.setSelectedIndex(initialInputMethod);
|
||||
} catch (IllegalArgumentException e) {
|
||||
initialInputMethod = 0; // Tibetan is the default.
|
||||
inputmethods.setSelectedIndex(initialInputMethod);
|
||||
}
|
||||
// Because we start in Tibetan mode, we must toggle initially
|
||||
// if the user wants it that way:
|
||||
if (1 == initialInputMethod && dp.isRomanEnabled())
|
||||
dp.toggleLanguage();
|
||||
|
||||
inputmethods.addActionListener(new ThdlActionListener() {
|
||||
public void theRealActionPerformed(ActionEvent e) {
|
||||
switch (inputmethods.getSelectedIndex()) {
|
||||
int si = inputmethods.getSelectedIndex();
|
||||
ThdlOptions.setUserPreference("thdl.Jskad.input.method", si);
|
||||
switch (si) {
|
||||
case 0: //Tibetan
|
||||
if (dp.isRomanMode())
|
||||
dp.toggleLanguage();
|
||||
|
@ -380,15 +433,6 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
toolBar.add(new JLabel("Keyboard:"));
|
||||
toolBar.addSeparator();
|
||||
|
||||
/* Initialize dp before calling
|
||||
JskadKeyboard.activate(DuffPane). */
|
||||
if (ThdlOptions.getBooleanOption(Jskad.enableKeypressStatusProp)) {
|
||||
dp = new DuffPane(statusBar);
|
||||
} else {
|
||||
dp = new DuffPane();
|
||||
}
|
||||
|
||||
|
||||
final JComboBox keyboards
|
||||
= new JComboBox(keybdMgr.getIdentifyingStrings());
|
||||
int initialKeyboard
|
||||
|
@ -402,7 +446,10 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
keybdMgr.elementAt(initialKeyboard).activate(dp);
|
||||
keyboards.addActionListener(new ThdlActionListener() {
|
||||
public void theRealActionPerformed(ActionEvent e) {
|
||||
int ki = keyboards.getSelectedIndex();
|
||||
keybdMgr.elementAt(keyboards.getSelectedIndex()).activate(dp);
|
||||
ThdlOptions.setUserPreference("thdl.default.tibetan.keyboard",
|
||||
ki);
|
||||
}
|
||||
});
|
||||
toolBar.add(keyboards);
|
||||
|
@ -493,11 +540,12 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
int size;
|
||||
try {
|
||||
size = Integer.parseInt(tibetanFontSizes.getSelectedItem().toString());
|
||||
dp.setByUserTibetanFontSize(size);
|
||||
}
|
||||
catch (NumberFormatException ne) {
|
||||
size = dp.getTibetanFontSize();
|
||||
dp.setTibetanFontSize(size);
|
||||
}
|
||||
dp.setTibetanFontSize(size);
|
||||
|
||||
String font = romanFontFamilies.getSelectedItem().toString();
|
||||
try {
|
||||
|
@ -506,7 +554,7 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
catch (NumberFormatException ne) {
|
||||
size = dp.getRomanFontSize();
|
||||
}
|
||||
dp.setRomanAttributeSet(font, size);
|
||||
dp.setByUserRomanAttributeSet(font, size);
|
||||
}
|
||||
|
||||
private void newFile() {
|
||||
|
@ -991,6 +1039,18 @@ public class Jskad extends JPanel implements DocumentListener {
|
|||
f.setLocation(d.width/8, d.height/8);
|
||||
f.getContentPane().add(new Jskad(f));
|
||||
f.setVisible(true);
|
||||
|
||||
/* Make it so that any time the user exits Jskad by
|
||||
* (almost) any means, the user's preferences are saved if
|
||||
* the SecurityManager allows it and the path is
|
||||
* correct. */
|
||||
Runtime.getRuntime().addShutdownHook(new Thread() {
|
||||
public void run() {
|
||||
savePreferencesAction();
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
} catch (ThdlLazyException e) {
|
||||
// FIXME: tell the users how to submit bug reports.
|
||||
System.err.println("Jskad has a BUG:");
|
||||
|
|
|
@ -27,7 +27,7 @@ import org.thdl.tib.input.JskadKeyboard;
|
|||
public class JskadKeyboardFactory {
|
||||
public static JskadKeyboard[] getAllAvailableJskadKeyboards() {
|
||||
return new JskadKeyboard[] {
|
||||
new JskadKeyboard("Extended Wylie Keyboard",
|
||||
new JskadKeyboard("Extended Wylie",
|
||||
null,
|
||||
"Wylie_keyboard.rtf"),
|
||||
new JskadKeyboard("TCC Keyboard #1",
|
||||
|
@ -39,7 +39,7 @@ public class JskadKeyboardFactory {
|
|||
new JskadKeyboard("Sambhota Keymap One",
|
||||
"sambhota_keyboard_1.ini",
|
||||
"Sambhota_keymap_one.rtf"),
|
||||
new JskadKeyboard("Asian Classics Input Project (ACIP) Keyboard",
|
||||
new JskadKeyboard("Asian Classics Input Project (ACIP)",
|
||||
"acip_keyboard.ini",
|
||||
null)
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue