svn commit: r14801 - trunk: modules/dev/src/org/argouml/dev src/argouml-app/src/org/argouml/ui

[email protected]
Newsgroups gmane.comp.lang.uml.argouml.cvs
Message-ID <[email protected]>
Author: mvw
Date: 2008-05-26 11:20:06-0700
New Revision: 14801

Modified:
   trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java
   trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java

Log:
Allow modules to add extra tabs to the About box.
The dev module demonstrates how to do this.

Modified: trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java?view=diff&rev=14801&p1=trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java&p2=trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java&r1=14800&r2=14801
==============================================================================
--- trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java	(original)
+++ trunk/modules/dev/src/org/argouml/dev/DeveloperModule.java	2008-05-26 11:20:06-0700
@@ -24,12 +24,16 @@
 
 package org.argouml.dev;
 
+import java.awt.BorderLayout;
 import java.util.ArrayList;
 import java.util.List;
 
 import javax.swing.JComponent;
+import javax.swing.JLabel;
 import javax.swing.JMenu;
+import javax.swing.JPanel;
 import javax.swing.JTabbedPane;
+import javax.swing.SwingConstants;
 
 import org.apache.log4j.Logger;
 import org.argouml.application.api.AbstractArgoJPanel;
@@ -37,6 +41,7 @@
 import org.argouml.dev.test.TestPanel;
 import org.argouml.moduleloader.DetailsTabProvider;
 import org.argouml.moduleloader.ModuleInterface;
+import org.argouml.ui.AboutBox;
 import org.argouml.ui.ProjectBrowser;
 import org.tigris.gef.undo.UndoManager;
 
@@ -49,6 +54,7 @@
         DetailsTabProvider {
 
     private static final Logger LOG = Logger.getLogger(DeveloperModule.class);
+    private static String aboutName = "Dev module";
     
     /**
      * Wrapper.
@@ -92,6 +98,14 @@
         ProjectBrowser.getInstance().addPanel(devPanel, 
                 ProjectBrowser.Position.East);
 
+        /* Demonstrate the About Box interface to add a tab: */
+        JPanel tab = new JPanel(new BorderLayout());
+        JLabel lbl1 = new JLabel(
+                "<html><p>Developer module</p>"
+                + "<p>by</p><p>Bob Tarling</p></html>");
+        lbl1.setHorizontalAlignment(SwingConstants.CENTER);
+        tab.add(lbl1, BorderLayout.NORTH);
+        AboutBox.addAboutTab(aboutName, tab);
 
         return true;
     }
@@ -109,6 +123,8 @@
 
         JComponent undoLogPanel = UndoLogPanel.getInstance();
         ProjectBrowser.getInstance().removePanel(undoLogPanel);
+        
+        AboutBox.removeAboutTab(aboutName);
         return true;
     }
 

Modified: trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java
Url: http://argouml.tigris.org/source/browse/argouml/trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java?view=diff&rev=14801&p1=trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java&p2=trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java&r1=14800&r2=14801
==============================================================================
--- trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java	(original)
+++ trunk/src/argouml-app/src/org/argouml/ui/AboutBox.java	2008-05-26 11:20:06-0700
@@ -1,5 +1,5 @@
 // $Id$
-// Copyright (c) 1996-2007 The Regents of the University of California. All
+// 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
@@ -25,10 +25,13 @@
 package org.argouml.ui;
 
 import java.awt.BorderLayout;
+import java.awt.Component;
 import java.awt.Dimension;
 import java.awt.Frame;
 import java.awt.Insets;
 import java.awt.Toolkit;
+import java.util.HashMap;
+import java.util.Map;
 
 import javax.swing.JPanel;
 import javax.swing.JScrollPane;
@@ -42,8 +45,8 @@
 
 /**
  * This is what you see after you activate the "Help->About ArgoUML" menu-item.
- *
- * TODO: Add registration for new AboutBox tabs.
+ * <p>
+ * Modules can add extra tabs at will.
  */
 public class AboutBox extends ArgoDialog {
 
@@ -51,9 +54,9 @@
      * Insets in pixels.
      */
     private static final int INSET_PX = 3;
-
-    ////////////////////////////////////////////////////////////////
-    // instance variables
+    
+    private static Map<String, Component> extraTabs = 
+        new HashMap<String, Component>();
 
     private JTabbedPane tabs = new JTabbedPane();
 
@@ -62,8 +65,6 @@
      */
     private SplashPanel splashPanel;
 
-    ////////////////////////////////////////////////////////////////
-    // constructor
     /**
      * Class constructor.
      */
@@ -146,6 +147,10 @@
 	tabs.addTab(localize("aboutbox.tab.legal"),
 		     createPane(localize("aboutbox.legal")));
 
+        for (String key : extraTabs.keySet()) {
+            tabs.addTab(key, extraTabs.get(key));
+        }
+
 	getContentPane().setLayout(new BorderLayout(0, 0));
 	getContentPane().add(tabs, BorderLayout.CENTER);
 
@@ -155,6 +160,25 @@
     }
 
     /**
+     * Add an extra tab to the About box.
+     * 
+     * @param name the name of the tab as shown on screen
+     * @param tab the tab
+     */
+    public static void addAboutTab(String name, Component tab) {
+        extraTabs.put(name, tab);
+    }
+    
+    /**
+     * Remove a previously added tab from the About Box.
+     * 
+     * @param name the name of the tab as shown on screen
+     */
+    public static void removeAboutTab(String name) {
+        extraTabs.remove(name);
+    }
+
+    /**
      * Get the contents of the version tab.<p>
      *
      * This should include all libraries used by ArgoUML.<p>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.