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


Java IProject.hasNature方法代碼示例

本文整理匯總了Java中org.eclipse.core.resources.IProject.hasNature方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.hasNature方法的具體用法?Java IProject.hasNature怎麽用?Java IProject.hasNature使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.eclipse.core.resources.IProject的用法示例。


在下文中一共展示了IProject.hasNature方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addAsMainNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static void addAsMainNature(IProject project, String natureID, IProgressMonitor monitor) throws CoreException{
	if (monitor != null && monitor.isCanceled()) {
		throw new OperationCanceledException();
	}
	if (!project.hasNature(natureID)) {
		IProjectDescription description = project.getDescription();
		String[] natures = description.getNatureIds();
		String[] newNatures = new String[natures.length + 1];
		System.arraycopy(natures, 0, newNatures, 1, natures.length);
		newNatures[0] = natureID;
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	} else {
		if (monitor != null) {
			monitor.worked(1);
		}
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:19,代碼來源:AddRemoveGemocSequentialLanguageNatureHandler.java

示例2: decorate

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public void decorate(Object element, IDecoration decoration) {
    if (element instanceof IResource) {
        IResource res = (IResource) element;
        IProject proj = res.getProject();
        try {
            if (proj != null && proj.isAccessible() && proj.hasNature(NATURE.ID)) {
                IMarker[] markers = res.findMarkers(MARKER.ERROR, false,
                        IResource.DEPTH_INFINITE);
                if (markers.length > 0) {
                    decoration.addOverlay(PlatformUI.getWorkbench().getSharedImages()
                            .getImageDescriptor(ISharedImages.IMG_DEC_FIELD_ERROR));
                }
            }
        } catch (CoreException e) {
            Log.log(e);
        }
    }
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:20,代碼來源:PgDecorator.java

示例3: isRemoteEditNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
 * Returns {@code true} if the given project is of the
 * {@link ProjectLocationAwareWorkingSetManager#REMOTE_EDIT_PROJECT_NATURE_ID} nature.
 */
private boolean isRemoteEditNature(IProject project) {
	try {
		if (project.hasNature(REMOTE_EDIT_PROJECT_NATURE_ID)) {
			return true;
		}
	} catch (CoreException e) {
		return false;
	}
	return false;
}
 
開發者ID:eclipse,項目名稱:n4js,代碼行數:15,代碼來源:ProjectLocationAwareWorkingSetManager.java

示例4: addPluginNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void addPluginNature(IProject project) throws CoreException {
	if(!project.hasNature("org.eclipse.pde.PluginNature")) 
	{
		try {
			// create first the plugin.xml file
			PluginXMLHelper.createEmptyTemplateFile(project.getFile(PluginXMLHelper.PLUGIN_FILENAME), false);					
			// convert to plugin and add necessary entries in the build.properties
			PluginConverter.convert(project);							
		} 
		catch (InvocationTargetException | InterruptedException e) 
		{
			Activator.error("cannot add org.eclipse.pde.PluginNature nature to project due to " + e.getMessage(), e);
		}								
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio-modeldebugging,代碼行數:16,代碼來源:AddRemoveGemocSequentialLanguageNatureHandler.java

示例5: isInterestingProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private boolean isInterestingProject ( final IProject project )
{
    try
    {
        final boolean result = project.hasNature ( Constants.PROJECT_NATURE_CONFIGURATION );
        logger.debug ( "Checking project - project: {}, result: {}", project, result );
        return result;
    }
    catch ( final CoreException e )
    {
        StatusManager.getManager ().handle ( e.getStatus () );
        return false;
    }

}
 
開發者ID:eclipse,項目名稱:neoscada,代碼行數:16,代碼來源:ProjectBuilder.java

示例6: isPluginProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static boolean isPluginProject(IProject project)
{
	try
	{
		if( project.isOpen() && project.hasNature(JPFProjectNature.NATURE_ID) )
			return JPFProject.getManifest(project).exists();
	}
	catch( CoreException e )
	{
		return false;
	}
	return false;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:WorkspacePluginModelManager.java

示例7: isInterestingProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected boolean isInterestingProject(IProject project)
{
	try
	{
		return project.isOpen() && project.hasNature(JPFJarNature.NATURE_ID);
	}
	catch( CoreException e )
	{
		JPFClasspathLog.logError(e);
		return false;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:14,代碼來源:WorkspaceJarModelManager.java

示例8: getChildren

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
public Object[] getChildren(Object o)
{
	if( !(o instanceof IWorkspace) )
	{
		return new Object[0];
	}

	// Collect all the projects in the workspace except the given
	// project
	IProject[] projects = ((IWorkspace) o).getRoot().getProjects();
	List<IProject> referenced = new ArrayList<>(projects.length);
	boolean found = false;
	for( int i = 0; i < projects.length; i++ )
	{
		IProject otherProject = projects[i];
		if( !found && otherProject.equals(project) )
		{
			found = true;
			continue;
		}
		try
		{
			if( otherProject.isOpen() && otherProject.hasNature(JPFJarNature.NATURE_ID) )
			{
				referenced.add(otherProject);
			}
		}
		catch( CoreException e )
		{
			// ignore
		}
	}

	return referenced.toArray();
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:37,代碼來源:JarProjectContentProvider.java

示例9: hasNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static boolean hasNature(IProject project)
{
	try
	{
		return project.isOpen() && project.hasNature(NATURE_ID);
	}
	catch( CoreException e )
	{
		JPFClasspathLog.logError(e);
		return false;
	}
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:13,代碼來源:JPFProjectNature.java

示例10: getPrefs

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
 * @return pgCodeKeeper project preferences or null if wrong project
 */
public static IEclipsePreferences getPrefs(IProject proj) {
    try {
        if (proj.hasNature(NATURE.ID)) {
            return new ProjectScope(proj).getNode(PLUGIN_ID.THIS);
        }
    } catch (CoreException ex) {
        Log.log(ex);
    }
    return null;
}
 
開發者ID:pgcodekeeper,項目名稱:pgcodekeeper,代碼行數:14,代碼來源:PgDbProject.java

示例11: create

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
static public void create(IProject project) throws CoreException, IOException
{
	if(!project.hasNature(JavaCore.NATURE_ID)){
		JavaCore.create(project);
		IProjectUtils.addNature(project, JavaCore.NATURE_ID);
		IProjectUtils.createFolder(project, "src/main/java", new NullProgressMonitor());
		IProjectUtils.createFolder(project, "src/main/xdsml-java-gen", new NullProgressMonitor());
		addJavaResources(project);
	}		
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:11,代碼來源:JavaProject.java

示例12: addNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static void addNature(IProject project, String natureId) throws CoreException 
{
	IProjectDescription description = project.getDescription();
	String[] natures = description.getNatureIds();
	if (!project.hasNature(natureId)) 
	{
		String[] newNatures = new String[natures.length + 1];
		System.arraycopy(natures, 0, newNatures, 1, natures.length);
		newNatures[0] = natureId;
		description.setNatureIds(newNatures);
		project.setDescription(description, null);
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:14,代碼來源:IProjectUtils.java

示例13: toggleNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static NatureToggling toggleNature(IProject project, String natureId) throws CoreException
{
	if (!project.hasNature(natureId)) 
	{
		addNature(project, natureId);
		return NatureToggling.Added;
	}
	else 
	{
		removeNature(project, natureId);
		return NatureToggling.Removed;
	}
}
 
開發者ID:eclipse,項目名稱:gemoc-studio,代碼行數:14,代碼來源:IProjectUtils.java

示例14: addNature

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private void addNature(IProject project) throws CoreException{
	if(!project.hasNature(ProjectNature.NATURE_ID)){
		IProjectDescription description = project.getDescription();
		String[] prevNatures = description.getNatureIds();
		String[] newNatures = new String[prevNatures.length + 3];
		System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
		newNatures[prevNatures.length] = ProjectNature.NATURE_ID;
		newNatures[prevNatures.length + 1] = JavaCore.NATURE_ID;
		newNatures[prevNatures.length + 2] = ORG_ECLIPSE_M2E_CORE_MAVEN2_NATURE;

		// validate the natures
		IWorkspace workspace = ResourcesPlugin.getWorkspace();
		IStatus status = workspace.validateNatureSet(newNatures); 
		ICommand javaBuildCommand= description.newCommand();
		javaBuildCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
		ICommand mavenBuildCommand= description.newCommand();
		mavenBuildCommand.setBuilderName("org.eclipse.m2e.core.maven2Builder");
		ICommand[] iCommand = {javaBuildCommand, mavenBuildCommand};
		description.setBuildSpec(iCommand); 
		// only apply new nature, if the status is ok
		if (status.getCode() == IStatus.OK) {
			description.setNatureIds(newNatures);
			project.setDescription(description, null);
		}
		logger.debug("Project nature added"); 
	}
}
 
開發者ID:capitalone,項目名稱:Hydrograph,代碼行數:28,代碼來源:ProjectStructureCreator.java

示例15: getCurrentJavaProject

import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static IJavaProject getCurrentJavaProject() {
	IProject project = getCurrentProject();
	if(project != null){
		try {
			if (project.hasNature(JavaCore.NATURE_ID)) {
				return JavaCore.create(project);
			}
		} catch (CoreException e) {
			e.printStackTrace();
			throw new RuntimeException(e);
		}
	}
	return null;
}
 
開發者ID:bsteker,項目名稱:bdf2,代碼行數:15,代碼來源:ProjectHelper.java


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