git-svn-id: https://jmonkeyengine.googlecode.com/svn/trunk@9958 75d07b2b-3a1a-0410-a2c5-0572b91ccdca3.0
parent
d8fd0868df
commit
1c169fda64
@ -1,8 +1,8 @@ |
||||
build.xml.data.CRC32=991b240e |
||||
build.xml.data.CRC32=b1982df4 |
||||
build.xml.script.CRC32=e68af6b0 |
||||
build.xml.stylesheet.CRC32=a56c6a5b@2.49.1 |
||||
build.xml.stylesheet.CRC32=a56c6a5b@2.50.1 |
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. |
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. |
||||
nbproject/build-impl.xml.data.CRC32=991b240e |
||||
nbproject/build-impl.xml.data.CRC32=b1982df4 |
||||
nbproject/build-impl.xml.script.CRC32=5d3b3399 |
||||
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.49.1 |
||||
nbproject/build-impl.xml.stylesheet.CRC32=238281d1@2.50.1 |
||||
|
@ -0,0 +1,28 @@ |
||||
package com.jme3.gde.welcome; |
||||
|
||||
import java.awt.Color; |
||||
import java.awt.GradientPaint; |
||||
import java.awt.Graphics; |
||||
import java.awt.Graphics2D; |
||||
import javax.swing.JPanel; |
||||
|
||||
/** |
||||
* |
||||
* @author normenhansen |
||||
*/ |
||||
public class GradPanel extends JPanel { |
||||
|
||||
@Override |
||||
protected void paintComponent(Graphics grphcs) { |
||||
super.paintComponent(grphcs); |
||||
int w = getWidth(); |
||||
int h = getHeight(); |
||||
Graphics2D g2d = (Graphics2D) grphcs; |
||||
GradientPaint gp = new GradientPaint( |
||||
0, 0, Color.WHITE, |
||||
0, h, Color.LIGHT_GRAY); |
||||
|
||||
g2d.setPaint(gp); |
||||
g2d.fillRect(0, 0, w, h); |
||||
} |
||||
} |
@ -1,196 +0,0 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.gde.welcome; |
||||
|
||||
//import atmosphere.Planet;
|
||||
//import atmosphere.PlanetRendererState;
|
||||
import com.jme3.gde.core.assets.ProjectAssetManager; |
||||
import com.jme3.gde.core.scene.PreviewRequest; |
||||
import com.jme3.gde.core.scene.SceneApplication; |
||||
import com.jme3.gde.core.scene.SceneListener; |
||||
import com.jme3.gde.core.scene.SceneRequest; |
||||
import com.jme3.gde.core.sceneexplorer.nodes.NodeUtility; |
||||
import com.jme3.light.DirectionalLight; |
||||
import com.jme3.material.Material; |
||||
import com.jme3.math.ColorRGBA; |
||||
import com.jme3.math.Vector3f; |
||||
import com.jme3.niftygui.NiftyJmeDisplay; |
||||
import com.jme3.renderer.Caps; |
||||
import com.jme3.renderer.queue.RenderQueue.Bucket; |
||||
import com.jme3.renderer.queue.RenderQueue.ShadowMode; |
||||
import com.jme3.scene.Geometry; |
||||
import com.jme3.scene.Mesh; |
||||
import com.jme3.scene.Node; |
||||
import com.jme3.scene.Spatial; |
||||
import com.jme3.scene.shape.Sphere; |
||||
import com.jme3.texture.Image; |
||||
import com.jme3.texture.TextureCubeMap; |
||||
import de.lessvoid.nifty.Nifty; |
||||
import de.lessvoid.nifty.controls.checkbox.CheckboxControl; |
||||
import de.lessvoid.nifty.screen.Screen; |
||||
import de.lessvoid.nifty.screen.ScreenController; |
||||
import java.net.URL; |
||||
import java.util.concurrent.Callable; |
||||
import org.netbeans.api.javahelp.Help; |
||||
import org.openide.util.Exceptions; |
||||
import org.openide.util.HelpCtx; |
||||
import org.openide.util.Lookup; |
||||
import org.openide.util.NbPreferences; |
||||
|
||||
/** |
||||
* |
||||
* @author normenhansen |
||||
*/ |
||||
public class WelcomeScreen implements ScreenController { |
||||
|
||||
// PlanetRendererState planetView;
|
||||
SceneRequest request; |
||||
NiftyJmeDisplay niftyDisplay; |
||||
Nifty nifty; |
||||
Screen screen; |
||||
Spatial skyBox; |
||||
|
||||
public void startScreen() { |
||||
final Node rootNode = new Node("Welcome Screen"); |
||||
request = new SceneRequest(this, NodeUtility.createNode(rootNode), new ProjectAssetManager()); |
||||
request.setHelpCtx(new HelpCtx("com.jme3.gde.core.about")); |
||||
request.setWindowTitle("Welcome to jMonkeyEngine"); |
||||
final WelcomeScreen welcomeScreen = this; |
||||
final DirectionalLight dirLight = new DirectionalLight(); |
||||
dirLight.setDirection(new Vector3f(.1f, 1, .1f).normalizeLocal()); |
||||
dirLight.setColor(ColorRGBA.Gray); |
||||
// SceneApplication.getApplication().addSceneListener(new SceneListener() {
|
||||
//
|
||||
// @Override
|
||||
// public void sceneRequested(SceneRequest request) {
|
||||
// if (request.getRequester() == WelcomeScreen.this) {
|
||||
// //FIXME: planet location dont work?
|
||||
// if (SceneApplication.getApplication().getRenderer().getCaps().contains(Caps.OpenGL21)) {
|
||||
//// planetView = new PlanetRendererState(new Planet(100f, new Vector3f(0, 0, 0)), dirLight);
|
||||
//// SceneApplication.getApplication().getStateManager().attach(planetView);
|
||||
// }
|
||||
// SceneApplication.getApplication().getViewPort().getScenes().get(0).addLight(dirLight);
|
||||
// SceneApplication.getApplication().getCamera().setLocation(new Vector3f(0, 0, 400));
|
||||
// setupSkyBox();
|
||||
// niftyDisplay = new NiftyJmeDisplay(SceneApplication.getApplication().getAssetManager(),
|
||||
// SceneApplication.getApplication().getInputManager(),
|
||||
// SceneApplication.getApplication().getAudioRenderer(),
|
||||
// SceneApplication.getApplication().getGuiViewPort());
|
||||
// nifty = niftyDisplay.getNifty();
|
||||
// try {
|
||||
// nifty.fromXml("Interface/WelcomeScreen.xml", new URL("nbres:/Interface/WelcomeScreen.xml").openStream(), "start", welcomeScreen);
|
||||
// } catch (Exception ex) {
|
||||
// Exceptions.printStackTrace(ex);
|
||||
// }
|
||||
//
|
||||
// // attach the nifty display to the gui view port as a processor
|
||||
// SceneApplication.getApplication().getGuiViewPort().addProcessor(niftyDisplay);
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public boolean sceneClose(SceneRequest request) {
|
||||
// SceneApplication.getApplication().getViewPort().getScenes().get(0).removeLight(dirLight);
|
||||
// skyBox.removeFromParent();
|
||||
// SceneApplication.getApplication().getGuiViewPort().removeProcessor(niftyDisplay);
|
||||
// nifty.exit();
|
||||
//// if (planetView != null) {
|
||||
//// SceneApplication.getApplication().getStateManager().detach(planetView);
|
||||
//// }
|
||||
// SceneApplication.getApplication().removeSceneListener(this);
|
||||
// return true;
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public void previewRequested(PreviewRequest request) {
|
||||
// }
|
||||
// });
|
||||
// SceneApplication.getApplication().enqueue(new Callable<Object>() {
|
||||
//
|
||||
// @Override
|
||||
// public Object call() throws Exception {
|
||||
// SceneApplication.getApplication().requestScene(request);
|
||||
// return null;
|
||||
// }
|
||||
// });
|
||||
} |
||||
|
||||
private void setupSkyBox() { |
||||
Mesh sphere = new Sphere(32, 32, 10f); |
||||
sphere.setStatic(); |
||||
skyBox = new Geometry("SkyBox", sphere); |
||||
skyBox.setQueueBucket(Bucket.Sky); |
||||
skyBox.setShadowMode(ShadowMode.Off); |
||||
|
||||
Image cube = SceneApplication.getApplication().getAssetManager().loadTexture("Textures/blue-glow-1024.dds").getImage(); |
||||
TextureCubeMap cubemap = new TextureCubeMap(cube); |
||||
|
||||
Material mat = new Material(SceneApplication.getApplication().getAssetManager(), "Common/MatDefs/Misc/Sky.j3md"); |
||||
mat.setBoolean("SphereMap", false); |
||||
mat.setTexture("Texture", cubemap); |
||||
mat.setVector3("NormalScale", new Vector3f(1, 1, 1)); |
||||
skyBox.setMaterial(mat); |
||||
|
||||
((Node) SceneApplication.getApplication().getViewPort().getScenes().get(0)).attachChild(skyBox); |
||||
} |
||||
|
||||
public void setNoStartup() { |
||||
NbPreferences.forModule(Installer.class).put("NO_WELCOME_SCREEN", "true"); |
||||
} |
||||
|
||||
public void startUpdating() { |
||||
nifty.gotoScreen("updating"); |
||||
} |
||||
|
||||
public void startIntro() { |
||||
nifty.gotoScreen("intro"); |
||||
} |
||||
|
||||
public void startPlanet() { |
||||
nifty.gotoScreen("planet"); |
||||
} |
||||
|
||||
public void creatingProjects() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("sdk.project_creation")); |
||||
} |
||||
|
||||
public void importingModels() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("sdk.model_loader_and_viewer")); |
||||
} |
||||
|
||||
public void editingScenes() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("sdk.scene_composer")); |
||||
} |
||||
|
||||
public void editingCode() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("sdk.code_editor")); |
||||
} |
||||
|
||||
public void updatingJmp() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("com.jme3.gde.core.updating")); |
||||
} |
||||
|
||||
public void tutorials() { |
||||
Lookup.getDefault().lookup(Help.class).showHelp(new HelpCtx("jme3.beginner.hello_simpleapplication")); |
||||
} |
||||
|
||||
public void quit() { |
||||
if (screen.findNiftyControl("checkbox", CheckboxControl.class).isChecked()) { |
||||
setNoStartup(); |
||||
} |
||||
SceneApplication.getApplication().closeScene(request); |
||||
} |
||||
|
||||
public void bind(Nifty nifty, Screen screen) { |
||||
this.nifty = nifty; |
||||
this.screen = screen; |
||||
} |
||||
|
||||
public void onStartScreen() { |
||||
} |
||||
|
||||
public void onEndScreen() { |
||||
} |
||||
} |
@ -0,0 +1,137 @@ |
||||
<?xml version="1.0" encoding="UTF-8" ?> |
||||
|
||||
<Form version="1.5" maxVersion="1.8" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> |
||||
<Properties> |
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="ff" green="ff" id="white" palette="1" red="ff" type="palette"/> |
||||
</Property> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="1"/> |
||||
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> |
||||
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="true"/> |
||||
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="true"/> |
||||
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> |
||||
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> |
||||
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> |
||||
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> |
||||
</AuxValues> |
||||
|
||||
<Layout> |
||||
<DimensionLayout dim="0"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> |
||||
</Group> |
||||
</DimensionLayout> |
||||
<DimensionLayout dim="1"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> |
||||
</Group> |
||||
</DimensionLayout> |
||||
</Layout> |
||||
<SubComponents> |
||||
<Container class="javax.swing.JPanel" name="jPanel1"> |
||||
<Properties> |
||||
<Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/> |
||||
</Property> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="JavaCodeGenerator_CreateCodeCustom" type="java.lang.String" value="new GradPanel()"/> |
||||
</AuxValues> |
||||
|
||||
<Layout> |
||||
<DimensionLayout dim="0"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Group type="102" alignment="0" attributes="0"> |
||||
<EmptySpace max="-2" attributes="0"/> |
||||
<Component id="jScrollPane2" max="32767" attributes="0"/> |
||||
<EmptySpace max="-2" attributes="0"/> |
||||
<Component id="jScrollPane3" min="-2" pref="230" max="-2" attributes="0"/> |
||||
<EmptySpace max="-2" attributes="0"/> |
||||
</Group> |
||||
</Group> |
||||
</DimensionLayout> |
||||
<DimensionLayout dim="1"> |
||||
<Group type="103" groupAlignment="0" attributes="0"> |
||||
<Group type="102" alignment="1" attributes="0"> |
||||
<EmptySpace max="-2" attributes="0"/> |
||||
<Group type="103" groupAlignment="1" attributes="0"> |
||||
<Component id="jScrollPane2" max="32767" attributes="0"/> |
||||
<Component id="jScrollPane3" pref="436" max="32767" attributes="0"/> |
||||
</Group> |
||||
<EmptySpace max="-2" attributes="0"/> |
||||
</Group> |
||||
</Group> |
||||
</DimensionLayout> |
||||
</Layout> |
||||
<SubComponents> |
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane3"> |
||||
<Properties> |
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
||||
<Border info="null"/> |
||||
</Property> |
||||
<Property name="opaque" type="boolean" value="false"/> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> |
||||
</AuxValues> |
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> |
||||
<SubComponents> |
||||
<Component class="javax.swing.JTextPane" name="jTextPane1"> |
||||
<Properties> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> |
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo"> |
||||
<TitledBorder title="Latest jMonkeyEngine News"> |
||||
<ResourceString PropertyName="titleX" bundle="com/jme3/gde/welcome/Bundle.properties" key="WelcomeScreenTopComponent.jTextPane1.border.title" replaceFormat="org.openide.util.NbBundle.getMessage({sourceFileName}.class, "{key}")"/> |
||||
</TitledBorder> |
||||
</Border> |
||||
</Property> |
||||
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> |
||||
<Font name="Lucida Grande" size="12" style="2"/> |
||||
</Property> |
||||
<Property name="foreground" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="cc" green="0" red="0" type="rgb"/> |
||||
</Property> |
||||
<Property name="caret" type="javax.swing.text.Caret" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> |
||||
<Connection code="null" type="code"/> |
||||
</Property> |
||||
<Property name="caretColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/> |
||||
</Property> |
||||
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="cc" green="0" red="0" type="rgb"/> |
||||
</Property> |
||||
<Property name="opaque" type="boolean" value="false"/> |
||||
</Properties> |
||||
</Component> |
||||
</SubComponents> |
||||
</Container> |
||||
<Container class="javax.swing.JScrollPane" name="jScrollPane2"> |
||||
<Properties> |
||||
<Property name="opaque" type="boolean" value="false"/> |
||||
</Properties> |
||||
<AuxValues> |
||||
<AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> |
||||
</AuxValues> |
||||
|
||||
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> |
||||
<SubComponents> |
||||
<Component class="javax.swing.JEditorPane" name="jEditorPane1"> |
||||
<Properties> |
||||
<Property name="editable" type="boolean" value="false"/> |
||||
<Property name="caretColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> |
||||
<Color blue="ff" green="ff" red="ff" type="rgb"/> |
||||
</Property> |
||||
<Property name="opaque" type="boolean" value="false"/> |
||||
</Properties> |
||||
</Component> |
||||
</SubComponents> |
||||
</Container> |
||||
</SubComponents> |
||||
</Container> |
||||
</SubComponents> |
||||
</Form> |
@ -0,0 +1,186 @@ |
||||
/* |
||||
* To change this template, choose Tools | Templates |
||||
* and open the template in the editor. |
||||
*/ |
||||
package com.jme3.gde.welcome; |
||||
|
||||
import com.jme3.gde.welcome.rss.RssFeedParser; |
||||
import java.io.IOException; |
||||
import java.net.URL; |
||||
import javax.swing.event.HyperlinkEvent; |
||||
import javax.swing.event.HyperlinkListener; |
||||
import javax.swing.text.html.StyleSheet; |
||||
import org.netbeans.api.settings.ConvertAsProperties; |
||||
import org.openide.awt.ActionID; |
||||
import org.openide.awt.ActionReference; |
||||
import org.openide.awt.HtmlBrowser.URLDisplayer; |
||||
import org.openide.util.Exceptions; |
||||
import org.openide.windows.TopComponent; |
||||
import org.openide.util.NbBundle.Messages; |
||||
|
||||
/** |
||||
* Top component which displays something. |
||||
*/ |
||||
@ConvertAsProperties( |
||||
dtd = "-//com.jme3.gde.welcome//WelcomeScreen//EN", |
||||
autostore = false) |
||||
@TopComponent.Description( |
||||
preferredID = "WelcomeScreenTopComponent", |
||||
//iconBase="SET/PATH/TO/ICON/HERE",
|
||||
persistenceType = TopComponent.PERSISTENCE_ALWAYS) |
||||
@TopComponent.Registration(mode = "editor", openAtStartup = true) |
||||
@ActionID(category = "Window", id = "com.jme3.gde.welcome.WelcomeScreenTopComponent") |
||||
@ActionReference(path = "Menu/Window" /*, position = 333 */) |
||||
@TopComponent.OpenActionRegistration( |
||||
displayName = "#CTL_WelcomeScreenAction", |
||||
preferredID = "WelcomeScreenTopComponent") |
||||
@Messages({ |
||||
"CTL_WelcomeScreenAction=WelcomeScreen", |
||||
"CTL_WelcomeScreenTopComponent=WelcomeScreen Window", |
||||
"HINT_WelcomeScreenTopComponent=This is a WelcomeScreen window" |
||||
}) |
||||
public final class WelcomeScreenTopComponent extends TopComponent implements HyperlinkListener { |
||||
|
||||
private final RssFeedParser parser = new RssFeedParser("http://jmonkeyengine.org/feed/rdf/");//"http://www.chip.de/rss/rss_tests.xml");
|
||||
|
||||
public WelcomeScreenTopComponent() { |
||||
initComponents(); |
||||
jScrollPane2.setOpaque(false); |
||||
jScrollPane2.getViewport().setOpaque(false); |
||||
jScrollPane3.setOpaque(false); |
||||
jScrollPane3.getViewport().setOpaque(false); |
||||
|
||||
setName(Bundle.CTL_WelcomeScreenTopComponent()); |
||||
setToolTipText(Bundle.HINT_WelcomeScreenTopComponent()); |
||||
|
||||
jTextPane1.setEditorKit(parser.getEditorKit()); |
||||
jTextPane1.setDocument(parser.getDocument()); |
||||
jTextPane1.addHyperlinkListener(this); |
||||
// jEditorPane2.addHyperlinkListener(this);
|
||||
|
||||
// StyleSheet sheet = new StyleSheet();
|
||||
// sheet.addRule("background-color: transparent;");
|
||||
// parser.getEditorKit().setStyleSheet(sheet);
|
||||
|
||||
try { |
||||
jEditorPane1.setPage(new URL("http://jmonkeyengine.org/wiki/doku.php/sdk:welcome?do=export_xhtmlbody")); |
||||
// jEditorPane1.setPage(new URL("nbres:/com/jme3/gde/core/docs/core-about.html"));
|
||||
} catch (IOException ex) { |
||||
try { |
||||
jEditorPane1.setPage(new URL("nbres:/com/jme3/gde/core/docs/core-about.html")); |
||||
} catch (IOException ex1) { |
||||
Exceptions.printStackTrace(ex1); |
||||
} |
||||
} |
||||
// jEditorPane2.setBackground(new Color(0, 0, 0, 128));
|
||||
// jTextPane1.setBackground(new Color(0, 0, 0, 128));
|
||||
parser.updateFeed(); |
||||
} |
||||
|
||||
/** |
||||
* 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 |
||||
* regenerated by the Form Editor. |
||||
*/ |
||||
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
|
||||
private void initComponents() { |
||||
|
||||
jPanel1 = new GradPanel(); |
||||
jScrollPane3 = new javax.swing.JScrollPane(); |
||||
jTextPane1 = new javax.swing.JTextPane(); |
||||
jScrollPane2 = new javax.swing.JScrollPane(); |
||||
jEditorPane1 = new javax.swing.JEditorPane(); |
||||
|
||||
setBackground(java.awt.Color.white); |
||||
|
||||
jPanel1.setBackground(new java.awt.Color(255, 255, 255)); |
||||
|
||||
jScrollPane3.setBorder(null); |
||||
jScrollPane3.setOpaque(false); |
||||
|
||||
jTextPane1.setEditable(false); |
||||
jTextPane1.setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(WelcomeScreenTopComponent.class, "WelcomeScreenTopComponent.jTextPane1.border.title"))); // NOI18N
|
||||
jTextPane1.setFont(new java.awt.Font("Lucida Grande", 2, 12)); // NOI18N
|
||||
jTextPane1.setForeground(new java.awt.Color(0, 0, 204)); |
||||
jTextPane1.setCaret(null); |
||||
jTextPane1.setCaretColor(new java.awt.Color(255, 255, 255)); |
||||
jTextPane1.setDisabledTextColor(new java.awt.Color(0, 0, 204)); |
||||
jTextPane1.setOpaque(false); |
||||
jScrollPane3.setViewportView(jTextPane1); |
||||
|
||||
jScrollPane2.setOpaque(false); |
||||
|
||||
jEditorPane1.setEditable(false); |
||||
jEditorPane1.setCaretColor(new java.awt.Color(255, 255, 255)); |
||||
jEditorPane1.setOpaque(false); |
||||
jScrollPane2.setViewportView(jEditorPane1); |
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); |
||||
jPanel1.setLayout(jPanel1Layout); |
||||
jPanel1Layout.setHorizontalGroup( |
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||
.addGroup(jPanel1Layout.createSequentialGroup() |
||||
.addContainerGap() |
||||
.addComponent(jScrollPane2) |
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
||||
.addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 230, javax.swing.GroupLayout.PREFERRED_SIZE) |
||||
.addContainerGap()) |
||||
); |
||||
jPanel1Layout.setVerticalGroup( |
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() |
||||
.addContainerGap() |
||||
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) |
||||
.addComponent(jScrollPane2) |
||||
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 436, Short.MAX_VALUE)) |
||||
.addContainerGap()) |
||||
); |
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
||||
this.setLayout(layout); |
||||
layout.setHorizontalGroup( |
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
||||
); |
||||
layout.setVerticalGroup( |
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
||||
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
||||
); |
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JEditorPane jEditorPane1; |
||||
private javax.swing.JPanel jPanel1; |
||||
private javax.swing.JScrollPane jScrollPane2; |
||||
private javax.swing.JScrollPane jScrollPane3; |
||||
private javax.swing.JTextPane jTextPane1; |
||||
// End of variables declaration//GEN-END:variables
|
||||
|
||||
@Override |
||||
public void componentOpened() { |
||||
// TODO add custom code on component opening
|
||||
} |
||||
|
||||
@Override |
||||
public void componentClosed() { |
||||
// TODO add custom code on component closing
|
||||
} |
||||
|
||||
void writeProperties(java.util.Properties p) { |
||||
// better to version settings since initial version as advocated at
|
||||
// http://wiki.apidesign.org/wiki/PropertyFiles
|
||||
p.setProperty("version", "1.0"); |
||||
// TODO store your settings
|
||||
} |
||||
|
||||
void readProperties(java.util.Properties p) { |
||||
String version = p.getProperty("version"); |
||||
// TODO read your settings according to their version
|
||||
} |
||||
|
||||
public void hyperlinkUpdate(HyperlinkEvent he) { |
||||
if (he.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { |
||||
URLDisplayer.getDefault().showURL(he.getURL()); |
||||
} |
||||
} |
||||
} |
@ -0,0 +1,64 @@ |
||||
package com.jme3.gde.welcome.rss; |
||||
|
||||
import java.util.ArrayList; |
||||
import java.util.List; |
||||
|
||||
/** |
||||
* |
||||
* @author Lars Vogel |
||||
*/ |
||||
public class Feed { |
||||
|
||||
final String title; |
||||
final String link; |
||||
final String description; |
||||
final String language; |
||||
final String copyright; |
||||
final String pubDate; |
||||
final List<FeedMessage> entries = new ArrayList<FeedMessage>(); |
||||
|
||||
public Feed(String title, String link, String description, String language, |
||||
String copyright, String pubDate) { |
||||
this.title = title; |
||||
this.link = link; |
||||
this.description = description; |
||||
this.language = language; |
||||
this.copyright = copyright; |
||||
this.pubDate = pubDate; |
||||
} |
||||
|
||||
public List<FeedMessage> getMessages() { |
||||
return entries; |
||||
} |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public String getLink() { |
||||
return link; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public String getLanguage() { |
||||
return language; |
||||
} |
||||
|
||||
public String getCopyright() { |
||||
return copyright; |
||||
} |
||||
|
||||
public String getPubDate() { |
||||
return pubDate; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "Feed [copyright=" + copyright + ", description=" + description |
||||
+ ", language=" + language + ", link=" + link + ", pubDate=" |
||||
+ pubDate + ", title=" + title + "]"; |
||||
} |
||||
} |
@ -0,0 +1,61 @@ |
||||
package com.jme3.gde.welcome.rss; |
||||
|
||||
/** |
||||
* |
||||
* @author Lars Vogel |
||||
*/ |
||||
public class FeedMessage { |
||||
|
||||
String title; |
||||
String description; |
||||
String link; |
||||
String author; |
||||
String guid; |
||||
|
||||
public String getTitle() { |
||||
return title; |
||||
} |
||||
|
||||
public void setTitle(String title) { |
||||
this.title = title; |
||||
} |
||||
|
||||
public String getDescription() { |
||||
return description; |
||||
} |
||||
|
||||
public void setDescription(String description) { |
||||
this.description = description; |
||||
} |
||||
|
||||
public String getLink() { |
||||
return link; |
||||
} |
||||
|
||||
public void setLink(String link) { |
||||
this.link = link; |
||||
} |
||||
|
||||
public String getAuthor() { |
||||
return author; |
||||
} |
||||
|
||||
public void setAuthor(String author) { |
||||
this.author = author; |
||||
} |
||||
|
||||
public String getGuid() { |
||||
return guid; |
||||
} |
||||
|
||||
public void setGuid(String guid) { |
||||
this.guid = guid; |
||||
} |
||||
|
||||
@Override |
||||
public String toString() { |
||||
return "FeedMessage [title=" + title + ", description=" + description |
||||
+ ", link=" + link + ", author=" + author + ", guid=" + guid |
||||
+ "]"; |
||||
} |
||||
} |
@ -0,0 +1,219 @@ |
||||
package com.jme3.gde.welcome.rss; |
||||
|
||||
/** |
||||
* |
||||
* @author Lars Vogel, normenhansen |
||||
*/ |
||||
import java.io.IOException; |
||||
import java.io.InputStream; |
||||
import java.net.URL; |
||||
import java.util.List; |
||||
import javax.swing.text.BadLocationException; |
||||
import javax.swing.text.Document; |
||||
import javax.swing.text.html.HTML; |
||||
import javax.swing.text.html.HTMLDocument; |
||||
import javax.swing.text.html.HTMLEditorKit; |
||||
import javax.xml.stream.XMLEventReader; |
||||
import javax.xml.stream.XMLInputFactory; |
||||
import javax.xml.stream.XMLStreamException; |
||||
import javax.xml.stream.events.XMLEvent; |
||||
import org.openide.util.Exceptions; |
||||
|
||||
public class RssFeedParser { |
||||
|
||||
static final String TITLE = "title"; |
||||
static final String DESCRIPTION = "description"; |
||||
static final String CHANNEL = "channel"; |
||||
static final String LANGUAGE = "language"; |
||||
static final String COPYRIGHT = "copyright"; |
||||
static final String LINK = "link"; |
||||
static final String AUTHOR = "author"; |
||||
static final String ITEM = "item"; |
||||
static final String PUB_DATE = "pubDate"; |
||||
static final String GUID = "guid"; |
||||
private final URL url; |
||||
private final HTMLEditorKit ekit; |
||||
private final HTMLDocument doc; |
||||
|
||||
public RssFeedParser(String feedUrl) { |
||||
try { |
||||
this.url = new URL(feedUrl); |
||||
ekit = new HTMLEditorKit(); |
||||
doc = new HTMLDocument(); |
||||
} catch (Exception e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
|
||||
public HTMLDocument getDocument() { |
||||
return doc; |
||||
} |
||||
|
||||
public HTMLEditorKit getEditorKit() { |
||||
return ekit; |
||||
} |
||||
|
||||
public void updateFeed() { |
||||
Thread t = new Thread(new Runnable() { |
||||
public void run() { |
||||
try { |
||||
final Feed feed = readFeed(); |
||||
java.awt.EventQueue.invokeLater(new Runnable() { |
||||
public void run() { |
||||
List<FeedMessage> msgs = feed.getMessages(); |
||||
try { |
||||
for (FeedMessage feedMessage : msgs) { |
||||
//AttributeSet set = new SimpleAttributeSet();
|
||||
ekit.insertHTML(doc, doc.getLength(), |
||||
"<h3><a href='" |
||||
+ feedMessage.getLink() |
||||
+ "'>" |
||||
+ feedMessage.getTitle() |
||||
+ "</a>", |
||||
0, |
||||
0, |
||||
HTML.Tag.H3); |
||||
// ekit.insertHTML(doc, doc.getLength(),
|
||||
// "<p>"
|
||||
// + feedMessage.getDescription()
|
||||
// + "",
|
||||
// 0,
|
||||
// 0,
|
||||
// HTML.Tag.P);
|
||||
ekit.insertHTML(doc, doc.getLength(), |
||||
"<br/>", |
||||
0, |
||||
0, |
||||
null); |
||||
} |
||||
doc.insertString(0, "", null); |
||||
} catch (BadLocationException ex) { |
||||
Exceptions.printStackTrace(ex); |
||||
} catch (IOException ex) { |
||||
Exceptions.printStackTrace(ex); |
||||
} |
||||
} |
||||
}); |
||||
} catch (Exception ex) { |
||||
Exceptions.printStackTrace(ex); |
||||
} |
||||
} |
||||
}); |
||||
t.start(); |
||||
} |
||||
|
||||
@SuppressWarnings("null") |
||||
public Feed readFeed() { |
||||
Feed feed = null; |
||||
try { |
||||
|
||||
boolean isFeedHeader = true; |
||||
// Set header values intial to the empty string
|
||||
String description = ""; |
||||
String title = ""; |
||||
String link = ""; |
||||
String language = ""; |
||||
String copyright = ""; |
||||
String author = ""; |
||||
String pubdate = ""; |
||||
String guid = ""; |
||||
|
||||
// First create a new XMLInputFactory
|
||||
XMLInputFactory inputFactory = XMLInputFactory.newInstance(); |
||||
// Setup a new eventReader
|
||||
InputStream in = read(); |
||||
XMLEventReader eventReader = inputFactory.createXMLEventReader(in); |
||||
// Read the XML document
|
||||
while (eventReader.hasNext()) { |
||||
|
||||
XMLEvent event = eventReader.nextEvent(); |
||||
|
||||
if (event.isStartElement()) { |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(ITEM)) { |
||||
if (isFeedHeader) { |
||||
isFeedHeader = false; |
||||
feed = new Feed(title, link, description, language, |
||||
copyright, pubdate); |
||||
} |
||||
event = eventReader.nextEvent(); |
||||
continue; |
||||
} |
||||
|
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(TITLE)) { |
||||
event = eventReader.nextEvent(); |
||||
title = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(DESCRIPTION)) { |
||||
event = eventReader.nextEvent(); |
||||
description = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
|
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(LINK)) { |
||||
event = eventReader.nextEvent(); |
||||
//System.out.println("Teh hack: " + event.toString() + event.getClass());
|
||||
Object chars = event.asCharacters(); |
||||
if (chars instanceof javax.xml.stream.events.Characters) { |
||||
javax.xml.stream.events.Characters jchars = (javax.xml.stream.events.Characters) chars; |
||||
link = jchars.getData(); |
||||
} else { |
||||
link = event.asCharacters().getData(); |
||||
} |
||||
continue; |
||||
} |
||||
|
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(GUID)) { |
||||
event = eventReader.nextEvent(); |
||||
guid = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(LANGUAGE)) { |
||||
event = eventReader.nextEvent(); |
||||
language = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(AUTHOR)) { |
||||
event = eventReader.nextEvent(); |
||||
author = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(PUB_DATE)) { |
||||
event = eventReader.nextEvent(); |
||||
pubdate = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
if (event.asStartElement().getName().getLocalPart() != null && event.asStartElement().getName().getLocalPart().equals(COPYRIGHT)) { |
||||
event = eventReader.nextEvent(); |
||||
copyright = event.asCharacters().getData(); |
||||
continue; |
||||
} |
||||
} else if (event.isEndElement()) { |
||||
if (event.asEndElement().getName().getLocalPart() != null && event.asEndElement().getName().getLocalPart().equals(ITEM)) { |
||||
FeedMessage message = new FeedMessage(); |
||||
message.setAuthor(author); |
||||
message.setDescription(description); |
||||
message.setGuid(guid); |
||||
message.setLink(link); |
||||
message.setTitle(title); |
||||
feed.getMessages().add(message); |
||||
event = eventReader.nextEvent(); |
||||
continue; |
||||
} |
||||
} |
||||
} |
||||
} catch (XMLStreamException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
return feed; |
||||
|
||||
} |
||||
|
||||
private InputStream read() { |
||||
try { |
||||
return url.openStream(); |
||||
} catch (IOException e) { |
||||
throw new RuntimeException(e); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue