Author: andreas
Date: 2008-05-14 07:56:48-0700
New Revision: 14730

Added:
   trunk/src/argouml-app/src/org/argouml/ui/HelpBox.java
   trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionHelp.java
Modified:
   trunk/src/argouml-app/src/org/argouml/i18n/action.properties
   trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
   trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java

Log:
Added a help action and a help window with tabs for manual, forum and wiki.


Modified: trunk/src/argouml-app/src/org/argouml/i18n/action.properties
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/i18n/action.properties?view=diff&rev=14730&p1=trunk/src/argouml-app/src/org/argouml/i18n/action.properties&p2=trunk/src/argouml-app/src/org/argouml/i18n/action.properties&r1=14729&r2=14730
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/i18n/action.properties        
(original)
+++ trunk/src/argouml-app/src/org/argouml/i18n/action.properties        
2008-05-14 07:56:48-0700
@@ -91,6 +91,7 @@
 action.goto-source = Source
 action.goto-tagged-values = Tagged Values
 action.goto-todo-item = ToDo Item
+action.help = Help
 action.hide-all-compartments = Hide All Compartments
 action.hide-attribute-compartment = Hide Attribute Compartment
 action.hide-enumeration-literal-compartment = Hide Enumeration Literal 
Compartment

Added: trunk/src/argouml-app/src/org/argouml/ui/HelpBox.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/HelpBox.java?view=auto&rev=14730
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/ui/HelpBox.java       2008-05-14 
07:56:48-0700
@@ -0,0 +1,156 @@
+// $Id$
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies.  This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason.  IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ui;
+
+import java.awt.BorderLayout;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Insets;
+import java.awt.Toolkit;
+import java.io.IOException;
+import java.net.URL;
+import java.net.MalformedURLException;
+
+import javax.swing.JEditorPane;
+import javax.swing.JFrame;
+import javax.swing.JPanel;
+import javax.swing.JScrollPane;
+import javax.swing.JTabbedPane;
+import javax.swing.border.EmptyBorder;
+import javax.swing.event.HyperlinkEvent;
+import javax.swing.event.HyperlinkListener;
+
+import org.argouml.i18n.Translator;
+import org.argouml.util.ArgoDialog;
+import org.argouml.util.Tools;
+
+/**
+ * This is what you see after you activate the "Help->Help" menu-item.
+ */
+public class HelpBox extends JFrame implements HyperlinkListener {
+
+    /**
+     * Insets in pixels.
+     */
+    private static final int INSET_PX = 3;
+
+    ////////////////////////////////////////////////////////////////
+    // instance variables
+
+    /**
+     * A tabbed pane to display several pages simultaneously.
+     */
+    private JTabbedPane tabs = new JTabbedPane();
+
+    /**
+     * The panes to display the various help pages.
+     */
+    JEditorPane [] _panes = null;
+
+    /**
+     * The names and URLs for the pages.
+     */
+    String _pages [] [] = { { "Manual", 
"http://argouml-stats.tigris.org/documentation/manual-0.24/"; , "The ArgoUML 
online manual"},
+                           { "Forum", 
"http://www.argouml-users.net/forum/viewforum.php?f=1";, "A ArgoUML forum" },
+                            { "Wiki", 
"http://www.argouml-users.net/index.php?title=Main_Page";, "A ArgoUML wiki" } };
+
+
+    ////////////////////////////////////////////////////////////////
+    // constructor
+
+    /**
+     * @see Translator#localize(String)
+     *
+     * @param str The key to localize.
+     * @return The localized String.
+     */
+    private static String localize(String str) {
+       return Translator.localize(str);
+    }
+
+    /**
+    * Class constructor.
+    *
+    * @param title      the title of the help window.
+    */
+    public HelpBox( String title) {
+       super( title);
+       Dimension scrSize = Toolkit.getDefaultToolkit().getScreenSize();
+       setLocation(scrSize.width / 2 - 400, scrSize.height / 2 - 300);
+
+       getContentPane().setLayout(new BorderLayout(0, 0));
+       setSize( 800, 600);
+
+       _panes = new JEditorPane [ _pages.length];
+       for( int i=0; i < _pages.length; i++) {
+            _panes[i] = new JEditorPane();
+            _panes[i].setEditable( false);
+            _panes[i].setSize( 780, 580);
+            _panes[i].addHyperlinkListener( this);
+
+           URL paneURL = null;
+            try {
+                paneURL = new URL( _pages[i][1]);
+            } catch( MalformedURLException e) {
+                System.err.println( _pages[i][0] + " URL malformed: " + 
_pages[i][1]);
+            }
+
+            if( paneURL != null) {
+                try {
+                    _panes[i].setPage( paneURL);
+                } catch( IOException e) {
+                    System.err.println("Attempted to read a bad URL: " + 
paneURL);
+                }
+            } else {
+                System.err.println("Couldn't find " + _pages[i][0]);
+            }
+
+            // Put the current pane in a scroll pane.
+            JScrollPane paneScrollPane = new JScrollPane( _panes[i]);
+            paneScrollPane.setVerticalScrollBarPolicy( 
JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
+            paneScrollPane.setPreferredSize(new Dimension(800, 600));
+            paneScrollPane.setMinimumSize(new Dimension(400, 300));
+
+           tabs.addTab( _pages[i][0], null, paneScrollPane, _pages[i][2]);
+        }
+        getContentPane().add( tabs, BorderLayout.CENTER);
+    }
+
+    public void hyperlinkUpdate(HyperlinkEvent event) {
+       if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
+           JEditorPane pane = (JEditorPane)event.getSource();
+            try {
+                pane.setPage(event.getURL());
+            } catch (IOException ioe) {
+                System.err.println( "Could not fetch requested URL");
+            }
+       }
+    }
+
+    /**
+     * The UID.
+     */
+    private static final long serialVersionUID = 0L;
+} /* end class HelpBox */

Added: trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionHelp.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionHelp.java?view=auto&rev=14730
==============================================================================
--- (empty file)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/ActionHelp.java        
2008-05-14 07:56:48-0700
@@ -0,0 +1,65 @@
+// $Id$
+// Copyright (c) 1996-2008 The Regents of the University of California. All
+// Rights Reserved. Permission to use, copy, modify, and distribute this
+// software and its documentation without fee, and without a written
+// agreement is hereby granted, provided that the above copyright notice
+// and this paragraph appear in all copies.  This software program and
+// documentation are copyrighted by The Regents of the University of
+// California. The software program and documentation are supplied "AS
+// IS", without any accompanying services from The Regents. The Regents
+// does not warrant that the operation of the program will be
+// uninterrupted or error-free. The end-user understands that the program
+// was developed for research purposes and is advised not to rely
+// exclusively on the program for any reason.  IN NO EVENT SHALL THE
+// UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT,
+// SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, INCLUDING LOST PROFITS,
+// ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF
+// THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF
+// SUCH DAMAGE. THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY
+// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+// MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE
+// PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF
+// CALIFORNIA HAS NO OBLIGATIONS TO PROVIDE MAINTENANCE, SUPPORT,
+// UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
+
+package org.argouml.ui.cmd;
+
+import java.awt.event.ActionEvent;
+
+import javax.swing.AbstractAction;
+import javax.swing.JFrame;
+
+import org.argouml.application.helpers.ResourceLoaderWrapper;
+import org.argouml.i18n.Translator;
+import org.argouml.ui.HelpBox;
+// import org.argouml.util.ArgoFrame;
+
+
+/**
+ * The action to show the ArgoUML help dialog.
+ */
+public class ActionHelp extends AbstractAction {
+
+    /**
+     * Constructor.
+     */
+    public ActionHelp() {
+        super(Translator.localize("action.help"),
+                ResourceLoaderWrapper.lookupIcon("action.help"));
+    }
+
+    /*
+     * @see 
java.awt.event.ActionListener#actionPerformed(java.awt.event.ActionEvent)
+     */
+    public void actionPerformed(ActionEvent ae) {
+       HelpBox box = new HelpBox( Translator.localize("action.help"));
+
+       // box.setLocationRelativeTo(jframe);
+       box.setVisible(true);
+    }
+
+    /**
+     * The UID.
+     */
+    private static final long serialVersionUID = 0L;
+} /* end class ActionHelp */

Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java?view=diff&rev=14730&p1=trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java&r1=14729&r2=14730
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java        
(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/GenericArgoMenuBar.java        
2008-05-14 07:56:48-0700
@@ -899,6 +899,12 @@
             help.insertSeparator(0);
         }
 
+        // Add the help menu item.
+        JMenuItem argoHelp = help.add(new ActionHelp());
+        setMnemonic(argoHelp, "ArgoUML help");
+        ShortcutMgr.assignAccelerator(argoHelp, ShortcutMgr.ACTION_HELP);
+        help.addSeparator();
+
         JMenuItem systemInfo = help.add(new ActionSystemInfo());
         setMnemonic(systemInfo, "System Information");
         ShortcutMgr.assignAccelerator(systemInfo,

Modified: trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java
Url: 
http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java?view=diff&rev=14730&p1=trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java&p2=trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java&r1=14729&r2=14730
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java       
(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/cmd/ShortcutMgr.java       
2008-05-14 07:56:48-0700
@@ -247,6 +247,9 @@
     /** Action key for open critics */
     public static final String ACTION_OPEN_CRITICS = "openCritics";
 
+    /** Action key for help */
+    public static final String ACTION_HELP = "help";
+
     /** Action key for system info */
     public static final String ACTION_SYSTEM_INFORMATION = "systemInfo";
 
@@ -724,5 +727,10 @@
                 KeyEvent.VK_B, SHIFTED_DEFAULT_MASK), new ReorderAction(
                         "ToBack",
                         ReorderAction.SEND_TO_BACK));
+
+       // help menu
+       putDefaultShortcut(ACTION_HELP, 
+                           KeyStroke.getKeyStroke( KeyEvent.VK_F1, 0), 
+                           new ActionHelp());
     }
 }

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to