diff --git a/src/antidote/docs/design-overview.html b/src/antidote/docs/design-overview.html index 5afd2978c..8eb3d325d 100644 --- a/src/antidote/docs/design-overview.html +++ b/src/antidote/docs/design-overview.html @@ -8,7 +8,7 @@
Version 0.1 (2000/11/02)
+Version 0.2 (2000/12/18)
Authors: Simeon H.K. Fitch @@ -39,7 +39,7 @@ communications channel.
To a large extent, the configuration of application modules is - driven by localized configuration files, allowing new editors or + driven by localized configuration files, allowing new modules or data views to be added, as well as providing multi-language support.
@@ -53,7 +53,7 @@ Antidote Component Architecture +---------------+ +----------------+ +-------------+ +-------------+ | | | | | | | | - | ActionManager | | EventResponder | | AntEditor | | AntEditor | + | ActionManager | | EventResponder | | AntModule | | AntModule | | | | | |(ProjectNav) | |(SourceEdit) | +---------------+ +----------------+ +-------------+ +-------------+ | ^ ^ ^ diff --git a/src/antidote/org/apache/tools/ant/gui/AntEditor.java b/src/antidote/org/apache/tools/ant/gui/AntModule.java similarity index 71% rename from src/antidote/org/apache/tools/ant/gui/AntEditor.java rename to src/antidote/org/apache/tools/ant/gui/AntModule.java index dd02ef6e0..768f38ee8 100644 --- a/src/antidote/org/apache/tools/ant/gui/AntEditor.java +++ b/src/antidote/org/apache/tools/ant/gui/AntModule.java @@ -53,34 +53,51 @@ */ package org.apache.tools.ant.gui; -import javax.swing.JPanel; +import javax.swing.JComponent; import javax.swing.BorderFactory; /** - * Abstract base class for an "editor", which is really anything that + * Abstract base class for a "module", which is really anything that * can send or receive events, or edit or view the model. * * @version $Revision$ * @author Simeon Fitch */ -public abstract class AntEditor extends JPanel { - - /** Parameters to the Contructor. Used for loading - classes through reflection. */ - public static final Class[] CTOR_PARAMS = { AppContext.class }; +public abstract class AntModule extends JComponent { /** The application context. */ private AppContext _context = null; /** - * Standard constuctor. + * Default constructor. + */ + protected AntModule() { + // Create a dummy border so that the widget will at least have a + // minimal display in a bean environment. + setBorder(BorderFactory.createTitledBorder(getClass().getName())); + } + + /** + * This method is called after instantiation when the application context + * is available for constructing the class' display. Think of this in + * a similar manner to Applet.init() or Servlet.init(). It should + * immediately call #setContext() with the given parameter. + * + * @param context Valid application context providing + * all required resources. + */ + public abstract void contextualize(AppContext context); + + /** + * Set the application context. * * @param context Application context. */ - protected AntEditor(AppContext context) { + protected void setContext(AppContext context) { _context = context; - setBorder(BorderFactory.createTitledBorder(getName())); - } + setBorder(_context == null ? null : + BorderFactory.createTitledBorder(getName())); + } /** * Get the application context. @@ -88,6 +105,10 @@ public abstract class AntEditor extends JPanel { * @return Application context. */ public AppContext getContext() { + if(_context == null) { + throw new IllegalStateException( + "The AppContext has not been set."); + } return _context; } /** @@ -96,6 +117,6 @@ public abstract class AntEditor extends JPanel { * @return Editor's name. */ public String getName() { - return _context.getResources().getString(getClass(), "name"); + return getContext().getResources().getString(getClass(), "name"); } } diff --git a/src/antidote/org/apache/tools/ant/gui/Antidote.java b/src/antidote/org/apache/tools/ant/gui/Antidote.java index 017a189ef..85bf5e5a2 100644 --- a/src/antidote/org/apache/tools/ant/gui/Antidote.java +++ b/src/antidote/org/apache/tools/ant/gui/Antidote.java @@ -78,10 +78,10 @@ public class Antidote extends JPanel { _context = context; - // Add the various editors/views to the editing area. + // Add the various modules to the editing area. JSplitPane splitter = new JSplitPane(); - splitter.add(JSplitPane.LEFT, populateEditors("left")); - splitter.add(JSplitPane.RIGHT, populateEditors("right")); + splitter.add(JSplitPane.LEFT, populateModules("left")); + splitter.add(JSplitPane.RIGHT, populateModules("right")); // This is necessary because, frankly, the JSplitPane widget // sucks, and doesn't provide enought (working) control over the // initial size of it's subcomponents. setDividerLocation(double) @@ -93,38 +93,35 @@ public class Antidote extends JPanel { splitter2.setOneTouchExpandable(true); splitter2.add(JSplitPane.TOP, splitter); - splitter2.add(JSplitPane.BOTTOM, populateEditors("bottom")); + splitter2.add(JSplitPane.BOTTOM, populateModules("bottom")); add(BorderLayout.CENTER, splitter2); splitter2.resetToPreferredSizes(); - add(BorderLayout.NORTH, populateEditors("top")); + add(BorderLayout.NORTH, populateModules("top")); setPreferredSize(new Dimension(640, 600)); } /** - * Instantiate the configured editors. + * Instantiate the configured modules. * - * @return Component containing the editor(s). + * @return Component containing the modules(s). */ - private JComponent populateEditors(String prefix) { + private JComponent populateModules(String prefix) { String[] classNames = _context.getResources(). - getStringArray(getClass(), prefix + ".editors"); + getStringArray(getClass(), prefix + ".modules"); - AntEditor[] editors = new AntEditor[classNames.length]; + AntModule[] modules = new AntModule[classNames.length]; for(int i = 0; i < classNames.length; i++) { try { - Class editorType = Class.forName(classNames[i]); + Class type = Class.forName(classNames[i]); - Constructor ctor = - editorType.getConstructor(AntEditor.CTOR_PARAMS); - - editors[i] = - (AntEditor) ctor.newInstance(new Object[] { _context }); + modules[i] = (AntModule) type.newInstance(); + modules[i].contextualize(_context); } catch(Exception ex) { // XXX log me. @@ -132,14 +129,14 @@ public class Antidote extends JPanel { } } - if(editors.length == 1) { - return editors[0]; + if(modules.length == 1) { + return modules[0]; } - else if(editors.length > 1) { + else if(modules.length > 1) { JTabbedPane tabbed = new JTabbedPane(JTabbedPane.BOTTOM); - for(int i = 0; i < editors.length; i++) { - tabbed.addTab(editors[i].getName(), editors[i]); + for(int i = 0; i < modules.length; i++) { + tabbed.addTab(modules[i].getName(), modules[i]); } return tabbed; } diff --git a/src/antidote/org/apache/tools/ant/gui/Console.java b/src/antidote/org/apache/tools/ant/gui/Console.java index be91fb336..35feadfd2 100644 --- a/src/antidote/org/apache/tools/ant/gui/Console.java +++ b/src/antidote/org/apache/tools/ant/gui/Console.java @@ -68,7 +68,7 @@ import java.util.EventObject; * @version $Revision$ * @author Simeon Fitch */ -public class Console extends AntEditor { +public class Console extends AntModule { /** Area where messages are printed. */ private JTextPane _text = null; /** Selection of logging levels. */ @@ -77,12 +77,19 @@ public class Console extends AntEditor { private ConsoleStyleContext _styles = null; /** - * Standard ctor. + * Default ctor. + */ + public Console() { + } + + + /** + * Using the given AppContext, initialize the display. * - * @param context Application context; + * @param context Application context. */ - public Console(AppContext context) { - super(context); + public void contextualize(AppContext context) { + setContext(context); context.getEventBus().addMember(EventBus.MONITORING, new Handler()); setLayout(new BorderLayout()); @@ -106,6 +113,7 @@ public class Console extends AntEditor { } + /** Class for handling project events. */ private class Handler implements BusMember { private final Filter _filter = new Filter(); diff --git a/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java b/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java index 53e61cf0b..ea31f63f6 100644 --- a/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java +++ b/src/antidote/org/apache/tools/ant/gui/ProjectNavigator.java @@ -66,18 +66,25 @@ import java.util.EventObject; * @version $Revision$ * @author Simeon Fitch */ -class ProjectNavigator extends AntEditor { +class ProjectNavigator extends AntModule { /** Navigation via a tree widget. */ private JTree _tree = null; /** - * Standard ctor. + * Default ctor. + * + */ + public ProjectNavigator() { + } + + /** + * Using the given AppContext, initialize the display. * * @param context Application context. */ - public ProjectNavigator(AppContext context) { - super(context); + public void contextualize(AppContext context) { + setContext(context); context.getEventBus().addMember(EventBus.MONITORING, new Handler()); setLayout(new GridLayout(1,1)); diff --git a/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java b/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java index 6d4260d9d..f9058e081 100644 --- a/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java +++ b/src/antidote/org/apache/tools/ant/gui/PropertyEditor.java @@ -71,7 +71,7 @@ import java.awt.Point; * @version $Revision$ * @author Simeon H.K. Fitch */ -class PropertyEditor extends AntEditor { +public class PropertyEditor extends AntModule { /** The editor for current bean.*/ private Customizer _customizer = null; @@ -81,12 +81,19 @@ class PropertyEditor extends AntEditor { private JScrollPane _scroller = null; /** - * Standard ctor. + * Default ctor. * - * @param context Application context. */ - public PropertyEditor(AppContext context) { - super(context); + public PropertyEditor() { + } + + /** + * Using the given AppContext, initialize the display. + * + * @param context Application context. + */ + public void contextualize(AppContext context) { + setContext(context); context.getEventBus().addMember(EventBus.MONITORING, new Handler()); setLayout(new BorderLayout()); _container = new JPanel(new BorderLayout()); diff --git a/src/antidote/org/apache/tools/ant/gui/SourceEditor.java b/src/antidote/org/apache/tools/ant/gui/SourceEditor.java deleted file mode 100644 index e881e77b3..000000000 --- a/src/antidote/org/apache/tools/ant/gui/SourceEditor.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * The Apache Software License, Version 1.1 - * - * Copyright (c) 1999, 2000 The Apache Software Foundation. All rights - * reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * 3. The end-user documentation included with the redistribution, if - * any, must include the following acknowlegement: - * "This product includes software developed by the - * Apache Software Foundation (http://www.apache.org/)." - * Alternately, this acknowlegement may appear in the software itself, - * if and wherever such third-party acknowlegements normally appear. - * - * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software - * Foundation" must not be used to endorse or promote products derived - * from this software without prior written permission. For written - * permission, please contact apache@apache.org. - * - * 5. Products derived from this software may not be called "Apache" - * nor may "Apache" appear in their names without prior written - * permission of the Apache Group. - * - * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED - * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR - * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF - * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * ==================================================================== - * - * This software consists of voluntary contributions made by many - * individuals on behalf of the Apache Software Foundation. For more - * information on the Apache Software Foundation, please see - *