/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2012 Board of Regents of the University of
 * Wisconsin-Madison, Broad Institute of MIT and Harvard, and Max Planck
 * Institute of Molecular Cell Biology and Genetics.
 * %%
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 * 
 * 1. Redistributions of source code must retain the above copyright notice,
 *    this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright notice,
 *    this list of conditions and the following disclaimer in the documentation
 *    and/or other materials provided with the distribution.
 * 
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
 * POSSIBILITY OF SUCH DAMAGE.
 * 
 * The views and conclusions contained in the software and documentation are
 * those of the authors and should not be interpreted as representing official
 * policies, either expressed or implied, of any organization.
 * #L%
 */

package imagej.ui.pivot.widget;

import imagej.Priority;
import imagej.ext.plugin.Plugin;
import imagej.module.Module;
import imagej.plugin.PreprocessorPlugin;
import imagej.ui.AbstractInputHarvesterPlugin;
import imagej.ui.pivot.PivotUI;
import imagej.widget.InputHarvester;
import imagej.widget.InputPanel;

import org.apache.pivot.wtk.BoxPane;
import org.apache.pivot.wtk.Display;
import org.apache.pivot.wtk.Sheet;
import org.apache.pivot.wtk.TablePane;

/**
 * PivotInputHarvester is an {@link InputHarvester} that collects input
 * parameter values from the user using a {@link PivotInputPanel} dialog box.
 * 
 * @author Curtis Rueden
 * @author Barry DeZonia
 */
@Plugin(type = PreprocessorPlugin.class, priority = Priority.VERY_LOW_PRIORITY)
public class PivotInputHarvester extends
	AbstractInputHarvesterPlugin<TablePane, BoxPane>
{

	// -- InputHarvester methods --

	@Override
	public PivotInputPanel createInputPanel() {
		return new PivotInputPanel();
	}

	@Override
	public boolean harvestInputs(final InputPanel<TablePane, BoxPane> inputPanel,
		final Module module)
	{
		final TablePane pane = inputPanel.getComponent();

		final Sheet dialog = new Sheet();
		dialog.setTitle(module.getInfo().getLabel());
		dialog.add(pane);
		dialog.open((Display) null);// FIXME
		final boolean success = dialog.getResult();
		return success;
	}

	// -- Internal methods --

	@Override
	protected String getUI() {
		return PivotUI.NAME;
	}

}

@@ -2018,32 +2018,92 @@
 arvesterPlugin;%0A
+import imagej.ui.UIService;%0Aimport imagej.ui.UserInterface;%0A
 import imagej.ui
@@ -2230,45 +2230,8 @@
 ne;%0A
-import org.apache.pivot.wtk.Display;%0A
 impo
@@ -2982,16 +2982,51 @@
 ent();%0A%0A
+%09%09final PivotUI ui = getPivotUI();%0A
 %09%09final 
@@ -3053,16 +3053,16 @@
 heet();%0A
-
 %09%09dialog
@@ -3139,32 +3139,34 @@
 pen(
-(Display) null);// FIXME
+ui.getApplicationFrame());
 %0A%09%09f
@@ -3293,24 +3293,24 @@
 g getUI() %7B%0A
-
 %09%09return Piv
@@ -3324,10 +3324,220 @@
 ME;%0A%09%7D%0A%0A
+%09// -- Helper methods --%0A%0A%09private PivotUI getPivotUI() %7B%0A%09%09final UIService uiService = getContext().getService(UIService.class);%0A%09%09final UserInterface ui = uiService.getUI(getUI());%0A%09%09return (PivotUI) ui;%0A%09%7D%0A%0A
 %7D%0A

improve harvestInputs UI