Changeset 3856


Ignore:
Timestamp:
03/28/08 15:39:06 (12 years ago)
Author:
curtis
Message:

First cut at interface for individual formats' custom widgets.

Location:
trunk/loci/plugins/config
Files:
6 added
3 edited

Legend:

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

    r3855 r3856  
    4848 
    4949  private JList formatsList; 
     50  private JPanel formatInfo; 
    5051  private JTextField extensions; 
    5152  private JCheckBox enabled; 
     
    8687    String javaVersion = System.getProperty("java.version") + 
    8788      " (" + System.getProperty("java.vendor") + ")"; 
     89 
     90    String bfVersion = "@date@"; 
     91    // Ant replaces date token with datestamp of the build 
     92    if (bfVersion.equals("@" + "date" + "@")) bfVersion = "Internal build"; 
    8893 
    8994    String qtVersion = null; 
     
    154159        "You can toggle which mode is used " + 
    155160        "in the Formats tab's \"QuickTime\" entry."), 
    156       new LibraryEntry("JAI Image I/O Tools (native)", libNative, 
     161      new LibraryEntry("JAI Image I/O Tools - native codecs", libNative, 
    157162        "TODO", null, 
    158163        "https://jai-imageio.dev.java.net/", "BSD", 
     
    167172      // ImageJ plugins 
    168173      new LibraryEntry("LOCI plugins", libPlugin, 
    169         "loci.plugins.About", "@date@", // loci_plugins.jar 
     174        "loci.plugins.About", bfVersion, // loci_plugins.jar 
    170175        "http://www.loci.wisc.edu/ome/formats.html", "LGPL", 
    171176        "LOCI Plugins for ImageJ: a collection of ImageJ plugins including " + 
     
    185190      // Java libraries 
    186191      new LibraryEntry("Bio-Formats", libJava, 
    187         "loci.formats.IFormatReader", "@date@", // bio-formats.jar 
     192        "loci.formats.IFormatReader", bfVersion, // bio-formats.jar 
    188193        "http://www.loci.wisc.edu/ome/formats.html", "LGPL", 
    189194        "LOCI Bio-Formats package for reading and converting " + 
     
    193198        "http://www.unidata.ucar.edu/software/decoders/", "LGPL", 
    194199        "Used by the NetCDF Java library."), 
    195       new LibraryEntry("TODO clib", libJava, 
     200      new LibraryEntry("JAI Image I/O Tools - Java wrapper", libJava, 
    196201        "com.sun.medialib.codec.jiio.Constants", null, // clibwrapper_jiio.jar 
    197202        "https://jai-imageio.dev.java.net/", "BSD", 
    198         "Java wrapper for JAI Image I/O Tools native library."), 
     203        "Java wrapper for JAI Image I/O Tools native codecs."), 
    199204      new LibraryEntry("GRIB Java Decoder", libJava, 
    200205        "ucar.grib.GribChecker", null, // grib-5.1.03.jar 
    201206        "http://www.unidata.ucar.edu/software/decoders/", "LGPL", 
    202207        "Used by the NetCDF Java library."), 
    203       new LibraryEntry("JAI Image I/O Tools (Java)", libJava, 
     208      new LibraryEntry("JAI Image I/O Tools - Java codecs", libJava, 
    204209        "com.sun.media.imageio.plugins.jpeg2000.J2KImageReadParam", 
    205210        null, // jai_imageio.jar 
     
    211216        "Used by Bio-Formats for Zeiss LSM metadata in MDB database files."), 
    212217      new LibraryEntry("NetCDF Java", libJava, 
    213         "TODO", null, // netcdf-4.0.jar 
     218        "ucar.nc2.NetcdfFile", null, // netcdf-4.0.jar 
    214219        "http://www.unidata.ucar.edu/software/netcdf-java/", "LGPL", 
    215220        "Used by Bio-Formats for HDF support (Imaris 5.5)."), 
     
    264269      new LibraryEntry("OME Notes", libJava, 
    265270        "loci.ome.notes.Notes", null, // ome-notes.jar 
    266         "http://www.loci.wisc.edu/ome/notes.html", "LGPL", "TODO"), 
     271        "http://www.loci.wisc.edu/ome/notes.html", "LGPL", 
     272        "OME Notes library for flexible organization and presentation " + 
     273        "of OME-XML metadata."), 
    267274      new LibraryEntry("LuraWave decoder SDK", libJava, 
    268275        "com.luratech.lwf.lwfDecoder", null, // lwf_jsdk2.6.jar 
     
    283290 
    284291    formatsList = makeList(formats); 
    285     JPanel formatInfo = new JPanel(); 
    286     tabs.addTab("Formats", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
    287       new JScrollPane(formatsList), formatInfo)); 
    288  
    289     formatInfo.setLayout(new SpringLayout()); 
    290  
    291     formatInfo.add(makeLabel("Extensions", false)); 
     292 
     293    formatInfo = new JPanel(); 
     294    tabs.addTab("Formats", makeSplitPane(formatsList, formatInfo)); 
     295 
    292296    extensions = makeTextField(); 
    293     formatInfo.add(extensions); 
    294  
    295     formatInfo.add(makeLabel("Enabled", false)); 
    296297    enabled = new JCheckBox("", false); 
    297     formatInfo.add(enabled); 
    298  
    299     SpringUtilities.makeCompactGrid(formatInfo, 2, 2, 3, 3, 3, 3); 
     298 
     299    doFormatLayout(null); 
    300300 
    301301    // TODO - reader-specific options 
     
    308308    libsList = makeList(libraries); 
    309309    JPanel libInfo = new JPanel(); 
    310     JPanel libsPanel = new JPanel(); 
    311     tabs.addTab("Libraries", new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
    312       new JScrollPane(libsList), libInfo)); 
     310    tabs.addTab("Libraries", makeSplitPane(libsList, libInfo)); 
    313311 
    314312    libInfo.setLayout(new SpringLayout()); 
     
    351349    notes.setWrapStyleWord(true); 
    352350    notes.setLineWrap(true); 
    353     notes.setBorder(license.getBorder()); // match text field border style 
    354     libInfo.add(notes); 
     351    libInfo.add(new JScrollPane(notes)); 
    355352 
    356353    // TODO - "How to install" for each library? 
     
    367364    if (src == formatsList) { 
    368365      FormatEntry entry = (FormatEntry) formatsList.getSelectedValue(); 
    369       StringBuffer sb = new StringBuffer(); 
    370       for (int i=0; i<entry.suffixes.length; i++) { 
    371         if (i > 0) sb.append(", "); 
    372         sb.append(entry.suffixes[i]); 
    373       } 
    374       extensions.setText(sb.toString()); 
    375       enabled.setSelected(true); 
     366      doFormatLayout(entry); 
    376367    } 
    377368    else if (src == libsList) { 
     
    387378  } 
    388379 
     380  // -- Utility methods -- 
     381 
     382  public static JTextField makeTextField() { 
     383    JTextField textField = new JTextField(38); 
     384    int prefHeight = textField.getPreferredSize().height; 
     385    textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prefHeight)); 
     386    textField.setEditable(false); 
     387    return textField; 
     388  } 
     389 
    389390  // -- Helper methods -- 
    390391 
     
    400401    list.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); 
    401402    list.setVisibleRowCount(25); 
    402     list.setPrototypeCellValue("abcdefghijklmnopqrstuvwxyz12345678"); 
    403403    list.addListSelectionListener(this); 
    404404    return list; 
    405405  } 
    406406 
    407   private JTextField makeTextField() { 
    408     JTextField textField = new JTextField(38); 
    409     int prefHeight = textField.getPreferredSize().height; 
    410     textField.setMaximumSize(new Dimension(Integer.MAX_VALUE, prefHeight)); 
    411     textField.setEditable(false); 
    412     return textField; 
     407  private JSplitPane makeSplitPane(JList list, JPanel info) { 
     408    JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, 
     409      new JScrollPane(list), info); 
     410    splitPane.setDividerLocation(260); 
     411    return splitPane; 
     412  } 
     413 
     414  private void doFormatLayout(FormatEntry entry) { 
     415    if (entry != null) { 
     416      // build list of extensions 
     417      StringBuffer sb = new StringBuffer(); 
     418      for (int i=0; i<entry.suffixes.length; i++) { 
     419        if (i > 0) sb.append(", "); 
     420        sb.append(entry.suffixes[i]); 
     421      } 
     422      extensions.setText(sb.toString()); 
     423 
     424      enabled.setSelected(true); 
     425    } 
     426 
     427    formatInfo.removeAll(); 
     428    formatInfo.setLayout(new SpringLayout()); 
     429 
     430    formatInfo.add(makeLabel("Extensions", false)); 
     431    formatInfo.add(extensions); 
     432 
     433    formatInfo.add(makeLabel("Enabled", false)); 
     434    formatInfo.add(enabled); 
     435 
     436    // format-specific widgets 
     437    int rows = entry == null ? 0 : entry.widgets.length; 
     438    for (int i=0; i<rows; i++) { 
     439      formatInfo.add(makeLabel(entry.labels[i], false)); 
     440      formatInfo.add(entry.widgets[i]); 
     441    } 
     442 
     443    SpringUtilities.makeCompactGrid(formatInfo, 2 + rows, 2, 3, 3, 3, 3); 
     444 
     445    formatInfo.validate(); 
     446    formatInfo.repaint(); 
    413447  } 
    414448 
  • trunk/loci/plugins/config/FormatEntry.java

    r3855 r3856  
    2626package loci.plugins.config; 
    2727 
     28import java.awt.Component; 
    2829import java.lang.reflect.Method; 
    2930 
     
    4445  private String name; 
    4546  protected String[] suffixes; 
     47  protected String[] labels; 
     48  protected Component[] widgets; 
    4649 
    4750  // -- Constructor -- 
     
    4952  public FormatEntry(Object reader) { 
    5053    this.reader = reader; 
     54    Class readerClass = null; 
    5155    try { 
    52       Method getFormat = reader.getClass().getMethod("getFormat", null); 
     56      readerClass = reader.getClass(); 
     57      Method getFormat = readerClass.getMethod("getFormat", null); 
    5358      name = (String) getFormat.invoke(reader, null); 
    54       Method getSuffixes = reader.getClass().getMethod("getSuffixes", null); 
     59      Method getSuffixes = readerClass.getMethod("getSuffixes", null); 
    5560      suffixes = (String[]) getSuffixes.invoke(reader, null); 
    5661    } 
     
    5964      suffixes = new String[0]; 
    6065    } 
     66    // create any extra widgets for this format, if any 
     67    IFormatWidgets fw = null; 
     68    try { 
     69      String readerClassName = readerClass.getName(); 
     70      String fwClassName = "loci.plugins.config." + 
     71        readerClassName.substring(readerClassName.lastIndexOf(".") + 1, 
     72        readerClassName.length() - 6) + "Widgets"; 
     73      Class fwClass = Class.forName(fwClassName); 
     74      fw = (IFormatWidgets) fwClass.newInstance(); 
     75    } 
     76    catch (Throwable t) { } 
     77    labels = fw == null ? new String[0] : fw.getLabels(); 
     78    widgets = fw == null ? new Component[0] : fw.getWidgets(); 
    6179  } 
    6280 
  • trunk/loci/plugins/config/LibraryEntry.java

    r3855 r3856  
    3939  // -- Constants -- 
    4040 
    41   private static final String RED = "7f0000"; 
    42   private static final String ORANGE = "7f3f00"; 
    43   private static final String BLACK = "000000"; 
     41  /** HTML markup for installed library. */ 
     42  private static final String PRESENT = ""; 
     43 
     44  /** HTML markup for missing library. */ 
     45  private static final String MISSING = "<font color=\"7f7f7f\"><i>"; 
    4446 
    4547  // -- Fields -- 
     
    5456  protected String status; 
    5557  protected String version; 
    56   protected String latest; 
    5758 
    5859  protected String path; 
     
    9091      } 
    9192      this.version = version; 
    92       latest = version; // TEMP 
    9393 
    9494      // get resource containing the class 
     
    114114 
    115115  public String toString() { 
    116     String color = BLACK; 
    117     if (version == null) color = RED; 
    118     else if (!version.equals(latest)) color = ORANGE; 
    119     return "<html><font color=\"" + color + "\">" + name; 
     116    String markup = version == null ? MISSING : PRESENT; 
     117    return "<html>" + markup + name; 
    120118  } 
    121119 
Note: See TracChangeset for help on using the changeset viewer.