/*
 * #%L
 * ImageJ software for multidimensional image processing and analysis.
 * %%
 * Copyright (C) 2009 - 2014 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.
 * #L%
 */

package net.imagej.options;

import java.net.URL;

import org.scijava.log.LogService;
import org.scijava.menu.MenuConstants;
import org.scijava.options.OptionsPlugin;
import org.scijava.platform.PlatformService;
import org.scijava.plugin.Menu;
import org.scijava.plugin.Parameter;
import org.scijava.plugin.Plugin;
import org.scijava.widget.Button;

/**
 * Runs the Edit::Options::Compatibility dialog.
 * 
 * @author Barry DeZonia
 */
@Plugin(type = OptionsPlugin.class, menu = {
	@Menu(label = MenuConstants.EDIT_LABEL, weight = MenuConstants.EDIT_WEIGHT,
		mnemonic = MenuConstants.EDIT_MNEMONIC),
	@Menu(label = "Options", mnemonic = 'o'),
	@Menu(label = "Compatibility...", weight = 16) })
public class OptionsCompatibility extends OptionsPlugin {

	private static final String MODE_LEGACY = "Legacy";
	private static final String MODE_MODERN = "Modern";

	@Parameter(required = false)
	private PlatformService platformService;

	@Parameter
	private LogService log;

	@Parameter(label = "Notes",
			description="View a web page detailing the commands on this dialog",
			callback="openWebPage", persist = false)
	private Button openWebPage;

	@Parameter(label = "Invert command",
		choices = {MODE_LEGACY, MODE_MODERN})
	private String invertMode = MODE_LEGACY;

	// -- OptionsMisc methods --


	public boolean isInvertModeLegacy() {
		return invertMode.equals(MODE_LEGACY);
	}
	
	public boolean isInvertModeModern() {
		return invertMode.equals(MODE_MODERN);
	}

	public void setInvertModeLegacy() {
		invertMode = MODE_LEGACY;
	}

	public void setInvertModeModern() {
		invertMode = MODE_MODERN;
	}
	
	// -- helpers --
	
	protected void openWebPage() {
		try {
			String urlString =
					"http://wiki.imagej.net/ImageJ2/Documentation/Edit/Options/Compatibility";
			URL url = new URL(urlString);
			if (platformService == null) {
				log.error("Could not open URL " + urlString);
			}
			else {
				platformService.open(url);
			}
		}
		catch (Exception e) {
			// do nothing
		}
	}
}

@@ -2599,17 +2599,16 @@
 tes%22,%0A%09%09
-%09
 descript
@@ -2610,17 +2610,19 @@
 cription
-=
+ = 
 %22View a 
@@ -2676,17 +2676,16 @@
 ,%0A%09%09
-%09
 callback
 =%22op
@@ -2680,17 +2680,19 @@
 callback
-=
+ = 
 %22openWeb
@@ -2782,19 +2782,17 @@
 ommand%22,
-%0A%09%09
+ 
 choices 
@@ -2794,16 +2794,17 @@
 ices = %7B
+ 
 MODE_LEG
@@ -2819,16 +2819,17 @@
 E_MODERN
+ 
 %7D)%0A%09priv
@@ -2897,17 +2897,16 @@
 ods --%0A%0A
-%0A
 %09public 
@@ -2980,17 +2980,16 @@
 CY);%0A%09%7D%0A
-%09
 %0A%09public
@@ -3202,17 +3202,16 @@
 ERN;%0A%09%7D%0A
-%09
 %0A%09// -- 
@@ -3221,17 +3221,16 @@
 pers --%0A
-%09
 %0A%09protec
@@ -3265,16 +3265,22 @@
 ry %7B%0A%09%09%09
+final 
 String u
@@ -3290,17 +3290,16 @@
 tring =%0A
-%09
 %09%09%09%09%22htt
@@ -3372,16 +3372,22 @@
 ty%22;%0A%09%09%09
+final 
 URL url 
@@ -3556,16 +3556,22 @@
 %09catch (
+final 
 Exceptio

Clean up OptionsCompatibility's source code