List of usage examples for org.eclipse.jdt.core IJavaProject getElementName
String getElementName();
From source file:org.limy.eclipse.qalab.ant.QalabCreator.java
License:Open Source License
/** * |?[g?o^?[Qbg???B/*w ww . jav a 2s. c o m*/ * @param root ?[gvf * @param env * @param enableCreators LQAc?[ * @throws FileNotFoundException Kvt@C?? */ private void createReportTarget(XmlElement root, LimyQalabEnvironment env, AntCreator[] enableCreators) throws FileNotFoundException { IJavaProject project = env.getJavaProject(); XmlElement targetEl = createTargetElement(root, "qalab-report-only", "init"); XmlElement mkdirEl = XmlUtils.createElement(targetEl, "mkdir"); mkdirEl.setAttribute("dir", "${dest.dir}/qalab"); XmlElement styleEl1 = createVmstyleElement(targetEl, "${dest.dir}/qalab/index.html", "qalab/index.vm"); addVmParam(styleEl1, "projectName", project.getElementName()); XmlElement styleEl2 = createVmstyleElement(targetEl, "${dest.dir}/qalab/menu.html", "qalab/menu.vm"); String target = LimyCreatorUtils.createTargetString(enableCreators, null, 0, 1); XmlElement styleEl3 = null; XmlElement styleEl5 = null; if (target.length() > 0) { styleEl3 = createVmstyleElement(targetEl, "${qalab.xml}", "${dest.dir}/qalab/qalab.html", "qalab/qalab.vm"); addVmParam(styleEl3, "pluginVersion", "${plugin.version}"); IPreferenceStore store = env.getStore(); if (store.getBoolean(LimyQalabConstants.ENABLE_INDIVISUAL)) { addVmParam(styleEl3, "enable_indivisual"); createVmstyleElement(targetEl, "${qalab.xml}", "${dest.dir}/qalab/all-packages.html", "qalab/all_packages.vm"); styleEl5 = createVmstyleElement(targetEl, "${qalab.xml}", "${dest.dir}/qalab/dummy.html", "qalab/per_file_main.vm"); } } boolean enableQalab = false; boolean summaryGraph = false; for (AntCreator creator : enableCreators) { int group = creator.getSummaryGroup(); if (group >= 0) { addVmParam(styleEl2, creator.getTargetName()); addVmParam(styleEl3, creator.getTargetName()); addVmParam(styleEl5, creator.getTargetName()); } if (group == 0) { summaryGraph = true; } if (group == 0 || group == 1) { enableQalab = true; } } if (enableQalab) { addVmParam(styleEl1, "qalab"); addVmParam(styleEl2, "qalab"); } if (summaryGraph) { addVmParam(styleEl3, "enable_qalab"); } createMoverReport(targetEl, env, enableCreators); }
From source file:org.mybatis.generator.eclipse.core.callback.EclipseShellCallback.java
License:Apache License
/** * This method returns the first modifiable package fragment root in the * java project/*from w w w. j a va 2 s .co m*/ * * @param javaProject * @return */ private IPackageFragmentRoot getFirstSourceFolder(IJavaProject javaProject) throws ShellException { // find the first non-JAR package fragment root IPackageFragmentRoot[] roots; try { roots = javaProject.getPackageFragmentRoots(); } catch (CoreException e) { throw new ShellException(e.getStatus().getMessage(), e); } IPackageFragmentRoot srcFolder = null; for (int i = 0; i < roots.length; i++) { if (roots[i].isArchive() || roots[i].isReadOnly() || roots[i].isExternal()) { continue; } else { srcFolder = roots[i]; break; } } if (srcFolder == null) { StringBuffer sb = new StringBuffer(); sb.append("Cannot find source folder for project "); sb.append(javaProject.getElementName()); throw new ShellException(sb.toString()); } return srcFolder; }
From source file:org.mybatis.generator.eclipse.ui.launcher.GeneratorLaunchShortcut.java
License:Apache License
/** * This will return null if there isn't a JavaProject associated with this * resource./*from ww w . j a va2 s .com*/ * * @param resource * @return the JavaProject name if there is one */ public static String getJavaProjectNameFromResource(IResource resource) { String name = null; IProject project = resource.getProject(); try { if (project != null && project.exists() && project.hasNature(JavaCore.NATURE_ID)) { // add the JavaProject name to the launch - this will add it to the // classpath of the launch automatically IJavaProject javaProject = JavaCore.create(project); name = javaProject.getElementName(); } } catch (CoreException e) { // just ignore it - no ultimate harm done if we can't find the Java project } return name; }
From source file:org.nuxeo.ide.sdk.deploy.Deployment.java
License:Open Source License
protected void copyCompilationUnit(Set<String> commands, IPackageFragmentRoot root, ICompilationUnit unit) throws JavaModelException, CoreException { IJavaProject java = (IJavaProject) root.getParent(); String type = unitOutput(unit); IFolder nxdataFolder = nxdataFolder(java).getFolder(type); IProject project = java.getProject(); IPath outputLocation = java.getOutputLocation(); IPath path = unit.getPath().removeFirstSegments(root.getPath().segmentCount()).removeLastSegments(1); path = path.append(// w ww. j a v a 2 s . c o m org.eclipse.jdt.internal.core.util.Util.getNameWithoutJavaLikeExtension(unit.getElementName()) + ".class"); //$NON-NLS-1$ IContainer container = (IContainer) project.getWorkspace().getRoot().findMember(outputLocation); IResource dotClassMember = container.findMember(path); if (dotClassMember == null) { SDKPlugin.log(IStatus.ERROR, "Cannot find binary class " + path + " in project " + java.getElementName()); return; } IFile outputFile = nxdataFolder.getFile(path); mkdirs((IFolder) outputFile.getParent(), new NullProgressMonitor()); dotClassMember.copy(outputFile.getFullPath(), IResource.HIDDEN | IResource.DERIVED, new NullProgressMonitor()); commands.add(type + ":" + nxdataFolder.getLocation().toOSString()); }
From source file:org.nuxeo.ide.sdk.ui.widgets.ProjectChooser.java
License:Open Source License
@Override public String toString(IJavaProject value) { return value != null ? value.getElementName() : ""; }
From source file:org.obeonetwork.jdt2uml.core.api.Utils.java
License:Open Source License
public static String getModelFileName(IJavaProject javaProject) { return javaProject.getElementName() + ".model"; }
From source file:org.obeonetwork.jdt2uml.core.api.Utils.java
License:Open Source License
public static String getLibrariesFileName(IJavaProject javaProject) { return javaProject.getElementName() + ".libraries"; }
From source file:org.obeonetwork.jdt2uml.core.api.Utils.java
License:Open Source License
public static String createModelPath(IJavaProject javaProject, String fileName) { return '/' + javaProject.getElementName() + "/target/uml/" + fileName + ".uml"; }
From source file:org.obeonetwork.jdt2uml.creator.api.job.ExportModels.java
License:Open Source License
private BuildTodo recursiveTODO(IJavaProject javaProject, IProgressMonitor monitor) throws CoreException { LibVisitor libVisitor = CreatorFactory.createLibVisitor(monitor); ProjectVisitor projectVisitor = CreatorFactory.createProjectVisitor(monitor); BuildDescriptor libraryDescriptor = new BuildDescriptorImpl( "Export Libraries Model in " + javaProject.getElementName(), javaProject, libVisitor); BuildDescriptor projectDescriptor = new BuildDescriptorImpl( "Export Project Model in " + javaProject.getElementName(), javaProject, projectVisitor); BuildTodo result = CoreFactory.createBuildTodo(javaProject, projectDescriptor, libraryDescriptor); IProject[] referencedProjects = javaProject.getProject().getReferencedProjects(); for (IProject referencedProject : referencedProjects) { if (referencedProject.hasNature(JavaCore.NATURE_ID)) { IJavaProject referencedJDTProject = JavaCore.create(referencedProject); BuildTodo recursiveTODOs = recursiveTODO(referencedJDTProject, monitor); result.addSubBuildTodos(recursiveTODOs); }//from w w w .j ava 2 s . co m } return result; }
From source file:org.objectstyle.wolips.launching.actions.WOJavaApplicationLaunchShortcut.java
License:Open Source License
/** * Returns a list of classpath URLs for the given project that should match * what you'd get at runtime.//from w ww. j av a 2 s . c o m * * @param javaProject the java project to generate a classpath for * @return a list of classpath URLs for the given project */ public static List<URL> createClasspathURLsForProject(IJavaProject javaProject) throws CoreException, MalformedURLException { ILaunchManager launchManager = DebugPlugin.getDefault().getLaunchManager(); ILaunchConfigurationWorkingCopy wc = null; ILaunchConfigurationType launchConfigurationType = launchManager.getLaunchConfigurationType( WOJavaLocalApplicationLaunchConfigurationDelegate.WOJavaLocalApplicationID); wc = launchConfigurationType.newInstance(null, launchManager.generateUniqueLaunchConfigurationNameFrom("Entity Modeler SQL Generation")); // wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_MAIN_TYPE_NAME, // type.getFullyQualifiedName()); wc.setAttribute(IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, javaProject.getElementName()); wc.setMappedResources(new IResource[] { javaProject.getProject() }); WOJavaLocalApplicationLaunchConfigurationDelegate.initConfiguration(wc); IRuntimeClasspathEntry[] runtimeClasspathEntries = JavaRuntime.computeUnresolvedRuntimeClasspath(wc); runtimeClasspathEntries = JavaRuntime.resolveRuntimeClasspath(runtimeClasspathEntries, wc); List<String> userEntries = new ArrayList<String>(runtimeClasspathEntries.length); Set<String> set = new HashSet<String>(runtimeClasspathEntries.length); for (int i = 0; i < runtimeClasspathEntries.length; i++) { if (runtimeClasspathEntries[i].getClasspathProperty() == IRuntimeClasspathEntry.USER_CLASSES) { String location = runtimeClasspathEntries[i].getLocation(); if (location != null) { if (!set.contains(location)) { userEntries.add(location); set.add(location); } } } } String[] classpathEntryStrings = userEntries.toArray(new String[userEntries.size()]); List<URL> classpathUrls = new LinkedList<URL>(); for (String str : classpathEntryStrings) { classpathUrls.add(new File(str).toURL()); } return classpathUrls; }