[jsword-svn] r1163 - in trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop: book book/install desktop

dmsmith at www.crosswire.org dmsmith at www.crosswire.org
Mon Oct 16 18:30:45 MST 2006


Author: dmsmith
Date: 2006-10-16 18:30:30 -0700 (Mon, 16 Oct 2006)
New Revision: 1163

Added:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookIcon.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Librarian.java
Removed:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java
Modified:
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookTreeCellRenderer.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
   trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
Log:
Isolated BibleDesktop's installer so that it can be standalone, allowing it to be re-engineered as an RCP/SWT/JFace application.
Renamed SitesPane to Librarian to make its purpose more obvious.

Deleted: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -1,139 +0,0 @@
-/**
- * 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$
- */
-package org.crosswire.bibledesktop.book;
-
-import javax.swing.Icon;
-import javax.swing.SwingConstants;
-
-import org.crosswire.common.swing.CompositeIcon;
-import org.crosswire.common.swing.GuiUtil;
-import org.crosswire.jsword.book.Book;
-import org.crosswire.jsword.book.BookCategory;
-
-/**
- * Generates the appropriate icon for a book.
- *
- * @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 class BookIcon
-{
-    /**
-     * Static class
-     */
-    private BookIcon()
-    {
-    }
-
-    public static Icon getIcon(Book book)
-    {
-        Icon icon = ICON_OTHER;
-        BookCategory type = book.getBookCategory();
-        if (type.equals(BookCategory.BIBLE))
-        {
-            icon = ICON_BIBLE;
-        }
-        else if (type.equals(BookCategory.COMMENTARY))
-        {
-            icon = ICON_COMNT;
-        }
-        else if (type.equals(BookCategory.DICTIONARY))
-        {
-            icon = ICON_DICT;
-        }
-        else if (type.equals(BookCategory.GLOSSARY))
-        {
-            icon = ICON_GLOSS;
-        }
-        else if (type.equals(BookCategory.DAILY_DEVOTIONS))
-        {
-            icon = ICON_READ;
-        }
-        else
-        {
-            icon = ICON_OTHER;
-        }
-
-        if (book.isQuestionable())
-        {
-            icon = new CompositeIcon(icon, ICON_QUESTIONABLE, SwingConstants.CENTER);
-        }
-
-        if (!book.isSupported())
-        {
-            icon = new CompositeIcon(icon, ICON_UNSUPPORTED, SwingConstants.CENTER);
-        }
-        else if (book.isLocked())
-        {
-            icon = new CompositeIcon(icon, ICON_LOCKED, SwingConstants.CENTER);
-        }
-
-        return icon;
-    }
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_BIBLE = GuiUtil.getIcon("images/book-b16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_COMNT = GuiUtil.getIcon("images/book-c16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_DICT = GuiUtil.getIcon("images/book-d16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_READ = GuiUtil.getIcon("images/book-r16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_GLOSS = GuiUtil.getIcon("images/book-g16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_OTHER = GuiUtil.getIcon("images/book-o16.png"); //$NON-NLS-1$
-
-    /**
-     * The small version icon
-     */
-    private static final Icon ICON_QUESTIONABLE = GuiUtil.getIcon("images/overlay-q16.png"); //$NON-NLS-1$
-
-    /**
-     * An overlay icon
-     */
-    private static final Icon ICON_LOCKED = GuiUtil.getIcon("images/overlay-lock16.png"); //$NON-NLS-1$
-
-    /**
-     * An overlay icon
-     */
-    private static final Icon ICON_UNSUPPORTED = GuiUtil.getIcon("images/overlay-x16.png"); //$NON-NLS-1$
-
-}

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookListCellRenderer.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -30,6 +30,7 @@
 import javax.swing.UIManager;
 import javax.swing.border.Border;
 
+import org.crosswire.bibledesktop.book.install.BookIcon;
 import org.crosswire.jsword.book.Book;
 
 /**

Copied: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookIcon.java (from rev 1155, trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java)
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/BookIcon.java	2006-10-10 23:34:40 UTC (rev 1155)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookIcon.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -0,0 +1,139 @@
+/**
+ * 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$
+ */
+package org.crosswire.bibledesktop.book.install;
+
+import javax.swing.Icon;
+import javax.swing.SwingConstants;
+
+import org.crosswire.common.swing.CompositeIcon;
+import org.crosswire.common.swing.GuiUtil;
+import org.crosswire.jsword.book.Book;
+import org.crosswire.jsword.book.BookCategory;
+
+/**
+ * Generates the appropriate icon for a book.
+ *
+ * @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 class BookIcon
+{
+    /**
+     * Static class
+     */
+    private BookIcon()
+    {
+    }
+
+    public static Icon getIcon(Book book)
+    {
+        Icon icon = ICON_OTHER;
+        BookCategory type = book.getBookCategory();
+        if (type.equals(BookCategory.BIBLE))
+        {
+            icon = ICON_BIBLE;
+        }
+        else if (type.equals(BookCategory.COMMENTARY))
+        {
+            icon = ICON_COMNT;
+        }
+        else if (type.equals(BookCategory.DICTIONARY))
+        {
+            icon = ICON_DICT;
+        }
+        else if (type.equals(BookCategory.GLOSSARY))
+        {
+            icon = ICON_GLOSS;
+        }
+        else if (type.equals(BookCategory.DAILY_DEVOTIONS))
+        {
+            icon = ICON_READ;
+        }
+        else
+        {
+            icon = ICON_OTHER;
+        }
+
+        if (book.isQuestionable())
+        {
+            icon = new CompositeIcon(icon, ICON_QUESTIONABLE, SwingConstants.CENTER);
+        }
+
+        if (!book.isSupported())
+        {
+            icon = new CompositeIcon(icon, ICON_UNSUPPORTED, SwingConstants.CENTER);
+        }
+        else if (book.isLocked())
+        {
+            icon = new CompositeIcon(icon, ICON_LOCKED, SwingConstants.CENTER);
+        }
+
+        return icon;
+    }
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_BIBLE = GuiUtil.getIcon("images/book-b16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_COMNT = GuiUtil.getIcon("images/book-c16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_DICT = GuiUtil.getIcon("images/book-d16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_READ = GuiUtil.getIcon("images/book-r16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_GLOSS = GuiUtil.getIcon("images/book-g16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_OTHER = GuiUtil.getIcon("images/book-o16.png"); //$NON-NLS-1$
+
+    /**
+     * The small version icon
+     */
+    private static final Icon ICON_QUESTIONABLE = GuiUtil.getIcon("images/overlay-q16.png"); //$NON-NLS-1$
+
+    /**
+     * An overlay icon
+     */
+    private static final Icon ICON_LOCKED = GuiUtil.getIcon("images/overlay-lock16.png"); //$NON-NLS-1$
+
+    /**
+     * An overlay icon
+     */
+    private static final Icon ICON_UNSUPPORTED = GuiUtil.getIcon("images/overlay-x16.png"); //$NON-NLS-1$
+
+}


Property changes on: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookIcon.java
___________________________________________________________________
Name: svn:keywords
   + Author Date Id Revision
Name: svn:eol-style
   + native

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookTreeCellRenderer.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookTreeCellRenderer.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/BookTreeCellRenderer.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -24,7 +24,6 @@
 import javax.swing.JTree;
 import javax.swing.tree.DefaultTreeCellRenderer;
 
-import org.crosswire.bibledesktop.book.BookIcon;
 import org.crosswire.jsword.book.Book;
 
 /**

Copied: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Librarian.java (from rev 1161, trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java)
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java	2006-10-15 22:37:25 UTC (rev 1161)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Librarian.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -0,0 +1,269 @@
+/**
+ * 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$
+ */
+package org.crosswire.bibledesktop.book.install;
+
+import java.awt.BorderLayout;
+import java.awt.Component;
+import java.awt.Dimension;
+import java.awt.FlowLayout;
+import java.awt.event.WindowAdapter;
+import java.awt.event.WindowEvent;
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.swing.BorderFactory;
+import javax.swing.JButton;
+import javax.swing.JDialog;
+import javax.swing.JOptionPane;
+import javax.swing.JPanel;
+import javax.swing.JTabbedPane;
+
+import org.crosswire.common.progress.swing.JobsProgressBar;
+import org.crosswire.common.swing.ActionFactory;
+import org.crosswire.jsword.book.install.InstallManager;
+import org.crosswire.jsword.book.install.Installer;
+import org.crosswire.jsword.book.install.InstallerEvent;
+import org.crosswire.jsword.book.install.InstallerListener;
+
+/**
+ * A Librarian manages library sites.
+ * <p>so start one of these call:
+ * <pre>
+ * librarian = new Librarian();
+ * librarian.showInDialog(parent);
+ * </pre>
+ *
+ * @see gnu.gpl.License for license details.
+ *      The copyright to this program is held by it's authors.
+ * @author Joe Walker [joe at eireneh dot com]
+ */
+public class Librarian extends JPanel
+{
+    /**
+     * Simple ctor
+     */
+    public Librarian()
+    {
+        init();
+
+        imanager = new InstallManager();
+        installers = imanager.getInstallers();
+
+        addAllInstallers();
+
+        imanager.addInstallerListener(new SiteInstallerListener());
+    }
+
+    /**
+     * Build the GUI components
+     */
+    private void init()
+    {
+        actions = new ActionFactory(Librarian.class, this);
+
+        tabMain = new JTabbedPane();
+        this.setLayout(new BorderLayout());
+        this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
+        this.add(tabMain, BorderLayout.CENTER);
+        this.add(new JobsProgressBar(true), BorderLayout.SOUTH);
+    }
+
+    /**
+     * Re-create the list of installers
+     */
+    protected final void addAllInstallers()
+    {
+        // Now add panels for book installation sites
+        Iterator iter = installers.keySet().iterator();
+        while (iter.hasNext())
+        {
+            String name = (String) iter.next();
+            Installer installer = (Installer) installers.get(name);
+
+            SitePane site = new SitePane(installer);
+            tabMain.add(name, site);
+        }
+
+        // Add the panel for the locally installed books
+        tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
+    }
+
+    /**
+     * Remove all the non-local installers
+     */
+    protected void removeAllInstallers()
+    {
+        tabMain.removeAll();
+    }
+
+    /**
+     * Add a site to the list of install sources.
+     */
+    public void doManageSites()
+    {
+        EditSitePane edit = new EditSitePane(imanager);
+        edit.showInDialog(this);
+    }
+
+    /**
+     * We are done, close the window
+     */
+    public void doSitesClose()
+    {
+        if (dlgMain != null)
+        {
+            dlgMain.setVisible(false);
+        }
+    }
+
+    /**
+     * Open this Panel in it's own dialog box.
+     */
+    public void showInDialog(Component parent)
+    {
+        dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
+        dlgMain.setSize(new Dimension(750, 500));
+        dlgMain.getContentPane().setLayout(new BorderLayout());
+        dlgMain.getContentPane().add(this, BorderLayout.CENTER);
+        dlgMain.getContentPane().add(createButtons(), BorderLayout.SOUTH);
+        dlgMain.setTitle(Msg.AVAILABLE_BOOKS.toString());
+        dlgMain.setResizable(true);
+        //dlgMain.setModal(true);
+        dlgMain.addWindowListener(new WindowAdapter()
+        {
+            /* (non-Javadoc)
+             * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
+             */
+            /* @Override */
+            public void windowClosed(WindowEvent ev)
+            {
+                doSitesClose();
+            }
+        });
+        dlgMain.setLocationRelativeTo(parent);
+        dlgMain.setVisible(true);
+        dlgMain.toFront();
+    }
+
+    /**
+     *
+     */
+    private Component createButtons()
+    {
+        if (pnlButtons == null)
+        {
+            JButton btnOK = new JButton(actions.getAction(CLOSE));
+
+            JButton btnAdd = new JButton(actions.getAction(EDIT_SITE));
+
+            pnlButtons = new JPanel();
+            pnlButtons.setLayout(new FlowLayout(FlowLayout.RIGHT));
+            pnlButtons.add(btnAdd, null);
+            pnlButtons.add(btnOK);
+        }
+        return pnlButtons;
+
+    }
+
+    /**
+     * Serialization support.
+     * 
+     * @param is
+     * @throws IOException
+     * @throws ClassNotFoundException
+     */
+    private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
+    {
+        actions = new ActionFactory(Librarian.class, this);
+        imanager = new InstallManager();
+        installers = imanager.getInstallers();
+
+        is.defaultReadObject();
+
+        addAllInstallers();
+
+        imanager.addInstallerListener(new SiteInstallerListener());
+    }
+
+    /**
+     * Local listener for install events.
+     */
+    class SiteInstallerListener implements InstallerListener
+    {
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.install.InstallerListener#installerAdded(org.crosswire.jsword.book.install.InstallerEvent)
+         */
+        public void installerAdded(InstallerEvent ev)
+        {
+            Installer installer = ev.getInstaller();
+            String name = imanager.getInstallerNameForInstaller(installer);
+
+            SitePane site = new SitePane(installer);
+            tabMain.add(name, site);
+        }
+
+        /* (non-Javadoc)
+         * @see org.crosswire.jsword.book.install.InstallerListener#installerRemoved(org.crosswire.jsword.book.install.InstallerEvent)
+         */
+        public void installerRemoved(InstallerEvent ev)
+        {
+            // This gets tricky because if you add a site with a new name
+            // but the same details as an old one, then the old name goes
+            // so we can't get the old name to remove it's tab (and anyway
+            // we would have to do a search through all the tabs to find it
+            // by name)
+            // So we just nuke all the tabs and re-create them
+            removeAllInstallers();
+            addAllInstallers();
+        }
+    }
+
+    private static final String CLOSE = "SitesClose"; //$NON-NLS-1$
+    private static final String EDIT_SITE = "ManageSites"; //$NON-NLS-1$
+
+    /**
+     * The known installers fetched from InstallManager
+     */
+    private transient Map installers;
+
+    /**
+     * The current installer
+     */
+    protected transient InstallManager imanager;
+
+    private transient ActionFactory actions;
+
+    /*
+     * GUI Components
+     */
+    private JDialog dlgMain;
+    private JPanel pnlButtons;
+    protected JTabbedPane tabMain;
+
+    /**
+     * Serialization ID
+     */
+    private static final long serialVersionUID = 3258126947069605936L;
+}

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -32,8 +32,8 @@
  */
 final class Msg extends MsgBase
 {
-    static final Msg AVAILABLE_BOOKS = new Msg("SitesPane.AvailableBooks"); //$NON-NLS-1$
-    static final Msg LOCAL_BOOKS = new Msg("SitesPane.Local"); //$NON-NLS-1$
+    static final Msg AVAILABLE_BOOKS = new Msg("Librarian.AvailableBooks"); //$NON-NLS-1$
+    static final Msg LOCAL_BOOKS = new Msg("Librarian.Local"); //$NON-NLS-1$
 
     static final Msg KB_SIZE = new Msg("SitePane.KBSize"); //$NON-NLS-1$
     static final Msg MB_SIZE = new Msg("SitePane.MBSize"); //$NON-NLS-1$

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/Msg.properties	2006-10-17 01:30:30 UTC (rev 1163)
@@ -9,8 +9,8 @@
 BookChooser.OK=OK
 BookChooser.Title=Select a Bible
 
-SitesPane.AvailableBooks=Available Books
-SitesPane.Local=Installed Books
+Librarian.AvailableBooks=Available Books
+Librarian.Local=Installed Books
 
 SitePane.KBSize={0} is {1,number,###,###,###.#}KB. Continue?
 SitePane.MBSize={0} is {1,number,###,###,###.#}MB. Continue?

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitePane.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -62,7 +62,7 @@
 import org.crosswire.jsword.index.IndexManagerFactory;
 
 /**
- * A panel for use within a SitesPane to display one set of Books that are
+ * A panel for use within a Librarian to display one set of Books that are
  * installed or could be installed.
  *
  * @see gnu.gpl.License for license details.

Deleted: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/book/install/SitesPane.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -1,270 +0,0 @@
-/**
- * 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$
- */
-package org.crosswire.bibledesktop.book.install;
-
-import java.awt.BorderLayout;
-import java.awt.Component;
-import java.awt.Dimension;
-import java.awt.FlowLayout;
-import java.awt.event.WindowAdapter;
-import java.awt.event.WindowEvent;
-import java.io.IOException;
-import java.io.ObjectInputStream;
-import java.util.Iterator;
-import java.util.Map;
-
-import javax.swing.BorderFactory;
-import javax.swing.JButton;
-import javax.swing.JDialog;
-import javax.swing.JOptionPane;
-import javax.swing.JPanel;
-import javax.swing.JTabbedPane;
-
-import org.crosswire.common.progress.swing.JobsProgressBar;
-import org.crosswire.common.swing.ActionFactory;
-import org.crosswire.jsword.book.install.InstallManager;
-import org.crosswire.jsword.book.install.Installer;
-import org.crosswire.jsword.book.install.InstallerEvent;
-import org.crosswire.jsword.book.install.InstallerListener;
-
-/**
- * A panel for use within a SitesPane to display one set of Books that are
- * installed or could be installed.
- * <p>so start one of these call:
- * <pre>
- * sites = new SitesPane();
- * sites.showInDialog(parent);
- * </pre>
- *
- * @see gnu.gpl.License for license details.
- *      The copyright to this program is held by it's authors.
- * @author Joe Walker [joe at eireneh dot com]
- */
-public class SitesPane extends JPanel
-{
-    /**
-     * Simple ctor
-     */
-    public SitesPane()
-    {
-        init();
-
-        imanager = new InstallManager();
-        installers = imanager.getInstallers();
-
-        addAllInstallers();
-
-        imanager.addInstallerListener(new SiteInstallerListener());
-    }
-
-    /**
-     * Build the GUI components
-     */
-    private void init()
-    {
-        actions = new ActionFactory(SitesPane.class, this);
-
-        tabMain = new JTabbedPane();
-        this.setLayout(new BorderLayout());
-        this.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
-        this.add(tabMain, BorderLayout.CENTER);
-        this.add(new JobsProgressBar(true), BorderLayout.SOUTH);
-    }
-
-    /**
-     * Re-create the list of installers
-     */
-    protected final void addAllInstallers()
-    {
-        // Now add panels for book installation sites
-        Iterator iter = installers.keySet().iterator();
-        while (iter.hasNext())
-        {
-            String name = (String) iter.next();
-            Installer installer = (Installer) installers.get(name);
-
-            SitePane site = new SitePane(installer);
-            tabMain.add(name, site);
-        }
-
-        // Add the panel for the locally installed books
-        tabMain.add(Msg.LOCAL_BOOKS.toString(), new SitePane());
-    }
-
-    /**
-     * Remove all the non-local installers
-     */
-    protected void removeAllInstallers()
-    {
-        tabMain.removeAll();
-    }
-
-    /**
-     * Add a site to the list of install sources.
-     */
-    public void doManageSites()
-    {
-        EditSitePane edit = new EditSitePane(imanager);
-        edit.showInDialog(this);
-    }
-
-    /**
-     * We are done, close the window
-     */
-    public void doSitesClose()
-    {
-        if (dlgMain != null)
-        {
-            dlgMain.setVisible(false);
-        }
-    }
-
-    /**
-     * Open this Panel in it's own dialog box.
-     */
-    public void showInDialog(Component parent)
-    {
-        dlgMain = new JDialog(JOptionPane.getFrameForComponent(parent));
-        dlgMain.setSize(new Dimension(750, 500));
-        dlgMain.getContentPane().setLayout(new BorderLayout());
-        dlgMain.getContentPane().add(this, BorderLayout.CENTER);
-        dlgMain.getContentPane().add(createButtons(), BorderLayout.SOUTH);
-        dlgMain.setTitle(Msg.AVAILABLE_BOOKS.toString());
-        dlgMain.setResizable(true);
-        //dlgMain.setModal(true);
-        dlgMain.addWindowListener(new WindowAdapter()
-        {
-            /* (non-Javadoc)
-             * @see java.awt.event.WindowListener#windowClosed(java.awt.event.WindowEvent)
-             */
-            /* @Override */
-            public void windowClosed(WindowEvent ev)
-            {
-                doSitesClose();
-            }
-        });
-        dlgMain.setLocationRelativeTo(parent);
-        dlgMain.setVisible(true);
-        dlgMain.toFront();
-    }
-
-    /**
-     *
-     */
-    private Component createButtons()
-    {
-        if (pnlButtons == null)
-        {
-            JButton btnOK = new JButton(actions.getAction(CLOSE));
-
-            JButton btnAdd = new JButton(actions.getAction(EDIT_SITE));
-
-            pnlButtons = new JPanel();
-            pnlButtons.setLayout(new FlowLayout(FlowLayout.RIGHT));
-            pnlButtons.add(btnAdd, null);
-            pnlButtons.add(btnOK);
-        }
-        return pnlButtons;
-
-    }
-
-    /**
-     * Serialization support.
-     * 
-     * @param is
-     * @throws IOException
-     * @throws ClassNotFoundException
-     */
-    private void readObject(ObjectInputStream is) throws IOException, ClassNotFoundException
-    {
-        actions = new ActionFactory(SitesPane.class, this);
-        imanager = new InstallManager();
-        installers = imanager.getInstallers();
-
-        is.defaultReadObject();
-
-        addAllInstallers();
-
-        imanager.addInstallerListener(new SiteInstallerListener());
-    }
-
-    /**
-     * Local listener for install events.
-     */
-    class SiteInstallerListener implements InstallerListener
-    {
-
-        /* (non-Javadoc)
-         * @see org.crosswire.jsword.book.install.InstallerListener#installerAdded(org.crosswire.jsword.book.install.InstallerEvent)
-         */
-        public void installerAdded(InstallerEvent ev)
-        {
-            Installer installer = ev.getInstaller();
-            String name = imanager.getInstallerNameForInstaller(installer);
-
-            SitePane site = new SitePane(installer);
-            tabMain.add(name, site);
-        }
-
-        /* (non-Javadoc)
-         * @see org.crosswire.jsword.book.install.InstallerListener#installerRemoved(org.crosswire.jsword.book.install.InstallerEvent)
-         */
-        public void installerRemoved(InstallerEvent ev)
-        {
-            // This gets tricky because if you add a site with a new name
-            // but the same details as an old one, then the old name goes
-            // so we can't get the old name to remove it's tab (and anyway
-            // we would have to do a search through all the tabs to find it
-            // by name)
-            // So we just nuke all the tabs and re-create them
-            removeAllInstallers();
-            addAllInstallers();
-        }
-    }
-
-    private static final String CLOSE = "SitesClose"; //$NON-NLS-1$
-    private static final String EDIT_SITE = "ManageSites"; //$NON-NLS-1$
-
-    /**
-     * The known installers fetched from InstallManager
-     */
-    private transient Map installers;
-
-    /**
-     * The current installer
-     */
-    protected transient InstallManager imanager;
-
-    private transient ActionFactory actions;
-
-    /*
-     * GUI Components
-     */
-    private JDialog dlgMain;
-    private JPanel pnlButtons;
-    protected JTabbedPane tabMain;
-
-    /**
-     * Serialization ID
-     */
-    private static final long serialVersionUID = 3258126947069605936L;
-}

Modified: trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java
===================================================================
--- trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2006-10-17 01:28:02 UTC (rev 1162)
+++ trunk/bibledesktop/src/main/java/org/crosswire/bibledesktop/desktop/DesktopActions.java	2006-10-17 01:30:30 UTC (rev 1163)
@@ -33,7 +33,7 @@
 import javax.swing.ToolTipManager;
 
 import org.crosswire.bibledesktop.book.BibleViewPane;
-import org.crosswire.bibledesktop.book.install.SitesPane;
+import org.crosswire.bibledesktop.book.install.Librarian;
 import org.crosswire.bibledesktop.display.BookDataDisplay;
 import org.crosswire.bibledesktop.display.splitlist.SplitBookDataDisplay;
 import org.crosswire.bibledesktop.display.tab.TabbedBookDataDisplay;
@@ -92,13 +92,13 @@
     /**
      * @return the Bible installer dialog
      */
-    public SitesPane getSites()
+    public Librarian getLibrarian()
     {
-        if (sites == null)
+        if (librarian == null)
         {
-            sites = new SitesPane();
+            librarian = new Librarian();
         }
-        return sites;
+        return librarian;
     }
 
     /**
@@ -378,11 +378,11 @@
     }
 
     /**
-     * Opens the Book installer window (aka a SitesPane)
+     * Opens the Book installer window (aka a Librarian)
      */
     public void doBooks()
     {
-        getSites().showInDialog(getDesktop());
+        getLibrarian().showInDialog(getDesktop());
     }
 
     /**
@@ -525,5 +525,5 @@
     /**
      * The Book installer window
      */
-    private SitesPane sites;
+    private Librarian librarian;
 }




More information about the jsword-svn mailing list