Changeset 2248


Ignore:
Timestamp:
02/08/07 18:10:24 (13 years ago)
Author:
chris
Message:

Notebook:
Capability to merge saved versions of companion and
original file at any time through menu item in the
tools menu, added and seemingly totally functional.

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

Legend:

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

    r2247 r2248  
    463463      metadata.stateChanged(false); 
    464464    } 
     465    else if ("merge".equals(cmd)) { 
     466      metadata.merge(); 
     467    } 
    465468    else if ("exit".equals(cmd)) { 
    466469          if (metadata.getState()) { 
  • trunk/loci/ome/notebook/MetadataPane.java

    r2247 r2248  
    325325    try { 
    326326      thisOmeNode.writeOME(compFile, false); 
    327       stateChanged(false); 
    328327    } 
    329328    catch (Exception exc) { 
     
    385384        mn.setCurrentFile(file); 
    386385      } 
    387       stateChanged(false); 
     386    } 
     387  } 
     388   
     389  public void merge() throws RuntimeException { 
     390    if (currentFile != null) { 
     391      String id = currentFile.getPath(); 
     392      ImageReader read = new ImageReader(); 
     393      OMEXMLMetadataStore ms = new OMEXMLMetadataStore(); 
     394      read.setMetadataStore(ms); 
     395       
     396      try {  
     397        //just to repopulate the metadatastore to original state      
     398        int imageCount = read.getImageCount(id); 
     399//        BufferedImage whatever = reader.openImage(id, imageCount/2); 
     400      } 
     401      catch(Exception exc) { 
     402        if(exc instanceof RuntimeException) throw (RuntimeException)exc; 
     403        else exc.printStackTrace(); 
     404      } 
     405      OMENode ome = (OMENode)ms.getRoot(); 
     406     
     407      File companion = new File(currentFile.getPath() + ".ome"); 
     408      if (companion.exists()) { 
     409        Merger merge = new Merger(ome,companion,this); 
     410        setOMEXML(merge.getRoot()); 
     411      } 
     412      else { 
     413        JOptionPane.showMessageDialog(this, 
     414            "No companion file found to merge!!", 
     415            "MetadataNotebook Error", JOptionPane.ERROR_MESSAGE); 
     416      } 
     417    } 
     418    else { 
     419      JOptionPane.showMessageDialog(this, 
     420            "You have not saved or opened a file to merge yet!", 
     421            "MetadataNotebook Error", JOptionPane.ERROR_MESSAGE); 
    388422    } 
    389423  } 
     
    457491        thumb = ImageTools.scale(img, width, height, false); 
    458492        ome = (OMENode) ms.getRoot(); 
     493         
    459494        if(doMerge) { 
    460495          Merger merge = new Merger(ome,companionFile,this); 
    461496          ome = merge.getRoot(); 
    462497        } 
    463          
    464498        setOMEXML(ome); 
    465499      } 
Note: See TracChangeset for help on using the changeset viewer.