本文整理匯總了Java中org.eclipse.core.resources.IProject.getDescription方法的典型用法代碼示例。如果您正苦於以下問題:Java IProject.getDescription方法的具體用法?Java IProject.getDescription怎麽用?Java IProject.getDescription使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.core.resources.IProject
的用法示例。
在下文中一共展示了IProject.getDescription方法的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: removeGW4ENature
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Remove the GW4E nature from this project This remove the nature
* and the GraphWalker libraries from its classpath
*
* @param project
*/
public static void removeGW4ENature(IProject project) {
try {
IProjectDescription description = project.getDescription();
List<String> newNatures = new ArrayList<String>();
for (String natureId : description.getNatureIds()) {
if (!NATURE_ID.equals(natureId)) {
newNatures.add(natureId);
}
}
description.setNatureIds(newNatures.toArray(new String[newNatures.size()]));
project.setDescription(description, null);
} catch (CoreException e) {
ResourceManager.logException(e);
return;
}
}
示例3: setGW4ENature
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Set the GW4E Nature to the passed project
*
* @param project
* @return
* @throws CoreException
*/
public static IStatus setGW4ENature(IProject project) throws CoreException {
IProjectDescription description = project.getDescription();
String[] natures = description.getNatureIds();
String[] newNatures = new String[natures.length + 1];
System.arraycopy(natures, 0, newNatures, 0, natures.length);
// add our id
newNatures[natures.length] = GW4ENature.NATURE_ID;
// validate the natures
IWorkspace workspace = ResourcesPlugin.getWorkspace();
IStatus status = workspace.validateNatureSet(newNatures);
if (status.getCode() == IStatus.OK) {
description.setNatureIds(newNatures);
project.setDescription(description, null);
}
return status;
}
示例4: setBuilder
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Set the GW4E builder
*
* @param project
* @param monitor
* @throws CoreException
*/
public static void setBuilder(IProject project, IProgressMonitor monitor) throws CoreException {
IProjectDescription desc = project.getDescription();
ICommand[] commands = desc.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
return;
}
}
ICommand[] newCommands = new ICommand[commands.length + 1];
System.arraycopy(commands, 0, newCommands, 0, commands.length);
ICommand command = desc.newCommand();
command.setBuilderName(GW4EBuilder.BUILDER_ID);
newCommands[newCommands.length - 1] = command;
desc.setBuildSpec(newCommands);
project.setDescription(desc, null);
}
示例5: unsetBuilder
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Remove the GW4E builder
*
* @param project
* @param monitor
* @throws CoreException
*/
public static void unsetBuilder(IProject project, IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
ICommand[] commands = description.getBuildSpec();
for (int i = 0; i < commands.length; ++i) {
if (commands[i].getBuilderName().equals(GW4EBuilder.BUILDER_ID)) {
ICommand[] newCommands = new ICommand[commands.length - 1];
System.arraycopy(commands, 0, newCommands, 0, i);
System.arraycopy(commands, i + 1, newCommands, i, commands.length - i - 1);
description.setBuildSpec(newCommands);
project.setDescription(description, null);
GW4EBuilder.removeProjectProblemMarker(project, monitor);
return;
}
}
}
示例6: hasNature
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* Test whether the project has the passed nature
*
* @param receiver
* @param nature
* @return
*/
public static boolean hasNature(Object receiver, String nature) {
IProject project = JDTManager.toJavaProject(receiver);
if (project == null || !project.isOpen())
return false;
IProjectDescription description;
try {
description = project.getDescription();
} catch (CoreException e) {
ResourceManager.logException(e);
return false;
}
String[] natures = description.getNatureIds();
for (int i = 0; i < natures.length; i++) {
if (nature.equalsIgnoreCase(natures[i]))
return true;
}
return false;
}
示例7: addBuilder
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static void addBuilder(final IProject project) {
try {
// verify already registered builders
if (hasBuilder(project)) {
// already enabled
return;
}
// add builder to project properties
IProjectDescription description = project.getDescription();
final ICommand buildCommand = description.newCommand();
buildCommand.setBuilderName(BUILDER.ID);
final List<ICommand> commands = new ArrayList<ICommand>();
commands.addAll(Arrays.asList(description.getBuildSpec()));
commands.add(buildCommand);
description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
project.setDescription(description, null);
} catch (final CoreException e) {
Log.log(Log.LOG_ERROR, "Cannot add builder", e); //$NON-NLS-1$
}
}
示例8: removeBuilder
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static void removeBuilder(final IProject project) {
try {
final IProjectDescription description = project
.getDescription();
final List<ICommand> commands = new ArrayList<ICommand>();
commands.addAll(Arrays.asList(description.getBuildSpec()));
for (final ICommand buildSpec : description.getBuildSpec()) {
if (BUILDER.ID.equals(buildSpec.getBuilderName())) {
// remove builder
commands.remove(buildSpec);
}
}
description.setBuildSpec(commands.toArray(new ICommand[commands.size()]));
project.setDescription(description, null);
} catch (final CoreException e) {
Log.log(Log.LOG_ERROR, "Cannot remove builder", e); //$NON-NLS-1$
}
}
示例9: updateProjectReferencesIfNecessary
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
/**
* We have to set dynamic dependencies in the project meta data to ensure that the builder is correctly triggered
* according to the declared dependencies in the N4JS manifest files.
*
* @param project
* the project to update in respect of its dynamic references.
*/
public void updateProjectReferencesIfNecessary(final IProject project) {
if (project instanceof ExternalProject) {
return; // No need to adjust any dynamic references.
}
try {
IProject[] eclipseRequired = project.getDescription().getDynamicReferences();
Set<IProject> currentRequires = Sets.newHashSet(eclipseRequired);
final Set<IProject> newRequires = getProjectDependenciesAsSet(project);
if (currentRequires.equals(newRequires)) {
return;
}
IWorkspaceRunnable runnable = new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
IProjectDescription description = project.getDescription();
IProject[] array = newRequires.toArray(new IProject[newRequires.size()]);
description.setDynamicReferences(array);
project.setDescription(description, IResource.AVOID_NATURE_CONFIG, monitor);
}
};
internalWorkspace.getWorkspace().getWorkspace().run(runnable,
null /* cannot use a scheduling rule here since this is triggered lazily by the linker */,
IWorkspace.AVOID_UPDATE, null);
} catch (CoreException e) {
// ignore
}
}
示例10: finishPage
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException
{
fSecondPage.performFinish(monitor);
IProject project = fSecondPage.getJavaProject().getProject();
JPFProject.getPreferences(project).put(JPFClasspathPlugin.PREF_REGISTRY_NAME,
fFirstPage.getSelectedRegistry().getName());
IProjectDescription description = project.getDescription();
writePluginJpf(monitor, project);
JPFProjectNature.addNature(description);
project.setDescription(description, SubMonitor.convert(monitor, "Add JPF Project Nature", 1));
}
示例11: finishPage
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
@Override
protected void finishPage(IProgressMonitor monitor) throws InterruptedException, CoreException
{
fSecondPage.performFinish(monitor);
IProject project = fSecondPage.getJavaProject().getProject();
IProjectDescription description = project.getDescription();
JPFJarNature.addNature(description);
project.setDescription(description, SubMonitor.convert(monitor, "Add JPF Registry Nature", 1));
}
示例12: addNatureToProject
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
private static void addNatureToProject(IProject proj, String natureId, IProgressMonitor monitor)
throws CoreException {
IProjectDescription description = proj.getDescription();
String[] prevNatures = description.getNatureIds();
String[] newNatures = new String[prevNatures.length + 1];
System.arraycopy(prevNatures, 0, newNatures, 0, prevNatures.length);
newNatures[prevNatures.length] = natureId;
description.setNatureIds(newNatures);
proj.setDescription(description, monitor);
}
示例13: 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);
}
}
示例14: removeNature
import org.eclipse.core.resources.IProject; //導入方法依賴的package包/類
public static void removeNature(IProject project, String natureId) throws CoreException
{
IProjectDescription description = project.getDescription();
List<String> natures = Arrays.asList(description.getNatureIds());
natures.remove(natureId);
String[] newNatures = natures.toArray(new String[natures.size()]);
description.setNatureIds(newNatures);
project.setDescription(description, null);
}
示例15: 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");
}
}