[jsword-svn] bibledesktop/java/main/org/crosswire/bibledesktop/book/install s

jswordcvs at crosswire.org jswordcvs at crosswire.org
Sat Sep 10 02:07:09 MST 2005


Update of /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install
In directory www.crosswire.org:/tmp/cvs-serv16921/java/main/org/crosswire/bibledesktop/book/install

Modified Files:
	Msg.java EditSitePane.java Msg.properties 
Added Files:
	SiteEditorFactory.properties SwordSiteEditor.java 
	SiteEditorFactory.java SiteEditor.java 
Log Message:
Replaced BeanPanel with SiteEditor for the Installer.
Added XalanProcess which is useful outside of JSword to transform xml via xslt.
Cleaned up checkstyle complaints.

Index: Msg.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/Msg.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** Msg.java	22 Jun 2005 03:50:49 -0000	1.7
--- Msg.java	10 Sep 2005 09:07:07 -0000	1.8
***************
*** 66,69 ****
--- 66,74 ----
      static final Msg OPTION_CANCEL = new Msg("IndexResolver.OptionCancel"); //$NON-NLS-1$
  
+     static final Msg HOST = new Msg("SwordSiteEditor.Host"); //$NON-NLS-1$
+     static final Msg DIRECTORY = new Msg("SwordSiteEditor.Directory"); //$NON-NLS-1$
+     static final Msg PROXY_HOST = new Msg("SwordSiteEditor.ProxyHost"); //$NON-NLS-1$
+     static final Msg PROXY_PORT = new Msg("SwordSiteEditor.ProxyPort"); //$NON-NLS-1$
+ 
      /**
       * Passthrough ctor

--- NEW FILE: SwordSiteEditor.java ---
/**
 * Distribution License:
 * BibleDesktop is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 2 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/gpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: SwordSiteEditor.java,v 1.1 2005/09/10 09:07:07 dmsmith Exp $
 */
package org.crosswire.bibledesktop.book.install;

import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;

import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;

import org.crosswire.jsword.book.install.Installer;
import org.crosswire.jsword.book.install.sword.AbstractSwordInstaller;

/**
 * A representation of a Sword SiteEditor.
 * 
 * @see gnu.gpl.License
 * @author DM Smith [ dmsmith555 at yahoo dot com]
 * @version $Id: SwordSiteEditor.java,v 1.1 2005/09/10 09:07:07 dmsmith Exp $
 */
public class SwordSiteEditor extends JPanel implements SiteEditor
{
    public void initialize()
    {
        host = new JTextField();
        JLabel hostLabel = getLabelForText(Msg.HOST, host); //$NON-NLS-1$

        directory = new JTextField();
        JLabel directoryLabel = getLabelForText(Msg.DIRECTORY, directory); //$NON-NLS-1$

        proxyHost = new JTextField();
        JLabel proxyHostLabel = getLabelForText(Msg.PROXY_HOST, proxyHost); //$NON-NLS-1$

        proxyPort = new JTextField();
        JLabel proxyPortLabel = getLabelForText(Msg.PROXY_PORT, proxyPort); //$NON-NLS-1$

        setLayout(new GridBagLayout());
        add(hostLabel,      new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 10, 2, 2), 0, 0));
        add(host,           new GridBagConstraints(1, 0, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 10), 0, 0));
        add(directoryLabel, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 10, 2, 2), 0, 0));
        add(directory,      new GridBagConstraints(1, 1, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 10), 0, 0));
        add(proxyHostLabel, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 10, 2, 2), 0, 0));
        add(proxyHost,      new GridBagConstraints(1, 2, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 10), 0, 0));
        add(proxyPortLabel, new GridBagConstraints(0, 3, 1, 1, 0.0, 0.0, GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(2, 10, 2, 2), 0, 0));
        add(proxyPort,      new GridBagConstraints(1, 3, 1, 1, 1.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 10), 0, 0));

        reset();
    }

    /* (non-Javadoc)
     * @see org.crosswire.bibledesktop.book.install.SiteEditor#save()
     */
    public void save()
    {
        installer.setHost(host.getText());
        installer.setDirectory(directory.getText());
        installer.setProxyHost(proxyHost.getText());
        Integer pport = null;
        try
        {
            pport = new Integer(proxyPort.getText());
        }
        catch (NumberFormatException e)
        {
            pport = null; // or -1
        }
        installer.setProxyPort(pport);
    }

    /* (non-Javadoc)
     * @see org.crosswire.bibledesktop.book.install.SiteEditor#reset()
     */
    public void reset()
    {
        if (installer == null)
        {
            return;
        }

        host.setText(installer.getHost());
        directory.setText(installer.getDirectory());
        proxyHost.setText(installer.getProxyHost());
        Integer port = installer.getProxyPort();
        proxyPort.setText(port == null ? null : port.toString());
    }

    /* (non-Javadoc)
     * @see org.crosswire.bibledesktop.book.install.SiteEditor#setEditable(boolean)
     */
    public void setEditable(boolean editable)
    {
        if (host != null)
        {
            host.setEditable(editable);
        }

        if (directory != null)
        {
            directory.setEditable(editable);
        }

        if (proxyHost != null)
        {
            proxyHost.setEditable(editable);
        }

        if (proxyPort != null)
        {
            proxyPort.setEditable(editable);
        }
    }

    /* (non-Javadoc)
     * @see org.crosswire.bibledesktop.book.install.SiteEditor#getInstaller()
     */
    public Installer getInstaller()
    {
        return installer;
    }

    /* (non-Javadoc)
     * @see org.crosswire.bibledesktop.book.install.SiteEditor#setInstaller()
     */
    public void setInstaller(Installer newInstaller)
    {
        assert newInstaller == null || newInstaller instanceof AbstractSwordInstaller;
        Installer old = installer;
        installer = (AbstractSwordInstaller) newInstaller;
        if (newInstaller == null)
        {
            removeAll();
        }
        else if (!newInstaller.equals(old))
        {
            removeAll();
            initialize();
        }
    }

    private JLabel getLabelForText(Msg title, JTextField field)
    {
        JLabel label = new JLabel();
        label.setText(title.toString());
        label.setLabelFor(field);
        return label;
    }

    private AbstractSwordInstaller installer;
    private JTextField host;
    private JTextField directory;
    private JTextField proxyHost;
    private JTextField proxyPort;

    /**
     * Serialization ID
     */
    private static final long serialVersionUID = 3834589894202175795L;

}

--- NEW FILE: SiteEditorFactory.properties ---
sword-ftp=org.crosswire.bibledesktop.book.install.SwordSiteEditor
sword-http=org.crosswire.bibledesktop.book.install.SwordSiteEditor
Index: Msg.properties
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/Msg.properties,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -d -r1.3 -r1.4
*** Msg.properties	22 Mar 2005 12:39:56 -0000	1.3
--- Msg.properties	10 Sep 2005 09:07:07 -0000	1.4
***************
*** 46,47 ****
--- 46,52 ----
  IndexResolver.OptionGenerate=Generate
  IndexResolver.OptionCancel=Cancel
+ 
+ SwordSiteEditor.Host=Host:
+ SwordSiteEditor.Directory=Directory:
+ SwordSiteEditor.ProxyHost=Proxy Host:
+ SwordSiteEditor.ProxyPort=Proxy Port:

--- NEW FILE: SiteEditorFactory.java ---
/**
 * Distribution License:
 * BibleDesktop is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 2 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/gpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: SiteEditorFactory.java,v 1.1 2005/09/10 09:07:07 dmsmith Exp $
 */
package org.crosswire.bibledesktop.book.install;

import java.io.IOException;
import java.util.MissingResourceException;
import java.util.Properties;

import org.crosswire.common.util.ResourceUtil;
import org.crosswire.jsword.book.install.Installer;

/**
 * Factory for SiteEditors.
 * 
 * @see gnu.gpl.License for license details.
 *      The copyright to this program is held by it's authors.
 * @author DM Smith [dmsmith555 at yahoo dot com]
 */
public final class SiteEditorFactory
{
    /**
     * Prevent Use
     */
    private SiteEditorFactory()
    {
    }

    /**
     * Create a new SiteEditor
     */
    public static SiteEditor createSiteEditor(Installer installer)
    {
        try
        {
            Properties properties = ResourceUtil.getProperties(SiteEditorFactory.class);
            String className = properties.getProperty(installer.getType());
            Class clazz = Class.forName(className);
            SiteEditor editor = (SiteEditor) clazz.newInstance();
            editor.setInstaller(installer);
            return editor;
        }
        catch (MissingResourceException e)
        {
            assert false : e;
        }
        catch (IOException e)
        {
            assert false : e;
        }
        catch (ClassNotFoundException e)
        {
            assert false : e;
        }
        catch (InstantiationException e)
        {
            assert false : e;
        }
        catch (IllegalAccessException e)
        {
            assert false : e;
        }
        return null;
    }
}

Index: EditSitePane.java
===================================================================
RCS file: /cvs/jsword/bibledesktop/java/main/org/crosswire/bibledesktop/book/install/EditSitePane.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** EditSitePane.java	21 Aug 2005 20:38:04 -0000	1.10
--- EditSitePane.java	10 Sep 2005 09:07:07 -0000	1.11
***************
*** 32,36 ****
  import java.awt.event.ActionListener;
  import java.awt.event.KeyEvent;
- import java.beans.IntrospectionException;
  
  import javax.swing.BorderFactory;
--- 32,35 ----
***************
*** 56,63 ****
  
  import org.crosswire.common.swing.ActionFactory;
- import org.crosswire.common.swing.BeanPanel;
  import org.crosswire.common.swing.FixedSplitPane;
  import org.crosswire.common.swing.GuiUtil;
- import org.crosswire.common.util.Reporter;
  import org.crosswire.jsword.book.install.InstallManager;
  import org.crosswire.jsword.book.install.Installer;
--- 55,60 ----
***************
*** 174,178 ****
          pnlBtn2.add(btnReset, null);
  
!         pnlBean = new BeanPanel();
          JPanel pnlMain = new JPanel();
          pnlMain.setLayout(new GridBagLayout());
--- 171,175 ----
          pnlBtn2.add(btnReset, null);
  
!         siteEditorPane = new JPanel();
          JPanel pnlMain = new JPanel();
          pnlMain.setLayout(new GridBagLayout());
***************
*** 187,191 ****
          }
          pnlMain.add(new JSeparator(), new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
!         pnlMain.add(pnlBean, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
          pnlMain.add(pnlBtn2, new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  
--- 184,188 ----
          }
          pnlMain.add(new JSeparator(), new GridBagConstraints(0, 3, 2, 1, 0.0, 0.0, GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(10, 10, 10, 10), 0, 0));
!         pnlMain.add(siteEditorPane, new GridBagConstraints(0, 4, 2, 1, 1.0, 1.0, GridBagConstraints.CENTER, GridBagConstraints.BOTH, new Insets(0, 0, 0, 0), 0, 0));
          pnlMain.add(pnlBtn2, new GridBagConstraints(0, 5, 2, 1, 0.0, 0.0, GridBagConstraints.CENTER, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
  
***************
*** 288,292 ****
              Installer installer = ifactory.createInstaller();
  
!             setBean(installer);
          }
      }
--- 285,289 ----
              Installer installer = ifactory.createInstaller();
  
!             setInstaller(installer);
          }
      }
***************
*** 314,318 ****
          // of the bean panel we need to redo it here. Since we are always in
          // display mode at this point, this is fairly easy.
!         pnlBean.setEditable(false);
      }
  
--- 311,318 ----
          // of the bean panel we need to redo it here. Since we are always in
          // display mode at this point, this is fairly easy.
!         if (siteEditor != null)
!         {
!             siteEditor.setEditable(false);
!         }
      }
  
***************
*** 402,407 ****
      {
          String name = txtName.getText();
!         Installer installer = (Installer) pnlBean.getBean();
          imanager.addInstaller(name, installer);
  
          clear();
--- 402,408 ----
      {
          String name = txtName.getText();
!         Installer installer = siteEditor.getInstaller();
          imanager.addInstaller(name, installer);
+         siteEditor.save();
  
          clear();
***************
*** 433,437 ****
              txtName.setEditable(false);
              cboType.setEnabled(false);
!             pnlBean.setEditable(false);
  
              break;
--- 434,442 ----
              txtName.setEditable(false);
              cboType.setEnabled(false);
! 
!             if (siteEditor != null)
!             {
!                 siteEditor.setEditable(false);
!             }
  
              break;
***************
*** 446,450 ****
              actions.getAction(RESET).setEnabled(true);
              actions.getAction(SAVE).setEnabled(state == STATE_EDIT_OK);
-             pnlBean.setEditable(true);
  
              actions.getAction(CLOSE).setEnabled(false);
--- 451,454 ----
***************
*** 452,456 ****
              txtName.setEditable(true);
              cboType.setEnabled(true);
!             pnlBean.setEditable(true);
  
              break;
--- 456,464 ----
              txtName.setEditable(true);
              cboType.setEnabled(true);
! 
!             if (siteEditor != null)
!             {
!                 siteEditor.setEditable(true);
!             }
  
              break;
***************
*** 482,486 ****
          userInitiated = true;
  
!         setBean(installer);
      }
  
--- 490,494 ----
          userInitiated = true;
  
!         setInstaller(installer);
      }
  
***************
*** 490,502 ****
      private void clear()
      {
!         try
!         {
!             txtName.setText(EMPTY_STRING);
!             pnlBean.setBean(null);
!         }
!         catch (IntrospectionException ex)
!         {
!             Reporter.informUser(this, ex);
!         }
      }
  
--- 498,503 ----
      private void clear()
      {
!         txtName.setText(EMPTY_STRING);
!         setInstaller(null);
      }
  
***************
*** 506,518 ****
       * @param installer The new installer to introspect
       */
!     private void setBean(Installer installer)
      {
!         try
!         {
!             pnlBean.setBean(installer);
!         }
!         catch (IntrospectionException ex)
          {
!             Reporter.informUser(this, ex);
          }
  
--- 507,518 ----
       * @param installer The new installer to introspect
       */
!     private void setInstaller(Installer installer)
      {
!         siteEditorPane.removeAll();
!         siteEditor = null;
!         if (installer != null)
          {
!             siteEditor = SiteEditorFactory.createSiteEditor(installer);
!             siteEditorPane.add((Component) siteEditor);
          }
  
***************
*** 586,590 ****
      private JTextField txtName;
      private JComboBox cboType;
!     private BeanPanel pnlBean;
  
      /*
--- 586,591 ----
      private JTextField txtName;
      private JComboBox cboType;
!     private JPanel siteEditorPane;
!     private SiteEditor siteEditor;
  
      /*

--- NEW FILE: SiteEditor.java ---
/**
 * Distribution License:
 * BibleDesktop is free software; you can redistribute it and/or modify it under
 * the terms of the GNU General Public License, version 2 as published by
 * the Free Software Foundation. This program is distributed in the hope
 * that it will be useful, but WITHOUT ANY WARRANTY; without even the
 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 * See the GNU General Public License for more details.
 *
 * The License is available on the internet at:
 *       http://www.gnu.org/copyleft/gpl.html
 * or by writing to:
 *      Free Software Foundation, Inc.
 *      59 Temple Place - Suite 330
 *      Boston, MA 02111-1307, USA
 *
 * Copyright: 2005
 *     The copyright to this program is held by it's authors.
 *
 * ID: $Id: SiteEditor.java,v 1.1 2005/09/10 09:07:07 dmsmith Exp $
 */
package org.crosswire.bibledesktop.book.install;

import org.crosswire.jsword.book.install.Installer;

/**
 * A SiteEditor allows for the editing of a site.
 * 
 * @see gnu.gpl.License
 * @author DM Smith [dmsmith555 at yahoo dot com]
 */
public interface SiteEditor
{
    /**
     * Establish the installer for this SiteEditor.
     * @param newInstaller
     */
    void setInstaller(Installer newInstaller);

    /**
     * Get the installer associated with this SiteEditor
     * @return the installer
     */
    Installer getInstaller();

    /**
     * Change the Editable state of this SiteEditor.
     * @param editable
     */
    void setEditable(boolean editable);

    /**
     * Save the state of this SiteEditor.
     */
    void save();

    /**
     * Set the state of this SiteEditor to the last save.
     */
    void reset();
}



More information about the jsword-svn mailing list