📄 preprocessedprojectmigrationrunnable.java
字号:
/**
* Copyright (c) 2003-2007 Craig Setera
* All Rights Reserved.
* Licensed under the Eclipse Public License - v 1.0
* For more information see http://www.eclipse.org/legal/epl-v10.html
*/
package eclipseme.core.internal;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspaceRoot;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.jdt.core.JavaCore;
import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.core.nature.BuildSpecManipulator;
/**
* A workspace runnable that walks through the workspace projects and migrates
* the preprocessor natures and builders such that the preprocessor works
* within the project rather than requiring the secondary project.
* <p />
* Copyright (c) 2003-2007 Craig Setera<br>
* All Rights Reserved.<br>
* Licensed under the Eclipse Public License - v 1.0<p/>
* <br>
* $Revision$
* <br>
* $Date$
* <br>
* @author Craig Setera
*/
public class PreprocessedProjectMigrationRunnable implements IWorkspaceRunnable {
/**
* @see org.eclipse.core.resources.IWorkspaceRunnable#run(org.eclipse.core.runtime.IProgressMonitor)
*/
public void run(IProgressMonitor monitor)
throws CoreException
{
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
IProject[] projects = root.getProjects();
for (int i = 0; i < projects.length; i++) {
IProject project = projects[i];
if (project.isOpen()) {
migrateProject(project, monitor);
}
}
}
/**
* The specified project is doing preprocessing. Update the builders and
* natures to match the new implementation.
*
* @param project
* @param monitor
* @throws CoreException
*/
private void migratePreprocessingProject(IProject project, IProgressMonitor monitor)
throws CoreException
{
BuildSpecManipulator manipulator = new BuildSpecManipulator(project);
if (!manipulator.hasBuilder(JavaCore.BUILDER_ID)) {
manipulator.addBuilderBefore(
IEclipseMECoreConstants.J2ME_PREVERIFIER_ID,
JavaCore.BUILDER_ID,
null);
}
if (!manipulator.hasBuilder(IEclipseMECoreConstants.J2ME_PREPROCESSOR_ID)) {
manipulator.addBuilderBefore(
JavaCore.BUILDER_ID,
IEclipseMECoreConstants.J2ME_PREPROCESSOR_ID,
null);
}
if (manipulator.hasArguments(IEclipseMECoreConstants.J2ME_PREVERIFIER_ID)) {
manipulator.replaceBuilder(IEclipseMECoreConstants.J2ME_PREVERIFIER_ID, null);
}
manipulator.commitChanges(monitor);
}
/**
* The specified project is open, so go ahead and attempt to migrate that project.
*
* @param project
* @param monitor
* @throws CoreException
*/
private void migrateProject(IProject project, IProgressMonitor monitor)
throws CoreException
{
if (project.hasNature(EclipseMECorePlugin.J2ME_PREPROCESSING_NATURE_ID)) {
migratePreprocessingProject(project, monitor);
} else if (project.hasNature(EclipseMECorePlugin.J2ME_PREPROCESSED_NATURE_ID)) {
// We no longer require this secondary project for the new implementation
// so go ahead and delete it
project.delete(true, monitor);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -