List of usage examples for org.eclipse.jdt.core IPackageFragmentRoot getPackageFragment
IPackageFragment getPackageFragment(String packageName);
From source file:com.redhat.ceylon.eclipse.ui.test.headless.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkMainProjectPureJavaUnits() throws CoreException { if (compilationError != null) { throw compilationError; }/*from ww w .j a v a 2 s . c om*/ IJavaProject javaProject = JavaCore.create(mainProject); String rootPath = null; ICompilationUnit javaElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("mainModule"); if (pkg.exists() && pkg.getCompilationUnit("JavaClassInCeylonModule_Main_Ceylon_Project.java").exists()) { javaElement = pkg.getCompilationUnit("JavaClassInCeylonModule_Main_Ceylon_Project.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("mainModule", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "mainModule.JavaClassInCeylonModule_Main_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "mainModule/JavaClassInCeylonModule_Main_Ceylon_Project.java", "mainModule/JavaClassInCeylonModule_Main_Ceylon_Project.java", "JavaClassInCeylonModule_Main_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Pure Java Class : ", javaElement, javaClassCompilationUnit.getTypeRoot()); Assert.assertNotNull("Project Resource for Pure Java Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource Pure Java for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should Pure Java for Class not be null :", javaClassCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.headless.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkReferencedProjectJavaCeylonUnits() throws CoreException { if (compilationError != null) { throw compilationError; }//from w w w .jav a 2 s .com IJavaProject javaProject = JavaCore.create(referencedCeylonProject); String rootPath = null; ICompilationUnit javaClassElement = null; ICompilationUnit javaObjectElement = null; ICompilationUnit javaMethodElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("referencedCeylonProject"); if (pkg.exists() && pkg.getCompilationUnit("JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java").exists()) { javaClassElement = pkg.getCompilationUnit("JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java"); javaObjectElement = pkg .getCompilationUnit("javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java"); javaMethodElement = pkg .getCompilationUnit("javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("referencedCeylonProject", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.JavaCeylonTopLevelClass_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java", "referencedCeylonProject/JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java", "JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Class : ", javaClassElement, javaClassCompilationUnit.getTypeRoot()); Assert.assertNotNull("Project Resource for Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Class not be null :", javaClassCompilationUnit.getFileResource()); JavaCompilationUnit javaObjectCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.javaCeylonTopLevelObject_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java", "referencedCeylonProject/javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java", "javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Object : ", javaObjectElement, javaObjectCompilationUnit.getTypeRoot()); Assert.assertNotNull("Project Resource for Object should not be null :", javaObjectCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Object should not be null :", javaObjectCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Object not be null :", javaObjectCompilationUnit.getFileResource()); JavaCompilationUnit javaMethodCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.javaCeylonTopLevelMethod_Referenced_Ceylon_Project_", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java", "referencedCeylonProject/javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java", "javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Method : ", javaMethodElement, javaMethodCompilationUnit.getTypeRoot()); Assert.assertNotNull("Project Resource for Method should not be null :", javaMethodCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Method should not be null :", javaMethodCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Method not be null :", javaMethodCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.headless.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkReferencedProjectPureJavaUnits() throws CoreException { if (compilationError != null) { throw compilationError; }//w w w . j a v a 2s. c om IJavaProject javaProject = JavaCore.create(referencedCeylonProject); String rootPath = null; ICompilationUnit javaElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("referencedCeylonProject"); if (pkg.exists() && pkg.getCompilationUnit("JavaClassInCeylonModule_Referenced_Ceylon_Project.java").exists()) { javaElement = pkg.getCompilationUnit("JavaClassInCeylonModule_Referenced_Ceylon_Project.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("referencedCeylonProject", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.JavaClassInCeylonModule_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/JavaClassInCeylonModule_Referenced_Ceylon_Project.java", "referencedCeylonProject/JavaClassInCeylonModule_Referenced_Ceylon_Project.java", "JavaClassInCeylonModule_Referenced_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Pure Java Class : ", javaElement, javaClassCompilationUnit.getTypeRoot()); Assert.assertNotNull("Project Resource for Pure Java Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource Pure Java for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should Pure Java for Class not be null :", javaClassCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.ModelAndPhasedUnitsTests.java
License:Open Source License
@SuppressWarnings("restriction") @Test/*www .j a va 2 s. c om*/ public void checkJavaLibrayrUnits() throws CoreException { if (compilationError != null) { throw compilationError; } IJavaProject javaProject = JavaCore.create(mainProject); String jarName = null; IClassFile javaElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { if (root instanceof JarPackageFragmentRoot) { JarPackageFragmentRoot jarRoot = (JarPackageFragmentRoot) root; IPackageFragment pkg = root.getPackageFragment("java.util.logging"); if (pkg.exists()) { javaElement = pkg.getClassFile("Logger.class"); jarName = jarRoot.getJar().getName(); break; } } } Module module = modelLoader.findModule(AbstractModelLoader.JAVA_BASE_MODULE_NAME, AbstractModelLoader.JDK_MODULE_VERSION); JavaClassFile javaClass = checkDeclarationUnit(module, "java.util.logging.Logger", JavaClassFile.class, jarName + "!/" + "java/util/logging/Logger.class", "java/util/logging/Logger.class", "Logger.class"); Assert.assertEquals("Wrong Java Element : ", javaElement, javaClass.getJavaElement()); Assert.assertNull("Project Resource should be null :", javaClass.getProjectResource()); Assert.assertNull("Root Folder Resource should be null :", javaClass.getRootFolderResource()); Assert.assertNull("File Resource should be null :", javaClass.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkMainProjectJavaCeylonUnits() throws CoreException { if (compilationError != null) { throw compilationError; }/*from ww w.java2 s. co m*/ IJavaProject javaProject = JavaCore.create(mainProject); String rootPath = null; ICompilationUnit javaClassElement = null; ICompilationUnit javaObjectElement = null; ICompilationUnit javaMethodElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("mainModule"); if (pkg.exists() && pkg.getCompilationUnit("JavaCeylonTopLevelClass_Main_Ceylon_Project.java").exists()) { javaClassElement = pkg.getCompilationUnit("JavaCeylonTopLevelClass_Main_Ceylon_Project.java"); javaObjectElement = pkg.getCompilationUnit("javaCeylonTopLevelObject_Main_Ceylon_Project_.java"); javaMethodElement = pkg.getCompilationUnit("javaCeylonTopLevelMethod_Main_Ceylon_Project_.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("mainModule", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "mainModule.JavaCeylonTopLevelClass_Main_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "mainModule/JavaCeylonTopLevelClass_Main_Ceylon_Project.java", "mainModule/JavaCeylonTopLevelClass_Main_Ceylon_Project.java", "JavaCeylonTopLevelClass_Main_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Class : ", javaClassElement, javaClassCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Class not be null :", javaClassCompilationUnit.getFileResource()); JavaCompilationUnit javaObjectCompilationUnit = checkDeclarationUnit(module, "mainModule.javaCeylonTopLevelObject_Main_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "mainModule/javaCeylonTopLevelObject_Main_Ceylon_Project_.java", "mainModule/javaCeylonTopLevelObject_Main_Ceylon_Project_.java", "javaCeylonTopLevelObject_Main_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Object : ", javaObjectElement, javaObjectCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Object should not be null :", javaObjectCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Object should not be null :", javaObjectCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Object not be null :", javaObjectCompilationUnit.getFileResource()); JavaCompilationUnit javaMethodCompilationUnit = checkDeclarationUnit(module, "mainModule.javaCeylonTopLevelMethod_Main_Ceylon_Project_", JavaCompilationUnit.class, rootPath + "/" + "mainModule/javaCeylonTopLevelMethod_Main_Ceylon_Project_.java", "mainModule/javaCeylonTopLevelMethod_Main_Ceylon_Project_.java", "javaCeylonTopLevelMethod_Main_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Method : ", javaMethodElement, javaMethodCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Method should not be null :", javaMethodCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Method should not be null :", javaMethodCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Method not be null :", javaMethodCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkMainProjectPureJavaUnits() throws CoreException { if (compilationError != null) { throw compilationError; }// ww w . ja v a2 s. co m IJavaProject javaProject = JavaCore.create(mainProject); String rootPath = null; ICompilationUnit javaElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("mainModule"); if (pkg.exists() && pkg.getCompilationUnit("JavaClassInCeylonModule_Main_Ceylon_Project.java").exists()) { javaElement = pkg.getCompilationUnit("JavaClassInCeylonModule_Main_Ceylon_Project.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("mainModule", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "mainModule.JavaClassInCeylonModule_Main_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "mainModule/JavaClassInCeylonModule_Main_Ceylon_Project.java", "mainModule/JavaClassInCeylonModule_Main_Ceylon_Project.java", "JavaClassInCeylonModule_Main_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Pure Java Class : ", javaElement, javaClassCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Pure Java Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource Pure Java for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should Pure Java for Class not be null :", javaClassCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkReferencedProjectJavaCeylonUnits() throws CoreException { if (compilationError != null) { throw compilationError; }//www . j av a 2s. co m IJavaProject javaProject = JavaCore.create(referencedCeylonProject); String rootPath = null; ICompilationUnit javaClassElement = null; ICompilationUnit javaObjectElement = null; ICompilationUnit javaMethodElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("referencedCeylonProject"); if (pkg.exists() && pkg.getCompilationUnit("JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java").exists()) { javaClassElement = pkg.getCompilationUnit("JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java"); javaObjectElement = pkg .getCompilationUnit("javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java"); javaMethodElement = pkg .getCompilationUnit("javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("referencedCeylonProject", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.JavaCeylonTopLevelClass_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java", "referencedCeylonProject/JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java", "JavaCeylonTopLevelClass_Referenced_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Class : ", javaClassElement, javaClassCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Class not be null :", javaClassCompilationUnit.getFileResource()); JavaCompilationUnit javaObjectCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.javaCeylonTopLevelObject_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java", "referencedCeylonProject/javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java", "javaCeylonTopLevelObject_Referenced_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Object : ", javaObjectElement, javaObjectCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Object should not be null :", javaObjectCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Object should not be null :", javaObjectCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Object not be null :", javaObjectCompilationUnit.getFileResource()); JavaCompilationUnit javaMethodCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.javaCeylonTopLevelMethod_Referenced_Ceylon_Project_", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java", "referencedCeylonProject/javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java", "javaCeylonTopLevelMethod_Referenced_Ceylon_Project_.java"); Assert.assertEquals("Wrong Java Element for Method : ", javaMethodElement, javaMethodCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Method should not be null :", javaMethodCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource for Method should not be null :", javaMethodCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should for Method not be null :", javaMethodCompilationUnit.getFileResource()); }
From source file:com.redhat.ceylon.eclipse.ui.test.ModelAndPhasedUnitsTests.java
License:Open Source License
@Test public void checkReferencedProjectPureJavaUnits() throws CoreException { if (compilationError != null) { throw compilationError; }//from ww w .j a v a 2 s . c om IJavaProject javaProject = JavaCore.create(referencedCeylonProject); String rootPath = null; ICompilationUnit javaElement = null; for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { IPackageFragment pkg = root.getPackageFragment("referencedCeylonProject"); if (pkg.exists() && pkg.getCompilationUnit("JavaClassInCeylonModule_Referenced_Ceylon_Project.java").exists()) { javaElement = pkg.getCompilationUnit("JavaClassInCeylonModule_Referenced_Ceylon_Project.java"); rootPath = root.getPath().toOSString(); break; } } Module module = modelLoader.findModule("referencedCeylonProject", "1.0.0"); JavaCompilationUnit javaClassCompilationUnit = checkDeclarationUnit(module, "referencedCeylonProject.JavaClassInCeylonModule_Referenced_Ceylon_Project", JavaCompilationUnit.class, rootPath + "/" + "referencedCeylonProject/JavaClassInCeylonModule_Referenced_Ceylon_Project.java", "referencedCeylonProject/JavaClassInCeylonModule_Referenced_Ceylon_Project.java", "JavaClassInCeylonModule_Referenced_Ceylon_Project.java"); Assert.assertEquals("Wrong Java Element for Pure Java Class : ", javaElement, javaClassCompilationUnit.getJavaElement()); Assert.assertNotNull("Project Resource for Pure Java Class should not be null :", javaClassCompilationUnit.getProjectResource()); Assert.assertNotNull("Root Folder Resource Pure Java for Class should not be null :", javaClassCompilationUnit.getRootFolderResource()); Assert.assertNotNull("File Resource should Pure Java for Class not be null :", javaClassCompilationUnit.getFileResource()); }
From source file:com.sabre.buildergenerator.TestHelper.java
License:Open Source License
public static IPackageFragment createPackage(IJavaProject javaProject, String packageName) throws JavaModelException { IPackageFragmentRoot sourceRoot = getSourceRoot(javaProject); IPackageFragment packageFragment = null; if (sourceRoot != null) { packageFragment = sourceRoot.getPackageFragment(packageName); if (!packageFragment.exists()) { packageFragment = sourceRoot.createPackageFragment(packageName, false, null); }// w w w . ja v a 2 s . c om } return packageFragment; }
From source file:com.sabre.buildergenerator.ui.actions.GenerateBuilderAction.java
License:Open Source License
/** * Starts the generation procedure for the type * * @param type//from w w w . j a va2 s. c o m * a type that the generator is going to be invoked for * @param shell * the shell of the running component * @throws CoreException */ @SuppressWarnings("deprecation") public void execute(final IType type, final Shell shell, IRunnableContext runnableContext) throws Exception { if (!validateAndShowErrorMessageIfNeeded(type, shell)) { return; } GenerateBuilderWizard wizard = new GenerateBuilderWizard(new BuilderGenerationProperties(type)); WizardDialog wizardDialog = new WizardDialog(shell, wizard); wizardDialog.setMinimumPageSize(200, 500); if (wizardDialog.open() == Dialog.OK) { final BuilderGenerationProperties properties = wizard.getBuilderGenerationProperties(); IRunnableWithProgress runnableWithProgress = new IRunnableWithProgress() { public void run(IProgressMonitor aMonitor) throws InvocationTargetException, InterruptedException { try { aMonitor.beginTask("Generating class", 4); IPackageFragmentRoot selectedSourceFolder = properties.getSourceFolder(); String packageName = properties.getPackageName(); String builderClassName = properties.getBuilderClassName(); aMonitor.worked(1); // creating package if (!selectedSourceFolder.getPackageFragment(packageName).exists()) { selectedSourceFolder.createPackageFragment(packageName, false, aMonitor); } String source = generateSource(builderGenerator, properties); aMonitor.worked(2); // create source file IPath builderPath = selectedSourceFolder.getPath(); for (String s : packageName.split("\\.")) { builderPath = builderPath.append(s); } builderPath = builderPath.append(builderClassName).addFileExtension("java"); IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile(builderPath); if (file.exists()) { file.delete(false, aMonitor); } file.create(new StringBufferInputStream(source), false, aMonitor); } catch (Throwable e) { throw new InvocationTargetException(e); } finally { aMonitor.done(); } } }; try { runnableContext.run(true, false, runnableWithProgress); } catch (InvocationTargetException e) { Throwable t = e.getTargetException(); StringWriter buf = new StringWriter(); t.printStackTrace(new PrintWriter(buf)); MessageDialog.openError(null, "Error", buf.toString()); t.printStackTrace(); } catch (InterruptedException e) { StringWriter buf = new StringWriter(); e.printStackTrace(new PrintWriter(buf)); MessageDialog.openError(null, "Error", buf.toString()); e.printStackTrace(); } catch (Throwable e) { StringWriter buf = new StringWriter(); e.printStackTrace(new PrintWriter(buf)); MessageDialog.openError(null, "Error", buf.toString()); e.printStackTrace(); } } }