Revision: 8483
http://languagetool.svn.sourceforge.net/languagetool/?rev=8483&view=rev
Author: dnaber
Date: 2012-12-02 15:15:11 +0000 (Sun, 02 Dec 2012)
Log Message:
-----------
cleanup: separate public and private methods (no other change than method
order) - this class is too long, I think this new method order makes it at
least a bit better
Modified Paths:
--------------
trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
Modified: trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
===================================================================
--- trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
2012-12-02 15:03:43 UTC (rev 8482)
+++ trunk/JLanguageTool/src/main/java/org/languagetool/gui/Main.java
2012-12-02 15:15:11 UTC (rev 8483)
@@ -80,7 +80,6 @@
private boolean closeHidesToTray;
private boolean isInTray;
-
private boolean isAlreadyChecking;
private Main() throws IOException {
@@ -90,6 +89,73 @@
maybeStartServer();
}
+ @Override
+ public void actionPerformed(final ActionEvent e) {
+ try {
+ if
(e.getActionCommand().equals(StringTools.getLabel(messages.getString("checkText"))))
{
+ checkTextAndDisplayResults();
+ } else {
+ throw new IllegalArgumentException("Unknown action " + e);
+ }
+ } catch (Exception exc) {
+ Tools.showError(exc);
+ }
+ }
+
+ void loadFile() {
+ final File file = Tools.openFileDialog(frame, new PlainTextFileFilter());
+ if (file == null) {
+ // user clicked cancel
+ return;
+ }
+ try {
+ final FileInputStream inputStream = new FileInputStream(file);
+ try {
+ final String fileContents = StringTools.readFile(inputStream);
+ textArea.setText(fileContents);
+ } finally {
+ inputStream.close();
+ }
+ checkTextAndDisplayResults();
+ } catch (IOException e) {
+ Tools.showError(e);
+ }
+ }
+
+ void addLanguage() {
+ final LanguageManagerDialog lmd = new LanguageManagerDialog(frame,
Language.getExternalLanguages());
+ lmd.show();
+ try {
+ Language.reInit(lmd.getLanguages());
+ } catch (RuleFilenameException e) {
+ Tools.showErrorMessage(e);
+ }
+ languageBox.populateLanguageBox();
+ }
+
+ void showOptions() {
+ final Language currentLanguage = getCurrentLanguage();
+ final JLanguageTool langTool = getCurrentLanguageTool(currentLanguage);
+ final List<Rule> rules = langTool.getAllRules();
+ final ConfigurationDialog configDialog =
getCurrentConfigDialog(currentLanguage);
+ configDialog.show(rules); // this blocks until OK/Cancel is clicked in the
dialog
+ config.setDisabledRuleIds(configDialog.getDisabledRuleIds());
+ config.setEnabledRuleIds(configDialog.getEnabledRuleIds());
+ config.setDisabledCategoryNames(configDialog.getDisabledCategoryNames());
+ config.setMotherTongue(configDialog.getMotherTongue());
+ config.setRunServer(configDialog.getRunServer());
+ config.setUseGUIConfig(configDialog.getUseGUIConfig());
+ config.setServerPort(configDialog.getServerPort());
+ try { //save config - needed for the server
+ config.saveConfiguration(langTool.getLanguage());
+ } catch (IOException e) {
+ Tools.showError(e);
+ }
+ // Stop server, start new server if requested:
+ stopServer();
+ maybeStartServer();
+ }
+
private void createGUI() {
frame = new JFrame("LanguageTool " + JLanguageTool.VERSION);
@@ -141,13 +207,13 @@
autoDetectBox = new LanguageDetectionCheckbox(messages, languageBox,
config);
languageBox.setEnabled(!autoDetectBox.isSelected());
-
+
buttonCons.gridx = 1;
buttonCons.gridy = 1;
buttonCons.gridwidth = 2;
buttonCons.anchor = GridBagConstraints.WEST;
insidePanel.add(autoDetectBox, buttonCons);
-
+
final Container contentPane = frame.getContentPane();
final GridBagLayout gridLayout = new GridBagLayout();
contentPane.setLayout(gridLayout);
@@ -160,7 +226,7 @@
cons.gridy = 1;
cons.weighty = 5.0f;
final JSplitPane splitPane = new JSplitPane(JSplitPane.VERTICAL_SPLIT,
- new JScrollPane(textArea), new JScrollPane(resultArea));
+ new JScrollPane(textArea), new JScrollPane(resultArea));
splitPane.setDividerLocation(200);
contentPane.add(splitPane, cons);
@@ -189,43 +255,31 @@
}
}
- private void showGUI() {
- frame.setVisible(true);
+ private PopupMenu makePopupMenu() {
+ final PopupMenu popup = new PopupMenu();
+ final ActionListener rmbListener = new TrayActionRMBListener();
+ // Check clipboard text:
+ final MenuItem checkClipboardItem =
+ new
MenuItem(StringTools.getLabel(messages.getString("guiMenuCheckClipboard")));
+ checkClipboardItem.addActionListener(rmbListener);
+ popup.add(checkClipboardItem);
+ // Open main window:
+ final MenuItem restoreItem = new
MenuItem(StringTools.getLabel(messages.getString("guiMenuShowMainWindow")));
+ restoreItem.addActionListener(rmbListener);
+ popup.add(restoreItem);
+ // Exit:
+ final MenuItem exitItem = new
MenuItem(StringTools.getLabel(messages.getString("guiMenuQuit")));
+ exitItem.addActionListener(rmbListener);
+ popup.add(exitItem);
+ return popup;
}
- @Override
- public void actionPerformed(final ActionEvent e) {
- try {
- if
(e.getActionCommand().equals(StringTools.getLabel(messages.getString("checkText"))))
{
- checkTextAndDisplayResults();
- } else {
- throw new IllegalArgumentException("Unknown action " + e);
- }
- } catch (Exception exc) {
- Tools.showError(exc);
- }
+ void checkClipboardText() {
+ final String s = getClipboardText();
+ textArea.setText(s);
+ checkTextAndDisplayResults();
}
- void loadFile() {
- final File file = Tools.openFileDialog(frame, new PlainTextFileFilter());
- if (file == null) {
- // user clicked cancel
- return;
- }
- try {
- final FileInputStream inputStream = new FileInputStream(file);
- try {
- final String fileContents = StringTools.readFile(inputStream);
- textArea.setText(fileContents);
- } finally {
- inputStream.close();
- }
- checkTextAndDisplayResults();
- } catch (IOException e) {
- Tools.showError(e);
- }
- }
-
void hideToTray() {
if (!isInTray) {
final SystemTray tray = SystemTray.getSystemTray();
@@ -245,63 +299,44 @@
frame.setVisible(false);
}
- private PopupMenu makePopupMenu() {
- final PopupMenu popup = new PopupMenu();
- final ActionListener rmbListener = new TrayActionRMBListener();
- // Check clipboard text:
- final MenuItem checkClipboardItem =
- new
MenuItem(StringTools.getLabel(messages.getString("guiMenuCheckClipboard")));
- checkClipboardItem.addActionListener(rmbListener);
- popup.add(checkClipboardItem);
- // Open main window:
- final MenuItem restoreItem = new
MenuItem(StringTools.getLabel(messages.getString("guiMenuShowMainWindow")));
- restoreItem.addActionListener(rmbListener);
- popup.add(restoreItem);
- // Exit:
- final MenuItem exitItem = new
MenuItem(StringTools.getLabel(messages.getString("guiMenuQuit")));
- exitItem.addActionListener(rmbListener);
- popup.add(exitItem);
- return popup;
+ void tagText() {
+ new Thread() {
+ @Override
+ public void run() {
+ setWaitCursor();
+ try {
+ final JLanguageTool langTool =
getCurrentLanguageTool(getCurrentLanguage());
+ tagTextAndDisplayResults(langTool);
+ } finally {
+ unsetWaitCursor();
+ }
+ }
+ }.start();
}
- void addLanguage() {
- final LanguageManagerDialog lmd = new LanguageManagerDialog(frame,
Language.getExternalLanguages());
- lmd.show();
- try {
- Language.reInit(lmd.getLanguages());
- } catch (RuleFilenameException e) {
- Tools.showErrorMessage(e);
+ void quitOrHide() {
+ if (closeHidesToTray) {
+ hideToTray();
+ } else {
+ quit();
}
- languageBox.populateLanguageBox();
}
- void showOptions() {
- final Language currentLanguage = getCurrentLanguage();
- final JLanguageTool langTool = getCurrentLanguageTool(currentLanguage);
- final List<Rule> rules = langTool.getAllRules();
- final ConfigurationDialog configDialog =
getCurrentConfigDialog(currentLanguage);
- configDialog.show(rules); // this blocks until OK/Cancel is clicked in the
dialog
- config.setDisabledRuleIds(configDialog.getDisabledRuleIds());
- config.setEnabledRuleIds(configDialog.getEnabledRuleIds());
- config.setDisabledCategoryNames(configDialog.getDisabledCategoryNames());
- config.setMotherTongue(configDialog.getMotherTongue());
- config.setRunServer(configDialog.getRunServer());
- config.setUseGUIConfig(configDialog.getUseGUIConfig());
- config.setServerPort(configDialog.getServerPort());
- try { //save config - needed for the server
- config.saveConfiguration(langTool.getLanguage());
- } catch (IOException e) {
- Tools.showError(e);
- }
- // Stop server, start new server if requested:
+ void quit() {
stopServer();
- maybeStartServer();
+ try {
+ final Language currentLanguage = getCurrentLanguage();
+
config.saveConfiguration(getCurrentLanguageTool(currentLanguage).getLanguage());
+ } catch (IOException e) {
+ Tools.showError(e);
+ }
+ frame.setVisible(false);
+ JLanguageTool.removeTemporaryFiles();
+ System.exit(0);
}
- void checkClipboardText() {
- final String s = getClipboardText();
- textArea.setText(s);
- checkTextAndDisplayResults();
+ private void showGUI() {
+ frame.setVisible(true);
}
private void restoreFromTray() {
@@ -309,7 +344,7 @@
}
// show GUI and check the text from clipboard/selection:
- private void restoreFromTrayAndCheck() {
+ private void restoreFromTrayAndCheck() {
final String s = getClipboardText();
restoreFromTray();
textArea.setText(s);
@@ -342,43 +377,7 @@
}
return s;
}
-
- void tagText() {
- new Thread() {
- @Override
- public void run() {
- setWaitCursor();
- try {
- final JLanguageTool langTool =
getCurrentLanguageTool(getCurrentLanguage());
- tagTextAndDisplayResults(langTool);
- } finally {
- unsetWaitCursor();
- }
- }
- }.start();
- }
- void quitOrHide() {
- if (closeHidesToTray) {
- hideToTray();
- } else {
- quit();
- }
- }
-
- void quit() {
- stopServer();
- try {
- final Language currentLanguage = getCurrentLanguage();
-
config.saveConfiguration(getCurrentLanguageTool(currentLanguage).getLanguage());
- } catch (IOException e) {
- Tools.showError(e);
- }
- frame.setVisible(false);
- JLanguageTool.removeTemporaryFiles();
- System.exit(0);
- }
-
private void maybeStartServer() {
if (config.getRunServer()) {
try {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Keep yourself connected to Go Parallel:
DESIGN Expert tips on starting your parallel project right.
http://goparallel.sourceforge.net/
_______________________________________________
Languagetool-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/languagetool-commits