-- Changelog --
* 2012-
+- Updated french translations.
+- Fixed #3432039 TODO: add necessary L10n strings
- Fixed #3482839 Exit Custom Grid Mode in case New/Open grid is selected
- Fixed #3482838 Actions to deactivate when in normal "custom grid" mode
- Fixed #3482837 Deactivate "play grid" if custom grid is invalid
public void actionPerformed(ActionEvent e) {\r
CheckUpdateDialog dlg = new CheckUpdateDialog(frame, this);\r
dlg.setVisible(true);\r
- int isNewVersionAvailable = dlg.getResult();\r
- if (isNewVersionAvailable == 0) {\r
+ int upToDateStatus = dlg.getResult();\r
+ if (upToDateStatus == 0) {\r
JOptionPane.showMessageDialog(frame, "<html>"\r
+ "<table border=\"0\">" + "<tr>"\r
+ _("This version of Sudokuki is up-to-date.") + "</tr>"\r
+ "</html>", "Sudokuki", JOptionPane.PLAIN_MESSAGE);\r
- } else if (isNewVersionAvailable == 1) {\r
+ } else if (upToDateStatus == 1) {\r
openUpdateSiteAction.setEnabled(true);\r
NewVersionFoundDialog nvDlg = new NewVersionFoundDialog(frame);\r
nvDlg.setVisible(true);\r
- } else if (isNewVersionAvailable == -1) {\r
+ } else if (upToDateStatus == -1) {\r
JOptionPane.showMessageDialog(frame, "<html>"\r
+ "<table border=\"0\">" + "<tr>"\r
+ _("Unable to retrieve update information.<br/><br/>Please check on the following website<br/>if a new version of Sudokuki is available:<br/><br/>")\r
import static net.jankenpoi.i18n.I18n._;
import java.awt.Container;
+import java.awt.FlowLayout;
import java.awt.GridLayout;
import java.io.BufferedReader;
import java.io.IOException;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
+import javax.swing.JPanel;
import javax.swing.SwingWorker;
import net.jankenpoi.sudokuki.Version;
@SuppressWarnings("serial")
public class CheckUpdateDialog extends JDialog {
+ private static final String VERSION_FILE_DOWNLOAD_WEB_SITE = "http://sourceforge.net/projects/sudokuki/files/sudokuki/1.1/Beta/LATEST/download";
+
private JFrame parent;
final CheckUpdateAction checkUpdateAction;
- /**
- * <b>Warning</b>: read/write this variable from the EDT thread only.
- */
- private int result = -1;
+ private int result = -1; // to access from the EDT only
private final SwingWorker<String, Void> worker = new SwingWorker<String, Void>() {
System.out
.println("CheckUpdateDialog.worker.new SwingWorker() {...}.done() CancellationException !!!!");
result = -2;
+ } finally {
+ CheckUpdateDialog.this.dispose();
}
- CheckUpdateDialog.this.dispose();
}
private String getHttpLatestVersionString() {
URL url;
URLConnection urlConn;
- url = new URL(
- "http://sourceforge.net/projects/sudokuki/files/sudokuki/1.1/Beta/LATEST/download");
+ url = new URL(VERSION_FILE_DOWNLOAD_WEB_SITE);
urlConn = url.openConnection();
urlConn.setDoInput(true);
System.out.println("getHttpLatestVersionString() line:" + line);
String versionString = "";
if (line != null) {
- String[] strs = line.split(_(" is the latest version."));
+ String[] strs = line.split(" is the latest version.");
if (strs.length >= 1) {
versionString = strs[0];
}
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
Container pane = getContentPane();
- GridLayout btnLayout = new GridLayout(4, 1);
- pane.setLayout(btnLayout);
+ GridLayout layout = new GridLayout(3, 1);
+ pane.setLayout(layout);
JLabel messageLbl1 = new JLabel("<html>" + "<table border=\"0\">"
+ "<tr>" + "<td align=\"center\">"
- + _("Checking for available updates")+".</td>" + "</tr><html>");
- JLabel messageLbl2 = new JLabel("<html>" + "<table border=\"0\">"
- + "<tr>" + "<td align=\"center\">" + _("Please wait...")+"</td>"
+ + _("Checking for available updates") + ".</td>"
+ "</tr><html>");
- JLabel messageLbl3 = new JLabel("");
+ JLabel messageLbl2 = new JLabel("<html>" + "<table border=\"0\">"
+ + "<tr>" + "<td align=\"center\">" + _("Please wait...")
+ + "</td>" + "</tr><html>");
JButton cancelBtn = new JButton(_("Cancel"));
cancelBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
cancelBtn.addActionListener(new java.awt.event.ActionListener() {
pane.add(messageLbl1);
pane.add(messageLbl2);
- pane.add(messageLbl3);
- pane.add(cancelBtn);
+
+ FlowLayout btnLayout = new FlowLayout(1);
+ JPanel btnPanel = new JPanel();
+ btnPanel.setLayout(btnLayout);
+ btnPanel.add(cancelBtn);
+ pane.add(btnPanel);
pack();
setLocationRelativeTo(parent);
/**
* @return <ul>
- * <li>1 if a new version is available</li>
* <li>0 if the version is up-to-date</li>
+ * <li>1 if a new version is available</li>
* <li>-1 if an error occurred</li>
* <li>-2 if cancelled by the user</li>
* </ul>
* <i>result</i>).
*/
int getResult() {
+
+ System.out.println("CheckUpdateDialog.getResult() thread : "
+ + Thread.currentThread());
+ Thread.dumpStack();
+
System.out.println("CheckUpdateDialog.getResult() Thread:"
+ Thread.currentThread().getName());
\r
private JFrame parent;\r
\r
- private int status = -1;\r
-\r
private final GridView view;\r
\r
private final SwingWorker<Integer, Void> worker;\r
@Override\r
/* Executed in the EDT, triggered when the SwingWorker has completed */\r
protected void done() {\r
- boolean isGenerated = false;\r
try {\r
- status = get();\r
- if (status == 0) {\r
- isGenerated = true;\r
- }\r
+ get();\r
} catch (InterruptedException e) {\r
e.printStackTrace();\r
return;\r
} catch (ExecutionException e) {\r
e.printStackTrace();\r
return;\r
+ } finally {\r
+ dispose();\r
}\r
- dispose();\r
}\r
};\r
initComponents();\r
\r
private void initComponents() {\r
\r
- // FIXME: TODO: search how to do something special in case the window is\r
- // closed => set status to "CANCELLED"\r
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
\r
Container pane = getContentPane();\r
- GridLayout btnLayout = new GridLayout(4, 1);\r
+ GridLayout btnLayout = new GridLayout(3, 1);\r
pane.setLayout(btnLayout);\r
\r
\r
+ "</html>");\r
\r
JLabel messageLbl3 = new JLabel("");\r
- JButton cancelBtn = new JButton("Cancel");\r
+ JButton cancelBtn = new JButton(_("Please wait..."));\r
+ cancelBtn.setEnabled(false); // generate task is not interruptible at the moment\r
cancelBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);\r
cancelBtn.addActionListener(new java.awt.event.ActionListener() {\r
public void actionPerformed(java.awt.event.ActionEvent evt) {\r
*/\r
System.out\r
.println("ResolveGridDialog.ResolveGridDialog(...) CANCELLED");\r
- }\r
-\r
- /**\r
- * \r
- * @return <b>0</b> if the resolution was successful<br/>\r
- * <b>1</b> if the solving process was canceled by the user before\r
- * completion<br/>\r
- * <b>2</b> if the process failed to resolve the grid\r
- */\r
- public int getResult() {\r
- return status;\r
+ dispose();\r
}\r
\r
private int generateGrid() {\r
\r
import static net.jankenpoi.i18n.I18n._;\r
\r
+import java.awt.Container;\r
+import java.awt.FlowLayout;\r
import java.awt.GridLayout;\r
import java.awt.Point;\r
import java.awt.event.ActionEvent;\r
import java.util.Locale;\r
\r
import javax.swing.AbstractAction;\r
+import javax.swing.BoxLayout;\r
import javax.swing.ButtonGroup;\r
import javax.swing.Icon;\r
+import javax.swing.JButton;\r
import javax.swing.JDialog;\r
import javax.swing.JFrame;\r
import javax.swing.JPanel;\r
import javax.swing.JRadioButton;\r
\r
import net.jankenpoi.i18n.I18n;\r
+import net.jankenpoi.i18n.LocaleListener;\r
import net.jankenpoi.sudokuki.ui.L10nComponent;\r
\r
@SuppressWarnings("serial")\r
\r
private HashMap<String, JRadioButton> itemsMap = new HashMap<String, JRadioButton>();\r
\r
+ private LocaleListener localeListener;\r
+ \r
public LanguageDialog(JFrame parent, ToolBar toolbar) {\r
super(parent, true);\r
setTitle(_("Language"));\r
setLocation(toolBarLoc.x + toolbar.getWidth() / 2 - getWidth() / 2,\r
toolBarLoc.y + toolbar.getHeight());\r
setSize(getPreferredSize());\r
+ \r
+ localeListener = new LocaleListenerImpl(this);\r
+ I18n.addLocaleListener(localeListener);\r
}\r
\r
private JPanel panel = new JPanel();\r
+ private JPanel btnPanel = new JPanel();\r
+ private JButton okBtn = new JButton(_("Ok"));\r
\r
private void initComponents() {\r
- GridLayout btnLayout = new GridLayout(8, 1);\r
- panel.setLayout(btnLayout);\r
+ \r
+ Container pane = getContentPane();\r
+ BoxLayout globalLayout = new BoxLayout(pane, BoxLayout.Y_AXIS);\r
+ pane.setLayout(globalLayout);\r
+\r
+ GridLayout pnlLayout = new GridLayout(6, 1);\r
+ panel.setLayout(pnlLayout);\r
\r
String detectedLanguage = _("DETECTED_LANGUAGE");\r
System.out.println("LanguageMenu.addItems() detected language:"\r
addItem("ru", _("Russian"), myGroup);\r
addItem("zh", _("Mandarin"), myGroup);\r
\r
- add(panel);\r
+ pane.add(panel);\r
+ \r
+ FlowLayout btnLayout = new FlowLayout(1);\r
+ btnPanel.setLayout(btnLayout);\r
+ okBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);\r
+ okBtn.addActionListener(new java.awt.event.ActionListener() {\r
+ public void actionPerformed(java.awt.event.ActionEvent evt) {\r
+ okButtonClicked();\r
+ }\r
+\r
+ private void okButtonClicked() {\r
+ dispose();\r
+ }\r
+ });\r
+ btnPanel.add(okBtn); \r
+ \r
+ pane.add(btnPanel);\r
}\r
\r
@Override\r
public void setL10nMessages(Locale locale, String languageCode) {\r
setTitle(_("Language"));\r
+ okBtn.setText(_("Ok"));\r
itemsMap.get("de").setText(_("German"));\r
itemsMap.get("el").setText(_("Greek"));\r
itemsMap.get("en").setText(_("English"));\r
import static net.jankenpoi.i18n.I18n._;\r
\r
import java.awt.Container;\r
+import java.awt.FlowLayout;\r
import java.awt.GridLayout;\r
import java.awt.print.PrinterException;\r
import java.awt.print.PrinterJob;\r
+import java.util.concurrent.CancellationException;\r
import java.util.concurrent.ExecutionException;\r
\r
import javax.swing.JButton;\r
import javax.swing.JDialog;\r
import javax.swing.JFrame;\r
import javax.swing.JLabel;\r
+import javax.swing.JPanel;\r
import javax.swing.SwingWorker;\r
\r
import net.jankenpoi.sudokuki.view.GridView;\r
\r
private JFrame parent;\r
\r
- private int status = -1;\r
-\r
private final SwingWorker<Integer, Void> worker;\r
\r
+ private Object lock = new Object();\r
+ private boolean cancelledDialog = false;\r
+\r
public PrintMultiDialog(JFrame parent, final GridView view) {\r
\r
super(parent, true);\r
@Override\r
/* Executed in the EDT, triggered when the SwingWorker has completed */\r
protected void done() {\r
- boolean isResolved = false;\r
try {\r
- status = get();\r
- if (status == 0) {\r
- isResolved = true;\r
- }\r
+ get();\r
} catch (InterruptedException e) {\r
e.printStackTrace();\r
return;\r
} catch (ExecutionException e) {\r
e.printStackTrace();\r
return;\r
+ } catch (CancellationException ce) {\r
+ ce.printStackTrace();\r
+ } finally {\r
+ dispose();\r
}\r
- dispose();\r
}\r
};\r
initComponents();\r
\r
private void initComponents() {\r
\r
- // FIXME: TODO: search how to do something special in case the window is\r
- // closed => set status to "CANCELLED"\r
- // => call bruteSolver.cancel(); if the window was CLOSED using the\r
- // "CLOSE" button instead of the Cancel button...\r
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);\r
\r
Container pane = getContentPane();\r
- GridLayout btnLayout = new GridLayout(4, 1);\r
- pane.setLayout(btnLayout);\r
+ GridLayout layout = new GridLayout(3, 1);\r
+ pane.setLayout(layout);\r
\r
\r
JLabel messageLbl1 = new JLabel( \r
+ "<table border=\"0\">" + "<tr>"\r
+ _("to the printer...") + "</tr>"\r
+ "</html>");\r
- JLabel messageLbl3 = new JLabel("");\r
- JButton cancelBtn = new JButton("Cancel");\r
+ JButton cancelBtn = new JButton(_("Cancel"));\r
cancelBtn.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);\r
cancelBtn.addActionListener(new java.awt.event.ActionListener() {\r
public void actionPerformed(java.awt.event.ActionEvent evt) {\r
\r
pane.add(messageLbl1);\r
pane.add(messageLbl2);\r
- pane.add(messageLbl3);\r
- pane.add(cancelBtn);\r
+ \r
+ \r
+ FlowLayout btnLayout = new FlowLayout(1);\r
+ JPanel btnPanel = new JPanel();\r
+ btnPanel.setLayout(btnLayout);\r
+ btnPanel.add(cancelBtn);\r
+ pane.add(btnPanel);\r
\r
pack();\r
setLocationRelativeTo(parent);\r
\r
private void clickedCancel() {\r
System.out.println("PrintMultiDialog.clickedCancel()");\r
+ synchronized (lock) {\r
+ cancelledDialog = true;\r
+ }\r
/**\r
* CANCELLED\r
*/\r
System.out\r
.println("PrintMultiDialog.clickedCancel(...) CANCELLED");\r
-// bruteSolver.cancel();\r
+ boolean cancelled = worker.cancel(true);\r
+ System.out.println("PrintMultiDialog.clickedCancel(...) cancelled:"\r
+ + cancelled);\r
}\r
\r
- /**\r
- * \r
- * @return <b>0</b> if the resolution was successful<br/>\r
- * <b>1</b> if the solving process was canceled by the user before\r
- * completion<br/>\r
- * <b>2</b> if the process failed to resolve the grid\r
- */\r
- public int getResult() {\r
- return status;\r
+ private boolean dialogCancelled() {\r
+ synchronized (lock) {\r
+ return cancelledDialog;\r
+ }\r
}\r
-\r
+ \r
private int generateFourGrids() {\r
-\r
- System.out.println("PrintAction.actionPerformed() let try this out..."); \r
+ System.out.println("PrintAction.actionPerformed() let try this out..."); \r
+ if (dialogCancelled()) {\r
+ return 1;\r
+ }\r
PrinterJob job = PrinterJob.getPrinterJob();\r
+ if (dialogCancelled()) {\r
+ return 1;\r
+ }\r
job.setPrintable(new SwingMultiGrid());\r
+ if (dialogCancelled()) {\r
+ return 1;\r
+ }\r
boolean doPrint = job.printDialog();\r
System.out.println("SwingGrid.mouseExited() doPrint: "+doPrint);\r
if (doPrint) {\r
try {\r
+ if (dialogCancelled()) {\r
+ return 1;\r
+ }\r
job.print();\r
+ if (dialogCancelled()) {\r
+ return 1;\r
+ }\r
} catch (PrinterException pEx) {\r
/* The job did not successfully complete */\r
pEx.printStackTrace();\r
}\r
}\r
-\r
-// if (solution == null) {\r
-// /**\r
-// * RESOLUTION PROCESS CANCELLED BEFORE COMPLETION\r
-// */\r
-// return 1;\r
-// }\r
-// if (solution.isSolved()) {\r
-// GridModel solGrid = solution.getSolutionGrid();\r
-// for (int li = 0; li < 9; li++) {\r
-// for (int co = 0; co < 9; co++) {\r
-// byte value = solGrid.getValueAt(li, co);\r
-// view.getController().notifyGridValueChanged(li, co, value);\r
-// }\r
-// }\r
-// // fireGridChanged(new GridChangedEvent(this, 0, 0, (short) 0));\r
-// /**\r
-// * RESOLUTION SUCCESSFULL\r
-// */\r
-// return 0;\r
-// } else {\r
-// /**\r
-// * RESOLUTION PROCESS WAS UNABLE TO SOLVE THIS GRID\r
-// */\r
-// return 2;\r
-// }\r
return 0;\r
}\r
\r
import java.awt.Component;
import java.awt.event.ActionEvent;
+import java.util.Locale;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;
import javax.swing.JToolBar;
+import net.jankenpoi.i18n.I18n;
+import net.jankenpoi.i18n.LocaleListener;
+import net.jankenpoi.sudokuki.ui.L10nComponent;
+
@SuppressWarnings("serial")
-public class ToolBar extends JToolBar {
+public class ToolBar extends JToolBar implements L10nComponent {
private JFrame frame;
+ private Action actionInvokeLanguageDialog;
+ private final LocaleListener localeListener;
ToolBar(JFrame frame, ActionsRepository actions) {
this.frame = frame;
for (int i=0; i<components.length; i++) {
components[i].setFocusable(false);
}
+
+ setL10nMessages(null, null);
+ localeListener = new LocaleListenerImpl(this);
+ I18n.addLocaleListener(localeListener);
}
private void addButtons(ActionsRepository actions) {
button.setEnabled(false);
this.add(button);
- Action actionInvokeLanguageMenu = new AbstractAction() {
+ actionInvokeLanguageDialog = new AbstractAction() {
@Override
public void actionPerformed(ActionEvent arg0) {
}
};
- button = new JButton(actionInvokeLanguageMenu);
+ button = new JButton(actionInvokeLanguageDialog);
button.setEnabled(true);
- actionInvokeLanguageMenu.putValue(Action.SMALL_ICON, StockIcons.ICON_GO_HOME);
- actionInvokeLanguageMenu.putValue(Action.SHORT_DESCRIPTION, _("Language"));
+ actionInvokeLanguageDialog.putValue(Action.SMALL_ICON, StockIcons.ICON_GO_HOME);
+ actionInvokeLanguageDialog.putValue(Action.SHORT_DESCRIPTION, _("Language"));
button.setText("");
this.add(button);
}
+ @Override
+ public void setL10nMessages(Locale locale, String languageCode) {
+ actionInvokeLanguageDialog.putValue(Action.SHORT_DESCRIPTION, _("Language"));
+ }
+
}