introduction tour
authorplaa <plaa@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 24 Dec 2011 18:03:56 +0000 (18:03 +0000)
committerplaa <plaa@180e2498-e6e9-4542-8430-84ac67f01cd8>
Sat, 24 Dec 2011 18:03:56 +0000 (18:03 +0000)
git-svn-id: https://openrocket.svn.sourceforge.net/svnroot/openrocket/trunk@245 180e2498-e6e9-4542-8430-84ac67f01cd8

38 files changed:
datafiles-src/tours/convert-images.sh [new file with mode: 0755]
datafiles-src/tours/introduction/advanced_features.xcf.gz [new file with mode: 0644]
datafiles-src/tours/introduction/flight_simulations.xcf.gz [new file with mode: 0644]
datafiles-src/tours/introduction/logo-MANUAL.xcf.gz [new file with mode: 0644]
datafiles-src/tours/introduction/main_window.png [new file with mode: 0644]
datafiles-src/tours/introduction/main_window_bottom.xcf.gz [new file with mode: 0644]
datafiles-src/tours/introduction/main_window_top.xcf.gz [new file with mode: 0644]
datafiles/tours/designed_rocket.png [deleted file]
datafiles/tours/introduction/advanced_features.jpg [new file with mode: 0644]
datafiles/tours/introduction/flight_simulations.jpg [new file with mode: 0644]
datafiles/tours/introduction/introduction.tour [new file with mode: 0644]
datafiles/tours/introduction/logo.png [new file with mode: 0644]
datafiles/tours/introduction/main_window.jpg [new file with mode: 0644]
datafiles/tours/introduction/main_window_bottom.jpg [new file with mode: 0644]
datafiles/tours/introduction/main_window_top.jpg [new file with mode: 0644]
datafiles/tours/introduction/simulation_edit.png [new file with mode: 0644]
datafiles/tours/left_design.png [deleted file]
datafiles/tours/main_window.png [deleted file]
datafiles/tours/rocket_configuration.png [deleted file]
datafiles/tours/style.css
datafiles/tours/test.tour [deleted file]
datafiles/tours/test1/left_design.png [new file with mode: 0644]
datafiles/tours/test1/main_window.png [new file with mode: 0644]
datafiles/tours/test1/test.tour [new file with mode: 0644]
datafiles/tours/test1/test_de.tour [new file with mode: 0644]
datafiles/tours/test2.tour [deleted file]
datafiles/tours/test2/left_design.png [new file with mode: 0644]
datafiles/tours/test2/main_window.png [new file with mode: 0644]
datafiles/tours/test2/test2.tour [new file with mode: 0644]
datafiles/tours/test_de.tour [deleted file]
datafiles/tours/tours.txt
src/net/sf/openrocket/gui/help/tours/GuidedTourSelectionDialog.java
src/net/sf/openrocket/gui/help/tours/Slide.java
src/net/sf/openrocket/gui/help/tours/SlideSetManager.java
src/net/sf/openrocket/gui/help/tours/SlideShowComponent.java
src/net/sf/openrocket/gui/help/tours/SlideShowDialog.java
src/net/sf/openrocket/gui/help/tours/SlideShowLinkListener.java [new file with mode: 0644]
src/net/sf/openrocket/gui/util/GUIUtil.java

diff --git a/datafiles-src/tours/convert-images.sh b/datafiles-src/tours/convert-images.sh
new file mode 100755 (executable)
index 0000000..f9fa53c
--- /dev/null
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+#
+# A script to batch-convert all source image files into suitable
+# slideset image files.  It converts all *.png, *.jpg and *.xcf.gz
+# files into the suitably sized jpg images in the datafiles directory.
+#
+
+DEST=../../datafiles/tours
+
+CONVERSION="-background #ececec -flatten -geometry 600x400 -quality 85"
+
+
+# Convert all xcf files
+find -iname "*.xcf.gz" | grep -v MANUAL | while read FILE; do
+
+    echo Converting $FILE
+    BASE="$(echo $FILE | sed 's/\.xcf\.gz$//')"
+    xcf2png "$FILE" | convert $CONVERSION - $DEST/$BASE.jpg
+
+done
+
+# Convert all png and jpg files
+find -iname "*.png" -o -iname "*.jpg" | grep -v MANUAL | while read FILE; do 
+
+    echo Converting $FILE
+    BASE="$(echo $FILE | sed 's/\.png$//' | sed 's/\.jpg$//')"
+    convert $CONVERSION $FILE $DEST/$BASE.jpg
+
+done
\ No newline at end of file
diff --git a/datafiles-src/tours/introduction/advanced_features.xcf.gz b/datafiles-src/tours/introduction/advanced_features.xcf.gz
new file mode 100644 (file)
index 0000000..5c687d3
Binary files /dev/null and b/datafiles-src/tours/introduction/advanced_features.xcf.gz differ
diff --git a/datafiles-src/tours/introduction/flight_simulations.xcf.gz b/datafiles-src/tours/introduction/flight_simulations.xcf.gz
new file mode 100644 (file)
index 0000000..e3fb8ad
Binary files /dev/null and b/datafiles-src/tours/introduction/flight_simulations.xcf.gz differ
diff --git a/datafiles-src/tours/introduction/logo-MANUAL.xcf.gz b/datafiles-src/tours/introduction/logo-MANUAL.xcf.gz
new file mode 100644 (file)
index 0000000..910c4f3
Binary files /dev/null and b/datafiles-src/tours/introduction/logo-MANUAL.xcf.gz differ
diff --git a/datafiles-src/tours/introduction/main_window.png b/datafiles-src/tours/introduction/main_window.png
new file mode 100644 (file)
index 0000000..8a217a9
Binary files /dev/null and b/datafiles-src/tours/introduction/main_window.png differ
diff --git a/datafiles-src/tours/introduction/main_window_bottom.xcf.gz b/datafiles-src/tours/introduction/main_window_bottom.xcf.gz
new file mode 100644 (file)
index 0000000..3a2f23e
Binary files /dev/null and b/datafiles-src/tours/introduction/main_window_bottom.xcf.gz differ
diff --git a/datafiles-src/tours/introduction/main_window_top.xcf.gz b/datafiles-src/tours/introduction/main_window_top.xcf.gz
new file mode 100644 (file)
index 0000000..ba08206
Binary files /dev/null and b/datafiles-src/tours/introduction/main_window_top.xcf.gz differ
diff --git a/datafiles/tours/designed_rocket.png b/datafiles/tours/designed_rocket.png
deleted file mode 100644 (file)
index 0accfa2..0000000
Binary files a/datafiles/tours/designed_rocket.png and /dev/null differ
diff --git a/datafiles/tours/introduction/advanced_features.jpg b/datafiles/tours/introduction/advanced_features.jpg
new file mode 100644 (file)
index 0000000..24cc9b1
Binary files /dev/null and b/datafiles/tours/introduction/advanced_features.jpg differ
diff --git a/datafiles/tours/introduction/flight_simulations.jpg b/datafiles/tours/introduction/flight_simulations.jpg
new file mode 100644 (file)
index 0000000..0d112db
Binary files /dev/null and b/datafiles/tours/introduction/flight_simulations.jpg differ
diff --git a/datafiles/tours/introduction/introduction.tour b/datafiles/tours/introduction/introduction.tour
new file mode 100644 (file)
index 0000000..48386f3
--- /dev/null
@@ -0,0 +1,84 @@
+
+Introduction
+
+<p>This first tour provides a quick overview of OpenRocket screens and
+features.
+
+
+[logo.png]
+# TODO: Add "Welcome to OpenRocket" text to image.
+
+<p><b>OpenRocket</b> is a versatile application for designing,
+simulating and optimizing model rockets.  This first tour provides an
+overview of the OpenRocket screens and features.
+
+<p>You can browse through the tour using the <b>Next</b> and
+<b>Previous</b> buttons, or using the <em>left</em> and <em>right
+arrows</em> on your keyboard.
+
+
+[none]
+
+<p>This is the startup screen from which you can create a new rocket
+design or open existing designs.
+
+<p>For this tour, let's open an example design called <em>A simple model
+rocket</em>.
+
+
+[main_window.jpg]
+
+<p>This is the main screen of OpenRocket.  It is divided horizontally
+into two parts:  the rocket design / flight simulation section and the
+rocket design view.
+
+
+[main_window_top.jpg]
+
+<p>On the top left is the component tree of the rocket design.
+It displays which components are attached to what components.
+
+<p>Next to it are buttons which allow adding new components to the
+rocket.
+
+
+[main_window_bottom.jpg]
+
+<p>The bottom half of the window contains a diagram of the current
+rocket design.
+
+<p>The different viewing options are described in detail in the
+<a href="FIXME">Viewing options</a> tour. 
+
+
+[flight_simulations.jpg]
+
+<p>When you select the <b>Flight simulations</b> tab, the top part of
+the window changes to show the simulations that have been defined for
+the rocket.
+
+<p>You can define various simulations with different motor
+configurations and differing launch conditions, such as wind and
+launch rod angle.
+
+
+[simulation_edit.png]
+
+<p>By double-clicking on a simulation you open the <em>Simulation edit
+dialog</em>.  On the first two tabs you can define simulation options,
+on the last two tabs you can plot or export the results.
+
+<p>Simulating a rocket is described in detail in the
+<a href="FIXME">Simulating a flight</a> tour.
+
+
+[advanced_features.jpg]
+
+<p>Other advanced features include component analysis and automatic
+design optimization, which are covered by separate tours.
+
+<p>Next you can take a tour on <a href="FIXME">Creating a rocket
+design</a>, browse other tours or start experimenting with the
+software.
+
+
diff --git a/datafiles/tours/introduction/logo.png b/datafiles/tours/introduction/logo.png
new file mode 100644 (file)
index 0000000..9946c41
Binary files /dev/null and b/datafiles/tours/introduction/logo.png differ
diff --git a/datafiles/tours/introduction/main_window.jpg b/datafiles/tours/introduction/main_window.jpg
new file mode 100644 (file)
index 0000000..8f6713b
Binary files /dev/null and b/datafiles/tours/introduction/main_window.jpg differ
diff --git a/datafiles/tours/introduction/main_window_bottom.jpg b/datafiles/tours/introduction/main_window_bottom.jpg
new file mode 100644 (file)
index 0000000..1a38592
Binary files /dev/null and b/datafiles/tours/introduction/main_window_bottom.jpg differ
diff --git a/datafiles/tours/introduction/main_window_top.jpg b/datafiles/tours/introduction/main_window_top.jpg
new file mode 100644 (file)
index 0000000..aef8964
Binary files /dev/null and b/datafiles/tours/introduction/main_window_top.jpg differ
diff --git a/datafiles/tours/introduction/simulation_edit.png b/datafiles/tours/introduction/simulation_edit.png
new file mode 100644 (file)
index 0000000..552a414
Binary files /dev/null and b/datafiles/tours/introduction/simulation_edit.png differ
diff --git a/datafiles/tours/left_design.png b/datafiles/tours/left_design.png
deleted file mode 100644 (file)
index 4c496d5..0000000
Binary files a/datafiles/tours/left_design.png and /dev/null differ
diff --git a/datafiles/tours/main_window.png b/datafiles/tours/main_window.png
deleted file mode 100644 (file)
index d6f7f70..0000000
Binary files a/datafiles/tours/main_window.png and /dev/null differ
diff --git a/datafiles/tours/rocket_configuration.png b/datafiles/tours/rocket_configuration.png
deleted file mode 100644 (file)
index e2ddd7e..0000000
Binary files a/datafiles/tours/rocket_configuration.png and /dev/null differ
index 4aa6f5506a581a4186fcd37f2c5bcfdeae14023e..59c62b8e153480c41be16948421a5a78f0a45e64 100644 (file)
@@ -11,10 +11,14 @@ div.base {
 }
 
 p {
-  margin: 0 0 5px;
+  margin: 0 0 8px;
 }
 
 a {
   color: #0000dd;
   text-decoration: underline;
 }
+
+em {
+  font-style: italics;
+}
\ No newline at end of file
diff --git a/datafiles/tours/test.tour b/datafiles/tours/test.tour
deleted file mode 100644 (file)
index 978771c..0000000
+++ /dev/null
@@ -1,19 +0,0 @@
-
-# Foo bar
-
-First test tour
-
-This is the <i>description</i>.
-
-
-[left_design.png]
-
-<p>This is the first slide &mdash; the left_design file.
-
-<p>It's nifty. It can also contain <a href="foobar">links</a> (though they don't work yet).
-
-
-
-[main_window.png]
-This is the next slide (and the last).
-
diff --git a/datafiles/tours/test1/left_design.png b/datafiles/tours/test1/left_design.png
new file mode 100644 (file)
index 0000000..4c496d5
Binary files /dev/null and b/datafiles/tours/test1/left_design.png differ
diff --git a/datafiles/tours/test1/main_window.png b/datafiles/tours/test1/main_window.png
new file mode 100644 (file)
index 0000000..d6f7f70
Binary files /dev/null and b/datafiles/tours/test1/main_window.png differ
diff --git a/datafiles/tours/test1/test.tour b/datafiles/tours/test1/test.tour
new file mode 100644 (file)
index 0000000..f5a278b
--- /dev/null
@@ -0,0 +1,20 @@
+
+# Foo bar
+
+First test tour
+
+This is the <i>description</i>.
+
+
+[left_design.png]
+
+<p>This is the first slide &mdash; the left_design file.
+
+<p>It's nifty. It can also contain <a href="foobar">links</a> (though they don't work yet).
+<p>Tour2: <a href="test2/test2.tour">Test2</a>
+<p>Hyperlink: <a href="http://www.google.com">google</a>
+
+
+[main_window.png]
+This is the next slide (and the last).
+
diff --git a/datafiles/tours/test1/test_de.tour b/datafiles/tours/test1/test_de.tour
new file mode 100644 (file)
index 0000000..615dd84
--- /dev/null
@@ -0,0 +1,6 @@
+
+Das test Tour
+
+[left_design.png]
+
+Das is ein test tour.
diff --git a/datafiles/tours/test2.tour b/datafiles/tours/test2.tour
deleted file mode 100644 (file)
index f8daabd..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-Another test tour
-
-<p>This is the second tour.
-<p>Comprende?
-
-
-[left_design.png]
-
-This is the second tour.
-
-
-[main_window.png]
-
-This is the second/last slide.
-
diff --git a/datafiles/tours/test2/left_design.png b/datafiles/tours/test2/left_design.png
new file mode 100644 (file)
index 0000000..4c496d5
Binary files /dev/null and b/datafiles/tours/test2/left_design.png differ
diff --git a/datafiles/tours/test2/main_window.png b/datafiles/tours/test2/main_window.png
new file mode 100644 (file)
index 0000000..d6f7f70
Binary files /dev/null and b/datafiles/tours/test2/main_window.png differ
diff --git a/datafiles/tours/test2/test2.tour b/datafiles/tours/test2/test2.tour
new file mode 100644 (file)
index 0000000..f8daabd
--- /dev/null
@@ -0,0 +1,15 @@
+Another test tour
+
+<p>This is the second tour.
+<p>Comprende?
+
+
+[left_design.png]
+
+This is the second tour.
+
+
+[main_window.png]
+
+This is the second/last slide.
+
diff --git a/datafiles/tours/test_de.tour b/datafiles/tours/test_de.tour
deleted file mode 100644 (file)
index 615dd84..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-
-Das test Tour
-
-[left_design.png]
-
-Das is ein test tour.
index 79242c0793df2a1de4b71523e9af0ffd02266c9d..200e9d111e309c0fba83d467e14b8fe5cb8ea2e1 100644 (file)
@@ -1,6 +1,9 @@
 
 # This file lists all the available tours.
 
-test.tour
-test2.tour
+introduction/introduction.tour
+
+
+test1/test.tour
+test2/test2.tour
 
index c2ede5e2daf1427529fabac1ad7507480e82b7b6..baff4a5bbb9fa3822933599d79dbaa25fa918675 100644 (file)
@@ -5,8 +5,6 @@ import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
 import java.awt.event.MouseAdapter;
 import java.awt.event.MouseEvent;
-import java.io.FileNotFoundException;
-import java.io.IOException;
 import java.util.List;
 
 import javax.swing.AbstractListModel;
@@ -29,16 +27,14 @@ import net.sf.openrocket.gui.components.StyledLabel.Style;
 import net.sf.openrocket.gui.util.GUIUtil;
 import net.sf.openrocket.l10n.Translator;
 import net.sf.openrocket.startup.Application;
-import net.sf.openrocket.util.BugException;
 import net.sf.openrocket.util.Named;
 
 public class GuidedTourSelectionDialog extends JDialog {
        
        private static final Translator trans = Application.getTranslator();
        
-       private static final String TOURS_BASE_DIR = "datafiles/tours";
        
-
+       
        private final SlideSetManager slideSetManager;
        private final List<String> tourNames;
        
@@ -52,21 +48,9 @@ public class GuidedTourSelectionDialog extends JDialog {
        public GuidedTourSelectionDialog(Window parent) {
                super(parent, trans.get("title"), ModalityType.MODELESS);
                
-               try {
-                       
-                       slideSetManager = new SlideSetManager(TOURS_BASE_DIR);
-                       slideSetManager.load();
-                       
-                       tourNames = slideSetManager.getSlideSetNames();
-                       if (tourNames.isEmpty()) {
-                               throw new FileNotFoundException("No tours found.");
-                       }
-                       
-               } catch (IOException e) {
-                       throw new BugException(e);
-               }
+               slideSetManager = SlideSetManager.getSlideSetManager();
+               tourNames = slideSetManager.getSlideSetNames();
                
-
                JPanel panel = new JPanel(new MigLayout("fill"));
                
                panel.add(new StyledLabel(trans.get("lbl.selectTour"), Style.BOLD), "spanx, wrap rel");
@@ -87,10 +71,10 @@ public class GuidedTourSelectionDialog extends JDialog {
                                }
                        }
                });
-               panel.add(new JScrollPane(tourList), "grow, gapright unrel, w 200lp, h 150lp");
+               panel.add(new JScrollPane(tourList), "grow, gapright unrel, w 200lp, h 250lp");
+               
+               
                
-
-
                //  Sub-panel containing description and start button
                JPanel sub = new JPanel(new MigLayout("fill, ins 0"));
                sub.add(new StyledLabel(trans.get("lbl.description"), -1), "wrap rel");
@@ -113,10 +97,10 @@ public class GuidedTourSelectionDialog extends JDialog {
                });
                sub.add(start, "growx");
                
-               panel.add(sub, "grow, wrap para, w 200lp, h 150lp");
+               panel.add(sub, "grow, wrap para, w 350lp, h 250lp");
+               
+               
                
-
-
                JButton close = new JButton(trans.get("button.close"));
                close.addActionListener(new ActionListener() {
                        @Override
@@ -128,6 +112,7 @@ public class GuidedTourSelectionDialog extends JDialog {
                
                this.add(panel);
                GUIUtil.setDisposableDialogOptions(this, close);
+               GUIUtil.rememberWindowPosition(this);
                tourList.setSelectedIndex(0);
        }
        
@@ -192,6 +177,6 @@ public class GuidedTourSelectionDialog extends JDialog {
                
        }
        
-
-
+       
+       
 }
index 7ac4212b04c06851ec9e36de5d522127aa78aa3e..c3c1fab871cc7e305cd7640a07977cf667cf9b98 100644 (file)
@@ -14,6 +14,7 @@ import javax.imageio.ImageIO;
  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
  */
 public class Slide {
+       private static final String NO_IMAGE = "none";
        
        private final String imageFile;
        private SoftReference<BufferedImage> imageReference = null;
@@ -21,16 +22,20 @@ public class Slide {
        private final String text;
        
        
-
+       
        public Slide(String imageFile, String text) {
                this.imageFile = imageFile;
                this.text = text;
        }
        
        
-
+       
        public BufferedImage getImage() {
                
+               if (imageFile.equals(NO_IMAGE)) {
+                       return new BufferedImage(0, 0, BufferedImage.TYPE_INT_ARGB);
+               }
+               
                // Check the cache
                if (imageReference != null) {
                        BufferedImage image = imageReference.get();
@@ -51,7 +56,7 @@ public class Slide {
        }
        
        
-
+       
        private BufferedImage loadImage() {
                BufferedImage img;
                
index abf5e74b888dcdd24e70aeb57988a31cfaccfd22..0d9e38155cc830dffdf2210b9d046d8827c77c71 100644 (file)
@@ -11,6 +11,8 @@ import java.util.Map;
 
 import javax.swing.text.html.StyleSheet;
 
+import net.sf.openrocket.util.BugException;
+
 /**
  * A manager that loads a number of slide sets from a defined base directory
  * and provides access to them.
@@ -18,11 +20,14 @@ import javax.swing.text.html.StyleSheet;
  * @author Sampo Niskanen <sampo.niskanen@iki.fi>
  */
 public class SlideSetManager {
+       private static final String TOURS_BASE_DIR = "datafiles/tours";
        
        private static final String TOURS_FILE = "tours.txt";
        private static final String STYLESHEET_FILE = "style.css";
        
-
+       private static SlideSetManager slideSetManager = null;
+       
+       
        private final String baseDir;
        private final Map<String, SlideSet> slideSets = new LinkedHashMap<String, SlideSet>();
        
@@ -49,20 +54,24 @@ public class SlideSetManager {
                List<String> tours = loadTourList();
                StyleSheet styleSheet = loadStyleSheet();
                
-               for (String file : tours) {
+               for (String fileAndDir : tours) {
+                       String base;
+                       String file;
                        
-                       String base = baseDir + file;
-                       int index = base.lastIndexOf('/');
+                       String fullFileAndDir = baseDir + fileAndDir;
+                       int index = fullFileAndDir.lastIndexOf('/');
                        if (index >= 0) {
-                               base = base.substring(0, index);
+                               base = fullFileAndDir.substring(0, index);
+                               file = fullFileAndDir.substring(index + 1);
                        } else {
                                base = "";
+                               file = "";
                        }
                        
                        SlideSetLoader loader = new SlideSetLoader(base);
                        SlideSet set = loader.load(file);
                        set.setStyleSheet(styleSheet);
-                       slideSets.put(file, set);
+                       slideSets.put(fileAndDir, set);
                }
                
        }
@@ -131,4 +140,26 @@ public class SlideSetManager {
                
        }
        
+       
+       
+       /**
+        * Return a singleton implementation that has loaded the default tours.
+        */
+       public static SlideSetManager getSlideSetManager() {
+               if (slideSetManager == null) {
+                       try {
+                               SlideSetManager ssm = new SlideSetManager(TOURS_BASE_DIR);
+                               ssm.load();
+                               
+                               if (ssm.getSlideSetNames().isEmpty()) {
+                                       throw new FileNotFoundException("No tours found.");
+                               }
+                               
+                               slideSetManager = ssm;
+                       } catch (IOException e) {
+                               throw new BugException(e);
+                       }
+               }
+               return slideSetManager;
+       }
 }
index 4e11d252b8de9cfbf35d3b0c86c493e6019242f7..236f9cc893a92498ff0cea4e1dfb8618d7d26a42 100644 (file)
@@ -19,6 +19,10 @@ import net.sf.openrocket.gui.components.ImageDisplayComponent;
  */
 public class SlideShowComponent extends JSplitPane {
        
+       private final int WIDTH = 600;
+       private final int HEIGHT_IMAGE = 400;
+       private final int HEIGHT_TEXT = 100;
+       
        private final ImageDisplayComponent imageDisplay;
        private final JEditorPane textPane;
        
@@ -27,21 +31,21 @@ public class SlideShowComponent extends JSplitPane {
                super(VERTICAL_SPLIT);
                
                imageDisplay = new ImageDisplayComponent();
-               imageDisplay.setPreferredSize(new Dimension(600, 350));
+               imageDisplay.setPreferredSize(new Dimension(WIDTH, HEIGHT_IMAGE));
                this.setLeftComponent(imageDisplay);
                
                textPane = new JEditorPane("text/html", "");
                textPane.setEditable(false);
-               textPane.setPreferredSize(new Dimension(600, 100));
+               textPane.setPreferredSize(new Dimension(WIDTH, HEIGHT_TEXT));
                
                JScrollPane scrollPanel = new JScrollPane(textPane);
                this.setRightComponent(scrollPanel);
                
-               this.setResizeWeight(0.7);
+               this.setResizeWeight(((double) HEIGHT_IMAGE) / (HEIGHT_IMAGE + HEIGHT_TEXT));
        }
        
        
-
+       
        public void setSlide(Slide slide) {
                this.imageDisplay.setImage(slide.getImage());
                this.textPane.setText(slide.getText());
index ca97e2e637e431864c984d229397593f564e7a97..61936b911421575a34faee18f7c6037fec054a73 100644 (file)
@@ -3,24 +3,28 @@ package net.sf.openrocket.gui.help.tours;
 import java.awt.Window;
 import java.awt.event.ActionEvent;
 import java.awt.event.ActionListener;
-import java.util.Locale;
+import java.awt.event.KeyEvent;
 
+import javax.swing.AbstractAction;
+import javax.swing.Action;
 import javax.swing.JButton;
+import javax.swing.JComponent;
 import javax.swing.JDialog;
 import javax.swing.JPanel;
-import javax.swing.SwingUtilities;
-import javax.swing.event.HyperlinkEvent;
-import javax.swing.event.HyperlinkListener;
+import javax.swing.JRootPane;
+import javax.swing.KeyStroke;
 
 import net.miginfocom.swing.MigLayout;
 import net.sf.openrocket.gui.util.GUIUtil;
 import net.sf.openrocket.l10n.Translator;
+import net.sf.openrocket.logging.LogHelper;
 import net.sf.openrocket.startup.Application;
 import net.sf.openrocket.util.BugException;
 import net.sf.openrocket.util.Chars;
 
 public class SlideShowDialog extends JDialog {
        
+       private static final LogHelper log = Application.getLogger();
        private static final Translator trans = Application.getTranslator();
        
        private SlideShowComponent slideShowComponent;
@@ -38,35 +42,38 @@ public class SlideShowDialog extends JDialog {
                JPanel panel = new JPanel(new MigLayout("fill"));
                
                slideShowComponent = new SlideShowComponent();
+               slideShowComponent.addHyperlinkListener(new SlideShowLinkListener(parent));
                panel.add(slideShowComponent, "spanx, grow, wrap para");
                
-
+               
                JPanel sub = new JPanel(new MigLayout("ins 0, fill"));
                
                prevButton = new JButton(Chars.LEFT_ARROW + " " + trans.get("btn.prev"));
                prevButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
+                               log.user("Clicked previous button");
                                setPosition(position - 1);
                        }
                });
                sub.add(prevButton, "left");
                
-
-
+               
+               
                nextButton = new JButton(trans.get("btn.next") + " " + Chars.RIGHT_ARROW);
                nextButton.addActionListener(new ActionListener() {
                        @Override
                        public void actionPerformed(ActionEvent e) {
+                               log.user("Clicked next button");
                                setPosition(position + 1);
                        }
                });
                sub.add(nextButton, "left, gapleft para");
                
-
+               
                sub.add(new JPanel(), "growx");
                
-
+               
                closeButton = new JButton(trans.get("button.close"));
                closeButton.addActionListener(new ActionListener() {
                        @Override
@@ -76,12 +83,16 @@ public class SlideShowDialog extends JDialog {
                });
                sub.add(closeButton, "right");
                
-
+               
                panel.add(sub, "growx");
                
                this.add(panel);
                updateEnabled();
+               addKeyActions();
                GUIUtil.setDisposableDialogOptions(this, nextButton);
+               nextButton.grabFocus();
+               GUIUtil.rememberWindowPosition(this);
+               GUIUtil.rememberWindowSize(this);
                this.setAlwaysOnTop(true);
        }
        
@@ -120,41 +131,43 @@ public class SlideShowDialog extends JDialog {
        }
        
        
-       public static void main(String[] args) throws Exception {
+       
+       
+       
+       private void addKeyActions() {
+               Action next = new AbstractAction() {
+                       @Override
+                       public void actionPerformed(ActionEvent event) {
+                               log.user("Key action for next slide");
+                               if (position < slideSet.getSlideCount() - 1) {
+                                       setPosition(position + 1);
+                               }
+                       }
+               };
                
-               Locale.setDefault(new Locale("de", "DE", ""));
+               Action previous = new AbstractAction() {
+                       @Override
+                       public void actionPerformed(ActionEvent event) {
+                               log.user("Key action for previous slide");
+                               if (position > 0) {
+                                       setPosition(position - 1);
+                               }
+                       }
+               };
                
-               SlideSetManager manager = new SlideSetManager("datafiles/tours");
-               manager.load();
+               String nextKey = "slide:next";
+               String prevKey = "slide:previous";
                
-               final SlideSet set = manager.getSlideSet("test.tour");
+               JRootPane root = this.getRootPane();
+               root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_RIGHT, 0), nextKey);
+               root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_RIGHT, 0), nextKey);
+               root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_LEFT, 0), prevKey);
+               root.getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke(KeyEvent.VK_KP_LEFT, 0), prevKey);
                
-               SwingUtilities.invokeAndWait(new Runnable() {
-                       @Override
-                       public void run() {
-                               
-                               SlideShowDialog ssd = new SlideShowDialog(null);
-                               
-                               ssd.slideShowComponent.addHyperlinkListener(new HyperlinkListener() {
-                                       @Override
-                                       public void hyperlinkUpdate(HyperlinkEvent e) {
-                                               System.out.println("Hyperlink event: " + e);
-                                               System.out.println("Event type: " + e.getEventType());
-                                               System.out.println("Description: " + e.getDescription());
-                                               System.out.println("URL: " + e.getURL());
-                                               System.out.println("Source element: " + e.getSourceElement());
-                                               
-                                       }
-                               });
-                               
-                               ssd.setSize(500, 500);
-                               ssd.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE);
-                               ssd.setVisible(true);
-                               
-                               ssd.setSlideSet(set, 0);
-                       }
-               });
+               root.getActionMap().put(nextKey, next);
+               root.getActionMap().put(prevKey, previous);
        }
        
-
+       
+       
 }
diff --git a/src/net/sf/openrocket/gui/help/tours/SlideShowLinkListener.java b/src/net/sf/openrocket/gui/help/tours/SlideShowLinkListener.java
new file mode 100644 (file)
index 0000000..5fc1d88
--- /dev/null
@@ -0,0 +1,55 @@
+package net.sf.openrocket.gui.help.tours;
+
+import java.awt.Desktop;
+import java.awt.Window;
+import java.net.URL;
+
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkEvent.EventType;
+import javax.swing.event.HyperlinkListener;
+
+import net.sf.openrocket.startup.Application;
+
+public class SlideShowLinkListener implements HyperlinkListener {
+       
+       private final Window parent;
+       
+       public SlideShowLinkListener(Window parent) {
+               this.parent = parent;
+       }
+       
+       @Override
+       public void hyperlinkUpdate(HyperlinkEvent event) {
+               
+               if (event.getEventType() != EventType.ACTIVATED) {
+                       return;
+               }
+               
+               URL url = event.getURL();
+               if (url != null && (url.getProtocol().equalsIgnoreCase("http") || url.getProtocol().equals("https"))) {
+                       
+                       if (Desktop.isDesktopSupported()) {
+                               try {
+                                       Desktop.getDesktop().browse(url.toURI());
+                               } catch (Exception e) {
+                                       // Ignore
+                               }
+                       }
+                       
+               } else {
+                       
+                       String name = event.getDescription();
+                       try {
+                               SlideSet ss = SlideSetManager.getSlideSetManager().getSlideSet(name);
+                               
+                               SlideShowDialog dialog = new SlideShowDialog(parent);
+                               dialog.setSlideSet(ss, 0);
+                               dialog.setVisible(true);
+                       } catch (IllegalArgumentException e) {
+                               Application.getExceptionHandler().handleErrorCondition("Guided tour '" + name + "' not found.");
+                       }
+                       
+               }
+               
+       }
+}
index c796405c82eb63ef56ee053b516a8f2f7a42735d..4ee74ba4e83edfc75245c9020ecaf00e26d9ba84 100644 (file)
@@ -127,8 +127,8 @@ public class GUIUtil {
        }
        
        
-
-
+       
+       
        /**
         * Set suitable options for a single-use disposable dialog.  This includes
         * setting ESC to close the dialog, adding the appropriate window icons and
@@ -153,7 +153,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Add the correct action to close a JDialog when the ESC key is pressed.
         * The dialog is closed by sending is a WINDOW_CLOSING event.
@@ -192,7 +192,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Change the behavior of a component so that TAB and Shift-TAB cycles the focus of
         * the components.  This is necessary for e.g. <code>JTextArea</code>.
@@ -207,7 +207,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Set the OpenRocket icons to the window icons.
         * 
@@ -236,7 +236,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Set the best available look-and-feel into use.
         */
@@ -294,7 +294,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Automatically remember the size of a window.  This stores the window size in the user
         * preferences when resizing/maximizing the window and sets the state on the first call.
@@ -377,7 +377,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * Traverses recursively the component tree, and sets all applicable component 
         * models to null, so as to remove the listener connections.  After calling this
@@ -519,7 +519,7 @@ public class GUIUtil {
        }
        
        
-
+       
        /**
         * A mouse listener that toggles the state of a boolean value in a table model
         * when clicked on another column of the table.