Author: dgolovin
Date: 2007-12-28 20:47:45 -0500 (Fri, 28 Dec 2007)
New Revision: 5478
Modified:
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java
Log:
http://jira.jboss.com/jira/browse/JBIDE-1490
1. JUnit test for JBIDE-1490 was added
2. Javadoc comments were added
3. Coding style was improved to reduce amount of Checkstyle violations
Modified:
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 2007-12-29
01:47:41 UTC (rev 5477)
+++
trunk/tests/tests/org.jboss.tools.test/src/org/jboss/tools/test/util/WorkbenchUtils.java 2007-12-29
01:47:45 UTC (rev 5478)
@@ -7,42 +7,44 @@
*
* Contributors:
* 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.preference.PreferenceDialog;
+import org.eclipse.jface.preference.PreferenceManager;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPage;
import org.eclipse.ui.IWorkbenchWizard;
import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.dialogs.PreferencesUtil;
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;
+ 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();
}
@@ -54,4 +56,25 @@
// TODO Auto-generated method stub
return getWorkbench().getActiveWorkbenchWindow().getActivePage();
}
+
+ /**
+ * To show modal dialog parent shell is required, this method can be used to
+ * obtain active workbench window shell
+ *
+ * @return active workbench window shell
+ */
+ public static Shell getActiveShell() {
+ return getWorkbench().getActiveWorkbenchWindow().getShell();
+ }
+
+ public static PreferenceManager getPreferenceManager() {
+ return getWorkbench().getPreferenceManager();
+ }
+
+ public static PreferenceDialog createPreferenceDialog(String pageId) {
+
+ return PreferencesUtil.createPreferenceDialogOn(WorkbenchUtils
+ .getActiveShell(), pageId, new String[] {pageId}, null);
+ }
+
}