Changeset 3859


Ignore:
Timestamp:
03/28/08 19:16:50 (12 years ago)
Author:
curtis
Message:
  • Respect enabled status of each format when importing.
  • Really add LOCI Plugins Configuration entry to LOCI menu this time.
Location:
trunk/loci/plugins
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/plugins/Importer.java

    r3815 r3859  
    5050public class Importer { 
    5151 
     52  // -- Constants -- 
     53 
     54  public static final String READER_ENABLED_PROPERTY = "bioformats.enabled"; 
     55 
    5256  // -- Fields -- 
    5357 
     
    96100    if (options.isLocal() || options.isHTTP()) { 
    97101      IJ.showStatus("Identifying " + idName); 
    98       ImageReader reader = new ImageReader(); 
     102      ImageReader reader = makeImageReader(); 
    99103      try { r = reader.getReader(id); } 
    100104      catch (FormatException exc) { 
     
    590594  // -- Helper methods -- 
    591595 
     596  /** Creates an image reader from only the enabled reader types. */ 
     597  private ImageReader makeImageReader() { 
     598    Class[] c = null; 
     599    try { 
     600      ClassList defaultClasses = 
     601        new ClassList("readers.txt", IFormatReader.class); 
     602      c = defaultClasses.getClasses(); 
     603    } 
     604    catch (IOException exc) { 
     605      return new ImageReader(); 
     606    } 
     607    ClassList enabledClasses = new ClassList(IFormatReader.class); 
     608    for (int i=0; i<c.length; i++) { 
     609      String n = c[i].getName(); 
     610      String readerName = n.substring(n.lastIndexOf(".") + 1, n.length() - 6); 
     611      String key = READER_ENABLED_PROPERTY + "." + readerName; 
     612      boolean on = Prefs.get(key, true); 
     613      if (on) { 
     614        try { 
     615          enabledClasses.addClass(c[i]); 
     616        } 
     617        catch (FormatException exc) { 
     618          exc.printStackTrace(); 
     619        } 
     620      } 
     621    } 
     622    return new ImageReader(enabledClasses); 
     623  } 
     624 
    592625  /** 
    593626   * Displays the given image stack according to 
  • trunk/loci/plugins/config/ConfigWindow.java

    r3858 r3859  
    2929import java.awt.event.ItemEvent; 
    3030import java.awt.event.ItemListener; 
     31import java.lang.reflect.Field; 
    3132import java.lang.reflect.Method; 
    3233import java.util.Arrays; 
     
    4849  implements ItemListener, ListSelectionListener 
    4950{ 
    50  
    51   // -- Constants -- 
    52  
    53   private static final String READER_ENABLED_PROPERTY = "bioformats.enabled"; 
    5451 
    5552  // -- Fields -- 
     
    467464  private boolean isReaderEnabled(FormatEntry entry) { 
    468465    if (entry == null) return false; 
    469     String key = READER_ENABLED_PROPERTY + "." + entry.readerName; 
    470466    try { 
     467      Class importerClass = Class.forName("loci.plugins.Importer"); 
     468      Field field = importerClass.getField("READER_ENABLED_PROPERTY"); 
     469      String key = field.get(null) + "." + entry.readerName; 
    471470      Class prefsClass = Class.forName("ij.Prefs"); 
    472471      Method get = prefsClass.getMethod("get", 
     
    484483  private void setReaderEnabled(FormatEntry entry, boolean on) { 
    485484    if (entry == null) return; 
    486     String key = READER_ENABLED_PROPERTY + "." + entry.readerName; 
    487485    try { 
     486      Class importerClass = Class.forName("loci.plugins.Importer"); 
     487      Field field = importerClass.getField("READER_ENABLED_PROPERTY"); 
     488      String key = field.get(null) + "." + entry.readerName; 
    488489      Class prefsClass = Class.forName("ij.Prefs"); 
    489490      Method set = prefsClass.getMethod("set", 
  • trunk/loci/plugins/plugins.config

    r3798 r3859  
    2424#Plugins>LOCI, "Bio-Formats Master Importer", loci.plugins.LociImporter("") 
    2525 
     26Plugins>LOCI, "LOCI Plugins Configuration", loci.plugins.config.LociConfig("") 
     27 
     28Plugins>LOCI, "-" 
    2629Plugins>LOCI, "Data Browser", loci.plugins.LociImporter("location=[Local machine] view=[Data Browser] stack_order=[XYZCT] group_files=true use_virtual_stack=true ") 
    2730Plugins>LOCI, "Bio-Formats Importer", loci.plugins.LociImporter("location=[Local machine] windowless=false ") 
Note: See TracChangeset for help on using the changeset viewer.