Revision: 3845
Author: [email protected]
Date: Thu Aug 5 16:05:33 2010
Log: Architect now checks for updates on startup.
http://code.google.com/p/power-architect/source/detail?r=3845
Modified:
/trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CheckForUpdateAction.java
=======================================
--- /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Thu Aug 5 12:36:09 2010
+++ /trunk/src/main/java/ca/sqlpower/architect/swingui/ArchitectFrame.java
Thu Aug 5 16:05:33 2010
@@ -866,7 +866,7 @@
}
public JMenuBar createNewMenuBar() {
- Action checkForUpdateAction = new CheckForUpdateAction(this);
+ checkForUpdateAction = new CheckForUpdateAction(this);
Action exportCSVAction = new ExportCSVAction(this);
Action mappingReportAction = new VisualMappingReportAction(this);
Action kettleETL = new KettleJobAction(this);
@@ -1203,6 +1203,8 @@
private JMenu enterpriseMenu;
+ private CheckForUpdateAction checkForUpdateAction;
+
public JMenu getEnterpriseMenu() {
return enterpriseMenu;
}
@@ -1379,13 +1381,20 @@
sessions.add(context.createSession());
}
if (!headless) {
- ArchitectFrame frame = new ArchitectFrame(context,
null);
+ final ArchitectFrame frame = new
ArchitectFrame(context, null);
frame.init(sessions.get(0));
for (int i = 1; i < sessions.size(); i++) {
frame.addSession(sessions.get(i));
frame.setCurrentSession(sessions.get(i));
}
frame.setCurrentSession(sessions.get(0));
+
+ SwingUtilities.invokeLater(new Runnable() {
+ @Override
+ public void run() {
+
frame.checkForUpdateAction.checkForUpdate(false);
+ }
+ });
}
} catch (Exception e) {
e.printStackTrace();
=======================================
---
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CheckForUpdateAction.java
Mon Jul 12 08:21:11 2010
+++
/trunk/src/main/java/ca/sqlpower/architect/swingui/action/CheckForUpdateAction.java
Thu Aug 5 16:05:33 2010
@@ -33,7 +33,6 @@
import ca.sqlpower.architect.ArchitectVersion;
import ca.sqlpower.architect.swingui.ASUtils;
import ca.sqlpower.architect.swingui.ArchitectFrame;
-import ca.sqlpower.architect.swingui.ArchitectSwingSession;
import ca.sqlpower.util.BrowserUtil;
/**
@@ -48,7 +47,6 @@
private static final String UPDATE_URL
= "http://download.sqlpower.ca/architect/current.html"; //$NON-NLS-1$
- private ArchitectSwingSession session;
private String versionPropertyString;
private HttpURLConnection urlc;
@@ -64,6 +62,10 @@
* message as appropriate.
*/
public void actionPerformed(ActionEvent e) {
+ checkForUpdate(true);
+ }
+
+ public void checkForUpdate(boolean verbose) {
try {
URL url = new URL(VERSION_FILE_URL);
urlc = (HttpURLConnection) url.openConnection();
@@ -82,15 +84,15 @@
if (userVersion.compareTo(latestVersion) < 0) {
promptUpdate();
- } else {
- JOptionPane.showMessageDialog(session.getArchitectFrame(),
+ } else if (verbose) {
+
JOptionPane.showMessageDialog(getSession().getArchitectFrame(),
Messages.getString("CheckForUpdateAction.upToDate"), //$NON-NLS-1$
Messages.getString("CheckForUpdateAction.name"),
//$NON-NLS-1$
JOptionPane.INFORMATION_MESSAGE);
}
} catch (IOException ex) {
logger.error("Fail to retrieve current version number!");
//$NON-NLS-1$
-
ASUtils.showExceptionDialogNoReport(session.getArchitectFrame(),
+
ASUtils.showExceptionDialogNoReport(getSession().getArchitectFrame(),
Messages.getString("CheckForUpdateAction.failedToCheckForUpdate"), ex);
//$NON-NLS-1$
} finally {
urlc.disconnect();
@@ -107,7 +109,7 @@
* Prompts the user for update and opens browser to current version if
accepted.
*/
private void promptUpdate() {
- int response =
JOptionPane.showConfirmDialog(session.getArchitectFrame(),
+ int response =
JOptionPane.showConfirmDialog(getSession().getArchitectFrame(),
Messages.getString("CheckForUpdateAction.newerVersionAvailable"),
//$NON-NLS-1$
Messages.getString("CheckForUpdateAction.name"),
//$NON-NLS-1$
JOptionPane.YES_NO_OPTION);
@@ -115,7 +117,7 @@
try {
BrowserUtil.launch(UPDATE_URL);
} catch (IOException e) {
-
ASUtils.showExceptionDialogNoReport(session.getArchitectFrame(),
+
ASUtils.showExceptionDialogNoReport(getSession().getArchitectFrame(),
Messages.getString("CheckForUpdateAction.failedToUpdate"), e); //$NON-NLS-1$
}
}