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


Java IProjectNature類代碼示例

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


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

示例1: selectionChanged

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
@Override
public void selectionChanged(IAction action, ISelection selection) {
    if (!(selection instanceof IStructuredSelection)) {
        project = null;
        return;
    }
    IStructuredSelection ssel = (IStructuredSelection) selection;
    Object firstElement = ssel.getFirstElement();
    if(firstElement == null) {
        project = null;
        return;
    }
    project = getProject(firstElement);
    if (project != null) {
        return;
    }
    if (firstElement instanceof IResource) {
        project = ((IResource) firstElement).getProject();
    }
    if (project != null) {
        return;
    }
    if (firstElement instanceof IProjectNature) {
        project = ((IProjectNature) firstElement).getProject();
    }
}
 
開發者ID:iloveeclipse,項目名稱:filesync4eclipse,代碼行數:27,代碼來源:ForceFileSyncActionDelegate.java

示例2: addNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public void addNature(IProject project, String nature_id) {
	if(project.isOpen() == false) {
		return;
	}
	
	try {
		IProjectDescription pd	= project.getDescription();
		IProjectNature nature	= project.getNature(nature_id);
		
		if(nature == null) {
			List<String> newNatures	= new ArrayList<String>();
		    newNatures.addAll(Arrays.asList(pd.getNatureIds()));
		    newNatures.add(nature_id);
		    pd.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
		    project.setDescription(pd, null);
		}
	} catch(Exception e) {
		/* Do Nothing */
	}
}
 
開發者ID:MyChannel-Apps,項目名稱:Extensions,代碼行數:21,代碼來源:KnuddelsWizard.java

示例3: decorate

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
@Override
public void decorate(Object element, IDecoration decoration) {
	// TODO Auto-generated method stub
	if(element instanceof IFolder)
	{
		try{
			IFolder folder = (IFolder)element;
			IProjectNature nature = folder.getProject().getNature(WTNewProjectNature.ID);
			if(nature!=null){
				//Search XMI
				IFile file = folder.getFile(folder.getName().concat(".xmi"));
				if(file.exists()){
					XMI_File file_xmi = new XMI_File(URI.createFileURI(file.getFullPath().toString()));
					EObject root = file_xmi.Get_Root();
				}						
			}
			
		}catch(Throwable th){/*Ignore if file is not found*/ }
	}
	
}
 
開發者ID:mondo-project,項目名稱:mondo-demo-wt,代碼行數:22,代碼來源:ModularProjectDecorator.java

示例4: getSpifeNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
private SpifeGenericProjectNature getSpifeNature(IResource resource) {
	SpifeLabelProviderNature labelProviderNature = getSpifeLabelProviderNature(resource);
	if (labelProviderNature != null) {
		return labelProviderNature;
	}
	try {
		IProject project = resource.getProject();
		if (project != null) {
			IProjectNature nature = project.getNature(SpifeProjectNature.ID);
			if (nature instanceof SpifeProjectNature) {
				return (SpifeProjectNature) nature;
			}
		}
	} catch (CoreException e) {
		//silent fail
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:19,代碼來源:SpifeNavigatorLabelProvider.java

示例5: getSpifeLabelProviderNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
private SpifeLabelProviderNature getSpifeLabelProviderNature(IResource resource) {
	IProject project = resource.getProject();
	if (project != null) {
		try {
			IProjectDescription description = project.getDescription();
			String[] natureIds = description.getNatureIds();
			List<SpifeLabelProviderNature> labelProviderNatures = new ArrayList();
			for (String natureID : natureIds) {
				IProjectNature nature = project.getNature(natureID);
				if (nature instanceof SpifeLabelProviderNature) {
					labelProviderNatures.add((SpifeLabelProviderNature) nature);
				}
			}
			if (labelProviderNatures.size() > 1) {
				LogUtil.error("Found " + labelProviderNatures.size() + " SpifeLabelProviderNature's. Can't have more than one! Returning generic.");
			} else if (labelProviderNatures.size() == 1){
				return labelProviderNatures.get(0);
			}
		} catch (CoreException e) {
			//silent fail
		}
	}
	return null;
}
 
開發者ID:nasa,項目名稱:OpenSPIFe,代碼行數:25,代碼來源:SpifeNavigatorLabelProvider.java

示例6: isOnBuildPath

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public static boolean isOnBuildPath(IJavaElement element) {
       //fix for bug http://dev.eclipse.org/bugs/show_bug.cgi?id=20051
       if (element.getElementType() == IJavaElement.JAVA_PROJECT)
           return true;
	IJavaProject project= element.getJavaProject();
	try {
		if (!project.isOnClasspath(element))
			return false;
		IProject resourceProject= project.getProject();
		if (resourceProject == null)
			return false;
		IProjectNature nature= resourceProject.getNature(JavaCore.NATURE_ID);
		// We have a Java project
		if (nature != null)
			return true;
	} catch (CoreException e) {
	}
	return false;
}
 
開發者ID:trylimits,項目名稱:Eclipse-Postfix-Code-Completion,代碼行數:20,代碼來源:ActionUtil.java

示例7: addJavaNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public static IJavaProject addJavaNature(IProject project, boolean rawClasspath) throws CoreException, JavaModelException {
 
	 IProjectNature nature = project.getNature(ProjectConstants.JAVA_NATURE_ID);
	 if(nature==null){
	    ProjectUtils.addNatureToProject(project, true, ProjectConstants.JAVA_NATURE_ID);
	 }
	IJavaProject javaProject = JavaCore.create(project);
	IFolder targetFolder = project.getFolder("target");
	targetFolder.create(false, true, null);
	javaProject.setOutputLocation(targetFolder.getFullPath(), null);
	Set<IClasspathEntry> entries = new HashSet<IClasspathEntry>();
	if(rawClasspath){
		entries.addAll(Arrays.asList(getClasspathEntries(javaProject)));
	}
	if(nature==null){
		entries.add(JavaRuntime.getDefaultJREContainerEntry());
	 }
	javaProject.setRawClasspath(entries.toArray(new IClasspathEntry[entries.size()]), null);
	return javaProject;
}
 
開發者ID:wso2,項目名稱:developer-studio,代碼行數:21,代碼來源:JavaUtils.java

示例8: createRadlFile

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public IFile createRadlFile(String folderName, String serviceName, IProgressMonitor monitor,
    IWorkspaceRoot root) throws CoreException {
  IFolder folder = root.getFolder(new Path(folderName));
  if (!folder.exists()) {
    ensureFolder(monitor, folder);
  }
  final IFile result = folder.getFile(serviceNameToFileName(serviceName));
  try (InputStream stream = getRadlSkeleton(serviceName)) {
    if (result.exists()) {
      result.setContents(stream, true, true, monitor);
    } else {
      result.create(stream, true, monitor);
    }
  } catch (IOException e) { // NOPMD EmptyCatchBlock
  }
  IProjectNature nature = new RadlNature();
  nature.setProject(folder.getProject());
  nature.configure();
  return result;
}
 
開發者ID:restful-api-description-language,項目名稱:RADL,代碼行數:21,代碼來源:RadlCreator.java

示例9: get

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public static @Nullable RustNature get(final @Nullable IProject p, boolean askAddNature) {
	if (p == null) {
		return null;
	}
	try {
		IProjectNature nat = p.getNature(NATURE_ID);
		if (nat instanceof RustNature) {
			return (RustNature) nat;
		} else if (askAddNature) {
			final boolean answer[] = new boolean[] {false};
			Display.getDefault().syncExec(() -> {
				answer[0] = MessageDialog.openQuestion(null, "No Rust nature", "No Rust nature was found for the project " + p.getName() + ".\n"
						+ "Do you want to add the Rust nature?");
			});
			if (answer[0]) {
				addNatureToProject(p);
				return get(p);
			}
		}
	} catch (CoreException e) {
		e.printStackTrace();
	}
	return null;
}
 
開發者ID:peq,項目名稱:rustyeclipse,代碼行數:25,代碼來源:RustNature.java

示例10: getScenarioNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public static ScenarioNature getScenarioNature(IProject project)
{
    if (project == null) {
        return null;
    }

    try
    {
        IProjectNature nature = project.getNature(NATURE_ID);
        if (nature instanceof ScenarioNature)
        {
            return (ScenarioNature) nature;
        }
    }
    catch (CoreException e)
    {
        e.printStackTrace();
    }
    return null;
}
 
開發者ID:vobject,項目名稱:maru,代碼行數:21,代碼來源:ScenarioNature.java

示例11: getDjangoNature

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
/**
 * @param project the project we want to know about (if it is null, null is returned)
 * @return the django nature for a project (or null if it does not exist for the project)
 * 
 * @note: it's synchronized because more than 1 place could call getDjangoNature at the same time and more
 * than one nature ended up being created from project.getNature().
 */
public static DjangoNature getDjangoNature(IProject project) {
    if (project != null && project.isOpen()) {
        try {
            if (project.hasNature(DJANGO_NATURE_ID)) {
                synchronized (lockGetNature) {
                    IProjectNature n = project.getNature(DJANGO_NATURE_ID);
                    if (n instanceof DjangoNature) {
                        return (DjangoNature) n;
                    }
                }
            }
        } catch (CoreException e) {
            Log.logInfo(e);
        }
    }
    return null;
}
 
開發者ID:fabioz,項目名稱:Pydev,代碼行數:25,代碼來源:DjangoNature.java

示例12: setElement

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public void setElement(IAdaptable element) {
	if (element instanceof IProject) {
		project = (IProject) element;
	} else if (element instanceof IProjectNature) {
		IProjectNature pn = (IProjectNature) element;
		project = pn.getProject();
	}
}
 
開發者ID:UrsZeidler,項目名稱:uml2solidity,代碼行數:9,代碼來源:AbstractProjectPreferencesPage.java

示例13: isProject

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
public static boolean isProject(IProject pro) 
{
	IProjectNature nature_modular = null;
	try {
		nature_modular = pro.getNature(Project_Nature);
	} catch (CoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	if(nature_modular==null)
		return false;
	else
		return true;		
}
 
開發者ID:mondo-project,項目名稱:mondo-demo-wt,代碼行數:15,代碼來源:AllElementsPropertySource.java

示例14: getChoicesOfValuesWS

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
@SuppressWarnings("unchecked")
public EList<?> getChoicesOfValuesWS(String modularNature, EClass anEClass){
	
	EList<EObject> result = new BasicEList<EObject>();
	IProject[] projs = ResourcesPlugin.getWorkspace().getRoot().getProjects();
	int count = projs.length;
	IProjectNature nat = null;
	IProject current_pro = null;
	ResourceSet set = new ResourceSetImpl();
	Resource res = null;
	EList<?> project_result = null;
	try {
		for (int i = 0; i < count; i++) {
			current_pro = projs[i];
			nat = current_pro.getNature(modularNature);
			if(nat!=null){
				IFile fil = current_pro.getFile(new Path(current_pro.getName() + ".xmi"));	
				res = set.createResource(URI.createPlatformResourceURI(fil.getFullPath().toString(), true));
				project_result =  getChoicesOfValuesProject(res, anEClass);
				if(project_result!=null)
				{
					result.addAll((EList<? extends EObject>) project_result);
					project_result = null;
				}
			}				
		}			
	} catch (CoreException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	
	return result;
}
 
開發者ID:mondo-project,項目名稱:mondo-demo-wt,代碼行數:34,代碼來源:WTModularCrossReferences.java

示例15: checkProject

import org.eclipse.core.resources.IProjectNature; //導入依賴的package包/類
private boolean checkProject (InputAlternative ia)
{
	String projectName = ia.getExtractedProjectName();
	
	if (projectName == null || projectName.isEmpty())
	{
		ia.getSelfStatus().addWarning(INFO_NO_PROJECT_NAME, IValidationStatus.SEVERITY_ERROR, "Project is missing.");
		return false;
	}
	
	IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
	IProject project = root.getProject(projectName);
	
	if (project == null || !project.exists())
	{
		ia.getSelfStatus().addWarning(INFO_NO_PROJECT, IValidationStatus.SEVERITY_ERROR, "Project does not exist. -> Project Name = "+projectName);
		return false;
	}
	
	
	final String JAVA_NATURE_ID = "org.eclipse.jdt.core.javanature";
	try
	{
		IProjectNature nature = project.getNature(JAVA_NATURE_ID);
		if (nature == null) throw new Exception();
	} catch (Exception e)
	{
		ia.getSelfStatus().addWarning(INFO_NO_PROJECT_JAVA, IValidationStatus.SEVERITY_ERROR, "Project is not Java nature.");
		return false;
	}
	
	return true;
}
 
開發者ID:CloudScale-Project,項目名稱:Environment,代碼行數:34,代碼來源:InputValidator.java


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