fix SWTBot tests for Oxygen

they changed "OK" button to "Open" in open dialogs.

Change-Id: I14cc89b7c4b09f4560d636dc90a36148e3a5a767
diff --git a/tests/org.eclipse.emf.parsley.tests.swtbot.cdo/src/org/eclipse/emf/parsley/tests/swtbot/cdo/EmfParsleyCdoSWTBotTests.java b/tests/org.eclipse.emf.parsley.tests.swtbot.cdo/src/org/eclipse/emf/parsley/tests/swtbot/cdo/EmfParsleyCdoSWTBotTests.java
index aa38ce9..d3c739c 100644
--- a/tests/org.eclipse.emf.parsley.tests.swtbot.cdo/src/org/eclipse/emf/parsley/tests/swtbot/cdo/EmfParsleyCdoSWTBotTests.java
+++ b/tests/org.eclipse.emf.parsley.tests.swtbot.cdo/src/org/eclipse/emf/parsley/tests/swtbot/cdo/EmfParsleyCdoSWTBotTests.java
@@ -16,8 +16,11 @@
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
 
 import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Platform;
 import org.eclipse.emf.cdo.net4j.CDONet4jSessionConfiguration;
 import org.eclipse.emf.cdo.net4j.CDONet4jUtil;
 import org.eclipse.emf.cdo.session.CDOSession;
@@ -61,6 +64,8 @@
 
 	private static final String EMF_PARSLEY_CATEGORY = "EMF Parsley";
 
+	public static String OPEN_DIALOG_SUBMIT = "OK";
+
 	private static SWTWorkbenchBot bot;
 
 	@BeforeClass
@@ -69,6 +74,10 @@
 		bot = new SWTWorkbenchBot();
 		SWTBotPreferences.KEYBOARD_LAYOUT = "EN_US";
 		closeWelcomePage();
+		if (isOxygen()) {
+			// they changed "OK" to "Open" in Oxygen
+			OPEN_DIALOG_SUBMIT = "Open";
+		}
 		openTestView(TEST_CDO_FORM_VIEW);
 	}
 
@@ -77,6 +86,24 @@
 		getLibraryView(TEST_CDO_FORM_VIEW).close();
 	}
 
+	protected static boolean isOxygen() {
+		// org.eclipse.ui has minor number 109 for Oxygen
+		return getOrgEclipseUiMinorVersion() >= 109;
+	}
+
+	protected static int getOrgEclipseUiMinorVersion() {
+		String version = Platform.getBundle(PlatformUI.PLUGIN_ID).getHeaders()
+				.get("Bundle-Version");
+
+		Pattern versionPattern = Pattern.compile("\\d+\\.(\\d+)\\..*");
+		Matcher m = versionPattern.matcher(version);
+		if (m.matches()) {
+			return Integer.parseInt(m.group(1));
+		} else {
+			throw new RuntimeException("Can't parse version " + version);
+		}
+	}
+
 	@Test
 	public void testView() {
 		Assert.assertNotNull(getLibraryView(TEST_CDO_FORM_VIEW));
@@ -180,7 +207,7 @@
 		SWTBotShell shell = bot.shell("Show View");
 		shell.activate();
 		expandNodeSync(bot.tree(), EMF_PARSLEY_CATEGORY).select(libraryView);
-		bot.button("OK").click();
+		bot.button(OPEN_DIALOG_SUBMIT).click();
 		bot.waitUntil(shellCloses(shell), 50000);
 		return getLibraryView(libraryView);
 	}
diff --git a/tests/org.eclipse.emf.parsley.tests.swtbot/src/org/eclipse/emf/parsley/tests/swtbot/EmfParsleySWTBotAbstractTests.java b/tests/org.eclipse.emf.parsley.tests.swtbot/src/org/eclipse/emf/parsley/tests/swtbot/EmfParsleySWTBotAbstractTests.java
index e0bc740..881eda4 100644
--- a/tests/org.eclipse.emf.parsley.tests.swtbot/src/org/eclipse/emf/parsley/tests/swtbot/EmfParsleySWTBotAbstractTests.java
+++ b/tests/org.eclipse.emf.parsley.tests.swtbot/src/org/eclipse/emf/parsley/tests/swtbot/EmfParsleySWTBotAbstractTests.java
@@ -99,6 +99,8 @@
 @RunWith(SWTBotJunit4ClassRunner.class)
 public abstract class EmfParsleySWTBotAbstractTests {
 
+	public static String OPEN_DIALOG_SUBMIT = "OK";
+
 	public static final String PACKAGE_EXPLORER = "Package Explorer";
 
 	protected static final String EMF_PARSLEY_CATEGORY = "EMF Parsley";
@@ -408,9 +410,14 @@
 		SWTBotShell openPerspectiveShell = bot.shell("Open Perspective");
 		openPerspectiveShell.activate();
 
+		if (isOxygen()) {
+			// they changed "OK" to "Open" in Oxygen
+			OPEN_DIALOG_SUBMIT = "Open";
+		}
+
 		// select the dialog
 		bot.table().select("Plug-in Development");
-		bot.button("OK").click();
+		bot.button(OPEN_DIALOG_SUBMIT).click();
 		
 		// in SwtBot 2.2.0 we must use part name since the title
 		// of the problems view also contains the items count
@@ -465,6 +472,11 @@
 		});
 	}
 
+	protected static boolean isOxygen() {
+		// org.eclipse.ui has minor number 109 for Oxygen
+		return getOrgEclipseUiMinorVersion() >= 109;
+	}
+
 	protected static boolean isLuna() {
 		// org.eclipse.ui has minor number 106 for Luna
 		return getOrgEclipseUiMinorVersion() >= 106;
@@ -971,7 +983,7 @@
 		SWTBotShell shell = bot.shell("Show View");
 		shell.activate();
 		expandNodeSync(bot.tree(), EMF_PARSLEY_CATEGORY).select(viewName);
-		bot.button("OK").click();
+		bot.button(OPEN_DIALOG_SUBMIT).click();
 		waitForShellToClose(shell);
 		return getView(viewName);
 	}