⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 emulationjavasourcepathcomputer.java

📁 eclipseme的最新版本的source,欢迎j2me程序员使用
💻 JAVA
字号:
/**
 * Copyright (c) 2003-2006 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.launching;

import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.debug.core.ILaunchConfiguration;
import org.eclipse.debug.core.sourcelookup.ISourceContainer;
import org.eclipse.jdt.core.IJavaProject;
import org.eclipse.jdt.core.JavaCore;
import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
import org.eclipse.jdt.launching.sourcelookup.containers.JavaProjectSourceContainer;
import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer;

import eclipseme.core.IEclipseMECoreConstants;
import eclipseme.core.internal.EclipseMECorePlugin;
import eclipseme.core.internal.preprocessor.PreprocessorBuilder;

/**
 * Overrides the standard {@link JavaSourcePathComputer} to point the source folder
 * into the preprocessed project.
 * <p />
 * Copyright (c) 2003-2006 Craig Setera<br>
 * All Rights Reserved.<br>
 * Licensed under the Eclipse Public License - v 1.0<p/>
 * <br>
 * $Revision: 1.2 $
 * <br>
 * $Date: 2006/11/12 01:11:04 $
 * <br>
 * @author Craig Setera
 */
public class EmulationJavaSourcePathComputer extends JavaSourcePathComputer {
	public static final String ID = "eclipseme.core.launching.emulationSourcePathComputer";
	
	/**
	 * @see org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer#computeSourceContainers(org.eclipse.debug.core.ILaunchConfiguration, org.eclipse.core.runtime.IProgressMonitor)
	 */
	public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) 
		throws CoreException 
	{
		ISourceContainer[] containers = super.computeSourceContainers(configuration, monitor);
		
//		if (isPreprocessingProject(configuration)) {
//			for (int i = 0; i < containers.length; i++) {
//				if (containers[i] instanceof JavaProjectSourceContainer) {
//					IJavaProject javaProject = 
//						((JavaProjectSourceContainer) containers[i]).getJavaProject();
//					
//					IProject srcProject = javaProject.getProject();
//					IProject tgtProject = PreprocessorBuilder.getOutputProject(srcProject);
//					if (tgtProject.exists()) {
//						IJavaProject tgtJavaProject = JavaCore.create(tgtProject);
//						if (tgtJavaProject.exists()) {
//							containers[i] = new JavaProjectSourceContainer(tgtJavaProject);
//						}
//					}
//				}
//			}
//		}
		
		return containers;
	}

	/**
	 * @see org.eclipse.jdt.launching.sourcelookup.containers.JavaSourcePathComputer#getId()
	 */
	public String getId() {
		return ID;
	}

	/**
	 * Return a boolean indicating whether the project being launched by the
	 * configuration is a preprocessing project.
	 * 
	 * @param configuration
	 * @return
	 */
	private boolean isPreprocessingProject(ILaunchConfiguration configuration) {
		boolean preprocessing = false;
		
		try {
			String projectName = configuration.getAttribute(
				IJavaLaunchConfigurationConstants.ATTR_PROJECT_NAME, 
				"");
			IProject project = 
				ResourcesPlugin.getWorkspace().getRoot().getProject(projectName);
			
			if (project.exists()) {
				preprocessing = 
					project.hasNature(IEclipseMECoreConstants.J2ME_PREPROCESSING_NATURE_ID); 
			}
			
		} catch (CoreException e) {
			EclipseMECorePlugin.log(IStatus.WARNING, e);
		}
		
		return preprocessing;
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -