Changeset 2208


Ignore:
Timestamp:
02/01/07 17:56:53 (13 years ago)
Author:
chris
Message:

Notebook:
ability to save ".meta" extension companion OME-xml
files added.

Location:
trunk/loci/ome/notebook
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/ome/notebook/MetadataNotebook.java

    r2206 r2208  
    192192    fileOpen.setMnemonic('o'); 
    193193    fileOpen.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_MASK)); 
    194     JMenuItem fileSave = new JMenuItem("Save"); 
     194    JMenuItem fileSave = new JMenuItem("Save to orignal"); 
    195195    file.add(fileSave); 
    196196    fileSave.setActionCommand("save"); 
     
    199199    fileSave.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_MASK)); 
    200200    fileSave.setEnabled(addSave); 
     201    JMenuItem fileSaveComp = new JMenuItem("Save as companion"); 
     202    file.add(fileSaveComp); 
     203    fileSaveComp.setActionCommand("saveComp"); 
     204    fileSaveComp.addActionListener(this); 
     205    fileSaveComp.setMnemonic('c'); 
     206    fileSaveComp.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_MASK)); 
     207    fileSaveComp.setEnabled(addSave); 
    201208    JMenuItem fileSaveAs = new JMenuItem("Save As..."); 
    202209    file.add(fileSaveAs); 
     
    319326    metadata.saveFile(file); 
    320327  } 
     328   
     329  /** saves to a companion file, same path with .meta extenstion, pure ome*/ 
     330  public void saveCompanionFile(File file) { 
     331    metadata.saveCompanionFile(file); 
     332  } 
    321333 
    322334  /**Given an array of Strings of appropriate tab names, this method 
     
    422434      metadata.stateChanged(false); 
    423435    } 
     436    else if ("saveComp".equals(cmd) && currentFile != null) { 
     437      saveCompanionFile(currentFile); 
     438      metadata.stateChanged(false); 
     439    } 
    424440    else if ("exit".equals(cmd)) { 
    425441          if (metadata.getState()) { 
  • trunk/loci/ome/notebook/MetadataPane.java

    r2207 r2208  
    303303          mdn.setTitle("OME Metadata Notebook - " + file); 
    304304        } 
    305 /** 
    306         //Workaround for transform problems with writeOME(file,false); 
    307         String xml = thisOmeNode.writeOME(false); 
    308         FileWriter fw = new FileWriter(file); 
    309         BufferedWriter bw = new BufferedWriter(fw); 
    310         bw.write(xml); 
    311         bw.close(); 
    312 */ 
    313305      } 
    314306    } 
     
    321313      System.out.println("ERROR! Attempt failed to open file: " + 
    322314        file.getName() ); 
     315    } 
     316  } 
     317   
     318  public void saveCompanionFile(File file) throws RuntimeException { 
     319    File compFile = new File(file.getPath() + ".meta"); 
     320    try { 
     321      thisOmeNode.writeOME(compFile, false); 
     322    } 
     323    catch (Exception exc) { 
     324      if(exc instanceof RuntimeException) throw (RuntimeException)exc; 
     325      else exc.printStackTrace(); 
    323326    } 
    324327  } 
Note: See TracChangeset for help on using the changeset viewer.