- add date check to WelcomeScreen

git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@10262 75d07b2b-3a1a-0410-a2c5-0572b91ccdca
3.0
nor..67 12 years ago
parent 116eaf1bb8
commit 348faf6a04
  1. 2
      sdk/jme3-welcome-screen/src/com/jme3/gde/welcome/Bundle.properties
  2. 7
      sdk/jme3-welcome-screen/src/com/jme3/gde/welcome/Installer.java
  3. 65
      sdk/jme3-welcome-screen/src/com/jme3/gde/welcome/WelcomeScreenTopComponent.java

@ -5,4 +5,4 @@ OpenIDE-Module-Name=Welcome Screen
OpenIDE-Module-Short-Description=The jMonkeyEngine GDE Welcome Screen OpenIDE-Module-Short-Description=The jMonkeyEngine GDE Welcome Screen
WelcomeScreenTopComponent.http.link=http://jmonkeyengine.org/wiki/doku.php/sdk:welcome:3_0rc3?do=export_xhtmlbody WelcomeScreenTopComponent.http.link=http://jmonkeyengine.org/wiki/doku.php/sdk:welcome:3_0rc3?do=export_xhtmlbody
WelcomeScreenTopComponent.rss.link=http://jmonkeyengine.org/feed/rdf/ WelcomeScreenTopComponent.rss.link=http://jmonkeyengine.org/feed/rdf/
WelcomeScreenTopComponent.local.link=nbres:/com/jme3/gde/core/docs/sdk/welcome/3_0rc3.html WelcomeScreenTopComponent.local.link=nbres:/com/jme3/gde/docs/sdk/welcome/3_0rc3.html

@ -5,6 +5,7 @@
package com.jme3.gde.welcome; package com.jme3.gde.welcome;
import org.openide.modules.ModuleInstall; import org.openide.modules.ModuleInstall;
import org.openide.windows.WindowManager;
/** /**
* Manages a module's lifecycle. Remember that an installer is optional and * Manages a module's lifecycle. Remember that an installer is optional and
@ -14,5 +15,11 @@ public class Installer extends ModuleInstall {
@Override @Override
public void restored() { public void restored() {
WindowManager.getDefault().invokeWhenUIReady(new Runnable(){
public void run() {
WelcomeScreenTopComponent.checkOpen();
}
});
} }
} }

@ -4,9 +4,11 @@
*/ */
package com.jme3.gde.welcome; package com.jme3.gde.welcome;
import com.jme3.gde.welcome.rss.RssFeedParser;
import java.io.IOException; import java.io.IOException;
import java.net.URL; import java.net.URL;
import java.net.URLConnection;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.event.HyperlinkEvent; import javax.swing.event.HyperlinkEvent;
import javax.swing.event.HyperlinkListener; import javax.swing.event.HyperlinkListener;
import org.netbeans.api.settings.ConvertAsProperties; import org.netbeans.api.settings.ConvertAsProperties;
@ -17,6 +19,8 @@ import org.openide.util.Exceptions;
import org.openide.util.HelpCtx; import org.openide.util.HelpCtx;
import org.openide.windows.TopComponent; import org.openide.windows.TopComponent;
import org.openide.util.NbBundle.Messages; import org.openide.util.NbBundle.Messages;
import org.openide.util.NbPreferences;
import org.openide.windows.WindowManager;
import sun.swing.SwingUtilities2; import sun.swing.SwingUtilities2;
/** /**
@ -28,7 +32,7 @@ autostore = false)
@TopComponent.Description( @TopComponent.Description(
preferredID = "WelcomeScreenTopComponent", preferredID = "WelcomeScreenTopComponent",
//iconBase="SET/PATH/TO/ICON/HERE", //iconBase="SET/PATH/TO/ICON/HERE",
persistenceType = TopComponent.PERSISTENCE_NEVER) persistenceType = TopComponent.PERSISTENCE_ALWAYS)
@TopComponent.Registration(mode = "editor", openAtStartup = true) @TopComponent.Registration(mode = "editor", openAtStartup = true)
@ActionID(category = "Window", id = "com.jme3.gde.welcome.WelcomeScreenTopComponent") @ActionID(category = "Window", id = "com.jme3.gde.welcome.WelcomeScreenTopComponent")
@ActionReference(path = "Menu/Window" /*, position = 333 */) @ActionReference(path = "Menu/Window" /*, position = 333 */)
@ -41,8 +45,9 @@ preferredID = "WelcomeScreenTopComponent")
"HINT_WelcomeScreenTopComponent=Shows news and information about your SDK" "HINT_WelcomeScreenTopComponent=Shows news and information about your SDK"
}) })
public final class WelcomeScreenTopComponent extends TopComponent implements HyperlinkListener { public final class WelcomeScreenTopComponent extends TopComponent implements HyperlinkListener {
private static final HelpCtx ctx = new HelpCtx("com.jme3.gde.core.about");
private static final Logger logger = Logger.getLogger(WelcomeScreenTopComponent.class.getName());
private static final HelpCtx ctx = new HelpCtx("com.jme3.gde.core.about");
// private final RssFeedParser parser = new RssFeedParser(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.rss.link")); // private final RssFeedParser parser = new RssFeedParser(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.rss.link"));
public WelcomeScreenTopComponent() { public WelcomeScreenTopComponent() {
@ -60,10 +65,13 @@ public final class WelcomeScreenTopComponent extends TopComponent implements Hyp
try { try {
jEditorPane1.setPage(he.getURL()); jEditorPane1.setPage(he.getURL());
} catch (IOException ex) { } catch (IOException ex) {
logger.log(Level.INFO, "Loading page failed", ex);
try { try {
jEditorPane1.setPage(new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.local.link"))); logger.log(Level.WARNING, "Could not open web page!");
URL startUrl = new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.local.link"));
jEditorPane1.setPage(startUrl);
} catch (IOException ex1) { } catch (IOException ex1) {
Exceptions.printStackTrace(ex1); logger.log(Level.SEVERE, "Could not open local help page!", ex1);
} }
} }
} }
@ -71,6 +79,42 @@ public final class WelcomeScreenTopComponent extends TopComponent implements Hyp
}); });
} }
public void loadPage() {
try {
URL startUrl = new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.http.link"));
URLConnection conn = startUrl.openConnection();
long lastMod = conn.getLastModified();
NbPreferences.forModule(getClass()).putLong("LAST_PAGE_UPDATE", lastMod);
jEditorPane1.setPage(startUrl);
} catch (IOException ex) {
logger.log(Level.INFO, "Loading page failed", ex);
try {
jEditorPane1.setPage(new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.local.link")));
} catch (IOException ex1) {
logger.log(Level.SEVERE, "Could not open local help page!", ex1);
}
}
}
public static void checkOpen() {
try {
long lastCheck = NbPreferences.forModule(WelcomeScreenTopComponent.class).getLong("LAST_PAGE_UPDATE", 0);
URL startUrl = new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.http.link"));
URLConnection conn = startUrl.openConnection();
long lastMod = conn.getLastModified();
if (lastCheck != lastMod) {
WelcomeScreenTopComponent tc = (WelcomeScreenTopComponent) WindowManager.getDefault().findTopComponent("WelcomeScreenTopComponent");
if (tc != null) {
tc.open();
tc.requestActive();
}
}
} catch (IOException ex) {
Exceptions.printStackTrace(ex);
}
}
/** /**
* This method is called from within the constructor to initialize the form. * This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always * WARNING: Do NOT modify this code. The content of this method is always
@ -133,16 +177,7 @@ public final class WelcomeScreenTopComponent extends TopComponent implements Hyp
@Override @Override
public void componentOpened() { public void componentOpened() {
try { loadPage();
jEditorPane1.setPage(new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.http.link")));
} catch (IOException ex) {
try {
jEditorPane1.setPage(new URL(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.local.link")));
} catch (IOException ex1) {
Exceptions.printStackTrace(ex1);
}
}
// parser.updateFeed();
} }
@Override @Override

Loading…
Cancel
Save