Changeset 2520


Ignore:
Timestamp:
03/29/07 16:20:14 (13 years ago)
Author:
curtis
Message:

Remove dependency on loci.ome.notebook package (use reflection).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/ImageViewer.java

    r2516 r2520  
    3434import javax.swing.event.ChangeEvent; 
    3535import javax.swing.event.ChangeListener; 
    36 import loci.ome.notebook.Notebook; 
    3736 
    3837/** 
     
    151150    setJMenuBar(menubar); 
    152151    JMenu file = new JMenu("File"); 
     152    file.setMnemonic('f'); 
    153153    menubar.add(file); 
    154154    JMenuItem fileOpen = new JMenuItem("Open..."); 
     155    fileOpen.setMnemonic('o'); 
    155156    fileOpen.setActionCommand("open"); 
    156157    fileOpen.addActionListener(this); 
    157158    file.add(fileOpen); 
    158159    fileSave = new JMenuItem("Save..."); 
     160    fileSave.setMnemonic('s'); 
    159161    fileSave.setEnabled(false); 
    160162    fileSave.setActionCommand("save"); 
    161163    fileSave.addActionListener(this); 
    162164    file.add(fileSave); 
    163     JMenuItem view = new JMenuItem("View..."); 
    164     view.setEnabled(true); 
    165     view.setActionCommand("view"); 
    166     view.addActionListener(this); 
    167     file.add(view); 
     165    boolean canDoNotebook = false; 
     166    try { 
     167      Class c = Class.forName("loci.ome.notebook.Notebook"); 
     168      if (c != null) canDoNotebook = true; 
     169    } 
     170    catch (Throwable t) { } 
     171    if (canDoNotebook) { 
     172      JMenuItem fileView = new JMenuItem("View Metadata..."); 
     173      fileView.setMnemonic('m'); 
     174      fileView.setEnabled(true); 
     175      fileView.setActionCommand("view"); 
     176      fileView.addActionListener(this); 
     177      file.add(fileView); 
     178    } 
    168179    JMenuItem fileExit = new JMenuItem("Exit"); 
     180    fileExit.setMnemonic('x'); 
    169181    fileExit.setActionCommand("exit"); 
    170182    fileExit.addActionListener(this); 
    171183    file.add(fileExit); 
    172184    JMenu help = new JMenu("Help"); 
     185    help.setMnemonic('h'); 
    173186    menubar.add(help); 
    174187    JMenuItem helpAbout = new JMenuItem("About..."); 
     188    helpAbout.setMnemonic('a'); 
    175189    helpAbout.setActionCommand("about"); 
    176190    helpAbout.addActionListener(this); 
     
    351365    } 
    352366    else if ("view".equals(cmd)) { 
    353       Notebook n =  
    354         new Notebook(null, filename); 
     367      ReflectedUniverse r = new ReflectedUniverse(); 
     368      try { 
     369        r.exec("import loci.ome.notebook.Notebook"); 
     370        r.setVar("filename", filename); 
     371        r.exec("new Notebook(null, filename)"); 
     372      } 
     373      catch (ReflectException exc) { exc.printStackTrace(); } 
    355374    } 
    356375    else if ("exit".equals(cmd)) dispose(); 
Note: See TracChangeset for help on using the changeset viewer.