User: andreas 
  Date: 00/10/14 09:16:56

  Added:       examples/simple.component/src/com/madplanet/simpleComponent
                        FileManagerFactoryImpl.java FileManagerImpl.java
                        MainPane.java
  Log:
  Add two new examples taken from Andreas Schaefer's
  HowTo page.
  The plain.pane is just shows how to bring a simple pane
  up and running and the simple component shows how
  to use XMLBeans to create a Bean component.
  
  Revision  Changes    Path
  1.1                  
ejx/examples/simple.component/src/com/madplanet/simpleComponent/FileManagerFactoryImpl.java
  
  Index: FileManagerFactoryImpl.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package com.madplanet.simpleComponent;
  
  import java.io.File;
  import javax.swing.filechooser.FileFilter;
  
  import com.dreambean.ejx.FileManager;
  import com.dreambean.ejx.FileManagerFactory;
  
  /**
  * FileManagerFactory implemenation which allows EJX
  * plugin to select an existing file or create one in the
  * given directory.
  * <BR>
  * The purpose of this class is to deliver a file filter to
  * select a file and to create a file manage implemenation
  * when the file is selected or a directory to put the new
  * file into.
  *      
  * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  * @version $Revision: 1.1 $
  **/
  public class FileManagerFactoryImpl
        extends FileFilter
        implements FileManagerFactory
  {
        // Public --------------------------------------------------------
        
        // FileFilter implementation -------------------------------------
        public boolean accept(File f)
        {
                return f.getName().equals( "simple.component.xml" ) || f.isDirectory();
        }
        
        public String getDescription() { 
                return toString(); 
        }
  
        // FileManagerFactory implementation -----------------------------
        public FileManager createFileManager() {
                return new FileManagerImpl( this );
        }
        
        public FileFilter getFileFilter() {
                return this;
        }
        
        public String toString() {
                return "Simple Component XML";
        }
  }
  
  
  
  1.1                  
ejx/examples/simple.component/src/com/madplanet/simpleComponent/FileManagerImpl.java
  
  Index: FileManagerImpl.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package com.madplanet.simpleComponent;
  
  import java.awt.BorderLayout;
  import java.awt.Component;
  import java.beans.beancontext.BeanContextServicesSupport;
  import java.io.File;
  
  import com.dreambean.ejx.FileManager;
  import com.dreambean.ejx.FileManagerFactory;
  
  /**
  * FileManager handles the load and save of a given file
  * and create a new GUI component to display in EJX
  * when EJX is asking for.
  *      
  * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  * @version $Revision: 1.1 $
  **/
  public class FileManagerImpl
        extends BeanContextServicesSupport
        implements FileManager
  {
        // Attributes ----------------------------------------------------
        /** The factory which created this instance **/
        private FileManagerFactory mFactory;
        
        // Constructors --------------------------------------------------
        /**
        * Creates this file manager and store the Factory created
        * this instance
        *
        * @param pCaller                                        File Manager Factory 
created this instance
        **/
        FileManagerImpl( FileManagerFactory pCaller ) {
                mFactory = pCaller;
        }
        
        // Public --------------------------------------------------------
        
        // FileManager implementation ------------------------------------
        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() {
                // Create the Property Container and return its GUI component
                return new MainPane().getComponent();
        }
  }
  
  
  
  1.1                  
ejx/examples/simple.component/src/com/madplanet/simpleComponent/MainPane.java
  
  Index: MainPane.java
  ===================================================================
  /*
   * jBoss, the OpenSource EJB server
   *
   * Distributable under GPL license.
   * See terms of license at gnu.org.
   */
  package com.madplanet.simpleComponent;
  
  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;
  
  /**
  * Class containing the Bean Context Support and
  * the viewer GUI component.
  *
  * @author <A href="mailto:[EMAIL PROTECTED]">Andreas "Mad" Schaefer</A>
  * @version $Revision: 1.1 $
  **/
  public class MainPane
     extends BeanContextSupport
  {
        // Constants -----------------------------------------------------
        
        // Attributes ----------------------------------------------------
        private String mFirstProperty = "";
        private String mSecondProperty = "";
        
        // Static --------------------------------------------------------
        
        // Constructors --------------------------------------------------
        public MainPane() {
                super();
        }
        
        // Public --------------------------------------------------------
        /*
        * There are the properties the Main Pane offer and which can
        * then be set by GUI component defined by the Bean Context
        * ATTENTION: All the properties in the BeanInfo XML file need
        * here a public getter and setter method with the appropriate
        * type.
        */
        public String getFirstProperty() {
                return mFirstProperty;
        }
        public void setFirstProperty( String pToSet ) {
                mFirstProperty = pToSet;
        }
        public String getSecondProperty() {
                return mSecondProperty;
        }
        public void setSecondProperty( String pToSet ) {
                mSecondProperty = pToSet;
        }
  
        // BeanContextChildComponentProxy implementation -----------------
        /**
        * Creates and returns the GUI component which is used to display
        * the properties and information of this instance by a Generic
        * Customiser.
        *
        * @return                               GUI Component displaying this instances
        *                                               properties
        **/
        public Component getComponent() {
                JPanel lPane = new JPanel( new BorderLayout() );
                // Init UI
                lPane.add(
                        new GenericCustomizer( this ),
                        BorderLayout.CENTER
                );
                return lPane;
        }
  }
  
  
  

Reply via email to