本文整理汇总了Java中org.eclipse.jdt.core.IJavaProject.getProject方法的典型用法代码示例。如果您正苦于以下问题:Java IJavaProject.getProject方法的具体用法?Java IJavaProject.getProject怎么用?Java IJavaProject.getProject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.eclipse.jdt.core.IJavaProject
的用法示例。
在下文中一共展示了IJavaProject.getProject方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getSelectedPathInProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Lets get the path of hat have been selected in the UI - the complete path
* a path is something like "src/main/resources"
*
* @param receiver
* @return
*/
public static String getSelectedPathInProject(Object receiver) {
if (!ResourceManager.isPackageFragmentRoot(receiver)) {
return null;
}
IPackageFragmentRoot pkg = (IPackageFragmentRoot) receiver;
IJavaProject javaProject = pkg.getJavaProject();
if (javaProject == null)
return null;
IProject project = javaProject.getProject();
if (!GW4ENature.hasGW4ENature(project))
return null;
String projectName = pkg.getJavaProject().getElementName();
int pos = projectName.length();
String input = pkg.getPath().toString().substring(pos + 2);
return input;
}
示例2: findProject
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
/**
* Given a stack frame, find the target project that the associated source file belongs to.
*
* @param stackFrame
* the stack frame.
* @param containers
* the source container list.
* @return the context project.
*/
public static IProject findProject(StackFrame stackFrame, ISourceContainer[] containers) {
Location location = stackFrame.location();
try {
Object sourceElement = findSourceElement(location.sourcePath(), containers);
if (sourceElement instanceof IResource) {
return ((IResource) sourceElement).getProject();
} else if (sourceElement instanceof IClassFile) {
IJavaProject javaProject = ((IClassFile) sourceElement).getJavaProject();
if (javaProject != null) {
return javaProject.getProject();
}
}
} catch (AbsentInformationException e) {
// When the compiled .class file doesn't contain debug source information, return null.
}
return null;
}
示例3: initialize
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
@Override
public void initialize(IPath containerPath, IJavaProject javaProject) throws CoreException
{
IProject project = javaProject.getProject();
IPluginModel model = JPFPluginModelManager.instance().findModel(project);
JavaCore.setClasspathContainer(containerPath, new IJavaProject[] { javaProject },
new IClasspathContainer[] { new JPFClasspathContainer(model) }, null);
}
示例4: testRemove
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
@Test
public void testRemove() throws Exception {
IJavaProject pj = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME, false, false);
String[] values = new String[] { PreferenceManager.SUFFIX_PREFERENCE_FOR_TEST_IMPLEMENTATION };
SettingsManager.remove(pj.getProject(), values);
IScopeContext context = new ProjectScope(pj.getProject());
IEclipsePreferences projectPreferences = context.getNode(Activator.PLUGIN_ID);
String val = projectPreferences.get(PreferenceManager.SUFFIX_PREFERENCE_FOR_TEST_IMPLEMENTATION, "");
assertEquals("", val);
}
示例5: addMarker
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
private void addMarker(String msg,int severity) throws Exception {
IJavaProject pj = ProjectHelper.getOrCreateSimpleGW4EProject(PROJECT_NAME,true,false);
IFile file = (IFile) ResourceManager.getResource(pj.getProject().getFullPath().append("src/test/resources/Simple.json").toString());
MarkerManager.addMarker(file, this, createParserException(msg), severity);
MarkerCondition mc = new MarkerCondition(pj.getProject(),GW4EBuilder.MARKER_TYPE, msg, severity);
Waiter.waitUntil(mc);
}
示例6: addFolderToClassPath
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public static IPackageFragmentRoot addFolderToClassPath(IJavaProject jproject, String containerName)
throws CoreException {
IProject project = jproject.getProject();
IFolder folder = project.getFolder(containerName);
if (!folder.exists()) {
createFolder(folder, false, true, new NullProgressMonitor());
}
IClasspathEntry cpe = JavaCore.newLibraryEntry(folder.getFullPath(), null, null);
addToClasspath(jproject, cpe);
return jproject.getPackageFragmentRoot(folder);
}
示例7: getFixImportProposals
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
@Override
public ClasspathFixProposal[] getFixImportProposals(final IJavaProject project, String name) throws CoreException
{
IProject requestedProject = project.getProject();
if( !requestedProject.hasNature(JPFProjectNature.NATURE_ID) )
{
return null;
}
ArrayList<ClasspathFixProposal> props = new ArrayList<ClasspathFixProposal>();
IWorkspace workspace = ResourcesPlugin.getWorkspace();
int idx = name.lastIndexOf('.');
char[] packageName = idx != -1 ? name.substring(0, idx).toCharArray() : null;
char[] typeName = name.substring(idx + 1).toCharArray();
if( typeName.length == 1 && typeName[0] == '*' )
{
typeName = null;
}
ArrayList<TypeNameMatch> res = new ArrayList<TypeNameMatch>();
TypeNameMatchCollector requestor = new TypeNameMatchCollector(res);
IJavaSearchScope scope = SearchEngine.createWorkspaceScope();
int matchMode = SearchPattern.R_EXACT_MATCH | SearchPattern.R_CASE_SENSITIVE;
new SearchEngine().searchAllTypeNames(packageName, matchMode, typeName, matchMode, IJavaSearchConstants.TYPE,
scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, null);
if( res.isEmpty() )
{
return null;
}
JPFPluginModelManager service = JPFPluginModelManager.instance();
for( TypeNameMatch curr : res )
{
IType type = curr.getType();
if( type != null )
{
IPackageFragmentRoot root = (IPackageFragmentRoot) type.getAncestor(IJavaElement.PACKAGE_FRAGMENT_ROOT);
IPluginModel model = null;
if( root.isArchive() )
{
model = service.findModel((IFile) root.getResource());
}
else if( !root.isExternal() )
{
model = service.findModel(root.getResource().getProject());
}
if( model != null )
{
System.err.println("Found in " + model.getParsedManifest().getId());
props.add(new JPFClasspathFixProposal(project, JPFProject.getManifest(requestedProject), model));
}
}
}
return props.toArray(new ClasspathFixProposal[props.size()]);
}
示例8: execute
import org.eclipse.jdt.core.IJavaProject; //导入方法依赖的package包/类
public Object execute(ExecutionEvent event) throws ExecutionException {
boolean autoBuilding = ResourcesPlugin.getWorkspace().getDescription().isAutoBuilding();
IWorkbenchWindow aww = HandlerUtil.getActiveWorkbenchWindow(event);
ISelection sel = HandlerUtil.getCurrentSelection(event);
if (sel.isEmpty())
return null;
if (sel instanceof IStructuredSelection) {
IStructuredSelection selection = (IStructuredSelection) sel;
if (selection != null) {
Object obj = selection.getFirstElement();
if (obj != null) {
try {
IResource selectedResource = null;
if (obj instanceof IJavaProject) {
IJavaProject jp = (IJavaProject) obj;
selectedResource = jp.getProject();
}
if (obj instanceof IPackageFragmentRoot) {
IPackageFragmentRoot pfr = (IPackageFragmentRoot) obj;
selectedResource = pfr.getCorrespondingResource();
}
if (obj instanceof IPackageFragment) {
IPackageFragment pf = (IPackageFragment) obj;
selectedResource = pf.getCorrespondingResource();
}
if (selectedResource != null && !selectedResource.exists())
return null;
// This is where the synchronization is done ...
ResourceManager.setAutoBuilding(false);
GraphWalkerContextManager.synchronizeBuildPolicies(selectedResource, aww);
} catch (Exception e) {
ResourceManager.logException(e);
} finally {
ResourceManager.setAutoBuilding(autoBuilding);
}
}
}
}
return null;
}