List of usage examples for org.eclipse.jdt.core IJavaProject getPath
IPath getPath();
From source file:com.tasktop.dropwizard.launcher.DropwizardRuntimeClasspathProvider.java
License:Open Source License
IRuntimeClasspathEntry[] resolveClasspath0(IRuntimeClasspathEntry[] entries, ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException { int scope = getArtifactScope(configuration); Set<IRuntimeClasspathEntry> all = new LinkedHashSet<IRuntimeClasspathEntry>(entries.length); for (IRuntimeClasspathEntry entry : entries) { if (entry.getType() == IRuntimeClasspathEntry.CONTAINER && MavenClasspathHelpers.isMaven2ClasspathContainer(entry.getPath())) { addMavenClasspathEntries(all, entry, configuration, scope, monitor); } else if (entry.getType() == IRuntimeClasspathEntry.PROJECT) { IJavaProject javaProject = JavaRuntime.getJavaProject(configuration); if (javaProject.getPath().equals(entry.getPath())) { addProjectEntries(all, entry.getPath(), scope, THIS_PROJECT_CLASSIFIER, configuration, monitor); } else { addStandardClasspathEntries(all, entry, configuration); }//w ww. j ava2 s.c o m } else { addStandardClasspathEntries(all, entry, configuration); } } return all.toArray(new IRuntimeClasspathEntry[all.size()]); }
From source file:com.technophobia.eclipse.project.cache.listener.ClassFileChangedListener.java
License:Open Source License
private boolean isClassFileChange(final IJavaElementDelta delta, final IJavaProject javaProject) { try {/*from w w w . j a va 2s . c om*/ final IPath projectPath = javaProject.getPath(); if (isDeltaForProject(delta, projectPath)) { return affectedClassFiles(delta).size() > 0; } } catch (final CoreException ex) { FeatureEditorPlugin.instance().error( "Could not determine whether change delta " + delta + " contains a class file change", ex); } return false; }
From source file:com.windowtester.codegen.util.BuildPathUtil.java
License:Open Source License
/** * Appends target project build path with source project build path. * /*ww w. j a v a 2s . c o m*/ * @param targetProject the target project * @param sourceProject the source project * @throws CoreException */ public static void appendProjectBuildPath(IJavaProject targetProject, IJavaProject sourceProject) throws CoreException { try { // copy required entries to target IClasspathEntry[] srcEntries = sourceProject.getRawClasspath(); for (int i = 0; i < srcEntries.length; i++) { IClasspathEntry entry = srcEntries[i]; if (entry.isExported() || entry.getEntryKind() == IClasspathEntry.CPE_SOURCE) continue; addToClasspath(targetProject, entry); } // add the source project as a project entry IClasspathEntry srcPrjEntry = JavaCore.newProjectEntry(sourceProject.getPath()); addToClasspath(targetProject, srcPrjEntry); } catch (JavaModelException e) { // we interested only in core exceptions if (e.getCause() instanceof CoreException) { throw (CoreException) e.getCause(); } } }
From source file:com.windowtester.eclipse.ui.convert.WTAPIUsage.java
License:Open Source License
/** * Recursively iterate over the elements in the specified java element to convert each * compilation to use the new WindowTester API. * /*ww w. java 2s. c o m*/ * @param proj the java project (not <code>null</code>) * @param monitor the progress monitor (not <code>null</code>) */ private void scanProject(IJavaProject proj, IProgressMonitor monitor) throws JavaModelException { if (visited.contains(proj)) return; visited.add(proj); IPackageFragmentRoot[] roots = proj.getPackageFragmentRoots(); monitor.beginTask("Scanning " + proj.getPath(), roots.length); for (int i = 0; i < roots.length; i++) { scanPackageRoot(roots[i], new SubProgressMonitor(monitor, 1)); monitor.worked(1); } monitor.done(); }
From source file:com.windowtester.eclipse.ui.convert.WTConvertAPIRefactoring.java
License:Open Source License
/** * Recursively iterate over the elements in the specified java element to convert each * compilation to use the new WindowTester API. * /*from w ww . j a v a 2 s .co m*/ * @param proj the java project (not <code>null</code>) * @param monitor the progress monitor (not <code>null</code>) */ private void convertProject(IJavaProject proj, IProgressMonitor monitor) throws JavaModelException { if (visited.contains(proj)) return; visited.add(proj); IPackageFragmentRoot[] roots = proj.getPackageFragmentRoots(); monitor.beginTask("Converting " + proj.getPath(), roots.length); for (int i = 0; i < roots.length; i++) convertPackageRoot(roots[i], new SubProgressMonitor(monitor, 1)); monitor.done(); }
From source file:de.cau.cs.kieler.klassviz.handlers.SynthesizeClassDiagramHandler.java
License:Open Source License
/** * Save the selection in the plug-ins folder of the projects that has an selected element. * // w ww .ja v a2 s . c om * @param classModel the class model * @param projects the set of projects that have been selected */ private void saveSelection(KClassModel classModel, Set<IJavaProject> projects) { // Create a resource set. ResourceSet resourceSet = new ResourceSetImpl(); for (IJavaProject javaProject : projects) { // Path is: /metadata of the plugin/javaproject/selection.xmi URI platformURI = RestoreSelectionHandler.getStoredSelectionURI(javaProject.getPath()); // Create a resource for this file. Resource resource = resourceSet.createResource(platformURI); // Add the model objects to the contents. resource.getContents().add(classModel); // Save the contents of the resource to the file system. try { resource.save(Collections.EMPTY_MAP); } catch (IOException exception) { IStatus status = new Status(IStatus.ERROR, PLUGIN_ID, "Could not save selection to project meta data.", exception); StatusManager.getManager().handle(status); } } }
From source file:de.hentschel.visualdbc.generation.ui.test.testCase.swtbot.SWTBotGenerateDiagramWizardTest.java
License:Open Source License
/** * Tests manipulating the driver settings *//*from www . j a va 2s . c o m*/ @Test public void testManipulateDriverSettings() { try { // Create project structure IJavaProject javaProject = TestUtilsUtil .createJavaProject("SWTBotGenerateDiagramWizardTest_testManipulateDriverSettings"); // Select project in project explorer TestUtilsUtil.selectInProjectExplorer(bot, javaProject.getProject().getName()); // Get driver and open expected connection IDSDriver driver = DriverUtil.getDriver(UIDummyDriver1.class.getCanonicalName()); assertNotNull(driver); IDSConnection connection = driver.createConnection(); Map<String, Object> settings = TestGenerationUtil.createDefaultSettings(driver, SWTUtil.createSelection(javaProject.getPath())); settings.put(UIDummyDriver1.SETTING_BOOLEAN, Boolean.FALSE); settings.put(UIDummyDriver1.SETTING_PACKAGE, ResourceUtil.getLocation(javaProject.getProject())); connection.connect(settings, false, null); // Open new wizard ISWTBotShellManipulator manipulator = new ISWTBotShellManipulator() { @Override public void manipulate(SWTBotShell shell) { SWTBotButton finishButton = shell.bot().button("Finish"); assertTrue(finishButton.isEnabled()); // Unselect boolean value shell.bot().checkBox().deselect(); assertTrue(finishButton.isEnabled()); // Select invalid path shell.bot().text().setText("INVALID"); assertFalse(finishButton.isEnabled()); // Select valid file shell.bot().radio(1).click(); assertTrue(finishButton.isEnabled()); } }; TestGenerationUIUtil.createDiagramViaGenerateDiagramWizard(bot, true, javaProject.getProject().getFolder("src"), "Test.dbc_diagram", javaProject.getProject().getFolder("src"), "Test.dbc", driver, manipulator, true, connection); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:de.hentschel.visualdbc.generation.ui.test.testCase.swtbot.SWTBotGenerateDiagramWizardTest.java
License:Open Source License
/** * Executes a test with default settings. * @param projectName The project name./* w w w . j av a2 s. c o m*/ * @param earlyFinishAllowed Early finish allowed? * @param finish Finish or cancel wizard. */ protected void doTestDefaultValues(String projectName, boolean earlyFinishAllowed, boolean finish) { try { // Create project structure IJavaProject javaProject = TestUtilsUtil.createJavaProject(projectName); // Select project in project explorer TestUtilsUtil.selectInProjectExplorer(bot, javaProject.getProject().getName()); // Get driver and open expected connection IDSDriver driver = DriverUtil.getDriver(UIDummyDriver1.class.getCanonicalName()); assertNotNull(driver); IDSConnection connection = driver.createConnection(); Map<String, Object> settings = TestGenerationUtil.createDefaultSettings(driver, SWTUtil.createSelection(javaProject.getPath())); connection.connect(settings, false, null); // Open new wizard TestGenerationUIUtil.createDiagramViaGenerateDiagramWizard(bot, earlyFinishAllowed, javaProject.getProject().getFolder("src"), "Test.dbc_diagram", javaProject.getProject().getFolder("src"), "Test.dbc", driver, null, finish, connection); } catch (Exception e) { e.printStackTrace(); fail(e.getMessage()); } }
From source file:de.loskutov.bco.ui.JdtUtils.java
License:Open Source License
/** * @param javaElement/* ww w. j a v a2s . c o m*/ * @return absolute path of generated bytecode package for given element * @throws JavaModelException */ private static String getPackageOutputPath(IJavaElement javaElement) throws JavaModelException { String dir = ""; //$NON-NLS-1$ if (javaElement == null) { return dir; } IJavaProject project = javaElement.getJavaProject(); if (project == null) { return dir; } // default bytecode location IPath path = project.getOutputLocation(); IResource resource = javaElement.getUnderlyingResource(); if (resource == null) { return dir; } // resolve multiple output locations here if (project.exists() && project.getProject().isOpen()) { IClasspathEntry entries[] = project.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry classpathEntry = entries[i]; if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputPath = classpathEntry.getOutputLocation(); if (outputPath != null && classpathEntry.getPath().isPrefixOf(resource.getFullPath())) { path = outputPath; break; } } } } if (path == null) { // check the default location if not already included IPath def = project.getOutputLocation(); if (def != null && def.isPrefixOf(resource.getFullPath())) { path = def; } } if (path == null) { return dir; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (!project.getPath().equals(path)) { IFolder outputFolder = workspace.getRoot().getFolder(path); if (outputFolder != null) { // linked resources will be resolved here! IPath rawPath = outputFolder.getRawLocation(); if (rawPath != null) { path = rawPath; } } } else { path = project.getProject().getLocation(); } // here we should resolve path variables, // probably existing at first place of path IPathVariableManager pathManager = workspace.getPathVariableManager(); path = pathManager.resolvePath(path); if (path == null) { return dir; } if (isPackageRoot(project, resource)) { dir = path.toOSString(); } else { String packPath = EclipseUtils.getJavaPackageName(javaElement).replace(Signature.C_DOT, PACKAGE_SEPARATOR); dir = path.append(packPath).toOSString(); } return dir; }
From source file:de.loskutov.eclipse.jdepend.views.TreeObject.java
License:Open Source License
protected String getPackageOutputPath(IJavaElement jElement) throws JavaModelException { String dir = ""; //$NON-NLS-1$ if (jElement == null) { return dir; }/* w w w . j a v a 2 s .c o m*/ IJavaProject project = jElement.getJavaProject(); if (project == null) { return dir; } IPath path = project.getOutputLocation(); IResource resource = jElement.getUnderlyingResource(); if (resource == null) { return dir; } // resolve multiple output locations here if (project.exists() && project.getProject().isOpen()) { IClasspathEntry entries[] = project.getRawClasspath(); for (int i = 0; i < entries.length; i++) { IClasspathEntry classpathEntry = entries[i]; if (classpathEntry.getEntryKind() == IClasspathEntry.CPE_SOURCE) { IPath outputPath = classpathEntry.getOutputLocation(); if (outputPath != null) { // if this source folder contains specified java resource // then take bytecode location from himself if (classpathEntry.getPath().isPrefixOf(resource.getFullPath())) { path = outputPath; break; } } } } } if (path == null) { // check the default location if not already included IPath def = project.getOutputLocation(); if (def != null && def.isPrefixOf(resource.getFullPath())) { path = def; } } if (path == null) { return dir; } IWorkspace workspace = ResourcesPlugin.getWorkspace(); if (!project.getPath().equals(path)) { IFolder outputFolder = workspace.getRoot().getFolder(path); if (outputFolder != null) { // linked resources will be resolved here! IPath rawPath = outputFolder.getRawLocation(); if (rawPath != null) { path = rawPath; } } } else { path = project.getProject().getLocation(); } if (path == null) { return dir; } // here we should resolve path variables, // probably existing at first place of path IPathVariableManager pathManager = workspace.getPathVariableManager(); path = pathManager.resolvePath(path); if (path == null) { return dir; } boolean packageRoot = false; try { packageRoot = isPackageRoot(project, resource); } catch (JavaModelException e) { // seems to be a bug in 3.3 } if (packageRoot) { dir = path.toOSString(); } else { String packPath = getPackageName().replace('.', '/'); dir = path.append(packPath).toOSString(); } return dir; }