Author: dgolovin
Date: 2007-08-13 19:38:45 -0400 (Mon, 13 Aug 2007)
New Revision: 3103
Added:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
Log:
http://jira.jboss.org/jira/browse/EXIN-337
Added:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
===================================================================
---
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
(rev 0)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2007-08-13
23:38:45 UTC (rev 3103)
@@ -0,0 +1,57 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Exadel, Inc. and Red Hat, Inc.
+ * Distributed under license by Red Hat, Inc. All rights reserved.
+ * This program is made available under the terms of the
+ * Eclipse Public License v1.0 which accompanies this distribution,
+ * and is available at
http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Exadel, Inc. and Red Hat, Inc. - initial API and implementation
+ ******************************************************************************/
+
+package org.jboss.tools.test.util;
+
+import junit.framework.TestCase;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWizard;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.wizards.IWizardDescriptor;
+
+/**
+ * @author eskimo
+ *
+ */
+public class WorkbenchUtils {
+
+ static public IWizard findWizardByDefId(String definitionId) {
+ IWizardDescriptor aWizardDescr =
+ getWorkbench().getNewWizardRegistry()
+ .findWizard(definitionId);
+ TestCase.assertNotNull("Cannot find wizard "
+ + definitionId
+ + " definition in wizard registry", aWizardDescr);
+ IWorkbenchWizard aWizard=null;
+ try {
+ aWizard = aWizardDescr.createWizard();
+ } catch (CoreException e) {
+ JUnitUtils.fail("Cannot create IWorkbenchWizard instance",e);
+ }
+ return aWizard;
+ }
+
+ public static IWorkbench getWorkbench() {
+ return PlatformUI.getWorkbench();
+ }
+
+ /**
+ * @return
+ */
+ public static IWorkbenchPage getWorkbenchActivePage() {
+ // TODO Auto-generated method stub
+ return getWorkbench().getActiveWorkbenchWindow().getActivePage();
+ }
+}