[jboss-svn-commits] JBL Code SVN: r19272 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin: META-INF and 3 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Thu Mar 27 18:45:16 EDT 2008
Author: KrisVerlaenen
Date: 2008-03-27 18:45:16 -0400 (Thu, 27 Mar 2008)
New Revision: 19272
Added:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitApplicationLaunchShortcut.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitLaunchConfigurationDelegate.java
Modified:
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java
labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java
Log:
JBRULES-1319: debug junit test as drools application without requiring main function on junit test class
- added "Debug as Drools JUnit Test" action when right-clicking JUnit test class
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF 2008-03-27 21:59:41 UTC (rev 19271)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/META-INF/MANIFEST.MF 2008-03-27 22:45:16 UTC (rev 19272)
@@ -15,6 +15,7 @@
org.eclipse.jdt.debug.ui,
org.eclipse.jdt.launching,
org.eclipse.jdt.ui,
+ org.eclipse.jdt.junit,
org.eclipse.jface.text,
org.eclipse.ui,
org.eclipse.ui.console,
@@ -22,6 +23,7 @@
org.eclipse.ui.forms,
org.eclipse.ui.ide,
org.eclipse.ui.views,
+ org.eclipse.ui.views.properties.tabbed,
org.eclipse.ui.workbench.texteditor,
org.eclipse.gef,
com.ibm.icu
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-03-27 21:59:41 UTC (rev 19271)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml 2008-03-27 22:45:16 UTC (rev 19272)
@@ -231,7 +231,14 @@
delegate="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
sourceLocatorId="org.drools.eclipse.launching.DroolsSourceLookupDirector"
sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"
- modes= "debug" />
+ modes="debug" />
+ <launchConfigurationType
+ id="org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate"
+ name="Drools JUnit Test"
+ delegate="org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate"
+ sourceLocatorId="org.drools.eclipse.launching.DroolsSourceLookupDirector"
+ sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"
+ modes="debug" />
</extension>
<extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
@@ -240,6 +247,11 @@
configTypeID="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
id="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate.Image">
</launchConfigurationTypeImage>
+ <launchConfigurationTypeImage
+ icon="icons/drools.gif"
+ configTypeID="org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate"
+ id="org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate.Image">
+ </launchConfigurationTypeImage>
</extension>
<extension
@@ -253,9 +265,15 @@
perspective="org.eclipse.debug.ui.DebugPerspective"
description="Debug a Drools application">
</launchMode>
+ </launchConfigurationTabGroup>
+ <launchConfigurationTabGroup
+ type="org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate"
+ class="org.eclipse.jdt.internal.debug.ui.launcher.LocalJavaApplicationTabGroup"
+ id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.localJavaApplication">
<launchMode
- mode="run"
- description="Run a Drools application">
+ mode="debug"
+ perspective="org.eclipse.debug.ui.DebugPerspective"
+ description="Debug a Drools JUnit Test">
</launchMode>
</launchConfigurationTabGroup>
</extension>
@@ -289,6 +307,32 @@
<perspective id="org.eclipse.jdt.ui.JavaBrowsingPerspective"/>
<perspective id="org.eclipse.debug.ui.DebugPerspective"/>
</shortcut>
+ <shortcut
+ label="Drools JUnit Test"
+ icon="icons/drools.gif"
+ helpContextId="org.eclipse.jdt.junit.launch_shortcut"
+ class="org.drools.eclipse.launching.DroolsJUnitApplicationLaunchShortcut"
+ modes="debug"
+ id="org.drools.eclipse.launching.DroolsJUnitApplicationLaunchShortcut">
+ <contextualLaunch>
+ <enablement>
+ <with variable="selection">
+ <count value="1"/>
+ <iterate>
+ <adapt type="org.eclipse.jdt.core.IJavaElement">
+ <test property="org.eclipse.jdt.core.isInJavaProject"/>
+ <test property="org.eclipse.jdt.core.hasTypeOnClasspath" value="junit.framework.Test"/>
+ <test property="org.eclipse.jdt.junit.canLaunchAsJUnit" forcePluginActivation="true"/>
+ </adapt>
+ </iterate>
+ </with>
+ </enablement>
+ </contextualLaunch>
+ <perspective id="org.eclipse.jdt.ui.JavaPerspective"/>
+ <perspective id="org.drools.eclipse.DroolsPerspective"/>
+ <perspective id="org.eclipse.jdt.ui.JavaBrowsingPerspective"/>
+ <perspective id="org.eclipse.debug.ui.DebugPerspective"/>
+ </shortcut>
</extension>
<extension
@@ -357,24 +401,24 @@
objectClass="org.eclipse.core.resources.IProject"
id="org.drools.eclipse.action.ConvertToDroolsProject1">
<filter name="nature" value="org.eclipse.jdt.core.javanature"/>
- <action id="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+ <action id="org.drools.eclipse.action.ConvertToDroolsProjectAction1"
label="Convert to Drools Project"
icon="icons/drools.gif"
menubarPath="additions"
class="org.drools.eclipse.action.ConvertToDroolsProjectAction"
- definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+ definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction1"
enablesFor="1">
</action>
</objectContribution>
<objectContribution
objectClass="org.eclipse.jdt.core.IJavaProject"
id="org.drools.eclipse.action.ConvertToDroolsProject2">
- <action id="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+ <action id="org.drools.eclipse.action.ConvertToDroolsProjectAction2"
label="Convert to Drools Project"
icon="icons/drools.gif"
menubarPath="additions"
class="org.drools.eclipse.action.ConvertToDroolsProjectAction"
- definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+ definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction2"
enablesFor="1">
</action>
</objectContribution>
@@ -447,4 +491,41 @@
id="org.drools.eclipse.rulebuilder.wizards.NewGuidedRuleFileWizard"
name="Guided Rule"/>
</extension>
+
+ <!-- tabbed properties
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyContributor">
+ <propertyContributor
+ contributorId="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor"
+ labelProvider="org.drools.eclipse.flow.common.view.property.ProcessLabelProvider"
+ typeMapper="org.drools.eclipse.flow.common.view.property.ProcessTypeMapper">
+ <propertyCategory category="org.drools.eclipse.flow.general"/>
+ </propertyContributor>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertyTabs">
+ <propertyTabs contributorId="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
+ <propertyTab
+ category="org.drools.eclipse.flow.general"
+ id="org.drools.eclipse.flow.general"
+ label="General"/>
+ </propertyTabs>
+ </extension>
+
+ <extension point="org.eclipse.ui.views.properties.tabbed.propertySections">
+ <propertySections contributorId="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
+ <propertySection
+ class="org.drools.eclipse.flow.ruleflow.view.property.ElementNameSection"
+ id="org.drools.eclipse.flow.ruleflow.view.property.ElementNameSection"
+ tab="org.drools.eclipse.flow.general">
+ <input type="org.drools.eclipse.flow.common.editor.core.ElementWrapper"/>
+ </propertySection>
+ <propertySection
+ class="org.drools.eclipse.flow.ruleflow.view.property.ProcessNameSection"
+ id="org.drools.eclipse.flow.ruleflow.view.property.ProcessNameSection"
+ tab="org.drools.eclipse.flow.general">
+ <input type="org.drools.eclipse.flow.common.editor.core.ProcessWrapper"/>
+ </propertySection>
+ </propertySections>
+ </extension> -->
+
</plugin>
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java 2008-03-27 21:59:41 UTC (rev 19271)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java 2008-03-27 22:45:16 UTC (rev 19272)
@@ -6,6 +6,7 @@
String DROOLS_MARKER_TYPE = "org.drools.eclipse.droolsBreakpointMarker";
String DRL_LINE_NUMBER = "Drools_DRL_LineNumber";
String LAUNCH_CONFIGURATION_TYPE = "org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate";
+ String JUNIT_LAUNCH_CONFIGURATION_TYPE = "org.drools.eclipse.launching.DroolsJUnitLaunchConfigurationDelegate";
/**
* com.package.HelloWorld:14;com.package.GoodBye:7 style of packed rule info. int is the linenumber at the drl.
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitApplicationLaunchShortcut.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitApplicationLaunchShortcut.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitApplicationLaunchShortcut.java 2008-03-27 22:45:16 UTC (rev 19272)
@@ -0,0 +1,12 @@
+package org.drools.eclipse.launching;
+
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.eclipse.jdt.junit.launcher.JUnitLaunchShortcut;
+
+public class DroolsJUnitApplicationLaunchShortcut extends JUnitLaunchShortcut {
+
+ protected String getLaunchConfigurationTypeId() {
+ return IDroolsDebugConstants.JUNIT_LAUNCH_CONFIGURATION_TYPE;
+ }
+
+}
Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitLaunchConfigurationDelegate.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitLaunchConfigurationDelegate.java (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsJUnitLaunchConfigurationDelegate.java 2008-03-27 22:45:16 UTC (rev 19272)
@@ -0,0 +1,57 @@
+package org.drools.eclipse.launching;
+
+import java.text.MessageFormat;
+import java.util.HashMap;
+
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.ILaunchManager;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint;
+import org.eclipse.jdt.internal.launching.LaunchingMessages;
+import org.eclipse.jdt.junit.launcher.JUnitLaunchConfigurationDelegate;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+
+public class DroolsJUnitLaunchConfigurationDelegate extends JUnitLaunchConfigurationDelegate {
+
+ public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+ if (monitor == null) {
+ monitor = new NullProgressMonitor();
+ }
+ if (monitor.isCanceled()) {
+ return;
+ }
+ // TODO make sure that all DRLs needed during execution are built and cached
+ super.launch(configuration, mode, launch, monitor);
+ if (mode.equals(ILaunchManager.DEBUG_MODE)) {
+ // TODO only retrieve breakpoints of this project or any
+ // of its dependent projects
+ IBreakpoint[] breakpoints = getDroolsBreakpoints();
+ for (int i = 0; i < breakpoints.length; i++) {
+ launch.getDebugTarget().breakpointAdded(breakpoints[i]);
+ }
+ }
+ }
+
+ private IBreakpoint[] getDroolsBreakpoints() {
+ return DebugPlugin.getDefault().getBreakpointManager()
+ .getBreakpoints(IDroolsDebugConstants.ID_DROOLS_DEBUG_MODEL);
+ }
+
+ public IVMRunner getVMRunner(ILaunchConfiguration configuration, String mode) throws CoreException {
+ IVMInstall vm = verifyVMInstall(configuration);
+ IVMRunner runner = new DroolsVMDebugger(vm);
+ if (runner == null) {
+ abort(MessageFormat.format(LaunchingMessages.JavaLocalApplicationLaunchConfigurationDelegate_0, new String[]{vm.getName(), mode}), null, IJavaLaunchConfigurationConstants.ERR_VM_RUNNER_DOES_NOT_EXIST);
+ }
+ return runner;
+ }
+
+}
Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java 2008-03-27 21:59:41 UTC (rev 19271)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java 2008-03-27 22:45:16 UTC (rev 19272)
@@ -85,11 +85,11 @@
}
IPath location = getProjectLocation(project.getProject());
IPath outputPath = location.append(project.getOutputLocation().removeFirstSegments(1));
- pathElements.add(outputPath.toFile().toURI().toURL());
+ pathElements.add(0, outputPath.toFile().toURI().toURL());
for (Iterator iterator = outputPaths.iterator(); iterator.hasNext(); ) {
IPath path = (IPath) iterator.next();
outputPath = location.append(path.removeFirstSegments(1));
- pathElements.add(outputPath.toFile().toURI().toURL());
+ pathElements.add(0, outputPath.toFile().toURI().toURL());
}
// also add classpath of required projects
More information about the jboss-svn-commits
mailing list