package imagej.gui;

import java.io.IOException;

import loci.formats.FormatException;
import mpicbg.imglib.image.Image;
import mpicbg.imglib.io.ImageOpener;
import mpicbg.imglib.type.numeric.RealType;
import imagej.dataset.Dataset;
import imagej.ij1bridge.ImgLibDataset;
import imagej.plugin.IPlugin;
import imagej.plugin.Menu;
import imagej.plugin.Parameter;
import imagej.plugin.Plugin;

@Plugin(
  menu={
    @Menu(label="File", weight=0, mnemonic='f'),
    @Menu(label="Import", weight=0, mnemonic='i'),
    @Menu(label="Bio-Formats...", weight=0, mnemonic='b')
  },
  accelerator="^O"
)
public class OpenImage<T extends RealType<T>> implements IPlugin {

	@Parameter(output=true)
	private Dataset dataset;

  @Override
  public void run() {
  	// open image
  	final String id = "";
  	final ImageOpener imageOpener = new ImageOpener();
  	try {
			final Image<T> img = imageOpener.openImage(id);
			dataset = new ImgLibDataset<T>(img);
		}
		catch (FormatException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
  }

}

@@ -54,36 +54,139 @@
 ort 
-loci.formats.FormatException
+javax.swing.JFileChooser;%0A%0Aimport loci.formats.ChannelMerger;%0Aimport loci.formats.FormatException;%0Aimport loci.formats.gui.GUITools
 ;%0Aim
@@ -496,18 +496,59 @@
 Plugin(%0A
-  
+//%09menuPath=%22File%3EImport%3EBio-Formats...%22,%0A%09
 menu=%7B%0A 
@@ -850,18 +850,17 @@
 taset;%0A%0A
-  
+%09
 @Overrid
@@ -861,18 +861,17 @@
 verride%0A
-  
+%09
 public v
@@ -886,52 +886,324 @@
 ) %7B%0A
-  
+%09
 %09// 
-open image%0A  %09final String id = %22%22;%0A  
+prompt for input file%0A%09%09final JFileChooser fileChooser =%0A%09%09%09GUITools.buildFileChooser(new ChannelMerger());%0A%09%09final int rval = fileChooser.showOpenDialog(null);%0A%09%09if (rval != JFileChooser.APPROVE_OPTION) return; // canceled%0A%09%09final String id = fileChooser.getSelectedFile().getAbsolutePath();%0A%0A%09%09// open image%0A%09
 %09fin
@@ -1250,18 +1250,17 @@
 ener();%0A
-  
+%09
 %09try %7B%0A%09
@@ -1349,16 +1349,133 @@
 %3E(img);%0A
+%09%09%09System.out.println(%22Image dimensions: %22 + dataset.getDimensions()%5B0%5D + %22 x %22 + dataset.getDimensions()%5B1%5D);//TEMP%0A
 %09%09%7D%0A%09%09ca

Make OpenImage (temporarily) prompt for a file using a JFileChooser.