本文介绍如何定制一种适合自己项目调试的方式。
- 扩展点 org.eclipse.debug.ui.launchShortcuts
[codesyntax lang="xml"]
<extension
point="org.eclipse.debug.ui.launchShortcuts">
<shortcut class="surenpi.com.dev.debugger.surenpi.comShortcut"
icon="icons/surenpi.com16x16.png"
id="surenpi.com.dev.debugger.launchShortcuts"
label="surenpi.comDebug"
modes="run,debug">
<configurationType
id="surenpi.com.dev.debugger.launchConfigurationTypes"/>
<contextualLaunch>
<enablement>
<with variable="selection">
<count value="1">
</count>
<iterate>
<or>
<test
property="org.eclipse.debug.ui.matchesPattern"
value="*.xml">
</test>
</or>
<or>
<adapt type="org.eclipse.core.resources.IFile">
<test property="org.eclipse.core.resources.name" value="pom.xml"/>
</adapt>
<adapt type="org.eclipse.core.resources.IProject">
<test property="org.eclipse.core.resources.projectNature" value="org.eclipse.m2e.core.maven2Nature"/>
</adapt>
</or>
</iterate>
</with>
</enablement>
</contextualLaunch>
</shortcut>
</extension>
[/codesyntax] 以上扩展点用于在项目或者文件上右键运行的配置。 对应的实现类如下; [codesyntax lang="php"]
/**
* surenpi.com
*/
import org.eclipse.debug.ui.ILaunchShortcut;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IEditorPart;
/**
* @author surenpi.com
* @since jdk1.6
* 2015年8月10日
*/
public class GboatShortcut implements ILaunchShortcut {
@Override
public void launch(ISelection arg0, String arg1) {
System.out.println("public void launch(ISelection arg0, String arg1) {");
}
@Override
public void launch(IEditorPart arg0, String arg1) {
System.out.println("public void launch(IEditorPart arg0, String arg1) {");
}
}
[/codesyntax]