Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 57 additions & 63 deletions src/main/java/tm/modaldialog/TMModalDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,14 @@
import java.awt.event.*;

/**
*
* A class providing a general framework for modal dialogs.
* It has an OK and Cancel button. Must be subclassed to
* provide the getDialogPane() method, which creates and
* returns a panel with the actual dialog components where
* input can be given by the user.
*
**/
*
* A class providing a general framework for modal dialogs.
* It has an OK and Cancel button. Must be subclassed to
* provide the getDialogPane() method, which creates and
* returns a panel with the actual dialog components where
* input can be given by the user.
*
**/

public abstract class TMModalDialog extends JDialog {

Expand All @@ -43,11 +43,11 @@ public abstract class TMModalDialog extends JDialog {
private Xlator xl;
private JPanel dialogPane;

/**
*
*
*
**/
/**
*
*
*
**/

public TMModalDialog(Frame owner, String title, Xlator xl) {
super(owner, xl != null ? xl.xlate(title) : title, true);
Expand All @@ -56,17 +56,17 @@ public TMModalDialog(Frame owner, String title, Xlator xl) {
okButton = new JButton(xlate("OK"));
cancelButton = new JButton(xlate("Cancel"));
okButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
approveInput();
}
new ActionListener() {
public void actionPerformed(ActionEvent e) {
approveInput();
}
}
);
cancelButton.addActionListener(
new ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelInput();
}
new ActionListener() {
public void actionPerformed(ActionEvent e) {
cancelInput();
}
}
);
JPanel buttonPane = new JPanel();
Expand All @@ -92,7 +92,7 @@ public Insets getInsets() {
return new Insets(10,10,10,10);
}
};
buttonPane.setBorder(new EmptyBorder(10, 0, 0, 0));
buttonPane.setBorder(new EmptyBorder(10, 0, 0, 0));
setContentPane(contentPane);
contentPane.setLayout(new BorderLayout());
contentPane.add(buttonPane, BorderLayout.SOUTH);
Expand All @@ -102,60 +102,60 @@ public Insets getInsets() {

}

/**
*
* Shows the dialog.
*
**/
/**
*
* Shows the dialog.
*
**/

public int showDialog() {
// center the dialog
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int insetx = (screenSize.width - getWidth()) / 2;
int insety = (screenSize.height - getHeight()) / 2;
setBounds(insetx, insety,
getWidth(), getHeight());
getWidth(), getHeight());

result = JOptionPane.CANCEL_OPTION;
setVisible(true);
return result;
}

/**
*
*
*
**/
/**
*
*
*
**/

protected void approveInput() {
result = JOptionPane.OK_OPTION;
setVisible(false);
}

/**
*
*
*
**/
/**
*
*
*
**/

protected void cancelInput() {
result = JOptionPane.CANCEL_OPTION;
setVisible(false);
}

/**
*
* Method that provides the real content pane of the dialog.
*
**/
/**
*
* Method that provides the real content pane of the dialog.
*
**/

protected abstract JPanel getDialogPane();

/**
*
*
*
**/
/**
*
*
*
**/

protected static void buildConstraints(GridBagConstraints gbc, int gx, int gy, int gw, int gh, int wx, int wy) {
gbc.gridx = gx;
Expand All @@ -166,13 +166,13 @@ protected static void buildConstraints(GridBagConstraints gbc, int gx, int gy, i
gbc.weighty = wy;
}

/**
*
* Sets enabled state of OK button.
* Subclasses can use this to keep the user from OK'ing the input when it
* isn't valid/completed.
*
**/
/**
*
* Sets enabled state of OK button.
* Subclasses can use this to keep the user from OK'ing the input when it
* isn't valid/completed.
*
**/

public void maybeEnableOKButton() {
okButton.setEnabled(inputOK());
Expand All @@ -192,14 +192,8 @@ public void removeUpdate(DocumentEvent e) {
}
}

public String xlate(String key) {
try {
String value = xl.xlate(key);
return value;
}
catch (Exception e) {
return key;
}
protected String xlate(String key) {
return xl.xlate(key);
}

}
16 changes: 2 additions & 14 deletions src/main/java/tm/modaldialog/TMOrganizeTreeDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -285,20 +285,8 @@ public void treeNodesRemoved(TreeModelEvent e) {
public void treeStructureChanged(TreeModelEvent e) {
}

/**
*
*
*
**/

public String xlate(String key) {
try {
String value = xl.xlate(key);
return value;
}
catch (Exception e) {
return key;
}
private String xlate(String key) {
return xl.xlate(key);
}

/**
Expand Down
37 changes: 0 additions & 37 deletions src/main/java/tm/ui/TMAboutDialog.java

This file was deleted.

12 changes: 3 additions & 9 deletions src/main/java/tm/ui/TMSettings.java
Original file line number Diff line number Diff line change
Expand Up @@ -258,15 +258,9 @@ public String makePropertyTag(String key, String value) {
* If no corresponding value is found, the key itself is returned.
*
**/

public String xlate(String key) {
try {
String value = xl.xlate(key);
return value;
} catch (Exception e) {
return key;
}
}
private String xlate(String key) {
return xl.xlate(key);
}


/**
Expand Down
12 changes: 3 additions & 9 deletions src/main/java/tm/ui/TMUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -4550,15 +4550,9 @@ public ColorCodec[] getColorCodecs() {
* If no corresponding value is found, the key itself is returned.
*
**/

public String xlate(String key) {
try {
String value = xl.xlate(key);
return value;
} catch (Exception e) {
return key;
}
}
public String xlate(String key) {
return xl.xlate(key);
}

/**
*
Expand Down
38 changes: 12 additions & 26 deletions src/main/java/tm/utils/Xlator.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,49 +21,35 @@
import java.util.ResourceBundle;
import java.util.Locale;

/**
*
*
*
**/

/*
* This class provides a simple way to translate strings in the application.
*/
public class Xlator {

private ResourceBundle rb;

/**
*
*
*
**/

public Xlator(String baseName, Locale locale) throws Exception {
rb = null;
try {
rb = ResourceBundle.getBundle(baseName, locale);
}
catch (Exception e) {
} catch (Exception e) {
throw e;
}
}

/**
*
*
*
**/

/**
* Translate a string to a different language. If the input key is not found the
* lookup key is returned.
*
* @param key input key
* @return translated string
*/
public String xlate(String key) {
try {
String value = rb.getString(key);
return value;
}
catch (Exception e) {
} catch (Exception e) {
return key;
}
}

public String trans(String key) {
return xlate(key);
}
}