List of usage examples for org.eclipse.jdt.core IPackageFragmentRoot getResource
IResource getResource();
From source file:de.fxworld.generationgap.ui.properties.GapPropertyPage.java
License:Open Source License
@Override public boolean performOk() { if (configuration != null) { //sourceFolderCleanTableViewer.getCheckedElements() configuration.setGenerateEdit(generateEditButton.getSelection()); configuration.setGenerateEditor(generateEditorButton.getSelection()); configuration.setGenerateCustomClasses(generateCustomClassesButton.getSelection()); Object customClassTargetObject = ((IStructuredSelection) customClassTargetComboViewer.getSelection()) .getFirstElement();//from ww w .j a v a 2s.c om if ((customClassTargetObject != null) && (customClassTargetObject instanceof IPackageFragmentRoot)) { IPackageFragmentRoot customClassRoot = (IPackageFragmentRoot) customClassTargetObject; configuration.setCustomSrcPath(customClassRoot.getResource().getProjectRelativePath().toString()); } List<String> sourceFolders = new ArrayList<String>(); for (Object object : sourceFolderCleanTableViewer.getCheckedElements()) { IPackageFragmentRoot root = (IPackageFragmentRoot) object; sourceFolders.add(root.getResource().getProjectRelativePath().toString()); } configuration.setSrcPaths(sourceFolders); List<String> generatorModels = new ArrayList<String>(); for (Object object : generatorModelTableViewer.getCheckedElements()) { IFile file = (IFile) object; generatorModels.add(file.getProjectRelativePath().toString()); //IFile newFile = configuration.getJavaProject().getProject().getFile(file.getProjectRelativePath().toString()); } configuration.setGenModels(generatorModels); configuration.save(); } return super.performOk(); }
From source file:edu.pdx.cs.multiview.test.JavaTestProject.java
License:Open Source License
/** * Copy the files at this location into the source directory of this project. * @param location - the location//from ww w . j a va2 s.c om * @throws CoreException */ public void copyToSourceDir(String location) throws Exception { File source = new File(location); if (!source.exists()) throw new IllegalArgumentException("location does not exist"); IPackageFragmentRoot root = getSourceFolder(); IResource resource = root.getResource(); IPath rawLocation = resource.getRawLocation(); File destination = rawLocation.toFile(); copy(source, destination); getProject().refreshLocal(IResource.DEPTH_INFINITE, null); waitForJobsToComplete(getProject()); }
From source file:fede.workspace.eclipse.java.manager.PathFolderVariable.java
License:Apache License
public String compute(ContextVariable context, Item item) { ContentItem parent = item.getContentItem().getParentContentManager(); IPath p = new Path(""); if (parent != null) { IPackageFragmentRoot pfr = parent.getMainMappingContent(context, IPackageFragmentRoot.class); if (pfr != null) { p = pfr.getResource().getProjectRelativePath(); }/*from w w w . j av a2 s . c o m*/ } String _packageName = packageName.compute(context, item); if (_packageName != null) { p = p.append(_packageName.replace('.', '/')); } return p.toPortableString(); }
From source file:fr.imag.adele.cadse.cadseg.contents.CadseDefinitionContent.java
License:Apache License
/** * Gets the java source element./*from w w w . ja va 2 s. co m*/ * * @param cxt * the cxt * * @return the java source element */ public IContainer getCustomJavaSourceElementContainer(ContextVariable cxt) { IPackageFragmentRoot jp = getCustomJavaSourceElement(cxt); if (jp != null) { return (IContainer) jp.getResource(); } return null; }
From source file:fr.imag.adele.cadse.cadseg.contents.CadseDefinitionContent.java
License:Apache License
/** * Gets the source folder./* ww w . j a va 2 s . c o m*/ * * @param cxt * the cxt * * @return the source folder */ public IContainer getSourceFolder(ContextVariable cxt) { IPackageFragmentRoot je = getJavaSourceElement(cxt); if (je != null) { return (IContainer) je.getResource(); } return null; }
From source file:in.cypal.studio.gwt.core.launch.LaunchConfigurationDelegate.java
License:Apache License
public String[] getClasspath(ILaunchConfiguration configuration) throws CoreException { String projectName = configuration.getAttribute(Constants.LAUNCH_ATTR_PROJECT_NAME, ""); //$NON-NLS-1$ IJavaProject project = JavaCore.create(Util.getProject(projectName)); List classpath = new ArrayList(4); IPackageFragmentRoot[] packageFragmentRoots = project.getPackageFragmentRoots(); for (int i = 0; i < packageFragmentRoots.length; i++) { IPackageFragmentRoot packageFragmentRoot = packageFragmentRoots[i]; if (packageFragmentRoot.getKind() == IPackageFragmentRoot.K_SOURCE) { classpath.add(packageFragmentRoot.getResource().getLocation().toOSString()); }//w ww . j av a2 s . com } String[] classpath2 = super.getClasspath(configuration); for (int i = 0; i < classpath2.length; i++) { String aClasspath = classpath2[i]; classpath.add(aClasspath); } classpath.add(Util.getGwtDevLibPath().toPortableString()); return (String[]) classpath.toArray(new String[classpath.size()]); }
From source file:io.sarl.lang.ui.contentassist.SARLProposalProvider.java
License:Apache License
private static String extractProjectPath(IPath fileWorkspacePath, IJavaProject javaProject) { if (javaProject != null && javaProject.exists() && javaProject.isOpen()) { try {//from w ww . j a v a2s . c o m for (final IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { if (!root.isArchive() && !root.isExternal()) { final IResource resource = root.getResource(); if (resource != null) { final IPath sourceFolderPath = resource.getFullPath(); if (sourceFolderPath.isPrefixOf(fileWorkspacePath)) { final IPath claspathRelativePath = fileWorkspacePath .makeRelativeTo(sourceFolderPath); return claspathRelativePath.removeLastSegments(1).toString().replace("/", "."); //$NON-NLS-1$//$NON-NLS-2$ } } } } } catch (JavaModelException e) { Logger.getLogger(SARLProposalProvider.class).error(e.getLocalizedMessage(), e); } } return null; }
From source file:io.sarl.lang.ui.validation.SARLUIValidator.java
License:Apache License
private static String getRelativeSourceFolder(IJavaProject javaProject, IPath rootPath) throws JavaModelException { for (IPackageFragmentRoot root : javaProject.getPackageFragmentRoots()) { if (!root.isArchive() && !root.isExternal()) { IResource resource = root.getResource(); if (resource != null) { IPath sourceFolderPath = resource.getFullPath(); if (sourceFolderPath.isPrefixOf(rootPath)) { IPath classpathRelativePath = rootPath.makeRelativeTo(sourceFolderPath); return classpathRelativePath.removeLastSegments(1).toString().replace("/", "."); //$NON-NLS-1$//$NON-NLS-2$ }//from www.j ava 2 s . com } } } return null; }
From source file:io.spring.boot.development.eclipse.visitors.SpringFactories.java
License:Open Source License
static SpringFactories find(IProject project) { IJavaProject javaProject = JavaCore.create(project); try {//from w w w . j av a 2 s . c o m for (IPackageFragmentRoot root : javaProject.getAllPackageFragmentRoots()) { if (root.getKind() == IPackageFragmentRoot.K_SOURCE) { IFile springFactories = project.getFile( root.getResource().getProjectRelativePath().append("META-INF/spring.factories")); if (springFactories.exists()) { Properties properties = new Properties(); properties.load(springFactories.getContents()); return new SpringFactories(properties); } } } } catch (Exception ex) { throw new RuntimeException("Failure while finding spring.factories", ex); } return null; }
From source file:jmockit.assist.JunitLaunchListener.java
License:Open Source License
public boolean addJavaAgentVmArg(final ILaunchConfiguration conf) throws CoreException { boolean added = false; String vmargs = conf.getAttribute(JunitLaunchListener.VM_ARGS, ""); String project = conf.getAttribute(JunitLaunchListener.PROJ_ATTR, ""); IJavaModel javaModel = JavaCore.create(ResourcesPlugin.getWorkspace().getRoot()); IJavaProject jproj = javaModel.getJavaProject(project); IType mockitType = jproj.findType(MockUtil.MOCK); if (mockitType == null) { mockitType = jproj.findType(MockUtil.MOCKIT); }/*from ww w . j a v a 2s . c o m*/ if (mockitType != null) { IPackageFragmentRoot root = (IPackageFragmentRoot) mockitType .getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT); if (root != null && root.isArchive()) // its a jar { String jarPath = root.getPath().toOSString(); if (root.getResource() != null) { jarPath = root.getResource().getRawLocation().toString(); } if (new File(jarPath).exists()) { String javaagentArg = "-javaagent:\"" + jarPath + "\""; setOrCreateVariable(javaagentArg); if (!vmargs.contains(JunitLaunchListener.JMOCKIT_VAR) && !vmargs.contains("-javaagent")) { setRunConfVmArgs(conf, vmargs + " " + JunitLaunchListener.JMOCKIT_VAR); added = true; } } else { Activator.log(new FileNotFoundException(jarPath)); } } } return added; }