User: andreas 
  Date: 00/09/24 21:45:47

  Added:       .        EJX.Getting-Started.HowTo.html
  Log:
  First Release of an introduction to EJX/AWT writen by
  Rickard Oeberg.
  
  Revision  Changes    Path
  1.1                  jbossweb/EJX.Getting-Started.HowTo.html
  
  Index: EJX.Getting-Started.HowTo.html
  ===================================================================
  <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
  <HTML>
  <HEAD>
  <TITLE>EJX/AWT Introduction and HowTo</TITLE>
  <LINK REL="stylesheet" type="text/css" href="HowTo.css" >
  </HEAD>
  <BODY>
  <DIV class="page">
  
  <H1>EJX/AWT Description and HowTo</H1>
  <H2>Introduction</H2>
  <H3>EJX/AWT from <A href="mailto:[EMAIL PROTECTED]" >Rickard �berg</A></H3>
  <DIV class="para" ALIGN="left">
  Both packages are created by Rickard �berg and are available at his DreamBean
  Website: <A HREF="http://www.dreambean.com">www.dreambean.com</A>. Both packages
  are heavily used in jBoss do create/maintain EJB descriptor and other XML files.
  </DIV>
  <DIV class="para" ALIGN="left">
  The reason or motivation for me to write this HowTo was that I struggle to 
understand EJX
  and AWT. On the other hand Rickard was so busy with other stuff that I had to dig 
throug
  myself and to save time for other members of jBoss I started writing this HowTo. This
  document is <B>still under construction</B> and will maybe never be finished.
  </DIV>
  <H4>Idea of EJX</H4>
  <DIV class="para" ALIGN="left">
  EJX is a package and runtime environment enabling you to create a plugin to add new
  functionality and new GUI elements. EJX will dynamically lookup for plugins on the
  <B>predefined</B> package <B>/lib/ext</B> and load them for you. Whenever you create
  a new file or open a given file it will instantiate your plugin and show as an Frame 
within
  the EJX framework.
  </DIV>
  <DIV class="para" ALIGN="left">
  EJX uses XML but at the moment this is not quite clear for me but I am working on it
  (AS 9/15/00),
  </DIV>
  <H4>Idea of AWT</H4>
  <DIV class="para" ALIGN="left">
  AWT (or here called <I>Advanced Window Toolkit</I> and do not mix it up with
  <B>java.awt.*</B>) enables you to use an uniform GUI Environment and to use 
BeanContext
  with an easy to write XML definition file.
  </DIV>
  <DIV class="para" ALIGN="left">
  I am still at the beginning to understand AWT and EJX but I will upgrade this 
document
  as soon as I have more information and <B>examples</B>.
  </DIV>
  <H2>Project</H2>
  <H3>Introduction</A></H3>
  <DIV class="para" ALIGN="left">
  My way to understand EJX/AWT was to take EJX/AWT out of any context, rip off any 
unnecessary
  files/examples and start me own project. This allows me to write any types of 
examples without
  be bound to any other example (go back to the roots and start from there). Because 
of a mail
  from Rickard I figured out that the EJX structure missleaded my to the conclusion 
that EJB is
  tidly indegrated into EJX. Therefore I took out all the EJB related stuff and ended 
up with
  a &quot;clean&quot; set of files. To make my life easier I added Ant (<A 
HREF="http://jakarta.apache.org">
  jakarta.apache.org</A> project ANT) and wrote my own build.xml file. On top of this 
&quot;core&quot;
  project I started to add my own examples with Ant support.
  </DIV>
  <H3>Structure</A></H3>
  <DIV class="para" ALIGN="left">
  For the project structure download the <A HREF="ejx-project.zip">EJX Project Zip 
File</A> and extract it
  where you like. Then rename the directory <B>ejx.as.development</B> to whatever you 
like.
  </DIV>
  <DIV class="para" ALIGN="left">
  To save download time I removed all the jar-files you can take from jBoss CVS and 
these are:
  <UL>
  <LI>
  ejx.jar from jboss/dist/bin directory to yourProject/bin
  </LI>
  <LI>
  ant.jar, codegen.jar, javac.jar,xml.jar,xmlbeans.jar from jboss/lib to 
yourProject/lib/build
  </LI>
  <LI>
  awt.jar, xml.jar from jboss/lib to yourProject/lib/external
  </LI>
  </UL>
  All other jar-files are generated and copied to the right place.
  </DIV>
  <DIV class="para" ALIGN="left">
  <B>Attention:</B> Before you start with compiling any examples you <B>have</B> to 
run the
  compilation of the core project first. For this go to the yourProject/core/build and 
start the
  build.bat or build.sh file. This compiles the core project, but the necessary 
jar-files to the right
  place and creates the necessary ejxeditor.jar file.
  </DIV>
  <DIV class="para" ALIGN="left">
  Now you are ready for the examples.
  </DIV>
  <H3>Plane Pane Example</A></H3>
  <DIV class="para" ALIGN="left">
  This was my first example and the goal was to creat a Panel within EJX framework to 
display
  just a simple text. I used this example to find simplest example within EJX.
  </DIV>
  <DIV class="para" ALIGN="left">
  According to the EJX spec the only necessary thing you have to to is:
  <OL>
  <LI>
  Create a class extending the com.dreambean.ejx.FileManagerFactory interface
  </LI>
  <LI>
  Create a class extending the com.dreambean.ejx.FileManager interface
  </LI>
  <LI>
  Create an appropriate Manifest file with looks like this for this example:
  <PRE class="code" ALIGN="left">
  Class-Path: awt.jar ejb.jar
  EJX-plugin: com.madplanet.plainPane.FileManagerFactoryImpl
  
  Name: com/madplanet/plainPane/
  Specification-Title: PlanePane 0.1
  Specification-Version: v0.1
  Specification-Vendor: MAD plaNET plc
  Implementation-Title: ejx-plain-pane
  Implementation-Version: build1
  Implementation-Vendor: MAD plaNET plc
  </PRE>
  </LI>
  <LI>
  Compile these two classes
  </LI>
  <LI>
  Put these two classes and the Manifest file into a jar-file (name does not matter
  but I always name it this way: ejx.&lt;ProjectName&gt;.jar).
  </LI>
  <LI>
  And last but not least but the just created jar-file into the yourProject/lib/ext
  directory.
  </LI>
  </OL>
  Now the only thing left is to start EJX (go to yourProject/bin directory and start
  EJX with &quot;java -jar ejx.jar&quot;). When the EJX Frame comes up go to
  file/new and select &quot;Plane Pane XML&quot; and you will see our plugin
  coming up.
  </DIV>
  <DIV class="para" ALIGN="left">
  Now let's have a closer look to the classes we created in our plugin.
  </DIV>
  <H4>FileManagerFactoryImpl</H4>
  <DIV class="para" ALIGN="left">
  Implements the com.dreambean.ejx.FileManagerFactory and enables the EJX
  framework to select the right file for you. But now let's delf into the code
  <UL>
  <LI>
  Classes to be imported
  <PRE class="code" ALIGN="left">
  import java.io.File;
  import javax.swing.filechooser.FileFilter;
  
  import com.dreambean.ejx.FileManager;
  import com.dreambean.ejx.FileManagerFactory;
  </PRE>
  </LI>
  <LI>
  Class definition (to extend this class from FileFilter is just convenience because
  it is needed either way):
  <PRE class="code" ALIGN="left">
  public class FileManagerFactoryImpl
        extends FileFilter
        implements FileManagerFactory
  </PRE>
  </LI>
  <LI>
  These methods must be implement due FileManagerFactory interface. The first
  method creates the FileManager when a file is selected or in a given directory
  a new one can be created. The second method returns a FileFilter to select a
  file or directory and the last is used to get a name for the Plugin to select the
  right one.
  <PRE class="code" ALIGN="left">
  public FileManager createFileManager() {
        return new FileManagerImpl( this );
  }
  public FileFilter getFileFilter() {
        return this;
  }
  public String toString() {
        return "Plane Pane XML";
  }
  </PRE>
  </LI>
  </UL>
  </DIV>
  <H4>FileManagerImpl</H4>
  <DIV class="para" ALIGN="left">
  Implements the com.dreambean.ejx.FileManager and enables the plugin
  to decide what GUI element to display. For each file or directory selected
  a new instance of this class is created.
  <UL>
  <LI>
  Classes to be imported
  <PRE class="code" ALIGN="left">
  import java.awt.BorderLayout;
  import java.awt.Component;
  import java.beans.beancontext.BeanContextServicesSupport;
  import java.io.File;
  import javax.swing.JPanel;
  import javax.swing.JLabel;
  
  import com.dreambean.ejx.FileManager;
  import com.dreambean.ejx.FileManagerFactory;
  </PRE>
  I am only so pitty about what classes are imported to show you at the
  header where the used classes are coming from.
  </LI>
  <LI>
  Constructor of the class:
  <PRE class="code" ALIGN="left">
  FileManagerImpl( FileManagerFactory pCaller ) {
        mFactory = pCaller;
  }
  </PRE>
  </LI>
  <LI>
  Methods must be overwriten by the class, The important part is the
  getComponent() method which is called by the EJX framework to get
  the GUI component to be displayed.
  <PRE class="code" ALIGN="left">
  public boolean isChanged() {
        return true;
  }
  public void createNew() {
  }
  public void load( File file )
        throws Exception
  {
  }
  public void save( File f )
        throws Exception
  {
  }
  public File getFile() {
        return null;
  }
  public void setFile( File pFile ) {
  }
  public FileManagerFactory getFactory() {
        return mFactory;
  }
  public Component getComponent() {
        JPanel lPane = new JPanel( new BorderLayout() );
        lPane.add(
                new JLabel( &quot;&lt;HTML&gt;&lt;BODY&gt;&lt;H1&gt;Hello 
World&lt;/H1&gt;&quot; +
                        &quot;&lt;H2&gt;Next 
Step&lt;/H2&gt;&lt;/BODY&gt;&lt;/HTML&gt;&quot; ), 
                BorderLayout.CENTER
        );
        return lPane;
  }
  </PRE>
  </LI>
  </UL>
  </DIV>
  <H3>Simple Component Example</A></H3>
  <DIV class="para" ALIGN="left">
  This example is an introduction to AWT and how it can be used to define a GUI by the
  XML description file, compiled and display on the Panel in the EJX framework. To 
shorten
  the further discussion I only show the important stuff having changed or is new.
  </DIV>
  <DIV class="para" ALIGN="left">
  The only thing with AWT you have to consider is that you have to use XMLBeans to 
compile
  the BeanInfo XML description into a Java class and then to compile it to a java 
bytecode
  class. For that have a look at the build.xml and look for xmlbeans.
  </DIV>
  <DIV class="para" ALIGN="left">
  According to the AWT spec the only necessary thing you have to to is:
  <OL>
  <LI>
  Create an Bean Info XML description file like this:
  <PRE class="code" ALIGN="left">
  &lt;bean 
        class=&quot;com.madplanet.simpleComponent.MainPane&quot;
        displayname=&quot;Simple Component's Main Pane&quot;
        iconcolor16=&quot;/images/container.gif&quot;&gt;
        
        &lt;property 
                name=&quot;FirstProperty&quot; class=&quot;java.lang.String&quot; 
                displayname=&quot;First Property&quot;/&gt;
        
        &lt;property 
                name=&quot;SecondProperty&quot; class=&quot;java.lang.String&quot; 
                displayname=&quot;Second Property&quot;/&gt;
        </bean>
  </PRE>
  </LI>
  <LI>
  Create a GUI component class and add the GenericCustomizer to it (as parameter
  you have to pass the class instance which is referred above (here it is
  com.madplanet.singleComponent.MainPane). There are other classes you can use
  but at the moment I have no more informations.
  </LI>
  <LI>
  Compile all the java classes
  </LI>
  <LI>
  User XMLBeans to create the java sourcecode from the XML beaninfo. The newly
  created java classes are named like the referred class but with Beaninfo at
  the end (same package structure).
  </LI>
  <LI>
  Compile the bean info java sourcecode files.
  </LI>
  </OL>
  That's it. 
  </DIV>
  <H4>FileManagerImpl</H4>
  <DIV class="para" ALIGN="left">
  Like the one before except the getComponent() method:
  <PRE class="code" ALIGN="left">
  public Component getComponent() {
        // Create the Property Container and return its GUI component
        return new MainPane().getComponent();
  }
  </PRE>
  </DIV>
  <H4>MainPane</H4>
  <DIV class="para" ALIGN="left">
  This class now creates the GUI component using AWT to display the properties
  this class have.
  <UL>
  <LI>
  Classes to be imported
  <PRE class="code" ALIGN="left">
  import java.awt.BorderLayout;
  import java.awt.Component;
  import java.beans.beancontext.BeanContextSupport;
  import java.beans.beancontext.BeanContextChildComponentProxy;
  import javax.swing.JPanel;
  
  import com.dreambean.awt.GenericCustomizer;
  </PRE>
  </LI>
  <LI>
  This class has to supclass the BeanContextSupport
  <PRE class="code" ALIGN="left">
  public class MainPane
     extends BeanContextSupport
  </PRE>
  </LI>
  <LI>
  There are the properties the Main Pane offer and which can
  then be set by GUI component defined by the Bean Context
  <B>Attention:</B> All the properties in the BeanInfo XML file need
  here a public getter and setter method with the appropriate
  type.
  <PRE class="code" ALIGN="left">
  public String getFirstProperty() {
        return mFirstProperty;
  }
  public void setFirstProperty( String pToSet ) {
        mFirstProperty = pToSet;
  }
  public String getSecondProperty() {
        return mSecondProperty;
  }
  public void setSecondProperty( String pToSet ) {
        mSecondProperty = pToSet;
  }
  </PRE>
  </LI>
  <LI>
  This method returns the GUI component which contains the Generic
  Customizer need to display the properties of this instance accordingly
  to the Bean Info XML description mentioned above.
  <PRE class="code" ALIGN="left">
  public Component getComponent() {
        JPanel lPane = new JPanel( new BorderLayout() );
        lPane.add(
                new GenericCustomizer( this ),
                BorderLayout.CENTER
        );
        return lPane;
  }
  </PRE>
  </LI>
  </UL>
  Eh voil�, that's it. When you build this example, start EJX and select
  Simple Component XML you will see two lines with the tag "First Property"
  and a Text Field (and also for Second Property).
  </DIV>
  <DIV class="para" ALIGN="left">
  That's all for now. In the next step I will delf further into AWT and how
  you can use the Bean Info XML description to describe more advanced application.
  In addition I will then use the save() and load() method to load XML files
  which are the persistent part of a plugin.
  </DIV>
  <DIV class="footer" ALIGN="left">
  I anything is wrong or not correct please contact me at
  <A HREF="mailto:[EMAIL PROTECTED]">[EMAIL PROTECTED]</A>.
  Also if you want to know more in detail or have a request for changes in this
  HowTo document.
  </DIV>
  </BODY>
  </HTML>
  
  
  
  

Reply via email to