Changeset 3884


Ignore:
Timestamp:
04/04/08 17:15:27 (12 years ago)
Author:
curtis
Message:
  • First cut at detecting native JAI Image I/O Tools library (untested).
  • Initial skeleton for installation & upgrade wizard.
Location:
trunk/loci/plugins/config
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/config/ConfigWindow.java

    r3868 r3884  
    2727 
    2828import java.awt.Dimension; 
    29 import java.awt.event.ItemEvent; 
    30 import java.awt.event.ItemListener; 
     29import java.awt.event.*; 
    3130import java.lang.reflect.Field; 
    3231import java.lang.reflect.Method; 
    3332import java.io.*; 
    3433import java.util.*; 
     34import javax.imageio.spi.IIORegistry; 
    3535import javax.swing.*; 
    3636import javax.swing.border.EmptyBorder; 
     
    4848 */ 
    4949public class ConfigWindow extends JFrame 
    50   implements ItemListener, ListSelectionListener, Runnable 
     50  implements ActionListener, ItemListener, ListSelectionListener, Runnable 
    5151{ 
     52 
     53  // -- Constants -- 
     54 
     55  private static final int PAD = 5; 
    5256 
    5357  // -- Fields -- 
     
    7781 
    7882    JTabbedPane tabs = new JTabbedPane(); 
    79     tabs.setBorder(new EmptyBorder(3, 3, 3, 3)); 
     83    tabs.setBorder(new EmptyBorder(PAD, PAD, PAD, PAD)); 
    8084    setContentPane(tabs); 
    8185 
    82     JPanel optionsPanel = new JPanel(); 
    83     tabs.addTab("Options", optionsPanel); 
     86    JPanel installPanel = new JPanel(); 
     87    tabs.addTab("Install", installPanel); 
     88 
     89    JButton installButton = new JButton( 
     90      "<html><center><br><font size=\"+1\">Check my system,<br>" + 
     91      "install missing libraries,<br>" + 
     92      "and upgrade old files</font><br>" + 
     93      "<font size=\"-1\">&nbsp;<br>" + 
     94      "(We'll ask before we install or upgrade anything.)" + 
     95      "</font><br>&nbsp;"); 
     96    installButton.addActionListener(this); 
     97    installPanel.add(installButton); 
    8498 
    8599    formatsListModel = new DefaultListModel(); 
     
    155169    logPanel.add(new JScrollPane(logArea)); 
    156170 
    157     SpringUtilities.makeCompactGrid(libInfo, 7, 2, 3, 3, 3, 3); 
    158  
    159     tabs.setSelectedIndex(1); // Formats tab 
     171    SpringUtilities.makeCompactGrid(libInfo, 7, 2, PAD, PAD, PAD, PAD); 
     172 
    160173    pack(); 
    161174 
     
    164177 
    165178    new Thread(this, "ConfigWindow-Loader").start(); 
     179  } 
     180 
     181  // -- ActionListener API methods -- 
     182 
     183  public void actionPerformed(ActionEvent e) { 
     184    new LociInstaller().run(null); 
     185    dispose(); 
    166186  } 
    167187 
     
    252272    } 
    253273 
     274    String clibIIOVersion = null; 
     275    try { 
     276      Class jpegSpi = Class.forName( 
     277        "com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi"); 
     278      IIORegistry registry = IIORegistry.getDefaultInstance(); 
     279      Object jpeg = registry.getServiceProviderByClass(jpegSpi); 
     280      if (jpeg == null) clibIIOVersion = LibraryEntry.MISSING_VERSION_CODE; 
     281    } 
     282    catch (Throwable t) { 
     283      if (t instanceof ClassNotFoundException) { 
     284        // JAI Image I/O Tools library not available 
     285      } 
     286      else { 
     287        log.println("Error determining native Image I/O Tools version:"); 
     288        t.printStackTrace(log); 
     289      } 
     290    } 
     291 
    254292    String matlabVersion = null; 
    255293    try { 
     
    276314    if (bfVersion != null) versions.put("bfVersion", bfVersion); 
    277315    if (qtVersion != null) versions.put("qtVersion", qtVersion); 
     316    if (clibIIOVersion != null) versions.put("clibIIOVersion", clibIIOVersion); 
    278317    if (matlabVersion != null) versions.put("matlabVersion", matlabVersion); 
    279318 
     
    440479    } 
    441480 
    442     SpringUtilities.makeCompactGrid(formatInfo, 2 + rows, 2, 3, 3, 3, 3); 
     481    SpringUtilities.makeCompactGrid(formatInfo, 
     482      2 + rows, 2, PAD, PAD, PAD, PAD); 
    443483 
    444484    formatInfo.validate(); 
  • trunk/loci/plugins/config/LibraryEntry.java

    r3864 r3884  
    4343 
    4444  // -- Constants -- 
     45 
     46  /** Version code to indicate a missing library. */ 
     47  public static final String MISSING_VERSION_CODE = "!"; 
    4548 
    4649  /** HTML markup for installed library. */ 
     
    106109        } 
    107110      } 
     111      else if (version.equals(MISSING_VERSION_CODE)) { 
     112        // we know a priori that this library is not properly installed 
     113        version = null; 
     114        throw new ClassNotFoundException(); 
     115      } 
    108116      this.version = version; 
    109117 
  • trunk/loci/plugins/config/LociConfig.java

    r3864 r3884  
    4747  public void run(String arg) { 
    4848    ConfigWindow cw = new ConfigWindow(); 
    49     Dimension size = cw.getSize(); 
     49    placeWindow(cw); 
     50    cw.setVisible(true); 
     51  } 
     52 
     53  // -- Utility methods -- 
     54 
     55  /** 
     56   * Places the given window at a nice location on screen, either centered 
     57   * below the ImageJ window if there is one, or else centered on screen. 
     58   */ 
     59  public static void placeWindow(Window w) { 
     60    Dimension size = w.getSize(); 
    5061 
    5162    Dimension screen = Toolkit.getDefaultToolkit().getScreenSize(); 
     
    7889    } 
    7990 
    80     cw.setLocation(p); 
    81     cw.setVisible(true); 
     91    w.setLocation(p); 
    8292  } 
    8393 
  • trunk/loci/plugins/config/libraries.txt

    r3860 r3884  
    9696[JAI Image I/O Tools - native codecs] 
    9797type = Native library 
    98 class = TODO 
     98class = com.sun.media.imageioimpl.plugins.jpeg.CLibJPEGImageReaderSpi 
     99version = clibIIOVersion 
    99100url = https://jai-imageio.dev.java.net/ 
    100101license = BSD 
Note: See TracChangeset for help on using the changeset viewer.