當前位置: 首頁>>代碼示例>>Java>>正文


Java IJavaProject.getProject方法代碼示例

本文整理匯總了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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:28,代碼來源:ResourceManager.java

示例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;
}
 
開發者ID:Microsoft,項目名稱:java-debug,代碼行數:27,代碼來源:JdtUtils.java

示例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);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:9,代碼來源:JPFClasspathContainerInitializer.java

示例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);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:13,代碼來源:SettingsManagerTest.java

示例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);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:8,代碼來源:MarkerManagerTest.java

示例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);
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:14,代碼來源:ProjectHelper.java

示例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()]);
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:58,代碼來源:JPFClasspathFixProcessor.java

示例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;
}
 
開發者ID:gw4e,項目名稱:gw4e.project,代碼行數:42,代碼來源:SynchronizeBuildPoliciesHandler.java


注:本文中的org.eclipse.jdt.core.IJavaProject.getProject方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。