[jboss-svn-commits] JBL Code SVN: r15989 - in labs/jbossrules/branches/4.0.x: drools-analytics and 116 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Oct 22 13:56:30 EDT 2007


Author: mark.proctor at jboss.com
Date: 2007-10-22 13:56:29 -0400 (Mon, 22 Oct 2007)
New Revision: 15989

Added:
   labs/jbossrules/branches/4.0.x/drools-eclipse3.2/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/allElements.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/customTargets.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/.project
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/feature.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/pom.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.classpath
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.project
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.settings/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/META-INF/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/META-INF/MANIFEST.MF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/help/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/action.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/activity.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_connective.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_field_to_fact.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowleft.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowright.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/bluediamond.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/check.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/class_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear_disabled.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/connection.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/constant_co.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_item_small.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-large.PNG
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-query.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-rule.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl-large.png
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.png
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl_expression.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_large.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_small.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/edit.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_private_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_public_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/function_assets.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/greensquare.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import_statement.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/join.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure_disabled.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/methpub_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/new_item.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/open.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/package_obj.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_start.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_stop.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/public_co.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/question.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/redsquare.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh_disabled.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/sample.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/split.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/static_co.gif
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/yellowsquare.GIF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/lib/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/plugin.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/pom.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DRLInfo.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPerspective.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPluginImages.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/IDroolsConstants.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/action/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/action/ConvertToDroolsProjectAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuildMarker.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuilder.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/IDroolsModelMarker.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/Util.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsElement.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsModelBuilder.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Expander.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Function.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Global.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Import.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Package.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Query.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Rule.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleAttribute.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleSet.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Template.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsFilter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsLabelProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsTreeSorter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterActionGroup.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaLogicalStructureDelegate.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaViewContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataViewContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditViewContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugEventHandlerView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugViewContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ObjectWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/VariableWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryViewContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/DeleteLogAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/OpenLogAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/RefreshLogAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowEventCauseAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowLogicalStructureAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModel.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModelPresentation.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpoint.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpointMarkerUpdater.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLocalVariable.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsStackFrame.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThisVariable.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELThisVariable.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLAdapter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLContentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLLabelProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLMappingSorter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor2.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleSourceViewerConfig.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocument.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocumentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLRuleViewer.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/IMappingListViewer.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/MappingEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/NLGrammarModel.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/TransformedDocument.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/completion/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/completion/DSLRuleCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/AbstractRuleEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ColorManager.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLAnnotationModel.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLDocumentProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLProblemAnnotation.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLReconcilingStrategy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor2.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditorActionContributor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLSourceViewerConfig.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DescrUtil.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsLineBreakpointAdapter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsPairMatcher.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/Keywords.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomInAction2.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomOutAction2.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionContext.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionUtil.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/Node.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/ReflectionUtils.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProposal.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/outline/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/outline/RuleContentOutlinePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteViewer.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteooLayoutFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/Row.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/RowList.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/commands/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/commands/NodeSetConstraintCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/ConnectionFigure.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/VertexFigure.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/Connection.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/GraphicalVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ModelElement.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ReteGraph.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/VertexPropertySource.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/ConnectionEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/DiagramEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPartFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLPartionScanner.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLScanner.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleEditorMessages.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleWordDetector.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/WhitespaceDetector.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DataTypeRegistry.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DefaultDataTypeRegistry.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/impl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/impl/DataTypeRegistryImpl.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/DropDownMenuWithDefaultAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericActionBarContributor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericContextMenuProvider.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/ObjectInputStreamWithLoader.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/OverviewOutlinePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/DefaultElementWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnectionFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelEvent.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelListener.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ProcessWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/AddElementCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ChangeConstraintCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/CreateBendpointCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteBendpointCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteConnectionCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteElementCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/MoveBendpointCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/RenameElementCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/SplitConnectionCommand.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/DirectedGraphLayoutVisitor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementCellEditorLocator.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/GraphLayoutManager.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ProcessEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementFigure.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionBendpointEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditManager.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementNodeEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ProcessLayoutEditPolicy.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/DataTypeEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/Editor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/BooleanEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeCombo.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeEditorComposite.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EditorComposite.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EmptyEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/FloatEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/IntegerEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/StringEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/BeanDialogCellEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditBeanDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditListDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/ListPropertyDescriptor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFilePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFileWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapperFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/NodeWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowProcessWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/action/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/action/CheckRuleFlowAction.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ActionEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/EndNodeEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/JoinEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/MilestoneEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowConnectionEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleSetNodeEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SplitEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/StartNodeEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SubFlowEditPart.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionCellEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionPropertyDescriptor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListCellEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintsPropertyDescriptor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ImportCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintCellEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintPropertyDescriptor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowGlobalsDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowImportsDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListCellEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsApplicationLaunchShortcut.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsLaunchConfigurationDelegate.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupParticipant.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourcePathComputerDelegate.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsVMDebugger.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/MVELSourceLookupParticipant.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/BrlPage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CustomRuleDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/NumericKeyFilter.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizardPage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainerInitializer.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/rules/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/rules/RulesView.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFilePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFileWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizardPage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/DRLGenerator.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackagePage.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackageWizard.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AccumulateNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AlphaNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/BaseVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/CollectNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/EvalConditionNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ExistsNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/FromNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/JoinNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/LeftInputAdapterNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/NotNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ObjectTypeNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/QueryTerminalNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteooVisitor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RightInputAdapterNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RuleTerminalNodeVertex.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/java_keywords.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/mvel_keywords.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/scanners/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/scanners/RuleEditorMessages.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/ruleflow/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/ruleflow/SampleRuleFlow.rf.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/decisiontable/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/decisiontable/template.xls
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/dsl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/dsl/template.dsl
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/DecisionTableLauncherSample.java.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.drl.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.xls.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_package.drl.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_rule.drl.template
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/.project
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/feature.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/pom.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.classpath
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.project
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.settings/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.settings/org.eclipse.jdt.core.prefs
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/META-INF/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/META-INF/MANIFEST.MF
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/debug/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/debug/DebugViewsTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/DSLAdapterTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/test.dsl
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessorTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionContextTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionUtilTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/ContextScanningTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/DRLCompletionProcessorTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/KeywordsTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MockCompletionProcessor.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MvelParsingTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/RuleCompletionProcessorTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/outline/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/outline/RuleContentOutlineTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ReteooLayoutFactoryTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ZoomControlTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/rule/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/rule/DRLGenTemplateTest.java
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/debug.drl
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/simplerule.drl
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/test.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/genericTargets.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/package.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/pom.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.3/setupEclipse.xml
   labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/
   labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar
   labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.pom
   labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.2.xml
   labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.3.xml
Removed:
   labs/jbossrules/branches/4.0.x/drools-eclipse/
   labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.8/
   labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse.xml
Modified:
   labs/jbossrules/branches/4.0.x/drools-analytics/.classpath
   labs/jbossrules/branches/4.0.x/drools-analytics/.project
   labs/jbossrules/branches/4.0.x/drools-ant/.classpath
   labs/jbossrules/branches/4.0.x/drools-ant/.project
   labs/jbossrules/branches/4.0.x/drools-compiler/.classpath
   labs/jbossrules/branches/4.0.x/drools-core/.classpath
   labs/jbossrules/branches/4.0.x/drools-decisiontables/.classpath
   labs/jbossrules/branches/4.0.x/drools-eclipse3.2/build.properties
   labs/jbossrules/branches/4.0.x/drools-eclipse3.2/customTargets.xml
   labs/jbossrules/branches/4.0.x/drools-eclipse3.2/pom.xml
   labs/jbossrules/branches/4.0.x/drools-jbrms/.classpath
   labs/jbossrules/branches/4.0.x/drools-jbrms/.project
   labs/jbossrules/branches/4.0.x/drools-jsr94/.classpath
   labs/jbossrules/branches/4.0.x/drools-jsr94/.project
   labs/jbossrules/branches/4.0.x/drools-repository/.classpath
   labs/jbossrules/branches/4.0.x/pom.xml
   labs/jbossrules/branches/4.0.x/update-version.xml
Log:
JBRULES-1293 Backport for Eclipse 3.3
JBRULES-1294 Upgrade to MVEL 1.2.10

Modified: labs/jbossrules/branches/4.0.x/drools-analytics/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-analytics/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-analytics/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,15 +5,15 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
   <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
   <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
   <classpathentry kind="src" path="/drools-core"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-  <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-analytics/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-analytics/.project	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-analytics/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -2,8 +2,8 @@
   <name>drools-analytics</name>
   <comment>A rule production system</comment>
   <projects>
+    <project>drools-compiler</project>
     <project>drools-core</project>
-    <project>drools-compiler</project>
   </projects>
   <buildSpec>
     <buildCommand>

Modified: labs/jbossrules/branches/4.0.x/drools-ant/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-ant/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-ant/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -4,18 +4,18 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="var" path="M2_REPO/ant/ant-nodeps/1.6.5/ant-nodeps-1.6.5.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/ant/ant-nodeps/1.6.5/ant-nodeps-1.6.5.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
-  <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar" sourcepath="M2_REPO/ant/ant/1.6.5/ant-1.6.5-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar"/>
   <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
-  <classpathentry kind="src" path="/drools-analytics"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/ant/ant/1.6.5/ant-1.6.5.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
   <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
   <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="src" path="/drools-analytics"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-ant/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-ant/.project	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-ant/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -2,9 +2,9 @@
   <name>drools-ant</name>
   <comment>A rule production system</comment>
   <projects>
-    <project>drools-analytics</project>
     <project>drools-compiler</project>
     <project>drools-core</project>
+    <project>drools-analytics</project>
   </projects>
   <buildSpec>
     <buildCommand>

Modified: labs/jbossrules/branches/4.0.x/drools-compiler/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-compiler/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-compiler/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,14 +5,14 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
   <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
+  <classpathentry kind="src" path="/drools-core"/>
   <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-core/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-core/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-core/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,8 +5,8 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
   <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-decisiontables/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-decisiontables/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-decisiontables/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -6,13 +6,13 @@
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
   <classpathentry kind="var" path="M2_REPO/jexcelapi/jxl/2.4.2/jxl-2.4.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
   <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
   <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
 </classpath>
\ No newline at end of file

Copied: labs/jbossrules/branches/4.0.x/drools-eclipse3.2 (from rev 15973, labs/jbossrules/branches/4.0.x/drools-eclipse)

Modified: labs/jbossrules/branches/4.0.x/drools-eclipse3.2/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse/build.properties	2007-10-22 05:38:26 UTC (rev 15973)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.2/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -8,8 +8,8 @@
 collectingFolder=${archivePrefix}
 
 ##sets the zip name
-zipFile=drools-eclipse-${droolsVersion}.zip
-testZipFile=drools-eclipse-test-${droolsVersion}.zip
+zipFile=drools-eclipse3.2-${droolsVersion}.zip
+testZipFile=drools-eclipse3.2-test-${droolsVersion}.zip
 
 #Set to true if you want the output to be ready for an update jar (no site.xml generated)
 outputUpdateJars = false
@@ -39,8 +39,8 @@
 #basews=win32
 #basearch=x86
 
-eclipseGefURL=http://download.eclipse.org//tools/gef/downloads/drops
-eclipseURL=http://download.eclipse.org/eclipse/downloads/drops
+eclipseGefURL=http://download.eclipse.org/tools/gef/downloads/drops
+eclipseURL=http://archive.eclipse.org/eclipse/downloads/drops
 eclipseBuildRevision=R-3.2.2-200702121330
 eclipseGefBuildRevision=R-3.2.2-200702081315
 eclipseBuildId=3.2.2

Modified: labs/jbossrules/branches/4.0.x/drools-eclipse3.2/customTargets.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse/customTargets.xml	2007-10-22 05:38:26 UTC (rev 15973)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.2/customTargets.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -53,14 +53,14 @@
 	<target name="preSetup">
 	  <echo>preSetup</echo>	  
     <!--cleanup -->
-    <delete file="${base}/eclipse/org.drools.eclipse*.xml" />
-    <delete dir="${base}/eclipse/test-workspace"/>
+    <delete failonerror="false" file="${base}/eclipse/org.drools.eclipse*.xml" />
+    <delete failonerror="false" dir="${base}/eclipse/test-workspace"/>
     
-    <delete dir="${base}/eclipse/features/org.drools.eclipse.feature_${droolsVersion}"/>
-    <delete dir="${base}/eclipse/features/org.drools.eclipse.test-feature_${droolsVersion}"/>
+    <delete failonerror="false"  dir="${base}/eclipse/features/org.drools.eclipse.feature_${droolsVersion}"/>
+    <delete failonerror="false" dir="${base}/eclipse/features/org.drools.eclipse.test-feature_${droolsVersion}"/>
     
-    <delete file="${base}/eclipse/plugins/org.drools.eclipse_${droolsVersion}.jar"/>
-    <delete dir="${base}/eclipse/plugins/org.drools.eclipse.test_${droolsVersion}"/>            
+    <delete failonerror="false" file="${base}/eclipse/plugins/org.drools.eclipse_${droolsVersion}.jar"/>
+    <delete failonerror="false" dir="${base}/eclipse/plugins/org.drools.eclipse.test_${droolsVersion}"/>            
 	</target>
 
 	<!-- ===================================================================== -->

Modified: labs/jbossrules/branches/4.0.x/drools-eclipse3.2/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse/pom.xml	2007-10-22 05:38:26 UTC (rev 15973)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.2/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -8,10 +8,10 @@
   </parent>
 
   <modelVersion>4.0.0</modelVersion>
-  <artifactId>drools-eclipse</artifactId>
+  <artifactId>drools-eclipse3.2</artifactId>
    <packaging>pom</packaging>
 
-  <name>Drools :: Eclipse-Plugin</name>
+  <name>Drools :: Eclipse-Plugin3.2</name>
   <build>
     <plugins>    
      <plugin>
@@ -181,7 +181,7 @@
            <phase>package</phase>
            <configuration>
              <tasks>                
-                <unzip src="target/drools-eclipse-${project.version}.zip" dest="../target/eclipse"/>                         
+                <unzip src="target/drools-eclipse3.2-${project.version}.zip" dest="../target/eclipse3.2"/>                         
              </tasks>
            </configuration>
            <goals>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/allElements.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/allElements.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/allElements.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,45 @@
+<project name="allElements Delegator">
+ 	<!-- ===================================================================== -->
+ 	<!-- Run a given ${target} on all elements being built                     -->
+ 	<!-- Replace element.id with the id of the top level element being built.    -->
+	<!-- If element.id does not exist in ${buildDirectory}/features/element.id   -->
+	<!-- or ${baseLocation}/features/element.id, then you must provide the       -->
+	<!-- location by setting the property "pluginPath"                           -->
+ 	<!-- Add on <ant> task for each top level element being built.             -->
+ 	<!-- ===================================================================== -->
+ 	<target name="allElementsDelegator">
+    <antcall target="org.drools.eclipse.feature"  />
+    <antcall target="org.drools.eclipse.test-feature"  />
+ 	</target>
+
+ 	<target name="org.drools.eclipse.feature" if="mavenCompilePhase">
+ 		<ant antfile="${genericTargets}" target="${target}">
+	 		<property name="type" value="feature" />
+	 		<property name="id" value="org.drools.eclipse.feature" />
+ 		</ant>
+ 	</target>
+
+ 	<target name="org.drools.eclipse.test-feature" if="mavenTestPhase">
+ 		<ant antfile="${genericTargets}" target="${target}">
+	 		<property name="type" value="feature" />
+	 		<property name="id" value="org.drools.eclipse.test-feature" />
+ 		</ant>
+ 	</target>
+
+ 	<!-- ===================================================================== -->
+ 	<!-- Targets to assemble the built elements for particular configurations  -->
+ 	<!-- These generally call the generated assemble scripts (named in         -->
+ 	<!-- ${assembleScriptName}) but may also add pre and post processing       -->
+ 	<!-- Add one target for each root element and each configuration           -->
+ 	<!-- Replace element.id with the id of the top level element being built   -->
+ 	<!-- ===================================================================== -->
+ 	<target name="assemble.org.drools.eclipse.feature">
+ 		<property name="archiveName" value="${zipFile}"/>
+ 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
+ 	</target>
+
+ 	<target name="assemble.org.drools.eclipse.test-feature">
+ 		<property name="archiveName" value="${testZipFile}"/>
+ 		<ant antfile="${assembleScriptName}" dir="${buildDirectory}"/>
+ 	</target>
+</project>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,72 @@
+#product=/plugin or feature id/path/to/.product
+runPackager=true
+droolsVersion=4.0.3.SNAPSHOT
+
+# The prefix that will be used in the generated archive.
+archivePrefix=
+# The location underwhich all of the build output will be collected.
+collectingFolder=${archivePrefix}
+
+##sets the zip name
+zipFile=drools-eclipse3.3-${droolsVersion}.zip
+testZipFile=drools-eclipse3.3-test-${droolsVersion}.zip
+
+#Set to true if you want the output to be ready for an update jar (no site.xml generated)
+outputUpdateJars = false
+
+# Timestamp for the build.  Used in naming the build output
+timestamp=007
+
+# Type of build.  Used in naming the build output.  Typically this value is
+# one of I, N, M, S, ...
+buildType=N
+
+# ID of the build.  Used in naming the build output.
+buildId=drools-build
+
+# Label for the build.  Used in naming the build output
+buildLabel=${buildType}.${buildId}
+
+#Where the customised scripts live
+builder=.
+base=${builder}/target
+buildDirectory=${base}/eclipse.build
+baseLocation=${base}/eclipse
+
+
+#Os/Ws/Arch/nl of the eclipse specified by baseLocation
+#baseos=win32
+#basews=win32
+#basearch=x86
+
+eclipseGefURL=http://download.eclipse.org/tools/gef/downloads/drops
+eclipseURL=http://download.eclipse.org/eclipse/downloads/drops
+eclipseBuildRevision=R-3.3.1-200709211145
+eclipseGefBuildRevision=R-3.3.1-200709241000
+eclipseBuildId=3.3.1
+
+# We don't want any SCM automation
+skipFetch=true
+
+# Specify the output format of the compiler log when eclipse jdt is used
+logExtension=.log
+
+# Whether or not to include debug info in the output jars
+javacDebugInfo=false
+
+# Whether or not to fail the build if there are compiler errors
+javacFailOnError=false
+
+# Enable or disable verbose mode of the compiler
+javacVerbose=true
+
+# Extra arguments for the compiler. These are specific to the java compiler being used.
+#compilerArg=
+
+# Default value for the version of the source code. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacSource in build.properties
+javacSource=1.4
+
+# Default value for the version of the byte code targeted. This value is used when compiling plug-ins that do not set the Bundle-RequiredExecutionEnvironment or set javacTarget in build.properties.
+javacTarget=1.4
+
+

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/build.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,126 @@
+<project name="Build All Elements" default="main">
+
+<!-- ===================================================================== -->
+<!-- Global properties.  See the build.properties for information on -->
+<!-- the properties which callers can control. -->
+<!-- ===================================================================== -->
+<property name="builder" location="${user.dir}"/>
+<property name="builderDirectory" location="${builder}"/>
+<property name="buildProperties" location="${builder}/build.properties"/>
+<property file="${buildProperties}"/>
+<available property="customTargets" file="${builder}/customTargets.xml" value="${builder}/customTargets.xml"/>
+<property name="customTargets" location="${eclipse.pdebuild.templates}/headless-build/customTargets.xml"/>
+<property name="genericTargets" location="${eclipse.pdebuild.scripts}/genericTargets.xml"/>
+
+<!-- ===================================================================== -->
+<!-- main entry point to setup, fetch, generate, build etc. Use -->
+<!-- the customTargets.xml to modify the build behaviour. -->
+<!-- ===================================================================== -->
+
+<!-- ******* add in the descriptions for each of the top level targets to teh target decl -->
+<target name="main" description="the main build target">	
+  	<antcall target="preBuild" /> 
+ 	<antcall target="fetch" />
+	<antcall target="generate" /> 
+	<antcall target="process" /> 
+	<antcall target="assemble" />
+	<antcall target="package" />
+	<antcall target="postBuild" />
+</target>
+
+<!-- ===================================================================== -->
+<!-- Steps to do before starting the build.  Typical setup includes -->
+<!-- fetching the map files and building the directory.  -->
+<!-- ===================================================================== -->
+<target name="preBuild">
+	<mkdir dir="${buildDirectory}" />
+	<ant antfile="${customTargets}" target="preSetup" /> 
+	<ant antfile="${customTargets}" target="getMapFiles" /> 
+	<concat destfile="${buildDirectory}/directory.txt" fixlastline="yes">
+		<fileset dir="${buildDirectory}" includes="maps/**/*.map"/>
+	</concat>
+	<ant antfile="${customTargets}" target="postSetup" />
+</target>
+
+<!-- ===================================================================== -->
+<!-- Fetch the elements identified in the customTargets -->
+<!-- ===================================================================== -->
+<target name="fetch" unless="skipFetch">
+	<ant antfile="${customTargets}" target="preFetch"/>
+	<!-- Generates and then execute the fetch scripts for each build element-->
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="fetchElement" />
+	</ant>
+	
+	<ant antfile="${customTargets}" target="postFetch"/>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Generate the build scripts for each element identified in the customTargets -->
+<!-- ===================================================================== -->
+<target name="generate">
+	<ant antfile="${customTargets}" target="preGenerate"/>
+	<!-- Generate the build.xml for each build element-->
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="generateScript" />
+	</ant>
+	<ant antfile="${customTargets}" target="postGenerate"/>	
+</target>
+
+<!-- ===================================================================== -->
+<!-- Run the build scripts for each element identified in the customTargets -->
+<!-- ===================================================================== -->
+<target name="process">
+	<!-- Run custom tasks before processing, i.e. creating source build zip files -->
+	<ant antfile="${customTargets}" target="preProcess" />
+
+	<!-- Process all of the build elements-->
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="processElement" />
+	</ant>
+
+	<!-- Run custom tasks after compiling, i.e. reporting compile errors -->
+	<ant antfile="${customTargets}" target="postProcess" />
+</target>
+
+<!-- ===================================================================== -->
+<!-- Assemble the build elements into final distributions -->
+<!-- ===================================================================== -->
+<target name="assemble">
+	<ant antfile="${customTargets}" target="preAssemble"/>
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="assembleElement"/>
+	</ant>
+	<ant antfile="${customTargets}" target="postAssemble"/>	
+</target>
+
+<!-- ===================================================================== -->
+<!-- Package the build elements into final distributions -->
+<!-- ===================================================================== -->
+<target name="package" if="runPackager">
+	<ant antfile="${customTargets}" target="prePackage"/>
+	<ant antfile="${customTargets}" target="allElements">
+		<property name="target" value="packageElement"/>
+	</ant>
+	<ant antfile="${customTargets}" target="postPackage"/>	
+</target>
+
+<!-- ===================================================================== -->
+<!-- Do any steps required after the build (e.g., posting, testing, ...) -->
+<!-- ===================================================================== -->
+<target name="postBuild">
+	<ant antfile="${customTargets}" target="postBuild" />
+</target>
+
+<!-- ===================================================================== -->
+<!-- Clean the build elements.  This target is here as an entry -->
+<!-- point to the customTargets.  It is not called directly in the normal -->
+<!-- course of events. -->
+<!-- ===================================================================== -->
+<target name="clean">
+  <ant antfile="${customTargets}" target="allElements">
+     <property name="target" value="cleanElement"/>
+  </ant>
+</target>
+
+</project>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/customTargets.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/customTargets.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/customTargets.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,198 @@
+<project name="Build specific targets and properties" default="noDefault">
+	<!-- ===================================================================== -->
+	<!-- Run a given ${target} on all elements being built -->
+	<!-- Add on <ant> task for each top level element being built. -->
+	<!-- ===================================================================== -->
+	<property name="allElementsFile" value="${builder}/allElements.xml"/>
+	<import file="${allElementsFile}" />
+	<target name="allElements">
+		<antcall target="allElementsDelegator" />
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- ===================================================================== -->
+	<!-- Check out map files from correct repository -->
+	<!-- Replace values for mapsCheckoutTag as desired. -->
+	<!-- ===================================================================== -->
+	<target name="getMapFiles" depends="checkLocalMaps" unless="skipMaps">
+		<property name="mapsCheckoutTag" value="HEAD" />
+		<cvs cvsRoot="${mapsRepo}" package="${mapsRoot}" dest="${buildDirectory}/maps" tag="${mapsCheckoutTag}" />
+	</target>
+
+	<target name="checkLocalMaps">
+		<available property="skipMaps" file="${buildDirectory}/maps" />
+	</target>
+
+	<target name="tagMapFiles" if="tagMaps">
+		<cvs dest="${buildDirectory}/maps/${mapsRoot}" command="tag ${mapsTagTag}" />
+	</target>
+
+	<!-- ===================================================================== -->
+
+	<target name="clean" unless="noclean">
+		<antcall target="allElements">
+			<param name="target" value="cleanElement" />
+		</antcall>
+	</target>
+
+	<target name="gatherLogs">
+		<mkdir dir="${buildDirectory}/${buildLabel}/compilelogs" />
+		<antcall target="allElements">
+			<param name="target" value="gatherLogs" />
+		</antcall>
+		<unzip dest="${buildDirectory}/${buildLabel}/compilelogs" overwrite="true">
+			<fileset dir="${buildDirectory}/features">
+				<include name="**/*.log.zip" />
+			</fileset>
+		</unzip>
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before setup -->
+	<!-- ===================================================================== -->
+	<target name="preSetup">
+	  <echo>preSetup</echo>	  
+    <!--cleanup -->
+    <delete failonerror="false" file="${base}/eclipse/org.drools.eclipse*.xml" />
+    <delete failonerror="false" dir="${base}/eclipse/test-workspace"/>
+    
+    <delete failonerror="false"  dir="${base}/eclipse/features/org.drools.eclipse.feature_${droolsVersion}"/>
+    <delete failonerror="false" dir="${base}/eclipse/features/org.drools.eclipse.test-feature_${droolsVersion}"/>
+    
+    <delete failonerror="false" file="${base}/eclipse/plugins/org.drools.eclipse_${droolsVersion}.jar"/>
+    <delete failonerror="false" dir="${base}/eclipse/plugins/org.drools.eclipse.test_${droolsVersion}"/>            
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after setup but before starting the build proper -->
+	<!-- ===================================================================== -->
+	<target name="postSetup">		
+		<mkdir dir="${buildDirectory}/features"/>
+		<mkdir dir="${buildDirectory}/plugins"/>
+		
+		<antcall target="compilePostSetup" />
+		<antcall target="testPostSetup" />
+	</target>
+	
+	<target name="compilePostSetup" if="mavenCompilePhase">
+		<copy todir="${buildDirectory}/features/org.drools.eclipse.feature">
+			<fileset dir="${builder}/drools-eclipse-feature"/>
+		</copy>
+
+		<copy todir="${buildDirectory}/plugins/org.drools.eclipse">
+				<fileset dir="${builder}/drools-eclipse-plugin"/>
+		</copy>		
+	</target>
+
+	<target name="testPostSetup" if="mavenTestPhase">
+		
+		<copy todir="${buildDirectory}/features/org.drools.eclipse.test-feature">
+			<fileset dir="${builder}/drools-eclipse-test-feature"/>
+		</copy>
+
+		<copy todir="${buildDirectory}/plugins/org.drools.eclipse.test">
+				<fileset dir="${builder}/drools-eclipse-test"/>
+		</copy>		
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before fetching the build elements -->
+	<!-- ===================================================================== -->
+	<target name="preFetch">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after fetching the build elements -->
+	<!-- ===================================================================== -->
+	<target name="postFetch">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before generating the build scripts. -->
+	<!-- ===================================================================== -->
+	<target name="preGenerate">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after generating the build scripts. -->
+	<!-- ===================================================================== -->
+	<target name="postGenerate">
+		<antcall target="clean" />
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before running the build.xmls for the elements being built. -->
+	<!-- ===================================================================== -->
+	<target name="preProcess">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after running the build.xmls for the elements being built. -->
+	<!-- ===================================================================== -->
+	<target name="postProcess">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before running assemble. -->
+	<!-- ===================================================================== -->
+	<target name="preAssemble">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after  running assemble. -->
+	<!-- ===================================================================== -->
+	<target name="postAssemble">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do before running package. -->
+	<!-- ===================================================================== -->
+	<target name="prePackage">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after  running package. -->
+	<!-- ===================================================================== -->
+	<target name="postPackage" if="mavenCompilePhase">
+	    <copy file="${buildDirectory}/${buildLabel}/${zipFile}" tofile="${base}/${zipFile}" />
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do after the build is done. -->
+	<!-- ===================================================================== -->
+	<target name="postBuild">
+		<antcall target="gatherLogs" />
+		<antcall target="test" />
+	</target>	
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do to test the build results -->
+	<!-- ===================================================================== -->
+  <target name="test" if="mavenTestPhase">  
+    <unzip src="${buildDirectory}/${buildLabel}/${zipFile}"
+           dest="${base}/eclipse"/>
+    <unzip src="${buildDirectory}/${buildLabel}/${testZipFile}" 
+           dest="${base}/eclipse"/>    
+
+
+    <ant antfile="${base}/eclipse/plugins/org.drools.eclipse.test_${droolsVersion}/test.xml">        
+      <property name="os" value="${baseos}" />
+      <property name="ws" value="${basews}" />
+      <property name="arch" value="${basearch}" />
+    </ant>
+  </target>
+
+	<!-- ===================================================================== -->
+	<!-- Steps to do to publish the build results -->
+	<!-- ===================================================================== -->
+	<target name="publish">
+	</target>
+
+	<!-- ===================================================================== -->
+	<!-- Default target                                                        -->
+	<!-- ===================================================================== -->
+	<target name="noDefault">
+		<echo message="You must specify a target when invoking this file" />
+	</target>
+
+</project>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/.project	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>drools-eclipse-feature</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/build.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1 @@
+bin.includes = feature.xml

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/feature.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/feature.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/feature.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.drools.eclipse.feature"
+      label="JBossRules Feature"
+      version="4.0.3.SNAPSHOT"
+      provider-name="JBoss, Inc.">
+
+   <description url="http://www.example.com/description">
+      [Enter Feature Description here.]
+   </description>
+
+   <copyright url="http://www.example.com/copyright">
+      [Enter Copyright Description here.]
+   </copyright>
+
+   <license url="http://www.example.com/license">
+      [Enter License Description here.]
+   </license>
+
+   <requires>
+      <import plugin="org.eclipse.core.runtime"/>
+      <import plugin="org.eclipse.core.resources"/>
+      <import plugin="org.eclipse.debug.core"/>
+      <import plugin="org.eclipse.debug.ui"/>
+      <import plugin="org.eclipse.jdt.core"/>
+      <import plugin="org.eclipse.jdt.debug"/>
+      <import plugin="org.eclipse.jdt.debug.ui"/>
+      <import plugin="org.eclipse.jdt.launching"/>
+      <import plugin="org.eclipse.jdt.ui"/>
+      <import plugin="org.eclipse.jface.text"/>
+      <import plugin="org.eclipse.ui"/>
+      <import plugin="org.eclipse.ui.console"/>
+      <import plugin="org.eclipse.ui.editors"/>
+      <import plugin="org.eclipse.ui.forms"/>
+      <import plugin="org.eclipse.ui.ide"/>
+      <import plugin="org.eclipse.ui.views"/>
+      <import plugin="org.eclipse.ui.workbench.texteditor"/>
+      <import plugin="org.eclipse.gef"/>
+      <import plugin="com.ibm.icu"/>
+   </requires>
+
+   <plugin
+         id="org.drools.eclipse"
+         download-size="0"
+         install-size="0"
+         version="4.0.3.SNAPSHOT"
+         unpack="false"/>
+
+</feature>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/pom.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-feature/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/P
+OM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+        <modelVersion>4.0.0</modelVersion>
+        <groupId>drools</groupId>
+        <artifactId>drools-eclipse-feature</artifactId>
+        <packaging>eclipse-feature</packaging>
+        <version>1.0-SNAPSHOT</version>
+        <build>
+                <plugins>
+                        <plugin>
+                                <groupId>org.codehaus.tycho</groupId>
+                                <artifactId>maven-osgi-lifecycle-plugin</artifactId>
+                                <extensions>true</extensions>
+                        </plugin>
+                </plugins>
+        </build>
+  <dependencies>
+    <dependency>
+      <groupId>drools</groupId>
+      <artifactId>drools-eclipse-plugin</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.classpath	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/main/resources"/>
+	<classpathentry exported="true" kind="lib" path="lib/drools-compiler.jar" sourcepath="/drools-compiler"/>
+	<classpathentry exported="true" kind="lib" path="lib/drools-core.jar" sourcepath="/drools-core"/>
+	<classpathentry exported="true" kind="lib" path="lib/drools-decisiontables.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/drools-jsr94.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/jsr94.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/junit.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/jxl.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/mvel.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/xpp3.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/xstream.jar"/>
+	<classpathentry exported="true" kind="lib" path="lib/antlr-runtime.jar"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.project	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>drools-eclipse-plugin</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/META-INF/MANIFEST.MF	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/META-INF/MANIFEST.MF	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,45 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Drools Eclipse Plug-in
+Bundle-SymbolicName: org.drools.eclipse;singleton:=true
+Bundle-Version: 4.0.3.SNAPSHOT
+Bundle-Activator: org.drools.eclipse.DroolsEclipsePlugin
+Bundle-Vendor: krisv,mic
+Bundle-Localization: plugin
+Require-Bundle: org.eclipse.core.runtime,
+ org.eclipse.core.resources,
+ org.eclipse.debug.core,
+ org.eclipse.debug.ui,
+ org.eclipse.jdt.core,
+ org.eclipse.jdt.debug,
+ org.eclipse.jdt.debug.ui,
+ org.eclipse.jdt.launching,
+ org.eclipse.jdt.ui,
+ org.eclipse.jface.text,
+ org.eclipse.ui,
+ org.eclipse.ui.console,
+ org.eclipse.ui.editors,
+ org.eclipse.ui.forms,
+ org.eclipse.ui.ide,
+ org.eclipse.ui.views,
+ org.eclipse.ui.workbench.texteditor,
+ org.eclipse.gef,
+ com.ibm.icu
+Eclipse-LazyStart: true
+Eclipse-BuddyPolicy: registered
+Bundle-ClassPath: .,
+ lib/drools-compiler.jar,
+ lib/drools-core.jar,
+ lib/drools-decisiontables.jar,
+ lib/drools-jsr94.jar,
+ lib/jsr94.jar,
+ lib/junit.jar,
+ lib/jxl.jar,
+ lib/mvel14.jar,
+ lib/xercesImpl.jar,
+ lib/xml-apis.jar,
+ lib/xpp3.jar,
+ lib/xstream.jar,
+ lib/antlr-runtime.jar
+Bundle-RequiredExecutionEnvironment: J2SE-1.4
+Export-Package: org.drools.eclipse.util

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/build.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+bin.includes = .,\
+			   META-INF/,\
+               icons/,\
+               plugin.xml,\
+               help/,\
+               lib/
+bin.excludes = lib/drools-documentation.jar
+src.includes = META-INF/,\
+               icons/,\
+               plugin.xml,\
+               help/,\
+               lib/,\
+               .project,\
+               .classpath
+src.excludes =  lib/drools-documentation.jar
+jars.compile.order = .
+source.. = src/main/java/,\
+           src/main/resources/

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/action.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/action.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/activity.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/activity.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_connective.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_connective.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_field_to_fact.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/add_field_to_fact.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowleft.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowleft.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowright.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/arrowright.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/bluediamond.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/bluediamond.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/check.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/check.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/class_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/class_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear_disabled.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/clear_disabled.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/connection.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/connection.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/constant_co.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/constant_co.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_item_small.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_item_small.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/delete_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-large.PNG
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-large.PNG
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-query.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-query.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-rule.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools-rule.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/drools.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl-large.png
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl-large.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.png
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl.png
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl_expression.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dsl_expression.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_large.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_large.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_small.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/dt_small.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/edit.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/edit.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_private_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_private_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_public_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/field_public_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/function_assets.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/function_assets.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/greensquare.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/greensquare.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import_statement.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/import_statement.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/join.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/join.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure_disabled.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/logical_structure_disabled.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/methpub_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/methpub_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/new_item.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/new_item.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/open.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/open.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/package_obj.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/package_obj.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_start.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_start.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_stop.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/process_stop.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/public_co.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/public_co.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/question.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/question.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/redsquare.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/redsquare.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh_disabled.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/refresh_disabled.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/sample.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/sample.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/split.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/split.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/static_co.gif
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/static_co.gif
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/yellowsquare.GIF
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/icons/yellowsquare.GIF
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/plugin.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/plugin.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,430 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.0"?>
+<plugin>
+   <extension point="org.eclipse.ui.views">
+      <category
+         name="Drools"
+         id="org.drools.eclipse.views">
+      </category>
+      <view
+         name="Working Memory View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.debug.WorkingMemoryView"
+         id="org.drools.eclipse.debug.WorkingMemoryView">
+      </view>
+      <view
+         name="Agenda View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.debug.AgendaView"
+         id="org.drools.eclipse.debug.AgendaView">
+      </view>
+      <view
+         name="Global Data View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.debug.ApplicationDataView"
+         id="org.drools.eclipse.debug.ApplicationDataView">
+      </view>
+      <!--
+      <view
+         name="Realtime Audit View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.debug.RealtimeAuditView"
+         id="org.drools.eclipse.debug.RealtimeAuditView">
+      </view>
+      -->
+      <view
+         name="Audit View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.debug.AuditView"
+         id="org.drools.eclipse.debug.AuditView">
+      </view>
+      <view
+         name="Rules View"
+         icon="icons/drools.gif"
+         category="org.drools.eclipse.views"
+         class="org.drools.eclipse.view.rules.RulesView"
+         id="org.drools.eclipse.view.rules.RulesView">
+      </view>
+   </extension>
+
+   <extension
+         point="org.eclipse.debug.core.logicalStructureTypes">
+      <logicalStructureType
+        id="org.drools.eclipse.debug.AgendaLogicalStructures"
+        class="org.drools.eclipse.debug.AgendaLogicalStructureDelegate"
+        modelIdentifier="org.eclipse.jdt.debug"
+        description="Agenda Item">
+      </logicalStructureType>
+   </extension>
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.drools.eclipse.editors.DRLRuleEditor2"
+            contributorClass="org.drools.eclipse.editors.DRLRuleEditorActionContributor"
+            extensions="drl,jbrule,drools,rule,package,pkg"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.editors.DRLRuleEditor"
+            name="Rule Editor"/>
+      <editor
+            class="org.drools.eclipse.dsl.editor.DSLRuleEditor2"
+            contributorClass="org.drools.eclipse.editors.DRLRuleEditorActionContributor"
+            extensions="dslr,dslrule"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.editors.DSLRuleEditor"
+            name="DSL Rule Editor"/>
+      <editor
+            class="org.drools.eclipse.dsl.editor.DSLEditor"
+            contributorClass="org.eclipse.ui.editors.text.TextEditorActionContributor"
+            default="false"
+            extensions="dsl,lang"
+            icon="icons/dsl.GIF"
+            id="org.drools.eclipse.editor.DomainSpecLangEditor"
+            name="DSL Editor"/>
+   </extension>
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <wizard
+            category="org.drools.eclipse.new"
+            class="org.drools.eclipse.wizard.rule.NewRulePackageWizard"
+            descriptionImage="icons/drools-large.PNG"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.new.file"
+            name="Rule Resource"/>
+      <wizard
+            category="org.drools.eclipse.new"
+            class="org.drools.eclipse.wizard.dsl.NewDSLFileWizard"
+            descriptionImage="icons/dsl-large.png"
+            icon="icons/dsl.GIF"
+            id="org.drools.eclipse.new.dsl"
+            name="Domain Specific Language"/>
+      <wizard
+            id = "org.drools.eclipse.wizards.new.project"
+            name = "Rule Project"
+            class= "org.drools.eclipse.wizard.project.NewDroolsProjectWizard"
+            category= "org.drools.eclipse.new"
+            project= "true"
+            icon= "icons/drools.gif">
+         <description>This wizard creates a new Rule project.</description>
+      </wizard>
+      <category
+            id="org.drools.eclipse.new"
+            name="Drools"/>
+      <wizard
+            category="org.drools.eclipse.new"
+            class="org.drools.eclipse.wizard.decisiontable.NewDTFileWizard"
+            descriptionImage="icons/dt_large.gif"
+            icon="icons/dt_small.gif"
+            id="org.drools.eclipse.new.decisiontable"
+            name="Decision Table"/>
+   </extension>
+   <extension
+         id="org.drools.eclipse.actionSet"
+         name="Drools"
+         point="org.eclipse.ui.actionSets">
+      <actionSet
+            id="org.drools.eclipse.workbenchMenu"
+            label="Drools"
+            visible="true">
+         <action
+               class="org.drools.eclipse.menu.RuleHelperActionDelegate"
+               icon="icons/drools.gif"
+               id="org.drools.eclipse.openRulesWorkbench"
+               label="Drools wizards"
+               style="pulldown"
+               toolbarPath="Normal/additions"
+               tooltip="Drools workbench"/>
+      </actionSet>
+   </extension>
+
+   <extension
+      id="droolsbuilder" name="Drools Builder" point="org.eclipse.core.resources.builders">
+      <builder>
+         <run class="org.drools.eclipse.builder.DroolsBuilder"/>
+      </builder>
+   </extension>
+
+   <extension
+         id="problem"
+         point="org.eclipse.core.resources.markers"
+         name="Drools Error">
+      <super type="org.eclipse.core.resources.problemmarker"/>
+      <super type="org.eclipse.core.resources.textmarker"/>
+      <persistent value="true" />
+   </extension>
+
+   <extension
+         id="droolsBreakpointMarker"
+         point="org.eclipse.core.resources.markers"
+         name="Drools Breakpoint Marker">
+	  <super type="org.eclipse.debug.core.breakpointMarker"/>
+      <persistent value="true"/>
+	</extension>
+
+   <extension point="org.eclipse.debug.core.breakpoints">
+      <breakpoint
+         id="droolsBreakpoint"
+         markerType="org.drools.eclipse.droolsBreakpointMarker"
+         class="org.drools.eclipse.debug.core.DroolsLineBreakpoint">
+      </breakpoint>
+   </extension>
+
+   <extension point="org.eclipse.jdt.core.classpathContainerInitializer">
+       <classpathContainerInitializer class="org.drools.eclipse.util.DroolsClasspathContainerInitializer" id="DROOLS" />
+   </extension>
+
+   <extension point="org.eclipse.ui.editors.annotationTypes">
+      <type super="org.eclipse.ui.workbench.texteditor.error" markerSeverity="2" markerType="org.eclipse.core.resources.problemmarker" name="org.drools.eclipse.editors.error_annotation"/>
+   </extension>
+
+   <extension point="org.eclipse.help.toc">
+      <toc file="help/eclipse/toc.xml" primary="true" />
+   </extension>
+
+   <extension point = "org.eclipse.ui.preferencePages">
+      <page id="org.drools.eclipse.preferences.DroolsPreferencePage"
+         class="org.drools.eclipse.preferences.DroolsPreferencePage"
+         name="Drools Preferences">
+      </page>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.perspectives">
+      <perspective
+         name="Drools"
+         icon="icons/drools.gif"
+         class="org.drools.eclipse.DroolsPerspective"
+         id="org.drools.eclipse.DroolsPerspective">
+      </perspective>
+   </extension>
+
+   <!-- Extensions for the interactive debugger -->
+
+   <extension point = "org.eclipse.debug.core.launchConfigurationTypes">
+      <launchConfigurationType
+   	     id="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
+         name="Drools Application"
+         delegate="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
+         sourceLocatorId="org.drools.eclipse.launching.DroolsSourceLookupDirector"
+         sourcePathComputerId="org.eclipse.jdt.launching.sourceLookup.javaSourcePathComputer"
+         modes= "debug" />
+   </extension>
+
+   <extension point="org.eclipse.debug.ui.launchConfigurationTypeImages">
+      <launchConfigurationTypeImage
+         icon="icons/drools.gif"
+         configTypeID="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
+         id="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate.Image">
+      </launchConfigurationTypeImage>
+   </extension>
+
+   <extension
+         point="org.eclipse.debug.ui.launchConfigurationTabGroups">
+      <launchConfigurationTabGroup
+            type="org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate"
+            class="org.eclipse.jdt.internal.debug.ui.launcher.LocalJavaApplicationTabGroup"
+            id="org.eclipse.jdt.debug.ui.launchConfigurationTabGroup.localJavaApplication">
+            <launchMode
+                  mode="debug"
+                  perspective="org.eclipse.debug.ui.DebugPerspective"
+                  description="Debug a Drools application">
+            </launchMode>
+            <launchMode
+                  mode="run"
+                  description="Run a Drools application">
+            </launchMode>
+      </launchConfigurationTabGroup>
+   </extension>
+   
+   <extension
+         point="org.eclipse.debug.ui.launchShortcuts">
+      <shortcut
+            label="Drools Application"
+            icon="icons/drools.gif"
+            modes="debug"
+            class="org.drools.eclipse.launching.DroolsApplicationLaunchShortcut"
+            id="org.drools.eclipse.launching.DroolsApplicationLaunchShortcut">
+         <contextualLaunch>
+           <enablement>
+             <with variable="selection">
+               <count value="1"/>
+               <iterate>
+                <or>
+               	  <test property="org.eclipse.jdt.launching.hasMain"/>
+               	  <and>
+               	     <test property="org.eclipse.jdt.launching.isContainer"/>
+               	     <test property="org.eclipse.jdt.launching.hasProjectNature" args="org.eclipse.jdt.core.javanature"/>
+               	  </and>
+               	</or>
+               </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
+         point="org.eclipse.debug.core.sourceLocators">
+      <sourceLocator
+         name="Drools Source Lookup Director"
+         class="org.drools.eclipse.launching.DroolsSourceLookupDirector"
+         id="org.drools.eclipse.launching.DroolsSourceLookupDirector">
+      </sourceLocator>
+   </extension>
+
+   <extension point="org.eclipse.ui.editors.markerUpdaters">
+      <updater
+         markerType="org.drools.eclipse.droolsBreakpointMarker"
+         class="org.drools.eclipse.debug.core.DroolsLineBreakpointMarkerUpdater"
+         id="org.drools.eclipse.debug.core.DroolsLineBreakpointMarkerUpdater" />
+   </extension>
+
+   <!-- not used anymore
+   <extension
+         point="org.eclipse.debug.core.sourcePathComputers">
+      <sourcePathComputer
+         class="org.drools.eclipse.launching.DroolsSourcePathComputerDelegate"
+         id="org.drools.eclipse.launching.DroolsSourcePathComputerDelegate">
+      </sourcePathComputer>
+   </extension> -->
+
+   <extension
+         point="org.eclipse.debug.ui.debugModelPresentations">
+      <debugModelPresentation
+         class="org.drools.eclipse.debug.core.DroolsDebugModelPresentation"
+         id="org.drools.eclipse.debug">
+      </debugModelPresentation>
+   </extension>
+
+   <!-- not working if using multipage editor -->
+   <extension point="org.eclipse.ui.editorActions">
+      <editorContribution
+            targetID="org.drools.eclipse.editors.DRLRuleEditor"
+            id="org.drools.eclipse.editors.DRLRuleEditor.RulerActions">
+         <action
+            label="Not Used"
+            class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
+            style="push"
+            actionID="RulerDoubleClick"
+            id="org.drools.eclipse.editors.DRLRuleEditor.ToggleBreakpointRulerAction" />
+      </editorContribution>
+   </extension>
+
+   <!-- not working if using multipage editor -->
+   <extension point="org.eclipse.ui.popupMenus">
+      <viewerContribution
+            targetID="#TextRulerContext"
+            id="org.drools.eclipse.editors.DRLRuleEditor.RulerPopupActions">
+         <action
+            label="Toggle Breakpoint"
+            class="org.eclipse.debug.ui.actions.RulerToggleBreakpointActionDelegate"
+            menubarPath="additions"
+            id="org.drools.eclipse.editors.DRLRuleEditor.rulerContextMenu.ToggleBreakpointRulerAction">
+         </action>
+      </viewerContribution>
+   </extension>
+
+   <extension point = "org.eclipse.ui.popupMenus">
+	 <objectContribution
+           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"
+	       label="Convert to Drools Project"
+	       icon="icons/drools.gif"
+	       menubarPath="additions"
+	       class="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+           definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+	       enablesFor="1">
+	    </action>
+      </objectContribution>
+      <objectContribution
+           objectClass="org.eclipse.jdt.core.IJavaProject"
+           id="org.drools.eclipse.action.ConvertToDroolsProject2">
+	    <action id="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+	       label="Convert to Drools Project"
+	       icon="icons/drools.gif"
+	       menubarPath="additions"
+	       class="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+           definitionId="org.drools.eclipse.action.ConvertToDroolsProjectAction"
+	       enablesFor="1">
+	    </action>
+      </objectContribution>
+   </extension>
+
+   <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            name="RuleFlow Editor"
+            extensions="rf, ruleflow, rflow"
+            icon="icons/process.gif"
+            contributorClass="org.drools.eclipse.flow.common.editor.GenericActionBarContributor"
+            class="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor"
+            id="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
+      </editor>
+   </extension>
+
+   <extension
+         point = "org.eclipse.ui.editorActions">
+      <editorContribution
+            id="org.drools.eclipse.flow.ruleflow.editor.action.CheckRuleFlowAction"
+            targetID="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
+	     <action
+	        id="org.drools.eclipse.flow.ruleflow.editor.action.CheckRuleFlowAction"
+            label="Check RuleFlow"
+	        toolbarPath="Drools"
+            icon="icons/check.gif"
+            tooltip="Check the ruleflow model"
+            class="org.drools.eclipse.flow.ruleflow.editor.action.CheckRuleFlowAction"
+         />
+      </editorContribution>
+   </extension>
+
+   <extension
+         point = "org.eclipse.ui.newWizards">
+	  <category
+	    id = "org.drools.eclipse.flow.new"
+	    name="RuleFlow">
+	  </category>
+ 	  <wizard
+	      id = "org.drools.eclipse.flow.ruleflow.NewRuleFlowFileWizard"
+      	  name = "RuleFlow File"
+	      class="org.drools.eclipse.flow.ruleflow.NewRuleFlowFileWizard"
+          category="org.drools.eclipse.new"
+	      icon="icons/process.gif">
+    	<description>A wizard that creates a new ruleflow file</description>
+	    <selection class="org.eclipse.core.resources.IResource"/>
+	  </wizard>
+   </extension>
+
+   <!-- RuleBuilder Extensions -->
+      <extension
+         point="org.eclipse.ui.editors">
+      <editor
+            class="org.drools.eclipse.rulebuilder.editors.RuleEditor"
+            extensions="brl"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.ide.rulebuilder.brl.editors.RuleEditor"
+            name="Guided Rule Editor"/>
+   </extension>
+
+
+   <extension
+         point="org.eclipse.ui.newWizards">
+      <wizard
+            category="org.drools.eclipse.new"
+            class="org.drools.eclipse.rulebuilder.wizards.NewBrlFileWizard"
+            descriptionImage="icons/drools-large.PNG"
+            icon="icons/drools.gif"
+            id="org.drools.eclipse.rulebuilder.wizards.NewGuidedRuleFileWizard"
+            name="Guided Rule"/>
+   </extension>
+</plugin>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/pom.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,146 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/P
+OM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+        <modelVersion>4.0.0</modelVersion>
+        <groupId>drools</groupId>
+        <artifactId>drools-eclipse-plugin</artifactId>
+        <packaging>osgi-bundle</packaging>
+        <version>1.0-SNAPSHOT</version>
+        
+        
+        
+  <repositories>
+    <repository>
+      <id>eclipse</id>
+      <url>http://repo1.maven.org/eclipse/</url>
+    </repository>
+  </repositories>        
+        
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.codehaus.tycho</groupId>
+        <artifactId>maven-osgi-lifecycle-plugin</artifactId>
+        <extensions>true</extensions>
+      </plugin>
+    </plugins>
+  </build>
+        
+  <dependencies>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.core.runtime</artifactId>
+      <version>3.2.0.v20060603</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.core.resources</artifactId>
+      <version>3.2.1.R32x_v20060914</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.core.resources.compatibility</artifactId>
+      <version>3.2.0.v20060603</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.core.resources.win32</artifactId>
+      <version>3.2.0.v20060603</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.debug.core</artifactId>
+      <version>3.2.1.v20060823</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.debug.ui</artifactId>
+      <version>3.2.1.v20060823</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jdt.core</artifactId>
+      <version>3.2.1.v_677_R32x</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jdt.debug</artifactId>
+      <version>3.2.1.r321_v20060731</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jdt.debug.ui</artifactId>
+      <version>3.2.1.r321_v20060918</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jdt.launching</artifactId>
+      <version>3.2.1.r321_v20060731</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jdt.ui</artifactId>
+      <version>3.2.1.r321_v20060907</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.jface.text</artifactId>
+      <version>3.2.1.r321_v20060810</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui</artifactId>
+      <version>3.2.1.M20060913-0800</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.console</artifactId>
+      <version>3.1.100.v20060605</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.editors</artifactId>
+      <version>3.2.1.r321_v20060721</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.forms</artifactId>
+      <version>3.2.0.v20060602</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.ide</artifactId>
+      <version>3.2.1.M20060915-1030</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.win32</artifactId>
+      <version>3.2.0.I20060605-1400</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.views</artifactId>
+      <version>3.2.1.M20060906-0800</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.ui.workbench.texteditor</artifactId>
+      <version>3.2.0.v20060605-1400</version>
+    </dependency>
+    <dependency>
+      <groupId>org.eclipse</groupId>
+      <artifactId>org.eclipse.gef</artifactId>
+      <version>3.2.2.v20070208</version>
+    </dependency>
+    <dependency>
+      <groupId>com.ibm</groupId>
+      <artifactId>com.ibm.icu</artifactId>
+      <version>3.4.5</version>
+    </dependency>
+<dependency>
+	<groupId>org.eclipse</groupId>
+	<artifactId>org.eclipse.swt.win32.win32.x86</artifactId>
+	<version>3.2.1.v3235</version>
+</dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DRLInfo.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DRLInfo.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DRLInfo.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,258 @@
+package org.drools.eclipse;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.compiler.Dialect;
+import org.drools.compiler.DroolsError;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.rule.LineMappings;
+import org.drools.rule.Package;
+import org.drools.rule.PackageCompilationData;
+
+public class DRLInfo {
+
+	private static final DroolsError[] EMPTY_DROOLS_ERROR_ARRAY = new DroolsError[0];
+	private static final List EMPTY_LIST = Collections.unmodifiableList(Collections.EMPTY_LIST);
+
+	private String sourcePathName;
+	private PackageDescr packageDescr;
+	private List parserErrors;
+	private Package compiledPackage;
+	private DroolsError[] builderErrors;
+	// cached entry
+	private transient RuleInfo[] ruleInfos;
+	private transient FunctionInfo[] functionInfos;
+
+	public DRLInfo(String sourcePathName, PackageDescr packageDescr, List parserErrors) {
+		if (sourcePathName == null || "".equals(sourcePathName)) {
+			throw new IllegalArgumentException("Invalid sourcePathName " + sourcePathName);
+		}
+		if (packageDescr == null) {
+			throw new IllegalArgumentException("Null packageDescr");
+		}
+		this.sourcePathName = sourcePathName;
+		this.packageDescr = packageDescr;
+		this.parserErrors =
+			parserErrors == null ? EMPTY_LIST : Collections.unmodifiableList(parserErrors);
+		this.builderErrors = EMPTY_DROOLS_ERROR_ARRAY;
+	}
+
+	public DRLInfo(String pathName, PackageDescr packageDescr, List parserErrors, Package compiledPackage, DroolsError[] builderErrors) {
+		this(pathName, packageDescr, parserErrors);
+		if (compiledPackage == null) {
+			throw new IllegalArgumentException("Null package");
+		}
+		this.compiledPackage = compiledPackage;
+		this.builderErrors =
+			builderErrors == null ? EMPTY_DROOLS_ERROR_ARRAY : builderErrors;
+	}
+
+	public String getSourcePathName() {
+		return sourcePathName;
+	}
+
+	public PackageDescr getPackageDescr() {
+		return packageDescr;
+	}
+
+	public List getParserErrors() {
+		return parserErrors;
+	}
+
+	public Package getPackage() {
+		return compiledPackage;
+	}
+
+	public DroolsError[] getBuilderErrors() {
+		return builderErrors;
+	}
+
+	public String getPackageName() {
+		return packageDescr.getName();
+	}
+
+	public boolean isCompiled() {
+		return compiledPackage != null;
+	}
+
+	public RuleInfo[] getRuleInfos() {
+		if (ruleInfos == null) {
+			List ruleInfosList = new ArrayList();
+	        for (Iterator rules = packageDescr.getRules().iterator(); rules.hasNext(); ) {
+	    		RuleDescr ruleDescr = (RuleDescr) rules.next();
+	    		RuleInfo ruleInfo = new RuleInfo(ruleDescr);
+	    		ruleInfosList.add(ruleInfo);
+	    	}
+	    	ruleInfos = (RuleInfo[]) ruleInfosList.toArray(new RuleInfo[0]);
+		}
+		return ruleInfos;
+	}
+
+	public RuleInfo getRuleInfo(int drlLineNumber) {
+		RuleInfo[] ruleInfos = getRuleInfos();
+
+		int ruleLine = -1;
+		RuleInfo result = null;
+		for (int i = 0; i < ruleInfos.length; i++) {
+			int ruleDrlLineNumber = ruleInfos[i].getDrlLineNumber();
+			if (ruleDrlLineNumber > ruleLine
+					&& ruleDrlLineNumber <= drlLineNumber + 1) {
+				ruleLine = ruleDrlLineNumber;
+				result = ruleInfos[i];
+			}
+		}
+		return result;
+	}
+
+	public class RuleInfo {
+
+		private final RuleDescr ruleDescr;
+		// cached entries
+		private transient String className;
+		private transient int consequenceJavaLineNumber = -1;
+
+		public RuleInfo(RuleDescr ruleDescr) {
+			if (ruleDescr == null) {
+				throw new IllegalArgumentException("Null ruleDescr");
+			}
+			this.ruleDescr = ruleDescr;
+		}
+
+        public Dialect getDialect() {
+            return ruleDescr.getDialect();
+        }
+
+		public String getSourcePathName() {
+			return DRLInfo.this.getSourcePathName();
+		}
+
+		public String getClassName() {
+			// ruleDescr is only filled in during compilation
+			if (!isCompiled()) {
+				throw new IllegalArgumentException("Package has not been compiled");
+			}
+			if (className == null) {
+	    		className = getPackageName() + "." + ruleDescr.getClassName();
+			}
+			return className;
+		}
+
+		public int getDrlLineNumber() {
+			return ruleDescr.getLine();
+		}
+
+		public int getConsequenceDrlLineNumber() {
+			return ruleDescr.getConsequenceLine();
+		}
+
+		public int getConsequenceJavaLineNumber() {
+			if (consequenceJavaLineNumber == -1) {
+				if (!isCompiled()) {
+					throw new IllegalArgumentException("Package has not been compiled");
+				}
+				PackageCompilationData data = compiledPackage
+                					.getPackageCompilationData();
+
+                LineMappings mappings = data.getLineMappings(className);
+                consequenceJavaLineNumber = mappings.getOffset();
+
+			}
+			return consequenceJavaLineNumber;
+		}
+
+		public String getPackageName() {
+			return packageDescr.getName();
+		}
+
+		public String getRuleName() {
+			return ruleDescr.getName();
+		}
+	}
+
+	public FunctionInfo[] getFunctionInfos() {
+		if (functionInfos == null) {
+			List functionInfosList = new ArrayList();
+	        for (Iterator functions = packageDescr.getFunctions().iterator(); functions.hasNext(); ) {
+	    		FunctionDescr functionDescr = (FunctionDescr) functions.next();
+	    		FunctionInfo functionInfo = new FunctionInfo(functionDescr);
+	    		functionInfosList.add(functionInfo);
+	    	}
+	        functionInfos = (FunctionInfo[]) functionInfosList.toArray(new FunctionInfo[0]);
+		}
+		return functionInfos;
+	}
+
+	public FunctionInfo getFunctionInfo(int drlLineNumber) {
+		FunctionInfo[] functionInfos = getFunctionInfos();
+		int functionLine = -1;
+		FunctionInfo result = null;
+		for (int i = 0; i < functionInfos.length; i++) {
+			int functionDrlLineNumber = functionInfos[i].getDrlLineNumber();
+			if (functionDrlLineNumber > functionLine
+					&& functionDrlLineNumber <= drlLineNumber + 1) {
+				functionLine = functionDrlLineNumber;
+				result = functionInfos[i];
+			}
+		}
+		return result;
+	}
+
+	public class FunctionInfo {
+
+		private FunctionDescr functionDescr;
+		// cached entries
+		private transient String className;
+		private transient int javaLineNumber = -1;
+
+		public FunctionInfo(FunctionDescr functionDescr) {
+			if (functionDescr == null) {
+				throw new IllegalArgumentException("Null functionDescr");
+			}
+			this.functionDescr = functionDescr;
+		}
+
+		public String getSourcePathName() {
+			return DRLInfo.this.getSourcePathName();
+		}
+
+		public String getClassName() {
+			// functionDescr is only filled in during compilation
+			if (!isCompiled()) {
+				throw new IllegalArgumentException("Package has not been compiled");
+			}
+			if (className == null) {
+	    		className = functionDescr.getClassName();
+			}
+			return className;
+		}
+
+		public int getDrlLineNumber() {
+			return functionDescr.getLine();
+		}
+
+		public int getJavaLineNumber() {
+			if (javaLineNumber == -1) {
+				if (!isCompiled()) {
+					throw new IllegalArgumentException("Package has not been compiled");
+				}
+				javaLineNumber = compiledPackage
+					.getPackageCompilationData().getLineMappings(className).getOffset();
+			}
+			return javaLineNumber;
+		}
+
+		public String getPackageName() {
+			return packageDescr.getName();
+		}
+
+		public String getFunctionName() {
+			return functionDescr.getName();
+		}
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,425 @@
+package org.drools.eclipse;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Reader;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.builder.DroolsBuilder;
+import org.drools.eclipse.builder.Util;
+import org.drools.eclipse.dsl.editor.DSLAdapter;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.eclipse.preferences.IDroolsConstants;
+import org.drools.eclipse.util.ProjectClassLoader;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.rule.builder.dialect.java.JavaDialectConfiguration;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The main plugin class to be used in the desktop.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DroolsEclipsePlugin extends AbstractUIPlugin {
+    
+    public static final int INTERNAL_ERROR = 120;
+    public static final String PLUGIN_ID = "org.drools.eclipse";
+    public static final String BUILD_RESULT_PACKAGE = "Package";
+    public static final String BUILD_RESULT_PACKAGE_DESCR = "PackageDescr";
+    
+	//The shared instance.
+	private static DroolsEclipsePlugin plugin;
+	//Resource bundle.
+	private ResourceBundle resourceBundle;
+	private Map colors = new HashMap();
+	private Map parsedRules = new HashMap();
+	private Map compiledRules = new HashMap();
+	private Map ruleInfoByClassNameMap = new HashMap();
+	private Map functionInfoByClassNameMap = new HashMap();
+	private boolean useCachePreference;
+
+    private FormColors               ruleBuilderFormColors;
+
+	/**
+	 * The constructor.
+	 */
+	public DroolsEclipsePlugin() {
+		super();
+		plugin = this;
+	}
+
+	/**
+	 * This method is called upon plug-in activation
+	 */
+	public void start(BundleContext context) throws Exception {
+		super.start(context);
+		IPreferenceStore preferenceStore = getPreferenceStore();
+		useCachePreference = preferenceStore.getBoolean(IDroolsConstants.CACHE_PARSED_RULES);
+    	preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {
+			public void propertyChange(PropertyChangeEvent event) {
+				if (IDroolsConstants.CACHE_PARSED_RULES.equals(event.getProperty())) {
+					useCachePreference = ((Boolean) event.getNewValue()).booleanValue();
+					if (!useCachePreference) {
+						clearCache();
+					}
+				}
+			}
+    	});
+
+    }
+	
+	public void clearCache() {
+		parsedRules.clear();
+		compiledRules.clear();
+		ruleInfoByClassNameMap.clear();
+		functionInfoByClassNameMap.clear();
+	}
+
+	/**
+	 * This method is called when the plug-in is stopped
+	 */
+	public void stop(BundleContext context) throws Exception {
+		super.stop(context);
+		plugin = null;
+		resourceBundle = null;
+		parsedRules = null;
+		compiledRules = null;
+		Iterator iterator = colors.values().iterator();
+		while (iterator.hasNext()) {
+			((Color) iterator.next()).dispose();
+		}
+	}
+
+	/**
+	 * Returns the shared instance.
+	 */
+	public static DroolsEclipsePlugin getDefault() {
+		return plugin;
+	}
+
+	/**
+	 * Returns the string from the plugin's resource bundle,
+	 * or 'key' if not found.
+	 */
+	public static String getResourceString(String key) {
+		ResourceBundle bundle = DroolsEclipsePlugin.getDefault().getResourceBundle();
+		try {
+			return (bundle != null) ? bundle.getString(key) : key;
+		} catch (MissingResourceException e) {
+			return key;
+		}
+	}
+
+	/**
+	 * Returns the plugin's resource bundle,
+	 */
+	public ResourceBundle getResourceBundle() {
+		try {
+			if (resourceBundle == null)
+				resourceBundle = ResourceBundle.getBundle("droolsIDE.DroolsIDEPluginResources");
+		} catch (MissingResourceException x) {
+			resourceBundle = null;
+		}
+		return resourceBundle;
+	}
+
+	/**
+	 * Returns an image descriptor for the image file at the given
+	 * plug-in relative path.
+     * Uses the plug ins image registry to "cache" it.
+	 *
+	 * @param path the path
+	 * @return the image descriptor
+	 */
+	public static ImageDescriptor getImageDescriptor(String path) {
+        
+        DroolsEclipsePlugin plugin = getDefault();
+        ImageRegistry reg = plugin.getImageRegistry();
+        ImageDescriptor des = reg.getDescriptor( path );
+        if (des == null) {
+            des = AbstractUIPlugin.imageDescriptorFromPlugin("org.drools.eclipse", path);
+            reg.put( path, des );
+        }
+		return des;
+	}
+    
+    public static String getUniqueIdentifier() {
+        if (getDefault() == null) {
+            return PLUGIN_ID;
+        }
+        return getDefault().getBundle().getSymbolicName();
+    }
+    
+    public static void log(Throwable t) {
+        Throwable top = t;
+        if (t instanceof DebugException) {
+            DebugException de = (DebugException) t;
+            IStatus status = de.getStatus();
+            if (status.getException() != null) {
+                top = status.getException();
+            }
+        } 
+        log(new Status(IStatus.ERROR, getUniqueIdentifier(),
+            INTERNAL_ERROR, "Internal error in Drools Plugin: ", top));        
+    }
+
+    public static void log(IStatus status) {
+        getDefault().getLog().log(status);
+    }
+
+	public Color getColor(String type) {
+		return (Color) colors.get(type);
+	}
+	
+	public void setColor(String type, Color color) {
+		colors.put(type, color);
+	}
+	
+	protected void initializeDefaultPreferences(IPreferenceStore store) {
+		store.setDefault(IDroolsConstants.BUILD_ALL, false);
+		store.setDefault(IDroolsConstants.EDITOR_FOLDING, true);
+		store.setDefault(IDroolsConstants.CACHE_PARSED_RULES, true);
+	}
+	
+	public DRLInfo parseResource(IResource resource, boolean compile) throws DroolsParserException {
+		DRLInfo result = (DRLInfo) compiledRules.get(resource);
+		if (result == null && !compile) {
+			result = (DRLInfo) parsedRules.get(resource);
+		}
+		if (result != null) {
+			return result;
+		}
+		return generateParsedResource(resource, compile);
+	}
+	
+	public DRLInfo parseResource(AbstractRuleEditor editor, boolean useUnsavedContent, boolean compile) throws DroolsParserException {
+		IResource resource = editor.getResource();
+		if (!editor.isDirty() || !useUnsavedContent) {
+			DRLInfo result = (DRLInfo) compiledRules.get(resource);
+			if (result == null && !compile) {
+				result = (DRLInfo) parsedRules.get(resource);
+			}
+			if (result != null) {
+				return result;
+			}
+		}
+		if (!editor.isDirty()) {
+			return generateParsedResource(editor.getContent(), resource, true, compile);
+		}
+		// TODO: can we cache result when using unsaved content as well? 
+		return generateParsedResource(editor.getContent(), resource, !useUnsavedContent, compile);
+	}
+	
+	public DRLInfo parseXLSResource(String content, IResource resource) throws DroolsParserException {
+		DRLInfo result = (DRLInfo) compiledRules.get(resource);
+		if (result != null) {
+			return result;
+		}
+		return generateParsedResource(content, resource, false, true);
+	}
+	
+	public DRLInfo parseBRLResource(String content, IResource resource) throws DroolsParserException {
+		DRLInfo result = (DRLInfo) compiledRules.get(resource);
+		if (result != null) {
+			return result;
+		}
+		return generateParsedResource(content, resource, false, true);
+	}
+	
+	public void invalidateResource(IResource resource) {
+		DRLInfo cached = (DRLInfo) compiledRules.remove(resource);
+		if (cached != null) {
+			RuleInfo[] ruleInfos = cached.getRuleInfos();
+			for (int i = 0; i < ruleInfos.length; i++) {
+				ruleInfoByClassNameMap.remove(ruleInfos[i].getClassName());
+			}
+			FunctionInfo[] functionInfos = cached.getFunctionInfos();
+			for (int i = 0; i < functionInfos.length; i++) {
+				functionInfoByClassNameMap.remove(functionInfos[i].getClassName());
+			}
+		}
+		parsedRules.remove(resource);
+	}
+	
+	private DRLInfo generateParsedResource(IResource resource, boolean compile) throws DroolsParserException {
+		if (resource instanceof IFile) {
+			IFile file = (IFile) resource;
+	        try {
+	        	String content = new String(Util.getResourceContentsAsCharArray(file));
+	        	return generateParsedResource(content, file, true, compile);
+	        } catch (CoreException e) {
+	        	log(e);
+	        }
+		}
+		return null;
+	}
+
+	private DRLInfo generateParsedResource(String content, IResource resource, boolean useCache, boolean compile) throws DroolsParserException {
+		useCache = useCache && useCachePreference;
+        DrlParser parser = new DrlParser();
+        try {
+            Reader dslReader = DSLAdapter.getDSLContent(content, resource);
+            ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+            ClassLoader newLoader = DroolsBuilder.class.getClassLoader();
+            PackageBuilderConfiguration builder_configuration = new PackageBuilderConfiguration();
+            if (resource.getProject().getNature("org.eclipse.jdt.core.javanature") != null) {
+                IJavaProject project = JavaCore.create(resource.getProject());
+                newLoader = ProjectClassLoader.getProjectClassLoader(project);
+                String level = project.getOption(JavaCore.COMPILER_COMPLIANCE, true);
+                JavaDialectConfiguration javaConf = ( JavaDialectConfiguration ) builder_configuration.getDialectConfiguration( "java" );
+                javaConf.setJavaLanguageLevel(level);
+            }
+            try {
+            	builder_configuration.setClassLoader(newLoader);
+                Thread.currentThread().setContextClassLoader(newLoader);
+
+                // first parse the source
+                PackageDescr packageDescr = null;
+                List parserErrors = null;
+                if (useCache) {
+                	DRLInfo cachedDrlInfo = (DRLInfo) parsedRules.get(resource);
+                	if (cachedDrlInfo != null) {
+                		packageDescr = cachedDrlInfo.getPackageDescr();
+                		parserErrors = cachedDrlInfo.getParserErrors();
+                	}
+                }
+                
+                if (packageDescr == null) {
+                	if (dslReader != null) {
+                		packageDescr = parser.parse(content, dslReader);
+                	} else {
+                		packageDescr = parser.parse(content);
+                	}
+                	parserErrors = parser.getErrors();
+                }
+                PackageBuilder builder = null;
+        		DRLInfo result = null;
+            	// compile parsed rules if necessary
+            	if (compile && !parser.hasErrors()) {
+                    builder = new PackageBuilder(builder_configuration);
+
+                    // check whether a .package file exists and add it
+                    if (resource.getParent() != null) {
+                    	MyResourceVisitor visitor = new MyResourceVisitor();
+                		resource.getParent().accept(visitor, IResource.DEPTH_ONE, IResource.NONE);
+                    	IResource packageDef = visitor.getPackageDef();
+                    	if (packageDef != null) {
+                    		builder.addPackage(parseResource(packageDef, false).getPackageDescr());
+                    	}
+                    }
+                    
+                    builder.addPackage(packageDescr);
+        			result = new DRLInfo(
+	    				resource.getProjectRelativePath().toString(),
+	    				packageDescr, parserErrors,
+	    				builder.getPackage(), builder.getErrors().getErrors());
+        		} else {
+        			result = new DRLInfo(
+	    				resource.getProjectRelativePath().toString(),
+	    				packageDescr, parserErrors);
+        		}
+        		            		
+            	// cache result
+        		if (useCache) {
+	    			if (compile && !parser.hasErrors()) {
+	    				parsedRules.remove(resource);
+    					compiledRules.put(resource, result);
+	        			RuleInfo[] ruleInfos = result.getRuleInfos();
+	        			for (int i = 0; i < ruleInfos.length; i++) {
+	        				ruleInfoByClassNameMap.put(ruleInfos[i].getClassName(), ruleInfos[i]);
+	        			}
+	        			FunctionInfo[] functionInfos = result.getFunctionInfos();
+	        			for (int i = 0; i < functionInfos.length; i++) {
+	        				functionInfoByClassNameMap.put(functionInfos[i].getClassName(), functionInfos[i]);
+	        			}
+	    			} else {
+    					parsedRules.put(resource, result);
+	    			}
+        		}
+            	return result;
+            } finally {
+                Thread.currentThread().setContextClassLoader(oldLoader);
+            }
+        } catch (CoreException e) {
+        	log(e);
+        }
+		return null;
+	}
+	
+	public RuleInfo getRuleInfoByClass(String ruleClassName) {
+		return (RuleInfo) ruleInfoByClassNameMap.get(ruleClassName);
+	}
+
+	public FunctionInfo getFunctionInfoByClass(String functionClassName) {
+		return (FunctionInfo) functionInfoByClassNameMap.get(functionClassName);
+	}
+
+    /**
+     * Form Colors, default colors for now.
+     * 
+     * @param display
+     * @return
+     */
+    public FormColors getRuleBuilderFormColors(Display display) {
+        if ( ruleBuilderFormColors == null ) {
+            ruleBuilderFormColors = new FormColors( display );
+            ruleBuilderFormColors.markShared();
+        }
+        return ruleBuilderFormColors;
+    }
+
+    private class MyResourceVisitor implements IResourceVisitor {
+    	private IResource packageDef;
+		public boolean visit(IResource resource) throws CoreException {
+			if ("package".equals(resource.getFileExtension())) {
+				packageDef = resource;
+			}
+			return true;
+		}
+		public IResource getPackageDef() {
+			return packageDef;
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPerspective.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPerspective.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPerspective.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,77 @@
+package org.drools.eclipse;
+
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.ui.JavaUI;
+import org.eclipse.ui.IFolderLayout;
+import org.eclipse.ui.IPageLayout;
+import org.eclipse.ui.IPerspectiveFactory;
+import org.eclipse.ui.console.IConsoleConstants;
+import org.eclipse.ui.progress.IProgressConstants;
+
+public class DroolsPerspective implements IPerspectiveFactory {
+
+	public void createInitialLayout(IPageLayout layout) {
+ 		String editorArea = layout.getEditorArea();
+		
+		IFolderLayout folder= layout.createFolder("left", IPageLayout.LEFT, (float)0.25, editorArea); //$NON-NLS-1$
+		folder.addView(JavaUI.ID_PACKAGES);
+		folder.addPlaceholder(JavaUI.ID_TYPE_HIERARCHY);
+		folder.addView(IPageLayout.ID_RES_NAV);
+		
+		IFolderLayout rulesfolder= layout.createFolder("leftbottom", IPageLayout.BOTTOM, (float)0.5, "left"); //$NON-NLS-1$
+		rulesfolder.addView(IDroolsConstants.RULES_VIEW);
+		
+		IFolderLayout outputfolder= layout.createFolder("bottom", IPageLayout.BOTTOM, (float)0.75, editorArea); //$NON-NLS-1$
+		outputfolder.addView(IPageLayout.ID_PROBLEM_VIEW);
+		outputfolder.addView(IPageLayout.ID_PROP_SHEET);
+		outputfolder.addPlaceholder(JavaUI.ID_JAVADOC_VIEW);
+		outputfolder.addPlaceholder(JavaUI.ID_SOURCE_VIEW);
+		outputfolder.addPlaceholder(IConsoleConstants.ID_CONSOLE_VIEW);
+		outputfolder.addPlaceholder(IPageLayout.ID_BOOKMARKS);
+		outputfolder.addPlaceholder(IProgressConstants.PROGRESS_VIEW_ID);
+		
+		// *** Drools-specific extensions ***
+		outputfolder.addView(IDroolsConstants.AUDIT_VIEW);
+		layout.addShowViewShortcut(IDroolsConstants.AUDIT_VIEW);
+		layout.addNewWizardShortcut("org.drools.eclipse.new.file");
+		layout.addNewWizardShortcut("org.drools.eclipse.new.dsl");
+		layout.addNewWizardShortcut("org.drools.eclipse.wizards.new.project");
+		// **********************************
+		
+		layout.addView(IPageLayout.ID_OUTLINE, IPageLayout.RIGHT, (float)0.75, editorArea);
+		
+		layout.addActionSet(IDebugUIConstants.LAUNCH_ACTION_SET);
+		layout.addActionSet(JavaUI.ID_ACTION_SET);
+		layout.addActionSet(JavaUI.ID_ELEMENT_CREATION_ACTION_SET);
+		layout.addActionSet(IPageLayout.ID_NAVIGATE_ACTION_SET);
+		
+		// views - java
+		layout.addShowViewShortcut(JavaUI.ID_PACKAGES);
+		layout.addShowViewShortcut(JavaUI.ID_TYPE_HIERARCHY);
+		layout.addShowViewShortcut(JavaUI.ID_SOURCE_VIEW);
+		layout.addShowViewShortcut(JavaUI.ID_JAVADOC_VIEW);
+
+		// views - debugging
+		layout.addShowViewShortcut(IConsoleConstants.ID_CONSOLE_VIEW);
+
+		// views - standard workbench
+		layout.addShowViewShortcut(IPageLayout.ID_OUTLINE);
+		layout.addShowViewShortcut(IPageLayout.ID_PROBLEM_VIEW);
+		layout.addShowViewShortcut(IPageLayout.ID_RES_NAV);
+		layout.addShowViewShortcut(IPageLayout.ID_TASK_LIST);
+		layout.addShowViewShortcut(IProgressConstants.PROGRESS_VIEW_ID);
+				
+		// new actions - Java project creation wizard
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewPackageCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewClassCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewInterfaceCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewEnumCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewAnnotationCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSourceFolderCreationWizard");	 //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.jdt.ui.wizards.NewSnippetFileCreationWizard"); //$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.folder");//$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.ui.wizards.new.file");//$NON-NLS-1$
+		layout.addNewWizardShortcut("org.eclipse.ui.editors.wizards.UntitledTextFileWizard");//$NON-NLS-1$
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPluginImages.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPluginImages.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/DroolsPluginImages.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,146 @@
+package org.drools.eclipse;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Handles the images used in this plugin.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DroolsPluginImages {
+
+    public static final String IMG_LOGICAL = "ImageLogical";
+    public static final String IMG_LOGICAL_DISABLED = "ImageLogicalDisabled";
+    public static final String REFRESH_LOG = "RefreshLog";
+    public static final String REFRESH_LOG_DISABLED = "RefreshLogDisabled";
+    public static final String OPEN_LOG = "OpenLog";
+    public static final String DELETE_LOG = "ClearLog";
+    public static final String DELETE_LOG_DISABLED = "ClearLogDisabled";
+    public static final String INSERT = "Insert";
+    public static final String UPDATE = "Update";
+    public static final String RETRACT = "RetractO";
+    public static final String CREATE_ACTIVATION = "CreateActivation";
+    public static final String CANCEL_ACTIVATION = "CancelActivation";
+    public static final String EXECUTE_ACTIVATION = "ExecuteActivation";
+    public static final String CLASS = "Class";
+    public static final String PACKAGE = "Package";
+    public static final String METHOD = "Method";
+    public static final String VARIABLE = "Variable";
+    public static final String DROOLS = "Drools";
+    public static final String RULE = "DroolsRule";
+    public static final String QUERY = "DroolsQuery";
+    public static final String DSL_EXPRESSION = "DslExpression";
+    public static final String IMPORT = "Import";
+    public static final String DSL = "DSL";
+    public static final String GLOBAL = "Global";
+    public static final String RULEFLOW = "RuleFlow";
+    
+    private static ImageRegistry imageRegistry;
+    private static final String PATH_SUFFIX = "/icons/";
+    private static final URL ICON_BASE_URL =
+    	DroolsEclipsePlugin.getDefault().getBundle().getEntry(PATH_SUFFIX);
+    
+    private static void declareImages() {
+        declareRegistryImage(IMG_LOGICAL, "logical_structure.gif");
+        declareRegistryImage(IMG_LOGICAL_DISABLED, "logical_structure_disabled.gif");
+        declareRegistryImage(REFRESH_LOG, "refresh.gif");
+        declareRegistryImage(REFRESH_LOG_DISABLED, "refresh_disabled.gif");
+        declareRegistryImage(OPEN_LOG, "open.gif");
+        declareRegistryImage(DELETE_LOG, "clear.gif");
+        declareRegistryImage(DELETE_LOG_DISABLED, "clear_disabled.gif");
+        declareRegistryImage(INSERT, "greensquare.GIF");
+        declareRegistryImage(UPDATE, "yellowsquare.GIF");
+        declareRegistryImage(RETRACT, "redsquare.GIF");
+        declareRegistryImage(CREATE_ACTIVATION, "arrowright.GIF");
+        declareRegistryImage(CANCEL_ACTIVATION, "arrowleft.GIF");
+        declareRegistryImage(EXECUTE_ACTIVATION, "bluediamond.GIF");
+        declareRegistryImage(CLASS, "class_obj.gif");
+        declareRegistryImage(PACKAGE, "package_obj.gif");
+        declareRegistryImage(METHOD, "methpub_obj.gif");
+        declareRegistryImage(VARIABLE, "field_private_obj.gif");
+        declareRegistryImage(DROOLS, "drools.gif");
+        declareRegistryImage(RULE, "drools-rule.GIF");
+        declareRegistryImage(QUERY, "drools-query.GIF");
+        declareRegistryImage(DSL_EXPRESSION, "dsl_expression.gif");
+        declareRegistryImage(IMPORT, "import.gif");
+        declareRegistryImage(DSL, "dsl.GIF");
+        declareRegistryImage(GLOBAL, "field_public_obj.gif");
+        declareRegistryImage(RULEFLOW, "process.gif");
+    }
+
+    /**
+     * Declare an Image in the registry table.
+     * @param key   The key to use when registering the image
+     * @param path  The path where the image can be found. This path is relative to where
+     *              this plugin class is found (i.e. typically the packages directory)
+     */
+    private final static void declareRegistryImage(String key, String path) {
+        ImageDescriptor desc= ImageDescriptor.getMissingImageDescriptor();
+        try {
+            desc= ImageDescriptor.createFromURL(makeIconFileURL(path));
+        } catch (MalformedURLException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+        imageRegistry.put(key, desc);
+    }
+    
+    /**
+     * Returns the ImageRegistry.
+     */
+    public static ImageRegistry getImageRegistry() {
+        if (imageRegistry == null) {
+            initializeImageRegistry();
+        }
+        return imageRegistry;
+    }
+
+    public static ImageRegistry initializeImageRegistry() {
+        imageRegistry = new ImageRegistry();
+        declareImages();
+        return imageRegistry;
+    }
+
+    /**
+     * Returns the <code>Image</code> identified by the given key,
+     * or <code>null</code> if it does not exist.
+     */
+    public static Image getImage(String key) {
+        return getImageRegistry().get(key);
+    }
+    
+    /**
+     * Returns the <code>ImageDescriptor</code> identified by the given key,
+     * or <code>null</code> if it does not exist.
+     */
+    public static ImageDescriptor getImageDescriptor(String key) {
+		return getImageRegistry().getDescriptor(key);
+    }
+    
+    private static URL makeIconFileURL(String iconPath) throws MalformedURLException {
+        if (ICON_BASE_URL == null) {
+            throw new MalformedURLException();
+        }
+            
+        return new URL(ICON_BASE_URL, iconPath);
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/IDroolsConstants.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/IDroolsConstants.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/IDroolsConstants.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,8 @@
+package org.drools.eclipse;
+
+public interface IDroolsConstants {
+	
+	final String AUDIT_VIEW = "org.drools.eclipse.debug.AuditView";
+	final String RULES_VIEW = "org.drools.eclipse.view.rules.RulesView";
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/action/ConvertToDroolsProjectAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/action/ConvertToDroolsProjectAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/action/ConvertToDroolsProjectAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,88 @@
+package org.drools.eclipse.action;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.builder.DroolsBuilder;
+import org.drools.eclipse.wizard.project.NewDroolsProjectWizard;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.ui.IObjectActionDelegate;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class ConvertToDroolsProjectAction implements IObjectActionDelegate {
+
+    private IJavaProject project;
+    
+	public void setActivePart(IAction action, IWorkbenchPart targetPart) {
+	}
+
+	public void run(IAction action) {
+		if (project != null && project.exists()) {
+			try {
+				addDroolsBuilder(project, null);
+				addDroolsLibraries(project, null);
+			} catch (Throwable t) {
+				DroolsEclipsePlugin.log(t);
+			}
+		}
+
+	}
+
+	public void selectionChanged(IAction action, ISelection selection) {
+		if (selection instanceof IStructuredSelection) {
+			IStructuredSelection structured = (IStructuredSelection) selection;
+			if (structured.size() == 1) {
+				Object element = structured.getFirstElement();
+				if (element instanceof IJavaProject) {
+					project = (IJavaProject) element;
+				} else if (element instanceof IProject) {
+					IJavaProject javaProject = JavaCore.create((IProject) element);
+					if (javaProject != null && javaProject.exists()) {
+						project = javaProject;
+					}
+				}
+			}
+		}
+	}
+	
+    public static void addDroolsBuilder(IJavaProject project, IProgressMonitor monitor) throws CoreException {
+        IProjectDescription description = project.getProject().getDescription();
+        // check whether Drools builder is already part of the project
+        ICommand[] commands = description.getBuildSpec();
+        for (int i = 0; i < commands.length; i++) {
+        	if (DroolsBuilder.BUILDER_ID.equals(commands[i].getBuilderName())) {
+        		return;
+        	}
+        }
+        // add Drools builder
+        ICommand[] newCommands = new ICommand[commands.length + 1];
+        System.arraycopy(commands, 0, newCommands, 0, commands.length);
+
+        ICommand droolsCommand = description.newCommand();
+        droolsCommand.setBuilderName(DroolsBuilder.BUILDER_ID);
+        newCommands[commands.length] = droolsCommand;
+        
+        description.setBuildSpec(newCommands);
+        project.getProject().setDescription(description, monitor);
+    }
+    
+    public static void addDroolsLibraries(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
+    	IClasspathEntry[] classpathEntries = project.getRawClasspath();
+    	for (int i = 0; i < classpathEntries.length; i++) {
+    		if (NewDroolsProjectWizard.DROOLS_CLASSPATH_CONTAINER_PATH.equals(classpathEntries[i].getPath().toString())) {
+    			return;
+    		}
+    	}
+		NewDroolsProjectWizard.addDroolsLibraries(project, null);
+    }
+            
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuildMarker.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuildMarker.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuildMarker.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.builder;
+
+public class DroolsBuildMarker {
+
+	private String text;
+	private int line = -1;
+	private int offset = -1;
+	private int length = -1;
+	
+	public DroolsBuildMarker(String text) {
+		this.text = text;
+	}
+	
+	public DroolsBuildMarker(String text, int line) {
+		this.text = text;
+		this.line = line;
+	}
+
+	public DroolsBuildMarker(String text, int offset, int length) {
+		this.text = text;
+		this.offset = offset;
+		this.length = length;
+	}
+
+	public int getLength() {
+		return length;
+	}
+
+	public int getLine() {
+		return line;
+	}
+
+	public int getOffset() {
+		return offset;
+	}
+
+	public String getText() {
+		return text;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuilder.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuilder.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/DroolsBuilder.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,444 @@
+package org.drools.eclipse.builder;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.antlr.runtime.RecognitionException;
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.brms.server.util.BRDRLPersistence;
+import org.drools.brms.server.util.BRXMLPersistence;
+import org.drools.commons.jci.problems.CompilationProblem;
+import org.drools.compiler.DroolsError;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.FactTemplateError;
+import org.drools.compiler.FieldTemplateError;
+import org.drools.compiler.FunctionError;
+import org.drools.compiler.GlobalError;
+import org.drools.compiler.ImportError;
+import org.drools.compiler.PackageBuilder;
+import org.drools.compiler.ParserError;
+import org.drools.compiler.ProcessBuilder;
+import org.drools.compiler.RuleError;
+import org.drools.decisiontable.InputType;
+import org.drools.decisiontable.SpreadsheetCompiler;
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper;
+import org.drools.eclipse.preferences.IDroolsConstants;
+import org.drools.lang.ExpanderException;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Automatically syntax checks .drl files and adds possible
+ * errors or warnings to the problem list. Nominally is triggerd on save.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DroolsBuilder extends IncrementalProjectBuilder {
+
+    public static final String BUILDER_ID = "org.drools.eclipse.droolsbuilder";
+
+    protected IProject[] build(int kind, Map args, IProgressMonitor monitor)
+            throws CoreException {
+        IProject currentProject = getProject();
+        if (currentProject == null || !currentProject.isAccessible()) {
+            return new IProject[0];
+        }
+        try {
+            if (monitor != null && monitor.isCanceled())
+                throw new OperationCanceledException();
+
+            if (kind == IncrementalProjectBuilder.FULL_BUILD) {
+                fullBuild(monitor);
+            } else {
+                IResourceDelta delta = getDelta(getProject());
+                if (delta == null) {
+                    fullBuild(monitor);
+                } else {
+                    incrementalBuild(delta, monitor);
+                }
+            }
+        } catch (CoreException e) {
+            IMarker marker = currentProject.createMarker(IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER);
+            marker.setAttribute(IMarker.MESSAGE, "Error when trying to build Drools project: " + e.getLocalizedMessage());
+            marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+        }
+        return getRequiredProjects(currentProject);
+    }
+    
+    protected void fullBuild(IProgressMonitor monitor)
+            throws CoreException {
+        getProject().accept(new DroolsBuildVisitor());
+    }
+    
+    protected void incrementalBuild(IResourceDelta delta,
+            IProgressMonitor monitor) throws CoreException {
+    	boolean buildAll = DroolsEclipsePlugin.getDefault().getPreferenceStore().getBoolean(IDroolsConstants.BUILD_ALL);
+        if (buildAll) {
+        	// to make sure that all rules are checked when a java file is changed 
+        	fullBuild(monitor);
+        } else {
+        	delta.accept(new DroolsBuildDeltaVisitor());
+        }
+    }
+
+    private class DroolsBuildVisitor implements IResourceVisitor {
+        public boolean visit(IResource res) {
+            return parseResource(res, true);
+        }
+    }
+
+    private class DroolsBuildDeltaVisitor implements IResourceDeltaVisitor {
+        public boolean visit(IResourceDelta delta) throws CoreException {
+            return parseResource(delta.getResource(), false);
+        }
+    }
+    
+    private boolean parseResource(IResource res, boolean clean) {
+        try {
+            IJavaProject project = JavaCore.create(res.getProject());
+            // exclude files that are located in the output directory,
+            // unless the ouput directory is the same as the project location
+            if (!project.getOutputLocation().equals(project.getPath())
+                    && project.getOutputLocation().isPrefixOf(res.getFullPath())) {
+                return false;
+            }
+        } catch (JavaModelException e) {
+            // do nothing
+        }
+
+        if (res instanceof IFile
+        		&& ("drl".equals(res.getFileExtension())
+    				|| "dslr".equals(res.getFileExtension())
+    				|| ".package".equals(res.getName()))) {
+            removeProblemsFor(res);
+            try {
+            	if (clean) {
+            		DroolsEclipsePlugin.getDefault().invalidateResource(res);
+            	}
+            	DroolsBuildMarker[] markers = parseDRLFile((IFile) res, new String(Util.getResourceContentsAsCharArray((IFile) res)));
+		        for (int i = 0; i < markers.length; i++) {
+		        	createMarker(res, markers[i].getText(), markers[i].getLine());
+		        }
+            } catch (Throwable t) {
+            	createMarker(res, t.getMessage(), -1);
+            }
+            return false;
+        } else if (res instanceof IFile && "xls".equals(res.getFileExtension())) {
+            removeProblemsFor(res);
+            try {
+            	if (clean) {
+            		DroolsEclipsePlugin.getDefault().invalidateResource(res);
+            	}
+            	DroolsBuildMarker[] markers = parseXLSFile((IFile) res);
+		        for (int i = 0; i < markers.length; i++) {
+		        	createMarker(res, markers[i].getText(), markers[i].getLine());
+		        }
+            } catch (Throwable t) {
+            	createMarker(res, t.getMessage(), -1);
+            }
+            return false;
+        } else if (res instanceof IFile && "brl".equals(res.getFileExtension())) {
+            removeProblemsFor(res);
+            try {
+            	if (clean) {
+            		DroolsEclipsePlugin.getDefault().invalidateResource(res);
+            	}
+            	DroolsBuildMarker[] markers = parseBRLFile((IFile) res);
+		        for (int i = 0; i < markers.length; i++) {
+		        	createMarker(res, markers[i].getText(), markers[i].getLine());
+		        }
+            } catch (Throwable t) {
+            	createMarker(res, t.getMessage(), -1);
+            }
+            return false;
+        } else if (res instanceof IFile && "rf".equals(res.getFileExtension())) {
+            removeProblemsFor(res);
+            try {
+            	if (clean) {
+            		DroolsEclipsePlugin.getDefault().invalidateResource(res);
+            	}
+            	DroolsBuildMarker[] markers = parseRuleFlowFile((IFile) res);
+		        for (int i = 0; i < markers.length; i++) {
+		        	createMarker(res, markers[i].getText(), markers[i].getLine());
+		        }
+            } catch (Throwable t) {
+            	createMarker(res, t.getMessage(), -1);
+            }
+            return false;
+        }
+
+        return true;
+    }
+    
+    private DroolsBuildMarker[] parseDRLFile(IFile file, String content) {
+    	List markers = new ArrayList();
+		try {
+            DRLInfo drlInfo =
+            	DroolsEclipsePlugin.getDefault().parseResource(file, true);
+            //parser errors
+            markParseErrors(markers, drlInfo.getParserErrors());  
+            markOtherErrors(markers, drlInfo.getBuilderErrors());
+        } catch (DroolsParserException e) {
+            // we have an error thrown from DrlParser
+            Throwable cause = e.getCause();
+            if (cause instanceof RecognitionException ) {
+                RecognitionException recogErr = (RecognitionException) cause;
+                markers.add(new DroolsBuildMarker(recogErr.getMessage(), recogErr.line)); //flick back the line number
+            }
+        } catch (Exception t) {
+        	String message = t.getMessage();
+            if (message == null || message.trim().equals("")) {
+                message = "Error: " + t.getClass().getName();
+            }
+            markers.add(new DroolsBuildMarker(message));
+        }
+        return (DroolsBuildMarker[]) markers.toArray(new DroolsBuildMarker[markers.size()]);
+    }
+
+    private DroolsBuildMarker[] parseXLSFile(IFile file) {
+    	List markers = new ArrayList();
+		try {
+			SpreadsheetCompiler converter = new SpreadsheetCompiler();
+	        String drl = converter.compile(file.getContents(), InputType.XLS);
+	        DRLInfo drlInfo =
+            	DroolsEclipsePlugin.getDefault().parseXLSResource(drl, file);
+            // parser errors
+            markParseErrors(markers, drlInfo.getParserErrors());  
+            markOtherErrors(markers, drlInfo.getBuilderErrors());
+        } catch (DroolsParserException e) {
+            // we have an error thrown from DrlParser
+            Throwable cause = e.getCause();
+            if (cause instanceof RecognitionException ) {
+                RecognitionException recogErr = (RecognitionException) cause;
+                markers.add(new DroolsBuildMarker(recogErr.getMessage(), recogErr.line)); //flick back the line number
+            }
+        } catch (Exception t) {
+        	String message = t.getMessage();
+            if (message == null || message.trim().equals( "" )) {
+                message = "Error: " + t.getClass().getName();
+            }
+            markers.add(new DroolsBuildMarker(message));
+        }
+        return (DroolsBuildMarker[]) markers.toArray(new DroolsBuildMarker[markers.size()]);
+    }
+
+    private DroolsBuildMarker[] parseBRLFile(IFile file) {
+    	List markers = new ArrayList();
+		try {
+			String brl = convertToString(file.getContents());
+			RuleModel model = BRXMLPersistence.getInstance().unmarshal(brl);
+			String drl = BRDRLPersistence.getInstance().marshal(model);
+			
+			// TODO pass this through DSL converter in case brl is based on dsl
+			
+	        DRLInfo drlInfo =
+            	DroolsEclipsePlugin.getDefault().parseBRLResource(drl, file);
+            // parser errors
+            markParseErrors(markers, drlInfo.getParserErrors());  
+            markOtherErrors(markers, drlInfo.getBuilderErrors());
+        } catch (DroolsParserException e) {
+            // we have an error thrown from DrlParser
+            Throwable cause = e.getCause();
+            if (cause instanceof RecognitionException ) {
+                RecognitionException recogErr = (RecognitionException) cause;
+                markers.add(new DroolsBuildMarker(recogErr.getMessage(), recogErr.line)); //flick back the line number
+            }
+        } catch (Exception t) {
+        	String message = t.getMessage();
+            if (message == null || message.trim().equals( "" )) {
+                message = "Error: " + t.getClass().getName();
+            }
+            markers.add(new DroolsBuildMarker(message));
+        }
+        return (DroolsBuildMarker[]) markers.toArray(new DroolsBuildMarker[markers.size()]);
+    }
+    
+    private DroolsBuildMarker[] parseRuleFlowFile(IFile file) {
+    	List markers = new ArrayList();
+		try {
+			String ruleflow = convertToString(file.getContents());
+			XStream stream = new XStream();
+	        stream.setMode(XStream.ID_REFERENCES);
+	        
+	        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+	        ClassLoader newLoader = this.getClass().getClassLoader();
+	        try {
+	            Thread.currentThread().setContextClassLoader(newLoader);
+	            Object o = stream.fromXML(ruleflow);
+	            if (o instanceof RuleFlowProcessWrapper) {
+	            	ProcessBuilder processBuilder = new ProcessBuilder(new PackageBuilder());
+	            	processBuilder.addProcess(((RuleFlowProcessWrapper) o).getRuleFlowProcess());
+	            	markParseErrors(markers, processBuilder.getErrors());
+	            }
+	        } finally {
+	            Thread.currentThread().setContextClassLoader(oldLoader);
+	        }			
+        } catch (Exception t) {
+        	String message = t.getMessage();
+            if (message == null || message.trim().equals( "" )) {
+                message = "Error: " + t.getClass().getName();
+            }
+            markers.add(new DroolsBuildMarker(message));
+        }
+        return (DroolsBuildMarker[]) markers.toArray(new DroolsBuildMarker[markers.size()]);
+    }
+    
+    private static String convertToString(final InputStream inputStream) throws IOException {
+    	Reader reader = new InputStreamReader(inputStream);
+    	final StringBuffer text = new StringBuffer();
+        final char[] buf = new char[1024];
+        int len = 0;
+        while ((len = reader.read(buf)) >= 0) {
+            text.append(buf, 0, len);
+        }
+        return text.toString();
+    }
+
+    /**
+     * This will create markers for parse errors.
+     * Parse errors mean that antlr has picked up some major typos in the input source.
+     */
+    private void markParseErrors(List markers, List parserErrors) {
+        for ( Iterator iter = parserErrors.iterator(); iter.hasNext(); ) {
+        	Object error = iter.next();
+        	if (error instanceof ParserError) {
+        		ParserError err = (ParserError) error;
+        		markers.add(new DroolsBuildMarker(err.getMessage(), err.getRow()));
+        	} else if (error instanceof ExpanderException) {
+        		ExpanderException exc = (ExpanderException) error;
+        		// TODO line mapping is incorrect
+        		markers.add(new DroolsBuildMarker(exc.getMessage(), -1));
+        	} else {
+        		markers.add(new DroolsBuildMarker(error.toString()));
+        	}
+        }
+    }
+
+    /**
+     * This will create markers for build errors that happen AFTER parsing.
+     */
+    private void markOtherErrors(List markers,
+                                        DroolsError[] buildErrors) {
+        // TODO are there warnings too?
+        for (int i = 0; i < buildErrors.length; i++ ) {
+        	DroolsError error = buildErrors[i];
+        	if (error instanceof GlobalError) {
+        		GlobalError globalError = (GlobalError) error;
+        		markers.add(new DroolsBuildMarker(globalError.getGlobal(), -1));
+        	} else if (error instanceof RuleError) {
+        		RuleError ruleError = (RuleError) error;
+        		// TODO try to retrieve line number (or even character start-end)
+        		// disabled for now because line number are those of the rule class,
+        		// not the rule file itself
+        		if (ruleError.getObject() instanceof CompilationProblem[]) {
+        			CompilationProblem[] problems = (CompilationProblem[]) ruleError.getObject();
+        			for (int j = 0; j < problems.length; j++) {
+        				markers.add(new DroolsBuildMarker(problems[j].getMessage(), ruleError.getLine()));
+        			}
+        		} else {
+        			markers.add(new DroolsBuildMarker(ruleError.getRule().getName() + ":" + ruleError.getMessage(), ruleError.getLine()));
+        		}
+        	} else if (error instanceof ParserError) {
+        		ParserError parserError = (ParserError) error;
+        		// TODO try to retrieve character start-end
+        		markers.add(new DroolsBuildMarker(parserError.getMessage(), parserError.getRow()));
+        	} else if (error instanceof FunctionError) {
+        		FunctionError functionError = (FunctionError) error;
+        		// TODO add line to function error
+        		// TODO try to retrieve character start-end
+        		if (functionError.getObject() instanceof CompilationProblem[]) {
+        			CompilationProblem[] problems = (CompilationProblem[]) functionError.getObject();
+        			for (int j = 0; j < problems.length; j++) {
+        				markers.add(new DroolsBuildMarker(problems[j].getMessage(), functionError.getErrorLines()[j]));
+        			}
+        		} else {
+        			markers.add(new DroolsBuildMarker(functionError.getFunctionDescr().getName() + ":" + functionError.getMessage(), -1));
+        		}
+        	} else if (error instanceof FieldTemplateError) {
+        		markers.add(new DroolsBuildMarker(error.getMessage(), ((FieldTemplateError) error).getLine()));
+        	} else if (error instanceof FactTemplateError) {
+        		markers.add(new DroolsBuildMarker(error.getMessage(), ((FactTemplateError) error).getLine()));
+        	} else if (error instanceof ImportError) {
+        		markers.add(new DroolsBuildMarker("ImportError: " + error.getMessage()));
+        	} else {
+        		markers.add(new DroolsBuildMarker("Unknown DroolsError " + error.getClass() + ": " + error));
+        	}
+        }
+    }
+
+    private void createMarker(final IResource res, final String message, final int lineNumber) {
+        try {
+        	IWorkspaceRunnable r= new IWorkspaceRunnable() {
+        		public void run(IProgressMonitor monitor) throws CoreException {
+            		IMarker marker = res
+                    	.createMarker(IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER);
+		            marker.setAttribute(IMarker.MESSAGE, message);
+		            marker.setAttribute(IMarker.SEVERITY,
+		                    IMarker.SEVERITY_ERROR);
+		            marker.setAttribute(IMarker.LINE_NUMBER, lineNumber);
+	    		}
+			};
+			res.getWorkspace().run(r, null, IWorkspace.AVOID_UPDATE, null);
+        } catch (CoreException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+    }
+    
+    private void removeProblemsFor(IResource resource) {
+        try {
+            if (resource != null && resource.exists()) {
+                resource.deleteMarkers(
+                        IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER, false,
+                        IResource.DEPTH_INFINITE);
+            }
+        } catch (CoreException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+    }
+    
+    private IProject[] getRequiredProjects(IProject project) {
+    	IJavaProject javaProject = JavaCore.create(project);
+    	List projects = new ArrayList();
+    	try {
+    		IClasspathEntry[] entries = javaProject.getResolvedClasspath(true);
+    		for (int i = 0, l = entries.length; i < l; i++) {
+    			IClasspathEntry entry = entries[i];
+    			if (entry.getEntryKind() == IClasspathEntry.CPE_PROJECT) {
+					IProject p = project.getWorkspace().getRoot().getProject(entry.getPath().lastSegment()); // missing projects are considered too
+	    			if (p != null && !projects.contains(p)) {
+	    				projects.add(p);
+	    			}
+    			}
+    		}
+    	} catch(JavaModelException e) {
+    		return new IProject[0];
+    	}
+    	return (IProject[]) projects.toArray(new IProject[projects.size()]);
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/IDroolsModelMarker.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/IDroolsModelMarker.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/IDroolsModelMarker.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,15 @@
+package org.drools.eclipse.builder;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+
+/**
+ * The drools problem marker id.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public interface IDroolsModelMarker {
+
+    public static final String DROOLS_MODEL_PROBLEM_MARKER = DroolsEclipsePlugin.PLUGIN_ID
+            + ".problem";
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/Util.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/Util.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/builder/Util.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,108 @@
+package org.drools.eclipse.builder;
+
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+
+/**
+ * Utility class.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Util {
+
+    public static final char[] NO_CHAR = new char[0];
+    private static final int DEFAULT_READING_SIZE = 8192;
+    
+    public static char[] getResourceContentsAsCharArray(IFile file) throws CoreException {
+        String encoding = null;
+        try {
+            encoding = file.getCharset();
+        }
+        catch(CoreException ce) {
+            // do not use any encoding
+        }
+        
+        InputStream stream= null;
+        stream = new BufferedInputStream(file.getContents(true));
+        try {
+            return getInputStreamAsCharArray(stream, -1, encoding);
+        } catch (IOException e) {
+            throw new CoreException(new Status(IStatus.ERROR, DroolsEclipsePlugin.PLUGIN_ID, IStatus.ERROR, "IOException", e));
+        } finally {
+            try {
+                stream.close();
+            } catch (IOException e) {
+                // ignore
+            }
+        }
+    }
+
+    private static char[] getInputStreamAsCharArray(InputStream stream,
+            int length, String encoding) throws IOException {
+        InputStreamReader reader = null;
+        reader = encoding == null ? new InputStreamReader(stream)
+                : new InputStreamReader(stream, encoding);
+        char[] contents;
+        if (length == -1) {
+            contents = NO_CHAR;
+            int contentsLength = 0;
+            int amountRead = -1;
+            do {
+                int amountRequested = Math.max(stream.available(),
+                        DEFAULT_READING_SIZE);
+                if (contentsLength + amountRequested > contents.length) {
+                    System.arraycopy(contents, 0,
+                            contents = new char[contentsLength
+                                    + amountRequested], 0, contentsLength);
+                }
+                amountRead = reader.read(contents, contentsLength,
+                        amountRequested);
+
+                if (amountRead > 0) {
+                    contentsLength += amountRead;
+                }
+            } while (amountRead != -1);
+
+            int start = 0;
+            if (contentsLength > 0 && "UTF-8".equals(encoding)) {
+                if (contents[0] == 0xFEFF) {
+                    contentsLength--;
+                    start = 1;
+                }
+            }
+            if (contentsLength < contents.length) {
+                System.arraycopy(contents, start,
+                        contents = new char[contentsLength], 0, contentsLength);
+            }
+        } else {
+            contents = new char[length];
+            int len = 0;
+            int readSize = 0;
+            while ((readSize != -1) && (len != length)) {
+                len += readSize;
+                readSize = reader.read(contents, len, length - len);
+            }
+            int start = 0;
+            if (length > 0 && "UTF-8".equals(encoding)) {
+                if (contents[0] == 0xFEFF) {
+                    len--;
+                    start = 1;
+                }
+            }
+            if (len != length)
+                System.arraycopy(contents, start, (contents = new char[len]),
+                        0, len);
+        }
+
+        return contents;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsElement.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsElement.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsElement.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,66 @@
+package org.drools.eclipse.core;
+
+import org.eclipse.core.resources.IFile;
+
+/**
+ * This represents a drools model element.  It is linked to its direct
+ * parents and its children. If relevant, Drools model elements refer
+ * to the file they are defined in and the offset and length of that
+ * element in the file. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public abstract class DroolsElement {
+
+	public static final int RULESET = 0;
+	public static final int PACKAGE = 1;
+	public static final int RULE = 2;
+	public static final int QUERY = 3;
+	public static final int FUNCTION = 4;
+	public static final int TEMPLATE = 5;
+	public static final int EXPANDER = 6;
+	public static final int GLOBAL = 7;
+	public static final int IMPORT = 8;
+	public static final int RULE_ATTRIBUTE = 9;
+	
+	protected static final DroolsElement[] NO_ELEMENTS = new DroolsElement[0];
+	
+	private DroolsElement parent;
+	private IFile file;
+	private int offset;
+	private int length;
+	
+	protected DroolsElement(DroolsElement parent) {
+		this.parent = parent;
+	}
+	
+	public abstract int getType();
+	
+	public DroolsElement getParent() {
+		return parent;
+	}
+	
+	public abstract DroolsElement[] getChildren();
+
+	public IFile getFile() {
+		return file;
+	}
+	
+	public int getOffset() {
+		return offset;
+	}
+
+	public int getLength() {
+		return length;
+	}
+
+	// These are helper methods for creating the model and should not
+	// be used directly.  Use DroolsModelBuilder instead.
+
+	void setFile(IFile file, int offset, int length) {
+		this.file = file;
+		this.offset = offset;
+		this.length = length;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsModelBuilder.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsModelBuilder.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/DroolsModelBuilder.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,174 @@
+package org.drools.eclipse.core;
+
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.core.resources.IFile;
+
+public class DroolsModelBuilder {
+	
+	public static RuleSet createRuleSet() {
+		return new RuleSet();
+	}
+
+	public static Package createPackage(String packageName, int offset, int length) {
+		Package pkg = new Package(null, packageName);
+		pkg.setFile(null, offset, length);
+		return pkg;
+	}
+	
+	public static Package addPackage(RuleSet ruleSet, String packageName, int offset, int length) {
+		Package pkg = new Package(ruleSet, packageName);
+		pkg.setFile(null, offset, length);
+		ruleSet.addPackage(pkg);
+		return pkg;
+	}
+	
+	public static void removePackage(Package pkg) {
+		RuleSet ruleSet = pkg.getParentRuleSet();
+		if (ruleSet != null) {
+			ruleSet.removePackage(pkg.getPackageName());
+		}
+	}
+	
+	public static void clearRuleSet(RuleSet ruleSet) {
+		ruleSet.clear();
+	}
+	
+	public static Rule addRule(Package pkg, String ruleName, IFile file, int offset, int length, Map attributes) {
+		Rule rule = new Rule(pkg, ruleName);
+		rule.setFile(file, offset, length);
+		if (attributes != null) {
+			for (Iterator iterator = attributes.entrySet().iterator(); iterator.hasNext();) {
+				Map.Entry entry = (Map.Entry) iterator.next();
+				RuleAttribute attribute = new RuleAttribute(rule, (String) entry.getKey(), entry.getValue());
+				attribute.setFile(file, offset, length);
+				rule.addAttribute(attribute);
+			}
+		}
+		pkg.addRule(rule);
+		return rule;
+	}
+	
+	public static void removeRule(Rule rule) {
+		Package pkg = rule.getParentPackage();
+		if (pkg != null) {
+			pkg.removeRule(rule);
+			if (pkg.getChildren().length == 0) {
+				removePackage(pkg);
+			}
+		}
+	}
+
+	public static Function addFunction(Package pkg, String functionName, IFile file, int offset, int length) {
+		Function function = new Function(pkg, functionName);
+		function.setFile(file, offset, length);
+		pkg.addFunction(function);
+		return function;
+	}
+
+	public static void removeFunction(Function function) {
+		Package pkg = function.getParentPackage();
+		if (pkg != null) {
+			pkg.removeFunction(function);
+		}
+	}
+
+	public static void addExpander(Package pkg, String expanderName, IFile file, int offset, int length) {
+		Expander expander = new Expander(pkg, expanderName);
+		expander.setFile(file, offset, length);
+		pkg.addExpander(expander);
+	}
+
+	public static void removeExpander(Expander expander) {
+		Package pkg = expander.getParentPackage();
+		if (pkg != null) {
+			pkg.removeExpander(expander);
+		}
+	}
+
+	public static void addImport(Package pkg, String importClass, IFile file, int offset, int length) {
+		Import imp = new Import(pkg, importClass);
+		imp.setFile(file, offset, length);
+		pkg.addImport(imp);
+	}
+
+	public static void removeImport(Import imp) {
+		Package pkg = imp.getParentPackage();
+		if (pkg != null) {
+			pkg.removeImport(imp);
+		}
+	}
+
+	public static Global addGlobal(Package pkg, String globalName, IFile file, int offset, int length) {
+		Global global = new Global(pkg, globalName);
+		global.setFile(file, offset, length);
+		pkg.addGlobal(global);
+		return global;
+	}
+
+	public static void removeGlobal(Global global) {
+		Package pkg = global.getParentPackage();
+		if (pkg != null) {
+			pkg.removeGlobal(global);
+		}
+	}
+
+	public static Query addQuery(Package pkg, String queryName, IFile file, int offset, int length) {
+		Query query = new Query(pkg, queryName);
+		query.setFile(file, offset, length);
+		pkg.addQuery(query);
+		return query;
+	}
+
+	public static void removeQuery(Query query) {
+		Package pkg = query.getParentPackage();
+		if (pkg != null) {
+			pkg.removeQuery(query);
+		}
+	}
+
+	public static Template addTemplate(Package pkg, String templateName, IFile file, int offset, int length) {
+		Template template = new Template(pkg, templateName);
+		template.setFile(file, offset, length);
+		pkg.addTemplate(template);
+		return template;
+	}
+
+	public static void removeTemplate(Template template) {
+		Package pkg = template.getParentPackage();
+		if (pkg != null) {
+			pkg.removeTemplate(template);
+		}
+	}
+	
+	public static void removeElement(DroolsElement element) {
+		switch (element.getType()) {
+			case DroolsElement.RULESET:
+				clearRuleSet((RuleSet) element);
+				break;
+			case DroolsElement.PACKAGE:
+				removePackage((Package) element);
+				break;
+			case DroolsElement.RULE:
+				removeRule((Rule) element);
+				break;
+			case DroolsElement.QUERY:
+				removeQuery((Query) element);
+				break;
+			case DroolsElement.FUNCTION:
+				removeFunction((Function) element);
+				break;
+			case DroolsElement.TEMPLATE:
+				removeTemplate((Template) element);
+				break;
+			case DroolsElement.EXPANDER:
+				removeExpander((Expander) element);
+				break;
+			case DroolsElement.GLOBAL:
+				removeGlobal((Global) element);
+				break;
+		}
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Expander.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Expander.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Expander.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents an expander. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Expander extends DroolsElement {
+
+	private final String expander;
+
+	Expander(Package parent, String expander) {
+		super(parent);
+		this.expander = expander;
+	}
+	
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+	public String getExpander() {
+		return expander;
+	}
+
+	public int getType() {
+		return EXPANDER;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return expander;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Function.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Function.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Function.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents a function. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Function extends DroolsElement {
+
+    private final String functionName;
+
+    Function(Package parent, String functionName) {
+        super(parent);
+        this.functionName = functionName;
+    }
+    
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+    public String getFunctionName() {
+    	return functionName;
+    }
+
+	public int getType() {
+		return FUNCTION;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return functionName;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Global.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Global.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Global.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents a global. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Global extends DroolsElement {
+
+    private final String globalName;
+
+    Global(Package parent, String globalName) {
+        super(parent);
+        this.globalName = globalName;
+    }
+    
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+    public String getGlobalName() {
+    	return globalName;
+    }
+
+	public int getType() {
+		return GLOBAL;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return globalName;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Import.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Import.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Import.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents an import. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Import extends DroolsElement {
+
+    private final String importClass;
+
+    Import(Package parent, String importClass) {
+        super(parent);
+        this.importClass = importClass;
+    }
+    
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+    public String getImportClass() {
+    	return importClass;
+    }
+
+	public int getType() {
+		return IMPORT;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return importClass;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Package.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Package.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Package.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,115 @@
+package org.drools.eclipse.core;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This represents a package. 
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class Package extends DroolsElement {
+
+	private String packageName;
+	private List rules = new ArrayList();
+	private List functions = new ArrayList();
+	private List expanders = new ArrayList();
+	private List imports = new ArrayList();
+	private List globals = new ArrayList();
+	private List queries = new ArrayList();
+	private List templates = new ArrayList();
+
+	Package(RuleSet parent, String packageName) {
+		super(parent);
+		this.packageName =
+			packageName == null ? "(default package)" : packageName;
+	}
+
+	public RuleSet getParentRuleSet() {
+		return (RuleSet) getParent();
+	}
+	
+	public String getPackageName() {
+		return packageName;
+	}
+
+	public int getType() {
+		return PACKAGE;
+	}
+	
+	public DroolsElement[] getChildren() {
+		List children = new ArrayList();
+		children.addAll(rules);
+		children.addAll(queries);
+		children.addAll(globals);
+		children.addAll(functions);
+		children.addAll(expanders);
+		children.addAll(imports);
+		children.addAll(templates);
+		return (DroolsElement[]) children.toArray(new DroolsElement[0]);
+	}
+
+	public String toString() {
+		return packageName;
+	}
+
+	// These are helper methods for creating the model and should not
+	// be used directly.  Use DroolsModelBuilder instead.
+
+	void addRule(Rule rule) {
+		rules.add(rule);
+	}
+	
+	void removeRule(Rule rule) {
+		rules.remove(rule);
+	}
+	
+	void addFunction(Function function) {
+		functions.add(function);
+	}
+	
+	void removeFunction(Function function) {
+		functions.remove(function);
+	}
+	
+	void addExpander(Expander expander) {
+		expanders.add(expander);
+	}
+	
+	void removeExpander(Expander expander) {
+		expanders.remove(expander);
+	}
+	
+	void addImport(Import imp) {
+		imports.add(imp);
+	}
+	
+	void removeImport(Import imp) {
+		imports.remove(imp);
+	}
+	
+	void addGlobal(Global global) {
+		globals.add(global);
+	}
+	
+	void removeGlobal(Global global) {
+		globals.remove(global);
+	}
+	
+	void addQuery(Query query) {
+		queries.add(query);
+	}
+	
+	void removeQuery(Query query) {
+		queries.remove(query);
+	}
+	
+	void addTemplate(Template template) {
+		templates.add(template);
+	}
+	
+	void removeTemplate(Template template) {
+		templates.remove(template);
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Query.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Query.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Query.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents a query. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Query extends DroolsElement {
+
+    private final String query;
+
+    Query(Package parent, String query) {
+        super(parent);
+        this.query = query;
+    }
+
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+	public String getQueryName() {
+		return query;
+	}
+	
+	public int getType() {
+		return QUERY;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return query;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Rule.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Rule.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Rule.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,52 @@
+package org.drools.eclipse.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This represents a rule. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class Rule extends DroolsElement {
+
+    private final String ruleName;
+    private Map attributes = new HashMap();
+
+    Rule(Package parent, String ruleName) {
+    	super(parent);
+        this.ruleName = ruleName;
+    }
+
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+	public String getRuleName() {
+		return ruleName;
+	}
+	
+	public RuleAttribute getAttribute(String attributeName) {
+		return (RuleAttribute) attributes.get(attributeName);
+	}
+	
+	public int getType() {
+		return RULE;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return ruleName;
+	}
+
+	// These are helper methods for creating the model and should not
+	// be used directly.  Use DroolsModelBuilder instead.
+
+    void addAttribute(RuleAttribute attribute) {
+		attributes.put(attribute.getAttributeName(), attribute);
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleAttribute.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleAttribute.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleAttribute.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,39 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents a rule attribute. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class RuleAttribute extends DroolsElement {
+
+    private final String attributeName;
+    private final Object attributeValue;
+
+    RuleAttribute(Rule parent, String attributeName, Object attributeValue) {
+    	super(parent);
+        this.attributeName = attributeName;
+        this.attributeValue = attributeValue;
+    }
+
+	public Rule getParentRule() {
+		return (Rule) getParent();
+	}
+	
+	public String getAttributeName() {
+		return attributeName;
+	}
+	
+	public int getType() {
+		return RULE_ATTRIBUTE;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return attributeName + " = " + attributeValue;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleSet.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleSet.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/RuleSet.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,47 @@
+package org.drools.eclipse.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * This represents a rule set. 
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleSet extends DroolsElement {
+	
+	private Map packages = new HashMap();
+	
+	RuleSet() {
+		super(null);
+	}
+	
+	public Package getPackage(String packageName) {
+		return (Package) packages.get(packageName);
+	}
+	
+	public int getType() {
+		return RULESET;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return (DroolsElement[]) packages.values().toArray(
+			new DroolsElement[packages.size()]);
+	}
+
+	// These are helper methods for creating the model and should not
+	// be used directly.  Use DroolsModelBuilder instead.
+
+	void addPackage(Package pkg) {
+		packages.put(pkg.getPackageName(), pkg);
+	}
+	
+	void removePackage(String packageName) {
+		packages.remove(packageName);
+	}
+	
+	void clear() {
+		packages.clear();
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Template.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Template.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/Template.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.core;
+
+/**
+ * This represents a template. 
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class Template extends DroolsElement {
+
+    private final String templateName;
+
+    Template(Package parent, String templateName) {
+        super(parent);
+        this.templateName = templateName;
+    }
+
+	public Package getParentPackage() {
+		return (Package) getParent();
+	}
+	
+	public String getTemplateName() {
+		return templateName;
+	}
+	
+	public int getType() {
+		return TEMPLATE;
+	}
+	
+	public DroolsElement[] getChildren() {
+		return NO_ELEMENTS;
+	}
+
+	public String toString() {
+		return templateName;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,44 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.core.DroolsElement;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Content provider for Drools model elements. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DroolsContentProvider implements ITreeContentProvider {
+
+	public Object[] getChildren(Object parentElement) {
+		if (parentElement instanceof DroolsElement) {
+			return ((DroolsElement) parentElement).getChildren();
+		}
+		return new Object[0];
+	}
+
+	public Object getParent(Object element) {
+		if (element instanceof DroolsElement) {
+			return ((DroolsElement) element).getParent();
+		}
+		return null;
+	}
+
+	public boolean hasChildren(Object element) {
+        return getChildren(element).length > 0;
+	}
+
+	public Object[] getElements(Object inputElement) {
+        return getChildren(inputElement);
+	}
+
+	public void dispose() {
+        // do nothing
+	}
+
+	public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        // do nothing
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsFilter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsFilter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsFilter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.core.DroolsElement;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+
+/**
+ * Filter for the rules viewer.
+ */
+public class DroolsFilter extends ViewerFilter {
+
+	public static final int FILTER_RULES = 1;
+	public static final int FILTER_QUERIES = 2;
+	public static final int FILTER_FUNCTIONS = 4;
+	public static final int FILTER_TEMPLATES = 8;
+	public static final int FILTER_GLOBALS = 16;
+	
+	private int filterProperties;
+
+	public final void addFilter(int filter) {
+		filterProperties |= filter;
+	}
+
+	public final void removeFilter(int filter) {
+		filterProperties &= (-1 ^ filter);
+	}
+
+	public final boolean hasFilter(int filter) {
+		return (filterProperties & filter) != 0;
+	}
+	
+	public boolean isFilterProperty(Object element, Object property) {
+		return false;
+	}
+
+	public boolean select(Viewer viewer, Object parentElement, Object element) {
+		if (element instanceof DroolsElement) {
+			DroolsElement droolsElement = (DroolsElement) element;
+			int type = droolsElement.getType();
+			if (hasFilter(FILTER_RULES) && type == DroolsElement.RULE) {
+				return false;
+			}
+			if (hasFilter(FILTER_QUERIES) && type == DroolsElement.QUERY) {
+				return false;
+			}
+			if (hasFilter(FILTER_FUNCTIONS) && type == DroolsElement.FUNCTION) {
+				return false;
+			}
+			if (hasFilter(FILTER_TEMPLATES) && type == DroolsElement.TEMPLATE) {
+				return false;
+			}
+			if (hasFilter(FILTER_GLOBALS) && type == DroolsElement.GLOBAL) {
+				return false;
+			}
+		}			
+		return true;
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsLabelProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsLabelProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsLabelProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,31 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.core.DroolsElement;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+public class DroolsLabelProvider extends LabelProvider {
+
+	private static final String[] ICONS = new String[] {
+		DroolsPluginImages.PACKAGE,	// ruleset
+		DroolsPluginImages.PACKAGE,	// package
+		DroolsPluginImages.DROOLS, 	// rule
+		DroolsPluginImages.DROOLS, 	// query
+		DroolsPluginImages.METHOD, 	// function
+		DroolsPluginImages.CLASS, 	// template
+		DroolsPluginImages.DSL, 	// expander
+		DroolsPluginImages.GLOBAL, 	// global
+		DroolsPluginImages.IMPORT, 	// import
+		DroolsPluginImages.DROOLS, 	// rule attribute
+	};
+	
+    public Image getImage(Object element) {
+    	if (element instanceof DroolsElement) {
+    		String icon = ICONS[((DroolsElement) element).getType()];
+    		return DroolsPluginImages.getImageRegistry().get(icon);
+    	}
+        return null;
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsTreeSorter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsTreeSorter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/DroolsTreeSorter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,82 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.core.DroolsElement;
+import org.drools.eclipse.core.Expander;
+import org.drools.eclipse.core.Function;
+import org.drools.eclipse.core.Global;
+import org.drools.eclipse.core.Import;
+import org.drools.eclipse.core.Package;
+import org.drools.eclipse.core.Query;
+import org.drools.eclipse.core.Rule;
+import org.drools.eclipse.core.RuleAttribute;
+import org.drools.eclipse.core.RuleSet;
+import org.drools.eclipse.core.Template;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+public class DroolsTreeSorter extends ViewerSorter {
+	
+	// level 0
+	private static final int RULESET = 0;
+	
+	// level 1
+	private static final int PACKAGE = 1;
+	
+	// level 2
+	private static final int RULE = 2;
+	private static final int QUERY = 3;
+	private static final int FUNCTION = 4;
+	private static final int TEMPLATE = 5;
+	private static final int EXPANDER = 6;
+	private static final int GLOBAL = 7;
+	private static final int IMPORT = 8;
+
+	// level 3
+	private static final int RULE_ATTRIBUTE = 9;
+	
+	private static final int UNKNOWN = 10;
+
+	private static DroolsLabelProvider labelProvider = new DroolsLabelProvider();
+
+	public int compare(Viewer viewer, Object e1, Object e2) {
+		DroolsElement node1 = (DroolsElement) e1;
+		DroolsElement node2 = (DroolsElement) e2;
+		int type1 = getElementType(node1);
+		int type2 = getElementType(node2);
+		if (type1 != type2) {
+			return type1 - type2;
+		}
+		String label1 = labelProvider.getText(node1); 
+		String label2 = labelProvider.getText(node2);
+		if (label1 == null) {
+			return (label2 == null ? 0 : -1);
+		}
+		return label1.compareTo(label2);
+	}
+	
+	private int getElementType(DroolsElement o) {
+		if (o instanceof RuleSet) {
+			return RULESET;
+		} else if (o instanceof Package) {
+			return PACKAGE;
+		} else if (o instanceof Rule) {
+			return RULE;
+		} else if (o instanceof Query) {
+			return QUERY;
+		} else if (o instanceof Function) {
+			return FUNCTION;
+		} else if (o instanceof Template) {
+			return TEMPLATE;
+		} else if (o instanceof Expander) {
+			return EXPANDER;
+		} else if (o instanceof Global) {
+			return GLOBAL;
+		} else if (o instanceof Import) {
+			return IMPORT;
+		} else if (o instanceof RuleAttribute) {
+			return RULE_ATTRIBUTE;
+		}
+		return UNKNOWN;
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,34 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.DroolsPluginImages;
+import org.eclipse.jface.action.Action;
+
+/**
+ * Action used to enable / disable filter properties
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class FilterAction extends Action {
+
+	private int filterType;
+
+	private FilterActionGroup filterActionGroup;
+
+	public FilterAction(FilterActionGroup actionGroup, String title,
+			int property, boolean initValue, String imageDescriptorKey) {
+		super(title);
+		filterActionGroup = actionGroup;
+		filterType = property;
+		setChecked(initValue);
+		setImageDescriptor(DroolsPluginImages.getImageDescriptor(imageDescriptorKey));
+	}
+
+	public int getFilterType() {
+		return filterType;
+	}
+
+	public void run() {
+		filterActionGroup.setFilter(filterType, isChecked());
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterActionGroup.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterActionGroup.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/core/ui/FilterActionGroup.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,112 @@
+package org.drools.eclipse.core.ui;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.util.Assert;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.actions.ActionGroup;
+
+/**
+ * Action Group that contributes filter buttons.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class FilterActionGroup extends ActionGroup {
+
+	private FilterAction[] filterActions;
+	private DroolsFilter filter;
+	public int i;
+	
+	private StructuredViewer viewer;
+	private String viewerId;
+	
+	public FilterActionGroup(StructuredViewer viewer, String viewerId) {	
+		this.viewer = viewer;
+		this.viewerId = viewerId;
+		filter = new DroolsFilter();
+		filterActions = new FilterAction[] {
+			addFilterForType(DroolsFilter.FILTER_RULES, "Hide Rules", DroolsPluginImages.RULE),
+			addFilterForType(DroolsFilter.FILTER_QUERIES, "Hide Queries", DroolsPluginImages.QUERY),
+			addFilterForType(DroolsFilter.FILTER_FUNCTIONS, "Hide Functions", DroolsPluginImages.METHOD),
+			addFilterForType(DroolsFilter.FILTER_GLOBALS, "Hide Globals", DroolsPluginImages.GLOBAL),
+			addFilterForType(DroolsFilter.FILTER_TEMPLATES, "Hide Templates", DroolsPluginImages.CLASS),
+		};
+		viewer.addFilter(filter);
+	}
+	
+	private FilterAction addFilterForType(int filterType, String tooltip, String imageDescriptorKey) {
+		boolean filterEnabled = DroolsEclipsePlugin.getDefault()
+			.getPreferenceStore().getBoolean(getPreferenceKey(filterType));
+		if (filterEnabled) {
+			filter.addFilter(filterType);
+		}
+		FilterAction hideAction = new FilterAction(this, tooltip, filterType, filterEnabled, imageDescriptorKey);
+		hideAction.setToolTipText(tooltip);
+		return hideAction;
+	}
+	
+	private String getPreferenceKey(int filterProperty) {
+		return "DroolsFilterActionGroup." + viewerId + '.' + String.valueOf(filterProperty);
+	}
+	
+	public void setFilter(int filterType, boolean set) {
+		setDroolsFilters(new int[] {filterType}, new boolean[] {set}, true);
+	}
+
+	private void setDroolsFilters(int[] propertyKeys, boolean[] propertyValues, boolean refresh) {
+		if (propertyKeys.length == 0)
+			return;
+		Assert.isTrue(propertyKeys.length == propertyValues.length);
+		
+		for (int i= 0; i < propertyKeys.length; i++) {
+			int filterProperty= propertyKeys[i];
+			boolean set= propertyValues[i];
+
+			IPreferenceStore store = DroolsEclipsePlugin.getDefault().getPreferenceStore();
+			boolean found = false;
+			for (int j= 0; j < filterActions.length; j++) {
+				int currProperty= filterActions[j].getFilterType();
+				if (currProperty == filterProperty) {
+					filterActions[j].setChecked(set);
+					found= true;
+					store.setValue(getPreferenceKey(filterProperty), set);
+				}
+			}
+			if (found) {
+				if (set) {
+					filter.addFilter(filterProperty);
+				} else {
+					filter.removeFilter(filterProperty);
+				}
+			}
+		}
+		if (refresh) {
+			viewer.getControl().setRedraw(false);
+			BusyIndicator.showWhile(viewer.getControl().getDisplay(), new Runnable() {
+				public void run() {
+					viewer.refresh();
+				}
+			});
+			viewer.getControl().setRedraw(true);
+		}
+	}
+	
+	public boolean hasDroolsFilter(int filterType) {
+		return filter.hasFilter(filterType);
+	}
+	
+	public void fillActionBars(IActionBars actionBars) {
+		contributeToToolBar(actionBars.getToolBarManager());
+	}
+	
+	public void contributeToToolBar(IToolBarManager tbm) {
+		for (int i= 0; i < filterActions.length; i++) {
+			tbm.add(filterActions[i]);
+		}
+	}
+	
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaLogicalStructureDelegate.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaLogicalStructureDelegate.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaLogicalStructureDelegate.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,81 @@
+package org.drools.eclipse.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.ILogicalStructureTypeDelegate;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaArray;
+import org.eclipse.jdt.debug.core.IJavaClassType;
+import org.eclipse.jdt.debug.core.IJavaInterfaceType;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+
+/**
+ * The logical structures of Agenda.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class AgendaLogicalStructureDelegate implements ILogicalStructureTypeDelegate {
+
+    public boolean providesLogicalStructure(IValue value) {
+        if (!(value instanceof IJavaObject)) {
+            return false;
+        }
+        IJavaObject javaValue= (IJavaObject) value;
+        try {
+            IJavaType type= javaValue.getJavaType();
+            if (!(type instanceof IJavaClassType)) {
+                return false;
+            }
+            IJavaClassType classType = (IJavaClassType) type;
+            IJavaInterfaceType[] interfaceTypes = classType.getAllInterfaces();
+            for ( int i = 0; i < interfaceTypes.length; i++ ) {
+                if ("org.drools.spi.Activation".equals(interfaceTypes[i].getName())) {
+                    return true;
+                }                
+            }
+            return false;
+        } catch (DebugException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+    }
+
+    public IValue getLogicalStructure(IValue value) throws CoreException {
+        if (!(value instanceof IJavaObject)) {
+            return null;
+        }
+        IJavaObject javaValue = (IJavaObject) value;
+        if (!providesLogicalStructure(value)) {
+            return null;
+        }
+        IJavaArray ruleParameters = (IJavaArray) DebugUtil.getValueByExpression("return getRule().getDeclarations();", value);
+        List variables = new ArrayList();
+        variables.add(new VariableWrapper("ruleName", (IJavaValue) DebugUtil.getValueByExpression("return getRule().getName();", value)));
+        
+        IJavaValue[] javaValues = ruleParameters.getValues();
+        for ( int j = 0; j < javaValues.length; j++ ) {
+            IJavaValue declaration = javaValues[j];
+            IVariable[] vars = declaration.getVariables();
+            for ( int k = 0; k < vars.length; k++ ) {
+                IVariable declarationVar = vars[k];
+                if ("identifier".equals(declarationVar.getName())) {
+                    String paramName = declarationVar.getValue().getValueString();
+                    IJavaValue varValue = (IJavaValue) DebugUtil.getValueByExpression("return getRule().getDeclaration(\"" + paramName + "\").getValue(((org.drools.common.InternalFactHandle) getTuple().get(getRule().getDeclaration(\"" + paramName + "\"))).getObject());", value);
+                    if (varValue != null) {
+                    	variables.add(new VariableWrapper(paramName, varValue));
+                    }
+                    break;
+                }                
+            }            
+        }
+        return new ObjectWrapper(javaValue, (IJavaVariable[]) variables.toArray(new IJavaVariable[variables.size()]));
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,19 @@
+package org.drools.eclipse.debug;
+
+import org.eclipse.jface.viewers.IContentProvider;
+
+/**
+ * The Agenda View.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class AgendaView extends DroolsDebugEventHandlerView {
+
+    protected IContentProvider createContentProvider() {
+        return new AgendaViewContentProvider(this);
+    }
+    
+    protected int getAutoExpandLevel() {
+    	return 1;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaViewContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaViewContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AgendaViewContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,205 @@
+package org.drools.eclipse.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaArray;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+
+/**
+ * The Agenda View content provider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class AgendaViewContentProvider extends DroolsDebugViewContentProvider {
+
+    private DroolsDebugEventHandlerView view;
+
+    public AgendaViewContentProvider(DroolsDebugEventHandlerView view) {
+        this.view = view;
+    }
+    
+    protected String getEmptyString() {
+    	return "The selected working memory has an empty agenda.";
+    }
+
+    public Object[] getChildren(Object obj) {
+        try {
+            Object[] variables = null;
+            if (obj != null && obj instanceof IJavaObject
+                    && "org.drools.reteoo.ReteooStatefulSession".equals(
+                        ((IJavaObject) obj).getReferenceTypeName())) {
+                variables = getAgendaElements((IJavaObject) obj);
+            } else if (obj instanceof IVariable) {
+            	if (view.isShowLogicalStructure()) {
+            		IValue value = getLogicalValue(((IVariable) obj).getValue(), new ArrayList());
+                	variables = value.getVariables();
+                }
+            	if (variables == null) {
+                	variables = ((IVariable) obj).getValue().getVariables();
+                }
+            }
+            if (variables == null) {
+                return new Object[0];
+            } else {
+                cache(obj, variables);
+                return variables;
+            }
+        } catch (DebugException e) {
+            DroolsEclipsePlugin.log(e);
+            return new Object[0];
+        }
+    }
+    
+    private Object[] getAgendaElements(IJavaObject workingMemoryImpl) throws DebugException {
+        List result = new ArrayList();
+        IValue agendaGroupObjects = DebugUtil.getValueByExpression("return getAgenda().getAgendaGroups();", workingMemoryImpl);
+        IValue focus = DebugUtil.getValueByExpression("return getAgenda().getFocus();", workingMemoryImpl);
+        if (agendaGroupObjects instanceof IJavaArray) {
+	        IJavaArray agendaGroupArray = (IJavaArray) agendaGroupObjects;
+	    	IJavaValue[] agendaGroupValueArray = agendaGroupArray.getValues();
+	        for (int i = 0; i < agendaGroupValueArray.length; i++) {
+	        	IJavaValue agendaGroup = agendaGroupValueArray[i];
+	        	String name = "";
+			    List activationsResult = new ArrayList();
+			    IVariable[] agendaGroupVarArray = agendaGroup.getVariables();
+	        	for (int j = 0; j < agendaGroupVarArray.length; j++) {
+	        		IVariable agendaGroupVar = agendaGroupVarArray[j];
+	        		if ("name".equals(agendaGroupVar.getName())) {
+	        			name = agendaGroupVar.getValue().getValueString();
+	        			break;
+	        		}
+	        	}
+				IJavaArray activations = (IJavaArray) DebugUtil.getValueByExpression("return getActivations();", agendaGroup);
+				IJavaValue[] activationArray = activations.getValues();
+	            for (int l = 0; l < activationArray.length; l++) {
+	            	IJavaValue activation = activationArray[l];
+	            	if (activation.getJavaType() != null) {
+	            		activationsResult.add(new VariableWrapper("[" + l + "]", 
+	            			new LazyActivationWrapper(activations, activation, workingMemoryImpl)));
+	            	}
+	            }
+	        	boolean active = false;
+            	if (agendaGroup.equals(focus)) {
+            		active = true;
+	            }
+            	// because the debug view does not handle spaces well, all spaces
+            	// in the agenda group name are replaced with '_'s.
+            	name = replaceSpaces(name);
+	            result.add(new MyVariableWrapper(name + "[" + (active ? "focus" : "nofocus") + "]", 
+            		new ObjectWrapper((IJavaObject) agendaGroup,
+        				(IJavaVariable[]) activationsResult.toArray(new IJavaVariable[activationsResult.size()]))));
+	        }
+        }
+        return result.toArray(new IVariable[0]);
+    }
+    
+    private String replaceSpaces(String name) {
+    	return name.replace(' ', '_');
+    }
+
+    private class LazyActivationWrapper extends ObjectWrapper {
+    	
+    	private IJavaValue activation;
+    	private IJavaValue workingMemoryImpl;
+    	
+    	public LazyActivationWrapper(IJavaObject object, IJavaValue activation, IJavaObject workingMemoryImpl) {
+    		super(object, null);
+    		this.activation = activation;
+    		this.workingMemoryImpl = workingMemoryImpl;
+    	}
+    	
+    	public IVariable[] getVariables() {
+    		IVariable[] result = super.getVariables();
+    		if (result == null) {
+    			try {
+	                List variables = new ArrayList();
+	                variables.add(new VariableWrapper("ruleName", (IJavaValue) DebugUtil.getValueByExpression("return getRule().getName();", activation)));
+	        		String activationId = null;
+				    IVariable[] activationVarArray = activation.getVariables();
+		        	for (int j = 0; j < activationVarArray.length; j++) {
+		        		IVariable activationVar = activationVarArray[j];
+		        		if ("activationNumber".equals(activationVar.getName())) {
+		        			activationId = activationVar.getValue().getValueString();
+		        			break;
+		        		}
+		        	}
+		        	if (activationId != null) {
+			        	IValue objects = DebugUtil.getValueByExpression("return getActivationParameters(" + activationId + ");", workingMemoryImpl);
+			        	if (objects instanceof IJavaArray) {
+			                IJavaArray array = (IJavaArray) objects;
+			                IJavaValue[] javaVals = array.getValues();
+			                for ( int k = 0; k < javaVals.length; k++ ) {
+			                    IJavaValue mapEntry = javaVals[k];
+			                    String key = null;
+			                    IJavaValue value = null;
+			                    
+			                    IVariable[] vars = mapEntry.getVariables();
+			                    for ( int j = 0; j < vars.length; j++ ) {
+			                        IVariable var = vars[j];
+			                        if ("key".equals(var.getName())) {
+			                            key = var.getValue().getValueString();
+			                        } else if ("value".equals(var.getName())) {
+			                            value = (IJavaValue) var.getValue();
+			                        }
+			                    }
+			                    variables.add(new VariableWrapper(key, value));
+			                }
+			                result = (IJavaVariable[]) variables.toArray(new IJavaVariable[variables.size()]);
+			        	}
+		        	}
+    			} catch (Throwable t) {
+    				DroolsEclipsePlugin.log(t);
+    			}
+        		if (result == null) {
+        			result = new IJavaVariable[0];
+        		}
+                setVariables((IJavaVariable[]) result);
+    		}
+    		return result;
+    	}
+    	
+    	public boolean hasVariables() {
+    		return true;
+    	}
+    	
+    	public String getValueString() throws DebugException {
+    		return "Activation";
+    	}
+    	
+    	public String getReferenceTypeName() throws DebugException {
+    		return "";
+    	}
+    }
+    
+    /**
+     * Special VariableWrapper that considers variables with the same name
+     * as equal.
+     */
+    private class MyVariableWrapper extends VariableWrapper {
+    	
+    	public MyVariableWrapper(String name, IJavaValue value) {
+    		super(name, value);
+    	}
+    	
+    	public boolean equals(Object obj) {
+            if (obj instanceof VariableWrapper) {
+                VariableWrapper var = (VariableWrapper) obj;
+                return var.getName().equals(getName());
+            }
+            return false;
+        }
+
+        public int hashCode() {
+            return getName().hashCode();
+        }
+    	
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,16 @@
+package org.drools.eclipse.debug;
+
+import org.eclipse.jface.viewers.IContentProvider;
+
+/**
+ * The Application Data View.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class ApplicationDataView extends DroolsDebugEventHandlerView {
+
+    protected IContentProvider createContentProvider() {
+        ApplicationDataViewContentProvider contentProvider = new ApplicationDataViewContentProvider(this);
+        return contentProvider;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataViewContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataViewContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ApplicationDataViewContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,85 @@
+package org.drools.eclipse.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaArray;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaValue;
+
+/**
+ * The Application Data View content provider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class ApplicationDataViewContentProvider extends DroolsDebugViewContentProvider {
+
+    private DroolsDebugEventHandlerView view;
+    
+    public ApplicationDataViewContentProvider(DroolsDebugEventHandlerView view) {
+        this.view = view;
+    }
+    
+    protected String getEmptyString() {
+    	return "The selected working memory has no globals defined.";
+    }
+
+    public Object[] getChildren(Object obj) {
+        try {
+            IVariable[] variables = null;
+            if (obj != null && obj instanceof IJavaObject
+                    && "org.drools.reteoo.ReteooStatefulSession".equals(
+                        ((IJavaObject) obj).getReferenceTypeName())) {
+                variables = getApplicationDataElements((IJavaObject) obj);
+            } else if (obj instanceof IVariable) {
+            	if (view.isShowLogicalStructure()) {
+            		IValue value = getLogicalValue(((IVariable) obj).getValue(), new ArrayList());
+                	variables = value.getVariables();
+                }
+            	if (variables == null) {
+                	variables = ((IVariable) obj).getValue().getVariables();
+                }
+            }
+            if (variables == null) {
+                return new Object[0];
+            } else {
+                cache(obj, variables);
+                return variables;
+            }
+        } catch (DebugException e) {
+            DroolsEclipsePlugin.log(e);
+            return new Object[0];
+        }
+    }
+    
+    private IVariable[] getApplicationDataElements(IJavaObject stackObj) throws DebugException {
+        IValue objects = DebugUtil.getValueByExpression("return ((org.drools.base.MapGlobalResolver) getGlobalResolver()).getGlobals();", stackObj);
+        if (objects instanceof IJavaArray) {
+            IJavaArray array = (IJavaArray) objects;
+            List result = new ArrayList();
+            IJavaValue[] javaVals = array.getValues();
+            for ( int i = 0; i < javaVals.length; i++ ) {
+                IJavaValue mapEntry = javaVals[i];
+                String key = null;
+                IJavaValue value = null;
+                
+                IVariable[] vars = mapEntry.getVariables();
+                for ( int j = 0; j < vars.length; j++ ) {
+                    IVariable var = vars[j];
+                    if ("key".equals(var.getName())) {
+                        key = var.getValue().getValueString();
+                    } else if ("value".equals(var.getName())) {
+                        value = (IJavaValue) var.getValue();
+                    }
+                }
+                result.add(new VariableWrapper(key, value));
+            }
+            return (IVariable[]) result.toArray(new IVariable[result.size()]);
+        }
+        return null;
+    }    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,441 @@
+package org.drools.eclipse.debug;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+import java.io.ObjectInputStream;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.audit.event.ActivationLogEvent;
+import org.drools.audit.event.LogEvent;
+import org.drools.audit.event.ObjectLogEvent;
+import org.drools.audit.event.RuleBaseLogEvent;
+import org.drools.audit.event.RuleFlowGroupLogEvent;
+import org.drools.audit.event.RuleFlowLogEvent;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.debug.actions.DeleteLogAction;
+import org.drools.eclipse.debug.actions.OpenLogAction;
+import org.drools.eclipse.debug.actions.RefreshLogAction;
+import org.drools.eclipse.debug.actions.ShowEventCauseAction;
+import org.eclipse.debug.ui.AbstractDebugView;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.PartInitException;
+
+import com.thoughtworks.xstream.XStream;
+
+public class AuditView extends AbstractDebugView {
+	
+	private static final String LOG_FILE_NAME = "LogFileName";
+	private static final String CAUSE_EVENT_COLOR = "CauseEventColor";
+	
+	private String logFileName;
+	private IAction deleteAction;
+	private IAction refreshAction;
+	
+    protected Viewer createViewer(Composite parent) {
+		final TreeViewer variablesViewer = new TreeViewer(parent);
+		variablesViewer.setContentProvider(new AuditViewContentProvider());
+        variablesViewer.setLabelProvider(new AuditLabelProvider());
+        variablesViewer.setUseHashlookup(true);
+        variablesViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				getViewer().refresh();
+			}
+        });
+        return variablesViewer;
+    }
+    
+    public void setLogFile(String logFileName) {
+    	this.logFileName = logFileName;
+    	refresh();
+		deleteAction.setEnabled(logFileName != null);
+        refreshAction.setEnabled(logFileName != null);
+    }
+    
+    public void refresh() {
+    	if (logFileName == null) {
+    		getViewer().setInput(null);
+    		return;
+    	}
+		try {
+			XStream xstream = new XStream();
+			ObjectInputStream in = xstream.createObjectInputStream(
+				new FileReader(logFileName));
+			getViewer().setInput(createEventList((List) in.readObject()));
+			// TODO: this is necessary because otherwise, the show cause action
+			// cannot find the cause event if it hasn't been shown yet
+			((TreeViewer) getViewer()).expandAll();
+		} catch (FileNotFoundException e) {
+			setLogFile(null);
+			getViewer().setInput(null);
+		} catch (Throwable t) {
+			DroolsEclipsePlugin.log(t);
+			getViewer().setInput(null);
+		}
+    }
+    
+    protected List createEventList(List logEvents) {
+		Iterator iterator = logEvents.iterator();
+		List events = new ArrayList();
+		Event currentBeforeActivationEvent = null;
+		Event currentBeforePackageEvent = null;
+		List newActivations = new ArrayList();
+		Map activationMap = new HashMap();
+		Map objectMap = new HashMap();
+		while (iterator.hasNext()) {
+			LogEvent inEvent = (LogEvent) iterator.next();
+			Event event = new Event(inEvent.getType());
+			switch (inEvent.getType()) {
+				case LogEvent.INSERTED:
+					ObjectLogEvent inObjectEvent = (ObjectLogEvent) inEvent;
+					event.setString("Object inserted (" + inObjectEvent.getFactId() + "): " + inObjectEvent.getObjectToString());
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					event.addSubEvents(newActivations);
+					newActivations.clear();
+					objectMap.put(new Long(((ObjectLogEvent) inEvent).getFactId()), event);
+					break;
+				case LogEvent.UPDATED:
+					inObjectEvent = (ObjectLogEvent) inEvent;
+					event.setString("Object updated (" + inObjectEvent.getFactId() + "): " + inObjectEvent.getObjectToString());
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					event.addSubEvents(newActivations);
+					newActivations.clear();
+					Event assertEvent = (Event) objectMap.get(new Long(((ObjectLogEvent) inEvent).getFactId()));
+					if (assertEvent != null) {
+						event.setCauseEvent(assertEvent);
+					}
+					break;
+				case LogEvent.RETRACTED:
+					inObjectEvent = (ObjectLogEvent) inEvent;
+					event.setString("Object removed (" + inObjectEvent.getFactId() + "): " + inObjectEvent.getObjectToString());
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					event.addSubEvents(newActivations);
+					newActivations.clear();
+					assertEvent = (Event) objectMap.get(new Long(((ObjectLogEvent) inEvent).getFactId()));
+					if (assertEvent != null) {
+						event.setCauseEvent(assertEvent);
+					}
+					break;
+				case LogEvent.ACTIVATION_CREATED:
+					ActivationLogEvent inActivationEvent = (ActivationLogEvent) inEvent;
+					event.setString("Activation created: Rule " + inActivationEvent.getRule() + " " + inActivationEvent.getDeclarations());
+					newActivations.add(event);
+					activationMap.put(((ActivationLogEvent) inEvent).getActivationId(), event);
+					break;
+				case LogEvent.ACTIVATION_CANCELLED:
+					inActivationEvent = (ActivationLogEvent) inEvent;
+					event.setString("Activation cancelled: Rule " + inActivationEvent.getRule() + " " + inActivationEvent.getDeclarations());
+					newActivations.add(event);
+					event.setCauseEvent((Event) activationMap.get(((ActivationLogEvent) inEvent).getActivationId()));
+					break;
+				case LogEvent.BEFORE_ACTIVATION_FIRE:
+					inActivationEvent = (ActivationLogEvent) inEvent;
+					event.setString("Activation executed: Rule " + inActivationEvent.getRule() + " " + inActivationEvent.getDeclarations());
+					events.add(event);
+					currentBeforeActivationEvent = event;
+					event.setCauseEvent((Event) activationMap.get(((ActivationLogEvent) inEvent).getActivationId()));
+					break;
+				case LogEvent.AFTER_ACTIVATION_FIRE:
+					currentBeforeActivationEvent = null;
+					break;
+				case LogEvent.RULEFLOW_CREATED:
+					RuleFlowLogEvent inRuleFlowEvent = (RuleFlowLogEvent) inEvent;
+					event.setString("RuleFlow started: " + inRuleFlowEvent.getProcessName() + "[" + inRuleFlowEvent.getProcessId() + "]");
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					break;
+				case LogEvent.RULEFLOW_COMPLETED:
+					inRuleFlowEvent = (RuleFlowLogEvent) inEvent;
+					event.setString("RuleFlow completed: " + inRuleFlowEvent.getProcessName() + "[" + inRuleFlowEvent.getProcessId() + "]");
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					break;
+				case LogEvent.RULEFLOW_GROUP_ACTIVATED:
+					RuleFlowGroupLogEvent inRuleFlowGroupEvent = (RuleFlowGroupLogEvent) inEvent;
+					event.setString("RuleFlowGroup activated: " + inRuleFlowGroupEvent.getGroupName() + "[size=" + inRuleFlowGroupEvent.getSize() + "]");
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					break;
+				case LogEvent.RULEFLOW_GROUP_DEACTIVATED:
+					inRuleFlowGroupEvent = (RuleFlowGroupLogEvent) inEvent;
+					event.setString("RuleFlowGroup deactivated: " + inRuleFlowGroupEvent.getGroupName() + "[size=" + inRuleFlowGroupEvent.getSize() + "]");
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					break;
+				case LogEvent.BEFORE_PACKAGE_ADDED:
+					RuleBaseLogEvent ruleBaseEvent = (RuleBaseLogEvent) inEvent;
+					event.setString("Package added: " + ruleBaseEvent.getPackageName());
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					currentBeforePackageEvent = event;
+					break;
+				case LogEvent.AFTER_PACKAGE_ADDED:
+					currentBeforePackageEvent = null;
+					break;
+				case LogEvent.BEFORE_PACKAGE_REMOVED:
+					ruleBaseEvent = (RuleBaseLogEvent) inEvent;
+					event.setString("Package removed: " + ruleBaseEvent.getPackageName());
+					if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					currentBeforePackageEvent = event;
+					break;
+				case LogEvent.AFTER_PACKAGE_REMOVED:
+					currentBeforePackageEvent = null;
+					break;
+				case LogEvent.AFTER_RULE_ADDED:
+					ruleBaseEvent = (RuleBaseLogEvent) inEvent;
+					event.setString("Rule added: " + ruleBaseEvent.getRuleName());
+					if (currentBeforePackageEvent != null) {
+						currentBeforePackageEvent.addSubEvent(event);
+					} else if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					event.addSubEvents(newActivations);
+					newActivations.clear();
+					break;
+				case LogEvent.AFTER_RULE_REMOVED:
+					ruleBaseEvent = (RuleBaseLogEvent) inEvent;
+					event.setString("Rule removed: " + ruleBaseEvent.getRuleName());
+					if (currentBeforePackageEvent != null) {
+						currentBeforePackageEvent.addSubEvent(event);
+					} else if (currentBeforeActivationEvent != null) {
+						currentBeforeActivationEvent.addSubEvent(event);
+					} else {
+						events.add(event);
+					}
+					event.addSubEvents(newActivations);
+					newActivations.clear();
+					break;
+			}
+		}
+		return events;
+    }
+    
+    public void deleteLog() {
+    	if (logFileName != null) {
+    		File file = new File(logFileName);
+    		try {
+    			file.delete();
+    			// TODO delete file cause this doesn't seem to work
+    			setLogFile(null);
+    			refresh();
+    		} catch (Throwable t) {
+    			t.printStackTrace();
+    			DroolsEclipsePlugin.log(t);
+    		}
+    	}
+    }
+    
+	protected void becomesVisible() {
+		refresh();
+	}
+    
+    protected String getHelpContextId() {
+        return null;
+    }
+    
+    public Event getSelectedEvent() {
+    	ISelection selection = getViewer().getSelection();
+    	if (selection instanceof IStructuredSelection) {
+    		Object selected = ((IStructuredSelection) selection).getFirstElement();
+    		if (selected instanceof Event) {
+    			return (Event) selected;
+    		}
+    	}
+    	return null;
+    }
+    
+    public void showEvent(Event event) {
+    	((TreeViewer) getViewer()).reveal(event);
+    }
+
+    protected void fillContextMenu(IMenuManager menu) {
+    	Event selected = getSelectedEvent();
+    	if (selected != null) {
+			Event causeEvent = selected.getCauseEvent();
+			if (causeEvent != null) {
+				menu.add(getAction("ShowEventCause"));
+			}
+    	}
+		menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+    }
+
+	protected void createActions() {
+        deleteAction = new DeleteLogAction(this);
+        setAction("ClearLog", deleteAction);
+        deleteAction.setEnabled(logFileName != null);
+        refreshAction = new RefreshLogAction(this);
+        setAction("RefreshLog", refreshAction);
+        refreshAction.setEnabled(logFileName != null);
+        IAction action = new OpenLogAction(this);
+        setAction("OpenLog", action);
+		action = new ShowEventCauseAction(this);
+		setAction("ShowEventCause", action);
+    }
+
+    protected void configureToolBar(IToolBarManager tbm) {
+        tbm.add(getAction("OpenLog"));
+        tbm.add(getAction("RefreshLog"));
+        tbm.add(getAction("ClearLog"));
+    }
+    
+    public void saveState(IMemento memento) {
+    	memento.putString(LOG_FILE_NAME, logFileName);
+    }
+    
+    public void init(IViewSite site, IMemento memento) throws PartInitException {
+        super.init(site, memento);
+        if (memento != null) {
+        	logFileName = memento.getString(LOG_FILE_NAME);
+        }
+    }
+    
+	public class Event {
+		
+		private String toString;
+		private int type;
+		private List subEvents = new ArrayList();
+		private Event causeEvent;
+		
+		public Event(int type) {
+			this.type = type;
+		}
+		
+		public void setString(String toString) {
+			this.toString = toString;
+		}
+		
+		public String toString() {
+			return toString;
+		}
+		
+		public int getType() {
+			return type;
+		}
+		
+		public void addSubEvent(Event subEvent) {
+			subEvents.add(subEvent);
+		}
+		
+		public void addSubEvents(Collection subEvents) {
+			this.subEvents.addAll(subEvents);
+		}
+		
+		public Object[] getSubEvents() {
+			return subEvents.toArray();
+		}
+		
+		public boolean hasSubEvents() {
+			return !subEvents.isEmpty();
+		}
+		
+		public void setCauseEvent(Event causeEvent) {
+			this.causeEvent = causeEvent;
+		}
+		
+		public Event getCauseEvent() {
+			return causeEvent;
+		}
+	}
+	
+	public class AuditLabelProvider extends LabelProvider implements IColorProvider {
+
+		public Color getForeground(Object element) {
+			return null;
+		}
+
+		public Color getBackground(Object element) {
+			Event selected = getSelectedEvent();
+			if (selected != null) {
+				if (element.equals(selected.getCauseEvent())) {
+			        Color color = DroolsEclipsePlugin.getDefault().getColor(CAUSE_EVENT_COLOR);
+			        if (color == null) {
+			        	color = new Color(getControl().getDisplay(), 0, 255, 0); 
+		        		DroolsEclipsePlugin.getDefault().setColor(CAUSE_EVENT_COLOR, color);
+			        }
+			        return color;
+				}
+			}
+			return null;
+		}
+		
+	    public Image getImage(Object element) {
+	    	if (element instanceof Event) {
+	    		int type = ((Event) element).getType();
+	    		switch (type) {
+	    			case LogEvent.INSERTED: return DroolsPluginImages.getImage(DroolsPluginImages.INSERT);
+	    			case LogEvent.UPDATED: return DroolsPluginImages.getImage(DroolsPluginImages.UPDATE);
+	    			case LogEvent.RETRACTED: return DroolsPluginImages.getImage(DroolsPluginImages.RETRACT);
+	    			case LogEvent.ACTIVATION_CREATED: return DroolsPluginImages.getImage(DroolsPluginImages.CREATE_ACTIVATION);
+	    			case LogEvent.ACTIVATION_CANCELLED: return DroolsPluginImages.getImage(DroolsPluginImages.CANCEL_ACTIVATION);
+	    			case LogEvent.BEFORE_ACTIVATION_FIRE: return DroolsPluginImages.getImage(DroolsPluginImages.EXECUTE_ACTIVATION);
+	    			case LogEvent.RULEFLOW_CREATED: return DroolsPluginImages.getImage(DroolsPluginImages.RULEFLOW);
+	    			case LogEvent.RULEFLOW_COMPLETED: return DroolsPluginImages.getImage(DroolsPluginImages.RULEFLOW);
+	    			case LogEvent.RULEFLOW_GROUP_ACTIVATED: return DroolsPluginImages.getImage(DroolsPluginImages.RULEFLOW);
+	    			case LogEvent.RULEFLOW_GROUP_DEACTIVATED: return DroolsPluginImages.getImage(DroolsPluginImages.RULEFLOW);
+	    			case LogEvent.BEFORE_PACKAGE_ADDED: return DroolsPluginImages.getImage(DroolsPluginImages.DROOLS);
+	    			case LogEvent.BEFORE_PACKAGE_REMOVED: return DroolsPluginImages.getImage(DroolsPluginImages.DROOLS);
+	    			case LogEvent.AFTER_RULE_ADDED: return DroolsPluginImages.getImage(DroolsPluginImages.DROOLS);
+	    			case LogEvent.AFTER_RULE_REMOVED: return DroolsPluginImages.getImage(DroolsPluginImages.DROOLS);
+	    		}
+	    		return null;
+	    	}
+	        return null;
+	    }
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditViewContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditViewContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/AuditViewContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,29 @@
+package org.drools.eclipse.debug;
+
+import java.util.List;
+
+import org.drools.eclipse.debug.AuditView.Event;
+
+public class AuditViewContentProvider extends DroolsDebugViewContentProvider {
+
+    protected String getEmptyString() {
+    	return "The selected audit log is empty.";
+    }
+
+    public Object[] getChildren(Object obj) {
+		if (obj instanceof List) {
+			return ((List) obj).toArray();
+		}
+        if (obj instanceof Event) {
+    		return ((Event) obj).getSubEvents();
+        }
+        return new Object[0];
+    }
+    
+    public boolean hasChildren(Object obj) {
+        if (obj instanceof Event) {
+    		return ((Event) obj).hasSubEvents();
+        }
+        return false;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DebugUtil.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,204 @@
+package org.drools.eclipse.debug;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.ISourceLocator;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.debug.core.IJavaClassType;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaReferenceType;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.eval.IAstEvaluationEngine;
+import org.eclipse.jdt.debug.eval.ICompiledExpression;
+import org.eclipse.jdt.debug.eval.IEvaluationListener;
+import org.eclipse.jdt.debug.eval.IEvaluationResult;
+import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
+
+public class DebugUtil {
+
+    public static final int INFO_EVALUATION_STACK_FRAME = 111;
+    private static IStatus fgNeedStackFrame = new Status(IStatus.INFO,
+        DroolsEclipsePlugin.getUniqueIdentifier(), INFO_EVALUATION_STACK_FRAME,
+        "Provides thread context for an evaluation", null);
+    private static IStatusHandler fgStackFrameProvider;
+
+    public static IValue getValueByExpression(String expression, IValue value) {
+        if (!(value instanceof IJavaObject)) {
+            return null;
+        }
+        IJavaObject javaValue = (IJavaObject) value;
+        try {
+            IJavaType type = javaValue.getJavaType();
+            if (!(type instanceof IJavaClassType)) {
+                return null;
+            }
+            IJavaStackFrame stackFrame = getStackFrame(javaValue);
+            if (stackFrame == null) {
+                return null;
+            }
+
+			// find the project the snippets will be compiled in.
+			ISourceLocator locator= javaValue.getLaunch().getSourceLocator();
+			Object sourceElement= null;
+			if (locator instanceof ISourceLookupDirector) {
+				String[] sourcePaths = ((IJavaClassType) type).getSourcePaths(null);
+				if (sourcePaths != null && sourcePaths.length > 0) {
+					sourceElement = ((ISourceLookupDirector) locator).getSourceElement(sourcePaths[0]);
+				}
+				if (!(sourceElement instanceof IJavaElement) && sourceElement instanceof IAdaptable) {
+					sourceElement = ((IAdaptable) sourceElement).getAdapter(IJavaElement.class);
+				}
+			}
+			if (sourceElement == null) {
+				sourceElement = locator.getSourceElement(stackFrame);
+				if (!(sourceElement instanceof IJavaElement) && sourceElement instanceof IAdaptable) {
+					Object newSourceElement = ((IAdaptable) sourceElement).getAdapter(IJavaElement.class);
+					// if the source is a drl during the execution of the rule
+					if (newSourceElement != null) {
+						sourceElement = newSourceElement;
+					}
+				}
+			}
+			IJavaProject project = null;
+			if (sourceElement instanceof IJavaElement) {
+				project = ((IJavaElement) sourceElement).getJavaProject();
+			} else if (sourceElement instanceof IResource) {
+				IJavaProject resourceProject = JavaCore.create(((IResource) sourceElement).getProject());
+				if (resourceProject.exists()) {
+					project = resourceProject;
+				}
+			}
+            if (project == null) {
+                return null;
+            }
+
+            IAstEvaluationEngine evaluationEngine = JDIDebugPlugin.getDefault()
+                    .getEvaluationEngine(project,
+                            (IJavaDebugTarget) stackFrame.getDebugTarget());
+
+            EvaluationBlock evaluationBlock = new EvaluationBlock(javaValue,
+                    (IJavaReferenceType) type, (IJavaThread) stackFrame.getThread(),
+                    evaluationEngine);
+            return evaluationBlock.evaluate(expression);
+
+        } catch (CoreException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+        return null;
+    }
+
+    /**
+     * Return the current stack frame context, or a valid stack frame for the
+     * given value.
+     */
+    private static IJavaStackFrame getStackFrame(IValue value)
+            throws CoreException {
+        IStatusHandler handler = getStackFrameProvider();
+        if (handler != null) {
+            IJavaStackFrame stackFrame = (IJavaStackFrame) handler
+                    .handleStatus(fgNeedStackFrame, value);
+            if (stackFrame != null) {
+                return stackFrame;
+            }
+        }
+        IDebugTarget target = value.getDebugTarget();
+        IJavaDebugTarget javaTarget = (IJavaDebugTarget) target
+                .getAdapter(IJavaDebugTarget.class);
+        if (javaTarget != null) {
+            IThread[] threads = javaTarget.getThreads();
+            for (int i = 0; i < threads.length; i++) {
+                IThread thread = threads[i];
+                if (thread.isSuspended()) {
+                    return (IJavaStackFrame) thread.getTopStackFrame();
+                }
+            }
+        }
+        return null;
+    }
+
+    private static IStatusHandler getStackFrameProvider() {
+        if (fgStackFrameProvider == null) {
+            fgStackFrameProvider = DebugPlugin.getDefault().getStatusHandler(
+                    fgNeedStackFrame);
+        }
+        return fgStackFrameProvider;
+    }
+
+    private static class EvaluationBlock implements IEvaluationListener {
+
+        private IJavaObject fEvaluationValue;
+        private IJavaReferenceType fEvaluationType;
+        private IJavaThread fThread;
+        private IAstEvaluationEngine fEvaluationEngine;
+        private IEvaluationResult fResult;
+
+        public EvaluationBlock(IJavaObject value, IJavaReferenceType type,
+                IJavaThread thread, IAstEvaluationEngine evaluationEngine) {
+            fEvaluationValue = value;
+            fEvaluationType = type;
+            fThread = thread;
+            fEvaluationEngine = evaluationEngine;
+        }
+
+        public void evaluationComplete(IEvaluationResult result) {
+            synchronized (this) {
+                fResult = result;
+                this.notify();
+            }
+        }
+
+        public IJavaValue evaluate(String snippet) throws DebugException {
+            ICompiledExpression compiledExpression = fEvaluationEngine
+                    .getCompiledExpression(snippet, fEvaluationType);
+            if (compiledExpression.hasErrors()) {
+                String[] errorMessages = compiledExpression.getErrorMessages();
+                String message = "";
+
+                for ( int i = 0; i < errorMessages.length; i++ ) {
+                    message += errorMessages[i] + "\n";
+                }
+                throw new DebugException(new Status(IStatus.ERROR, 
+                    DroolsEclipsePlugin.PLUGIN_ID, DroolsEclipsePlugin.INTERNAL_ERROR,
+                    "Error when compiling snippet " + snippet + ": " + message, null));
+            }
+            fResult = null;
+            fEvaluationEngine.evaluateExpression(compiledExpression,
+                    fEvaluationValue, fThread, this,
+                    DebugEvent.EVALUATION_IMPLICIT, false);
+            synchronized (this) {
+                if (fResult == null) {
+                    try {
+                        this.wait();
+                    } catch (InterruptedException e) {
+                    }
+                }
+            }
+            if (fResult == null) {
+                return null;
+            }
+            if (fResult.hasErrors()) {
+                return null;
+            }
+            return fResult.getValue();
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugEventHandlerView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugEventHandlerView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugEventHandlerView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,279 @@
+package org.drools.eclipse.debug;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.debug.actions.ShowLogicalStructureAction;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.internal.ui.VariablesViewModelPresentation;
+import org.eclipse.debug.internal.ui.contexts.DebugContextManager;
+import org.eclipse.debug.ui.AbstractDebugView;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.debug.ui.contexts.DebugContextEvent;
+import org.eclipse.debug.ui.contexts.IDebugContextListener;
+import org.eclipse.debug.ui.contexts.IDebugContextService;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jface.action.GroupMarker;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.viewers.IColorProvider;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchActionConstants;
+import org.eclipse.ui.IWorkbenchPart;
+
+/**
+ * A generic Drools debug view.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public abstract class DroolsDebugEventHandlerView extends AbstractDebugView implements IDebugContextListener, ISelectionListener {
+
+    private VariablesViewModelPresentation modelPresentation;
+    private boolean showLogical = true;
+    private Object[] oldExpandedElements = new Object[0];
+
+    public void dispose() {
+		DebugContextManager.getDefault().removeDebugContextListener(this);
+        getSite().getPage().removeSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
+        super.dispose();
+    }
+
+    public boolean isShowLogicalStructure() {
+        return showLogical;
+    }
+
+    public void setShowLogicalStructure(boolean showLogical) {
+        this.showLogical = showLogical;
+    }
+
+    protected void setViewerInput(Object context) {
+    	Object input = null;
+    	
+    	// if a working memory has been explicitly selected as variable, use this
+    	if (context instanceof IVariable) {
+        	IVariable variable = (IVariable) context;
+            try {
+                IValue value = ((IVariable) context).getValue();
+                if (value != null && value instanceof IJavaObject
+                        && "org.drools.reteoo.ReteooStatefulSession".equals(
+                            variable.getValue().getReferenceTypeName())) {
+                    input = value;
+                }
+            } catch (Throwable t) {
+                DroolsEclipsePlugin.log(t);
+            }
+        }
+    	// else get selected thread and determine if any of the stack frames
+    	// is executing in a working memory, if so, use that one 
+    	if (input == null) {
+    		IDebugContextService debugContextService = DebugContextManager.getDefault().getContextService(getSite().getWorkbenchWindow());
+    		if (debugContextService != null) {
+	    		ISelection stackSelection = debugContextService.getActiveContext();
+	    		if (stackSelection instanceof IStructuredSelection) {
+	                Object selection = ((IStructuredSelection) stackSelection).getFirstElement();
+	                if (selection instanceof IJavaStackFrame) {
+	                	try {
+	                    	IJavaThread thread = (IJavaThread) ((IJavaStackFrame) selection).getThread();
+	                    	IStackFrame[] frames = thread.getStackFrames();
+	                    	for (int i = 0; i < frames.length; i++) {
+	                            IJavaObject stackObj = ((IJavaStackFrame) frames[i]).getThis();
+	                            if ((stackObj != null)
+	                                    && (stackObj.getJavaType() != null)
+	                                    && ("org.drools.reteoo.ReteooStatefulSession".equals(
+	                                        stackObj.getJavaType().getName()))) {
+	                                input = stackObj;
+	                                break;
+	                            }
+	                    	}
+	                    } catch (Throwable t) {
+	                        DroolsEclipsePlugin.log(t);
+	                    }
+	                }
+	    		}
+    		}
+    	}
+		
+    	Object current = getViewer().getInput();
+				
+		if (current == null && input == null) {
+			return;
+		}
+
+		Object[] newExpandedElements = ((TreeViewer) getViewer()).getExpandedElements();
+		if (newExpandedElements.length != 0) {
+			oldExpandedElements = newExpandedElements;
+		}
+		getViewer().setInput(input);
+		if (input != null) {
+			((TreeViewer) getViewer()).setExpandedElements(oldExpandedElements);
+			((TreeViewer) getViewer()).expandToLevel(getAutoExpandLevel());
+		}
+    }
+
+    protected Viewer createViewer(Composite parent) {
+		TreeViewer variablesViewer = new TreeViewer(parent);
+		variablesViewer.setContentProvider(createContentProvider());
+        variablesViewer.setLabelProvider(new VariablesViewLabelProvider(
+            getModelPresentation()));
+        variablesViewer.setUseHashlookup(true);
+		DebugContextManager.getDefault().addDebugContextListener(this);
+        getSite().getPage().addSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
+		return variablesViewer;
+    }
+    
+    protected int getAutoExpandLevel() {
+    	return 0;
+    }
+    
+    protected abstract IContentProvider createContentProvider();
+
+    protected String getHelpContextId() {
+        return null;
+    }
+
+	protected void becomesHidden() {
+		setViewerInput(null);
+		super.becomesHidden();
+	}
+
+	protected void becomesVisible() {
+		super.becomesVisible();
+        ISelection selection = getSite().getPage().getSelection(
+            IDebugUIConstants.ID_VARIABLE_VIEW);
+        if (selection instanceof IStructuredSelection) {
+            setViewerInput(((IStructuredSelection) selection).getFirstElement());
+        } else {
+        	setViewerInput(null);
+        }
+    }
+
+	protected void createActions() {
+        IAction action = new ShowLogicalStructureAction(this);
+        setAction("ShowLogicalStructure", action);
+    }
+
+    protected void configureToolBar(IToolBarManager tbm) {
+        tbm.add(getAction("ShowLogicalStructure"));
+    }
+
+    protected void fillContextMenu(IMenuManager menu) {
+		menu.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
+    }
+
+	public void contextActivated(ISelection selection, IWorkbenchPart part) {
+		if (!isAvailable() || !isVisible()) {
+			return;
+		}
+		
+		if (selection instanceof IStructuredSelection) {
+			setViewerInput(((IStructuredSelection)selection).getFirstElement());
+		}
+		showViewer();
+	}
+
+	public void debugContextChanged(DebugContextEvent event) {
+		//selectionChanged(null, event.getContext());
+	}
+	
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+        if (!isAvailable()) {
+            return;
+        }
+        if (selection == null) {
+            setViewerInput(null);
+        } else if (selection instanceof IStructuredSelection) {
+            setViewerInput(((IStructuredSelection) selection).getFirstElement());
+        }
+    }
+    
+	protected void initActionState(IAction action) {
+		// The show logical structure action is always enabled by default
+		// when (re)starting the view 
+		String id = action.getId();
+		if (id.endsWith("ShowLogicalStructureAction")) {
+			action.setChecked(true);
+		} else {
+			super.initActionState(action);
+		}
+	}
+    
+    protected IDebugModelPresentation getModelPresentation() {
+        if (modelPresentation == null) {
+            modelPresentation = new VariablesViewModelPresentation();
+        }
+        return modelPresentation;
+    }
+
+	private class VariablesViewLabelProvider implements ILabelProvider, IColorProvider {
+
+        private IDebugModelPresentation presentation;
+
+        public VariablesViewLabelProvider(IDebugModelPresentation presentation) {
+            this.presentation = presentation;
+        }
+
+        public IDebugModelPresentation getPresentation() {
+            return presentation;
+        }
+
+        public Image getImage(Object element) {
+            return presentation.getImage(element);
+        }
+
+        public String getText(Object element) {
+            return presentation.getText(element);
+        }
+
+        public void addListener(ILabelProviderListener listener) {
+            presentation.addListener(listener);
+        }
+
+        public void dispose() {
+            presentation.dispose();
+        }
+
+        public boolean isLabelProperty(Object element, String property) {
+            return presentation.isLabelProperty(element, property);
+        }
+
+        public void removeListener(ILabelProviderListener listener) {
+            presentation.removeListener(listener);
+        }
+
+        public Color getForeground(Object element) {
+            if (element instanceof IVariable) {
+                IVariable variable = (IVariable) element;
+                try {
+                    if (variable.hasValueChanged()) {
+                        return JFaceResources.getColorRegistry()
+                            .get(IDebugUIConstants.PREF_CHANGED_DEBUG_ELEMENT_COLOR);
+                    }
+                } catch (DebugException e) {
+                    DroolsEclipsePlugin.log(e);
+                }
+            }
+            return null;
+        }
+
+        public Color getBackground(Object element) {
+            return null;
+        }
+
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugViewContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugViewContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/DroolsDebugViewContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,140 @@
+package org.drools.eclipse.debug;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILogicalStructureType;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * A generic Drools debug view content provider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DroolsDebugViewContentProvider implements ITreeContentProvider {
+    
+    private Map parentCache;
+    
+    public DroolsDebugViewContentProvider() {
+        parentCache = new HashMap(10);
+    }
+    
+    public Object[] getChildren(Object parent) {
+        return null;
+    }
+    
+    public Object[] getElements(Object parent) {
+        Object[] result = getChildren(parent);
+        if (result != null && result.length == 0) {
+        	return new Object[] { getEmptyString() };
+        }
+        return result;
+    }
+    
+    protected String getEmptyString() {
+    	return "Empty";
+    }
+
+    protected void cache(Object parent, Object[] children) {        
+        for (int i = 0; i < children.length; i++) {
+            parentCache.put(children[i], parent);
+        }       
+    }
+    
+    public Object getParent(Object item) {
+        return parentCache.get(item);
+    }
+
+    public void dispose() {
+        parentCache= null;
+    }
+    
+    protected void clearCache() {
+        if (parentCache != null) {
+            parentCache.clear();
+        }
+    }
+    
+    public void removeCache(Object[] children) {
+        if (parentCache == null) {
+            return;
+        }
+        for (int i = 0; i < children.length; i++) {
+            parentCache.remove(children[i]);   
+        }
+    }
+
+    public boolean hasChildren(Object element) {
+        try {
+            if (element instanceof IVariable) {
+                IValue v = ((IVariable)element).getValue();
+                return v != null && v.hasVariables();
+            }
+            if (element instanceof IValue) {
+                return ((IValue)element).hasVariables();
+            }
+            if (element instanceof IStackFrame) {
+                return ((IStackFrame)element).hasVariables();
+            }
+        } catch (DebugException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+        return false;
+    }
+
+    public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+        clearCache();
+    }
+    
+    public List getCachedDecendants(Object parent) {
+        Iterator children = parentCache.keySet().iterator();
+        List cachedChildren = new ArrayList(10);
+        while (children.hasNext()) {
+            Object child = children.next();
+            if (isCachedDecendant(child, parent)) {
+                cachedChildren.add(child);
+            }
+        }
+        return cachedChildren;
+    }
+    
+    protected boolean isCachedDecendant(Object child, Object parent) {
+        Object p = getParent(child);
+        while (p != null) {
+            if (p.equals(parent)) {
+                return true;
+            }
+            p = getParent(p);
+        }
+        return false;
+    }
+    
+    protected IValue getLogicalValue(IValue value, List previousStructureIds) {
+        ILogicalStructureType[] types = DebugPlugin.getLogicalStructureTypes(value);
+        if (types.length > 0) {
+            ILogicalStructureType type = DebugPlugin.getDefaultStructureType(types);
+            if (type != null && !previousStructureIds.contains(type.getId())) {
+                try {
+                    value = type.getLogicalStructure(value);
+                    previousStructureIds.add(type.getId());
+                    return getLogicalValue(value, previousStructureIds);
+                } catch (CoreException e) {
+                    // unable to display logical structure
+                }
+            }
+        }
+        return value;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ObjectWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ObjectWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/ObjectWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,108 @@
+package org.drools.eclipse.debug;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaFieldVariable;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+
+/**
+ * Creates a IJavaObject from an IJavaObject and given variables.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class ObjectWrapper implements IJavaObject {
+    
+    private IJavaObject object;
+    private IJavaVariable[] variables;
+    
+    public ObjectWrapper(IJavaObject object, IJavaVariable[] variables) {
+        this.object = object;
+        this.variables = variables;
+    }
+
+    public IJavaValue sendMessage(String selector, String signature, IJavaValue[] args, IJavaThread thread, boolean superSend) throws DebugException {
+        return object.sendMessage(selector, signature, args, thread, superSend);
+    }
+
+    public IJavaValue sendMessage(String selector, String signature, IJavaValue[] args, IJavaThread thread, String typeSignature) throws DebugException {
+        return object.sendMessage(selector, signature, args, thread, typeSignature);
+    }
+
+    public IJavaFieldVariable getField(String name, boolean superField) throws DebugException {
+        return object.getField(name, superField);
+    }
+
+    public IJavaFieldVariable getField(String name, String typeSignature) throws DebugException {
+        return object.getField(name, typeSignature);
+    }
+
+    public String getSignature() throws DebugException {
+        return object.getSignature();
+    }
+
+    public String getGenericSignature() throws DebugException {
+        return object.getGenericSignature();
+    }
+
+    public IJavaType getJavaType() throws DebugException {
+        return object.getJavaType();
+    }
+
+    public String getReferenceTypeName() throws DebugException {
+        return object.getReferenceTypeName();
+    }
+
+    public String getValueString() throws DebugException {
+        return object.getValueString();
+    }
+
+    public boolean isAllocated() throws DebugException {
+        return object.isAllocated();
+    }
+
+    public IVariable[] getVariables() {
+        return variables;
+    }
+
+    public boolean hasVariables() {
+        return variables.length > 0;
+    }
+    
+    protected void setVariables(IJavaVariable[] variables) {
+    	this.variables = variables;
+    }
+
+    public String getModelIdentifier() {
+        return object.getModelIdentifier();
+    }
+
+    public IDebugTarget getDebugTarget() {
+        return object.getDebugTarget();
+    }
+
+    public ILaunch getLaunch() {
+        return object.getLaunch();
+    }
+
+    public Object getAdapter(Class adapter) {
+        return object.getAdapter(adapter);
+    }
+
+    public IJavaThread[] getWaitingThreads() throws DebugException {
+        return object.getWaitingThreads();
+    }
+
+    public IJavaThread getOwningThread() throws DebugException {
+        return object.getOwningThread();
+    }
+
+	public IJavaObject[] getReferringObjects(long max) throws DebugException {
+		return object.getReferringObjects(max);
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/RealtimeAuditView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,105 @@
+package org.drools.eclipse.debug;
+
+import java.io.ObjectInputStream;
+import java.io.StringReader;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.debug.ui.IDebugUIConstants;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.ISelectionListener;
+import org.eclipse.ui.IWorkbenchPart;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * An audit view that shows the contents of the selected logger when debugging.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RealtimeAuditView extends AuditView implements ISelectionListener {
+
+    public void dispose() {
+        getSite().getPage().removeSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
+        super.dispose();
+    }
+
+    protected Viewer createViewer(Composite parent) {
+        getSite().getPage().addSelectionListener(IDebugUIConstants.ID_VARIABLE_VIEW, this);
+    	return super.createViewer(parent);
+    }
+    
+    protected void setViewerInput(Object context) {
+     	// if an in memory logger has been explicitly selected as variable
+    	if (context instanceof IVariable) {
+        	IVariable variable = (IVariable) context;
+            try {
+                IValue value = ((IVariable) context).getValue();
+                if (value != null && value instanceof IJavaObject
+                        && "org.drools.audit.WorkingMemoryInMemoryLogger".equals(
+                            variable.getValue().getReferenceTypeName())) {
+                	setAuditEvents((IJavaObject) value);
+                }
+            } catch (Throwable t) {
+                DroolsEclipsePlugin.log(t);
+            }
+        }
+    }
+
+	protected void becomesHidden() {
+		setViewerInput(null);
+		super.becomesHidden();
+	}
+
+	protected void becomesVisible() {
+		super.becomesVisible();
+        ISelection selection = getSite().getPage().getSelection(
+            IDebugUIConstants.ID_VARIABLE_VIEW);
+        if (selection instanceof IStructuredSelection) {
+            setViewerInput(((IStructuredSelection) selection).getFirstElement());
+        }
+    }
+
+    public void selectionChanged(IWorkbenchPart part, ISelection selection) {
+        if (!isAvailable()) {
+            return;
+        }
+        if (selection == null) {
+            setViewerInput(null);
+        } else if (selection instanceof IStructuredSelection) {
+            setViewerInput(((IStructuredSelection) selection).getFirstElement());
+        }
+    }
+    
+	protected void createActions() {
+	}
+	
+    protected void configureToolBar(IToolBarManager tbm) {
+    }
+    
+    private void setAuditEvents(IJavaObject inMemoryLogger) throws DebugException {
+        IValue eventString = DebugUtil.getValueByExpression("return getEvents();", inMemoryLogger);
+        String s = eventString.getValueString();
+        if (s != null) {
+        	try {
+				XStream xstream = new XStream();
+				ObjectInputStream in = xstream.createObjectInputStream(
+					new StringReader(s));
+				getViewer().setInput(createEventList((List) in.readObject()));
+        	} catch (Throwable t) {
+        		DroolsEclipsePlugin.log(t);
+        		getViewer().setInput(null);
+        	}
+        } else {
+        	getViewer().setInput(null);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/VariableWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/VariableWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/VariableWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,147 @@
+package org.drools.eclipse.debug;
+
+import org.eclipse.core.runtime.PlatformObject;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.jdt.debug.core.IJavaModifiers;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+
+/**
+ * Creates a Variable from an IValue and a given name.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class VariableWrapper extends PlatformObject implements IJavaVariable  {
+
+    private String name;
+    private IJavaValue value;
+    private boolean isLocal = false;
+    private boolean isPublic = false;
+    
+    public VariableWrapper(String name, IJavaValue value) {
+        this.name = name;
+        this.value = value;
+    }
+    
+    public String getSignature() throws DebugException {
+        return ((IJavaValue) getValue()).getSignature();
+    }
+
+    public String getGenericSignature() throws DebugException {
+        return ((IJavaValue) getValue()).getGenericSignature();
+    }
+    
+    public IJavaType getJavaType() throws DebugException {
+        return ((IJavaValue) getValue()).getJavaType();
+    }
+
+    public boolean isLocal() {
+        return isLocal;
+    }
+
+    public IValue getValue() {
+        return value;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getReferenceTypeName() throws DebugException {
+        return ((IJavaValue) getValue()).getReferenceTypeName();
+    }
+
+    public boolean hasValueChanged() {
+        return false;
+    }
+
+    public boolean isPublic() {
+        return isPublic;
+    }
+
+    public boolean isPrivate() {
+        return false;
+    }
+
+    public boolean isProtected() {
+        return false;
+    }
+
+    public boolean isPackagePrivate() {
+        return false;
+    }
+
+    public boolean isFinal() {
+        return false;
+    }
+
+    public boolean isStatic() {
+        return false;
+    }
+
+    public boolean isSynthetic() {
+        return false;
+    }
+
+    public String getModelIdentifier() {
+        return getValue().getModelIdentifier();
+    }
+
+    public IDebugTarget getDebugTarget() {
+        return ((IJavaValue) getValue()).getDebugTarget();
+    }
+
+    public ILaunch getLaunch() {
+        return getValue().getLaunch();
+    }
+
+    public void setValue(String expression) {
+    }
+
+    public void setValue(IValue value) {
+    }
+
+    public boolean supportsValueModification() {
+        return false;
+    }
+
+    public boolean verifyValue(String expression) {
+        return false;
+    }
+
+    public boolean verifyValue(IValue value) {
+        return false;
+    }
+
+    public Object getAdapter(Class adapter) {
+        if (IJavaVariable.class.equals(adapter) ||
+            IJavaModifiers.class.equals(adapter)) {
+            return this;
+        }
+        return super.getAdapter(adapter);
+    }
+
+    public boolean equals(Object obj) {
+        if (obj instanceof VariableWrapper) {
+            VariableWrapper var = (VariableWrapper) obj;
+            return var.getName().equals(getName()) && var.getValue().equals(getValue());
+        }
+        return false;
+    }
+
+    public int hashCode() {
+        return name.hashCode() + value.hashCode();
+    }
+
+    public void setLocal(boolean val) {
+        isLocal=val;
+    }
+    
+    public void setPublic(boolean val) {
+        isPublic = val;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,16 @@
+package org.drools.eclipse.debug;
+
+import org.eclipse.jface.viewers.IContentProvider;
+
+/**
+ * The Working Memory view.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class WorkingMemoryView extends DroolsDebugEventHandlerView {
+
+    protected IContentProvider createContentProvider() {
+        WorkingMemoryViewContentProvider contentProvider = new WorkingMemoryViewContentProvider(this);
+        return contentProvider;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryViewContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryViewContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/WorkingMemoryViewContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,203 @@
+package org.drools.eclipse.debug;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaArray;
+import org.eclipse.jdt.debug.core.IJavaModifiers;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+
+/**
+ * The Working Memory view content provider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class WorkingMemoryViewContentProvider extends DroolsDebugViewContentProvider {
+
+    private DroolsDebugEventHandlerView view;
+    
+    public WorkingMemoryViewContentProvider(DroolsDebugEventHandlerView view) {
+        this.view = view;
+    }
+    
+    protected String getEmptyString() {
+    	return "The selected working memory is empty.";
+    }
+
+    public Object[] getChildren(Object obj) {
+        try {
+            IVariable[] variables = null;
+            if (obj != null && obj instanceof IJavaObject
+                    && "org.drools.reteoo.ReteooStatefulSession".equals(
+                        ((IJavaObject) obj).getReferenceTypeName())) {
+                variables = getWorkingMemoryElements((IJavaObject) obj);
+            } else if (obj instanceof IVariable) {
+            	if (view.isShowLogicalStructure()) {
+            		IValue value = getLogicalValue(((IVariable) obj).getValue(), new ArrayList());
+                	variables = value.getVariables();
+                }
+            	if (variables == null) {
+                	variables = ((IVariable) obj).getValue().getVariables();
+                }
+            }
+            if (variables == null) {
+                return new Object[0];
+            } else {
+                cache(obj, variables);
+                return variables;
+            }
+        } catch (DebugException e) {
+            DroolsEclipsePlugin.log(e);
+            return new Object[0];
+        }
+    }
+    
+    private IVariable[] getWorkingMemoryElements(IJavaObject stackObj) throws DebugException {
+        IValue objects = DebugUtil.getValueByExpression("return iterateObjectsToList().toArray();", stackObj);
+        if (objects instanceof IJavaArray) {
+            IJavaArray array = (IJavaArray) objects;
+            List result = new ArrayList();
+            
+            IJavaValue[] vals = array.getValues();
+            
+            for ( int i = 0; i < vals.length; i++ ) {
+                result.add(new MyJavaVariable("[" + i + "]", vals[i]));
+            }
+            
+            
+            return (IVariable[]) result.toArray(new IVariable[0]);
+        }
+        return null;
+    }
+    
+    public class MyJavaVariable implements IJavaVariable {
+
+    	private String name;
+    	private IJavaValue value;
+
+    	public MyJavaVariable(String name, IJavaValue value) {
+    		this.name = name;
+    		this.value = value;
+    	}
+    	
+    	public String getSignature() throws DebugException {
+    		return ((IJavaValue)getValue()).getSignature();
+    	}
+
+    	public String getGenericSignature() throws DebugException {
+    		return ((IJavaValue)getValue()).getGenericSignature();
+    	}
+    	
+    	public IJavaType getJavaType() throws DebugException {
+    		return ((IJavaValue)getValue()).getJavaType();
+    	}
+
+    	public boolean isLocal() {
+    		return false;
+    	}
+
+    	public IValue getValue() {
+    		return value;
+    	}
+
+    	public String getName() {
+    		return name;
+    	}
+
+    	public String getReferenceTypeName() throws DebugException {
+    		return ((IJavaValue) getValue()).getReferenceTypeName();
+    	}
+
+    	public boolean hasValueChanged() {
+    		return false;
+    	}
+
+    	public boolean isPublic() {
+    		return false;
+    	}
+
+    	public boolean isPrivate() {
+    		return false;
+    	}
+
+    	public boolean isProtected() {
+    		return false;
+    	}
+
+    	public boolean isPackagePrivate() {
+    		return false;
+    	}
+
+    	public boolean isFinal() {
+    		return false;
+    	}
+
+    	public boolean isStatic() {
+    		return false;
+    	}
+
+    	public boolean isSynthetic() {
+    		return false;
+    	}
+
+    	public String getModelIdentifier() {
+    		return getValue().getModelIdentifier();
+    	}
+
+    	public IDebugTarget getDebugTarget() {
+    		return ((IJavaValue)getValue()).getDebugTarget();
+    	}
+
+    	public ILaunch getLaunch() {
+    		return getValue().getLaunch();
+    	}
+
+    	public void setValue(String expression) {
+    	}
+
+    	public void setValue(IValue value) {
+    	}
+
+    	public boolean supportsValueModification() {
+    		return false;
+    	}
+
+    	public boolean verifyValue(String expression) {
+    		return false;
+    	}
+
+    	public boolean verifyValue(IValue value) {
+    		return false;
+    	}
+
+    	public Object getAdapter(Class adapter) {
+    		if (IJavaVariable.class.equals(adapter) ||
+    			IJavaModifiers.class.equals(adapter)) {
+    			return this;
+    		}
+    		return null;
+    	}
+
+    	public boolean equals(Object obj) {
+    		if (obj instanceof MyJavaVariable) {
+    			MyJavaVariable var = (MyJavaVariable) obj;
+    			return var.getName().equals(getName()) && var.getValue().equals(getValue());
+    		}
+    		return false;
+    	}
+
+    	public int hashCode() {
+    		return name.hashCode() + value.hashCode();
+    	}
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/DeleteLogAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/DeleteLogAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/DeleteLogAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.debug.actions;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.debug.AuditView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.custom.BusyIndicator;
+
+/**
+ * Action to clear the log.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class DeleteLogAction extends Action {
+    
+    private AuditView view;
+
+    public DeleteLogAction(AuditView view) {
+        super(null, IAction.AS_PUSH_BUTTON);
+        this.view = view;
+        setToolTipText("Clear Log");
+        setImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.DELETE_LOG));
+        setDisabledImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.DELETE_LOG_DISABLED));
+        setId(DroolsEclipsePlugin.getUniqueIdentifier() + ".ClearLogAction");
+    }
+
+    public void run() {
+        if (!view.isAvailable()) {
+            return;
+        }
+        view.deleteLog();  
+        BusyIndicator.showWhile(view.getViewer().getControl().getDisplay(), new Runnable() {
+            public void run() {
+            	view.getViewer().refresh();                    
+            }
+        });         
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/OpenLogAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/OpenLogAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/OpenLogAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,43 @@
+package org.drools.eclipse.debug.actions;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.debug.AuditView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.custom.BusyIndicator;
+import org.eclipse.swt.widgets.FileDialog;
+
+/**
+ * Action to open a log.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class OpenLogAction extends Action {
+    
+    private AuditView view;
+
+    public OpenLogAction(AuditView view) {
+        super(null, IAction.AS_PUSH_BUTTON);
+        this.view = view;
+        setToolTipText("Open Log");
+        setImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.OPEN_LOG));
+        setId(DroolsEclipsePlugin.getUniqueIdentifier() + ".OpenLogAction");
+    }
+
+    public void run() {
+        if (!view.isAvailable()) {
+            return;
+        }
+        FileDialog dialog = new FileDialog(view.getSite().getShell());
+        dialog.setFilterExtensions(new String[] { "*.log" });
+        String fileName = dialog.open();
+        view.setLogFile(fileName);  
+        BusyIndicator.showWhile(view.getViewer().getControl().getDisplay(), new Runnable() {
+            public void run() {
+            	view.getViewer().refresh();                    
+            }
+        });         
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/RefreshLogAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/RefreshLogAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/RefreshLogAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.debug.actions;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.debug.AuditView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.custom.BusyIndicator;
+
+/**
+ * Action to refresh the log.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class RefreshLogAction extends Action {
+    
+    private AuditView view;
+
+    public RefreshLogAction(AuditView view) {
+        super(null, IAction.AS_PUSH_BUTTON);
+        this.view = view;
+        setToolTipText("Refresh Log");
+        setImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.REFRESH_LOG));
+        setDisabledImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.REFRESH_LOG_DISABLED));
+        setId(DroolsEclipsePlugin.getUniqueIdentifier() + ".RefreshLogAction");
+    }
+
+    public void run() {
+        if (!view.isAvailable()) {
+            return;
+        }
+        view.refresh();  
+        BusyIndicator.showWhile(view.getViewer().getControl().getDisplay(), new Runnable() {
+            public void run() {
+            	view.getViewer().refresh();                    
+            }
+        });         
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowEventCauseAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowEventCauseAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowEventCauseAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,36 @@
+package org.drools.eclipse.debug.actions;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.debug.AuditView;
+import org.drools.eclipse.debug.AuditView.Event;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+
+/**
+ * Action to show the cause event of an audit event.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class ShowEventCauseAction extends Action {
+    
+    private AuditView view;
+
+    public ShowEventCauseAction(AuditView view) {
+        super(null, IAction.AS_PUSH_BUTTON);
+        this.view = view;
+        setToolTipText("Show Cause");
+        setText("Show Cause");
+        setId(DroolsEclipsePlugin.getUniqueIdentifier() + ".ShowEventCause");
+    }
+
+    public void run() {
+    	Event event = view.getSelectedEvent();
+    	if (event != null) {
+    		Event cause = event.getCauseEvent();
+    		if (cause != null) {
+    			view.showEvent(cause);
+    		}
+    	}
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowLogicalStructureAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowLogicalStructureAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/actions/ShowLogicalStructureAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,45 @@
+package org.drools.eclipse.debug.actions;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.debug.DroolsDebugEventHandlerView;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.swt.custom.BusyIndicator;
+
+/**
+ * Action to toggle the display of the logical structure of variables
+ * that are shown in the tree.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class ShowLogicalStructureAction extends Action {
+    
+    private DroolsDebugEventHandlerView view;
+
+    public ShowLogicalStructureAction(DroolsDebugEventHandlerView view) {
+        super(null, IAction.AS_CHECK_BOX);
+        this.view = view;
+        setToolTipText("Show Logical Structure");
+        setImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.IMG_LOGICAL));
+        setDisabledImageDescriptor(DroolsPluginImages.getImageDescriptor(DroolsPluginImages.IMG_LOGICAL_DISABLED));
+        setId(DroolsEclipsePlugin.getUniqueIdentifier() + ".ShowLogicalStructureAction");
+    }
+
+    public void run() {
+        valueChanged(isChecked());
+    }
+
+    private void valueChanged(boolean on) {
+        if (!view.isAvailable()) {
+            return;
+        }
+        view.setShowLogicalStructure(on);  
+        BusyIndicator.showWhile(view.getViewer().getControl().getDisplay(), new Runnable() {
+            public void run() {
+            	view.getViewer().refresh();                    
+            }
+        });         
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModel.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModel.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModel.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,39 @@
+package org.drools.eclipse.debug.core;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+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.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.jdt.debug.core.IJavaDebugTarget;
+
+import com.sun.jdi.VirtualMachine;
+
+public class DroolsDebugModel {
+	
+	private DroolsDebugModel() {
+	}
+
+	public static IDebugTarget newDebugTarget(ILaunch launch, VirtualMachine vm, String name, IProcess process, boolean allowTerminate, boolean allowDisconnect) {
+		return newDebugTarget(launch, vm, name, process, allowTerminate, allowDisconnect, true);
+	}
+	
+	public static IDebugTarget newDebugTarget(final ILaunch launch, final VirtualMachine vm, final String name, final IProcess process, final boolean allowTerminate, final boolean allowDisconnect, final boolean resume) {
+		final IJavaDebugTarget[] target = new IJavaDebugTarget[1];
+		IWorkspaceRunnable r = new IWorkspaceRunnable() {
+			public void run(IProgressMonitor m) {
+				target[0]= new DroolsDebugTarget(launch, vm, name, allowTerminate, allowDisconnect, process, resume);
+			}
+		};
+		try {
+			ResourcesPlugin.getWorkspace().run(r, null, 0, null);
+		} catch (CoreException exc) {
+			DroolsEclipsePlugin.log(exc);
+		}
+		return target[0];
+	}
+        
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModelPresentation.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModelPresentation.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugModelPresentation.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,24 @@
+package org.drools.eclipse.debug.core;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.jdt.internal.debug.ui.JDIModelPresentation;
+
+public class DroolsDebugModelPresentation extends JDIModelPresentation {
+
+	protected String getBreakpointText(IBreakpoint breakpoint) {
+		if (breakpoint instanceof DroolsLineBreakpoint) {
+			DroolsLineBreakpoint breakp = ((DroolsLineBreakpoint) breakpoint);
+            int lineNumber = breakp.getDRLLineNumber();
+            int real;
+            try {
+                real = breakp.getLineNumber();
+            } catch ( CoreException e ) {
+                return breakpoint.getMarker().getResource().getName() + " [line: " + lineNumber + "] real: NA!!"; 
+            }
+			return breakpoint.getMarker().getResource().getName() + " [line: " + lineNumber + "] real: "+real;
+		}
+		return super.getBreakpointText(breakpoint);
+	}
+	    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsDebugTarget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,905 @@
+package org.drools.eclipse.debug.core;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.eclipse.core.resources.IMarkerDelta;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.jdi.TimeoutException;
+import org.eclipse.jdt.debug.core.IJavaBreakpoint;
+import org.eclipse.jdt.internal.debug.core.IJDIEventListener;
+import org.eclipse.jdt.internal.debug.core.breakpoints.JavaBreakpoint;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugModelMessages;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+
+import com.sun.jdi.ClassType;
+import com.sun.jdi.IntegerValue;
+import com.sun.jdi.Method;
+import com.sun.jdi.ObjectCollectedException;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.StringReference;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.VMDisconnectedException;
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.event.ClassPrepareEvent;
+import com.sun.jdi.event.Event;
+import com.sun.jdi.event.MethodEntryEvent;
+import com.sun.jdi.event.ThreadDeathEvent;
+import com.sun.jdi.event.ThreadStartEvent;
+import com.sun.jdi.event.VMStartEvent;
+import com.sun.jdi.request.ClassPrepareRequest;
+import com.sun.jdi.request.EventRequest;
+import com.sun.jdi.request.EventRequestManager;
+import com.sun.jdi.request.MethodEntryRequest;
+
+public class DroolsDebugTarget extends JDIDebugTarget {
+
+    private ArrayList          fThreads;
+    private ThreadStartHandler fThreadStartHandler = null;
+    private boolean            fSuspended          = true;
+
+    public DroolsDebugTarget(ILaunch launch,
+                             VirtualMachine jvm,
+                             String name,
+                             boolean supportTerminate,
+                             boolean supportDisconnect,
+                             IProcess process,
+                             boolean resume) {
+        super( launch,
+               jvm,
+               name,
+               supportTerminate,
+               supportDisconnect,
+               process,
+               resume );
+    }
+
+    public void breakpointAdded(IBreakpoint breakpoint) {
+
+        try {
+            if ( breakpoint instanceof DroolsLineBreakpoint ) {
+                ((DroolsLineBreakpoint) breakpoint).setJavaBreakpointProperties();
+
+                final DroolsLineBreakpoint d = (DroolsLineBreakpoint) breakpoint;
+
+                if ( d.getDialectName().equals( MVELDialect.ID ) ) {
+                    //getBreakpoints().add( breakpoint );
+                    //super.breakpointAdded(breakpoint);
+
+                    Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
+                    if ( !handleriter.hasNext() ) {
+                        // Create class prepare request to add breakpoint after MVELDebugHanlder is loaded
+                        ClassPrepareRequest req = getEventRequestManager().createClassPrepareRequest();
+                        req.addClassFilter( "org.drools.base.mvel.MVELDebugHandler" );
+                        req.setSuspendPolicy( EventRequest.SUSPEND_ALL );
+
+                        addJDIEventListener( new IJDIEventListener() {
+
+                                                 public boolean handleEvent(Event event,
+                                                                            JDIDebugTarget target) {
+                                                     addRemoteBreakpoint( d );
+                                                     return true;
+                                                 }
+
+                                                 public void wonSuspendVote(Event event,
+                                                                            JDIDebugTarget target) {
+                                                 }
+
+                                             },
+                                             req );
+
+                        req.enable();
+                        return;
+                    }
+
+                    addRemoteBreakpoint( d );
+                } else {
+                    // only add breakpoint if setting Java properties of DRL
+                    // breakpoint does not generate an error
+                    super.breakpointAdded( breakpoint );
+                }
+            } else {
+                super.breakpointAdded( breakpoint );
+            }
+        } catch ( Throwable t ) {
+            // Exception will be thrown when trying to use breakpoint
+            // on drl that is incorrect (cannot be parsed or compiled)
+            DroolsEclipsePlugin.log( t );
+        }
+    }
+
+    protected synchronized void initialize() {
+        setThreadList( new ArrayList( 5 ) );
+        super.initialize();
+    }
+
+    protected JDIThread createThread(ThreadReference thread) {
+        JDIThread jdiThread = null;
+        try {
+            jdiThread = new DroolsThread( this,
+                                          thread );
+        } catch ( ObjectCollectedException exception ) {
+            // ObjectCollectionException can be thrown if the thread has already
+            // completed (exited) in the VM.
+            return null;
+        }
+        if ( isDisconnected() ) {
+            return null;
+        }
+        synchronized ( fThreads ) {
+            fThreads.add( jdiThread );
+        }
+        jdiThread.fireCreationEvent();
+        return jdiThread;
+    }
+
+    private Iterator getThreadIterator() {
+        List threadList;
+        synchronized ( fThreads ) {
+            threadList = (List) fThreads.clone();
+        }
+        return threadList.iterator();
+    }
+
+    private boolean hasSuspendedThreads() {
+        Iterator it = getThreadIterator();
+        while ( it.hasNext() ) {
+            IThread thread = (IThread) it.next();
+            if ( thread.isSuspended() ) return true;
+        }
+        return false;
+    }
+
+    public boolean canResume() {
+        return (isSuspended() || hasSuspendedThreads()) && isAvailable() && !isPerformingHotCodeReplace();
+    }
+
+    protected void resume(boolean fireNotification) throws DebugException {
+        if ( (!isSuspended() && !hasSuspendedThreads()) || !isAvailable() ) {
+            return;
+        }
+        try {
+            setSuspended( false );
+            resumeThreads();
+            VirtualMachine vm = getVM();
+            if ( vm != null ) {
+                vm.resume();
+            }
+            if ( fireNotification ) {
+                fireResumeEvent( DebugEvent.CLIENT_REQUEST );
+            }
+        } catch ( VMDisconnectedException e ) {
+            disconnected();
+            return;
+        } catch ( RuntimeException e ) {
+            setSuspended( true );
+            fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIDebugTarget_exception_resume,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+    }
+
+    private void setSuspended(boolean suspended) {
+        fSuspended = suspended;
+    }
+
+    public boolean isSuspended() {
+        return fSuspended;
+    }
+
+    private void setThreadList(ArrayList threads) {
+        fThreads = threads;
+    }
+
+    public IThread[] getThreads() {
+        synchronized ( fThreads ) {
+            return (IThread[]) fThreads.toArray( new IThread[0] );
+        }
+    }
+
+    protected void removeAllThreads() {
+        Iterator itr = getThreadIterator();
+        while ( itr.hasNext() ) {
+            DroolsThread child = (DroolsThread) itr.next();
+            child.terminated();
+        }
+        synchronized ( fThreads ) {
+            fThreads.clear();
+        }
+    }
+
+    protected void initializeRequests() {
+        setThreadStartHandler( new ThreadStartHandler() );
+        new ThreadDeathHandler();
+        new MVELTraceHandler();
+    }
+
+    class ThreadDeathHandler
+        implements
+        IJDIEventListener {
+
+        protected ThreadDeathHandler() {
+            createRequest();
+        }
+
+        /**
+         * Creates and registers a request to listen to thread
+         * death events.
+         */
+        protected void createRequest() {
+            EventRequestManager manager = getEventRequestManager();
+            if ( manager != null ) {
+                try {
+                    EventRequest req = manager.createThreadDeathRequest();
+                    req.setSuspendPolicy( EventRequest.SUSPEND_NONE );
+                    req.enable();
+                    addJDIEventListener( this,
+                                         req );
+                } catch ( RuntimeException e ) {
+                    logError( e );
+                }
+            }
+        }
+
+        /**
+         * Locates the model thread associated with the underlying JDI thread
+         * that has terminated, and removes it from the collection of
+         * threads belonging to this debug target. A terminate event is
+         * fired for the model thread.
+         *
+         * @param event a thread death event
+         * @param target the target in which the thread died
+         * @return <code>true</code> - the thread should be resumed
+         */
+        public boolean handleEvent(Event event,
+                                   JDIDebugTarget target) {
+            ThreadReference ref = ((ThreadDeathEvent) event).thread();
+            DroolsThread thread = (DroolsThread) findThread( ref );
+            if ( thread != null ) {
+                synchronized ( fThreads ) {
+                    fThreads.remove( thread );
+                }
+                thread.terminated();
+            }
+            return true;
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
+         */
+        public void wonSuspendVote(Event event,
+                                   JDIDebugTarget target) {
+            // do nothing
+        }
+
+    }
+
+    class ThreadStartHandler
+        implements
+        IJDIEventListener {
+
+        protected EventRequest fRequest;
+
+        protected ThreadStartHandler() {
+            createRequest();
+        }
+
+        /**
+         * Creates and registers a request to handle all thread start
+         * events
+         */
+        protected void createRequest() {
+            EventRequestManager manager = getEventRequestManager();
+            if ( manager != null ) {
+                try {
+                    EventRequest req = manager.createThreadStartRequest();
+                    req.setSuspendPolicy( EventRequest.SUSPEND_NONE );
+                    req.enable();
+                    addJDIEventListener( this,
+                                         req );
+                    setRequest( req );
+                } catch ( RuntimeException e ) {
+                    logError( e );
+                }
+            }
+        }
+
+        /**
+         * Creates a model thread for the underlying JDI thread
+         * and adds it to the collection of threads for this
+         * debug target. As a side effect of creating the thread,
+         * a create event is fired for the model thread.
+         * The event is ignored if the underlying thread is already
+         * marked as collected.
+         *
+         * @param event a thread start event
+         * @param target the target in which the thread started
+         * @return <code>true</code> - the thread should be resumed
+         */
+        public boolean handleEvent(Event event,
+                                   JDIDebugTarget target) {
+            ThreadReference thread = ((ThreadStartEvent) event).thread();
+            try {
+                if ( thread.isCollected() ) {
+                    return false;
+                }
+            } catch ( VMDisconnectedException exception ) {
+                return false;
+            } catch ( ObjectCollectedException e ) {
+                return false;
+            } catch ( TimeoutException e ) {
+                // continue - attempt to create the thread
+            }
+            DroolsThread jdiThread = (DroolsThread) findThread( thread );
+            if ( jdiThread == null ) {
+                jdiThread = (DroolsThread) createThread( thread );
+                if ( jdiThread == null ) {
+                    return false;
+                }
+            } else {
+                jdiThread.disposeStackFrames();
+                jdiThread.fireChangeEvent( DebugEvent.CONTENT );
+            }
+            return !jdiThread.isSuspended();
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
+         */
+        public void wonSuspendVote(Event event,
+                                   JDIDebugTarget target) {
+            // do nothing
+        }
+
+        /**
+         * Deregisters this event listener.
+         */
+        protected void deleteRequest() {
+            if ( getRequest() != null ) {
+                removeJDIEventListener( this,
+                                        getRequest() );
+                setRequest( null );
+            }
+        }
+
+        protected EventRequest getRequest() {
+            return fRequest;
+        }
+
+        protected void setRequest(EventRequest request) {
+            fRequest = request;
+        }
+    }
+
+    private void disposeThreadHandler() {
+        ThreadStartHandler handler = getThreadStartHandler2();
+        if ( handler != null ) {
+            handler.deleteRequest();
+        }
+    }
+
+    public boolean hasThreads() {
+        return fThreads.size() > 0;
+    }
+
+    protected ThreadStartHandler getThreadStartHandler2() {
+        return fThreadStartHandler;
+    }
+
+    protected void setThreadStartHandler(ThreadStartHandler threadStartHandler) {
+        fThreadStartHandler = threadStartHandler;
+    }
+
+    public boolean isOutOfSynch() throws DebugException {
+        Iterator threads = getThreadIterator();
+        while ( threads.hasNext() ) {
+            JDIThread thread = (JDIThread) threads.next();
+            if ( thread.isOutOfSynch() ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public boolean mayBeOutOfSynch() {
+        Iterator threads = getThreadIterator();
+        while ( threads.hasNext() ) {
+            JDIThread thread = (JDIThread) threads.next();
+            if ( thread.mayBeOutOfSynch() ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    public JDIThread findThread(ThreadReference tr) {
+        Iterator iter = getThreadIterator();
+        while ( iter.hasNext() ) {
+            JDIThread thread = (JDIThread) iter.next();
+            if ( thread.getUnderlyingThread().equals( tr ) ) return thread;
+        }
+        return null;
+    }
+
+    public void breakpointRemoved(IBreakpoint breakpoint,
+                                  IMarkerDelta delta) {
+        if ( !isAvailable() ) {
+            return;
+        }
+        if ( supportsBreakpoint( breakpoint ) ) {
+            try {
+
+                if ( breakpoint instanceof DroolsLineBreakpoint ) {
+                    ((DroolsLineBreakpoint) breakpoint).setJavaBreakpointProperties();
+
+                    final DroolsLineBreakpoint d = (DroolsLineBreakpoint) breakpoint;
+
+                    if ( d.getDialectName().equals( MVELDialect.ID ) ) {
+                        removeRemoteBreakpoint( (DroolsLineBreakpoint) breakpoint,
+                                                delta );
+                    }
+                }
+
+                ((JavaBreakpoint) breakpoint).removeFromTarget( this );
+                getBreakpoints().remove( breakpoint );
+                Iterator threads = getThreadIterator();
+                while ( threads.hasNext() ) {
+                    ((DroolsThread) threads.next()).removeCurrentBreakpoint( breakpoint );
+                }
+            } catch ( CoreException e ) {
+                logError( e );
+            }
+        }
+    }
+
+    protected void suspendThreads() {
+        Iterator threads = getThreadIterator();
+        while ( threads.hasNext() ) {
+            ((DroolsThread) threads.next()).suspendedByVM();
+        }
+    }
+
+    protected void resumeThreads() throws DebugException {
+        Iterator threads = getThreadIterator();
+        while ( threads.hasNext() ) {
+            ((DroolsThread) threads.next()).resumedByVM();
+        }
+    }
+
+    public void disconnect() throws DebugException {
+
+        if ( !isAvailable() ) {
+            // already done
+            return;
+        }
+
+        if ( !canDisconnect() ) {
+            notSupported( JDIDebugModelMessages.JDIDebugTarget_does_not_support_disconnect );
+        }
+
+        try {
+            disposeThreadHandler();
+            VirtualMachine vm = getVM();
+            if ( vm != null ) {
+                vm.dispose();
+            }
+        } catch ( VMDisconnectedException e ) {
+            // if the VM disconnects while disconnecting, perform
+            // normal disconnect handling
+            disconnected();
+        } catch ( RuntimeException e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIDebugTarget_exception_disconnecting,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+
+    }
+
+    public void terminate() throws DebugException {
+        if ( !isAvailable() ) {
+            return;
+        }
+        if ( !supportsTerminate() ) {
+            notSupported( JDIDebugModelMessages.JDIDebugTarget_does_not_support_termination );
+        }
+        try {
+            setTerminating( true );
+            disposeThreadHandler();
+            VirtualMachine vm = getVM();
+            if ( vm != null ) {
+                vm.exit( 1 );
+            }
+            IProcess process = getProcess();
+            if ( process != null ) {
+                process.terminate();
+            }
+        } catch ( VMDisconnectedException e ) {
+            // if the VM disconnects while exiting, perform
+            // normal termination processing
+            terminated();
+        } catch ( TimeoutException exception ) {
+            // if there is a timeout see if the associated process is terminated
+            IProcess process = getProcess();
+            if ( process != null && process.isTerminated() ) {
+                terminated();
+            } else {
+                // All we can do is disconnect
+                disconnected();
+            }
+        } catch ( RuntimeException e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIDebugTarget_exception_terminating,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+    }
+
+    public void handleVMStart(VMStartEvent event) {
+        if ( isResumeOnStartup() ) {
+            try {
+                setSuspended( true );
+                resume();
+            } catch ( DebugException e ) {
+                logError( e );
+            }
+        }
+        // If any threads have resumed since thread collection was initialized,
+        // update their status (avoid concurrent modification - use #getThreads())
+        IThread[] threads = getThreads();
+        for ( int i = 0; i < threads.length; i++ ) {
+            DroolsThread thread = (DroolsThread) threads[i];
+            if ( thread.isSuspended() ) {
+                try {
+                    boolean suspended = thread.getUnderlyingThread().isSuspended();
+                    if ( !suspended ) {
+                        thread.setRunning( true );
+                        thread.fireResumeEvent( DebugEvent.CLIENT_REQUEST );
+                    }
+                } catch ( VMDisconnectedException e ) {
+                } catch ( ObjectCollectedException e ) {
+                } catch ( RuntimeException e ) {
+                    logError( e );
+                }
+            }
+        }
+    }
+
+    protected void initializeState() {
+
+        List threads = null;
+        VirtualMachine vm = getVM();
+        if ( vm != null ) {
+            try {
+                threads = vm.allThreads();
+            } catch ( RuntimeException e ) {
+                internalError( e );
+            }
+            if ( threads != null ) {
+                Iterator initialThreads = threads.iterator();
+                while ( initialThreads.hasNext() ) {
+                    createThread( (ThreadReference) initialThreads.next() );
+                }
+            }
+        }
+
+        if ( isResumeOnStartup() ) {
+            setSuspended( false );
+        }
+    }
+
+    public void suspend() throws DebugException {
+        if ( isSuspended() ) {
+            return;
+        }
+        try {
+            VirtualMachine vm = getVM();
+            if ( vm != null ) {
+                vm.suspend();
+            }
+            suspendThreads();
+            setSuspended( true );
+            fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
+        } catch ( RuntimeException e ) {
+            setSuspended( false );
+            fireResumeEvent( DebugEvent.CLIENT_REQUEST );
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIDebugTarget_exception_suspend,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+    }
+
+    public void prepareToSuspendByBreakpoint(JavaBreakpoint breakpoint) {
+        setSuspended( true );
+        suspendThreads();
+    }
+
+    protected void cancelSuspendByBreakpoint(JavaBreakpoint breakpoint) throws DebugException {
+        setSuspended( false );
+        resumeThreads();
+    }
+
+    class MVELTraceHandler
+        implements
+        IJDIEventListener {
+
+        protected MVELTraceHandler() {
+            createRequest();
+        }
+
+        protected void createRequest() {
+            EventRequestManager manager = getEventRequestManager();
+            if ( manager != null ) {
+                try {
+                    ClassPrepareRequest req = manager.createClassPrepareRequest();
+                    req.addClassFilter( "org.drools.base.mvel.MVELDebugHandler" );
+                    req.setSuspendPolicy( EventRequest.SUSPEND_ALL );
+                    addJDIEventListener( MVELTraceHandler.this,
+                                         req );
+                    req.enable();
+
+                } catch ( RuntimeException e ) {
+                    logError( e );
+                }
+            }
+        }
+
+        /**
+         * Locates the model thread associated with the underlying JDI thread
+         * that has terminated, and removes it from the collection of
+         * threads belonging to this debug target. A terminate event is
+         * fired for the model thread.
+         *
+         * @param event a thread death event
+         * @param target the target in which the thread died
+         * @return <code>true</code> - the thread should be resumed
+         */
+        public boolean handleEvent(Event event,
+                                   JDIDebugTarget target) {
+            String name = ((ClassPrepareEvent) event).referenceType().name();
+
+            MethodEntryRequest req = getEventRequestManager().createMethodEntryRequest();
+            req.addClassFilter( ((ClassPrepareEvent) event).referenceType() );
+
+            //breakpointCatched
+
+            /*field= type.fieldByName(getFieldName());
+             Field field;
+             EventRequest req= manager.createModificationWatchpointRequest(field);
+             */
+            req.setSuspendPolicy( EventRequest.SUSPEND_EVENT_THREAD );
+            addJDIEventListener( new IJDIEventListener() {
+
+                                     public boolean handleEvent(Event event,
+                                                                JDIDebugTarget target) {
+                                         MethodEntryEvent entryEvent = (MethodEntryEvent) event;
+
+                                         String name2 = entryEvent.method().name();
+
+                                         if ( !name2.equals( "onBreak" ) && !name2.equals( "receiveBreakpoints" ) ) {
+                                             //event.virtualMachine().resume();
+                                             return true;
+                                         }
+
+                                         try {
+                                             IThread[] tharr = getThreads();
+
+                                             ThreadReference t = null;
+                                             DroolsThread t2 = null;
+
+                                             for ( int i = 0; i < tharr.length; i++ ) {
+                                                 DroolsThread th2 = (DroolsThread) tharr[i];
+                                                 ThreadReference th2real = ((DroolsThread) tharr[i]).getUnderlyingThread();
+
+                                                 if ( th2real.suspendCount() == 1 && th2.getName().equals( "main" ) ) {
+                                                     t = th2real;
+                                                     t2 = (DroolsThread) th2;
+
+                                                     th2real.suspend();
+                                                     th2.setRunning( false );
+                                                     th2.fireSuspendEvent( DebugEvent.CLIENT_REQUEST );
+
+                                                     return true;
+                                                 }
+                                             }
+                                         } catch ( Exception t ) {
+                                             logError( t );
+                                         }
+                                         return true;
+
+                                     }
+
+                                     public void wonSuspendVote(Event event,
+                                                                JDIDebugTarget target) {
+
+                                     }
+
+                                 },
+                                 req );
+
+            req.enable();
+
+            return true;
+        }
+
+        /* (non-Javadoc)
+         * @see org.eclipse.jdt.internal.debug.core.IJDIEventListener#wonSuspendVote(com.sun.jdi.event.Event, org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget)
+         */
+        public void wonSuspendVote(Event event,
+                                   JDIDebugTarget target) {
+            // do nothing
+        }
+
+    }
+
+    /**
+     * Tries to find a match for the provided breakpoint information from the list of registered breakpoints.
+     * For stepping and possibly other purposes it returns also a breakpoint for cases where exactly the same line was not found.
+     * 
+     * If breakpoint is not found for <code>line</code> at <code>source</code> then it takes the first line that is above the
+     * specified line at the same file.
+     * 
+     * @param source
+     * @param line
+     * @return
+     */
+    public DroolsLineBreakpoint getDroolsBreakpoint(String source) {
+
+        if ( source == null ) {
+            return null;
+        }
+
+        Iterator iterator = getBreakpoints().iterator();
+        while ( iterator.hasNext() ) {
+            IJavaBreakpoint element = (IJavaBreakpoint) iterator.next();
+            if ( element instanceof DroolsLineBreakpoint && ((DroolsLineBreakpoint) element).getDialectName().equals( MVELDialect.ID ) ) {
+                DroolsLineBreakpoint l = (DroolsLineBreakpoint) element;
+                try {
+
+                    int matchLine = l.getLineNumber();
+                    String matchSource = l.getRuleName();
+
+                    if ( source.equals( matchSource ) || l.getFileRuleMappings().containsKey( source ) ) {
+                        return l;
+                    }
+
+                } catch ( CoreException e ) {
+                    logError( e );
+                }
+            }
+        }
+
+        return null;
+    }
+
+    private void addRemoteBreakpoint(DroolsLineBreakpoint d) {
+
+        try {
+            if ( !d.isEnabled() ) {
+                return; // No need to install disabled breakpoints
+            }
+        } catch ( CoreException e2 ) {
+            logError( e2 );
+            return; // No need to install breakpoints that are this much broken
+        }
+
+        Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
+        Object debugHandlerClass = handleriter.next();
+
+        int line;
+        String sourceName;
+
+        try {
+            line = d.getLineNumber();
+            sourceName = d.getTypeName();
+        } catch ( CoreException e1 ) {
+            logError( e1 );
+            return;
+        }
+
+        ReferenceType refType = (ReferenceType) debugHandlerClass;
+        Method m = (Method) refType.methodsByName( "registerBreakpoint" ).iterator().next();
+        List args = new ArrayList();
+        IntegerValue lineVal = getVM().mirrorOf( line );
+        StringReference nameVal = getVM().mirrorOf( sourceName );
+        JDIObjectValue val = (JDIObjectValue) newValue( sourceName );
+        ObjectReference realVal = val.getUnderlyingObject();
+        args.add( nameVal );
+        args.add( lineVal );
+
+        try {
+            ClassType tt = (ClassType) debugHandlerClass;
+            IThread[] tharr = getThreads();
+            ThreadReference t = null;
+            DroolsThread t2 = null;
+
+            for ( int i = 0; i < tharr.length; i++ ) {
+                IThread th2 = tharr[i];
+                ThreadReference th2real = ((DroolsThread) tharr[i]).getUnderlyingThread();
+
+                if ( th2real.suspendCount() == 1 && th2.getName().equals( "main" ) ) {
+                    t = th2real;
+                    t2 = (DroolsThread) th2;
+                }
+            }
+
+            tt.invokeMethod( t,
+                             m,
+                             args,
+                             ObjectReference.INVOKE_SINGLE_THREADED );
+            //t2.computeNewStackFrames();
+
+            super.breakpointAdded( d );
+
+        } catch ( Exception e ) {
+            logError( e );
+        }
+
+    }
+
+    private void removeRemoteBreakpoint(DroolsLineBreakpoint d,
+                                        IMarkerDelta delta) {
+        Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
+        Object debugHandlerClass = handleriter.next();
+
+        int line;
+        String sourceName;
+
+        try {
+            line = d.getLineNumber();
+            sourceName = d.getTypeName();
+        } catch ( CoreException e1 ) {
+            logError( e1 );
+            return;
+        }
+
+        ReferenceType refType = (ReferenceType) debugHandlerClass;
+        Method m = (Method) refType.methodsByName( "removeBreakpoint" ).iterator().next();
+        List args = new ArrayList();
+        IntegerValue lineVal = getVM().mirrorOf( line );
+        StringReference nameVal = getVM().mirrorOf( sourceName );
+        JDIObjectValue val = (JDIObjectValue) newValue( sourceName );
+        ObjectReference realVal = val.getUnderlyingObject();
+        args.add( nameVal );
+        args.add( lineVal );
+
+        try {
+            ClassType tt = (ClassType) debugHandlerClass;
+            IThread[] tharr = getThreads();
+            ThreadReference t = null;
+            DroolsThread t2 = null;
+
+            for ( int i = 0; i < tharr.length; i++ ) {
+                IThread th2 = tharr[i];
+                ThreadReference th2real = ((DroolsThread) tharr[i]).getUnderlyingThread();
+
+                if ( th2real.suspendCount() == 1 && th2.getName().equals( "main" ) ) {
+                    t = th2real;
+                    t2 = (DroolsThread) th2;
+                }
+            }
+
+            tt.invokeMethod( t,
+                             m,
+                             args,
+                             ObjectReference.INVOKE_SINGLE_THREADED );
+
+        } catch ( Exception e ) {
+            logError( e );
+        }
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpoint.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpoint.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpoint.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,174 @@
+package org.drools.eclipse.debug.core;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.internal.debug.core.breakpoints.JavaLineBreakpoint;
+
+public class DroolsLineBreakpoint extends JavaLineBreakpoint {
+
+    private static final String DIALECT = "org.drools.eclipse.debug.core.breakpointDialect";
+
+    /**
+     * Default constructor is required for the breakpoint manager
+     * to re-create persisted breakpoints. After instantiating a breakpoint,
+     * the <code>setMarker(...)</code> method is called to restore
+     * this breakpoint's attributes.
+     */
+    public DroolsLineBreakpoint() {
+        super();
+    }
+
+    /**
+     * Constructs a line breakpoint on the given resource at the given
+     * line number.
+     *
+     * @param resource file on which to set the breakpoint
+     * @param lineNumber line number of the breakpoint
+     * @throws CoreException if unable to create the breakpoint
+     */
+    public DroolsLineBreakpoint(IResource resource, int lineNumber)
+			throws CoreException {
+        super( resource, "", -1, -1, -1, 0, true,
+            createAttributesMap( lineNumber ), IDroolsDebugConstants.DROOLS_MARKER_TYPE );
+        setJavaBreakpointProperties();
+    }
+
+    private static Map createAttributesMap(int lineNumber) {
+        Map map = new HashMap();
+        map.put( IDroolsDebugConstants.DRL_LINE_NUMBER, new Integer( lineNumber ) );
+        return map;
+    }
+
+    public int getDRLLineNumber() {
+        return getMarker().getAttribute( IDroolsDebugConstants.DRL_LINE_NUMBER, -1 );
+    }
+
+    public String getModelIdentifier() {
+        return IDroolsDebugConstants.ID_DROOLS_DEBUG_MODEL;
+    }
+
+    public String getDialectName() {
+        return getMarker().getAttribute( DIALECT, "Unknown");
+    }
+
+    public Map getFileRuleMappings() {
+        String packedInfo = getMarker().getAttribute( IDroolsDebugConstants.DRL_RULES, "");
+        return unpackRuleMapping( packedInfo );
+    }
+
+    public void setJavaBreakpointProperties() throws CoreException {
+        IMarker marker = getMarker();
+        int drlLineNumber = getDRLLineNumber();
+        if ( marker.exists() ) {
+            try {
+                DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource( marker.getResource(), true );
+
+                RuleInfo[] ruleInfos = drlInfo.getRuleInfos();
+
+                StringBuffer rb = new StringBuffer();
+                for (int i=0;i<ruleInfos.length; i++) {
+                    int line = ruleInfos[i].getConsequenceDrlLineNumber();
+                    String ruleid = ruleInfos[i].getClassName()+":"+line;
+                    rb.append(ruleid);
+                    if (i<ruleInfos.length-1) {
+                        rb.append(";");
+                    }
+                }
+
+                marker.setAttribute( IDroolsDebugConstants.DRL_RULES, rb.toString());
+
+                marker.setAttribute( TYPE_NAME, getRuleClassName( drlInfo, marker.getResource().toString(), drlLineNumber ) );
+                int ruleLineNumber = getRuleLineNumber( drlInfo, marker.getResource().toString(), drlLineNumber );
+                marker.setAttribute( IMarker.LINE_NUMBER, ruleLineNumber );
+                marker.setAttribute( DIALECT, getDialect( drlInfo, drlLineNumber ) );
+
+            } catch ( Throwable t ) {
+                throw new CoreException( new Status( IStatus.ERROR, DroolsEclipsePlugin.getUniqueIdentifier(), 0,
+                                                     "Cannot determine ruleInfo " + marker.getResource() + " " + drlLineNumber, t ) );
+            }
+        }
+    }
+
+    private String getDialect(DRLInfo info, int drlLineNumber) {
+        if ( info != null ) {
+            return info.getRuleInfo( drlLineNumber ).getDialect().getId();
+        }
+        return null;
+    }
+
+    private String getRuleClassName(DRLInfo drlInfo, String resource, int lineNumber) throws CoreException {
+        if ( drlInfo != null ) {
+            RuleInfo ruleInfo = drlInfo.getRuleInfo( lineNumber );
+            if ( ruleInfo != null ) {
+                return ruleInfo.getClassName();
+            }
+            FunctionInfo functionInfo = drlInfo.getFunctionInfo( lineNumber );
+            if ( functionInfo != null ) {
+                return functionInfo.getClassName();
+            }
+        }
+        throw new CoreException( new Status( IStatus.ERROR, DroolsEclipsePlugin.getUniqueIdentifier(), 0,
+                                             "Cannot determine ruleClassName for " + resource + " " + lineNumber, null ) );
+    }
+
+    private int getRuleLineNumber(DRLInfo drlInfo, String resource, int lineNumber) throws CoreException {
+        if ( drlInfo != null ) {
+            RuleInfo ruleInfo = drlInfo.getRuleInfo( lineNumber );
+            if ( ruleInfo != null ) {
+                if ( ruleInfo.getConsequenceDrlLineNumber() < lineNumber ) {
+
+                    int line = ruleInfo.getConsequenceJavaLineNumber()
+                                        	+ (lineNumber - ruleInfo.getConsequenceDrlLineNumber());
+                    if (ruleInfo.getDialect().getId().equals( MVELDialect.ID )) {
+                        return line;
+                    }
+                    return line+1;
+                }
+            }
+            FunctionInfo functionInfo = drlInfo.getFunctionInfo( lineNumber );
+            if ( functionInfo != null ) {
+                return functionInfo.getJavaLineNumber()
+                	+ (lineNumber - functionInfo.getDrlLineNumber());
+            }
+        }
+        throw new CoreException( new Status( IStatus.ERROR, DroolsEclipsePlugin.getUniqueIdentifier(), 0,
+                                             "Cannot determine ruleLineNumber for " + resource + " " + lineNumber, null ) );
+    }
+
+    public String getRuleName() {
+        IMarker marker = getMarker();
+        if ( marker.exists() ) {
+                try {
+                    return (String) marker.getAttribute( TYPE_NAME);
+                } catch ( CoreException e ) {
+                    DroolsEclipsePlugin.log( e );
+                }
+        }
+        return null;
+    }
+
+    private final static Map unpackRuleMapping(String input) {
+        Map map = new HashMap();
+        String[] rules = input.split( "\\;");
+        for (int i=0; i<rules.length; i++) {
+            if (rules[i].length()>0) {
+                String[] inf = rules[i].split( "\\:" );
+                map.put( inf[0], Integer.valueOf( inf[1] ) );
+            }
+        }
+        return map;
+    }
+
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpointMarkerUpdater.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpointMarkerUpdater.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLineBreakpointMarkerUpdater.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,61 @@
+package org.drools.eclipse.debug.core;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.Position;
+import org.eclipse.ui.texteditor.IMarkerUpdater;
+import org.eclipse.ui.texteditor.MarkerUtilities;
+
+public class DroolsLineBreakpointMarkerUpdater implements IMarkerUpdater {
+
+	private static final String[] ATTRIBUTES = { 
+		IMarker.LINE_NUMBER, 
+		IDroolsDebugConstants.DRL_LINE_NUMBER 
+	};
+	
+	public String getMarkerType() {
+		// responsible for only Drools line breakpoint markers
+		return IDroolsDebugConstants.DROOLS_MARKER_TYPE;
+	}
+
+	public String[] getAttribute() {
+		return ATTRIBUTES;
+	}
+
+	public boolean updateMarker(IMarker marker, IDocument document, Position position) {
+		if (position == null) {
+			return true;
+		}
+		if (position.isDeleted()) {
+			return false;
+		}
+		boolean offsetsInitialized = false;
+		boolean offsetsChanged = false;
+		int markerStart = MarkerUtilities.getCharStart(marker);
+		int markerEnd = MarkerUtilities.getCharEnd(marker);
+		if (markerStart != -1 && markerEnd != -1) {
+			offsetsInitialized = true;
+			int offset = position.getOffset();
+			if (markerStart != offset) {
+				MarkerUtilities.setCharStart(marker, offset);
+				offsetsChanged= true;
+			}
+			offset += position.getLength();
+			if (markerEnd != offset) {
+				MarkerUtilities.setCharEnd(marker, offset);
+				offsetsChanged= true;
+			}
+		}
+		if (!offsetsInitialized || (offsetsChanged && MarkerUtilities.getLineNumber(marker) != -1)) {
+			try {
+				int drlLineNumber = document.getLineOfOffset(position.getOffset()) + 1;
+				marker.setAttribute(IDroolsDebugConstants.DRL_LINE_NUMBER, drlLineNumber);
+			} catch (Throwable t) {
+				DroolsEclipsePlugin.log(t);
+			}
+		}
+		return true;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLocalVariable.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLocalVariable.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsLocalVariable.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,22 @@
+package org.drools.eclipse.debug.core;
+
+import org.eclipse.jdt.internal.debug.core.model.JDILocalVariable;
+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+
+import com.sun.jdi.LocalVariable;
+
+public class DroolsLocalVariable extends JDILocalVariable {
+	
+	public DroolsLocalVariable(JDIStackFrame frame, LocalVariable local) {
+		super(frame, local);
+	}
+
+	protected void setLocal(LocalVariable local) {
+		super.setLocal(local);
+	}
+	
+	protected LocalVariable getLocal() {
+		return super.getLocal();
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsStackFrame.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsStackFrame.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsStackFrame.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,639 @@
+package org.drools.eclipse.debug.core;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IThread;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdt.debug.core.IJavaStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.debug.core.IJavaVariable;
+import org.eclipse.jdt.internal.debug.core.JDIDebugPlugin;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugModelMessages;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIFieldVariable;
+import org.eclipse.jdt.internal.debug.core.model.JDILocalVariable;
+import org.eclipse.jdt.internal.debug.core.model.JDIReferenceType;
+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+
+import com.ibm.icu.text.MessageFormat;
+import com.sun.jdi.AbsentInformationException;
+import com.sun.jdi.Field;
+import com.sun.jdi.LocalVariable;
+import com.sun.jdi.Location;
+import com.sun.jdi.Method;
+import com.sun.jdi.NativeMethodException;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.StackFrame;
+
+public class DroolsStackFrame extends JDIStackFrame {
+
+    private static final String CONSEQUENCE_SIGNATURE = "(Lorg/drools/spi/KnowledgeHelper";
+
+    private DroolsThread        fThread;
+    private Location            fLocation;
+    private List                fVariables;
+    private boolean             fRefreshVariables     = true;
+    private int                 fDepth                = -2;
+    private boolean             initialized           = true;
+    private StackFrame          fStackFrame;
+    private ObjectReference     fThisObject;
+    private String              fReceivingTypeName;
+    private boolean             fLocalsAvailable      = true;
+
+    public DroolsStackFrame(DroolsThread thread,
+                            StackFrame frame,
+                            int depth) {
+        super( thread,
+               frame,
+               depth );
+        bind( frame,
+              depth );
+    }
+
+    public boolean isExecutingRule() {
+        try {
+            if ( "consequence".equals( getMethodName() ) && getSignature().startsWith( CONSEQUENCE_SIGNATURE ) ) {
+                return true;
+            }
+        } catch ( DebugException exc ) {
+            DroolsEclipsePlugin.log( exc );
+        }
+        return false;
+    }
+
+    public RuleInfo getExecutingRuleInfo() {
+        try {
+            String methodName = getMethodName();
+            String signature = getSignature();
+            String type = getDeclaringTypeName();
+            if ( "consequence".equals( methodName ) && signature.startsWith( CONSEQUENCE_SIGNATURE ) ) {
+                return DroolsEclipsePlugin.getDefault().getRuleInfoByClass( type );
+            }
+
+        } catch ( DebugException exc ) {
+            DroolsEclipsePlugin.log( exc );
+        }
+        return null;
+    }
+
+    public FunctionInfo getExecutingFunctionInfo() {
+        try {
+            return DroolsEclipsePlugin.getDefault().getFunctionInfoByClass( getDeclaringTypeName() );
+        } catch ( DebugException exc ) {
+            DroolsEclipsePlugin.log( exc );
+        }
+        return null;
+    }
+
+    public int getLineNumber() throws DebugException {
+        synchronized ( fThread ) {
+            RuleInfo ruleInfo = getExecutingRuleInfo();
+            if ( ruleInfo != null ) {
+                return ruleInfo.getConsequenceDrlLineNumber() + (getInternalLineNumber() - ruleInfo.getConsequenceJavaLineNumber() - 1);
+            }
+            FunctionInfo functionInfo = getExecutingFunctionInfo();
+            if ( functionInfo != null ) {
+                return functionInfo.getDrlLineNumber() + (getInternalLineNumber() - functionInfo.getJavaLineNumber());
+            }
+        }
+
+        return getInternalLineNumber();
+    }
+
+    private int getInternalLineNumber() throws DebugException {
+        try {
+            return fLocation.lineNumber();
+        } catch ( RuntimeException e ) {
+            if ( getThread().isSuspended() ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number,
+                                                           new String[]{e.toString()} ),
+                                     e );
+            }
+        }
+        return -1;
+    }
+
+    public IVariable[] getVariables() throws DebugException {
+        IVariable[] variables = super.getVariables();
+        List result = new ArrayList( (variables.length - 1) / 2 );
+        for ( int i = 0; i < variables.length; i++ ) {
+            String name = variables[i].getName();
+            if ( !(name.equals( "drools" )) && !(name.endsWith( "__Handle__" )) ) {
+                result.add( variables[i] );
+            }
+        }
+        return (IVariable[]) result.toArray( new IVariable[result.size()] );
+    }
+
+    protected List getVariables0() throws DebugException {
+        synchronized ( fThread ) {
+            if ( fVariables == null ) {
+
+                // throw exception if native method, so variable view will update
+                // with information message
+                if ( isNative() ) {
+                    requestFailed( JDIDebugModelMessages.JDIStackFrame_Variable_information_unavailable_for_native_methods,
+                                   null );
+                }
+
+                Method method = getUnderlyingMethod();
+                fVariables = new ArrayList();
+                // #isStatic() does not claim to throw any exceptions - so it is not try/catch coded
+                if ( method.isStatic() ) {
+                    // add statics
+                    List allFields = null;
+                    ReferenceType declaringType = method.declaringType();
+                    try {
+                        allFields = declaringType.allFields();
+                    } catch ( RuntimeException e ) {
+                        targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_fields,
+                                                                   new String[]{e.toString()} ),
+                                             e );
+                        // execution will not reach this line, as 
+                        // #targetRequestFailed will throw an exception					
+                        return Collections.EMPTY_LIST;
+                    }
+                    if ( allFields != null ) {
+                        Iterator fields = allFields.iterator();
+                        while ( fields.hasNext() ) {
+                            Field field = (Field) fields.next();
+                            if ( field.isStatic() ) {
+                                fVariables.add( new JDIFieldVariable( (JDIDebugTarget) getDebugTarget(),
+                                                                      field,
+                                                                      declaringType ) );
+                            }
+                        }
+                        Collections.sort( fVariables,
+                                          new Comparator() {
+                                              public int compare(Object a,
+                                                                 Object b) {
+                                                  JDIFieldVariable v1 = (JDIFieldVariable) a;
+                                                  JDIFieldVariable v2 = (JDIFieldVariable) b;
+                                                  try {
+                                                      return v1.getName().compareToIgnoreCase( v2.getName() );
+                                                  } catch ( DebugException de ) {
+                                                      logError( de );
+                                                      return -1;
+                                                  }
+                                              }
+                                          } );
+                    }
+                } else {
+                    // add "this"
+                    ObjectReference t = getUnderlyingThisObject();
+                    if ( t != null ) {
+                        fVariables.add( new DroolsThisVariable( (JDIDebugTarget) getDebugTarget(),
+                                                                t ) );
+                    }
+                }
+                // add locals
+                Iterator variables = getUnderlyingVisibleVariables().iterator();
+                while ( variables.hasNext() ) {
+                    LocalVariable var = (LocalVariable) variables.next();
+                    fVariables.add( new DroolsLocalVariable( this,
+                                                             var ) );
+                }
+            } else if ( fRefreshVariables ) {
+                updateVariables();
+            }
+            fRefreshVariables = false;
+            return fVariables;
+        }
+    }
+
+    protected JDIStackFrame bind(StackFrame frame,
+                                 int depth) {
+        if ( initialized ) {
+            synchronized ( fThread ) {
+                if ( fDepth == -2 ) {
+                    // first initialization
+                    fStackFrame = frame;
+                    fDepth = depth;
+                    fLocation = frame.location();
+                    return this;
+                } else if ( depth == -1 ) {
+                    // mark as invalid
+                    fDepth = -1;
+                    fStackFrame = null;
+                    return null;
+                } else if ( fDepth == depth ) {
+                    Location location = frame.location();
+                    Method method = location.method();
+                    if ( method.equals( fLocation.method() ) ) {
+                        try {
+                            if ( method.declaringType().defaultStratum().equals( "Java" ) || //$NON-NLS-1$
+                                 equals( getSourceName( location ),
+                                         getSourceName( fLocation ) ) ) {
+                                // TODO: what about receiving type being the same?
+                                fStackFrame = frame;
+                                fLocation = location;
+                                clearCachedData();
+                                return this;
+                            }
+                        } catch ( DebugException e ) {
+                        }
+                    }
+                }
+                // invalidate this franme
+                bind( null,
+                      -1 );
+                // return a new frame
+                return createNewDroolsFrame( frame,
+                                             depth );
+            }
+        } else {
+            return null;
+        }
+    }
+
+    protected DroolsStackFrame createNewDroolsFrame(StackFrame frame,
+                                                    int depth) {
+        return DroolsThread.createCustomFrame( fThread,
+                                               depth,
+                                               frame );
+    }
+
+    public IThread getThread() {
+        return fThread;
+    }
+
+    public Method getUnderlyingMethod() {
+        synchronized ( fThread ) {
+            return fLocation.method();
+        }
+    }
+
+    protected List getUnderlyingVisibleVariables() throws DebugException {
+        synchronized ( fThread ) {
+            List variables = Collections.EMPTY_LIST;
+            try {
+                variables = getUnderlyingStackFrame().visibleVariables();
+            } catch ( AbsentInformationException e ) {
+                setLocalsAvailable( false );
+            } catch ( NativeMethodException e ) {
+                setLocalsAvailable( false );
+            } catch ( RuntimeException e ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables_2,
+                                                           new String[]{e.toString()} ),
+                                     e );
+            }
+            return variables;
+        }
+    }
+
+    protected ObjectReference getUnderlyingThisObject() throws DebugException {
+        synchronized ( fThread ) {
+            if ( (fStackFrame == null || fThisObject == null) && !isStatic() ) {
+                try {
+                    fThisObject = getUnderlyingStackFrame().thisObject();
+                } catch ( RuntimeException e ) {
+                    targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_this,
+                                                               new String[]{e.toString()} ),
+                                         e );
+                    // execution will not reach this line, as 
+                    // #targetRequestFailed will throw an exception			
+                    return null;
+                }
+            }
+            return fThisObject;
+        }
+    }
+
+    public String getDeclaringTypeName() throws DebugException {
+        synchronized ( fThread ) {
+            try {
+                if ( isObsolete() ) {
+                    return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1;
+                }
+                return JDIReferenceType.getGenericName( getUnderlyingMethod().declaringType() );
+            } catch ( RuntimeException e ) {
+                if ( getThread().isSuspended() ) {
+                    targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_declaring_type,
+                                                               new String[]{e.toString()} ),
+                                         e );
+                }
+                return JDIDebugModelMessages.JDIStackFrame__unknown_declaring_type__1;
+            }
+        }
+    }
+
+    public String getSourceName() throws DebugException {
+        synchronized ( fThread ) {
+            return getSourceName( fLocation );
+        }
+    }
+
+    public boolean isObsolete() {
+        if ( !JDIDebugPlugin.isJdiVersionGreaterThanOrEqual( new int[]{1, 4} ) || !((JDIDebugTarget) getDebugTarget()).hasHCROccurred() ) {
+            // If no hot code replace has occurred, this frame
+            // cannot be obsolete.
+            return false;
+        }
+        // if this frame's thread is not suspended, the obsolete status cannot
+        // change until it suspends again
+        synchronized ( fThread ) {
+            if ( getThread().isSuspended() ) {
+                return getUnderlyingMethod().isObsolete();
+            }
+            return false;
+        }
+    }
+
+    protected boolean exists() {
+        synchronized ( fThread ) {
+            return fDepth != -1;
+        }
+    }
+
+    protected StackFrame getUnderlyingStackFrame() throws DebugException {
+        synchronized ( fThread ) {
+            if ( fStackFrame == null ) {
+                if ( fDepth == -1 ) {
+                    throw new DebugException( new Status( IStatus.ERROR,
+                                                          JDIDebugPlugin.getUniqueIdentifier(),
+                                                          IJavaStackFrame.ERR_INVALID_STACK_FRAME,
+                                                          JDIDebugModelMessages.JDIStackFrame_25,
+                                                          null ) );
+                }
+                if ( fThread.isSuspended() ) {
+                    // re-index stack frames - See Bug 47198
+                    fThread.computeStackFrames();
+                    if ( fDepth == -1 ) {
+                        // If depth is -1, then this is an invalid frame
+                        throw new DebugException( new Status( IStatus.ERROR,
+                                                              JDIDebugPlugin.getUniqueIdentifier(),
+                                                              IJavaStackFrame.ERR_INVALID_STACK_FRAME,
+                                                              JDIDebugModelMessages.JDIStackFrame_25,
+                                                              null ) );
+                    }
+                } else {
+                    throw new DebugException( new Status( IStatus.ERROR,
+                                                          JDIDebugPlugin.getUniqueIdentifier(),
+                                                          IJavaThread.ERR_THREAD_NOT_SUSPENDED,
+                                                          JDIDebugModelMessages.JDIStackFrame_25,
+                                                          null ) );
+                }
+            }
+            return fStackFrame;
+        }
+    }
+
+    protected void setUnderlyingStackFrame(StackFrame frame) {
+        synchronized ( fThread ) {
+            fStackFrame = frame;
+            if ( frame == null ) {
+                fRefreshVariables = true;
+            }
+        }
+    }
+
+    protected void setThread(JDIThread thread) {
+        fThread = (DroolsThread) thread;
+    }
+
+    public String getSourcePath(String stratum) throws DebugException {
+        synchronized ( fThread ) {
+            try {
+                return fLocation.sourcePath( stratum );
+            } catch ( AbsentInformationException e ) {
+            } catch ( RuntimeException e ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path,
+                                                           new String[]{e.toString()} ),
+                                     e );
+            }
+        }
+        return null;
+    }
+
+    public String getSourcePath() throws DebugException {
+        synchronized ( fThread ) {
+            try {
+                return fLocation.sourcePath();
+            } catch ( AbsentInformationException e ) {
+            } catch ( RuntimeException e ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_path,
+                                                           new String[]{e.toString()} ),
+                                     e );
+            }
+        }
+        return null;
+    }
+
+    public int getLineNumber(String stratum) throws DebugException {
+        synchronized ( fThread ) {
+            try {
+                return fLocation.lineNumber( stratum );
+            } catch ( RuntimeException e ) {
+                if ( getThread().isSuspended() ) {
+                    targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_line_number,
+                                                               new String[]{e.toString()} ),
+                                         e );
+                }
+            }
+        }
+        return -1;
+    }
+
+    public String getSourceName(String stratum) throws DebugException {
+        synchronized ( fThread ) {
+            try {
+                return fLocation.sourceName( stratum );
+            } catch ( AbsentInformationException e ) {
+            } catch ( NativeMethodException e ) {
+            } catch ( RuntimeException e ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name,
+                                                           new String[]{e.toString()} ),
+                                     e );
+            }
+        }
+        return null;
+    }
+
+    protected void updateVariables() throws DebugException {
+        if ( fVariables == null ) {
+            return;
+        }
+
+        Method method = getUnderlyingMethod();
+        int index = 0;
+        if ( !method.isStatic() ) {
+            // update "this"
+            ObjectReference thisObject;
+            try {
+                thisObject = getUnderlyingThisObject();
+            } catch ( DebugException exception ) {
+                if ( !getThread().isSuspended() ) {
+                    thisObject = null;
+                } else {
+                    throw exception;
+                }
+            }
+            DroolsThisVariable oldThisObject = null;
+            if ( !fVariables.isEmpty() && fVariables.get( 0 ) instanceof DroolsThisVariable ) {
+                oldThisObject = (DroolsThisVariable) fVariables.get( 0 );
+            }
+            if ( thisObject == null && oldThisObject != null ) {
+                // removal of 'this'
+                fVariables.remove( 0 );
+                index = 0;
+            } else {
+                if ( oldThisObject == null && thisObject != null ) {
+                    // creation of 'this'
+                    oldThisObject = new DroolsThisVariable( (JDIDebugTarget) getDebugTarget(),
+                                                            thisObject );
+                    fVariables.add( 0,
+                                    oldThisObject );
+                    index = 1;
+                } else {
+                    if ( oldThisObject != null ) {
+                        // 'this' still exists, replace with new 'this' if a different receiver
+                        if ( !oldThisObject.retrieveValue().equals( thisObject ) ) {
+                            fVariables.remove( 0 );
+                            fVariables.add( 0,
+                                            new DroolsThisVariable( (JDIDebugTarget) getDebugTarget(),
+                                                                    thisObject ) );
+                        }
+                        index = 1;
+                    }
+                }
+            }
+        }
+
+        List locals = null;
+        try {
+            locals = getUnderlyingStackFrame().visibleVariables();
+        } catch ( AbsentInformationException e ) {
+            locals = Collections.EMPTY_LIST;
+        } catch ( NativeMethodException e ) {
+            locals = Collections.EMPTY_LIST;
+        } catch ( RuntimeException e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_visible_variables,
+                                                       new String[]{e.toString()} ),
+                                 e );
+            // execution will not reach this line, as 
+            // #targetRequestFailed will throw an exception			
+            return;
+        }
+        int localIndex = -1;
+        while ( index < fVariables.size() ) {
+            Object var = fVariables.get( index );
+            if ( var instanceof JDILocalVariable ) {
+                DroolsLocalVariable local = (DroolsLocalVariable) fVariables.get( index );
+                localIndex = locals.indexOf( local.getLocal() );
+                if ( localIndex >= 0 ) {
+                    // update variable with new underling JDI LocalVariable
+                    local.setLocal( (LocalVariable) locals.get( localIndex ) );
+                    locals.remove( localIndex );
+                    index++;
+                } else {
+                    // remove variable
+                    fVariables.remove( index );
+                }
+            } else {
+                //field variable of a static frame
+                index++;
+            }
+        }
+
+        // add any new locals
+        Iterator newOnes = locals.iterator();
+        while ( newOnes.hasNext() ) {
+            DroolsLocalVariable local = new DroolsLocalVariable( this,
+                                                                 (LocalVariable) newOnes.next() );
+            fVariables.add( local );
+        }
+    }
+
+    protected void setVariables(List variables) {
+        fVariables = variables;
+    }
+
+    public String getReceivingTypeName() throws DebugException {
+        if ( fStackFrame == null || fReceivingTypeName == null ) {
+            try {
+                if ( isObsolete() ) {
+                    fReceivingTypeName = JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2;
+                } else {
+                    ObjectReference thisObject = getUnderlyingThisObject();
+                    if ( thisObject == null ) {
+                        fReceivingTypeName = getDeclaringTypeName();
+                    } else {
+                        fReceivingTypeName = JDIReferenceType.getGenericName( thisObject.referenceType() );
+                    }
+                }
+            } catch ( RuntimeException e ) {
+                if ( getThread().isSuspended() ) {
+                    targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_receiving_type,
+                                                               new String[]{e.toString()} ),
+                                         e );
+                }
+                return JDIDebugModelMessages.JDIStackFrame__unknown_receiving_type__2;
+            }
+        }
+        return fReceivingTypeName;
+    }
+
+    private String getSourceName(Location location) throws DebugException {
+        try {
+            return location.sourceName();
+        } catch ( AbsentInformationException e ) {
+            return null;
+        } catch ( NativeMethodException e ) {
+            return null;
+        } catch ( RuntimeException e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIStackFrame_exception_retrieving_source_name,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+        return null;
+    }
+
+    private boolean equals(Object o1,
+                           Object o2) {
+        if ( o1 == null ) {
+            return o2 == null;
+        } else {
+            return o1.equals( o2 );
+        }
+    }
+
+    protected void clearCachedData() {
+        fThisObject = null;
+        fReceivingTypeName = null;
+    }
+
+    private void setLocalsAvailable(boolean available) {
+        if ( available != fLocalsAvailable ) {
+            fLocalsAvailable = available;
+            fireChangeEvent( DebugEvent.STATE );
+        }
+    }
+
+    public boolean wereLocalsAvailable() {
+        return fLocalsAvailable;
+    }
+
+    public IJavaVariable[] getLocalVariables() throws DebugException {
+        List list = getUnderlyingVisibleVariables();
+        IJavaVariable[] locals = new IJavaVariable[list.size()];
+        for ( int i = 0; i < list.size(); i++ ) {
+            locals[i] = new DroolsLocalVariable( this,
+                                                 (LocalVariable) list.get( i ) );
+        }
+        return locals;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThisVariable.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThisVariable.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThisVariable.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+package org.drools.eclipse.debug.core;
+
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIThisVariable;
+
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.Value;
+
+public class DroolsThisVariable extends JDIThisVariable {
+
+	public DroolsThisVariable(JDIDebugTarget target, ObjectReference object) {
+		super(target, object);
+	}
+	
+	protected Value retrieveValue() {
+		return super.retrieveValue();
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/DroolsThread.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,325 @@
+package org.drools.eclipse.debug.core;
+
+import java.text.MessageFormat;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.IStackFrame;
+import org.eclipse.jdt.debug.core.IJavaThread;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugModelMessages;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+import org.eclipse.jdt.internal.debug.core.model.JDIThread;
+import org.mvel.debug.Debugger;
+
+import com.sun.jdi.ClassType;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.IntegerValue;
+import com.sun.jdi.InvalidStackFrameException;
+import com.sun.jdi.Location;
+import com.sun.jdi.Method;
+import com.sun.jdi.ObjectCollectedException;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.StackFrame;
+import com.sun.jdi.ThreadReference;
+
+/**
+ * Drools Thread supporting MVEL and Java dialect stackframes
+ *
+ */
+public class DroolsThread extends JDIThread {
+
+    private List    fStackFrames;
+    private boolean fRefreshChildren = true;
+
+    public DroolsThread(JDIDebugTarget target,
+                        ThreadReference thread) throws ObjectCollectedException {
+        super( target,
+               thread );
+    }
+
+    protected void initialize() throws ObjectCollectedException {
+        super.initialize();
+        fStackFrames = new ArrayList();
+    }
+
+    public synchronized List computeStackFrames() throws DebugException {
+        return computeStackFrames( fRefreshChildren );
+    }
+
+    protected synchronized List computeStackFrames(boolean refreshChildren) throws DebugException {
+        if ( isSuspended() ) {
+            if ( isTerminated() ) {
+                fStackFrames.clear();
+            } else if ( refreshChildren ) {
+                List frames = getUnderlyingFrames();
+                int oldSize = fStackFrames.size();
+                int newSize = frames.size();
+                int discard = oldSize - newSize; // number of old frames to discard, if any
+                for ( int i = 0; i < discard; i++ ) {
+                    DroolsStackFrame invalid = (DroolsStackFrame) fStackFrames.remove( 0 );
+                    invalid.bind( null,
+                                  -1 );
+                }
+                int newFrames = newSize - oldSize; // number of frames to create, if any
+                int depth = oldSize;
+                for ( int i = newFrames - 1; i >= 0; i-- ) {
+                    StackFrame currentFrame = (StackFrame) frames.get( i );
+                    //MVEL: create an mvel stack frame when the declaring type is our debugger?
+
+                    DroolsStackFrame customFrame;
+
+                    customFrame = createCustomFrame( this,
+                                                     depth,
+                                                     currentFrame );
+
+                    fStackFrames.add( 0,
+                                      customFrame );
+
+                    depth++;
+                }
+                int numToRebind = Math.min( newSize,
+                                            oldSize ); // number of frames to attempt to rebind
+                int offset = newSize - 1;
+                for ( depth = 0; depth < numToRebind; depth++ ) {
+                    DroolsStackFrame oldFrame = (DroolsStackFrame) fStackFrames.get( offset );
+                    StackFrame frame = (StackFrame) frames.get( offset );
+                    DroolsStackFrame newFrame = (DroolsStackFrame) oldFrame.bind( frame,
+                                                                                  depth );
+                    if ( newFrame != oldFrame ) {
+                        fStackFrames.set( offset,
+                                          newFrame );
+                    }
+                    offset--;
+                }
+
+            }
+            fRefreshChildren = false;
+        } else {
+            return Collections.EMPTY_LIST;
+        }
+        return fStackFrames;
+    }
+
+    public final static DroolsStackFrame createCustomFrame(DroolsThread thread,
+                                                           int depth,
+                                                           StackFrame currentFrame) {
+        DroolsStackFrame customFrame;
+        Location loc = currentFrame.location();
+        if ( loc.declaringType().name().equals( "org.drools.base.mvel.MVELDebugHandler" ) && loc.method().name().equals( "onBreak" ) ) {
+            customFrame = new MVELStackFrame( thread,
+                                              currentFrame,
+                                              depth );
+        } else {
+            customFrame = new DroolsStackFrame( thread,
+                                                currentFrame,
+                                                depth );
+        }
+        return customFrame;
+    }
+
+    private List getUnderlyingFrames() throws DebugException {
+        if ( !isSuspended() ) {
+            // Checking isSuspended here eliminates a race condition in resume
+            // between the time stack frames are preserved and the time the
+            // underlying thread is actually resumed.
+            requestFailed( JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1,
+                           null,
+                           IJavaThread.ERR_THREAD_NOT_SUSPENDED );
+        }
+        try {
+            return getUnderlyingThread().frames();
+        } catch ( IncompatibleThreadStateException e ) {
+            requestFailed( JDIDebugModelMessages.JDIThread_Unable_to_retrieve_stack_frame___thread_not_suspended__1,
+                           e,
+                           IJavaThread.ERR_THREAD_NOT_SUSPENDED );
+        } catch ( RuntimeException e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        } catch ( InternalError e ) {
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_retrieving_stack_frames_2,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+        // execution will not reach this line, as
+        // #targetRequestFailed will thrown an exception
+        return null;
+    }
+
+    protected synchronized void preserveStackFrames() {
+        fRefreshChildren = true;
+        Iterator frames = fStackFrames.iterator();
+        while ( frames.hasNext() ) {
+            ((DroolsStackFrame) frames.next()).setUnderlyingStackFrame( null );
+        }
+    }
+
+    protected synchronized void disposeStackFrames() {
+        fStackFrames.clear();
+        fRefreshChildren = true;
+    }
+
+    protected void popFrame(IStackFrame frame) throws DebugException {
+        JDIDebugTarget target = (JDIDebugTarget) getDebugTarget();
+        if ( target.canPopFrames() ) {
+            // JDK 1.4 support
+            try {
+                // Pop the frame and all frames above it
+                StackFrame jdiFrame = null;
+                int desiredSize = fStackFrames.size() - fStackFrames.indexOf( frame ) - 1;
+                int lastSize = fStackFrames.size() + 1; // Set up to pass the first test
+                int size = fStackFrames.size();
+                while ( size < lastSize && size > desiredSize ) {
+                    // Keep popping frames until the stack stops getting smaller
+                    // or popFrame is gone.
+                    // see Bug 8054
+                    jdiFrame = ((DroolsStackFrame) frame).getUnderlyingStackFrame();
+                    preserveStackFrames();
+                    getUnderlyingThread().popFrames( jdiFrame );
+                    lastSize = size;
+                    size = computeStackFrames().size();
+                }
+            } catch ( IncompatibleThreadStateException exception ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_popping,
+                                                           new String[]{exception.toString()} ),
+                                     exception );
+            } catch ( InvalidStackFrameException exception ) {
+                // InvalidStackFrameException can be thrown when all but the
+                // deepest frame were popped. Fire a changed notification
+                // in case this has occured.
+                fireChangeEvent( DebugEvent.CONTENT );
+                targetRequestFailed( exception.toString(),
+                                     exception );
+            } catch ( RuntimeException exception ) {
+                targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_popping,
+                                                           new String[]{exception.toString()} ),
+                                     exception );
+            }
+        }
+    }
+
+    protected void terminated() {
+        super.terminated();
+    }
+
+    protected void removeCurrentBreakpoint(IBreakpoint bp) {
+        super.removeCurrentBreakpoint( bp );
+    }
+
+    protected synchronized void suspendedByVM() {
+        super.suspendedByVM();
+    }
+
+    protected synchronized void resumedByVM() throws DebugException {
+        super.resumedByVM();
+    }
+
+    protected void setRunning(boolean running) {
+        super.setRunning( running );
+    }
+
+    protected void dropToFrame(IStackFrame frame) throws DebugException {
+        super.dropToFrame( frame );
+    }
+
+    protected synchronized void stepToFrame(IStackFrame frame) throws DebugException {
+        super.stepToFrame( frame );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.jdt.internal.debug.core.model.JDIThread#newInstance(com.sun.jdi.ClassType, com.sun.jdi.Method, java.util.List)
+     */
+    public ObjectReference newInstance(ClassType receiverClass,
+                                       Method constructor,
+                                       List args) throws DebugException {
+        return super.newInstance( receiverClass,
+                                  constructor,
+                                  args );
+    }
+
+    public synchronized void stepOver() throws DebugException {
+
+        // Detection for active stackframe
+        if ( !(getTopStackFrame() instanceof MVELStackFrame) ) {
+            super.stepOver();
+            return;
+        }
+
+        //MVEL step over
+        MVELStackFrame mvelStack = (MVELStackFrame) getTopStackFrame();
+
+        if ( !canStepOver() || !mvelStack.canStepOver() ) {
+            return;
+        }
+
+        if ( !setRemoteOnBreakReturn( Debugger.STEP ) ) {
+            return;
+        }
+
+        preserveStackFrames();
+
+        setRunning( true );
+
+        try {
+            getUnderlyingThread().resume();
+        } catch ( RuntimeException e ) {
+            //stepEnd();
+            targetRequestFailed( MessageFormat.format( JDIDebugModelMessages.JDIThread_exception_stepping,
+                                                       new String[]{e.toString()} ),
+                                 e );
+        }
+
+    }
+
+    private boolean setRemoteOnBreakReturn(int step_over) throws DebugException {
+
+        JDIStackFrame top = (JDIStackFrame) getTopStackFrame();
+        if ( top == null || (!(top instanceof MVELStackFrame)) ) {
+            return false;
+        }
+
+        Iterator handleriter = getVM().classesByName( "org.drools.base.mvel.MVELDebugHandler" ).iterator();
+        Object debugHandlerClass = handleriter.next();
+
+        int line = step_over;
+
+        ReferenceType refType = (ReferenceType) debugHandlerClass;
+        Method m = (Method) refType.methodsByName( "setOnBreakReturn" ).iterator().next();
+        List args = new ArrayList();
+        IntegerValue lineVal = getVM().mirrorOf( line );
+        //ObjectReference realVal = val.getUnderlyingObject();
+        args.add( lineVal );
+
+        try {
+            ClassType tt = (ClassType) debugHandlerClass;
+            tt.invokeMethod( getUnderlyingThread(),
+                             m,
+                             args,
+                             ObjectReference.INVOKE_SINGLE_THREADED );
+
+        } catch ( Exception e ) {
+            DroolsEclipsePlugin.log( e );
+            return false;
+        }
+        return true;
+    }
+
+    public synchronized void resume() throws DebugException {
+        // clear up the step over flag. step over button never calls this method.
+        setRemoteOnBreakReturn( Debugger.CONTINUE );
+        super.resume();
+    }
+
+    public void setInvokingMethod(boolean invoking) {
+        super.setInvokingMethod( invoking );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/IDroolsDebugConstants.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,15 @@
+package org.drools.eclipse.debug.core;
+
+public interface IDroolsDebugConstants {
+
+	String ID_DROOLS_DEBUG_MODEL = "org.drools.eclipse.debug";
+	String DROOLS_MARKER_TYPE = "org.drools.eclipse.droolsBreakpointMarker";
+	String DRL_LINE_NUMBER = "Drools_DRL_LineNumber";
+	String LAUNCH_CONFIGURATION_TYPE = "org.drools.eclipse.launching.DroolsLaunchConfigurationDelegate";
+    
+    /**
+     * com.package.HelloWorld:14;com.package.GoodBye:7 style of packed rule info. int is the linenumber at the drl. 
+     */
+    String DRL_RULES = "org.drools.eclipse.debug.DRL_RULES";
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELStackFrame.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,530 @@
+package org.drools.eclipse.debug.core;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.debug.DebugUtil;
+import org.drools.eclipse.debug.VariableWrapper;
+import org.eclipse.debug.core.DebugEvent;
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.core.model.IVariable;
+import org.eclipse.jdi.internal.ObjectReferenceImpl;
+import org.eclipse.jdt.debug.core.IJavaClassObject;
+import org.eclipse.jdt.debug.core.IJavaFieldVariable;
+import org.eclipse.jdt.debug.core.IJavaObject;
+import org.eclipse.jdt.debug.core.IJavaReferenceType;
+import org.eclipse.jdt.debug.core.IJavaValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIObjectValue;
+import org.eclipse.jdt.internal.debug.core.model.JDIStackFrame;
+
+import com.sun.jdi.AbsentInformationException;
+import com.sun.jdi.ArrayReference;
+import com.sun.jdi.BooleanValue;
+import com.sun.jdi.ClassNotLoadedException;
+import com.sun.jdi.ClassType;
+import com.sun.jdi.Field;
+import com.sun.jdi.IncompatibleThreadStateException;
+import com.sun.jdi.IntegerValue;
+import com.sun.jdi.InvalidTypeException;
+import com.sun.jdi.InvocationException;
+import com.sun.jdi.LocalVariable;
+import com.sun.jdi.Method;
+import com.sun.jdi.ObjectReference;
+import com.sun.jdi.ReferenceType;
+import com.sun.jdi.StackFrame;
+import com.sun.jdi.StringReference;
+import com.sun.jdi.ThreadReference;
+import com.sun.jdi.Value;
+
+/**
+ * Stack Frame for MVEL Dialect
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class MVELStackFrame extends DroolsStackFrame {
+
+    private int                             cacheLineNumber           = -1;
+    private int                             cacheBreakpointLineNumber = -1;
+    private String                          cacheMVELName             = null;
+    private IVariable[]                     cacheVariables            = null;
+
+    private boolean                         evaluating                = false;
+
+    /**
+     * Dummy type with changed stratum to force debugger's LaunchView to show proper stackframe name
+     */
+    private static final IJavaReferenceType REF_TYPE                  = new IJavaReferenceType() {
+
+    	public IJavaFieldVariable getField(String name) throws DebugException {
+    		return null;
+    	}
+    	public IJavaClassObject getClassObject() throws DebugException {
+    		return null;
+    	}
+    	
+    	public String[] getAvailableStrata() throws DebugException {
+    		return null;
+    	}
+    	
+    	public String getDefaultStratum() throws DebugException {
+    		return "MVEL";
+    	}
+    	
+    	public String[] getDeclaredFieldNames() throws DebugException {
+    		return null;
+    	}
+    	
+    	public String[] getAllFieldNames() throws DebugException {
+    		return null;
+    	}
+        
+        public IJavaObject getClassLoaderObject() throws DebugException {
+    		return null;
+    	}
+        
+        public String getGenericSignature() throws DebugException {
+    		return null;
+    	}
+        
+        public String getSourceName() throws DebugException {
+    		return null;
+    	}
+        
+        public String[] getSourceNames(String stratum) throws DebugException {
+    		return null;
+    	}
+        
+        public String[] getSourcePaths(String stratum) throws DebugException {
+    		return null;
+    	}
+        
+        public IJavaObject[] getInstances(long max) throws DebugException {
+    		return null;
+    	}
+        
+		public String getName() throws DebugException {
+			return null;
+		}
+		
+		public String getSignature() throws DebugException {
+			return null;
+		}
+		
+		public IDebugTarget getDebugTarget() {
+			return null;
+		}
+		
+		public ILaunch getLaunch() {
+			return null;
+		}
+		
+		public String getModelIdentifier() {
+			return null;
+		}
+		
+		public Object getAdapter(Class adapter) {
+			return null;
+		}
+
+                                                                      };
+
+    public MVELStackFrame(DroolsThread thread,
+                          StackFrame frame,
+                          int depth) {
+        super( thread,
+               frame,
+               depth );
+
+    }
+
+    public IVariable[] getVariables() throws DebugException {
+
+        if ( !isSuspended() ) {
+            return null;
+        }
+
+        if ( cacheVariables != null ) {
+            return cacheVariables;
+        }
+
+        evaluating = true;
+        try {
+            List result = new ArrayList( 0 );
+
+            Method method = getUnderlyingMethod(); // onBreak
+            ReferenceType declaringType = method.declaringType(); // org.drools.base.mvel.MVELDebugHandler
+
+            try {
+
+                Object var = method.variables().get( 0 );
+                LocalVariable v2 = (LocalVariable) var;
+                DroolsLocalVariable frameLocal = new DroolsLocalVariable( this,
+                                                                          v2 );
+
+                IValue knownVars = DebugUtil.getValueByExpression( "return getFactory().getKnownVariables().toArray(new String[0]);",
+                                                                   frameLocal.getValue() );
+
+                IValue factory = DebugUtil.getValueByExpression( "return getFactory();",
+                                                                 frameLocal.getValue() );
+
+                IValue vars2 = DebugUtil.getValueByExpression( "return getFactory().getKnownVariables();",
+                                                               frameLocal.getValue() );
+
+                JDIObjectValue vvv = (JDIObjectValue) knownVars;
+
+                if ( vvv != null && ((ArrayReference) vvv.getUnderlyingObject()).length() > 0 ) {
+                    ArrayReference arr = (ArrayReference) vvv.getUnderlyingObject();
+
+                    Iterator varIter = arr.getValues().iterator();
+
+                    while ( varIter.hasNext() ) {
+                        final String varName = ((StringReference) varIter.next()).value();
+
+                        IJavaValue val = (IJavaValue) DebugUtil.getValueByExpression( "return getVariableResolver(\"" + varName + "\").getValue();",
+                                                                                      factory );
+                        if ( val != null ) {
+                            final ObjectReference valRef = ((JDIObjectValue) val).getUnderlyingObject();
+                            VariableWrapper local = new VariableWrapper( varName,
+                                                                         val );
+
+                            local.setPublic( true );
+                            result.add( local );
+                        } else {
+                            DroolsEclipsePlugin.log( new Exception( "Unable to get value for variable named '" + varName + "' suspend=" + isSuspended() ) );
+                        }
+                    }
+
+                }
+
+                IVariable[] vararr = (IVariable[]) result.toArray( new IVariable[result.size()] );
+                cacheVariables = vararr;
+                return vararr;
+
+            } catch ( Throwable t ) {
+                DroolsEclipsePlugin.log( t );
+            }
+
+            IVariable[] vararr = (IVariable[]) result.toArray( new IVariable[result.size()] );
+
+            Arrays.sort( vararr,
+                         new Comparator() {
+
+                             public int compare(Object var1,
+                                                Object var2) {
+                                 try {
+                                     return ((IVariable) var1).getName().compareTo( ((IVariable) var2).getName() );
+                                 } catch ( DebugException e ) {
+                                     return 0;
+                                 }
+                             }
+
+                         } );
+            cacheVariables = vararr;
+            return vararr;
+        } finally {
+            evaluating = false;
+            evalEnd();
+        }
+    }
+
+    private boolean internalHasNext(Value iter) throws InvalidTypeException,
+                                               ClassNotLoadedException,
+                                               IncompatibleThreadStateException,
+                                               InvocationException,
+                                               DebugException {
+        BooleanValue hasNext = (BooleanValue) runMethod( iter,
+                                                         "hasNext" );
+        return hasNext.booleanValue();
+    }
+
+    private Value fetchField(Value factoryVar,
+                             String fieldName) throws ClassNotLoadedException,
+                                              DebugException {
+        return fetchField( (ObjectReference) factoryVar,
+                           fieldName );
+    }
+
+    private Value runMethod(Value val,
+                            String methodName) throws InvalidTypeException,
+                                              ClassNotLoadedException,
+                                              IncompatibleThreadStateException,
+                                              InvocationException,
+                                              DebugException {
+
+        ObjectReference refObj = (ObjectReference) val;
+        ReferenceType t = refObj.referenceType();
+        Method m2 = (Method) t.methodsByName( methodName ).iterator().next();
+        ThreadReference thread = ((DroolsThread) getThread()).getUnderlyingThread();
+
+        Value res = refObj.invokeMethod( thread,
+                                         m2,
+                                         new ArrayList(),
+                                         0 );
+
+        return res;
+    }
+
+    private Value fetchField(DroolsLocalVariable frameLocal,
+                             String fieldName) throws DebugException,
+                                              ClassNotLoadedException {
+        ObjectReference objRef = ((JDIObjectValue) frameLocal.getValue()).getUnderlyingObject();
+        return fetchField( objRef,
+                           fieldName );
+    }
+
+    private Value fetchField(ObjectReference ref,
+                             String fieldName) throws ClassNotLoadedException,
+                                              DebugException {
+        ClassType varType = (ClassType) ref.type();
+        Field field = varType.fieldByName( fieldName );
+        Value res = ref.getValue( field );
+        return res;
+    }
+
+    protected DroolsStackFrame createNewDroolsFrame(StackFrame frame,
+                                                    int depth) {
+        return new MVELStackFrame( (DroolsThread) getThread(),
+                                   frame,
+                                   depth );
+    }
+
+    public int getLineNumber() throws DebugException {
+
+        if ( cacheLineNumber != -1 ) {
+            return cacheLineNumber;
+        }
+
+        if ( !isSuspended() ) {
+            return -1;
+        }
+
+        evaluating = true;
+        try {
+            DroolsDebugTarget t = (DroolsDebugTarget) getDebugTarget();
+
+            //int lineNr = getBreakpointLineNumber();
+            String sourceName = getMVELName();
+
+            DroolsLineBreakpoint bpoint = (DroolsLineBreakpoint) t.getDroolsBreakpoint( sourceName );
+
+            if ( bpoint == null ) {
+                return -1;
+            }
+
+            int line;
+
+            try {
+                line = Integer.parseInt( bpoint.getFileRuleMappings().get( sourceName ).toString() );
+            } catch ( Throwable t2 ) {
+                DroolsEclipsePlugin.log( t2 );
+                return -1;
+            }
+
+            int fragmentLine = getBreakpointLineNumber(); // 4->5 for step over
+
+            int res = line + fragmentLine;
+
+            cacheLineNumber = res;
+            return res;
+        } finally {
+            evaluating = false;
+            evalEnd();
+        }
+    }
+
+    public RuleInfo getExecutingRuleInfo() {
+        try {
+            String type = getDeclaringTypeName();
+
+            return DroolsEclipsePlugin.getDefault().getRuleInfoByClass( type );
+
+        } catch ( DebugException exc ) {
+            DroolsEclipsePlugin.log( exc );
+        }
+        return null;
+    }
+
+    public int getBreakpointLineNumber() {
+
+        if ( cacheBreakpointLineNumber != -1 ) {
+            return cacheBreakpointLineNumber;
+        }
+
+        if ( !isSuspended() ) {
+            return -1;
+        }
+
+        evaluating = true;
+        try {
+            try {
+                Object o = getRemoteVar( "lineNumber" );
+                if ( o == null ) {
+                    return -1;
+                }
+                IntegerValue val = (IntegerValue) o;
+                int realval = val.value();
+                cacheBreakpointLineNumber = realval;
+                return realval;
+            } catch ( Throwable e ) {
+                DroolsEclipsePlugin.log( e );
+            }
+            return -1;
+        } finally {
+            evaluating = false;
+            evalEnd();
+        }
+    }
+
+    public String getMVELName() {
+
+        if ( cacheMVELName != null ) {
+            return cacheMVELName;
+        }
+
+        if ( !isSuspended() ) {
+            return null;
+        }
+
+        evaluating = true;
+        try {
+            try {
+                Object rem = getRemoteVar( "sourceName" );
+                if ( rem == null ) {
+                    return null;
+                }
+                StringReference res = (StringReference) rem;
+                String realres = res.value();
+                cacheMVELName = realres;
+                return realres;
+            } catch ( Throwable e ) {
+                DroolsEclipsePlugin.log( e );
+            }
+
+            return "Unavailable";
+        } finally {
+            evaluating = false;
+            evalEnd();
+        }
+    }
+
+    private void evalEnd() {
+        fireChangeEvent( DebugEvent.STATE );
+        //fireChangeEvent( DebugEvent.CONTENT );
+    }
+
+    private Object getRemoteVar(String methodName) throws AbsentInformationException,
+                                                  ClassNotLoadedException,
+                                                  DebugException,
+                                                  InvalidTypeException,
+                                                  IncompatibleThreadStateException,
+                                                  InvocationException {
+
+        //frame arg
+        Method method = getUnderlyingMethod(); // onBreak
+        //ReferenceType declaringType = method.declaringType(); // org.drools.base.mvel.MVELDebugHandler
+
+        LocalVariable var = (LocalVariable) method.variables().get( 0 );//frame
+
+        ClassType frameType = (ClassType) var.type();
+
+        StackFrame frame = getUnderlyingStackFrame();
+        Value value = frame.getValue( var );
+        //getThread().getTopStackFrame().get
+
+        //IValue value = jdivar.getValue();
+        ObjectReferenceImpl o = (ObjectReferenceImpl) value;
+
+        /*        if ( value instanceof JDINullValue ) {
+         return null;
+         }
+         */
+
+        //ObjectReference o = (ObjectReference) ((JDIObjectValue) value).getUnderlyingObject();
+        if ( o == null ) {
+            return null;
+        }
+
+        Field field = frameType.fieldByName( methodName );
+        Value val = o.getValue( field );
+        return val;
+    }
+
+    public String getSourcePath() throws DebugException {
+        return getMVELName();
+    }
+
+    public boolean canStepInto() {
+        return false;
+    }
+
+    public boolean canStepOver() {
+        return exists() && !isObsolete() && !evaluating;
+    }
+
+    public boolean canDropToFrame() {
+        return false;
+    }
+
+    public boolean canStepReturn() {
+        return false;
+    }
+
+    public boolean canStepWithFilters() {
+        return false;
+    }
+
+    public IJavaReferenceType getReferenceType() throws DebugException {
+        return REF_TYPE;
+    }
+
+    public String getSourceName() throws DebugException {
+        return getMVELName();
+    }
+
+    protected JDIStackFrame bind(StackFrame frame,
+                                 int depth) {
+        clearCachedData();
+        return super.bind( frame,
+                           depth );
+    }
+
+    protected void clearCachedData() {
+        super.clearCachedData();
+        clearFrameCache();
+        if ( !isSuspended() ) {
+            initMVELinfo();
+        }
+    }
+
+    private void initMVELinfo() {
+        try {
+            getLineNumber();
+        } catch ( DebugException e ) {
+            // no luck this time. will be initialized later
+        }
+        getBreakpointLineNumber();
+        getMVELName();
+        try {
+            getVariables();
+        } catch ( DebugException e1 ) {
+            // no luck this time. will be initialized later
+        }
+    }
+
+    private void clearFrameCache() {
+        cacheLineNumber = -1;
+        cacheBreakpointLineNumber = -1;
+        cacheMVELName = null;
+        cacheVariables = null;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELThisVariable.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELThisVariable.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/debug/core/MVELThisVariable.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,25 @@
+package org.drools.eclipse.debug.core;
+
+import org.eclipse.debug.core.DebugException;
+import org.eclipse.jdt.internal.debug.core.model.JDIDebugTarget;
+import org.eclipse.jdt.internal.debug.core.model.JDIThisVariable;
+
+import com.sun.jdi.ObjectReference;
+
+public class MVELThisVariable extends JDIThisVariable {
+
+    private String label;
+
+    public MVELThisVariable(JDIDebugTarget target, ObjectReference object, String label) {
+        super( target, object );
+        this.label = label;
+    }
+
+    public String getName() {
+        return label;
+    }
+
+    public boolean isPublic() throws DebugException {
+        return true;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLAdapter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLAdapter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLAdapter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,222 @@
+package org.drools.eclipse.dsl.editor;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.builder.Util;
+import org.drools.eclipse.editors.completion.DSLTree;
+import org.drools.lang.dsl.DSLMapping;
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.drools.lang.dsl.DSLMappingFile;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.runtime.CoreException;
+
+/**
+ * This holds the DSL configuration for an editor instance.
+ * When loading, it will find the DSL file, and load the applicable lists.
+ * 
+ * This provides a link between the editor and the DSL features of the rule language.  
+ * 
+ * It will look for a DSL configuration, as named in the rule file, in the same directory as the rule file.
+ * Failing this, it will search one directory above the rule file. 
+ * Failing that, it will search the root of the project in the workspace.
+ * 
+ * @author Michael Neale
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DSLAdapter {
+
+    private String dslConfigName;
+    private boolean valid = false;
+    private List conditionProposals = new ArrayList();
+    private List consequenceProposals = new ArrayList();
+	private DSLTree dslTree = new DSLTree();
+    
+    //to dig out the expander, without using the parser.
+    private static final Pattern EXPANDER_PATTERN = Pattern.compile( "\\n\\s*expander\\s*(.*)\\.dsl\\s", 
+                                                             Pattern.DOTALL | Pattern.MULTILINE );
+    /**
+     * This will sniff out the DSL config file name from the content.
+     * It will then use the IFile input to search around for the file itself.
+     * TODO: provide an alternative that just loads off a stream (for non IDEs workbenches like jlibrary).
+     * @param content Rule source
+     * @param input File from the FileEditorInput
+     */
+    public DSLAdapter(String content, IFile input) throws CoreException {
+        dslConfigName = findDSLConfigName( content, input );
+        if (dslConfigName == null) {
+        	return;
+        }
+        loadConfig( input );
+    }
+    
+    /** Get a reader to the DSL contents */
+    public static Reader getDSLContent(String ruleSource, IResource input) throws CoreException {
+        String dslFileName = findDSLConfigName( ruleSource, input );
+        if (dslFileName == null) {
+        	return null;
+        }
+        IResource res = findDSLResource( input, dslFileName );
+        if (res instanceof IFile) {
+            IFile dslConf = (IFile) res;
+            if (dslConf.exists()) {
+                return new InputStreamReader(dslConf.getContents());
+            }
+        }
+        return null;
+    }
+
+    /**
+     * This does the hunting around the projec to find the .dsl file.
+     */
+    private void loadConfig(IFile input) {
+        IResource res = findDSLResource( input, dslConfigName );
+        if (res instanceof IFile) {
+            IFile dslConf = (IFile) res;
+            if (dslConf.exists()) {
+                InputStream stream = null; 
+                try {
+                    stream = dslConf.getContents();
+                    readConfig( stream );
+                    valid = true;
+                } catch ( Exception e ) {
+                    throw new IllegalStateException("Unable to open DSL config file. (Exception: " + e.getMessage() + ")");
+                } finally {
+                    closeStream( stream );
+                }
+                
+            }
+        }
+    }
+
+    private static IResource findDSLResource(IResource input, String dslFileName) {
+        IResource res = input.getParent().findMember( dslFileName );
+        if (res == null) res = input.getParent().getParent().findMember( dslFileName ); //try parent directory
+        if (res == null) res = input.getProject().findMember( dslFileName ); //try root of project.
+        return res;
+    }
+
+    
+    /** This will load in the DSL config file, using the DSLMapping from drools-compiler */
+    void readConfig(InputStream stream) throws IOException, CoreException {
+        DSLMappingFile file = new DSLMappingFile();
+        file.parseAndLoad(new InputStreamReader(stream));
+
+        DSLMapping grammar = file.getMapping();
+        List conditions = grammar.getEntries( DSLMappingEntry.CONDITION );
+        List consequences = grammar.getEntries( DSLMappingEntry.CONSEQUENCE );
+        
+        conditionProposals = buildProposals(conditions);
+        consequenceProposals = buildProposals(consequences);
+        
+		dslTree.buildTree(grammar);
+    }
+
+    private List buildProposals(List suggestions) {
+    	List result = new ArrayList(suggestions.size());
+    	Iterator iterator = suggestions.iterator();
+        while (iterator.hasNext()) {
+            DSLMappingEntry text = (DSLMappingEntry) iterator.next();
+            result.add(text.getMappingKey());
+        }
+        return result;
+    }
+
+    private void closeStream(InputStream stream) {
+        if (stream != null) try {
+            stream.close();
+        } catch ( IOException e ) {}
+    }
+
+    DSLAdapter() {
+        
+    }
+    
+    private static String findDSLConfigName(String content, IResource input) throws CoreException {
+        String dslConfigName = findDSLConfigName( content );
+        if (dslConfigName == null)  {
+	    	// try searching the .package file
+	    	if (input != null && input.getParent() != null) {
+	        	MyResourceVisitor visitor = new MyResourceVisitor();
+	        	input.getParent().accept(visitor, IResource.DEPTH_ONE, IResource.NONE);
+	        	IResource packageDef = visitor.getPackageDef();
+	        	if (packageDef != null) {
+	        		if (packageDef instanceof IFile) {
+	        			IFile file = (IFile) packageDef;
+	        	        try {
+	        	        	String pContent = new String(Util.getResourceContentsAsCharArray(file));
+	        	        	dslConfigName = findDSLConfigName( pContent );
+	        	        } catch (CoreException e) {
+	        	        	DroolsEclipsePlugin.log(e);
+	        	        }
+	        		}
+	        	}
+	        }
+        }
+        return dslConfigName;
+    }
+
+    /** Sniffs out the expander/DSL config name as best it can. */
+    static String findDSLConfigName(String content) {
+        String name = null;
+        Matcher matches = EXPANDER_PATTERN.matcher( content );
+        if (matches.find()) {
+            name = matches.group(1) + ".dsl";
+        }
+        return name;
+    }
+    
+    
+    String getDSLConfigName() {
+        return dslConfigName;
+    }
+    
+    
+    public boolean isValid() {
+        return valid;
+    }
+    
+    
+    public boolean hasConditions() {
+        return conditionProposals.size() > 0;
+    }
+    
+    public boolean hasConsequences() {
+        return consequenceProposals.size() > 0;
+    }
+    
+    public List listConditionItems() {
+        return conditionProposals;
+    }
+    
+    public List listConsequenceItems() {
+        return consequenceProposals;
+    }    
+    
+    public DSLTree getDSLTree() {
+    	return dslTree;
+    }
+    
+    private static class MyResourceVisitor implements IResourceVisitor {
+    	private IResource packageDef;
+		public boolean visit(IResource resource) throws CoreException {
+			if ("package".equals(resource.getFileExtension())) {
+				packageDef = resource;
+			}
+			return true;
+		}
+		public IResource getPackageDef() {
+			return packageDef;
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLContentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLContentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLContentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,57 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.jface.viewers.Viewer;
+
+/**
+ * Content provider for the Domain Specific Language editor.
+ * @author Michael Neale
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DSLContentProvider
+    implements
+    IStructuredContentProvider, IMappingListViewer {
+
+    private TableViewer viewer;
+    private NLGrammarModel model;
+    
+    public DSLContentProvider(TableViewer viewer, NLGrammarModel model) {
+        this.viewer = viewer;
+        this.model = model;
+    }
+    
+    public void dispose() {
+        model.removeChangeListener( this );
+    }
+    
+    public void inputChanged(Viewer viewer,
+                             Object oldInput,
+                             Object newInput) {
+        if (newInput != null)
+            ((NLGrammarModel) newInput).addChangeListener(this);
+        if (oldInput != null)
+            ((NLGrammarModel) oldInput).removeChangeListener(this);
+
+    }
+
+    public void addMapping(DSLMappingEntry item) {
+        viewer.add( item );
+        
+    }
+
+    public void removeMapping(DSLMappingEntry item) {
+
+        viewer.remove( item );
+    }
+
+    public void updateMapping(DSLMappingEntry item) {
+        viewer.update( item, null );
+    }
+
+    public Object[] getElements(Object inputElement) {
+        return model.getEntries().toArray();        
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,660 @@
+package org.drools.eclipse.dsl.editor;
+
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.builder.IDroolsModelMarker;
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.drools.lang.dsl.DSLMappingFile;
+import org.drools.lang.dsl.DefaultDSLMappingEntry;
+import org.drools.lang.dsl.MappingError;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.MouseEvent;
+import org.eclipse.swt.events.MouseListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Table;
+import org.eclipse.swt.widgets.TableColumn;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.EditorPart;
+import org.eclipse.ui.part.FileEditorInput;
+
+/**
+ * This is the tablular DSL configuration editor.
+ * @author Michael Neale
+ */
+public class DSLEditor extends EditorPart {
+
+    private Table          table;
+    private TableViewer    tableViewer;
+    private NLGrammarModel model;          //this is the model that does all the work (from drools-compiler)
+    private boolean        dirty = false;  //editing or deleting will make it dirty
+    private Text           exprText;       //for language expression
+    private Text           mappingText;    //for target rule expression
+    private Text           descriptionText; //just a comment field
+    private Text           objText;        // for the object name
+    private Combo          sortCombo;      // for the sort field
+
+    public void doSave(IProgressMonitor monitor) {
+
+        FileEditorInput input = (FileEditorInput) getEditorInput();
+        File outputFile = input.getFile().getLocation().toFile();
+        saveFile( monitor,
+                  outputFile,
+                  input );
+
+    }
+
+    private void saveFile(IProgressMonitor monitor,
+                          File outputFile,
+                          FileEditorInput input) {
+        try {
+            validate( input );
+
+            FileWriter writer = new FileWriter( outputFile );
+            DSLMappingFile.saveMapping( writer,
+                                        model );
+
+            makeClean();
+            writer.close();
+            input.getFile().getProject().refreshLocal( IResource.DEPTH_INFINITE,
+                                                       monitor );
+        } catch ( IOException e ) {
+            throw new IllegalStateException( "Unable to save DSL configuration file. (IOException: " + e.getMessage() + ")" );
+        } catch ( CoreException e ) {
+            throw new IllegalStateException( "Unable to resync workbench after DSL save. (CoreException: " + e.getMessage() + ")" );
+        }
+    }
+
+    private void validate(FileEditorInput input) {
+        removeProblemsFor( input.getFile() );
+        List errs = new ArrayList();
+        for ( Iterator iter = model.getEntries().iterator(); iter.hasNext(); ) {
+            DSLMappingEntry item = (DSLMappingEntry) iter.next();
+            errs.addAll( item.getErrors() );
+        }
+        if ( errs.size() > 0 ) {
+            for ( Iterator iter = errs.iterator(); iter.hasNext(); ) {
+                MappingError mapEr = (MappingError) iter.next();
+                createMarker( input.getFile(),
+                              mapEr.getMessage() + "  From [" + mapEr.getTemplateText() + "]",
+                              -1 );
+            }
+        }
+    }
+
+    private void createMarker(final IResource res,
+                              final String message,
+                              final int lineNumber) {
+        try {
+            IWorkspaceRunnable r = new IWorkspaceRunnable() {
+                public void run(IProgressMonitor monitor) throws CoreException {
+                    IMarker marker = res.createMarker( IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER );
+                    marker.setAttribute( IMarker.MESSAGE,
+                                         message );
+                    marker.setAttribute( IMarker.SEVERITY,
+                                         IMarker.SEVERITY_WARNING );
+                    marker.setAttribute( IMarker.LINE_NUMBER,
+                                         lineNumber );
+                }
+            };
+            res.getWorkspace().run( r,
+                                    null,
+                                    IWorkspace.AVOID_UPDATE,
+                                    null );
+        } catch ( CoreException e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+    }
+
+    private void removeProblemsFor(IResource resource) {
+        try {
+            if ( resource != null && resource.exists() ) {
+                resource.deleteMarkers( IDroolsModelMarker.DROOLS_MODEL_PROBLEM_MARKER,
+                                        false,
+                                        IResource.DEPTH_INFINITE );
+            }
+        } catch ( CoreException e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+    }
+
+    void makeClean() {
+        this.dirty = false;
+        firePropertyChange( PROP_DIRTY );
+
+    }
+
+    public void doSaveAs() {
+        // TODO Implement this.
+    }
+
+    public void init(IEditorSite site,
+                     IEditorInput editorInput) throws PartInitException {
+        FileEditorInput input = (FileEditorInput) editorInput;
+        setSite( site );
+        setInput( editorInput );
+        setVisibleName( input );
+
+        try {
+            InputStream stream = input.getFile().getContents();
+            model = new NLGrammarModel();
+            DSLMappingFile file = new DSLMappingFile();
+            file.parseAndLoad( new InputStreamReader( stream ) );
+            model.addEntries( file.getMapping().getEntries() );
+            stream.close();
+
+        } catch ( CoreException e ) {
+            throw new IllegalStateException( "Unable to load DSL configuration file. (CoreException: " + e.getMessage() + ")" );
+        } catch ( IOException e ) {
+            throw new IllegalStateException( "Unabel to close stream fo DSL config file. (IOException: " + e.getMessage() + ")" );
+        }
+
+    }
+
+    private void setVisibleName(FileEditorInput input) {
+        setPartName( input.getFile().getName() );
+        setContentDescription( "Editing Domain specific language: [" + input.getFile().getFullPath().toString() + "]" );
+    }
+
+    public boolean isDirty() {
+        return dirty;
+    }
+
+    /**
+     * Sets the dirty flag, and notifies the workbench.
+     */
+    void makeDirty() {
+        dirty = true;
+        firePropertyChange( PROP_DIRTY );
+    }
+
+    /**
+     * The method sorts th e
+     *
+     */
+    public void sortModel() {
+        if ( sortCombo.getSelectionIndex() == DSLMappingSorter.EXPRESSION ) {
+            tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.EXPRESSION ) );
+        } else if ( sortCombo.getSelectionIndex() == DSLMappingSorter.OBJECT ) {
+            tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.OBJECT ) );
+        } else if ( sortCombo.getSelectionIndex() == DSLMappingSorter.SCOPE ) {
+            tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.SCOPE ) );
+        } else if ( sortCombo.getSelectionIndex() == DSLMappingSorter.MAPPING ) {
+            tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.MAPPING ) );
+        }
+    }
+
+    public boolean isSaveAsAllowed() {
+        // TODO implement SaveAs
+        return false;
+    }
+
+    public void createPartControl(Composite parent) {
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_FILL | GridData.FILL_BOTH );
+        parent.setLayoutData( gridData );
+
+        // Set numColumns to 3 in the overall grid
+        GridLayout layout = new GridLayout( 3,
+                                            false );
+        layout.marginWidth = 4;
+        parent.setLayout( layout );
+
+        //create the overall desc field (comments).
+        createDescriptionField( parent );
+
+        // create the table
+        createTable( parent );
+
+        // Create and setup the TableViewer
+        createTableViewer();
+
+        //set up the table "binding" with the model
+        tableViewer.setContentProvider( new DSLContentProvider( tableViewer,
+                                                                model ) );
+        tableViewer.setLabelProvider( new DSLLabelProvider() );
+        refreshModel();
+
+        //setup the fields below the table
+        createExpressionViewField( parent );
+        createEditButton( parent );
+        createMappingViewField( parent );
+        createDeleteButton( parent );
+        createObjectViewField( parent );
+        createAddButton( parent );
+        createSortField( parent );
+        createSortButton( parent );
+        createCopyButton( parent );
+
+        //listeners on the table...
+        createTableListeners();
+
+    }
+
+    /**
+     * Setup table listeners for GUI events.
+     */
+    private void createTableListeners() {
+
+        //setup views into current selected
+        table.addSelectionListener( new SelectionListener() {
+
+            public void widgetSelected(SelectionEvent e) {
+                populate();
+            }
+
+            public void widgetDefaultSelected(SelectionEvent e) {
+                populate();
+            }
+
+            private void populate() {
+                DSLMappingEntry selected = getCurrentSelected();
+                exprText.setText( selected.getMappingKey() );
+                mappingText.setText( selected.getMappingValue() );
+                objText.setText( selected.getMetaData().getMetaData() == null ? "" : selected.getMetaData().getMetaData() );
+            }
+
+        } );
+
+        //double click support
+        table.addMouseListener( new MouseListener() {
+
+            public void mouseDoubleClick(MouseEvent e) {
+                showEditPopup();
+            }
+
+            public void mouseDown(MouseEvent e) {
+            }
+
+            public void mouseUp(MouseEvent e) {
+            }
+
+        } );
+
+    }
+
+    private void createDescriptionField(Composite parent) {
+        Label descLbl = new Label( parent,
+                                   SWT.NONE );
+        descLbl.setText( "Description:" );
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        descLbl.setLayoutData( gridData );
+
+        descriptionText = new Text( parent,
+                                    SWT.BORDER );
+        descriptionText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+        descriptionText.setText( model.getDescription() == null ? "" : model.getDescription() );
+        descriptionText.addModifyListener( new ModifyListener() {
+
+            public void modifyText(ModifyEvent e) {
+                String text = descriptionText.getText();
+                if ( !text.equals( model.getDescription() ) ) {
+                    model.setDescription( text );
+                    makeDirty();
+                }
+            }
+
+        } );
+    }
+
+    private void createMappingViewField(Composite parent) {
+        Label mapping = new Label( parent,
+                                   SWT.NONE );
+        mapping.setText( "Mapping:" );
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        mapping.setLayoutData( gridData );
+
+        mappingText = new Text( parent,
+                                SWT.BORDER );
+        mappingText.setEditable( false );
+
+        mappingText.setLayoutData( new GridData( GridData.FILL_HORIZONTAL ) );
+    }
+
+    private void createExpressionViewField(Composite parent) {
+
+        Label expr = new Label( parent,
+                                SWT.NONE );
+        expr.setText( "Expression:" );
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        expr.setLayoutData( gridData );
+
+        exprText = new Text( parent,
+                             SWT.BORDER );
+        exprText.setEditable( false );
+        gridData = new GridData( GridData.FILL_HORIZONTAL );
+
+        exprText.setLayoutData( gridData );
+
+    }
+
+    private void createObjectViewField(Composite parent) {
+
+        Label obj = new Label( parent,
+                               SWT.NONE );
+        obj.setText( "Object:" );
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        obj.setLayoutData( gridData );
+
+        objText = new Text( parent,
+                            SWT.BORDER );
+        objText.setEditable( false );
+        gridData = new GridData( GridData.FILL_HORIZONTAL );
+
+        objText.setLayoutData( gridData );
+
+    }
+
+    private void createSortField(Composite parent) {
+        Label sort = new Label( parent,
+                                SWT.NONE );
+        sort.setText( "Sort by:" );
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        sort.setLayoutData( gridData );
+
+        sortCombo = new Combo( parent,
+                               SWT.READ_ONLY );
+        sortCombo.add( "Object",
+                       DSLMappingSorter.OBJECT );
+        sortCombo.add( "Language Expression",
+                       DSLMappingSorter.EXPRESSION );
+        sortCombo.add( "Rule Language Mapping",
+                       DSLMappingSorter.MAPPING );
+        sortCombo.add( "Scope",
+                       DSLMappingSorter.SCOPE );
+        gridData = new GridData( GridData.FILL_HORIZONTAL );
+
+        sortCombo.setLayoutData( gridData );
+    }
+
+    /** Refreshes the table do make sure it is up to date with the model. */
+    private void refreshModel() {
+        tableViewer.setInput( model );
+    }
+
+    private void createEditButton(Composite parent) {
+        // Create and configure the "Add" button
+        Button add = new Button( parent,
+                                 SWT.PUSH | SWT.CENTER );
+        add.setText( "Edit" );
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        add.setLayoutData( gridData );
+
+        add.addSelectionListener( new SelectionAdapter() {
+
+            // Add a task to the ExampleTaskList and refresh the view
+            public void widgetSelected(SelectionEvent e) {
+                showEditPopup();
+            }
+
+        } );
+    }
+
+    private void showEditPopup() {
+    	DSLMappingEntry selected = getCurrentSelected();
+    	if (selected != null) {
+	        MappingEditor editor = new MappingEditor( getSite().getShell() );
+	        editor.create();
+	        editor.getShell().setText( "Edit language mapping" );
+	        editor.setTitle( "Edit an existing language mapping item." );
+	        editor.setTitleImage( getTitleImage() );
+	
+	        editor.setNLMappingItem( selected );
+	
+	        editor.open();
+	        if ( !editor.isCancelled() ) {
+	            refreshModel();
+	            makeDirty();
+	        }
+    	}
+    }
+
+    private void createDeleteButton(Composite parent) {
+        // Create and configure the "Add" button
+        Button add = new Button( parent,
+                                 SWT.PUSH | SWT.CENTER );
+        add.setText( "Remove" );
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        add.setLayoutData( gridData );
+        add.addSelectionListener( new SelectionAdapter() {
+            // Add a task to the ExampleTaskList and refresh the view
+            public void widgetSelected(SelectionEvent e) {
+                model.removeEntry( getCurrentSelected() );
+                refreshModel();
+                makeDirty();
+                exprText.setText( "" );
+                mappingText.setText( "" );
+                objText.setText( "" );
+            }
+        } );
+    }
+
+    private void createSortButton(Composite parent) {
+        // Create and configure the "Add" button
+        Button sort = new Button( parent,
+                                  SWT.PUSH | SWT.CENTER );
+        sort.setText( "Sort" );
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        sort.setLayoutData( gridData );
+        sort.addSelectionListener( new SelectionAdapter() {
+            // Add a task to the ExampleTaskList and refresh the view
+            public void widgetSelected(SelectionEvent e) {
+                sortModel();
+                refreshModel();
+                makeDirty();
+            }
+
+        } );
+    }
+
+    /**
+     * Return the selected item from the table grid thingy.
+     */
+    private DSLMappingEntry getCurrentSelected() {
+        return (DSLMappingEntry) ((IStructuredSelection) tableViewer.getSelection()).getFirstElement();
+    }
+
+    private void createAddButton(Composite parent) {
+        // Create and configure the "Add" button
+        Button add = new Button( parent,
+                                 SWT.PUSH | SWT.CENTER );
+        add.setText( "Add" );
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        add.setLayoutData( gridData );
+
+        add.addSelectionListener( new SelectionAdapter() {
+
+            // Add an item, should pop up the editor
+            public void widgetSelected(SelectionEvent e) {
+
+                DSLMappingEntry newItem = new DefaultDSLMappingEntry();
+
+                MappingEditor editor = new MappingEditor( getSite().getShell() );//shell);
+                editor.create();
+                editor.getShell().setText( "New language mapping" );
+                editor.setTitle( "Create a new language element mapping." );
+                editor.setTitleImage( getTitleImage() );
+
+                editor.setNLMappingItem( newItem );
+
+                editor.open();
+                if ( !editor.isCancelled() ) {
+                    model.addEntry( newItem );
+                    refreshModel();
+                    makeDirty();
+                }
+
+            }
+        } );
+    }
+
+    private void createCopyButton(Composite parent) {
+        // Create and configure the "Add" button
+        Button copy = new Button( parent,
+                                  SWT.PUSH | SWT.CENTER );
+        copy.setText( "Copy" );
+
+        GridData gridData = new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING );
+        gridData.widthHint = 80;
+        copy.setLayoutData( gridData );
+
+        copy.addSelectionListener( new SelectionAdapter() {
+
+            // Add an item, should pop up the editor
+            public void widgetSelected(SelectionEvent e) {
+
+                DSLMappingEntry curr = getCurrentSelected();
+                if (curr != null) {
+	                DSLMappingEntry newItem = new DefaultDSLMappingEntry( curr.getSection(),
+	                                                                      curr.getMetaData(),
+	                                                                      curr.getMappingKey(),
+	                                                                      curr.getMappingValue() );
+	
+	                MappingEditor editor = new MappingEditor( getSite().getShell() );//shell);
+	                editor.create();
+	                editor.getShell().setText( "New language mapping" );
+	                editor.setTitle( "Create a new language element mapping from a copy." );
+	                editor.setTitleImage( getTitleImage() );
+	
+	                editor.setNLMappingItem( newItem );
+	
+	                editor.open();
+	                if ( !editor.isCancelled() ) {
+	                    model.addEntry( newItem );
+	                    refreshModel();
+	                    makeDirty();
+	                }
+                }
+            }
+        } );
+    }
+
+    /**
+     * Create the viewer.
+     */
+    private void createTableViewer() {
+        tableViewer = new TableViewer( table );
+        tableViewer.setUseHashlookup( true );
+        //following is if we want default sorting... my thought is no...
+    }
+
+    /**
+     * Create the Table
+     */
+    private void createTable(Composite parent) {
+        int style = SWT.SINGLE | SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.HIDE_SELECTION;
+
+        table = new Table( parent,
+                           style );
+
+        GridData gridData = new GridData( GridData.FILL_BOTH );
+        gridData.grabExcessVerticalSpace = true;
+        gridData.horizontalSpan = 3;
+        table.setLayoutData( gridData );
+
+        table.setLinesVisible( true );
+        table.setHeaderVisible( true );
+
+        TableColumn column;
+
+        //Expression col
+        column = new TableColumn( table,
+                                  SWT.LEFT,
+                                  0 );
+        column.setText( "Language Expression" );
+        column.setWidth( 350 );
+        // Add listener to column so sorted when clicked 
+        column.addSelectionListener( new SelectionAdapter() {
+
+            public void widgetSelected(SelectionEvent e) {
+                tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.EXPRESSION ) );
+            }
+        } );
+
+        // 3rd column with task Owner
+        column = new TableColumn( table,
+                                  SWT.LEFT,
+                                  1 );
+        column.setText( "Rule Language Mapping" );
+        column.setWidth( 200 );
+        // Add listener to column so sorted when clicked
+        column.addSelectionListener( new SelectionAdapter() {
+
+            public void widgetSelected(SelectionEvent e) {
+                tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.MAPPING ) );
+            }
+        } );
+
+        // 4th column with task PercentComplete 
+        column = new TableColumn( table,
+                                  SWT.LEFT,
+                                  2 );
+        column.setText( "Object" );
+        column.setWidth( 80 );
+
+        // 5th column with task PercentComplete 
+        column = new TableColumn( table,
+                                  SWT.LEFT,
+                                  3 );
+        column.setText( "Scope" );
+        column.setWidth( 80 );
+
+        //  Add listener to column so tasks are sorted when clicked
+        column.addSelectionListener( new SelectionAdapter() {
+
+            public void widgetSelected(SelectionEvent e) {
+                tableViewer.setSorter( new DSLMappingSorter( DSLMappingSorter.SCOPE ) );
+            }
+        } );
+
+    }
+
+    public void setFocus() {
+    }
+
+    public void dispose() {
+        super.dispose();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLLabelProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLLabelProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLLabelProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,46 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.eclipse.jface.viewers.ITableLabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Provides visible part of the DSL editor table.
+ * 
+ * @author Michael Neale
+ *
+ */
+public class DSLLabelProvider extends LabelProvider
+    implements
+    ITableLabelProvider {
+
+    public Image getColumnImage(Object element,
+                                int columnIndex) {
+        return null;
+    }
+
+    public String getColumnText(Object element,
+                                int columnIndex) {
+        String result = "";
+        DSLMappingEntry item = (DSLMappingEntry) element;
+        switch (columnIndex) {
+            case 0:  
+                result = item.getMappingKey();
+                break;
+            case 1 :
+                result = item.getMappingValue();
+                break;
+            case 2 :
+            	result = item.getMetaData().getMetaData();
+            	break;
+            case 3 :
+                result = item.getSection().getSymbol();
+                break;
+            default :
+                break;  
+        }
+        return result;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLMappingSorter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLMappingSorter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLMappingSorter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,82 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerSorter;
+
+/** 
+ * Provides sorting for the natural language table viewer.
+ * @author Michael Neale
+ */
+public class DSLMappingSorter extends ViewerSorter {
+
+	public final static int OBJECT = 0;
+	public final static int EXPRESSION = 1;
+	public final static int MAPPING = 2;
+	public final static int SCOPE = 3;
+
+	// Criteria that the instance uses 
+	private int criteria;
+
+	/**
+	 * Creates a resource sorter that will use the given sort criteria.
+	 *
+	 * @param criteria the sort criterion to use: one of <code>NAME</code> or 
+	 *   <code>TYPE</code>
+	 */
+	public DSLMappingSorter(int criteria) {
+		super();
+		this.criteria = criteria;
+	}
+
+	/* (non-Javadoc)
+	 * Method declared on ViewerSorter.
+	 */
+	public int compare(Viewer viewer, Object o1, Object o2) {
+
+        DSLMappingEntry item1 = (DSLMappingEntry) o1;
+        DSLMappingEntry item2 = (DSLMappingEntry) o2;
+
+		switch (criteria) {
+			case OBJECT:
+				return compareObject(item1, item2);
+			case EXPRESSION :
+				return compareExpressions(item1, item2);
+			case MAPPING :
+				return compareMappings(item1, item2);
+			case SCOPE :
+				return compareScope(item1, item2);
+			default:
+				return 0;
+		}
+	}
+
+	
+
+	private int compareScope(DSLMappingEntry item1,
+                             DSLMappingEntry item2) {
+        return item1.getSection().compareTo( item2.getSection() );
+    }
+
+    private int compareMappings(DSLMappingEntry item1,
+                                DSLMappingEntry item2) {
+        return item1.getMappingValue().compareTo( item2.getMappingValue() );
+    }
+
+    private int compareExpressions(DSLMappingEntry item1,
+                                   DSLMappingEntry item2) {
+        return item1.getMappingKey().compareTo( item2.getMappingKey() );
+    }
+
+    private int compareObject(DSLMappingEntry item1, 
+                              DSLMappingEntry item2) {
+		return item1.getMetaData().compareTo(item2.getMetaData());
+	}
+    
+    /**
+	 * @return the sort criterion
+	 */
+	public int getCriteria() {
+		return criteria;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.ui.part.FileEditorInput;
+
+public class DSLRuleEditor extends DRLRuleEditor {
+
+    protected DSLAdapter dslAdapter;
+
+	public DSLAdapter getDSLAdapter() {
+		if (dslAdapter == null) {
+			try {
+				String content = getSourceViewer().getDocument().get();
+				dslAdapter = new DSLAdapter(content, ((FileEditorInput) getEditorInput()).getFile());
+				if (!dslAdapter.isValid()) {
+					dslAdapter = null;
+				}
+			} catch (CoreException exc) {
+				dslAdapter = null;
+			}
+		}
+		return dslAdapter;
+	}
+
+	protected SourceViewerConfiguration createSourceViewerConfiguration() {
+		return new DSLRuleSourceViewerConfig(this); 
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		super.doSave(monitor);
+		// remove cached content
+		dslAdapter = null;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor2.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor2.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleEditor2.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,118 @@
+package org.drools.eclipse.dsl.editor;
+
+import java.io.Reader;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.lang.dsl.DSLMappingFile;
+import org.drools.lang.dsl.DefaultExpander;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * Editor for rules using a domain-specific language.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DSLRuleEditor2 extends FormEditor {
+
+	private DSLRuleEditor dslRuleEditor;
+	private DSLtoDRLRuleViewer drlRuleViewer;
+
+	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+		super.init(site, input);
+		setPartName(input.getName());
+	}
+
+	protected void addPages() {
+		try {
+			dslRuleEditor = new DSLRuleEditor() {
+				public void close(boolean save) {
+					super.close(save);
+					DSLRuleEditor2.this.close(save);
+				}
+				protected void setPartName(String partName) {
+					super.setPartName(partName);
+					DSLRuleEditor2.this.setPartName(partName);
+				}
+			};
+			int text = addPage(dslRuleEditor, getEditorInput());
+			setPageText(text, "Text Editor");
+			drlRuleViewer = new DSLtoDRLRuleViewer(dslRuleEditor);
+			text = addPage(drlRuleViewer, getEditorInput());
+			setPageText(text, "DRL Viewer");
+		} catch (PartInitException e) {
+			DroolsEclipsePlugin.log(e);
+		}
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		dslRuleEditor.doSave(monitor);
+		setInput(getEditorInput());
+	}
+
+	public void doSaveAs() {
+		dslRuleEditor.doSaveAs();
+	}
+
+	public boolean isSaveAsAllowed() {
+		return dslRuleEditor.isSaveAsAllowed();
+	}
+
+	public Object getAdapter(Class adapter) {
+		return dslRuleEditor.getAdapter(adapter);
+	}
+
+	public void setFocus() {
+		if (getActivePage() == 1) {
+			// check if translation does succeed
+			try {
+		        DefaultExpander expander = new DefaultExpander();
+		        String content = dslRuleEditor.getContent();
+	        	Reader reader = DSLAdapter.getDSLContent(content, dslRuleEditor.getResource());
+	        	if (reader == null) {
+	        		throw new IllegalArgumentException("Could not find dsl definition.");
+	        	}
+	            DSLMappingFile mapping = new DSLMappingFile();
+	            mapping.parseAndLoad(reader);
+	            reader.close();
+	            expander.addDSLMapping(mapping.getMapping());
+	            expander.expand(content);
+	            // if translation succeeds, change to drl viewer
+				drlRuleViewer.setInput(getEditorInput());
+	        } catch (Throwable t) {
+	        	// if translation fails, show error and go to first page
+	        	handleError(t);
+	        	setActivePage(0);
+	        }
+		}
+		super.setFocus();
+	}
+
+    private void handleError(Throwable t) {
+        DroolsEclipsePlugin.log( t );
+        Throwable cause = t.getCause();
+        if ( cause == null ) {
+            cause = t;
+        }
+        String message = cause.getClass().getName()+": "+cause.getMessage();
+        if ( message == null || message.length() == 0 ) {
+            message = "Uncategorized Error!";
+        }
+        IStatus status = new Status( IStatus.ERROR,
+                                     DroolsEclipsePlugin.getUniqueIdentifier(),
+                                     -1,
+                                     message,
+                                     null);
+        ErrorDialog.openError( getSite().getShell(),
+                               "DSL Rule Translation Error!",
+                               "DSL Rule Translation Error!",
+                               status );
+
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleSourceViewerConfig.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleSourceViewerConfig.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLRuleSourceViewerConfig.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,38 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.eclipse.dsl.editor.completion.DSLRuleCompletionProcessor;
+import org.drools.eclipse.editors.DRLSourceViewerConfig;
+import org.drools.eclipse.editors.completion.DefaultCompletionProcessor;
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.source.ISourceViewer;
+
+/**
+ * Source viewer config wires up the syntax highlighting, partitioning
+ * and content assistance.
+ * 
+ * @author Michael Neale
+ *
+ */
+public class DSLRuleSourceViewerConfig extends DRLSourceViewerConfig {
+
+	public DSLRuleSourceViewerConfig(DSLRuleEditor editor) {
+		super(editor);
+	}
+
+	/**
+	 * Get the appropriate content assistance, for each partition.
+	 */
+	public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+		ContentAssistant assistant = new ContentAssistant();
+		assistant.setContentAssistProcessor(
+			new DefaultCompletionProcessor(getEditor()), IDocument.DEFAULT_CONTENT_TYPE);
+		assistant.setContentAssistProcessor(
+			new DSLRuleCompletionProcessor(getEditor()), DRLPartionScanner.RULE_PART_CONTENT);
+		assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+		assistant.setAutoActivationDelay(0);
+		return assistant;
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocument.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocument.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocument.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,34 @@
+package org.drools.eclipse.dsl.editor;
+
+import java.io.Reader;
+
+import org.drools.lang.dsl.DSLMappingFile;
+import org.drools.lang.dsl.DefaultExpander;
+import org.eclipse.jface.text.IDocument;
+
+public class DSLtoDRLDocument extends TransformedDocument {
+
+	private DSLtoDRLRuleViewer viewer;
+	
+	public DSLtoDRLDocument(IDocument dslDocument, DSLtoDRLRuleViewer viewer) {
+		super(dslDocument);
+		this.viewer = viewer;
+	}
+	
+	protected String transformInput(String content) {
+        DefaultExpander expander = new DefaultExpander();
+        try {
+        	Reader reader = DSLAdapter.getDSLContent(content, viewer.getResource());
+            DSLMappingFile mapping = new DSLMappingFile();
+            mapping.parseAndLoad(reader);
+            reader.close();
+            expander.addDSLMapping(mapping.getMapping());
+            return expander.expand(content);
+        } catch (Throwable t) {
+        	//viewer.handleError(t);
+        	return content;
+        }
+
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocumentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocumentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLDocumentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,27 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.eclipse.editors.DRLDocumentProvider;
+import org.eclipse.jface.text.IDocument;
+
+public class DSLtoDRLDocumentProvider extends DRLDocumentProvider {
+
+	private DSLtoDRLRuleViewer drlViewer;
+	private IDocument document;
+	
+	public DSLtoDRLDocumentProvider(DSLtoDRLRuleViewer drlViewer) {
+		this.drlViewer = drlViewer;
+	}
+	
+	public IDocument getDocument(Object element) {
+		if (document == null) {
+			IDocument superDocument = super.getDocument(element);
+			document = new DSLtoDRLDocument(superDocument, drlViewer);
+		}
+		return document;
+    }
+	
+	public boolean isModifiable(Object element) {
+		return false;
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLRuleViewer.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLRuleViewer.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/DSLtoDRLRuleViewer.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,43 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+public class DSLtoDRLRuleViewer extends AbstractRuleEditor {
+	
+	private DSLRuleEditor dslRuleEditor;
+
+	public DSLtoDRLRuleViewer(DSLRuleEditor dslRuleEditor) {
+		this.dslRuleEditor = dslRuleEditor;
+	}
+	
+    protected IDocumentProvider createDocumentProvider() {
+    	return new DSLtoDRLDocumentProvider(this);
+    }
+    
+    public String getDSLRuleContent() {
+    	return dslRuleEditor.getContent();
+    }
+
+	public void handleError(Throwable t) {
+		DroolsEclipsePlugin.log(t);
+		Throwable cause = t.getCause();
+		if (cause == null) {
+			cause = t;
+		}
+		String message = cause.getClass().getName() + ": " + cause.getMessage();
+		if (message == null || message.length() == 0) {
+			message = "Uncategorized Error!";
+		}
+		IStatus status = new Status(IStatus.ERROR, DroolsEclipsePlugin
+				.getUniqueIdentifier(), -1, message, null);
+		ErrorDialog.openError(getSite().getShell(),
+				"DSL Rule Translation Error!", "DSL Rule Translation Error!",
+				status);
+
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/IMappingListViewer.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/IMappingListViewer.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/IMappingListViewer.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.lang.dsl.DSLMappingEntry;
+
+/**
+ * Used to keep the view up to date with changes in mappings.
+ * 
+ * @author Michael Neale
+ */
+public interface IMappingListViewer {
+
+    public void addMapping(DSLMappingEntry item);
+    
+    public void removeMapping(DSLMappingEntry item);
+    
+    public void updateMapping(DSLMappingEntry item);
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/MappingEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/MappingEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/MappingEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,221 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.drools.lang.dsl.DSLMappingEntry.Section;
+import org.eclipse.jface.dialogs.TitleAreaDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * This provides an editor for mapping language mappings.
+ * This is preferable to in place editing, as it fits the usage pattern of read lots,
+ * edit little.
+ * 
+ * This is a simple popup modal dialog.
+ * 
+ * @author Michael Neale
+ */
+public class MappingEditor extends TitleAreaDialog {
+
+    private static final int       SCOPE_KEYWORD = 0;
+    private static final int       SCOPE_WHEN    = 1;
+    private static final int       SCOPE_THEN    = 2;
+    private static final int       SCOPE_ALL     = 3;
+    
+    private static final String    SCOPE_STR_KEYWORD = "keyword"; 
+    private static final String    SCOPE_STR_WHEN = "condition"; 
+    private static final String    SCOPE_STR_THEN = "consequence"; 
+    private static final String    SCOPE_STR_ALL  = "*"; 
+
+    private Text                   exprText;
+    private Text                   mappingText;
+    private Text                   objText;
+    private Combo                  scopeCombo;
+    private boolean                cancelled;
+
+    private DSLMappingEntry model;
+
+    protected MappingEditor(Shell parent) {
+        super( parent );
+    }
+
+    /**
+     * Pass in a NLMapping item for display/edits.
+     * Changes will be applied to this object only if the user clicks OK.
+     */
+    public void setNLMappingItem(DSLMappingEntry item) {
+        model = item;
+        setSection( model.getSection() );
+        exprText.setText( model.getMappingKey() == null ? "" : model.getMappingKey() );
+        mappingText.setText( model.getMappingValue() == null ? "" : model.getMappingValue() );
+        objText.setText( model.getMetaData().getMetaData() == null ? "" : model.getMetaData().getMetaData() );
+    }
+
+    private void setSection(Section section) {
+        if ( section == DSLMappingEntry.CONDITION ) {
+            scopeCombo.select( SCOPE_WHEN );
+        } else if ( section == DSLMappingEntry.CONSEQUENCE ) {
+            scopeCombo.select( SCOPE_THEN );
+        } else if ( section == DSLMappingEntry.ANY ) {
+            scopeCombo.select( SCOPE_ALL );
+        } else if ( section == DSLMappingEntry.KEYWORD ) {
+            scopeCombo.select( SCOPE_KEYWORD );
+        } else {
+            throw new IllegalArgumentException( "Unknown scope type: " + section );
+        }
+    }
+
+    private Section getSection(String sectionStr) {
+        DSLMappingEntry.Section section = DSLMappingEntry.ANY;
+        if ( SCOPE_STR_KEYWORD.equals( sectionStr ) ) {
+            section = DSLMappingEntry.KEYWORD;
+        } else if ( SCOPE_STR_WHEN.equals( sectionStr ) ) {
+            section = DSLMappingEntry.CONDITION;
+        } else if ( SCOPE_STR_THEN.equals( sectionStr ) ) {
+            section = DSLMappingEntry.CONSEQUENCE;
+        }
+        return section;
+    }
+
+    protected void cancelPressed() {
+        this.cancelled = true;
+        super.cancelPressed();
+    }
+
+    protected void okPressed() {
+        this.cancelled = false;
+        this.model.setMappingKey( this.exprText.getText() );
+        this.model.setMappingValue( this.mappingText.getText() );
+        this.model.setSection( this.getSection( this.scopeCombo.getText() ) );
+        this.model.setMetaData( new DSLMappingEntry.DefaultDSLEntryMetaData( this.objText.getText() ) );
+        super.okPressed();
+    }
+
+    /** This will tell if the user cancelled the edit */
+    public boolean isCancelled() {
+        return cancelled;
+    }
+
+    protected Control createDialogArea(Composite parent) {
+
+        //set the overall layout
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.marginHeight = 10;
+        gridLayout.verticalSpacing = 10;
+        gridLayout.marginWidth = 10;
+        gridLayout.numColumns = 2;
+        parent.setLayout( gridLayout );
+
+        //setup fields
+        createExpressionField( parent );
+        createMappingField( parent );
+        createObjectField( parent );
+        createScopeField( parent );
+
+        // create the top level composite wrapper
+        Composite composite = new Composite( parent,
+                                             SWT.NONE );
+        GridLayout layout = new GridLayout();
+        layout.marginHeight = 10;
+        layout.marginWidth = 10;
+        layout.verticalSpacing = 10;
+        composite.setLayout( layout );
+        composite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        composite.setFont( parent.getFont() );
+
+        return composite;
+    }
+
+    private void createMappingField(Composite parent) {
+        Label mappingLbl = new Label( parent,
+                                      SWT.NONE );
+        mappingLbl.setText( "Rule mapping:" );
+        mappingLbl.setFont( parent.getFont() );
+        mappingLbl.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
+
+        mappingText = new Text( parent,
+                                SWT.BORDER );
+        GridData data = new GridData();
+        data.widthHint = 450;
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        mappingText.setLayoutData( data );
+
+        mappingText.setToolTipText( "Enter the rule language mapping that the \nlanguage item will be translated to." + " Use the named variables (holes) \nthat you specify in the language expression above." );
+
+    }
+
+    private void createExpressionField(Composite parent) {
+        Label exprLbl = new Label( parent,
+                                   SWT.NONE );
+        exprLbl.setText( "Language expression:" );
+        exprLbl.setFont( parent.getFont() );
+        exprLbl.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
+
+        exprText = new Text( parent,
+                             SWT.BORDER );
+        GridData data = new GridData();
+        data.widthHint = 450;
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        exprText.setLayoutData( data );
+        exprText.setToolTipText( "Enter the language expression that you want to use in a rule.\n" + "Use curly brackets to mark 'holes' where the values will be extracted\n" + "from in the rule source. " + "Such as: Person has a name of {name} \n"
+                                 + "This will then parse the rule source to extract the data out of \n" + "the place where {name} would appear." );
+    }
+
+    private void createObjectField(Composite parent) {
+        Label objectLbl = new Label( parent,
+                                     SWT.NONE );
+        objectLbl.setText( "Object:" );
+        objectLbl.setFont( parent.getFont() );
+        objectLbl.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
+
+        objText = new Text( parent,
+                            SWT.BORDER );
+        GridData data = new GridData();
+        data.widthHint = 450;
+        data.horizontalAlignment = GridData.FILL;
+        data.grabExcessHorizontalSpace = true;
+        objText.setLayoutData( data );
+
+        objText.setToolTipText( "Enter the name of the object." );
+
+    }
+
+    private void createScopeField(Composite parent) {
+
+        //type
+        Label scopeLbl = new Label( parent,
+                                    SWT.NONE );
+        scopeLbl.setText( "Scope:" );
+        scopeLbl.setFont( parent.getFont() );
+        scopeLbl.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_END ) );
+
+        scopeCombo = new Combo( parent,
+                                SWT.READ_ONLY );
+
+        scopeCombo.add( SCOPE_STR_KEYWORD,
+                        SCOPE_KEYWORD );
+        scopeCombo.add( SCOPE_STR_WHEN,
+                        SCOPE_WHEN );
+        scopeCombo.add( SCOPE_STR_THEN,
+                        SCOPE_THEN );
+        scopeCombo.add( SCOPE_STR_ALL,
+                        SCOPE_ALL );
+
+        scopeCombo.select( SCOPE_ALL ); //the default
+
+        scopeCombo.setLayoutData( new GridData( GridData.HORIZONTAL_ALIGN_BEGINNING ) );
+        scopeCombo.setFont( parent.getFont() );
+        scopeCombo.setToolTipText( "This specifies what part of the rule the expression applies. Indicating '*' means global." );
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/NLGrammarModel.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/NLGrammarModel.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/NLGrammarModel.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,35 @@
+package org.drools.eclipse.dsl.editor;
+
+import java.util.HashSet;
+import java.util.Set;
+
+import org.drools.lang.dsl.DefaultDSLMapping;
+
+/**
+ * This extends the compilers DSL grammar implementation to provide
+ * change listener support.
+ * 
+ * @author Michael Neale
+ *
+ */
+public class NLGrammarModel extends DefaultDSLMapping {
+    
+    private static final long serialVersionUID = 400L;
+    
+    private Set changeListeners = new HashSet();
+
+    /**
+     * @param viewer
+     */
+    public void removeChangeListener(IMappingListViewer viewer) {
+        changeListeners.remove(viewer);
+    }
+
+    /**
+     * @param viewer
+     */
+    public void addChangeListener(IMappingListViewer viewer) {
+        changeListeners.add(viewer);
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/TransformedDocument.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/TransformedDocument.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/TransformedDocument.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,93 @@
+package org.drools.eclipse.dsl.editor;
+
+import org.eclipse.jface.text.AbstractDocument;
+import org.eclipse.jface.text.DefaultLineTracker;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.jface.text.ITextStore;
+
+/**
+ * A document that transforms the input of the original document
+ * to something else.  Changing something in this document will
+ * NOT change the original document (as the transformation is only
+ * defined in one way). All changes will also be overridden as soon
+ * as the original document changes.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class TransformedDocument extends AbstractDocument {
+	
+	private IDocument parentDocument;
+	private boolean changed = true;
+		
+	public TransformedDocument(IDocument parentDocument) {
+		this.parentDocument = parentDocument;
+		parentDocument.addDocumentListener(new IDocumentListener() {
+			public void documentAboutToBeChanged(DocumentEvent event) {
+				// Do nothing
+			}
+			public void documentChanged(DocumentEvent event) {
+				changed = true;
+			}
+		});
+		setTextStore(new StringTextStore());
+		setLineTracker(new DefaultLineTracker());
+		completeInitialization();
+	}
+	
+	/** 
+	 * Always check that the store is up-to-date.
+	 * All read operations access the store so this method makes sure
+	 * that the document is updated whenever necessary.
+	 */
+	protected ITextStore getStore() {
+		if (changed) {
+			update();
+		}
+		return super.getStore();
+	}
+	
+	private void update() {
+		String translation = transformInput(parentDocument.get());
+		super.getStore().set(translation);
+		getTracker().set(translation);
+		changed = false;
+	}
+	
+	/**
+	 * Transforms the original content of the document.
+	 */
+	protected abstract String transformInput(String content);
+
+	/**
+	 * Default text store.
+	 */
+	private static class StringTextStore implements ITextStore {
+
+		private String fContent;
+
+		public StringTextStore() {
+		}
+
+		public char get(int offset) {
+			return fContent.charAt(offset);
+		}
+
+		public String get(int offset, int length) {
+			return fContent.substring(offset, offset + length);
+		}
+
+		public int getLength() {
+			return fContent.length();
+		}
+
+		public void replace(int offset, int length, String text) {
+		}
+
+		public void set(String text) {
+			this.fContent = text;
+		}
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/completion/DSLRuleCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/completion/DSLRuleCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/dsl/editor/completion/DSLRuleCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,168 @@
+package org.drools.eclipse.dsl.editor.completion;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.dsl.editor.DSLAdapter;
+import org.drools.eclipse.dsl.editor.DSLRuleEditor;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.eclipse.editors.completion.RuleCompletionProcessor;
+import org.drools.eclipse.editors.completion.RuleCompletionProposal;
+import org.drools.lang.Location;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * For handling DSL rules.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DSLRuleCompletionProcessor extends RuleCompletionProcessor {
+
+	private static final Image DSL_ICON = 
+		DroolsPluginImages.getImage(DroolsPluginImages.DSL_EXPRESSION);
+
+	public DSLRuleCompletionProcessor(AbstractRuleEditor editor) {
+		super(editor);
+	}
+
+    protected DSLRuleEditor getDSLRuleEditor() {
+    	return (DSLRuleEditor) getEditor();
+    }
+    
+	protected void addRHSCompletionProposals(List list, int documentOffset, String prefix, String backText,
+			String conditions, String consequence) {
+		// super.addRHSCompletionProposals(list, documentOffset, prefix, backText, conditions, consequence);
+		DSLAdapter adapter = getDSLRuleEditor().getDSLAdapter();
+		if (adapter != null) {
+			List dslConsequences = adapter.getDSLTree().getConsequenceChildrenList(prefix, true);
+			addDSLProposals(list, documentOffset, prefix, dslConsequences);
+		}
+	}
+	
+	protected void addLHSCompletionProposals(List list, int documentOffset,
+			Location location, String prefix, String backText) {
+		// super.addLHSCompletionProposals(list, documentOffset, location, prefix, backText);
+		DSLAdapter adapter = getDSLRuleEditor().getDSLAdapter();
+		if (adapter != null) {
+			String lastobj = this.getLastNonDashLine(backText);
+			String last = this.getLastLine(backText);
+			// we have to check if the last line is when. if it is we set
+			// the last line to zero length string
+			if (last.equals("when")) {
+				last = "";
+				lastobj = "*";
+			}
+			// pass the last string in the backText to getProposals
+			List dslConditions = this.getProposals(adapter, lastobj, last);
+			// if we couldn't find any matches, we add the list from
+			// the DSLAdapter so that there's something
+			if (dslConditions.size() == 0) {
+				dslConditions.addAll(adapter.listConditionItems());
+			}
+			addDSLProposals(list, documentOffset, prefix, dslConditions);
+		}
+	}
+	
+	private void addDSLProposals(final List list, int documentOffset, final String prefix, List dslItems) {
+		Iterator iterator = dslItems.iterator();
+		while (iterator.hasNext()) {
+			String consequence = (String) iterator.next();
+			RuleCompletionProposal p = new RuleCompletionProposal(
+				documentOffset - prefix.length(), prefix.length(), consequence);
+			p.setImage(DSL_ICON);
+			list.add(p);
+		}
+	}
+
+	/**
+	 * because of how the backText works, we need to get the last line, so that
+	 * we can pass it to the DSLUtility
+	 * 
+	 * @param backText
+	 * @return
+	 */
+	public String getLastLine(String backText) {
+		BufferedReader breader = new BufferedReader(new StringReader(backText));
+		String last = "";
+		String line = null;
+		try {
+			while ((line = breader.readLine()) != null) {
+				// only if the line has text do we set last to it
+				if (line.length() > 0) {
+					last = line;
+				}
+			}
+		} catch (IOException e) {
+			// TODO need to log this.
+			// I'm leaving this for mic_hat, so he has something to do
+		}
+		// now that all the conditions for a single object are on the same line
+		// we need to check for the left parenthesis
+		if (last.indexOf("(") > -1) {
+			last = last.substring(last.lastIndexOf("(") + 1);
+		}
+		// if the string has a comma "," we get the substring starting from
+		// the index after the last comma
+		if (last.indexOf(",") > -1) {
+			last = last.substring(last.lastIndexOf(",") + 1);
+		}
+		// if the line ends with right parenthesis, we change it to zero length
+		// string
+		if (last.endsWith(")")) {
+			last = "";
+		}
+		return last;
+	}
+
+	/**
+	 * Returns the last line that doesn't start with a dash
+	 * 
+	 * @param backText
+	 * @return
+	 */
+	public String getLastNonDashLine(String backText) {
+		BufferedReader breader = new BufferedReader(new StringReader(backText));
+		String last = "";
+		String line = null;
+		try {
+			while ((line = breader.readLine()) != null) {
+				// there may be blank lines, so we trim first
+				line = line.trim();
+				// only if the line has text do we set last to it
+				if (line.length() > 0 && !line.startsWith("-")) {
+					last = line;
+				}
+			}
+		} catch (IOException e) {
+			// TODO need to log this.
+			// I'm leaving this for mic_hat, so he has something to do
+		}
+		if (last.indexOf("(") > -1 && !last.endsWith(")")) {
+			last = last.substring(0, last.indexOf("("));
+		} else if (last.indexOf("(") > -1 && last.endsWith(")")) {
+			last = "";
+		}
+		return last;
+	}
+
+	/**
+	 * The DSLTree is configurable. It can either return just the child of the
+	 * last token found, or it can traverse the tree and generate all the
+	 * combinations beneath the last matching node. TODO I don't know how to add
+	 * configuration to the editor, so it needs to be hooked up to the
+	 * configuration for the editor later.
+	 * 
+	 * @param last
+	 * @return
+	 */
+	protected List getProposals(DSLAdapter adapter, String obj, String last) {
+		if (last.length() == 0) {
+			last = " ";
+		}
+		return adapter.getDSLTree().getChildrenList(obj, last, true);
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/AbstractRuleEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/AbstractRuleEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/AbstractRuleEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,172 @@
+package org.drools.eclipse.editors;
+
+import java.util.HashMap;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.outline.RuleContentOutlinePage;
+import org.drools.eclipse.editors.scanners.RuleEditorMessages;
+import org.drools.eclipse.preferences.IDroolsConstants;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.ui.actions.ToggleBreakpointAction;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.preference.PreferenceConverter;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.IVerticalRuler;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotation;
+import org.eclipse.jface.text.source.projection.ProjectionAnnotationModel;
+import org.eclipse.jface.text.source.projection.ProjectionSupport;
+import org.eclipse.jface.text.source.projection.ProjectionViewer;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+import org.eclipse.ui.texteditor.ITextEditorActionConstants;
+import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds;
+import org.eclipse.ui.texteditor.SourceViewerDecorationSupport;
+import org.eclipse.ui.texteditor.TextOperationAction;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Abstract text-based rule editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class AbstractRuleEditor extends TextEditor {
+
+	protected RuleContentOutlinePage ruleContentOutline = null;
+
+    protected Annotation[] oldAnnotations;
+    protected ProjectionAnnotationModel annotationModel;
+	protected DroolsPairMatcher bracketMatcher = new DroolsPairMatcher();
+	
+	public AbstractRuleEditor() {
+		setSourceViewerConfiguration(createSourceViewerConfiguration());
+		setDocumentProvider(createDocumentProvider());
+		getPreferenceStore().setDefault(IDroolsConstants.DRL_EDITOR_MATCHING_BRACKETS, true);
+		PreferenceConverter.setDefault(getPreferenceStore(), IDroolsConstants.DRL_EDITOR_MATCHING_BRACKETS_COLOR, new RGB(192, 192, 192));
+    }
+	
+	protected SourceViewerConfiguration createSourceViewerConfiguration() {
+		return new DRLSourceViewerConfig(this); 
+	}
+
+    protected IDocumentProvider createDocumentProvider() {
+    	return new DRLDocumentProvider();
+    }
+
+	public void createPartControl(Composite parent) {
+		super.createPartControl(parent);
+		ProjectionViewer viewer = (ProjectionViewer) getSourceViewer();
+		ProjectionSupport projectionSupport = new ProjectionSupport(viewer,
+			getAnnotationAccess(), getSharedColors());
+		projectionSupport.install();
+		// turn projection mode on
+		viewer.doOperation(ProjectionViewer.TOGGLE);
+		annotationModel = viewer.getProjectionAnnotationModel();
+	}
+	
+	protected ISourceViewer createSourceViewer(Composite parent,
+			IVerticalRuler ruler, int styles) {
+		ISourceViewer viewer = new ProjectionViewer(parent, ruler,
+				getOverviewRuler(), isOverviewRulerVisible(), styles);
+		// ensure decoration support has been created and configured.
+		getSourceViewerDecorationSupport(viewer);
+		return viewer;
+	}
+	
+	protected void configureSourceViewerDecorationSupport(SourceViewerDecorationSupport support) {
+		support.setCharacterPairMatcher(bracketMatcher);
+		support.setMatchingCharacterPainterPreferenceKeys(
+			IDroolsConstants.DRL_EDITOR_MATCHING_BRACKETS,
+			IDroolsConstants.DRL_EDITOR_MATCHING_BRACKETS_COLOR);
+		super.configureSourceViewerDecorationSupport(support);
+	}
+	
+	public void updateFoldingStructure(List positions) {
+		Annotation[] annotations = new Annotation[positions.size()];
+		// this will hold the new annotations along
+		// with their corresponding positions
+		HashMap newAnnotations = new HashMap();
+		for (int i = 0; i < positions.size(); i++) {
+			ProjectionAnnotation annotation = new ProjectionAnnotation();
+			newAnnotations.put(annotation, positions.get(i));
+			annotations[i] = annotation;
+		}
+		annotationModel.modifyAnnotations(oldAnnotations, newAnnotations, null);
+		oldAnnotations = annotations;
+	}
+
+	/** For user triggered content assistance */
+	protected void createActions() {
+		super.createActions();
+
+		IAction a = new TextOperationAction(RuleEditorMessages
+				.getResourceBundle(), "ContentAssistProposal.", this,
+				ISourceViewer.CONTENTASSIST_PROPOSALS);
+		a
+				.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS);
+		setAction("ContentAssistProposal", a);
+
+		a = new TextOperationAction(
+				RuleEditorMessages.getResourceBundle(),
+				"ContentAssistTip.", this, ISourceViewer.CONTENTASSIST_CONTEXT_INFORMATION); //$NON-NLS-1$
+		a
+				.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_CONTEXT_INFORMATION);
+		setAction("ContentAssistTip", a);
+		
+		a = new ToggleBreakpointAction(getSite().getPart() , null, getVerticalRuler());
+		setAction(ITextEditorActionConstants.RULER_DOUBLE_CLICK, a);
+
+	}
+	
+    protected ContentOutlinePage getContentOutline() {
+        if (ruleContentOutline == null) {
+            ruleContentOutline = new RuleContentOutlinePage(this);
+            ruleContentOutline.update();
+        }
+        return ruleContentOutline;
+    }
+
+	public String getContent() {
+		return getSourceViewer().getDocument().get();
+	}
+	
+	public IResource getResource() {
+		if (getEditorInput() instanceof IFileEditorInput) {
+			return ((IFileEditorInput) getEditorInput()).getFile();
+		}
+		return null;
+	}
+	
+	public Object getAdapter(Class adapter) {
+		if (adapter.equals(IContentOutlinePage.class)) {
+			return getContentOutline();
+		}
+		return super.getAdapter(adapter);
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		// invalidate cached parsed rules
+		DroolsEclipsePlugin.getDefault().invalidateResource(getResource());
+		// save
+		super.doSave(monitor);
+		// update outline view
+		if (ruleContentOutline != null) {
+			ruleContentOutline.update();
+		}
+	}
+
+	public void dispose() {
+		super.dispose();
+		if (bracketMatcher != null) {
+			bracketMatcher.dispose();
+			bracketMatcher = null;
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ColorManager.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ColorManager.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ColorManager.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,45 @@
+package org.drools.eclipse.editors;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * Drools color manager.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ColorManager {
+
+    private static final ColorManager INSTANCE = new ColorManager();
+    
+    public static final RGB SINGLE_LINE_COMMENT = new RGB(128, 128, 0);
+    public static final RGB KEYWORD = new RGB(150, 0, 0);
+    public static final RGB STRING = new RGB(0, 128, 0); 
+
+	protected Map colorTable = new HashMap(10);
+
+	void dispose() {
+		Iterator e = colorTable.values().iterator();
+		while (e.hasNext()) {
+			 ((Color) e.next()).dispose();
+		}
+	}
+    
+    public static ColorManager getInstance() {
+        return INSTANCE;
+    }
+    
+	public Color getColor(RGB rgb) {
+		Color color = (Color) colorTable.get(rgb);
+		if (color == null) {
+			color = new Color(Display.getCurrent(), rgb);
+			colorTable.put(rgb, color);
+		}
+		return color;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLAnnotationModel.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLAnnotationModel.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLAnnotationModel.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,39 @@
+package org.drools.eclipse.editors;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Position;
+import org.eclipse.ui.texteditor.ResourceMarkerAnnotationModel;
+
+/**
+ * Drools annotation model.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DRLAnnotationModel extends ResourceMarkerAnnotationModel {
+
+	public DRLAnnotationModel(IResource resource) {
+		super(resource);
+	}
+
+	protected Position createPositionFromMarker(IMarker marker) {
+        try {
+        	if (!marker.getType().equals(IDroolsDebugConstants.DROOLS_MARKER_TYPE)) {
+	            return super.createPositionFromMarker(marker);
+	        }
+	        int line = marker.getAttribute(IDroolsDebugConstants.DRL_LINE_NUMBER, -1);
+	        try {
+	        	return new Position(fDocument.getLineOffset(line - 1));
+	        } catch (BadLocationException exc) {
+	        	return super.createPositionFromMarker(marker);
+	        }
+        } catch (CoreException exc) {
+        	DroolsEclipsePlugin.log(exc);
+        	return null;
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLDocumentProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLDocumentProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLDocumentProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.editors;
+
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.ui.editors.text.TextFileDocumentProvider;
+
+
+/**
+ * Simple document provider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DRLDocumentProvider extends TextFileDocumentProvider {
+	
+	public IDocument getDocument(Object element) {
+        IDocument document = getParentDocument(element); 
+        if (document != null) {
+            IDocumentPartitioner partitioner =
+                new FastPartitioner(
+                    new DRLPartionScanner(),
+                    DRLPartionScanner.LEGAL_CONTENT_TYPES);
+            partitioner.connect(document);
+            document.setDocumentPartitioner(partitioner);
+        }
+        return document;
+    }
+    
+    protected IAnnotationModel createAnnotationModel(IFile file) {
+        return new DRLAnnotationModel(file);
+	}
+    
+    protected IDocument getParentDocument(Object element) {
+        return super.getDocument(element);
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLProblemAnnotation.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLProblemAnnotation.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLProblemAnnotation.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+package org.drools.eclipse.editors;
+
+import org.eclipse.jface.text.source.Annotation;
+
+/**
+ * Problem annotation for Drools.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DRLProblemAnnotation extends Annotation {
+
+	public static final String ERROR = "org.drools.eclipse.editors.error_annotation";
+	
+	public DRLProblemAnnotation(String text) {
+		super(ERROR, false, text);
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLReconcilingStrategy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLReconcilingStrategy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLReconcilingStrategy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,150 @@
+package org.drools.eclipse.editors;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.preferences.IDroolsConstants;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Position;
+import org.eclipse.jface.text.reconciler.DirtyRegion;
+import org.eclipse.jface.text.reconciler.IReconcilingStrategy;
+import org.eclipse.jface.text.source.Annotation;
+import org.eclipse.jface.text.source.IAnnotationModel;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.widgets.Display;
+
+public class DRLReconcilingStrategy implements IReconcilingStrategy {
+
+    private static final Pattern RULE_PATTERN = Pattern.compile("\\n\\s*(rule\\s+.*?\\n\\s*end)", Pattern.DOTALL);
+    private static final Pattern TEMPLATE_PATTERN = Pattern.compile("\\n\\s*(template\\s+.*?\\n\\s*end)", Pattern.DOTALL);
+    private static final Pattern QUERY_PATTERN = Pattern.compile("\\n\\s*(query\\s+.*?\\n\\s*end)", Pattern.DOTALL);
+    private static final Pattern FUNCTION_PATTERN = Pattern.compile("\\n\\s*(function\\s+[^\\{]*\\{)", Pattern.DOTALL);
+    private static final Pattern IMPORT_PATTERN = Pattern.compile("\\n\\s*((\\s*import\\s+[^\\s;]+;?[\\t\\x0B\\f\\r]*\\n)+)", Pattern.DOTALL);
+    
+	private ISourceViewer sourceViewer;
+	private AbstractRuleEditor editor;
+	private IDocument document;
+    private boolean folding;
+
+	public DRLReconcilingStrategy(ISourceViewer sourceViewer, final AbstractRuleEditor editor) {
+		this.sourceViewer = sourceViewer;
+		this.editor = editor;
+		IPreferenceStore preferenceStore = DroolsEclipsePlugin.getDefault().getPreferenceStore();
+    	folding = preferenceStore.getBoolean(IDroolsConstants.EDITOR_FOLDING);
+    	preferenceStore.addPropertyChangeListener(new IPropertyChangeListener() {
+			public void propertyChange(PropertyChangeEvent event) {
+				if (IDroolsConstants.EDITOR_FOLDING.equals(event.getProperty())) {
+					folding = ((Boolean) event.getNewValue()).booleanValue();
+					if (folding) {
+						reconcile();
+					} else {
+						Display.getDefault().asyncExec(new Runnable() {
+							public void run() {
+								editor.updateFoldingStructure(new ArrayList());
+							}
+						});
+					}
+				}
+			}
+    	});
+    }
+
+	public void setDocument(IDocument document) {
+		this.document = document;
+		reconcile();
+	}
+
+	public void reconcile(DirtyRegion dirtyRegion, IRegion region) {
+		reconcile();
+	}
+
+	public void reconcile(IRegion region) {
+		reconcile();
+	}
+
+	private void reconcile() {
+		if (document != null) {
+            String s = document.get();
+            if (folding) {
+            	calculateFolding(s);
+            }
+            
+//			IFile file = ((IFileEditorInput) input).getFile();
+//			IAnnotationModel annotationModel = sourceViewer.getAnnotationModel();
+//	        removeAnnotationsFor(annotationModel);
+//            DroolsBuildMarker[] markers = DroolsBuilder.parseFile(file, s);
+//            for (int i = 0; i < markers.length; i++) {
+//            	createAnnotation(file, annotationModel, markers[i].getText(), markers[i].getOffset(), markers[i].getLength());
+//            }
+		} 
+    }
+
+    private static void createAnnotation(IFile file, final IAnnotationModel annotationModel, final String message, final int offset, final int length) {
+		Annotation annotation = new DRLProblemAnnotation(message);
+		Position position = new Position(0, 1);
+//		Position position = new Position(offset, length);
+        annotationModel.addAnnotation(annotation, position);
+    }
+    
+    public static void removeAnnotationsFor(IAnnotationModel annotationModel) {
+		Iterator iterator = annotationModel.getAnnotationIterator();
+		while (iterator.hasNext()) {
+			Annotation annotation = (Annotation) iterator.next();
+			if (annotation instanceof DRLProblemAnnotation) {
+				annotationModel.removeAnnotation(annotation);
+			}
+		}
+    }
+
+    protected void calculateFolding(String input) {
+    	// TODO replace this parsing by getting this input from the parsed rule file
+    	final List positions = new ArrayList();
+        Matcher matcher = RULE_PATTERN.matcher(input);
+        while (matcher.find()) {
+			positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
+        }
+        matcher = QUERY_PATTERN.matcher(input);
+        while (matcher.find()) {
+			positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
+        }
+        matcher = TEMPLATE_PATTERN.matcher(input);
+        while (matcher.find()) {
+			positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
+        }
+        matcher = IMPORT_PATTERN.matcher(input);
+        while (matcher.find()) {
+			positions.add(new Position(matcher.start(1), matcher.end(1) - matcher.start(1)));
+        }
+        matcher = FUNCTION_PATTERN.matcher(input);
+        while (matcher.find()) {
+        	int start = matcher.start(1);
+        	// TODO also take comments, strings etc. in consideration
+        	// use JavaPairMatcher or similar
+        	int nbOpenBrackets = 1;
+        	for (int i = matcher.end(); i < input.length(); i++) {
+    			if (input.charAt(i) == '{') {
+    				nbOpenBrackets++;
+    			} else if (input.charAt(i) == '}') {
+    				if (--nbOpenBrackets == 0) {
+            			positions.add(new Position(start, i - start + 1));
+            			break;
+    				}
+    			}
+        	}
+        }
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				editor.updateFoldingStructure(positions);
+			}
+		});
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,295 @@
+package org.drools.eclipse.editors;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.compiler.DroolsParserException;
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.FunctionImportDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.jdt.core.CompletionRequestor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+
+/**
+ * Generic rule editor for drools.
+ * @author Michael Neale
+ */
+public class DRLRuleEditor extends AbstractRuleEditor {
+
+    protected List imports;
+    protected List functions;
+    protected Map templates;
+    protected List globals;
+    protected String packageName;
+    protected List classesInPackage;
+	protected Map attributes;
+
+    public DRLRuleEditor() {
+	}
+
+	public List getImports() {
+		if (imports == null || isDirty()) {
+			loadImportsAndFunctions();
+		}
+		return imports;
+	}
+
+	public List getFunctions() {
+		if (functions == null) {
+			loadImportsAndFunctions();
+		}
+		return functions;
+	}
+
+	public Set getTemplates() {
+		if (templates == null) {
+			loadImportsAndFunctions();
+		}
+		return templates.keySet();
+	}
+
+	public Map getAttributes() {
+		if ( attributes == null ) {
+			loadImportsAndFunctions();
+		}
+		return attributes;
+	}
+
+
+	public FactTemplateDescr getTemplate(String name) {
+		if (templates == null) {
+			loadImportsAndFunctions();
+		}
+		return (FactTemplateDescr) templates.get(name);
+	}
+
+	public List getGlobals() {
+		if (globals == null ) {
+			loadImportsAndFunctions();
+		}
+		return globals;
+	}
+
+	public String getPackage() {
+		if (packageName == null) {
+			loadImportsAndFunctions();
+		}
+		return packageName;
+	}
+
+	public List getClassesInPackage() {
+		if (classesInPackage == null) {
+			classesInPackage = getAllClassesInPackage(getPackage());
+		}
+		return classesInPackage;
+	}
+
+	protected List getAllClassesInPackage(String packageName) {
+		List list = new ArrayList();
+		if (packageName != null) {
+			IEditorInput input = getEditorInput();
+			if (input instanceof IFileEditorInput) {
+				IProject project = ((IFileEditorInput) input).getFile().getProject();
+				IJavaProject javaProject = JavaCore.create(project);
+				list = getAllClassesInPackage(packageName, javaProject);
+			}
+		}
+		return list;
+	}
+
+	public static List getAllClassesInPackage(String packageName, IJavaProject javaProject) {
+		final List list = new ArrayList();
+		CompletionRequestor requestor = new CompletionRequestor() {
+			public void accept(org.eclipse.jdt.core.CompletionProposal proposal) {
+				String className = new String(proposal.getCompletion());
+				if (proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.TYPE_REF) {
+					list.add(className);
+				}
+				// ignore all other proposals
+			}
+		};
+
+		try {
+			javaProject.newEvaluationContext().codeComplete(packageName + ".", packageName.length() + 1, requestor);
+		} catch (Throwable t) {
+			DroolsEclipsePlugin.log(t);
+		}
+		return list;
+	}
+
+	protected List getAllStaticMethodsInClass(String className) {
+		final List list = new ArrayList();
+		if (className != null) {
+			IEditorInput input = getEditorInput();
+			if (input instanceof IFileEditorInput) {
+				IProject project = ((IFileEditorInput) input).getFile().getProject();
+				IJavaProject javaProject = JavaCore.create(project);
+
+				CompletionRequestor requestor = new CompletionRequestor() {
+					public void accept(org.eclipse.jdt.core.CompletionProposal proposal) {
+						String functionName = new String(proposal.getCompletion());
+						if (proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.METHOD_REF) {
+							list.add(functionName.substring(0, functionName.length() - 2)); // remove the ()
+						}
+						// ignore all other proposals
+					}
+				};
+
+				try {
+					javaProject.newEvaluationContext().codeComplete(className + ".", className.length() + 1, requestor);
+				} catch (Throwable t) {
+					DroolsEclipsePlugin.log(t);
+				}
+			}
+		}
+		return list;
+	}
+
+    protected void loadImportsAndFunctions() {
+        try {
+            DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(this, true, false);
+            PackageDescr descr = drlInfo.getPackageDescr();
+            // package
+            this.packageName = drlInfo.getPackageName();
+            // imports
+            List allImports = descr.getImports();
+            this.imports = new ArrayList();
+            if (packageName != null) {
+                imports.addAll(getAllClassesInPackage(packageName));
+            }
+            Iterator iterator = allImports.iterator();
+            while (iterator.hasNext()) {
+                String importName = ((ImportDescr) iterator.next()).getTarget();
+                if (importName.endsWith(".*")) {
+                    String packageName = importName.substring(0, importName.length() - 2);
+                    imports.addAll(getAllClassesInPackage(packageName));
+                } else {
+                    imports.add(importName);
+                }
+            }
+            // functions
+            List functionDescrs = descr.getFunctions();
+            List functionImports = descr.getFunctionImports();
+            functions = new ArrayList(functionDescrs.size());
+            iterator = functionDescrs.iterator();
+            while (iterator.hasNext()) {
+                functions.add(((FunctionDescr) iterator.next()).getName());
+            }
+            iterator = functionImports.iterator();
+            while (iterator.hasNext()) {
+                String functionImport = ((FunctionImportDescr) iterator.next()).getTarget();
+                if (functionImport.endsWith(".*")) {
+                    String className = functionImport.substring(0, functionImport.length() - 2);
+                    functions.addAll(getAllStaticMethodsInClass(className));
+                } else {
+                    int index = functionImport.lastIndexOf('.');
+                    if (index != -1) {
+                        functions.add(functionImport.substring(index + 1));
+                    }
+                }
+            }
+            // templates
+            List templateDescrs = descr.getFactTemplates();
+            templates = new HashMap(templateDescrs.size());
+            iterator = templateDescrs.iterator();
+            while (iterator.hasNext()) {
+                FactTemplateDescr template = (FactTemplateDescr) iterator.next();
+                templates.put(template.getName(), template);
+            }
+            // globals
+            List globalDescrs = descr.getGlobals();
+            globals = new ArrayList();
+            iterator = globalDescrs.iterator();
+            while (iterator.hasNext()) {
+                GlobalDescr global = (GlobalDescr) iterator.next();
+                globals.add(global);
+            }
+
+            //attributes
+            this.attributes = new HashMap();
+        	for (Iterator attrIter = descr.getAttributes().iterator(); attrIter.hasNext();) {
+        		AttributeDescr attribute = (AttributeDescr) attrIter.next();
+        		if (attribute != null && attribute.getName() != null) {
+        			attributes.put(attribute.getName(), attribute.getValue());
+        		}
+        	}
+
+        } catch (DroolsParserException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+    }
+
+	public Object getAdapter(Class adapter) {
+		if (adapter.equals(IToggleBreakpointsTarget.class)) {
+			return getBreakpointAdapter();
+		}
+		return super.getAdapter(adapter);
+	}
+
+	private Object getBreakpointAdapter() {
+		return new DroolsLineBreakpointAdapter();
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		super.doSave(monitor);
+		// remove cached content
+		imports = null;
+		functions = null;
+		templates = null;
+		globals = null;
+		packageName = null;
+		classesInPackage = null;
+	}
+
+	public void gotoMarker(IMarker marker) {
+		try {
+			if (marker.getType().equals(IDroolsDebugConstants.DROOLS_MARKER_TYPE)) {
+				int line = marker.getAttribute(IDroolsDebugConstants.DRL_LINE_NUMBER, -1);
+	            if (line > -1)
+	            	--line;
+	                try {
+	                    IDocument document = getDocumentProvider().getDocument(getEditorInput());
+	                    selectAndReveal(document.getLineOffset(line), document.getLineLength(line));
+	                } catch(BadLocationException exc) {
+	                	DroolsEclipsePlugin.log(exc);
+	                }
+			} else {
+				super.gotoMarker(marker);
+			}
+		} catch (CoreException exc) {
+			DroolsEclipsePlugin.log(exc);
+		}
+	}
+
+
+	public BaseDescr getDescr(int offset) {
+		try {
+			DRLInfo info = DroolsEclipsePlugin.getDefault().parseResource(this, true, false);
+			return DescrUtil.getDescr(info.getPackageDescr(), offset);
+		} catch (DroolsParserException exc) {
+			return null;
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor2.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor2.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditor2.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,313 @@
+package org.drools.eclipse.editors;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.rete.ReteViewer;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.operation.IRunnableWithProgress;
+import org.eclipse.jface.text.DocumentEvent;
+import org.eclipse.jface.text.IDocumentListener;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * This is a multi table editor wrapper for both the text editor and the RETE
+ * viewer.
+ * 
+ * @author Kris
+ * @author Ahti Kitsik
+ */
+public class DRLRuleEditor2 extends FormEditor {
+
+    private DRLRuleEditor             textEditor;
+
+    private ReteViewer                reteViewer;
+
+    private ZoomComboContributionItem zitem;
+
+    private ZoomInAction2             zoomIn;
+    private ZoomOutAction2            zoomOut;
+
+    protected ReteGraph               graph;
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.forms.editor.FormEditor#init(org.eclipse.ui.IEditorSite, org.eclipse.ui.IEditorInput)
+     */
+    public void init(IEditorSite site,
+                     IEditorInput input) throws PartInitException {
+        super.init( site,
+                    input );
+        setPartName( input.getName() );
+    }
+
+    /**
+     * Adds Text Editor for rules and Rete graph viewer
+     * 
+     * @see org.eclipse.ui.forms.editor.FormEditor#addPages()
+     */
+    protected void addPages() {
+        try {
+            textEditor = new DRLRuleEditor() {
+                public void close(boolean save) {
+                    super.close( save );
+                    DRLRuleEditor2.this.close( save );
+                }
+
+                protected void setPartName(String partName) {
+                    super.setPartName( partName );
+                    DRLRuleEditor2.this.setPartName( partName );
+                }
+            };
+
+            reteViewer = new ReteViewer(textEditor);
+
+            int text = addPage( textEditor,
+                                getEditorInput() );
+
+            int rete = addPage( reteViewer,
+                                getEditorInput() );
+
+            setPageText( text,
+                         "Text Editor" );
+            setPageText( rete,
+                         "Rete Tree" );
+
+            textEditor.getDocumentProvider().getDocument( getEditorInput() ).addDocumentListener( new IDocumentListener() {
+
+                public void documentAboutToBeChanged(DocumentEvent event) {
+                }
+
+                public void documentChanged(DocumentEvent event) {
+                    reteViewer.fireDocumentChanged();
+                }
+
+            } );
+
+        } catch ( PartInitException e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.EditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+     */
+    public void doSave(IProgressMonitor monitor) {
+        textEditor.doSave( monitor );
+        setInput( getEditorInput() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.EditorPart#doSaveAs()
+     */
+    public void doSaveAs() {
+        textEditor.doSaveAs();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.EditorPart#isSaveAsAllowed()
+     */
+    public boolean isSaveAsAllowed() {
+        return textEditor.isSaveAsAllowed();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.MultiPageEditorPart#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter(Class adapter) {
+        if ( adapter == ZoomManager.class ) {
+
+            if ( getActiveEditor() instanceof ReteViewer ) {
+                return reteViewer.getAdapter( adapter );
+            } else if ( getActiveEditor() instanceof DRLRuleEditor ) {
+                return null;
+            }
+
+        } else if ( adapter == ZoomInAction2.class ) {
+            return zoomIn;
+        } else if ( adapter == ZoomOutAction2.class ) {
+            return zoomOut;
+        } else if ( adapter == ZoomComboContributionItem.class ) {
+            return zitem;
+        }
+
+        return textEditor.getAdapter( adapter );
+    }
+
+    /**
+     * Updates ZoomManagers for contributed actions.
+     */
+    private void updateZoomItems() {
+        updateZoomIn();
+
+        updateZoomOut();
+
+        updateZoomCombo();
+
+    }
+
+    private void updateZoomCombo() {
+        if ( zitem != null ) {
+            zitem.setZoomManager( getZoomManager() );
+        }
+    }
+
+    private void updateZoomIn() {
+        boolean zoomActive = getZoomManager() != null;
+        if ( zoomIn != null ) {
+            zoomIn.setZoomManager( getZoomManager() );
+            zoomIn.setEnabled( zoomActive );
+        }
+    }
+
+    private void updateZoomOut() {
+        boolean zoomActive = getZoomManager() != null;
+        if ( zoomOut != null ) {
+            zoomOut.setZoomManager( getZoomManager() );
+            zoomOut.setEnabled( zoomActive );
+        }
+    }
+
+    /**
+     * Sets ZoomComboContributionItem to be used for updating it's
+     * ZoomManager when multipage tab is switched.
+     * 
+     * @param zitem contribution item
+     */
+    public void setZoomComboContributionItem(ZoomComboContributionItem zitem) {
+        this.zitem = zitem;
+        updateZoomCombo();
+    }
+
+    private ZoomManager getZoomManager() {
+        return (ZoomManager) getAdapter( ZoomManager.class );
+    }
+
+    /**
+     * Sets ZoomOutAction2 to be used for updating it's
+     * ZoomManager when multipage tab is switched.
+     * 
+     * @param zoomOutAction zoom action
+     */
+    public void setZoomOutAction(ZoomOutAction2 zoomOutAction) {
+        this.zoomOut = zoomOutAction;
+        updateZoomOut();
+    }
+
+    /**
+     * Sets ZoomInAction to be used for updating it's
+     * ZoomManager when multipage tab is switched. 
+     * @param zoomInAction zoom action
+     */
+    public void setZoomInAction(ZoomInAction2 zoomInAction) {
+        this.zoomIn = zoomInAction;
+        updateZoomIn();
+    }
+
+    public void setFocus() {
+        if ( getActivePage() == 1 ) {
+            boolean reteFailed = false;
+            graph = null;
+            try {
+                final String contents = textEditor.getDocumentProvider().getDocument( getEditorInput() ).get();
+                final IRunnableWithProgress runnable = new IRunnableWithProgress() {
+
+                    public void run(IProgressMonitor monitor) throws InvocationTargetException,
+                                                             InterruptedException {
+                        try {
+                            graph = reteViewer.loadReteModel( monitor,
+                                                              contents );
+                        } catch ( Throwable e ) {
+                            if ( e instanceof InvocationTargetException ) {
+                                throw (InvocationTargetException) e;
+                            } else if ( e instanceof InterruptedException ) {
+                                throw (InterruptedException) e;
+                            }
+                            throw new InvocationTargetException( e );
+                        }
+
+                    }
+
+                };
+
+                getEditorSite().getWorkbenchWindow().getWorkbench().getProgressService().busyCursorWhile( runnable );
+
+                reteViewer.drawGraph( graph );
+
+            } catch ( InvocationTargetException e ) {
+                handleError( e );
+                reteFailed = true;
+            } catch ( InterruptedException e ) {
+                MessageDialog.openError( getSite().getShell(),
+                                         "Rete Tree Error!",
+                                         "Rete Tree Calculation Cancelled!" );
+                reteFailed = true;
+            } catch ( Throwable t ) {
+                handleError( t );
+                reteFailed = true;
+            }
+            if ( reteFailed ) {
+                setActivePage( 0 );
+            }
+        }
+
+        super.setFocus();
+        updateZoomItems();
+
+    }
+
+    private void handleError(Throwable t) {
+        DroolsEclipsePlugin.log( t );
+        Throwable cause = t.getCause();
+        if ( cause == null ) {
+            cause = t;
+        }
+        String message = cause.getClass().getName()+": "+cause.getMessage();
+        if ( message == null || message.length() == 0 ) {
+            message = "Uncategorized Error!";
+        }
+        IStatus status = new Status( IStatus.ERROR,
+                                     DroolsEclipsePlugin.getUniqueIdentifier(),
+                                     -1,
+                                     message,
+                                     null);
+        ErrorDialog.openError( getSite().getShell(),
+                               "Rete Tree Build Error!",
+                               "Rete Tree Build Error!",
+                               status );
+
+    }
+
+    /**
+     * Increasing visibility to allow switching tabs by page index
+     */
+    public void setActivePage(int pageIndex) {
+        super.setActivePage( pageIndex );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditorActionContributor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditorActionContributor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLRuleEditorActionContributor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,111 @@
+package org.drools.eclipse.editors;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.editors.text.TextEditorActionContributor;
+import org.eclipse.ui.part.MultiPageEditorActionBarContributor;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+/**
+ * ActionContributors for DRLRuleEditor2
+ * 
+ * Currently implements contributors to zoom feature at rete viewer. 
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class DRLRuleEditorActionContributor extends MultiPageEditorActionBarContributor {
+
+    private TextEditorActionContributor contributor = new TextEditorActionContributor();
+
+    private ZoomComboContributionItem   zitem;
+    private ZoomOutAction2              zoomOut;
+    private ZoomInAction2               zoomIn;
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.EditorActionBarContributor#init(org.eclipse.ui.IActionBars, org.eclipse.ui.IWorkbenchPage)
+     */
+    public void init(IActionBars bars,
+                     IWorkbenchPage page) {
+        contributor.init( bars );
+        super.init( bars,
+                    page );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.part.MultiPageEditorActionBarContributor#setActivePage(org.eclipse.ui.IEditorPart)
+     */
+    public void setActivePage(IEditorPart activeEditor) {
+        IActionBars bars = getActionBars();
+        if ( activeEditor instanceof ITextEditor ) {
+            if ( bars != null ) {
+                contributor.setActiveEditor( activeEditor );
+            }
+        }
+    }
+
+    /**
+     * In addition to @link org.eclipse.ui.part.MultiPageEditorActionBarContributor#setActiveEditor(org.eclipse.ui.IEditorPart)
+     * it sets contribution items to DRLRuleEditor2 for later use when
+     * multipageditor tabs are switched.
+     * 
+     */
+    public void setActiveEditor(IEditorPart part) {
+        super.setActiveEditor( part );
+        if ( part instanceof DRLRuleEditor2 ) {
+            DRLRuleEditor2 p = (DRLRuleEditor2) part;
+            p.setZoomComboContributionItem( zitem );
+            p.setZoomInAction( zoomIn );
+            p.setZoomOutAction( zoomOut );
+        }
+    }
+
+    /**
+     * Adds Zoom-related contributions.
+     * 
+     * @see org.eclipse.ui.part.EditorActionBarContributor#contributeToToolBar(org.eclipse.jface.action.IToolBarManager)
+     */
+    public void contributeToToolBar(IToolBarManager toolBarManager) {
+        super.contributeToToolBar( toolBarManager );
+        toolBarManager.add( new Separator() );
+        String[] zoomStrings = new String[]{ZoomManager.FIT_ALL, ZoomManager.FIT_HEIGHT, ZoomManager.FIT_WIDTH};
+
+        zitem = new ZoomComboContributionItem( getPage(),
+                                               zoomStrings );
+        zitem.setZoomManager( null );
+        zitem.setVisible( false );
+
+        zoomIn = new ZoomInAction2();
+        zoomIn.setEnabled( false );
+
+        zoomOut = new ZoomOutAction2();
+        zoomOut.setEnabled( false );
+
+        toolBarManager.add( zitem );
+        toolBarManager.add( zoomIn );
+        toolBarManager.add( zoomOut );
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLSourceViewerConfig.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLSourceViewerConfig.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DRLSourceViewerConfig.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,125 @@
+package org.drools.eclipse.editors;
+
+import org.drools.eclipse.editors.completion.DefaultCompletionProcessor;
+import org.drools.eclipse.editors.completion.RuleCompletionProcessor;
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.drools.eclipse.editors.scanners.DRLScanner;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.presentation.IPresentationReconciler;
+import org.eclipse.jface.text.presentation.PresentationReconciler;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.reconciler.MonoReconciler;
+import org.eclipse.jface.text.rules.BufferedRuleBasedScanner;
+import org.eclipse.jface.text.rules.DefaultDamagerRepairer;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.source.DefaultAnnotationHover;
+import org.eclipse.jface.text.source.IAnnotationHover;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewerConfiguration;
+
+/**
+ * Source viewer config wires up the syntax highlighting, partitioning
+ * and content assistance.
+ * 
+ * @author Michael Neale
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DRLSourceViewerConfig extends SourceViewerConfiguration {
+
+	private DRLScanner scanner;
+
+	private AbstractRuleEditor editor;
+
+	public DRLSourceViewerConfig(AbstractRuleEditor editor) {
+		this.editor = editor;
+	}
+	
+	protected AbstractRuleEditor getEditor() {
+		return editor;
+	}
+
+	protected DRLScanner getScanner() {
+		if (scanner == null) {
+			scanner = new DRLScanner();
+		}
+		return scanner;
+	}
+
+	/**
+	 * Define reconciler - this has to be done for each partition.
+	 * Currently there are 3 partitions, Inside rule, outside rule and inside comment.
+	 */
+	public IPresentationReconciler getPresentationReconciler(ISourceViewer sourceViewer) {
+		PresentationReconciler reconciler = new PresentationReconciler();
+
+		//bucket partition... (everything else outside a rule)
+		DefaultDamagerRepairer dr = new DefaultDamagerRepairer(getScanner());
+		reconciler.setDamager(dr, IDocument.DEFAULT_CONTENT_TYPE);
+		reconciler.setRepairer(dr, IDocument.DEFAULT_CONTENT_TYPE);
+
+		//inside a rule partition
+		dr = new DefaultDamagerRepairer(getScanner());
+		reconciler.setDamager(dr, DRLPartionScanner.RULE_PART_CONTENT);
+		reconciler.setRepairer(dr, DRLPartionScanner.RULE_PART_CONTENT);
+
+		//finally, inside a multi line comment.
+		dr = new DefaultDamagerRepairer(new SingleTokenScanner(
+				new TextAttribute(ColorManager.getInstance().getColor(
+						ColorManager.SINGLE_LINE_COMMENT))));
+		reconciler.setDamager(dr, DRLPartionScanner.RULE_COMMENT);
+		reconciler.setRepairer(dr, DRLPartionScanner.RULE_COMMENT);
+
+		return reconciler;
+	}
+
+	/**
+	 * Single token scanner, used for scanning for multiline comments mainly.
+	 */
+	static class SingleTokenScanner extends BufferedRuleBasedScanner {
+		public SingleTokenScanner(TextAttribute attribute) {
+			setDefaultReturnToken(new Token(attribute));
+		}
+	}
+
+	/**
+	 * Get the appropriate content assistance, for each partition.
+	 */
+	public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+		ContentAssistant assistant = new ContentAssistant();
+		//setup the content assistance, which is
+		//sensitive to the partition that it is in.
+		assistant.setContentAssistProcessor(
+			new DefaultCompletionProcessor(editor), IDocument.DEFAULT_CONTENT_TYPE);
+		assistant.setContentAssistProcessor(
+			new RuleCompletionProcessor(editor), DRLPartionScanner.RULE_PART_CONTENT);
+		assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+		return assistant;
+	}
+
+	public String[] getConfiguredContentTypes(ISourceViewer sourceViewer) {
+		return DRLPartionScanner.LEGAL_CONTENT_TYPES;
+	}
+
+	public IReconciler getReconciler(ISourceViewer sourceViewer) {
+		MonoReconciler reconciler = null;
+		if (sourceViewer != null) {
+			reconciler = new MonoReconciler(
+				new DRLReconcilingStrategy(sourceViewer, editor), false);
+			reconciler.setDelay(500);
+			reconciler.setProgressMonitor(new NullProgressMonitor());
+		}
+		return reconciler;
+	}
+
+	public IAnnotationHover getOverviewRulerAnnotationHover(ISourceViewer sourceViewer) {
+		return new DefaultAnnotationHover();
+	}
+
+	public IAnnotationHover getAnnotationHover(ISourceViewer sourceViewer) {
+		return new DefaultAnnotationHover();
+	}
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DescrUtil.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DescrUtil.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DescrUtil.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,108 @@
+package org.drools.eclipse.editors;
+
+import java.util.Iterator;
+
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.FunctionImportDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+
+/**
+ * Util class for searching Descr tree.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public final class DescrUtil {
+	
+	private DescrUtil() {
+	}
+
+	public static BaseDescr getDescr(BaseDescr descr, int offset) {
+		if (descr instanceof PackageDescr) {
+			PackageDescr packageDescr = (PackageDescr) descr;
+			// rules
+			for (Iterator iterator = packageDescr.getRules().iterator(); iterator.hasNext(); ) {
+				RuleDescr ruleDescr = (RuleDescr) iterator.next();
+				if (ruleDescr != null) {
+					BaseDescr result = getDescr(ruleDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// imports
+			for (Iterator iterator = packageDescr.getImports().iterator(); iterator.hasNext(); ) {
+				ImportDescr importDescr = (ImportDescr) iterator.next();
+				if (importDescr != null) {
+					BaseDescr result = getDescr(importDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// function imports
+			for (Iterator iterator = packageDescr.getFunctionImports().iterator(); iterator.hasNext(); ) {
+				FunctionImportDescr functionImportDescr = (FunctionImportDescr) iterator.next();
+				if (functionImportDescr != null) {
+					BaseDescr result = getDescr(functionImportDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// functions
+			for (Iterator iterator = packageDescr.getFunctions().iterator(); iterator.hasNext(); ) {
+				FunctionDescr functionDescr = (FunctionDescr) iterator.next();
+				if (functionDescr != null) {
+					BaseDescr result = getDescr(functionDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// attributes
+			for (Iterator iterator = packageDescr.getAttributes().iterator(); iterator.hasNext(); ) {
+				AttributeDescr attributeDescr = (AttributeDescr) iterator.next();
+				if (attributeDescr != null) {
+					BaseDescr result = getDescr(attributeDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// globals
+			for (Iterator iterator = packageDescr.getGlobals().iterator(); iterator.hasNext(); ) {
+				GlobalDescr globalDescr = (GlobalDescr) iterator.next();
+				if (globalDescr != null) {
+					BaseDescr result = getDescr(globalDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			// fact templates
+			for (Iterator iterator = packageDescr.getFactTemplates().iterator(); iterator.hasNext(); ) {
+				FactTemplateDescr factTemplDescr = (FactTemplateDescr) iterator.next();
+				if (factTemplDescr != null) {
+					BaseDescr result = getDescr(factTemplDescr, offset);
+					if (result != null) {
+						return result;
+					}
+				}
+			}
+			return null;
+		} else {
+			if (offset < descr.getStartCharacter() || offset > descr.getEndCharacter()) {
+				return null;
+			}
+			// TODO: select subDescr if possible
+			return descr;
+		}
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsLineBreakpointAdapter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsLineBreakpointAdapter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsLineBreakpointAdapter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,89 @@
+package org.drools.eclipse.editors;
+
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.debug.core.DroolsLineBreakpoint;
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
+import org.eclipse.jface.text.ITextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPart;
+
+public class DroolsLineBreakpointAdapter implements IToggleBreakpointsTarget {
+
+	public boolean canToggleLineBreakpoints(IWorkbenchPart part, ISelection selection) {
+		if (part instanceof IEditorPart && selection instanceof ITextSelection) {
+			IEditorPart editor = (IEditorPart) part;
+			IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
+			ITextSelection textSelection = (ITextSelection) selection;
+			int lineNumber = textSelection.getStartLine();
+			try {
+				DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
+				if (drlInfo != null) {
+					RuleInfo ruleInfo = drlInfo.getRuleInfo(lineNumber);
+					if (ruleInfo != null) {
+						if (ruleInfo.getConsequenceDrlLineNumber() <= lineNumber) {
+							return true;
+						}
+					}
+					FunctionInfo functionInfo = drlInfo.getFunctionInfo(lineNumber);
+					if (functionInfo != null) {
+						if (functionInfo.getDrlLineNumber() <= lineNumber) {
+							return true;
+						}
+					}
+				}
+			} catch (Throwable t) {
+				DroolsEclipsePlugin.log(t);
+			}
+		}
+		return false;
+	}
+
+	public boolean canToggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) {
+		return false;
+	}
+
+	public boolean canToggleWatchpoints(IWorkbenchPart part, ISelection selection) {
+		return false;
+	}
+
+	public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+		if (part instanceof IEditorPart) {
+			IEditorPart editor = (IEditorPart) part;
+			IResource resource = (IResource) editor.getEditorInput().getAdapter(IResource.class);
+			ITextSelection textSelection = (ITextSelection) selection;
+			int lineNumber = textSelection.getStartLine();
+			IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(IDroolsDebugConstants.ID_DROOLS_DEBUG_MODEL);
+			for (int i = 0; i < breakpoints.length; i++) {
+				IBreakpoint breakpoint = breakpoints[i];
+				if (resource.equals(breakpoint.getMarker().getResource())) {
+					if (breakpoint.getMarker().getType().equals(IDroolsDebugConstants.DROOLS_MARKER_TYPE)) {
+						if (((DroolsLineBreakpoint) breakpoint).getDRLLineNumber() == (lineNumber + 1)) {
+							breakpoint.delete();
+							return;
+						}
+					}
+				}
+			}
+			// TODO: drools breakpoints can only be created in functions and consequences
+			DroolsLineBreakpoint lineBreakpoint = new DroolsLineBreakpoint(resource, lineNumber + 1);
+			DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
+		}
+	}
+
+    public void toggleMethodBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+		// do nothing
+	}
+
+	public void toggleWatchpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
+		// do nothing
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsPairMatcher.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsPairMatcher.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/DroolsPairMatcher.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,89 @@
+package org.drools.eclipse.editors;
+
+import java.util.Stack;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IRegion;
+import org.eclipse.jface.text.Region;
+import org.eclipse.jface.text.source.ICharacterPairMatcher;
+
+public final class DroolsPairMatcher implements ICharacterPairMatcher {
+
+	private int anchor;
+	private static final char[] leftChars = new char[] { '(', '{', '[' };
+	private static final char[] rightChars = new char[] { ')', '}', ']' };
+
+	public IRegion match(IDocument document, int offset) {
+        if (offset <= 0) {
+        	return null;
+        }
+        try {
+		    char c = document.getChar(offset - 1);
+		    for (int i = 0; i < rightChars.length; i++) {
+			    if (c == rightChars[i]) {
+			        return searchLeft(document, offset, rightChars[i], leftChars[i]);
+			    }
+			    if (c == leftChars[i]) {
+			        return searchRight(document, offset, rightChars[i], leftChars[i]);
+			    }
+		    }
+        } catch (BadLocationException e) {
+        	DroolsEclipsePlugin.log(e);
+        }
+        return null;
+    }
+
+	private IRegion searchRight(IDocument document, int offset, char rightChar, char leftChar) throws BadLocationException {
+        Stack stack = new Stack();
+        anchor = ICharacterPairMatcher.LEFT;
+        char[] chars = document.get(offset, document.getLength() - offset).toCharArray();
+        for (int i = 0; i < chars.length; i++) {
+	        if (chars[i] == leftChar) {
+	            stack.push(new Character(chars[i]));
+	            continue;
+	        }
+	        if (chars[i] == rightChar) {
+	        	if (stack.isEmpty()) {
+		            return new Region(offset - 1, i + 2);
+		        } else {
+		        	stack.pop();
+		        }
+	        }
+        }
+        return null;
+    }
+
+	private IRegion searchLeft(IDocument document, int offset, char rightChar, char leftChar)
+			throws BadLocationException {
+		Stack stack = new Stack();
+		anchor = ICharacterPairMatcher.RIGHT;
+		char[] chars = document.get(0, offset - 1).toCharArray();
+        for (int i = chars.length - 1; i >= 0; i--) {
+			if (chars[i] == rightChar) {
+				stack.push(new Character(chars[i]));
+				continue;
+			}
+			if (chars[i] == leftChar) {
+				if (stack.isEmpty()) {
+					return new Region(i, offset - i);
+				} else {
+					stack.pop();
+				}
+			}
+        }
+		return null;
+	}
+
+	public int getAnchor() {
+		return anchor;
+	}
+
+	public void dispose() {
+	}
+
+	public void clear() {
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/Keywords.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/Keywords.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/Keywords.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,77 @@
+package org.drools.eclipse.editors;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * This provides a list of keywords for syntax highlighting.
+ * Uses a pseudo properties file format.
+ * @author Michael Neale
+ */
+public class Keywords {
+
+    private String[] allDrools;
+    private String[] allJava;
+    private String[] allMvel;
+    private static Keywords instance;
+
+    public static Keywords getInstance() {
+        if (instance == null) {
+            instance = new Keywords();
+        }
+        return instance;
+    }
+
+
+    public String[] getAllDroolsKeywords() {
+        return allDrools;
+    }
+
+    public String[] getAllJavaKeywords() {
+        return allJava;
+    }
+
+    public String[] getAllMvelKeywords() {
+        return allMvel;
+    }
+
+
+    private Keywords() {
+    	allDrools = readKeywords("keywords.properties");
+        allJava = readKeywords("java_keywords.properties");
+        allMvel = readKeywords("mvel_keywords.properties");
+    }
+
+    private String[] readKeywords(String fileName) {
+        InputStream stream = this.getClass().getResourceAsStream(fileName);
+        try {
+            BufferedReader reader = new BufferedReader(new InputStreamReader(stream));
+
+            List list = new ArrayList();
+
+            String line = null;
+            while ((line = reader.readLine()) != null) {
+               if (!line.startsWith( "#" ))  list.add( line );
+            }
+
+            return (String[]) list.toArray( new String[list.size()] );
+        }
+        catch ( IOException e ) {
+            throw new IllegalArgumentException("Could not load keywords for editor.");
+        }
+        finally {
+            try {
+                stream.close();
+            }
+            catch ( IOException e ) {
+                throw new IllegalStateException("Error closing stream.");
+            }
+        }
+    }
+
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomInAction2.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomInAction2.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomInAction2.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.editors;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.ScalableFigure;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.ui.actions.ZoomInAction;
+
+/**
+ * Similar to ZoomInAction but adds setZoomManager(..) functionality.
+ * 
+ * ZoomInAction2 provides default constructor for initializing
+ * ZoomInAction without the need for ZoomManager.
+ * 
+ * Please note that ZoomInAction2 is not very functional until it has
+ * correct zoomManager set by setZoomManager(ZoomManager manager).<br/>
+ * 
+ * setZoomManager(ZoomManager manager) can be used several times.
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class ZoomInAction2 extends ZoomInAction {
+
+    final private static ZoomManager FAKE_ZOOM_MANAGER = new ZoomManager( (ScalableFigure) null,
+                                                                          null );
+
+    /**
+     * Default constructor to allow ZoomInActions without specified
+     * ZoomManager.
+     */
+    public ZoomInAction2() {
+        super( FAKE_ZOOM_MANAGER );
+    }
+
+    /**
+     * Replaces existing zoomManager with the new one.
+     * 
+     * Implementation is null-safe.
+     * 
+     * @param newManager new zoom manager
+     */
+    public void setZoomManager(ZoomManager newManager) {
+
+        if ( zoomManager != null ) {
+            zoomManager.removeZoomListener( this );
+        }
+
+        zoomManager = newManager;
+
+        if ( zoomManager != null ) {
+            zoomManager.addZoomListener( this );
+        }
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomOutAction2.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomOutAction2.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/ZoomOutAction2.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.editors;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.ScalableFigure;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.ui.actions.ZoomOutAction;
+
+/**
+ * Similar to ZoomOutAction but adds setZoomManager(..) functionality.
+ * 
+ * ZoomOutAction2 provides default constructor for initializing
+ * ZoomOutAction without the need for ZoomManager.
+ * 
+ * Please note that ZoomOutAction2 is not very functional until it has
+ * correct zoomManager set by setZoomManager(ZoomManager manager).<br/>
+ * 
+ * setZoomManager(ZoomManager manager) can be used several times.
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class ZoomOutAction2 extends ZoomOutAction {
+
+    final private static ZoomManager FAKE_ZOOM_MANAGER = new ZoomManager( (ScalableFigure) null,
+                                                                          null );
+
+    /**
+     * Default constructor to allow ZoomOutActions without specified
+     * ZoomManager.
+     */
+    public ZoomOutAction2() {
+        super( FAKE_ZOOM_MANAGER );
+    }
+
+    /**
+     * Replaces existing zoomManager with the new one.
+     * 
+     * Implementation is null-safe.
+     * 
+     * @param newManager new zoom manager
+     */
+    public void setZoomManager(ZoomManager manager) {
+
+        if ( zoomManager != null ) {
+            zoomManager.removeZoomListener( this );
+        }
+
+        zoomManager = manager;
+
+        if ( zoomManager != null ) {
+            zoomManager.addZoomListener( this );
+        }
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,113 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.jface.text.contentassist.IContextInformationValidator;
+import org.eclipse.ui.IEditorPart;
+
+/**
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class AbstractCompletionProcessor implements IContentAssistProcessor {
+
+    private IEditorPart editor;
+
+    public AbstractCompletionProcessor(IEditorPart editor) {
+    	this.editor = editor;
+    }
+
+    protected IEditorPart getEditor() {
+    	return editor;
+    }
+
+	public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) {
+    	List proposals = getCompletionProposals(viewer, documentOffset);
+    	if (proposals == null) {
+    		return new ICompletionProposal[0];
+    	}
+        Collections.sort(proposals, new RuleCompletionProposal.RuleCompletionProposalComparator());
+        return (ICompletionProposal[]) proposals.toArray(new ICompletionProposal[proposals.size()]);
+	}
+
+	/**
+	 * Returns a list of RuleCompletionProposals.
+	 *
+	 * @param viewer
+	 * @param documentOffset
+	 * @return
+	 */
+	protected abstract List getCompletionProposals(ITextViewer viewer, int documentOffset);
+
+    /**
+     *  Filter out the proposals whose content does not start with the given prefix.
+     */
+    protected static void filterProposalsOnPrefix(String prefix, List props) {
+    	if ( prefix != null && prefix.trim().length() > 0 ) {
+    		Iterator iterator = props.iterator();
+            String prefixLc = prefix.toLowerCase();
+    		while ( iterator.hasNext() ) {
+                ICompletionProposal item = (ICompletionProposal) iterator.next();
+                String content = item.getDisplayString().toLowerCase();
+                if ( !content.toLowerCase().startsWith( prefixLc ) ) {
+                    iterator.remove();
+                }
+    		}
+    	}
+    }
+
+    /**
+     * Read some text from behind the cursor position.
+     * This provides context to both filter what is shown based
+     * on what the user has typed in, and also to provide more information for the
+     * list of suggestions based on context.
+     */
+    protected String readBackwards(int documentOffset, IDocument doc) throws BadLocationException {
+        int startPart = doc.getPartition(documentOffset).getOffset();
+        String prefix = doc.get(startPart, documentOffset - startPart);
+        return prefix;
+    }
+
+	/*
+	 * @see IContentAssistProcessor
+	 */
+	public char[] getCompletionProposalAutoActivationCharacters() {
+		return null;
+	}
+
+	/*
+	 * @see IContentAssistProcessor
+	 */
+	public char[] getContextInformationAutoActivationCharacters() {
+		return null;
+	}
+
+	/*
+	 * @see IContentAssistProcessor
+	 */
+	public IContextInformationValidator getContextInformationValidator() {
+		return null;
+	}
+
+	/*
+	 * @see IContentAssistProcessor
+	 */
+	public IContextInformation[] computeContextInformation(ITextViewer viewer, int documentOffset) {
+		return null;
+	}
+
+	/*
+	 * @see IContentAssistProcessor
+	 */
+	public String getErrorMessage() {
+		return null;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionContext.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionContext.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionContext.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,219 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.lang.Location;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+
+/**
+ * A utility class that invokes the DRLParser on some partial drl text, and provides
+ * information back about the context of that parserd drl,
+ * such as a location type, a dialect, and so on.
+ *
+ */
+public class CompletionContext {
+
+    static final Pattern PATTERN_PATTERN_OPERATOR            = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*([^\\s<>!=:\\(\\),]+)(\\s*([<>=!]+)\\s*[^\\s<>!=:]*\\s*(&&|\\|\\|))*\\s+",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern PATTERN_PATTERN_COMPARATOR_ARGUMENT = Pattern.compile( ".*[(,](\\s*(\\S*)\\s*:)?\\s*([^\\s<>!=:\\(\\)]+)\\s*(([<>=!]+)\\s*[^\\s<>!=:]+\\s*(&&|\\|\\|)\\s*)*([<>=!]+)\\s*[^\\s<>!=:]*",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern EVAL_PATTERN                        = Pattern.compile( ".*\\s+eval\\s*\\(\\s*([(^\\))(\\([^\\)]*\\)?)]*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ACCUMULATE_PATTERN_INIT             = Pattern.compile( ".*,?\\s*init\\s*\\(\\s*(.*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ACCUMULATE_PATTERN_ACTION           = Pattern.compile( ".*,?\\s*init\\s*\\(\\s*(.*)\\)\\s*,?\\s*action\\s*\\(\\s*(.*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ACCUMULATE_PATTERN_REVERSE          = Pattern.compile( ".*,?\\s*init\\s*\\(\\s*(.*)\\)\\s*,?\\s*action\\s*\\(\\s*(.*)\\)\\s*,?\\s*reverse\\s*\\(\\s*(.*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ACCUMULATE_PATTERN_RESULT           = Pattern.compile( ".*,?\\s*init\\s*\\(\\s*(.*)\\)\\s*,?\\s*action\\s*\\(\\s*(.*)\\)\\s*,?(\\s*reverse\\s*\\(\\s*(.*)\\)\\s*,?)?\\s*result\\s*\\(\\s*(.*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern THEN_PATTERN                        = Pattern.compile( ".*\n\\s*when\\s*(.*)\n\\s*then\\s*(.*)",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ENDS_WITH_SPACES                    = Pattern.compile( ".*\\s+",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ENDS_WITH_COLON                     = Pattern.compile( ".*:\\s*",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern ENDS_WITH_BRACKET                   = Pattern.compile( ".*\\)\\s*",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern MVEL_DIALECT_PATTERN                = Pattern.compile( ".*dialect\\s+\"mvel\".*",
+                                                                                Pattern.DOTALL );
+
+    static final Pattern JAVA_DIALECT_PATTERN                = Pattern.compile( ".*dialect\\s+\"java\".*",
+                                                                                Pattern.DOTALL );
+
+    static final String  MVEL_DIALECT                        = "mvel";
+    static final String  JAVA_DIALECT                        = "java";
+
+    private String       backText;
+    private DrlParser    parser;
+    private RuleDescr    rule;
+    private PackageDescr packageDescr;
+    private String       dialect;
+
+    public CompletionContext(String backText) {
+        this.backText = backText;
+        this.parser = new DrlParser();
+
+        try {
+            packageDescr = parser.parse( backText );
+            List rules = packageDescr.getRules();
+            if ( rules != null && rules.size() == 1 ) {
+                this.rule = (RuleDescr) rules.get( 0 );
+            }
+
+        } catch ( DroolsParserException exc ) {
+            // do nothing
+        }
+
+        //FIXME: the whole story of dialect determination for completion needs beefing up
+        determineDialect( backText );
+    }
+
+    public boolean isJavaDialect() {
+        return JAVA_DIALECT.equalsIgnoreCase( dialect );
+    }
+
+    public boolean isMvelDialect() {
+        return MVEL_DIALECT.equalsIgnoreCase( dialect );
+    }
+
+    public boolean isDefaultDialect() {
+        return !isJavaDialect() && !isMvelDialect();
+    }
+
+    public PackageDescr getPackageDescr() {
+        return packageDescr;
+    }
+
+    //note: this is a crude but reasonably fast way to determine the dialect,
+    //especially when parsing imcomplete rules
+    private void determineDialect(String backText) {
+        dialect = null;
+        boolean mvel = MVEL_DIALECT_PATTERN.matcher( backText ).matches();
+        boolean java = JAVA_DIALECT_PATTERN.matcher( backText ).matches();
+        //which dialect may be defined for this rule?
+        if ( mvel ) {
+            dialect = MVEL_DIALECT;
+        }
+        if ( java ) {
+            dialect = JAVA_DIALECT;
+        }
+    }
+
+    public Location getLocation() {
+        if ( backText == null || rule == null ) {
+            return new Location( Location.LOCATION_UNKNOWN );
+        }
+        return determineLocationForDescr( rule,
+                                          parser.getLocation(),
+                                          backText );
+    }
+
+    public RuleDescr getRule() {
+        return rule;
+    }
+
+    private static Location determineLocationForDescr(BaseDescr descr,
+                                                      Location location,
+                                                      String backText) {
+        if ( location.getType() == Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR ) {
+            if ( !ENDS_WITH_SPACES.matcher( backText ).matches() || ENDS_WITH_COLON.matcher( backText ).matches() ) {
+                location.setType( Location.LOCATION_LHS_INSIDE_CONDITION_START );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_INSIDE_CONDITION_END ) {
+            if ( !backText.endsWith( " " ) ) {
+                location.setType( Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_INSIDE_EVAL ) {
+            Matcher matcher = EVAL_PATTERN.matcher( backText );
+            if ( matcher.matches() ) {
+                String content = matcher.group( 1 );
+                location.setProperty( Location.LOCATION_EVAL_CONTENT,
+                                      content );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_INSIDE_CONDITION_START ) {
+            Matcher matcher = PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT );
+                location.setProperty( Location.LOCATION_PROPERTY_OPERATOR,
+                                      matcher.group( 7 ) );
+                return location;
+            }
+
+            matcher = PATTERN_PATTERN_OPERATOR.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR );
+                return location;
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_FROM ) {
+            if ( location.getProperty( Location.LOCATION_FROM_CONTENT ) == null ) {
+                location.setProperty( Location.LOCATION_FROM_CONTENT,
+                                      "" );
+            } else if ( ((String) location.getProperty( Location.LOCATION_FROM_CONTENT )).length() > 0 && (ENDS_WITH_SPACES.matcher( backText ).matches() || ENDS_WITH_BRACKET.matcher( backText ).matches()) ) {
+                location.setType( Location.LOCATION_LHS_BEGIN_OF_CONDITION );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_FROM_ACCUMULATE_INIT ) {
+            Matcher matcher = ACCUMULATE_PATTERN_INIT.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE );
+                location.setProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT,
+                                      matcher.group( 1 ) );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION ) {
+            Matcher matcher = ACCUMULATE_PATTERN_ACTION.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE );
+                location.setProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT,
+                                      matcher.group( 2 ) );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_FROM_ACCUMULATE_REVERSE ) {
+            Matcher matcher = ACCUMULATE_PATTERN_REVERSE.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_FROM_ACCUMULATE_REVERSE_INSIDE );
+                location.setProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_REVERSE_CONTENT,
+                                      matcher.group( 3 ) );
+            }
+            matcher = ACCUMULATE_PATTERN_RESULT.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE );
+                location.setProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT,
+                                      matcher.group( 5 ) );
+            }
+        } else if ( location.getType() == Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT ) {
+            Matcher matcher = ACCUMULATE_PATTERN_RESULT.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setType( Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE );
+                location.setProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT,
+                                      matcher.group( 5 ) );
+            }
+        } else if ( location.getType() == Location.LOCATION_RHS ) {
+            Matcher matcher = THEN_PATTERN.matcher( backText );
+            if ( matcher.matches() ) {
+                location.setProperty( Location.LOCATION_LHS_CONTENT,
+                                      matcher.group( 1 ) );
+                location.setProperty( Location.LOCATION_RHS_CONTENT,
+                                      matcher.group( 2 ) );
+                return location;
+            }
+        }
+
+        return location;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionUtil.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionUtil.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/CompletionUtil.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,435 @@
+package org.drools.eclipse.editors.completion;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.StringTokenizer;
+import java.util.regex.Pattern;
+
+import org.eclipse.jdt.core.Signature;
+
+public class CompletionUtil {
+
+    protected static final Pattern INCOMPLETED_MVEL_EXPRESSION = Pattern.compile( "[\\.\\(\\{\\[]\\Z",
+                                                                                  Pattern.DOTALL );
+
+    protected static final Pattern COMPLETED_MVEL_EXPRESSION   = Pattern.compile( "]\\)\\}\\]\\Z",
+                                                                                  Pattern.DOTALL );
+
+    protected static final Pattern MODIFY_PATTERN              = Pattern.compile( ".*modify\\s*\\(\\s*(.*)\\s*\\)(\\s*\\{(.*)\\s*\\}?)?",
+                                                                                  Pattern.DOTALL );
+
+    protected static final Pattern START_OF_NEW_JAVA_STATEMENT = Pattern.compile( ".*[;{}]\\s*",
+                                                                                  Pattern.DOTALL );
+    protected static final Pattern START_OF_METHOD_ARGS        = Pattern.compile( ".*[\\(]\\s*",
+                                                                                  Pattern.DOTALL );
+
+    private CompletionUtil() {
+    }
+
+    /**
+     * Looks behind, gets stuff after the white space. Basically ripping out the
+     * last word.
+     */
+    public static String stripLastWord(String prefix) {
+        if ( "".equals( prefix ) ) {
+            return prefix;
+        }
+        if ( prefix.charAt( prefix.length() - 1 ) == ' ' ) {
+            return "";
+        } else {
+            char[] c = prefix.toCharArray();
+            int start = 0;
+            for ( int i = c.length - 1; i >= 0; i-- ) {
+                if ( Character.isWhitespace( c[i] ) || c[i] == '(' || c[i] == ':' || c[i] == ';' || c[i] == '=' || c[i] == '<' || c[i] == '>' || c[i] == '.' || c[i] == '{' || c[i] == '}' ) {
+                    start = i + 1;
+                    break;
+                }
+            }
+            prefix = prefix.substring( start,
+                                       prefix.length() );
+            return prefix;
+        }
+    }
+
+    public static String getPreviousExpression(String backText) {
+        int separator = backText.lastIndexOf( ';' );
+        if ( separator < 0 ) {
+            return backText;
+        }
+        return backText.substring( 0,
+                                   separator + 1 );
+    }
+
+    public static String getLastExpression(String backText) {
+        StringTokenizer st = new StringTokenizer( backText,
+                                                  ";" );
+        String last = "";
+        while ( st.hasMoreTokens() ) {
+            last = st.nextToken();
+        }
+        if ( last.trim().length() == 0 ) {
+            return backText;
+        }
+        return last;
+    }
+
+    public static String getInnerExpression(String backText) {
+        String last = getLastExpression( backText ).trim();
+
+        char[] c = last.toCharArray();
+        int start = 0;
+        for ( int i = c.length - 1; i >= 0; i-- ) {
+            if ( Character.isWhitespace( c[i] ) || c[i] == '(' || c[i] == '+' || c[i] == ')' || c[i] == '[' || c[i] == ']' || c[i] == ':' || c[i] == '=' || c[i] == '<' || c[i] == '>' || c[i] == ',' || c[i] == '{' || c[i] == '}' ) {
+                start = i + 1;
+                break;
+            }
+        }
+        last = last.substring( start );
+        return last;
+    }
+
+    public static int nestedExpressionIndex(char[] chars,
+                                            int start,
+                                            char type) {
+        int depth = 1;
+        char term = type;
+        switch ( type ) {
+            case '[' :
+                term = ']';
+                break;
+            case '{' :
+                term = '}';
+                break;
+            case '(' :
+                term = ')';
+                break;
+        }
+
+        if ( type == term ) {
+            for ( start++; start < chars.length; start++ ) {
+                if ( chars[start] == type ) {
+                    return start;
+                }
+            }
+        } else {
+            for ( start++; start < chars.length; start++ ) {
+                if ( chars[start] == '\'' || chars[start] == '"' ) {
+                    //start = captureStringLiteral(chars[start], chars, start, chars.length);
+                } else if ( chars[start] == type ) {
+                    depth++;
+                } else if ( chars[start] == term && --depth == 0 ) {
+                    return start;
+                }
+            }
+        }
+
+        return -1;
+    }
+
+    public static String stripWhiteSpace(String prefix) {
+        if ( "".equals( prefix ) ) {
+            return prefix;
+        }
+        if ( prefix.charAt( prefix.length() - 1 ) == ' ' ) {
+            return "";
+        } else {
+            char[] c = prefix.toCharArray();
+            int start = 0;
+            for ( int i = c.length - 1; i >= 0; i-- ) {
+                if ( Character.isWhitespace( c[i] ) ) {
+                    start = i + 1;
+                    break;
+                }
+            }
+            prefix = prefix.substring( start,
+                                       prefix.length() );
+            return prefix;
+        }
+    }
+
+    /**
+     * Attempt to enhance a consequence backtext such that it should compile in MVEL
+     * @param backText
+     * @return a substring of the back text, that should be compilable without
+     *         syntax errors by the mvel compiler
+     *
+     *         TODO: add tests and more use
+     *         cases
+     */
+    public static String getCompilableText(String backText) {
+        String trimed = backText.trim();
+        if ( trimed.endsWith( ";" ) ) {
+            // RHS expression should compile if it ends with ; but to get the last object,
+            // we do no want it, to simulate a return statement
+            return backText.substring( 0,
+                                       backText.length() - 1 );
+        } else if ( trimed.endsWith( "." ) || trimed.endsWith( "," ) ) {
+            // RHS expression should compile if it ends with no dot or comma
+            return backText.substring( 0,
+                                       backText.length() - 1 );
+        } else if ( CompletionUtil.COMPLETED_MVEL_EXPRESSION.matcher( backText ).matches() ) {
+            // RHS expression should compile if closed. just need to close the
+            // statement
+            return backText + ";";
+            //        } else if ( INCOMPLETED_MVEL_EXPRESSION.matcher( backText ).matches() ) {
+            //            // remove the last char and close the statement
+            //            return backText.substring( 0,
+            //                                       backText.length() - 1 );
+        } else {
+            //TODO: support completion within with {} blocks
+            //TODO: support completion within nested expression.
+
+            return backText;
+        }
+    }
+
+    /*
+     * propertyname extraction and bean convention methods names checks
+     */
+
+    public static boolean isGetter(String methodName,
+                                   int argCount,
+                                   String returnedType) {
+        return isAccessor( methodName,
+                           argCount,
+                           0,
+                           "get",
+                           returnedType,
+                           Signature.SIG_VOID,
+                           false );
+    }
+
+    public static boolean isSetter(String methodName,
+                                   int argCount,
+                                   String returnedType) {
+        return isAccessor( methodName,
+                           argCount,
+                           1,
+                           "set",
+                           returnedType,
+                           Signature.SIG_VOID,
+                           true );
+    }
+
+    public static boolean isIsGetter(String methodName,
+                                     int argCount,
+                                     String returnedType) {
+        return isAccessor( methodName,
+                           argCount,
+                           0,
+                           "is",
+                           returnedType,
+                           Signature.SIG_BOOLEAN,
+                           true );
+    }
+
+    /**
+     * Given a data depicting a method (name, # or params/args, returned type key), tries to return a  bean property name derived from that method.
+     * If a bean property name is not found, the initial method name is returned
+     * @param methodName
+     * @param parameterCount
+     * @param returnType
+     * @return a bean property name
+     */
+    public static String getPropertyName(String methodName,
+                                         int parameterCount,
+                                         String returnType) {
+        if ( methodName == null ) {
+            return null;
+        }
+        String simpleName = methodName.replaceAll( "\\(\\)",
+                                                   "" );
+        int prefixLength = 0;
+        if ( isIsGetter( simpleName,
+                         parameterCount,
+                         returnType ) ) {
+
+            prefixLength = 2;
+
+        } else if ( isGetter( simpleName,
+                              parameterCount,
+                              returnType ) //
+                    || isSetter( simpleName,
+                                 parameterCount,
+                                 returnType ) ) {
+
+            prefixLength = 3;
+        } else {
+            return methodName;
+        }
+
+        char firstChar = Character.toLowerCase( simpleName.charAt( prefixLength ) );
+        String propertyName = firstChar + simpleName.substring( prefixLength + 1 );
+        return propertyName;
+    }
+
+    public static String getPropertyName(String methodName,
+                                         char[] signature) {
+        if ( signature == null || methodName == null ) {
+            return methodName;
+        }
+
+        int parameterCount = Signature.getParameterCount( signature );
+        String returnType = new String( Signature.getReturnType( signature ) );
+
+        return getPropertyName( methodName,
+                                parameterCount,
+                                returnType );
+    }
+
+    /**
+     * Given a data depicting a method (name, # or params/args, returned type key), tries to return a  writable bean property name derived from that method.
+     * If a writable (ie setter) bean property name is not found, the initial method name is returned
+     * @param methodName
+     * @param parameterCount
+     * @param returnType
+     * @return a bean property name
+     */
+    public static String getWritablePropertyName(String methodName,
+                                                 int parameterCount,
+                                                 String returnType) {
+        if ( methodName == null ) {
+            return null;
+        }
+        String simpleName = methodName.replaceAll( "\\(\\)",
+                                                   "" );
+        if ( !isSetter( simpleName,
+                        parameterCount,
+                        returnType ) ) {
+            return methodName;
+        }
+
+        int prefixLength = 3;
+
+        char firstChar = Character.toLowerCase( simpleName.charAt( prefixLength ) );
+        String propertyName = firstChar + simpleName.substring( prefixLength + 1 );
+        return propertyName;
+    }
+
+    public static String getWritablePropertyName(String methodName,
+                                                 char[] signature) {
+        if ( signature == null || methodName == null ) {
+            return methodName;
+        }
+
+        int parameterCount = Signature.getParameterCount( signature );
+        String returnType = new String( Signature.getReturnType( signature ) );
+
+        return getWritablePropertyName( methodName,
+                                        parameterCount,
+                                        returnType );
+    }
+
+    /**
+     * Determine if the given method is a bean accessor (ie getter/setter)
+     * @param methodName
+     * @param actualParameterCount
+     * @param requiredParameterCount
+     * @param prefix
+     * @param returnType
+     * @param requiredReturnType
+     * @param includeType
+     * @return true if the method is a bean accessor, false otherwise
+     */
+    private static boolean isAccessor(String methodName,
+                                      int actualParameterCount,
+                                      int requiredParameterCount,
+                                      String prefix,
+                                      String returnType,
+                                      String requiredReturnType,
+                                      boolean includeType) {
+
+        //must be longer than the accessor prefix
+        if ( methodName.length() < prefix.length() + 1 ) {
+            return false;
+        }
+
+        //start with get, set or is
+        if ( !methodName.startsWith( prefix ) ) {
+            return false;
+        }
+
+        if ( actualParameterCount != requiredParameterCount ) {
+            return false;
+        }
+
+        //if we check for the returned type, verify that the returned type is of the cirrect type signature
+        if ( includeType ) {
+            if ( !requiredReturnType.equals( returnType ) ) {
+                return false;
+            }
+        } else {
+            if ( requiredReturnType.equals( returnType ) ) {
+                return false;
+            }
+        }
+        return true;
+    }
+
+    public static boolean isStartOfNewStatement(String text,
+                                                String prefix) {
+        String javaTextWithoutPrefix = text.substring( 0,
+                                                       text.length() - prefix.length() );
+
+        if ( "".equals( javaTextWithoutPrefix.trim() ) || CompletionUtil.START_OF_NEW_JAVA_STATEMENT.matcher( javaTextWithoutPrefix ).matches() ) {
+            return true;
+        }
+        return false;
+    }
+
+    public static String getLastLine(String text) {
+        final BufferedReader reader = new BufferedReader( new StringReader( text ) );
+        String line = null;
+        String lastLine = null;
+        try {
+            while ( (line = reader.readLine()) != null ) {
+                if ( line.trim().length() > 0 ) {
+                    lastLine = line;
+                }
+            }
+        } catch ( final IOException e ) {
+            // should never happen, it's just reading over a string.
+        }
+        return lastLine;
+    }
+
+    /**
+     * COMPENSATES FOR LACK OF getSimpleName IN java.lang.Class
+     * Borrowed and adpated from MVEL's org.mvel.util.ParseTools.getSimpleClassName(Class)
+     * @param cls -- class reference
+     * @return Simple name of class
+     */
+    public static String getSimpleClassName(Class cls) {
+        int lastIndex = cls.getName().lastIndexOf( '$' );
+        if ( lastIndex < 0 ) {
+            lastIndex = cls.getName().lastIndexOf( '.' );
+        }
+        if ( cls.isArray() ) {
+            return cls.getName().substring( lastIndex + 1 ) + "[]";
+        } else {
+            return cls.getName().substring( lastIndex + 1 );
+        }
+    }
+
+    public static String getTextWithoutPrefix(final String javaText,
+                                              final String prefix) {
+        int endIndex = javaText.length() - prefix.length();
+        String javaTextWithoutPrefix = javaText;
+        //javaText can be an empty string.
+        if ( endIndex >= 0 ) {
+            javaTextWithoutPrefix = javaText.substring( 0,
+                                                        endIndex );
+        }
+        return javaTextWithoutPrefix;
+    }
+
+    public static boolean isStartOfDialectExpression(String text) {
+        return "".equals( text.trim() ) || CompletionUtil.START_OF_NEW_JAVA_STATEMENT.matcher( text ).matches();
+    }
+
+    public static boolean isStartOfMethodArgsExpression(String text) {
+        return CompletionUtil.START_OF_NEW_JAVA_STATEMENT.matcher( text ).matches();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DSLTree.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,493 @@
+package org.drools.eclipse.editors.completion;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.drools.lang.dsl.DSLMapping;
+import org.drools.lang.dsl.DSLMappingEntry;
+import org.drools.lang.dsl.DSLMappingEntry.Section;
+
+public class DSLTree {
+
+    public static final String separator = "=";
+    public static final String tab = "  ";
+    
+    private Node current = null;
+    private Node last = null;
+    private Node rootCond = null;
+    private Node rootConseq = null;
+    private boolean empty = true;
+    private ArrayList suggestions = new ArrayList();
+    private HashMap objToNL = new HashMap();
+    
+    public DSLTree() {
+        this.rootCond = new Node("root");
+        this.rootConseq = new Node("root");
+    }
+    
+    /**
+     * the method will take the dsl file and build a DSLTree using
+     * the Node class.
+     * @param dslFile
+     */
+    public void buildTree(String dslFile) {
+        buildTree(openDSLFile(dslFile));
+    }
+
+    /**
+     * the method uses the DSLAdapter to get the contents of the
+     * DSL mapping file.
+     * @param dslcontents
+     */
+    public void buildTree(Reader dslcontents) {
+    	buildTree(createBufferedReader(dslcontents));
+    }
+    
+    private void buildTree(BufferedReader breader) {
+        this.rootCond.clearChildren();
+        this.rootConseq.clearChildren();
+        parseFile(breader);
+        try {
+            breader.close();
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+        this.empty = false;
+    }
+    
+    /**
+     * method will create a BufferedReader to read the file.
+     * @param filename
+     * @return
+     */
+    protected BufferedReader openDSLFile(String filename) {
+        try {
+            FileReader reader = new FileReader(filename);
+            BufferedReader breader = new BufferedReader(reader);
+            return breader;
+        } catch (IOException e) {
+            e.printStackTrace();
+            return null;
+        }
+    }
+
+    /**
+     * Create a buffered reader for the reader created by the DSLAdapater
+     * @param reader
+     * @return
+     */
+    protected BufferedReader createBufferedReader(Reader reader) {
+		return new BufferedReader(reader);
+    }
+    
+    /**
+     * if the DSL mapping hasn't been loaded, the method will return
+     * true. If the DSL mapping has been loaded, the method returns
+     * false.
+     * @return
+     */
+    public boolean isEmpty() {
+    	return this.empty;
+    }
+    
+    /**
+     * method will use the BufferedReader to read the contents of the file.
+     * It calls other methods to parse the line and build the tree.
+     * @param reader
+     */
+    protected void parseFile(BufferedReader reader) {
+        String line = null;
+        try {
+            while ( (line = reader.readLine()) != null) {
+            	Section section = getSection(line);
+                String nl = stripHeadingAndCode(line);
+                String objname = this.getObjMetadata(nl);
+                nl = this.stripObjMetadata(nl);
+                addEntry(section, nl, objname);
+            }
+        } catch (IOException e) {
+            e.printStackTrace();
+        }
+    }
+    
+    public void buildTree(DSLMapping mapping) {
+    	List entries = mapping.getEntries();
+    	for (Iterator iterator = entries.iterator(); iterator.hasNext(); ) {
+    		DSLMappingEntry entry = (DSLMappingEntry) iterator.next();
+        	Section section = entry.getSection();
+            String nl = entry.getMappingKey();
+            String objname = entry.getMetaData().getMetaData();
+            addEntry(section, nl, objname);
+    	}
+    }
+    
+    private void addEntry(Section section, String nl, String objname) {
+        if (!nl.startsWith("-")) {
+        	if (objname != null) {
+        		this.addObjToNLMap(objname, nl);
+        	}
+            String[] tokenz = nl.split("\\s");
+            if (section == DSLMappingEntry.CONDITION || section == DSLMappingEntry.ANY) {
+            	addTokens(tokenz, rootCond);
+            }
+            if (section == DSLMappingEntry.CONSEQUENCE || section == DSLMappingEntry.ANY) {
+            	addTokens(tokenz, rootConseq);
+            }
+        } else {
+        	String res = (String)this.objToNL.get(objname);
+            StringTokenizer tokenz = new StringTokenizer(nl);
+            addTokens(res,tokenz);
+        }
+    }
+    
+    public void addObjToNLMap(String objname, String nl) {
+    	if (!objname.startsWith("-")) {
+    		this.objToNL.put(objname, nl);
+    	}
+    }
+    
+    protected Section getSection(String text) {
+        if (text.startsWith(DSLMappingEntry.CONDITION.getSymbol())) {
+            return DSLMappingEntry.CONDITION;
+        } else if (text.startsWith(DSLMappingEntry.CONSEQUENCE.getSymbol())) {
+            return DSLMappingEntry.CONSEQUENCE;
+        } else if (text.startsWith(DSLMappingEntry.ANY.getSymbol())) {
+            return DSLMappingEntry.ANY;
+        } else if (text.startsWith(DSLMappingEntry.KEYWORD.getSymbol())) {
+        	return DSLMappingEntry.KEYWORD;
+        }
+        return null; 
+    }
+    
+    /**
+     * method will strip out the when, then, * at the beginning of each 
+     * line and the mapped drl expression
+     * @param text
+     * @return
+     */
+    protected String stripHeadingAndCode(String text) {
+        if (text.startsWith(DSLMappingEntry.CONDITION.getSymbol())) {
+            return text.substring(DSLMappingEntry.CONDITION.getSymbol().length() + 2,text.indexOf("="));
+        } else if (text.startsWith(DSLMappingEntry.CONSEQUENCE.getSymbol())) {
+            return text.substring(DSLMappingEntry.CONSEQUENCE.getSymbol().length() + 2,text.indexOf("="));
+        } else if (text.startsWith(DSLMappingEntry.ANY.getSymbol())) {
+            return text.substring(DSLMappingEntry.ANY.getSymbol().length() + 2,text.indexOf("="));
+        } else if (text.startsWith("#")) {
+            return "";
+        } else {
+            return text;
+        }
+    }
+    
+    /**
+     * Method will return just the object metadata
+     * @param text
+     * @return
+     */
+    protected String getObjMetadata(String text) {
+    	if (text.startsWith("[")) {
+        	return text.substring(1,text.lastIndexOf("]"));
+    	} else {
+    		return "";
+    	}
+    }
+
+    /**
+     * method will strip the metadata from the text string
+     * @param text
+     * @return
+     */
+    protected String stripObjMetadata(String text) {
+    	if (text.startsWith("[")) {
+        	return text.substring(text.lastIndexOf("]") + 1);
+    	} else {
+    		return text;
+    	}
+    }
+    
+    /**
+     * The method is different than addTokens(StringTokenizer). this method
+     * expects additional metadata. It expects to get an object name or "*"
+     * meaning all. If the metadata is a wildcard all, it will add the
+     * tokens to all the top level nodes that are immediate child of root.
+     * @param metadata
+     * @param tokens
+     */
+    public void addTokens(String metadata, StringTokenizer tokens) {
+    	Node mnode = this.rootCond.addToken(metadata);
+    	Node thenode = mnode;
+    	while (tokens.hasMoreTokens()) {
+    		Node newnode = thenode.addToken(tokens.nextToken());
+    		thenode = newnode;
+    	}
+    }
+    
+    /**
+     * method adds the token to root
+     * @param tokens
+     */
+    public void addTokens(String[] tokens, Node rootNode) {
+        Node thenode = rootNode;
+        for (int i = 0; i < tokens.length; i++) {
+            Node newnode = thenode.addToken(tokens[i]);
+            thenode = newnode;
+        }
+    }
+    
+    /**
+     * the method will tokenize the text and try to find
+     * the node that matches and return the children. the method
+     * will traverse down the network as far as it can and return
+     * the children at that level.
+     * @param text
+     * @return
+     */
+    public Node[] getConditionChildren(String text) {
+        Node thenode = this.rootCond;
+    	if (text.length() > 0) {
+            StringTokenizer tokenz = new StringTokenizer(text);
+            this.last = this.current;
+            while (tokenz.hasMoreTokens()) {
+                String strtk = tokenz.nextToken();
+                Node ch = thenode.getChild(strtk);
+                // if a child is found, we set thenode to the child Node
+                if (ch != null) {
+                    thenode = ch;
+                } else {
+                    break;
+                }
+            }
+            if (thenode != this.rootCond) {
+                this.current = thenode;
+            }
+    	}
+        Collection children = thenode.getChildren();
+        Node[] nchild = new Node[children.size()];
+        return (Node[])children.toArray(nchild);
+    }
+
+    /**
+     * the method will tokenize the text and try to find
+     * the node that matches and return the children. the method
+     * will traverse down the network as far as it can and return
+     * the children at that level.
+     * @param text
+     * @return
+     */
+    public Node[] getConsequenceChildren(String text) {
+        Node thenode = this.rootConseq;
+    	if (text.length() >= 0) {
+            StringTokenizer tokenz = new StringTokenizer(text);
+            this.last = this.current;
+            while (tokenz.hasMoreTokens()) {
+                String strtk = tokenz.nextToken();
+                Node ch = thenode.getChild(strtk);
+                // if a child is found, we set thenode to the child Node
+                if (ch != null) {
+                    thenode = ch;
+                } else {
+                    break;
+                }
+            }
+            if (thenode != this.rootConseq) {
+                this.current = thenode;
+            }
+    	}
+        Collection children = thenode.getChildren();
+        Node[] nchild = new Node[children.size()];
+        return (Node[]) children.toArray(nchild);
+    }
+
+    /**
+     * the method expects the caller to pass the object
+     * @param obj
+     * @param text
+     * @return
+     */
+    public Node[] getChildren(String obj, String text) {
+        Node thenode = this.rootCond.getChild(obj);
+    	if (thenode != null && text.length() > 0) {
+            StringTokenizer tokenz = new StringTokenizer(text);
+            this.last = this.current;
+            while (tokenz.hasMoreTokens()) {
+                String strtk = tokenz.nextToken();
+                Node ch = thenode.getChild(strtk);
+                // if a child is found, we set thenode to the child Node
+                if (ch != null) {
+                    thenode = ch;
+                } else {
+                    break;
+                }
+            }
+            if (thenode != this.rootCond) {
+                this.current = thenode;
+            }
+    	}
+    	if (thenode == null) {
+    		return null;
+    		// thenode = this.rootCond;
+    	}
+        Collection children = thenode.getChildren();
+        Node[] nchild = new Node[children.size()];
+        return (Node[])children.toArray(nchild);
+    }
+    
+    /**
+     * for convienance, the method will return a list of strings
+     * that are children of the last node found. If the editor
+     * wants to generate the children strings, call the method
+     * with true
+     * @param text
+     * @return
+     */
+    public ArrayList getConditionChildrenList(String text, boolean addChildren) {
+    	Node[] c = getConditionChildren(text);
+    	this.suggestions.clear();
+    	for (int idx=0; idx < c.length; idx++) {
+    		this.suggestions.add(c[idx].getToken());
+    		if (addChildren) {
+        		this.addChildToList(c[idx], c[idx].getToken(), this.suggestions);
+    		}
+    	}
+    	return this.suggestions;
+    }
+    
+    /**
+     * for convienance, the method will return a list of strings
+     * that are children of the last node found. If the editor
+     * wants to generate the children strings, call the method
+     * with true
+     * @param text
+     * @return
+     */
+    public ArrayList getConsequenceChildrenList(String text, boolean addChildren) {
+    	Node[] c = getConsequenceChildren(text);
+    	this.suggestions.clear();
+    	for (int idx=0; idx < c.length; idx++) {
+    		if (addChildren) {
+        		this.addChildToList(c[idx], c[idx].getToken(), this.suggestions);
+    		} else {
+    			this.suggestions.add(c[idx].getToken());
+    		}
+    	}
+    	return this.suggestions;
+    }
+    
+    /**
+     * 
+     * @param obj
+     * @param text
+     * @param addChildren
+     * @return
+     */
+    public ArrayList getChildrenList(String obj, String text, boolean addChildren) {
+    	Node[] c = getChildren(obj,text);
+    	this.suggestions.clear();
+    	if (c != null) {
+	    	for (int idx=0; idx < c.length; idx++) {
+	    		if (addChildren) {
+	        		this.addChildToList(c[idx], c[idx].getToken(), this.suggestions);
+	    		} else {
+	    			this.suggestions.add(c[idx].getToken());
+	    		}
+	    	}
+    	}
+    	if (c == null || text.trim().length() == 0) {
+	    	// in the event the line is zero length after it is trimmed, we also add
+	    	// the top level nodes
+    		Iterator top = this.rootCond.getChildren().iterator();
+        	while (top.hasNext()) {
+        		Node t = (Node)top.next();
+        		if (!this.suggestions.contains(t.getToken())) {
+            		if (addChildren) {
+                		this.addChildToList(t, t.getToken(), this.suggestions);
+            		} else {
+                		this.suggestions.add(t.getToken());
+            		}
+        		}
+        	}
+    	}
+    	return this.suggestions;
+    }
+
+    /**
+     * method will prepend the parent text to the child and generate
+     * the possible combinations in text format.
+     * @param n
+     * @param prefix
+     * @param list
+     */
+    public void addChildToList(Node n, String prefix, ArrayList list) {
+    	if (n.getChildren().size() > 0) {
+    		Iterator itr = n.getChildren().iterator();
+    		while (itr.hasNext()) {
+    			Node child = (Node)itr.next();
+    			String text = prefix + " " + child.getToken();
+    			// list.add(text);
+    			addChildToList(child,text,list);
+    		}
+    	} else {
+    		list.add(prefix);
+    	}
+    }
+    
+    public Node getCurrent() {
+        return current;
+    }
+
+    public void setCurrent(Node current) {
+        this.current = current;
+    }
+
+    public Node getLast() {
+        return last;
+    }
+
+    public void setLast(Node last) {
+        this.last = last;
+    }
+
+    /**
+     * The method will print the DSLTree to System.out in text format.
+     */
+    public void printTree() {
+        System.out.println("ROOT");
+        Iterator itr = this.rootCond.getChildren().iterator();
+        while (itr.hasNext()) {
+            Node n = (Node)itr.next();
+            printNode(n);
+        }
+    }
+    
+    /**
+     * method will print the node and then iterate over the children
+     * @param n
+     */
+    protected void printNode(Node n) {
+        printTabs(n.getDepth());
+        System.out.println("- \"" + n.getToken() + "\"");
+        Iterator itr = n.getChildren().iterator();
+        while (itr.hasNext()) {
+            Node c = (Node)itr.next();
+            printNode(c);
+        }
+    }
+    
+    /**
+     * Method will print n number of tabs
+     * @param count
+     */
+    protected void printTabs(int count) {
+        for (int idx=0; idx < count; idx++) {
+            System.out.print(tab);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/DefaultCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,414 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.rule.builder.dialect.java.KnowledgeHelperFixer;
+import org.drools.util.StringUtils;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.jdt.core.CompletionContext;
+import org.eclipse.jdt.core.CompletionProposal;
+import org.eclipse.jdt.core.IField;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.ILocalVariable;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.eval.IEvaluationContext;
+import org.eclipse.jdt.internal.ui.text.java.AbstractJavaCompletionProposal;
+import org.eclipse.jdt.internal.ui.text.java.JavaMethodCompletionProposal;
+import org.eclipse.jdt.internal.ui.text.java.LazyJavaTypeCompletionProposal;
+import org.eclipse.jdt.ui.text.java.CompletionProposalCollector;
+import org.eclipse.jdt.ui.text.java.IJavaCompletionProposal;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IFileEditorInput;
+
+/**
+ * This is the basic completion processor that is used when the editor is outside of a rule block
+ * partition.
+ * The provides the content assistance for basic rule assembly stuff.
+ *
+ * This processor will also read behind the current editing position, to provide some context to
+ * help provide the pop up list.
+ *
+ * @author Michael Neale, Kris Verlaenen
+ */
+public class DefaultCompletionProcessor extends AbstractCompletionProcessor {
+
+    private static final String    NEW_RULE_TEMPLATE           = "rule \"new rule\"" + System.getProperty( "line.separator" ) + "\twhen" + System.getProperty( "line.separator" ) + "\t\t" + System.getProperty( "line.separator" ) + "\tthen"
+                                                                 + System.getProperty( "line.separator" ) + "\t\t" + System.getProperty( "line.separator" ) + "end";
+    private static final String    NEW_QUERY_TEMPLATE          = "query \"query name\"" + System.getProperty( "line.separator" ) + "\t#conditions" + System.getProperty( "line.separator" ) + "end";
+    private static final String    NEW_FUNCTION_TEMPLATE       = "function void yourFunction(Type arg) {" + System.getProperty( "line.separator" ) + "\t/* code goes here*/" + System.getProperty( "line.separator" ) + "}";
+    private static final String    NEW_TEMPLATE_TEMPLATE       = "template Name" + System.getProperty( "line.separator" ) + "\t" + System.getProperty( "line.separator" ) + "end";
+    protected static final Pattern IMPORT_PATTERN              = Pattern.compile( ".*\n\\W*import\\W[^;\\s]*",
+                                                                                  Pattern.DOTALL );
+    // TODO: doesn't work for { inside functions
+    private static final Pattern   FUNCTION_PATTERN            = Pattern.compile( ".*\n\\W*function\\s+(\\S+)\\s+(\\S+)\\s*\\(([^\\)]*)\\)\\s*\\{([^\\}]*)",
+                                                                                  Pattern.DOTALL );
+    protected static final Image   VARIABLE_ICON               = DroolsPluginImages.getImage( DroolsPluginImages.VARIABLE );
+    protected static final Image   METHOD_ICON                 = DroolsPluginImages.getImage( DroolsPluginImages.METHOD );
+    protected static final Image   CLASS_ICON                  = DroolsPluginImages.getImage( DroolsPluginImages.CLASS );
+
+    public DefaultCompletionProcessor(AbstractRuleEditor editor) {
+        super( editor );
+    }
+
+    protected List getCompletionProposals(ITextViewer viewer,
+                                          int documentOffset) {
+        try {
+            IDocument doc = viewer.getDocument();
+            String backText = readBackwards( documentOffset,
+                                             doc );
+
+            String prefix = CompletionUtil.stripLastWord( backText );
+
+            List props = null;
+            Matcher matcher = IMPORT_PATTERN.matcher( backText );
+            if ( matcher.matches() ) {
+                String classNameStart = backText.substring( backText.lastIndexOf( "import" ) + 7 );
+                props = getAllClassProposals( classNameStart,
+                                              documentOffset,
+                                              prefix );
+            } else {
+                matcher = FUNCTION_PATTERN.matcher( backText );
+                if ( matcher.matches() ) {
+                    // extract function parameters
+                    Map params = extractParams( matcher.group( 3 ) );
+                    // add global parameters
+                    List globals = getGlobals();
+                    if ( globals != null ) {
+                        for ( Iterator iterator = globals.iterator(); iterator.hasNext(); ) {
+                            GlobalDescr global = (GlobalDescr) iterator.next();
+                            params.put( global.getIdentifier(),
+                                        global.getType() );
+                        }
+                    }
+                    String functionText = matcher.group( 4 );
+                    props = getJavaCompletionProposals( documentOffset,
+                                                        functionText,
+                                                        prefix,
+                                                        params );
+                    filterProposalsOnPrefix( prefix,
+                                             props );
+                } else {
+                    props = getPossibleProposals( viewer,
+                                                  documentOffset,
+                                                  backText,
+                                                  prefix );
+                }
+            }
+            return props;
+        } catch ( Throwable t ) {
+            DroolsEclipsePlugin.log( t );
+        }
+        return null;
+    }
+
+    private Map extractParams(String params) {
+        Map result = new HashMap();
+        String[] parameters = StringUtils.split( params,
+                                                 "," );
+        for ( int i = 0; i < parameters.length; i++ ) {
+            String[] typeAndName = StringUtils.split( parameters[i] );
+            if ( typeAndName.length == 2 ) {
+                result.put( typeAndName[1],
+                            typeAndName[0] );
+            }
+        }
+        return result;
+    }
+
+    /*
+     * create and returns a java project based on the current editor input or returns null
+     */
+    private IJavaProject getCurrentJavaProject() {
+        IEditorInput input = getEditor().getEditorInput();
+        if ( !(input instanceof IFileEditorInput) ) {
+            return null;
+        }
+        IProject project = ((IFileEditorInput) input).getFile().getProject();
+        IJavaProject javaProject = JavaCore.create( project );
+        return javaProject;
+    }
+
+    protected List getAllClassProposals(final String classNameStart,
+                                        final int documentOffset,
+                                        final String prefix) {
+        List result = new ArrayList();
+        IJavaProject javaProject = getCurrentJavaProject();
+        if ( javaProject == null ) {
+            return result;
+        }
+        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject ) {
+            public void accept(CompletionProposal proposal) {
+                if ( proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.PACKAGE_REF || proposal.getKind() == org.eclipse.jdt.core.CompletionProposal.TYPE_REF ) {
+                    super.accept( proposal );
+                }
+            }
+        };
+        collector.acceptContext( new CompletionContext() );
+        try {
+            IEvaluationContext evalContext = javaProject.newEvaluationContext();
+            evalContext.codeComplete( classNameStart,
+                                      classNameStart.length(),
+                                      collector );
+            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
+            for ( int i = 0; i < proposals.length; i++ ) {
+                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
+                    AbstractJavaCompletionProposal javaProposal = (AbstractJavaCompletionProposal) proposals[i];
+                    int replacementOffset = documentOffset - (classNameStart.length() - javaProposal.getReplacementOffset());
+                    javaProposal.setReplacementOffset( replacementOffset );
+                    if ( javaProposal instanceof LazyJavaTypeCompletionProposal ) {
+                        String completionPrefix = classNameStart.substring( classNameStart.length() - javaProposal.getReplacementLength() );
+                        int dotIndex = completionPrefix.lastIndexOf( '.' );
+                        // match up to the last dot in order to make higher level matching still work (camel case...)
+                        if ( dotIndex != -1 ) {
+                            javaProposal.setReplacementString( ((LazyJavaTypeCompletionProposal) javaProposal).getQualifiedTypeName() );
+                        }
+                    }
+                    result.add( proposals[i] );
+                }
+            }
+        } catch ( Throwable t ) {
+            DroolsEclipsePlugin.log( t );
+        }
+        return result;
+    }
+
+    protected List getPossibleProposals(ITextViewer viewer,
+                                        int documentOffset,
+                                        String backText,
+                                        final String prefix) {
+        List list = new ArrayList();
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "rule",
+                                              NEW_RULE_TEMPLATE,
+                                              6 ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "import",
+                                              "import " ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "expander",
+                                              "expander " ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "global",
+                                              "global " ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "package",
+                                              "package " ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "query",
+                                              NEW_QUERY_TEMPLATE ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "function",
+                                              NEW_FUNCTION_TEMPLATE,
+                                              14 ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "template",
+                                              NEW_TEMPLATE_TEMPLATE,
+                                              9 ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "dialect \"java\"",
+                                              "dialect \"java\" " ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "dialect \"mvel\"",
+                                              "dialect \"mvel\" " ) );
+        filterProposalsOnPrefix( prefix,
+                                 list );
+        return list;
+    }
+
+    protected List getJavaCompletionProposals(final int documentOffset,
+                                              final String javaText,
+                                              final String prefix,
+                                              Map params) {
+        final List list = new ArrayList();
+        requestJavaCompletionProposals( javaText,
+                                        prefix,
+                                        documentOffset,
+                                        params,
+                                        list );
+        return list;
+    }
+
+    /*
+     * do we already have a completion for that string that would be either a local variable or a field?
+     */
+    protected static boolean doesNotContainFieldCompletion(String completion,
+                                                         List completions) {
+        if ( completion == null || completion.length() == 0 || completions == null ) {
+            return false;
+        }
+        for ( Iterator iter = completions.iterator(); iter.hasNext(); ) {
+            Object o = iter.next();
+            if ( o instanceof AbstractJavaCompletionProposal ) {
+                AbstractJavaCompletionProposal prop = (AbstractJavaCompletionProposal) o;
+                String content = prop.getReplacementString();
+                if ( completion.equals( content ) ) {
+                    IJavaElement javaElement = prop.getJavaElement();
+                    if ( javaElement instanceof ILocalVariable || javaElement instanceof IField ) {
+                        return false;
+                    }
+                }
+            }
+        }
+        return true;
+    }
+
+    protected void requestJavaCompletionProposals(final String javaText,
+                                                  final String prefix,
+                                                  final int documentOffset,
+                                                  Map params,
+                                                  Collection results) {
+
+
+        String javaTextWithoutPrefix = CompletionUtil.getTextWithoutPrefix( javaText,
+                                                                            prefix );
+        // boolean to filter default Object methods produced by code completion when in the beginning of a statement
+        boolean filterObjectMethods = false;
+        if ( "".equals( javaTextWithoutPrefix.trim() ) || CompletionUtil.START_OF_NEW_JAVA_STATEMENT.matcher( javaTextWithoutPrefix ).matches() ) {
+            filterObjectMethods = true;
+        }
+        IJavaProject javaProject = getCurrentJavaProject();
+        if ( javaProject == null ) {
+            return;
+        }
+
+        CompletionProposalCollector collector = new CompletionProposalCollector( javaProject );
+        collector.acceptContext( new CompletionContext() );
+
+        try {
+            IEvaluationContext evalContext = javaProject.newEvaluationContext();
+            List imports = getImports();
+            if ( imports != null && imports.size() > 0 ) {
+                evalContext.setImports( (String[]) imports.toArray( new String[imports.size()] ) );
+            }
+            StringBuffer javaTextWithParams = new StringBuffer();
+            Iterator iterator = params.entrySet().iterator();
+            while ( iterator.hasNext() ) {
+                Map.Entry entry = (Map.Entry) iterator.next();
+                // this does not seem to work, so adding variables manually
+                // evalContext.newVariable((String) entry.getValue(), (String) entry.getKey(), null);
+                javaTextWithParams.append( entry.getValue() + " " + entry.getKey() + ";\n" );
+            }
+            javaTextWithParams.append( "org.drools.spi.KnowledgeHelper drools;" );
+            javaTextWithParams.append( javaText );
+            String jtext = javaTextWithParams.toString();
+            String fixedText = new KnowledgeHelperFixer().fix( jtext );
+
+            evalContext.codeComplete( fixedText,
+                                      fixedText.length(),
+                                      collector );
+            IJavaCompletionProposal[] proposals = collector.getJavaCompletionProposals();
+            for ( int i = 0; i < proposals.length; i++ ) {
+                if ( proposals[i] instanceof AbstractJavaCompletionProposal ) {
+                    AbstractJavaCompletionProposal javaProposal = (AbstractJavaCompletionProposal) proposals[i];
+                    int replacementOffset = documentOffset - (fixedText.length() - javaProposal.getReplacementOffset());
+                    javaProposal.setReplacementOffset( replacementOffset );
+                    if ( javaProposal instanceof LazyJavaTypeCompletionProposal ) {
+                        String completionPrefix = javaText.substring( javaText.length() - javaProposal.getReplacementLength() );
+                        int dotIndex = completionPrefix.lastIndexOf( '.' );
+                        // match up to the last dot in order to make higher level matching still work (camel case...)
+                        if ( dotIndex != -1 ) {
+                            javaProposal.setReplacementString( ((LazyJavaTypeCompletionProposal) javaProposal).getQualifiedTypeName() );
+                        }
+                    }
+                    if ( !filterObjectMethods || !(proposals[i] instanceof JavaMethodCompletionProposal) ) {
+                        results.add( proposals[i] );
+                    }
+                }
+            }
+        } catch ( Throwable t ) {
+            DroolsEclipsePlugin.log( t );
+        }
+    }
+
+    protected String getPackage() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getPackage();
+        }
+        return "";
+    }
+
+    protected List getImports() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getImports();
+        }
+        return Collections.EMPTY_LIST;
+    }
+
+    protected Set getUniqueImports() {
+        HashSet set = new HashSet();
+        set.addAll( getImports() );
+        return set;
+    }
+
+    protected List getFunctions() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getFunctions();
+        }
+        return Collections.EMPTY_LIST;
+    }
+
+    protected Map getAttributes() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getAttributes();
+        }
+        return Collections.EMPTY_MAP;
+    }
+
+    protected Set getTemplates() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getTemplates();
+        }
+        return Collections.EMPTY_SET;
+    }
+
+    protected FactTemplateDescr getTemplate(String name) {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getTemplate( name );
+        }
+        return null;
+    }
+
+    protected List getGlobals() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getGlobals();
+        }
+        return Collections.EMPTY_LIST;
+    }
+
+    protected List getClassesInPackage() {
+        if ( getEditor() instanceof DRLRuleEditor ) {
+            return ((DRLRuleEditor) getEditor()).getClassesInPackage();
+        }
+        return Collections.EMPTY_LIST;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/Node.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/Node.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/Node.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,110 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.Collection;
+import java.util.HashMap;
+
+public class Node {
+    private HashMap children = new HashMap();
+    private Node parent = null;
+    private String token;
+    private int depth = 0;
+    
+    public Node(String name) {
+        this.token = name;
+    }
+
+    /**
+     * The method will create a new Node instance and try to add it as
+     * a child node. If an Node with the same string token exists, the
+     * method will return the existing node instead.
+     * @param token
+     * @return
+     */
+    public Node addToken(String token) {
+        Node newnode = new Node(token);
+        // set the depth first
+        newnode.setDepth(depth + 1);
+        // add the node as a child
+        newnode = addChild(newnode);
+        return newnode;
+    }
+    
+    /**
+     * if the string matches this node's token, the method will return
+     * true. Otherwise it returns false.
+     * @param input
+     * @return
+     */
+    public boolean isMatch(String input) {
+        return input.equals(token);
+    }
+
+    public boolean isMatch(Node n) {
+        return this.token.equals(n.getToken());
+    }
+    
+    /**
+     * The method will check to see if a Node with the same string token
+     * already exists. If it doesn't, it will add the token as a child and
+     * return the same node.
+     * 
+     * On the otherhand, if there is an existing Node for the same string
+     * token, the method returns the existing Node instance.
+     * @param n
+     * @return
+     */
+    public Node addChild(Node n) {
+        if (!this.children.containsKey(n.getToken())) {
+            this.children.put(n.getToken(),n);
+            n.setParent(this);
+            return n;
+        } else {
+            return (Node)this.children.get(n.getToken());
+        }
+    }
+    
+    public void removeChild(Node n) {
+        this.children.remove(n.getToken());
+    }
+    
+    public Collection getChildren() {
+        return this.children.values();
+    }
+
+    /**
+     * The method will get the child matching the string token
+     * @param token
+     * @return
+     */
+    public Node getChild(String token) {
+        return (Node)this.children.get(token);
+    }
+    
+    public Node getParent() {
+        return parent;
+    }
+
+    public void setParent(Node parent) {
+        this.parent = parent;
+    }
+
+    public String getToken() {
+        return token;
+    }
+
+    public void setToken(String token) {
+        this.token = token;
+    }
+    
+    public int getDepth() {
+        return depth;
+    }
+
+    public void setDepth(int depth) {
+        this.depth = depth;
+    }
+    
+    public void clearChildren() {
+        this.children.clear();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/ReflectionUtils.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/ReflectionUtils.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/ReflectionUtils.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,35 @@
+package org.drools.eclipse.editors.completion;
+
+import java.lang.reflect.Field;
+
+public class ReflectionUtils {
+
+	private ReflectionUtils() {
+	}
+
+	public static Object getField(Object instance, String name) {
+		Class clazz = instance.getClass();
+
+		do {
+			Field[] fields = clazz.getDeclaredFields();
+			for (int i = 0; i < fields.length; i++) {
+				Field f = fields[i];
+				if (name.equals(f.getName())) {
+					try {
+						f.setAccessible(true);
+						return f.get(instance);
+
+					} catch (SecurityException ex) {
+						return null;
+					} catch (IllegalArgumentException ex) {
+						return null;
+					} catch (IllegalAccessException ex) {
+						return null;
+					}
+				}
+			}
+			clazz = clazz.getSuperclass();
+		} while (clazz.getSuperclass() != null);
+		return null;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,1642 @@
+package org.drools.eclipse.editors.completion;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.regex.Matcher;
+
+import org.drools.base.ClassTypeResolver;
+import org.drools.compiler.PackageBuilderConfiguration;
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.DroolsPluginImages;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.drools.eclipse.util.ProjectClassLoader;
+import org.drools.lang.Location;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldTemplateDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.rule.builder.dialect.mvel.MVELConsequenceBuilder;
+import org.drools.rule.builder.dialect.mvel.MVELDialect;
+import org.drools.spi.KnowledgeHelper;
+import org.drools.util.asm.ClassFieldInspector;
+import org.eclipse.jdt.core.CompletionProposal;
+import org.eclipse.jdt.core.IJavaElement;
+import org.eclipse.jdt.internal.ui.text.java.JavaCompletionProposal;
+import org.eclipse.jdt.internal.ui.text.java.JavaMethodCompletionProposal;
+import org.eclipse.jdt.internal.ui.text.java.LazyJavaCompletionProposal;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.swt.graphics.Image;
+import org.mvel.CompiledExpression;
+import org.mvel.ExpressionCompiler;
+import org.mvel.ParserContext;
+import org.mvel.PropertyVerifier;
+
+/**
+ * For handling within rules.
+ *
+ * @author Michael Neale, Kris Verlanen
+ */
+public class RuleCompletionProcessor extends DefaultCompletionProcessor {
+
+    private static final String DIALECT     = "dialect";
+
+    private static final Image  DROOLS_ICON = DroolsPluginImages.getImage( DroolsPluginImages.DROOLS );
+
+    private static final Image  CLASS_ICON  = DroolsPluginImages.getImage( DroolsPluginImages.CLASS );
+
+    /**
+     * A CompletionContext contains the DRL backtext parsing results, to avoid
+     * multilpe parser invocations
+     */
+    private CompletionContext   context;
+
+    public RuleCompletionProcessor(AbstractRuleEditor editor) {
+        super( editor );
+    }
+
+    protected List getCompletionProposals(ITextViewer viewer,
+                                          int documentOffset) {
+        try {
+            final List list = new ArrayList();
+            IDocument doc = viewer.getDocument();
+
+            String backText = readBackwards( documentOffset,
+                                             doc );
+            final String prefix = CompletionUtil.stripLastWord( backText );
+
+            // if inside the keyword "rule ", no code completion
+            if ( backText.length() < 5 ) {
+                return list;
+            }
+
+            this.context = new CompletionContext( backText );
+            Location location = context.getLocation();
+
+            if ( location.getType() == Location.LOCATION_RULE_HEADER ) {
+                addRuleHeaderProposals( list,
+                                        documentOffset,
+                                        prefix,
+                                        backText );
+            } else if ( location.getType() == Location.LOCATION_RHS ) {
+                addRHSCompletionProposals( list,
+                                           documentOffset,
+                                           prefix,
+                                           backText,
+                                           (String) location.getProperty( Location.LOCATION_LHS_CONTENT ),
+                                           (String) location.getProperty( Location.LOCATION_RHS_CONTENT ) );
+            } else {
+                addLHSCompletionProposals( list,
+                                           documentOffset,
+                                           location,
+                                           prefix,
+                                           backText );
+            }
+
+            filterProposalsOnPrefix( prefix,
+                                     list );
+            return list;
+        } catch ( Throwable t ) {
+            DroolsEclipsePlugin.log( t );
+        }
+        return null;
+    }
+
+    protected void addRHSCompletionProposals(List list,
+                                             int documentOffset,
+                                             String prefix,
+                                             String backText,
+                                             String conditions,
+                                             String consequence) {
+        // only add functions and keywords if at the beginning of a
+        // new statement
+        if ( consequence == null || consequence.length() < prefix.length() ) {
+            // possible if doing code completion directly after "then"
+            return;
+        }
+        String consequenceWithoutPrefix = consequence.substring( 0,
+                                                                 consequence.length() - prefix.length() );
+
+        if ( context == null ) {
+            context = new CompletionContext( backText );
+        }
+
+        boolean startOfDialectExpression = CompletionUtil.isStartOfDialectExpression( consequenceWithoutPrefix );
+        if ( isJavaDialect() && startOfDialectExpression ) {
+            addRHSKeywordCompletionProposals( list,
+                                              documentOffset,
+                                              prefix );
+            addRHSFunctionCompletionProposals( list,
+                                               documentOffset,
+                                               prefix );
+        }
+        
+
+        //if we have 1st a dialect defined locally, or 2nd a global dialect
+        //the locally defined dialect will override the package default
+        if ( isJavaDialect() ) {
+            addRHSJavaCompletionProposals( list,
+                                           documentOffset,
+                                           prefix,
+                                           backText,
+                                           consequence );
+        } else if ( isMvelDialect() ) {
+            addRHSMvelCompletionProposals( list,
+                                           documentOffset,
+                                           prefix,
+                                           backText,
+                                           consequence,
+                                           startOfDialectExpression );
+        }
+    }
+
+    private boolean isJavaDialect() {
+        // java is the default dialect, so no package dialect means java
+        // conditions are ordered from the more specific to the more general
+        if ( context.isJavaDialect() ) {
+            return true;
+        } else if ( context.isDefaultDialect() && (!(getAttributes().containsKey( DIALECT )) || hasPackageDialect( "java" )) ) {
+            return true;
+        }
+
+        return false;
+    }
+
+    private boolean isMvelDialect() {
+        if ( context.isMvelDialect() ) {
+            return true;
+        } else if ( context.isDefaultDialect() && hasPackageDialect( "mvel" ) ) {
+            return true;
+        }
+        return false;
+    }
+
+    private boolean hasPackageDialect(String dialect) {
+        String globalDialect = (String) getAttributes().get( DIALECT );
+        if ( globalDialect != null && dialect.equalsIgnoreCase( globalDialect ) ) {
+            return true;
+        }
+        return false;
+    }
+
+    protected void addLHSCompletionProposals(List list,
+                                             int documentOffset,
+                                             Location location,
+                                             String prefix,
+                                             String backText) {
+        switch ( location.getType() ) {
+            case Location.LOCATION_LHS_BEGIN_OF_CONDITION :
+                // if we are at the beginning of a new condition
+                // add drools keywords
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "and",
+                                                      "and ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "or",
+                                                      "or ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "from",
+                                                      "from ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "forall",
+                                                      "forall(  )",
+                                                      8,
+                                                      DROOLS_ICON ) );
+                RuleCompletionProposal prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                          prefix.length(),
+                                                                          "eval",
+                                                                          "eval(  )",
+                                                                          6 );
+                prop.setImage( DROOLS_ICON );
+                list.add( prop );
+                prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                   prefix.length(),
+                                                   "then",
+                                                   "then" + System.getProperty( "line.separator" ) + "\t" );
+                prop.setImage( DROOLS_ICON );
+                list.add( prop );
+                // we do not break but also add all elements that are needed for
+                // and/or
+            case Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR :
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "not",
+                                                      "not ",
+                                                      DROOLS_ICON ) );
+                // we do not break but also add all elements that are needed for
+                // not
+            case Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT :
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "exists",
+                                                      "exists ",
+                                                      DROOLS_ICON ) );
+                // we do not break but also add all elements that are needed for
+                // exists
+            case Location.LOCATION_LHS_FROM_ACCUMULATE :
+            case Location.LOCATION_LHS_FROM_COLLECT :
+            case Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS :
+                // and add imported classes
+                Iterator iterator = getImports().iterator();
+                while ( iterator.hasNext() ) {
+                    String name = (String) iterator.next();
+                    int index = name.lastIndexOf( "." );
+                    if ( index != -1 ) {
+                        String className = name.substring( index + 1 );
+                        RuleCompletionProposal p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                               prefix.length(),
+                                                                               className,
+                                                                               className + "(  )",
+                                                                               className.length() + 2 );
+                        p.setPriority( -1 );
+                        p.setImage( CLASS_ICON );
+                        list.add( p );
+                    }
+                }
+                iterator = getClassesInPackage().iterator();
+                while ( iterator.hasNext() ) {
+                    String name = (String) iterator.next();
+                    int index = name.lastIndexOf( "." );
+                    if ( index != -1 ) {
+                        String className = name.substring( index + 1 );
+                        RuleCompletionProposal p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                               prefix.length(),
+                                                                               className,
+                                                                               className + "(  )",
+                                                                               className.length() + 2 );
+                        p.setPriority( -1 );
+                        p.setImage( CLASS_ICON );
+                        list.add( p );
+                    }
+                }
+                iterator = getTemplates().iterator();
+                while ( iterator.hasNext() ) {
+                    String name = (String) iterator.next();
+                    RuleCompletionProposal p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                           prefix.length(),
+                                                                           name,
+                                                                           name + "(  )",
+                                                                           name.length() + 2 );
+                    p.setPriority( -1 );
+                    p.setImage( CLASS_ICON );
+                    list.add( p );
+                }
+                break;
+            case Location.LOCATION_LHS_INSIDE_CONDITION_START :
+                String className = (String) location.getProperty( Location.LOCATION_PROPERTY_CLASS_NAME );
+                String propertyName = (String) location.getProperty( Location.LOCATION_PROPERTY_PROPERTY_NAME );
+                if ( className != null ) {
+                    boolean isTemplate = addFactTemplatePropertyProposals( documentOffset,
+                                                                           prefix,
+                                                                           className,
+                                                                           list );
+                    if ( !isTemplate ) {
+                        ClassTypeResolver resolver = new ClassTypeResolver( getUniqueImports(),
+                                                                            ProjectClassLoader.getProjectClassLoader( getEditor() ) );
+                        try {
+                            String currentClass = className;
+                            if ( propertyName != null ) {
+                                String[] nestedProperties = propertyName.split( "\\." );
+                                int nbSuperProperties = nestedProperties.length - 1;
+                                if ( propertyName.endsWith( "." ) ) {
+                                    nbSuperProperties++;
+                                }
+                                for ( int i = 0; i < nbSuperProperties; i++ ) {
+                                    String simplePropertyName = nestedProperties[i];
+                                    currentClass = getSimplePropertyClass( currentClass,
+                                                                           simplePropertyName );
+                                    currentClass = convertToNonPrimitiveClass( currentClass );
+                                }
+                            }
+                            RuleCompletionProposal p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                                   prefix.length(),
+                                                                                   "this" );
+                            p.setImage( METHOD_ICON );
+                            list.add( p );
+                            Class clazz = resolver.resolveType( currentClass );
+                            if ( clazz != null ) {
+                                if ( Map.class.isAssignableFrom( clazz ) ) {
+                                    p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                    prefix.length(),
+                                                                    "this['']",
+                                                                    "this['']",
+                                                                    6 );
+                                    p.setImage( METHOD_ICON );
+                                    list.add( p );
+                                }
+                                ClassFieldInspector inspector = new ClassFieldInspector( clazz );
+                                Map types = inspector.getFieldTypes();
+                                Iterator iterator2 = inspector.getFieldNames().keySet().iterator();
+                                while ( iterator2.hasNext() ) {
+                                    String name = (String) iterator2.next();
+                                    p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                    prefix.length(),
+                                                                    name,
+                                                                    name + " " );
+                                    p.setImage( METHOD_ICON );
+                                    list.add( p );
+                                    Class type = (Class) types.get( name );
+                                    if ( type != null && Map.class.isAssignableFrom( type ) ) {
+                                        name += "['']";
+                                        p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                        prefix.length(),
+                                                                        name,
+                                                                        name,
+                                                                        name.length() - 2 );
+                                        p.setImage( METHOD_ICON );
+                                        list.add( p );
+                                    }
+                                }
+                            }
+                        } catch ( IOException exc ) {
+                            // Do nothing
+                        } catch ( ClassNotFoundException exc ) {
+                            // Do nothing
+                        }
+                    }
+                }
+                break;
+            case Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR :
+                className = (String) location.getProperty( Location.LOCATION_PROPERTY_CLASS_NAME );
+                String property = (String) location.getProperty( Location.LOCATION_PROPERTY_PROPERTY_NAME );
+                String type = getPropertyClass( className,
+                                                property );
+
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "==",
+                                                      "== ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "!=",
+                                                      "!= ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      ":",
+                                                      ": ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "->",
+                                                      "-> (  )",
+                                                      5,
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "memberOf",
+                                                      "memberOf ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "not memberOf",
+                                                      "not memberOf ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "in",
+                                                      "in (  )",
+                                                      5,
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "not in",
+                                                      "not in (  )",
+                                                      9,
+                                                      DROOLS_ICON ) );
+
+                if ( isComparable( type ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "<",
+                                                          "< ",
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "<=",
+                                                          "<= ",
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          ">",
+                                                          "> ",
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          ">=",
+                                                          ">= ",
+                                                          DROOLS_ICON ) );
+                }
+                if ( type.equals( "java.lang.String" ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "matches",
+                                                          "matches \"\"",
+                                                          9,
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "not matches",
+                                                          "not matches \"\"",
+                                                          13,
+                                                          DROOLS_ICON ) );
+                }
+                if ( isSubtypeOf( type,
+                                  "java.util.Collection" ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "contains",
+                                                          "contains ",
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "not contains",
+                                                          "not contains ",
+                                                          DROOLS_ICON ) );
+                }
+                break;
+            case Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT :
+                // determine type
+                className = (String) location.getProperty( Location.LOCATION_PROPERTY_CLASS_NAME );
+                property = (String) location.getProperty( Location.LOCATION_PROPERTY_PROPERTY_NAME );
+                String operator = (String) location.getProperty( Location.LOCATION_PROPERTY_OPERATOR );
+                type = getPropertyClass( className,
+                                         property );
+
+                if ( "in".equals( operator ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "()",
+                                                          "(  )",
+                                                          2,
+                                                          DROOLS_ICON ) );
+                    break;
+                }
+
+                if ( "contains".equals( operator ) || "excludes".equals( operator ) ) {
+                    type = "java.lang.Object";
+                }
+
+                if ( "memberOf".equals( operator ) ) {
+                    type = "java.util.Collection";
+                }
+
+                boolean isObject = false;
+                if ( "java.lang.Object".equals( type ) ) {
+                    isObject = true;
+                }
+
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "null",
+                                                      "null ",
+                                                      DROOLS_ICON ) );
+                if ( "boolean".equals( type ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "true",
+                                                          "true ",
+                                                          DROOLS_ICON ) );
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "false",
+                                                          "false ",
+                                                          DROOLS_ICON ) );
+                }
+                if ( isObject || "java.lang.String".equals( type ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "\"\"",
+                                                          "\"\"",
+                                                          1,
+                                                          DROOLS_ICON ) );
+                }
+                if ( isObject || "java.util.Date".equals( type ) ) {
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "\"dd-mmm-yyyy\"",
+                                                          "\"dd-mmm-yyyy\"",
+                                                          1,
+                                                          DROOLS_ICON ) );
+                }
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "()",
+                                                      "(  )",
+                                                      2,
+                                                      DROOLS_ICON ) );
+                // add parameters with possibly matching type
+                if ( context.getRule() != null ) {
+                    Map result = new HashMap();
+                    addRuleParameters( result,
+                                       context.getRule().getLhs().getDescrs() );
+                    Iterator iterator2 = result.entrySet().iterator();
+                    while ( iterator2.hasNext() ) {
+                        Map.Entry entry = (Map.Entry) iterator2.next();
+                        String paramName = (String) entry.getKey();
+                        String paramType = (String) entry.getValue();
+                        if ( isSubtypeOf( paramType,
+                                          type ) ) {
+                            RuleCompletionProposal proposal = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                                          prefix.length(),
+                                                                                          paramName );
+                            proposal.setPriority( -1 );
+                            proposal.setImage( VARIABLE_ICON );
+                            list.add( proposal );
+                        }
+                    }
+                }
+                // add globals with possibly matching type
+                List globals = getGlobals();
+                if ( globals != null ) {
+                    for ( iterator = globals.iterator(); iterator.hasNext(); ) {
+                        GlobalDescr global = (GlobalDescr) iterator.next();
+                        if ( isSubtypeOf( global.getType(),
+                                          type ) ) {
+                            RuleCompletionProposal proposal = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                                          prefix.length(),
+                                                                                          global.getIdentifier() );
+                            proposal.setPriority( -1 );
+                            proposal.setImage( VARIABLE_ICON );
+                            list.add( proposal );
+                        }
+                    }
+                }
+                break;
+            case Location.LOCATION_LHS_INSIDE_EVAL :
+                String content = (String) location.getProperty( Location.LOCATION_EVAL_CONTENT );
+                list.addAll( getJavaCompletionProposals( documentOffset,
+                                                         content,
+                                                         prefix,
+                                                         getRuleParameters( backText ) ) );
+                break;
+            case Location.LOCATION_LHS_INSIDE_CONDITION_END :
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "&&",
+                                                      "&& ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      "||",
+                                                      "|| ",
+                                                      DROOLS_ICON ) );
+                list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                      prefix.length(),
+                                                      ",",
+                                                      ", ",
+                                                      DROOLS_ICON ) );
+                break;
+            case Location.LOCATION_LHS_FROM :
+                String fromText = (String) location.getProperty( Location.LOCATION_FROM_CONTENT );
+                int index = fromText.indexOf( '.' );
+                if ( index == -1 ) {
+                    // add accumulate and collect keyword
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "accumulate",
+                                                          "accumulate (  , init (  ), action (  ), result (  ) )",
+                                                          13,
+                                                          DROOLS_ICON ) );
+                    PackageBuilderConfiguration config = new PackageBuilderConfiguration( ProjectClassLoader.getProjectClassLoader( getEditor() ),
+                                                                                          null );
+                    Map accumulateFunctions = config.getAccumulateFunctionsMap();
+                    for ( Iterator iterator2 = accumulateFunctions.keySet().iterator(); iterator2.hasNext(); ) {
+                        String accumulateFunction = (String) iterator2.next();
+                        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                              prefix.length(),
+                                                              "accumulate " + accumulateFunction,
+                                                              "accumulate (  , " + accumulateFunction + "(  ) )",
+                                                              13,
+                                                              DROOLS_ICON ) );
+                    }
+                    list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                          prefix.length(),
+                                                          "collect",
+                                                          "collect (  )",
+                                                          10,
+                                                          DROOLS_ICON ) );
+                    // add all functions
+                    if ( "".equals( fromText ) ) {
+                        List functions = getFunctions();
+                        iterator = functions.iterator();
+                        while ( iterator.hasNext() ) {
+                            String name = (String) iterator.next() + "()";
+                            prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                               prefix.length(),
+                                                               name,
+                                                               name,
+                                                               name.length() - 1 );
+                            prop.setPriority( -1 );
+                            prop.setImage( METHOD_ICON );
+                            list.add( prop );
+                        }
+                    }
+                    list.addAll( getJavaCompletionProposals( documentOffset,
+                                                             fromText,
+                                                             prefix,
+                                                             getRuleParameters( backText ) ) );
+                }
+                break;
+            case Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE :
+                content = (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT );
+                list.addAll( getJavaCompletionProposals( documentOffset,
+                                                         content,
+                                                         prefix,
+                                                         getRuleParameters( backText ) ) );
+                break;
+            case Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE :
+                content = (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT );
+                content += (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT );
+                list.addAll( getJavaCompletionProposals( documentOffset,
+                                                         content,
+                                                         prefix,
+                                                         getRuleParameters( backText ) ) );
+                break;
+            case Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE :
+                content = (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT );
+                content += (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT );
+                content += (String) location.getProperty( Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT );
+                list.addAll( getJavaCompletionProposals( documentOffset,
+                                                         content,
+                                                         prefix,
+                                                         getRuleParameters( backText ) ) );
+                break;
+        }
+    }
+
+    private String getPropertyClass(String className,
+                                    String propertyName) {
+        if ( className != null && propertyName != null ) {
+            FactTemplateDescr template = getTemplate( className );
+            if ( template != null ) {
+                Iterator iterator = template.getFields().iterator();
+                while ( iterator.hasNext() ) {
+                    FieldTemplateDescr field = (FieldTemplateDescr) iterator.next();
+                    if ( propertyName.equals( field.getName() ) ) {
+                        String type = field.getClassType();
+                        if ( isPrimitiveType( type ) ) {
+                            return type;
+                        }
+                        ClassTypeResolver resolver = new ClassTypeResolver( getUniqueImports(),
+                                                                            ProjectClassLoader.getProjectClassLoader( getEditor() ) );
+                        try {
+                            Class clazz = resolver.resolveType( type );
+                            if ( clazz != null ) {
+                                return clazz.getName();
+                            }
+                        } catch ( ClassNotFoundException exc ) {
+                            DroolsEclipsePlugin.log( exc );
+                        }
+                    }
+                }
+                // if not found, return null
+            } else {
+                String[] nestedProperties = propertyName.split( "\\." );
+                String currentClass = className;
+                for ( int i = 0; i < nestedProperties.length; i++ ) {
+                    String simplePropertyName = nestedProperties[i];
+                    currentClass = getSimplePropertyClass( currentClass,
+                                                           simplePropertyName );
+                }
+                return currentClass;
+            }
+        }
+        return null;
+    }
+
+    private String getSimplePropertyClass(String className,
+                                          String propertyName) {
+        if ( "this".equals( propertyName ) ) {
+            return className;
+        }
+        if ( propertyName.endsWith( "]" ) ) {
+            // TODO can we take advantage of generics here?
+            return "java.lang.Object";
+        }
+        ClassTypeResolver resolver = new ClassTypeResolver( getUniqueImports(),
+                                                            ProjectClassLoader.getProjectClassLoader( getEditor() ) );
+        try {
+            Class clazz = resolver.resolveType( className );
+            if ( clazz != null ) {
+                Class clazzz = (Class) new ClassFieldInspector( clazz ).getFieldTypes().get( propertyName );
+                if ( clazzz != null ) {
+                    return clazzz.getName();
+                }
+            }
+        } catch ( IOException exc ) {
+            // Do nothing
+        } catch ( ClassNotFoundException exc ) {
+            // Do nothing
+        }
+        return "java.lang.Object";
+    }
+
+    private Map getRuleParameters(String backText) {
+        Map result = new HashMap();
+        // add globals
+        List globals = getGlobals();
+        if ( globals != null ) {
+            for ( Iterator iterator = globals.iterator(); iterator.hasNext(); ) {
+                GlobalDescr global = (GlobalDescr) iterator.next();
+                result.put( global.getIdentifier(),
+                            global.getType() );
+            }
+        }
+
+        if ( context == null ) {
+            context = new CompletionContext( backText );
+        }
+        if ( context.getRule() == null ) {
+            return result;
+        }
+        // add parameters defined in conditions
+        addRuleParameters( result,
+                           context.getRule().getLhs().getDescrs() );
+        return result;
+    }
+
+    private boolean isComparable(String type) {
+        if ( type == null ) {
+            return false;
+        }
+        if ( isPrimitiveNumericType( type ) ) {
+            return true;
+        }
+        if ( isObjectNumericType( type ) ) {
+            return true;
+        }
+        if ( isSubtypeOf( type,
+                          "java.lang.Comparable" ) ) {
+            return true;
+        }
+        return false;
+    }
+
+    private boolean isPrimitiveType(String type) {
+        return isPrimitiveNumericType( type ) || type.equals( "boolean" );
+    }
+
+    private boolean isPrimitiveNumericType(String type) {
+        return type.equals( "byte" ) || type.equals( "short" ) || type.equals( "int" ) || type.equals( "long" ) || type.equals( "float" ) || type.equals( "double" ) || type.equals( "char" );
+    }
+
+    private boolean isObjectNumericType(String type) {
+        return type.equals( "java.lang.Byte" ) || type.equals( "java.lang.Short" ) || type.equals( "java.lang.Integer" ) || type.equals( "java.lang.Long" ) || type.equals( "java.lang.Float" ) || type.equals( "java.lang.Double" )
+               || type.equals( "java.lang.Char" );
+    }
+
+    /**
+     * Returns true if the first class is the same or a subtype of the second
+     * class.
+     *
+     * @param class1
+     * @param class2
+     * @return
+     */
+    private boolean isSubtypeOf(String class1,
+                                String class2) {
+        if ( class1 == null || class2 == null ) {
+            return false;
+        }
+        class1 = convertToNonPrimitiveClass( class1 );
+        class2 = convertToNonPrimitiveClass( class2 );
+        // TODO add code to take primitive types into account
+        ClassTypeResolver resolver = new ClassTypeResolver( getUniqueImports(),
+                                                            ProjectClassLoader.getProjectClassLoader( getEditor() ) );
+        try {
+            Class clazz1 = resolver.resolveType( class1 );
+            Class clazz2 = resolver.resolveType( class2 );
+            if ( clazz1 == null || clazz2 == null ) {
+                return false;
+            }
+            return clazz2.isAssignableFrom( clazz1 );
+        } catch ( ClassNotFoundException exc ) {
+            return false;
+        }
+    }
+
+    private String convertToNonPrimitiveClass(String clazz) {
+        if ( !isPrimitiveType( clazz ) ) {
+            return clazz;
+        }
+        if ( "byte".equals( clazz ) ) {
+            return "java.lang.Byte";
+        } else if ( "short".equals( clazz ) ) {
+            return "java.lang.Short";
+        } else if ( "int".equals( clazz ) ) {
+            return "java.lang.Integer";
+        } else if ( "long".equals( clazz ) ) {
+            return "java.lang.Long";
+        } else if ( "float".equals( clazz ) ) {
+            return "java.lang.Float";
+        } else if ( "double".equals( clazz ) ) {
+            return "java.lang.Double";
+        } else if ( "char".equals( clazz ) ) {
+            return "java.lang.Char";
+        } else if ( "boolean".equals( clazz ) ) {
+            return "java.lang.Boolean";
+        }
+        // should never occur
+        return null;
+    }
+
+    private void addRHSFunctionCompletionProposals(List list,
+                                                   int documentOffset,
+                                                   String prefix) {
+        Iterator iterator;
+        RuleCompletionProposal prop;
+        List functions = getFunctions();
+        iterator = functions.iterator();
+        while ( iterator.hasNext() ) {
+            String name = (String) iterator.next() + "()";
+            prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                               prefix.length(),
+                                               name,
+                                               name + ";",
+                                               name.length() - 1 );
+            prop.setPriority( -1 );
+            prop.setImage( METHOD_ICON );
+            list.add( prop );
+        }
+    }
+
+    private void addRHSKeywordCompletionProposals(List list,
+                                                  int documentOffset,
+                                                  String prefix) {
+        RuleCompletionProposal prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                  prefix.length(),
+                                                                  "update",
+                                                                  "update();",
+                                                                  7 );
+        prop.setImage( DROOLS_ICON );
+        list.add( prop );
+        prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                           prefix.length(),
+                                           "retract",
+                                           "retract();",
+                                           8 );
+        prop.setImage( DROOLS_ICON );
+        list.add( prop );
+        prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                           prefix.length(),
+                                           "insert",
+                                           "insert();",
+                                           7 );
+        prop.setImage( DROOLS_ICON );
+        list.add( prop );
+        prop = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                           prefix.length(),
+                                           "insertLogical",
+                                           "insertLogical();",
+                                           14 );
+        prop.setImage( DROOLS_ICON );
+        list.add( prop );
+    }
+
+    private void addRHSJavaCompletionProposals(List list,
+                                               int documentOffset,
+                                               String prefix,
+                                               String backText,
+                                               String consequence) {
+        list.addAll( getJavaCompletionProposals( documentOffset,
+                                                 consequence,
+                                                 prefix,
+                                                 getRuleParameters( backText ) ) );
+    }
+
+    private void addRHSMvelCompletionProposals(List list,
+                                               final int documentOffset,
+                                               String prefix,
+                                               String backText,
+                                               String consequence,
+                                               boolean expressionStart) {
+
+        Collection mvelCompletionProposals = getMvelCompletionProposals( consequence,
+                                                                         documentOffset,
+                                                                         prefix,
+                                                                         getRuleParameters( backText ),
+                                                                         backText,
+                                                                         expressionStart );
+        list.addAll( mvelCompletionProposals );
+    }
+
+    private Collection getMvelCompletionProposals(final String consequenceBackText,
+                                                  final int documentOffset,
+                                                  final String prefix,
+                                                  Map params,
+                                                  String ruleBackText,
+                                                  boolean startOfExpression) {
+
+        final Set proposals = new HashSet();
+
+        if ( !(getEditor() instanceof DRLRuleEditor) ) {
+            return proposals;
+        }
+
+        try {
+            DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource( (DRLRuleEditor) getEditor(),
+                                                                              true,
+                                                                              true );
+
+            String textWithoutPrefix = CompletionUtil.getTextWithoutPrefix( consequenceBackText,
+                                                                            prefix );
+            boolean expressionStart = CompletionUtil.isStartOfDialectExpression( textWithoutPrefix );
+
+            boolean isConstrained = textWithoutPrefix.endsWith( "." );
+
+            // we split the expression in various regions:
+            // *the previous expression
+            // *the last expression
+            // *the last inner expression
+
+            // attempt to compile and analyze the previous expression to collect inputs and vars
+            String previousExpression = CompletionUtil.getPreviousExpression( consequenceBackText );
+            MvelContext previousExprContext = analyzeMvelExpression( getResolvedMvelInputs( params ),
+                                                                     drlInfo,
+                                                                     previousExpression );
+
+            // attempt to compile and analyze the last and last inner expression, using as inputs the previous expression inputs and vars
+            Map variables = previousExprContext.getContext().getVariables();
+            Map inputs = previousExprContext.getContext().getInputs();
+            inputs.putAll( variables );
+
+            //last inner expression
+            String lastInnerExpression = CompletionUtil.getTextWithoutPrefix( CompletionUtil.getInnerExpression( consequenceBackText ),
+                                                                              prefix );
+            String compilableLastInnerExpression = CompletionUtil.getCompilableText( lastInnerExpression );
+
+            MvelContext lastInnerExprContext = analyzeMvelExpression( inputs,
+                                                                      drlInfo,
+                                                                      compilableLastInnerExpression );
+
+            //last expression
+            String lastExpression = CompletionUtil.getLastExpression( consequenceBackText ).trim();
+            //is this a modify expression?
+            //group 1 is the body of modify
+            //group 2 if present is the whole with block including brackets
+            //group 3 if present is the inner content of the with block
+            Matcher modMatcher = CompletionUtil.MODIFY_PATTERN.matcher( lastExpression );
+
+            boolean isModifyBlock = modMatcher.matches() && modMatcher.groupCount() == 3;
+
+            //if constrained, get completion for egress of last inner, filtered on prefix
+            if ( isConstrained ) {
+                if ( lastInnerExprContext.isStaticFlag() ) {
+                    return getMvelClassCompletionsFromJDT( documentOffset,
+                                                           "",
+                                                           params,
+                                                           lastInnerExprContext.getReturnedType() );
+
+                }
+
+                return getMvelInstanceCompletionsFromJDT( documentOffset,
+                                                          "",
+                                                          params,
+                                                          lastInnerExprContext.getReturnedType(),
+                                                          false );
+            }
+            //if expression start inside with block, then get completion for prefix with egrss of modif var + prev expr var&inputs
+            else if ( expressionStart && isModifyBlock ) {
+                String modifyVar = modMatcher.group( 1 );
+                //String modifyWith = modMatcher.group( 3 );
+
+                //get the egress type of the modify var
+                MvelContext modVarContext = analyzeMvelExpression( inputs,
+                                                                   drlInfo,
+                                                                   modifyVar );
+
+                Class modVarType = modVarContext.getReturnedType();
+
+                Collection modVarComps = getMvelInstanceCompletionsFromJDT( documentOffset,
+                                                                            "",
+                                                                            params,
+                                                                            modVarType,
+                                                                            true );
+
+                proposals.addAll( modVarComps );
+
+                //                addMvelCompletions( proposals,
+                //                                    documentOffset,
+                //                                    "",
+                //                                    lastInnerExprContext.getContext().getVariables() );
+                //
+                //                addMvelCompletions( proposals,
+                //                                    documentOffset,
+                //                                    "",
+                //                                    lastInnerExprContext.getContext().getInputs() );
+                //
+                //                Collection jdtProps = getJavaCompletionProposals( documentOffset,
+                //                                                                  prefix,
+                //                                                                  prefix,
+                //                                                                  params );
+                //
+                //                proposals.addAll( jdtProps );
+                return proposals;
+
+            }
+            //If expression start, and all other cases then get completion for prefix with prev expr var&inputs
+            addMvelCompletions( proposals,
+                                documentOffset,
+                                prefix,
+                                lastInnerExprContext.getContext().getVariables() );
+
+            addMvelCompletions( proposals,
+                                documentOffset,
+                                prefix,
+                                lastInnerExprContext.getContext().getInputs() );
+
+            Collection jdtProps = getJavaCompletionProposals( documentOffset,
+                                                              prefix,
+                                                              prefix,
+                                                              params );
+
+            proposals.addAll( jdtProps );
+
+        } catch ( Throwable e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+        Set uniqueProposals = new HashSet();
+        addAllNewProposals( uniqueProposals,
+                            proposals );
+        return uniqueProposals;
+    }
+
+    private Map getResolvedMvelInputs(Map params) {
+        ClassTypeResolver resolver = new ClassTypeResolver( getUniqueImports(),
+                                                            ProjectClassLoader.getProjectClassLoader( getEditor() ) );
+
+        Map resolved = new HashMap();
+        for ( Iterator iter = params.entrySet().iterator(); iter.hasNext(); ) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String inputType = (String) entry.getValue();
+            try {
+                Class type = resolver.resolveType( inputType );
+                resolved.put( entry.getKey(),
+                              type );
+            } catch ( ClassNotFoundException e ) {
+                DroolsEclipsePlugin.log( e );
+            }
+        }
+        return resolved;
+    }
+
+    class MvelContext {
+        private CompiledExpression expression;
+        private ParserContext      initialContext;
+        private Class              returnedType;
+        private boolean            staticFlag;
+
+        public ParserContext getContext() {
+            if ( getExpression() != null ) {
+                if ( getExpression().getParserContext() != null ) {
+                    return getExpression().getParserContext();
+                }
+            }
+            return getInitialContext();
+        }
+
+        void setExpression(CompiledExpression expression) {
+            this.expression = expression;
+        }
+
+        CompiledExpression getExpression() {
+            return expression;
+        }
+
+        void setInitialContext(ParserContext initialContext) {
+            this.initialContext = initialContext;
+        }
+
+        ParserContext getInitialContext() {
+            return initialContext;
+        }
+
+        void setReturnedType(Class returnedType) {
+            this.returnedType = returnedType;
+        }
+
+        Class getReturnedType() {
+            return returnedType;
+        }
+
+        public boolean isStaticFlag() {
+            return staticFlag;
+        }
+
+        public void setStaticFlag(boolean staticFlag) {
+            this.staticFlag = staticFlag;
+        }
+    }
+
+    private MvelContext analyzeMvelExpression(Map params,
+                                              DRLInfo drlInfo,
+                                              String mvel) {
+
+        String macroMvel = processMacros( mvel );
+
+        String name = context.getRule().getName();
+        RuleInfo currentRule = getCurrentRule( drlInfo,
+                                               name );
+        String qName = drlInfo.getPackageName() + "." + currentRule.getRuleName();
+        MVELDialect dialect = (MVELDialect) currentRule.getDialect();
+        ParserContext initialContext = createInitialContext( params,
+                                                             qName,
+                                                             dialect );
+        MvelContext mCon = new MvelContext();
+        mCon.setInitialContext( initialContext );
+
+        try {
+            ExpressionCompiler compiler = new ExpressionCompiler( macroMvel );
+            CompiledExpression expression = compiler.compile( initialContext );
+            mCon.setExpression( expression );
+
+            ParserContext compilationContext = compiler.getParserContextState();
+
+            Class lastType = expression.getKnownEgressType();
+
+            //Statics expression may return Class as an egress type
+            if ( lastType != null && "java.lang.Class".equals( lastType.getName() ) ) {
+                mCon.setStaticFlag( true );
+            }
+
+            if ( lastType == null || "java.lang.Object".equals( lastType.getName() ) || "java.lang.Class".equals( lastType.getName() ) ) {
+                // attempt to use the property verifier to get
+                // a better type  resolution (a recommend by cbrock, though egress gives consistent results)
+                lastType = new PropertyVerifier( macroMvel,
+                                                 compilationContext ).analyze();
+            }
+
+            if ( lastType == null ) {
+                lastType = Object.class;
+            }
+
+            mCon.setReturnedType( lastType );
+        } catch ( Exception e ) {
+            //do nothing while doing completion.
+        }
+        return mCon;
+    }
+
+    private static ParserContext createInitialContext(Map params,
+                                                      String qualifiedName,
+                                                      MVELDialect dialect) {
+
+        final ParserContext context = new ParserContext( dialect.getImports(),
+                                                         null,
+                                                         qualifiedName );
+
+        for ( Iterator it = dialect.getPackgeImports().values().iterator(); it.hasNext(); ) {
+            String packageImport = (String) it.next();
+            context.addPackageImport( packageImport );
+        }
+        context.setStrictTypeEnforcement( false );
+
+        context.setInterceptors( dialect.getInterceptors() );
+        context.setInputs( params );
+        context.addInput( "drools",
+                          KnowledgeHelper.class );
+        context.setCompiled( true );
+        return context;
+    }
+
+    public static String processMacros(String mvel) {
+        MVELConsequenceBuilder builder = new MVELConsequenceBuilder();
+        String macrosProcessedCompilableConsequence = builder.processMacros( mvel.trim() );
+        return macrosProcessedCompilableConsequence;
+    }
+
+    private static RuleInfo getCurrentRule(DRLInfo drlInfo,
+                                    String currentRulename) {
+        RuleInfo currentRule = null;
+        RuleInfo[] ruleInfos = drlInfo.getRuleInfos();
+        for ( int i = 0; i < ruleInfos.length; i++ ) {
+            if ( currentRulename.equals( ruleInfos[i].getRuleName() ) ) {
+                currentRule = ruleInfos[i];
+                break;
+            }
+        }
+        return currentRule;
+    }
+
+    /*
+     * Completions for object instance members
+     */
+    private Collection getMvelInstanceCompletionsFromJDT(final int documentOffset,
+                                                         final String prefix,
+                                                         Map params,
+                                                         Class lastType,
+                                                         boolean settersOnly) {
+        if ( lastType == null ) {
+            lastType = Object.class;
+        }
+
+        //FIXME: there is a small chance of var name collision using this arbitrary mvdrlofc as a variable name.
+        //ideally the variable name should be inferred from the last member of the expression
+        final String syntheticVarName = "mvdrlofc";
+
+        String javaText = "\n" + CompletionUtil.getSimpleClassName( lastType ) + " " + syntheticVarName + ";\n" + syntheticVarName + ".";
+        final List list1 = new ArrayList();
+        requestJavaCompletionProposals( javaText,
+                                        prefix,
+                                        documentOffset,
+                                        params,
+                                        list1 );
+
+        final List list = list1;
+
+        Collection mvelList = RuleCompletionProcessor.mvelifyProposals( list,
+                                                                        settersOnly );
+        return mvelList;
+    }
+
+    /*
+     * Completions for static Class members
+     */
+    private Collection getMvelClassCompletionsFromJDT(final int documentOffset,
+                                                      final String prefix,
+                                                      Map params,
+                                                      Class lastType) {
+        if ( lastType == null ) {
+            lastType = Object.class;
+        }
+
+        //FIXME: there is a small chance of var name collision using this arbitrary mvdrlofc as a variable name.
+        //ideally the variable name should be inferred from the last member of the expression
+
+        String javaText = "\n" + CompletionUtil.getSimpleClassName( lastType ) + ".";
+        final List list1 = new ArrayList();
+        requestJavaCompletionProposals( javaText,
+                                        prefix,
+                                        documentOffset,
+                                        params,
+                                        list1 );
+        final List list = list1;
+        Collection mvelList = RuleCompletionProcessor.mvelifyProposals( list,
+                                                                        false );
+        return mvelList;
+    }
+
+    private static void addMvelCompletions(final Collection proposals,
+                                    int documentOffset,
+                                    String prefix,
+                                    Map inputs) {
+        Set newProposals = new HashSet();
+        for ( Iterator iter = inputs.entrySet().iterator(); iter.hasNext(); ) {
+            Map.Entry entry = (Map.Entry) iter.next();
+            String prop = (String) entry.getKey();
+
+            Class type = (Class) entry.getValue();
+            String display = prop + "  " + CompletionUtil.getSimpleClassName( type );
+
+            RuleCompletionProposal rcp = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                     prefix.length(),
+                                                                     display,
+                                                                     prop );
+            rcp.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
+            newProposals.add( rcp );
+        }
+        addAllNewProposals( proposals,
+                            newProposals );
+    }
+
+    public static void addAllNewProposals(final Collection proposals,
+                                          final Collection newProposals) {
+        for ( Iterator iter = newProposals.iterator(); iter.hasNext(); ) {
+            ICompletionProposal newProp = (ICompletionProposal) iter.next();
+            String displayString = newProp.getDisplayString();
+
+            //JBRULES-1134 do not add completions if they already exist
+            if ( !containsProposal( proposals,
+                                    displayString ) ) {
+                proposals.add( newProp );
+            }
+        }
+    }
+
+    /**
+     * Attempt to compare proposals of different types based on the tokenized display string
+     * @param proposals
+     * @param newProposal
+     * @return true if the collection contains a proposal which matches the new Proposal.
+     * The match is based on the first token based on a space split
+     */
+    public static boolean containsProposal(final Collection proposals,
+                                           String newProposal) {
+        for ( Iterator iter = proposals.iterator(); iter.hasNext(); ) {
+            ICompletionProposal prop = (ICompletionProposal) iter.next();
+            String displayString = prop.getDisplayString();
+            String[] existings = displayString.split( " " );
+            if ( existings.length == 0 ) {
+                continue;
+            }
+
+            String[] newProposals = newProposal.split( " " );
+            if ( newProposals.length == 0 ) {
+                continue;
+            }
+
+            if ( existings[0].equals( newProposals[0] ) ) {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private void addRuleParameters(Map result,
+                                   List descrs) {
+        if ( descrs == null ) {
+            return;
+        }
+        Iterator iterator = descrs.iterator();
+        while ( iterator.hasNext() ) {
+            BaseDescr descr = (BaseDescr) iterator.next();
+            addRuleParameters( result,
+                               descr );
+        }
+    }
+
+    private void addRuleParameters(Map result,
+                                   BaseDescr descr) {
+        if ( descr == null ) {
+            return;
+        }
+        if ( descr instanceof PatternDescr ) {
+            String name = ((PatternDescr) descr).getIdentifier();
+            if ( name != null ) {
+                result.put( name,
+                            ((PatternDescr) descr).getObjectType() );
+            }
+            addRuleSubParameters( result,
+                                  ((PatternDescr) descr).getDescrs(),
+                                  ((PatternDescr) descr).getObjectType() );
+        } else if ( descr instanceof AndDescr ) {
+            addRuleParameters( result,
+                               ((AndDescr) descr).getDescrs() );
+        } else if ( descr instanceof OrDescr ) {
+            addRuleParameters( result,
+                               ((OrDescr) descr).getDescrs() );
+        } else if ( descr instanceof ExistsDescr ) {
+            addRuleParameters( result,
+                               ((ExistsDescr) descr).getDescrs() );
+        } else if ( descr instanceof NotDescr ) {
+            addRuleParameters( result,
+                               ((NotDescr) descr).getDescrs() );
+        }
+    }
+
+    private void addRuleSubParameters(Map result,
+                                      List descrs,
+                                      String clazz) {
+        if ( descrs == null ) {
+            return;
+        }
+        Iterator iterator = descrs.iterator();
+        while ( iterator.hasNext() ) {
+            BaseDescr descr = (BaseDescr) iterator.next();
+            if ( descr instanceof FieldBindingDescr ) {
+                FieldBindingDescr fieldDescr = (FieldBindingDescr) descr;
+                String name = fieldDescr.getIdentifier();
+                String field = fieldDescr.getFieldName();
+                String type = getPropertyClass( clazz,
+                                                field );
+                if ( name != null ) {
+                    result.put( name,
+                                type );
+                }
+            }
+        }
+    }
+
+    private void addRuleHeaderProposals(List list,
+                                        int documentOffset,
+                                        String prefix,
+                                        String backText) {
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "salience",
+                                              "salience ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "no-loop",
+                                              "no-loop ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "agenda-group",
+                                              "agenda-group ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "duration",
+                                              "duration ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "auto-focus",
+                                              "auto-focus ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "when",
+                                              "when" + System.getProperty( "line.separator" ) + "\t ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "activation-group",
+                                              "activation-group ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "date-effective",
+                                              "date-effective \"dd-MMM-yyyy\"",
+                                              16,
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "date-expires",
+                                              "date-expires \"dd-MMM-yyyy\"",
+                                              14,
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "enabled",
+                                              "enabled false",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "ruleflow-group",
+                                              "ruleflow-group \"\"",
+                                              16,
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "lock-on-active",
+                                              "lock-on-active ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "dialect \"java\"",
+                                              "dialect \"java\" ",
+                                              DROOLS_ICON ) );
+        list.add( new RuleCompletionProposal( documentOffset - prefix.length(),
+                                              prefix.length(),
+                                              "dialect \"mvel\"",
+                                              "dialect \"mvel\" ",
+                                              DROOLS_ICON ) );
+    }
+
+    private boolean addFactTemplatePropertyProposals(int documentOffset,
+                                                     String prefix,
+                                                     String templateName,
+                                                     List list) {
+        FactTemplateDescr descr = getTemplate( templateName );
+        if ( descr == null ) {
+            return false;
+        }
+        Iterator iterator = descr.getFields().iterator();
+        while ( iterator.hasNext() ) {
+            FieldTemplateDescr field = (FieldTemplateDescr) iterator.next();
+            String fieldName = field.getName();
+            RuleCompletionProposal p = new RuleCompletionProposal( documentOffset - prefix.length(),
+                                                                   prefix.length(),
+                                                                   fieldName,
+                                                                   fieldName + " " );
+            p.setImage( METHOD_ICON );
+            list.add( p );
+        }
+        return true;
+    }
+
+    /*
+     * Filters accessor method proposals to replace them with their mvel expression equivalent
+     * For instance a completion for getStatus() would be replaced by a completion for status
+     * when asking for stters only, then only setters or writable fields will be returned
+     */
+    public static Collection mvelifyProposals(List list,
+                                              boolean settersOnly) {
+        final Collection set = new HashSet();
+
+        for ( Iterator iter = list.iterator(); iter.hasNext(); ) {
+            Object o = iter.next();
+            if ( o instanceof JavaMethodCompletionProposal ) {
+                //methods
+                processJavaMethodCompletionProposal( list,
+                                                     settersOnly,
+                                                     set,
+                                                     o );
+
+            } else if ( o instanceof JavaCompletionProposal ) {
+                //fields
+                processesJavaCompletionProposal( settersOnly,
+                                                 set,
+                                                 o );
+            } else if ( !settersOnly ) {
+                set.add( o );
+            }
+        }
+        return set;
+    }
+
+    private static void processesJavaCompletionProposal(boolean settersOnly,
+                                                        final Collection set,
+                                                        Object o) {
+        if ( settersOnly ) {
+            JavaCompletionProposal jcp = (JavaCompletionProposal) o;
+            //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
+            //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
+            //                    Object field = ReflectionUtils.getField( o,
+            //                                                             "fProposal" );
+            IJavaElement javaElement = jcp.getJavaElement();
+            if ( javaElement.getElementType() == IJavaElement.FIELD ) {
+                set.add( o );
+
+            }
+        } else {
+            set.add( o );
+        }
+    }
+
+    private static void processJavaMethodCompletionProposal(List list,
+                                                            boolean settersOnly,
+                                                            final Collection set,
+                                                            Object o) {
+        LazyJavaCompletionProposal javaProposal = (LazyJavaCompletionProposal) o;
+        //TODO: FIXME: this is very fragile as it uses reflection to access the private completion field.
+        //Yet this is needed to do mvel filtering based on the method signtures, IF we use the richer JDT completion
+        Object field = ReflectionUtils.getField( o,
+                                                 "fProposal" );
+        if ( field != null && field instanceof CompletionProposal ) {
+            CompletionProposal proposal = (CompletionProposal) field;
+
+            String completion = new String( proposal.getCompletion() );
+
+            String propertyOrMethodName = null;
+
+            boolean isSetter = false;
+            boolean isAccessor = false;
+            if ( settersOnly ) {
+                // get the eventual writable property name for that method name and signature
+                propertyOrMethodName = CompletionUtil.getWritablePropertyName( completion,
+                                                                               proposal.getSignature() );
+                //                      if we got a property name that differs from the orginal method name
+                //then this is a bean accessor
+                isSetter = !completion.equals( propertyOrMethodName );
+
+            } else {
+                // get the eventual property name for that method name and signature
+                propertyOrMethodName = CompletionUtil.getPropertyName( completion,
+                                                                       proposal.getSignature() );
+                //if we got a property name that differs from the orginal method name
+                //then this is a bean accessor
+                isAccessor = !completion.equals( propertyOrMethodName );
+            }
+
+            // is the completion for a bean accessor? and do we have already some relevant completion?
+            boolean doesNotContainFieldCompletion = DefaultCompletionProcessor.doesNotContainFieldCompletion( propertyOrMethodName,
+                                                                                                              list );
+            if ( ((settersOnly && isSetter) || (!settersOnly && isAccessor)) && doesNotContainFieldCompletion ) {
+
+                //TODO: craft a better JDTish display name than just the property name
+                RuleCompletionProposal prop = new RuleCompletionProposal( javaProposal.getReplacementOffset(),
+                                                                          javaProposal.getReplacementLength(),
+                                                                          propertyOrMethodName );
+                prop.setImage( DefaultCompletionProcessor.VARIABLE_ICON );
+                //set high priority such that the completion for accessors shows up first
+                prop.setPriority( 1000 );
+                set.add( prop );
+
+            }
+
+            else if ( !settersOnly ) {
+                set.add( o );
+            }
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProposal.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProposal.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/completion/RuleCompletionProposal.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,210 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.Comparator;
+
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+/**
+ * Holds a completion proposal to be popped up.
+ *
+ * @author Michael Neale
+ *
+ */
+public class RuleCompletionProposal
+    implements
+    ICompletionProposal {
+
+    private String content;
+    private String display;
+    private int    replacementOffset;
+    private int    replacementLength;
+    private int    cursorPosition;
+    private Image  image;
+    private int    priority;
+
+    /** This is used when the stuff that is displayed, is the stuff that is used. */
+    public RuleCompletionProposal(int replacementOffset,
+                                  int replacementLength,
+                                  String content) {
+        this( replacementOffset,
+              replacementLength,
+              content,
+              content );
+    }
+
+    /** This is used when a different display value is shown to what is put in when selected. */
+    public RuleCompletionProposal(int replacementOffset,
+                                  int replacementLength,
+                                  String display,
+                                  String content) {
+        this( replacementOffset,
+              replacementLength,
+              display,
+              content,
+              content.length() );
+    }
+
+    /** Also allows an icon to be used */
+    public RuleCompletionProposal(int replacementOffset,
+                                  int replacementLength,
+                                  String display,
+                                  String content,
+                                  Image image) {
+        this( replacementOffset,
+              replacementLength,
+              display,
+              content,
+              content.length(),
+              image );
+    }
+
+    public RuleCompletionProposal(int replacementOffset,
+                                  int replacementLength,
+                                  String display,
+                                  String content,
+                                  int cursorPosition) {
+        this( replacementOffset,
+              replacementLength,
+              display,
+              content,
+              cursorPosition,
+              null );
+    }
+
+    /** This is used when a different display value is shown to what is put in when selected. */
+    public RuleCompletionProposal(int replacementOffset,
+                                  int replacementLength,
+                                  String display,
+                                  String content,
+                                  int cursorPosition,
+                                  Image image) {
+        this.replacementOffset = replacementOffset;
+        this.replacementLength = replacementLength;
+        this.content = content;
+        this.display = display;
+        this.cursorPosition = cursorPosition;
+        this.image = image;
+    }
+
+    public String getDisplay() {
+        return display;
+    }
+
+    public int getReplacementLength() {
+        return replacementLength;
+    }
+
+    public int getCursorPosition() {
+        return cursorPosition;
+    }
+
+    public Image getImage() {
+        return image;
+    }
+
+    public String getContent() {
+        return content;
+    }
+
+    public void setImage(Image image) {
+        this.image = image;
+    }
+
+    public int getPriority() {
+        return priority;
+    }
+
+    public void setPriority(int priority) {
+        this.priority = priority;
+    }
+
+    public String toString() {
+        return content;
+    }
+
+    //TODO:fixme now that we mix JDT and own proposals, comparison is all wrong, resulting in wrong ordering of mixed proposals (such as with mvel
+    public static class RuleCompletionProposalComparator
+        implements
+        Comparator {
+        public int compare(Object arg0,
+                           Object arg1) {
+            if ( arg0 instanceof RuleCompletionProposal ) {
+                if ( arg1 instanceof RuleCompletionProposal ) {
+                    RuleCompletionProposal prop0 = (RuleCompletionProposal) arg0;
+                    RuleCompletionProposal prop1 = (RuleCompletionProposal) arg1;
+                    if ( prop0.getPriority() == prop1.getPriority() ) {
+                        return prop0.display.compareTo( prop1.display );
+                    } else if ( prop0.getPriority() > prop1.getPriority() ) {
+                        return -1;
+                    } else {
+                        return 1;
+                    }
+                } else {
+                    return -1;
+                }
+            } else {
+                if ( arg1 instanceof RuleCompletionProposal ) {
+                    return 1;
+                }
+                return 0;
+            }
+        }
+    }
+
+    public void apply(IDocument document) {
+        try {
+            document.replace( replacementOffset,
+                              replacementLength,
+                              content );
+        } catch ( BadLocationException x ) {
+            // ignore
+        }
+    }
+
+    public String getAdditionalProposalInfo() {
+        return null;
+    }
+
+    public IContextInformation getContextInformation() {
+        return null;
+    }
+
+    public String getDisplayString() {
+        if ( display != null ) {
+            return display;
+        }
+        return content;
+    }
+
+    public int hashCode() {
+        final int PRIME = 31;
+        int result = 1;
+        result = PRIME * result + ((content == null) ? 0 : content.hashCode());
+        result = PRIME * result + ((display == null) ? 0 : display.hashCode());
+        return result;
+    }
+
+    public boolean equals(Object obj) {
+        if ( this == obj ) return true;
+        if ( obj == null ) return false;
+        if ( getClass() != obj.getClass() ) return false;
+        final RuleCompletionProposal other = (RuleCompletionProposal) obj;
+        if ( content == null ) {
+            if ( other.content != null ) return false;
+        } else if ( !content.equals( other.content ) ) return false;
+        if ( display == null ) {
+            if ( other.display != null ) return false;
+        } else if ( !display.equals( other.display ) ) return false;
+        return true;
+    }
+
+    public Point getSelection(IDocument document) {
+        return new Point( replacementOffset + cursorPosition,
+                          0 );
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/outline/RuleContentOutlinePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/outline/RuleContentOutlinePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/outline/RuleContentOutlinePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,247 @@
+package org.drools.eclipse.editors.outline;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.compiler.DroolsParserException;
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.core.DroolsElement;
+import org.drools.eclipse.core.DroolsModelBuilder;
+import org.drools.eclipse.core.Package;
+import org.drools.eclipse.core.RuleSet;
+import org.drools.eclipse.core.ui.DroolsContentProvider;
+import org.drools.eclipse.core.ui.DroolsLabelProvider;
+import org.drools.eclipse.core.ui.DroolsTreeSorter;
+import org.drools.eclipse.core.ui.FilterActionGroup;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.views.contentoutline.ContentOutlinePage;
+
+/**
+ * Simple outline view of a DRL file. At present this is not wired in with the Parser, so it is fault
+ * tolerant of incorrect syntax. 
+ * Should provide navigation assistance in large rule files.
+ * 
+ * @author "Jeff Brown" <brown_j at ociweb.com>
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class RuleContentOutlinePage extends ContentOutlinePage {
+
+    private AbstractRuleEditor editor;
+    private RuleSet ruleSet = DroolsModelBuilder.createRuleSet();
+    private Map rules;
+
+    ///////////////////////////////////
+    // Patterns that the parser uses
+    ///////////////////////////////////
+    private static final Pattern RULE_PATTERN1 = Pattern.compile(
+			"\\n\\s*rule\\s+\"([^\"]+)\"", Pattern.DOTALL);
+
+    private static final Pattern RULE_PATTERN2 = Pattern.compile(
+			"\\n\\s*rule\\s+([^\\s;#\"]+)", Pattern.DOTALL);
+
+    private static final Pattern PACKAGE_PATTERN = Pattern.compile(
+			"\\s*package\\s+([^\\s;#]+);?", Pattern.DOTALL);
+
+	private static final Pattern FUNCTION_PATTERN = Pattern.compile(
+			"\\n\\s*function\\s+(\\S+)\\s+(\\S+)\\(.*\\)", Pattern.DOTALL);
+
+	private static final Pattern TEMPLATE_PATTERN = Pattern.compile(
+			"\\n\\s*template\\s+([^\\s;#\"]+)", Pattern.DOTALL);
+
+	private static final Pattern IMPORT_PATTERN = Pattern.compile(
+			"\\n\\s*import\\s+([^\\s;#]+);?", Pattern.DOTALL);
+
+	private static final Pattern EXPANDER_PATTERN = Pattern.compile(
+			"\\n\\s*expander\\s+([^\\s;#]+);?", Pattern.DOTALL);
+
+	private static final Pattern GLOBAL_PATTERN = Pattern.compile(
+			"\\n\\s*global\\s+(\\S+)\\s+([^\\s;#]+);?", Pattern.DOTALL);
+
+	private static final Pattern QUERY_PATTERN1 = Pattern.compile(
+			"\\n\\s*query\\s+\"([^\"]+)\"", Pattern.DOTALL);
+
+	private static final Pattern QUERY_PATTERN2 = Pattern.compile(
+			"\\n\\s*query\\s+([^\\s;#\"]+)", Pattern.DOTALL);
+
+    public RuleContentOutlinePage(AbstractRuleEditor editor) {
+        this.editor = editor;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        TreeViewer viewer = getTreeViewer();
+        viewer.setContentProvider(new DroolsContentProvider());
+        viewer.setLabelProvider(new DroolsLabelProvider());
+        viewer.setSorter(new DroolsTreeSorter());
+        viewer.setInput(ruleSet);
+        FilterActionGroup filterActionGroup = new FilterActionGroup(
+    		viewer, "org.drools.eclipse.editors.outline.RuleContentOutlinePage");
+		filterActionGroup.fillActionBars(getSite().getActionBars());
+        update();
+
+        // add the listener for navigation of the rule document.
+        super.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+                Object selectionObj = event.getSelection();
+                if (selectionObj != null && selectionObj instanceof StructuredSelection) {
+                    StructuredSelection sel = (StructuredSelection) selectionObj;
+                    DroolsElement element = (DroolsElement) sel.getFirstElement();
+                    if (element != null) {
+                        editor.selectAndReveal(element.getOffset(),
+                                                element.getLength());
+                    }
+                }
+            }
+        });
+    }
+
+    /**
+     * Updates the outline page.
+     */
+    public void update() {
+        TreeViewer viewer = getTreeViewer();
+        if (viewer != null) {
+            Control control = viewer.getControl();
+            if (control != null && !control.isDisposed()) {
+            	initRules();
+            	populatePackageTreeNode();
+            	viewer.refresh();
+                control.setRedraw(false);
+                viewer.expandToLevel(2);
+                control.setRedraw(true);
+            }
+        }
+    }
+
+    /**
+     * populates the PackageTreeNode with all of its child elements
+     * 
+     * @param packageTreeNode the node to populate
+     */
+    public void populatePackageTreeNode() {
+    	String ruleFileContents = editor.getContent();
+    	populatePackageTreeNode(ruleFileContents);
+    }
+    
+    void populatePackageTreeNode(String ruleFileContents) {
+    	DroolsModelBuilder.clearRuleSet(ruleSet);
+    	Matcher matcher = PACKAGE_PATTERN.matcher(ruleFileContents);
+    	String packageName = null;
+    	int startChar = 0;
+    	int endChar = 0; 
+        if (matcher.find()) {
+            packageName = matcher.group(1);
+            startChar = matcher.start(1);
+            endChar = matcher.end(1);
+        }
+        Package pkg = DroolsModelBuilder.addPackage(ruleSet, packageName,
+    		startChar, endChar - startChar);
+
+        matcher = RULE_PATTERN1.matcher(ruleFileContents);
+        while (matcher.find()) {
+            String ruleName = matcher.group(1);
+            DroolsModelBuilder.addRule(pkg, ruleName, null,
+        		matcher.start(1), matcher.end(1) - matcher.start(1),
+        		extractAttributes((RuleDescr) rules.get(ruleName)));
+        }
+        matcher = RULE_PATTERN2.matcher(ruleFileContents);
+        while (matcher.find()) {
+            String ruleName = matcher.group(1);
+            DroolsModelBuilder.addRule(pkg, ruleName, null,
+        		matcher.start(1), matcher.end(1) - matcher.start(1),
+        		extractAttributes((RuleDescr) rules.get(ruleName)));
+         } 
+        matcher = FUNCTION_PATTERN.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String functionName = matcher.group(2);
+			DroolsModelBuilder.addFunction(pkg, functionName + "()", null,
+				matcher.start(2), matcher.end(2) - matcher.start(2));
+		}
+		matcher = EXPANDER_PATTERN.matcher(ruleFileContents);
+		if (matcher.find()) {
+			String expanderName = matcher.group(1);
+			DroolsModelBuilder.addExpander(pkg, expanderName, null,
+				matcher.start(1), matcher.end(1) - matcher.start(1));
+		}
+		matcher = IMPORT_PATTERN.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String importName = matcher.group(1);
+			DroolsModelBuilder.addImport(pkg, importName, null,
+				matcher.start(1), matcher.end(1) - matcher.start(1));
+		}
+		matcher = GLOBAL_PATTERN.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String globalType = matcher.group(1);
+			String globalName = matcher.group(2);
+			String name = globalName + " : " + globalType;
+			DroolsModelBuilder.addGlobal(pkg, name, null,
+				matcher.start(2), matcher.end(2) - matcher.start(2));
+		}
+		matcher = QUERY_PATTERN1.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String queryName = matcher.group(1);
+			DroolsModelBuilder.addQuery(pkg, queryName, null,
+					matcher.start(1), matcher.end(1) - matcher.start(1));
+		}
+		matcher = QUERY_PATTERN2.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String queryName = matcher.group(1);
+			DroolsModelBuilder.addQuery(pkg, queryName, null,
+				matcher.start(1), matcher.end(1) - matcher.start(1));
+		}
+		matcher = TEMPLATE_PATTERN.matcher(ruleFileContents);
+		while (matcher.find()) {
+			String templateName = matcher.group(1);
+			DroolsModelBuilder.addTemplate(pkg, templateName, null,
+					matcher.start(1), matcher.end(1) - matcher.start(1));
+		}
+    }
+    
+    RuleSet getRuleSet() {
+    	return ruleSet;
+    }
+    
+    private Map extractAttributes(RuleDescr ruleDescr) {
+        Map attributes = null;
+        if (ruleDescr != null) {
+        	attributes = new HashMap();
+        	for (Iterator iterator = ruleDescr.getAttributes().iterator(); iterator.hasNext();) {
+        		AttributeDescr attribute = (AttributeDescr) iterator.next();
+        		if (attribute != null && attribute.getName() != null) {
+        			attributes.put(attribute.getName(), attribute.getValue());
+        		}
+        	}
+        }
+        return attributes;
+    }
+
+    public void initRules() {
+    	rules = new HashMap();
+    	try {
+    		DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(editor, true, false);
+    		if (drlInfo != null) {
+		    	PackageDescr packageDescr = drlInfo.getPackageDescr();
+	    		for (Iterator iterator = packageDescr.getRules().iterator(); iterator.hasNext(); ) {
+	    			RuleDescr ruleDescr = (RuleDescr) iterator.next();
+	    			rules.put(ruleDescr.getName(), ruleDescr);
+	    		}
+    		}
+    	} catch (DroolsParserException e) {
+    		DroolsEclipsePlugin.log(e);
+    	}
+    }
+    
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteViewer.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteViewer.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteViewer.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,305 @@
+package org.drools.eclipse.editors.rete;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.eclipse.editors.rete.part.VertexEditPartFactory;
+import org.drools.reteoo.BaseVertex;
+import org.drools.reteoo.ReteooRuleBase;
+import org.drools.reteoo.ReteooVisitor;
+import org.drools.rule.Package;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.ConnectionRouter;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ShortestPathConnectionRouter;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.MouseWheelHandler;
+import org.eclipse.gef.MouseWheelZoomHandler;
+import org.eclipse.gef.editparts.LayerManager;
+import org.eclipse.gef.editparts.ScalableFreeformRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.ui.parts.GraphicalEditor;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.swt.SWT;
+
+/**
+ * GEF-based RETE Viewer
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class ReteViewer extends GraphicalEditor {
+
+    private static final String  MSG_PARSE_ERROR         = "Unable to parse rules to show RETE view!";
+
+    private static final int     SIMPLE_ROUTER_MIN_NODES = 100;
+
+    ScalableFreeformRootEditPart rootEditPart            = new ScalableFreeformRootEditPart();
+
+    private ReteGraph            diagram                 = new ReteGraph();
+
+    private boolean              relayoutRequired        = true;
+    
+    private DRLRuleEditor drlEditor;
+
+    /**
+     * Constructor.
+     * 
+     * @param documentProvider documentProvider must contain Document with rules.
+     */
+    public ReteViewer(DRLRuleEditor drlEditor) {
+        this.drlEditor = drlEditor;
+        setEditDomain( new DefaultEditDomain( this ) );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.ui.parts.GraphicalEditor#configureGraphicalViewer()
+     */
+    protected void configureGraphicalViewer() {
+        super.configureGraphicalViewer();
+        GraphicalViewer viewer = getGraphicalViewer();
+        viewer.getControl().setBackground( ColorConstants.white );
+        viewer.setEditPartFactory( new VertexEditPartFactory() );
+        viewer.setRootEditPart( rootEditPart );
+        viewer.setKeyHandler( new GraphicalViewerKeyHandler( viewer ) );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.ui.parts.GraphicalEditor#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter(Class type) {
+
+        if ( type == ZoomManager.class ) return ((ScalableFreeformRootEditPart) getGraphicalViewer().getRootEditPart()).getZoomManager();
+        if ( type == GraphicalViewer.class ) return getGraphicalViewer();
+        if ( type == EditPart.class && getGraphicalViewer() != null ) return getGraphicalViewer().getRootEditPart();
+        if ( type == IFigure.class && getGraphicalViewer() != null ) return ((GraphicalEditPart) getGraphicalViewer().getRootEditPart()).getFigure();
+        return super.getAdapter( type );
+    }
+
+    private RuleBase getRuleBase(String contents) {
+        try {
+        	DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(drlEditor, true, true);
+        	if (drlInfo != null) {
+        		Package pkg = drlInfo.getPackage();
+        		ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(RuleBase.RETEOO);
+        		ruleBase.addPackage(pkg);
+        		return ruleBase;
+        	}
+        } catch ( Throwable t ) {
+            DroolsEclipsePlugin.log( t );
+        }
+        return null;
+    }
+
+    /**
+     * Loads model from rule base,
+     * calculates rete view and initializes diagram model.
+     * @param monitor 
+     * @param contents 
+     * @return
+     */
+    public ReteGraph loadReteModel(IProgressMonitor monitor,
+                                   String contents) throws Throwable {
+        if ( relayoutRequired == false ) {
+            return diagram;
+        }
+
+        ReteGraph newDiagram = new ReteGraph();
+
+        try {
+
+            monitor.beginTask( "Loading RETE Tree",
+                               100 );
+
+            monitor.subTask( "Loading Rule Base" );
+            RuleBase ruleBase = getRuleBase( contents );
+            if ( ruleBase == null ) {
+                final Exception error = new Exception( MSG_PARSE_ERROR );
+                throw error;
+            }
+            monitor.worked( 50 );
+            if ( monitor.isCanceled() ) {
+                throw new InterruptedException();
+            }
+
+            monitor.subTask( "Building RETE Tree" );
+            final ReteooVisitor visitor = new ReteooVisitor( newDiagram );
+            visitor.visit( ruleBase );
+            monitor.worked( 30 );
+            if ( monitor.isCanceled() ) {
+                throw new InterruptedException();
+            }
+
+            monitor.subTask( "Calculating RETE Tree Layout" );
+            BaseVertex rootVertex = visitor.getRootVertex();
+            RowList rowList = ReteooLayoutFactory.calculateReteRows( rootVertex );
+            ReteooLayoutFactory.layoutRowList( newDiagram,
+                                               rowList );
+            zeroBaseDiagram( newDiagram );
+            monitor.worked( 20 );
+            if ( monitor.isCanceled() ) {
+                throw new InterruptedException();
+            }
+            monitor.done();
+
+        } catch ( Throwable t ) {
+            if ( !(t instanceof InterruptedException) ) {
+                DroolsEclipsePlugin.log( t );
+            }
+            throw t;
+        }
+        relayoutRequired = false;
+        return newDiagram;
+    }
+
+    private ReteGraph getModel() {
+        return diagram;
+    }
+
+    /**
+     * Loads Rete model and initializes zoom manager.
+     * 
+     */
+    protected void initializeGraphicalViewer() {
+        ZoomManager zoomManager = rootEditPart.getZoomManager();
+
+        //List<String>
+        List zoomLevels = new ArrayList( 3 );
+
+        zoomLevels.add( ZoomManager.FIT_ALL );
+        zoomLevels.add( ZoomManager.FIT_HEIGHT );
+        zoomLevels.add( ZoomManager.FIT_WIDTH );
+
+        zoomManager.setZoomLevelContributions( zoomLevels );
+
+        // Zoom mousewheel - Ctrl+Mousewheel for zoom in/out
+        getGraphicalViewer().setProperty( MouseWheelHandler.KeyGenerator.getKey( SWT.MOD1 ),
+                                          MouseWheelZoomHandler.SINGLETON );
+
+    }
+
+    /**
+     * Moves all <code>diagram</code> nodes to upper left corner
+     * and shifting to right if neccessary to get rid of negative XY coordinates.
+     * 
+     */
+    private void zeroBaseDiagram(ReteGraph graph) {
+
+        Dimension dim = rootEditPart.getContentPane().getSize();
+
+        int minx = 0, miny = 0, maxx = 0, x = dim.width;
+
+        final Iterator nodeIter = graph.getChildren().iterator();
+        while ( nodeIter.hasNext() ) {
+            Point loc = ((BaseVertex) (nodeIter.next())).getLocation();
+            minx = Math.min( loc.x,
+                             minx );
+            maxx = Math.max( loc.x,
+                             maxx );
+            miny = Math.min( loc.y,
+                             miny );
+        }
+
+        int delta = (x - (maxx - minx + 20)) / 2;
+        minx = minx - (delta);
+
+        final Iterator nodeIter2 = graph.getChildren().iterator();
+        while ( nodeIter2.hasNext() ) {
+            final BaseVertex vertex = (BaseVertex) (nodeIter2.next());
+            Point loc = vertex.getLocation();
+            vertex.setLocation( new Point( loc.x - minx,
+                                           loc.y - miny ) );
+        }
+    }
+
+    /**
+     * No save operation in ReteViewer
+     */
+    public void doSave(IProgressMonitor monitor) {
+
+    }
+
+    /**
+     * ReteViewer is never dirty.
+     * This prevents editor close mechanism to ask file save confirmation
+     * even after one of the vertices is moved.
+     */
+    public boolean isDirty() {
+        return false;
+    }
+
+    /**
+     * Fired when underlying source is modified.
+     * Marks graph viewer to be relayouted when activated.
+     */
+    public void fireDocumentChanged() {
+        relayoutRequired = true;
+    }
+
+    /**
+     * Draws graph.
+     * 
+     * @param newGraph used to replace existing graph. if null then existing graph is simply redrawn.
+     */
+    public void drawGraph(ReteGraph newGraph) {
+
+        LayerManager manager = (LayerManager) getGraphicalViewer().getEditPartRegistry().get( LayerManager.ID );
+        ConnectionLayer connLayer = (ConnectionLayer) manager.getLayer( LayerConstants.CONNECTION_LAYER );
+
+        // Lazy-init model initialization
+        if ( getGraphicalViewer().getContents() == null ) {
+            getGraphicalViewer().setContents( getModel() );
+        }
+
+        final boolean isNewDiagram = newGraph != null && newGraph != diagram;
+
+        if ( isNewDiagram ) {
+            diagram.removeAll();
+        }
+
+        // Update connection router according to new model size
+        ConnectionRouter router;
+        if ( (isNewDiagram && newGraph.getChildren().size() < SIMPLE_ROUTER_MIN_NODES) || (!isNewDiagram && getModel().getChildren().size() < SIMPLE_ROUTER_MIN_NODES) ) {
+            router = new ShortestPathConnectionRouter( (IFigure) rootEditPart.getContentPane().getChildren().get( 0 ) );
+        } else {
+            router = ConnectionRouter.NULL;
+        }
+        connLayer.setConnectionRouter( router );
+
+        if ( newGraph != null && newGraph != diagram ) {
+            diagram.addAll( newGraph.getChildren() );
+        }
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteooLayoutFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteooLayoutFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/ReteooLayoutFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,155 @@
+package org.drools.eclipse.editors.rete;
+
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.drools.eclipse.editors.rete.model.Connection;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.reteoo.BaseVertex;
+import org.eclipse.draw2d.geometry.Point;
+
+/**
+ * Factory methods for calculating and layouting reteoo graph
+ *
+ */
+public class ReteooLayoutFactory {
+
+    /**
+     * Calculates layouting for provided graph.
+     * 
+     * @param root graph root vertex
+     * 
+     * @return Optimally layouted rows from provided graph
+     */
+    public static RowList calculateReteRows(BaseVertex root) {
+        RowList rowList;
+        rowList = new RowList();
+
+        rowList.add( 0,
+                     root );
+
+        int curRow = 0;
+
+        final Set seenVertices = new HashSet();
+        seenVertices.add( root );
+
+        while ( curRow < rowList.getDepth() ) {
+            final List rowVertices = rowList.get( curRow ).getVertices();
+
+            for ( final Iterator rowNodeIter = rowVertices.iterator(); rowNodeIter.hasNext(); ) {
+                final BaseVertex rowNode = (BaseVertex) rowNodeIter.next();
+
+                final List edges = rowNode.getSourceConnections();
+
+                for ( final Iterator edgeIter = edges.iterator(); edgeIter.hasNext(); ) {
+
+                    final Connection edge = (Connection) edgeIter.next();
+                    final BaseVertex destNode = edge.getOpposite( rowNode );
+
+                    if ( !seenVertices.contains( destNode ) ) {
+                        rowList.add( curRow + 1,
+                                     destNode );
+                        seenVertices.add( destNode );
+                    }
+                }
+
+                seenVertices.add( rowNode );
+            }
+
+            ++curRow;
+        }
+
+        rowList.optimize();
+
+        return rowList;
+    }
+
+    /**
+     * Adds all vertices from rowList to the graph.
+     * 
+     * @param graph
+     * @param rowList
+     */
+    public static void layoutRowList(ReteGraph graph,
+                                     RowList rowList) {
+        new LayoutCalculator( graph,
+                              rowList );
+    }
+
+    private static class LayoutCalculator {
+
+        public final static String COORDS                = "drools.LayoutCalculator.coords";
+
+        private static final int   COLUMN_SPACE          = 40;
+        private static final int   ROW_HEIGHT_MULTIPLIER = 6;
+
+        private RowList            rowList;
+
+        private int                columnWidth;
+        private int                rowHeight;
+
+        private ReteGraph          graph;
+
+        private LayoutCalculator(final ReteGraph graph,
+                                 final RowList rowList) {
+            this.graph = graph;
+            this.rowList = rowList;
+            computeSize();
+
+            List vertices = getGraph().getChildren();
+            Iterator iter = vertices.iterator();
+            while ( iter.hasNext() ) {
+                BaseVertex v = (BaseVertex) iter.next();
+                initialize_local_vertex( v );
+            }
+
+        }
+
+        private void computeSize() {
+            final List vertices = getGraph().getChildren();
+
+            for ( final Iterator vertexIter = vertices.iterator(); vertexIter.hasNext(); ) {
+                final BaseVertex vertex = (BaseVertex) vertexIter.next();
+
+                final int width = vertex.getSize().width;
+                final int height = vertex.getSize().height;
+
+                if ( width > this.columnWidth ) {
+                    this.columnWidth = width;
+                }
+
+                if ( height > this.rowHeight ) {
+                    this.rowHeight = height;
+                }
+            }
+
+            this.columnWidth = this.columnWidth + LayoutCalculator.COLUMN_SPACE;
+        }
+
+        private void initialize_local_vertex(final BaseVertex vertex) {
+            final int row = this.rowList.getRow( vertex );
+            final int col = this.rowList.getColumn( vertex );
+
+            final int rowWidth = this.rowList.getWidth( row );
+
+            final int columnWidthPx = columnWidth;
+            final int rowHeightPx = rowHeight;
+
+            double x = (col * columnWidthPx);
+            double y = (row * (rowHeightPx * LayoutCalculator.ROW_HEIGHT_MULTIPLIER));
+
+            x = x + (columnWidthPx / 2) - ((rowWidth - 1) * (columnWidthPx / 2));
+            y = y + (rowHeightPx / 2) + 3;
+
+            vertex.setLocation( new Point( x,
+                                           y ) );
+        }
+
+        private ReteGraph getGraph() {
+            return graph;
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/Row.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/Row.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/Row.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,139 @@
+package org.drools.eclipse.editors.rete;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.Iterator;
+import java.util.LinkedList;
+import java.util.List;
+
+import org.drools.reteoo.BaseVertex;
+
+/**
+ * Represents one row in rete graph
+ *
+ */
+public class Row {
+
+    private final int depth;
+
+    //List<BaseVertex>
+    private List      vertices;
+
+    /**
+     * Default constructor.
+     * 
+     * @param depth row depth 
+     */
+    public Row(final int depth) {
+        super();
+        this.vertices = new ArrayList();
+        this.depth = depth;
+    }
+
+    /**
+     * Returns row depth
+     * 
+     * @return row depth
+     */
+    public int getDepth() {
+        return this.depth;
+    }
+
+    /**
+     * Adds new vertex to this row.
+     * 
+     * @param vertex new vertex to be added 
+     */
+    public void add(final BaseVertex vertex) {
+        this.vertices.add( vertex );
+    }
+
+    /**
+     * Returns all vertices from this row.
+     * 
+     * @return list of vertices with type BaseVertex
+     */
+    public List getVertices() {
+        return this.vertices;
+    }
+
+    /**
+     * @param vertex
+     * @return <code>true</code> if vertex is found in row. <code>false</code> otherwise.
+     */
+    public boolean contains(final BaseVertex vertex) {
+        return this.vertices.contains( vertex );
+    }
+
+    /**
+     * @return number of vertices in row 
+     */
+    public int getWidth() {
+        return this.vertices.size();
+    }
+
+    /**
+     * Optimizing vertices for optimal presentation
+     * 
+     */
+    public void optimize() {
+        final List sorted = new ArrayList( this.vertices );
+
+        Collections.sort( sorted,
+                          new Comparator() {
+                              public int compare(final Object o1,
+                                                 final Object o2) {
+                                  final BaseVertex v1 = (BaseVertex) o1;
+                                  final BaseVertex v2 = (BaseVertex) o2;
+
+                                  int v1OutDegree = v1.getSourceConnections().size();
+                                  int v2OutDegree = v2.getSourceConnections().size();
+
+                                  if ( v1OutDegree < v2OutDegree ) {
+                                      return 1;
+                                  }
+
+                                  if ( v1OutDegree > v2OutDegree ) {
+                                      return -1;
+                                  }
+
+                                  return 0;
+                              }
+                          } );
+
+        final LinkedList optimized = new LinkedList();
+
+        boolean front = false;
+
+        for ( final Iterator vertexIter = sorted.iterator(); vertexIter.hasNext(); ) {
+            final BaseVertex vertex = (BaseVertex) vertexIter.next();
+
+            if ( front ) {
+                optimized.addFirst( vertex );
+            } else {
+                optimized.addLast( vertex );
+            }
+
+            front = !front;
+        }
+
+        this.vertices = optimized;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/RowList.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/RowList.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/RowList.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,169 @@
+package org.drools.eclipse.editors.rete;
+
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.reteoo.BaseVertex;
+
+/**
+ * Holder for Row elements.
+ * 
+ */
+public class RowList {
+
+    // List<Row>
+    private List rows;
+
+    /**
+     * Default constructor.
+     */
+    public RowList() {
+        super();
+        this.rows = new ArrayList();
+    }
+
+    /**
+     * Adds new vertex to specified depth
+     * 
+     * @param depth depth for vertex
+     * @param vertex vertex
+     */
+    public void add(final int depth,
+                    final BaseVertex vertex) {
+        if ( this.rows.size() < (depth + 1) ) {
+            final int addRows = depth - this.rows.size() + 1;
+
+            for ( int i = 0; i < addRows; ++i ) {
+                this.rows.add( new Row( (depth - addRows) + i ) );
+            }
+        }
+
+        ((Row) this.rows.get( depth )).add( vertex );
+    }
+
+    /**
+     * @return number of rows in RowList
+     */
+    public int getDepth() {
+        return this.rows.size();
+    }
+
+    /**
+     * @param row index of the row to be returned (0..n-1)
+     * @return specified row
+     */
+    public Row get(final int row) {
+        return (Row) this.rows.get( row );
+    }
+
+    /**
+     * Finds specified vertex from the rows.
+     * 
+     * @param vertex vertex
+     * 
+     * @return row number where vertex was found (0..n-1). <code>-1</code> if not found. 
+     */
+    public int getRow(final BaseVertex vertex) {
+        final int numRows = this.rows.size();
+
+        for ( int i = 0; i < numRows; ++i ) {
+            if ( ((Row) this.rows.get( i )).contains( vertex ) ) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Finds the longest row width.
+     * 
+     * @return width of the longest row
+     */
+    public int getWidth() {
+        int width = 0;
+
+        for ( final Iterator rowIter = this.rows.iterator(); rowIter.hasNext(); ) {
+            final Row row = (Row) rowIter.next();
+            final int rowWidth = row.getWidth();
+
+            if ( rowWidth > width ) {
+                width = rowWidth;
+            }
+        }
+
+        return width;
+    }
+
+    /**
+     * Width of the row at specified index.
+     * 
+     * @param row
+     * @return width
+     */
+    public int getWidth(final int row) {
+        return ((Row) this.rows.get( row )).getWidth();
+    }
+
+    /**
+     * @param vertex vertex to search
+     * @return column where vertex was found
+     */
+    public int getColumn(final BaseVertex vertex) {
+        final int row = getRow( vertex );
+
+        if ( row < 0 ) {
+            return -1;
+        }
+
+        final List rowVertices = get( row ).getVertices();
+
+        final int numCols = rowVertices.size();
+
+        for ( int i = 0; i < numCols; ++i ) {
+            if ( rowVertices.get( i ).equals( vertex ) ) {
+                return i;
+            }
+        }
+
+        return -1;
+    }
+
+    /**
+     * Dumps all row vertices to System.err
+     */
+    public void dump() {
+        final int numRows = this.rows.size();
+
+        for ( int i = 0; i < numRows; ++i ) {
+            System.err.println( i + ": " + get( i ).getVertices() );
+        }
+    }
+
+    /**
+     * Optimizes all rows for optimal presentation
+     */
+    public void optimize() {
+        final int numRows = this.rows.size();
+
+        for ( int i = 0; i < numRows; ++i ) {
+            get( i ).optimize();
+        }
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/commands/NodeSetConstraintCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/commands/NodeSetConstraintCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/commands/NodeSetConstraintCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,79 @@
+package org.drools.eclipse.editors.rete.commands;
+
+import org.drools.reteoo.BaseVertex;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+
+/**
+ * A command to move a vertex.
+ * 
+ */
+public class NodeSetConstraintCommand extends Command {
+
+    /** Stores the new size and location. */
+    private final Rectangle           newBounds;
+
+    /** Stores the old size and location. */
+    private Rectangle                 oldBounds;
+
+    /** A request to move/resize an edit part. */
+    private final ChangeBoundsRequest request;
+
+    /** BaseVertex to manipulate. */
+    private final BaseVertex          vertex;
+
+    /**
+     * Create a command that can resize and/or move a vertex.
+     *  
+     * @param vertex the vertex to manipulate
+     * @param req       the move request
+     * @param newBounds the new location. size is ignored
+     * @throws IllegalArgumentException if any of the parameters is null
+     */
+    public NodeSetConstraintCommand(BaseVertex vertex,
+                                    ChangeBoundsRequest req,
+                                    Rectangle newBounds) {
+        if ( vertex == null || req == null || newBounds == null ) {
+            throw new IllegalArgumentException();
+        }
+        this.vertex = vertex;
+        this.request = req;
+        this.newBounds = newBounds.getCopy();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.commands.Command#canExecute()
+     */
+    public boolean canExecute() {
+        Object type = request.getType();
+        return (RequestConstants.REQ_MOVE.equals( type ) || RequestConstants.REQ_MOVE_CHILDREN.equals( type ));
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.commands.Command#execute()
+     */
+    public void execute() {
+        oldBounds = new Rectangle( vertex.getLocation(),
+                                   vertex.getSize() );
+        redo();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.commands.Command#redo()
+     */
+    public void redo() {
+        vertex.setSize( newBounds.getSize() );
+        vertex.setLocation( newBounds.getLocation() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.commands.Command#undo()
+     */
+    public void undo() {
+        vertex.setSize( oldBounds.getSize() );
+        vertex.setLocation( oldBounds.getLocation() );
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/ConnectionFigure.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/ConnectionFigure.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/ConnectionFigure.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,20 @@
+package org.drools.eclipse.editors.rete.figure;
+
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.swt.SWT;
+
+/**
+ * ConnectionFigure between two Vertices. 
+ *
+ */
+public class ConnectionFigure extends PolylineConnection {
+
+    /**
+     * Painting antialiased connector
+     */
+    public void paint(Graphics g) {
+        g.setAntialias( SWT.ON );
+        super.paint( g );
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/VertexFigure.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/VertexFigure.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/figure/VertexFigure.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,54 @@
+package org.drools.eclipse.editors.rete.figure;
+
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.Graphics;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Figure representing BaseVertex
+ *
+ */
+public class VertexFigure extends Figure {
+
+    final private Color backgroundColor;
+    final private Color borderColor;
+
+    /**
+     * Initializing Figure
+     * 
+     * @param backgroundColor background color
+     * @param borderColor border color
+     */
+    public VertexFigure(Color backgroundColor,
+                        Color borderColor) {
+        this.backgroundColor = backgroundColor;
+        this.borderColor = borderColor;
+    }
+
+    /**
+     * Painting antialiased vertex
+     */
+    public void paint(Graphics g) {
+        g.setAntialias( SWT.ON );
+        Rectangle r = getBounds().getCopy();
+        g.translate( r.getLocation() );
+        g.setBackgroundColor( backgroundColor );
+        g.setForegroundColor( borderColor );
+        g.fillArc( 0,
+                   0,
+                   15,
+                   15,
+                   0,
+                   360 );
+        g.drawArc( 0,
+                   0,
+                   14,
+                   14,
+                   0,
+                   360 );
+        super.paint( g );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/Connection.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/Connection.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/Connection.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,80 @@
+package org.drools.eclipse.editors.rete.model;
+
+import org.drools.reteoo.BaseVertex;
+
+/**
+ * A connection between two distinct vertices.
+ */
+public class Connection extends ModelElement {
+
+    private boolean    isConnected;
+
+    private BaseVertex source;
+
+    private BaseVertex target;
+
+    /** 
+     * Creating a connection between two distinct vertices.
+     * 
+     * @param source a source endpoint
+     * @param target a target endpoint
+     * @throws IllegalArgumentException if any of the parameters are null or source == target
+     */
+    public Connection(BaseVertex source,
+                      BaseVertex target) {
+        this.source = source;
+        this.target = target;
+        source.addConnection( this );
+        target.addConnection( this );
+        isConnected = true;
+    }
+
+    /** 
+     * Disconnect this connection from the vertices it is attached to.
+     */
+    public void disconnect() {
+        if ( isConnected ) {
+            source.removeConnection( this );
+            target.removeConnection( this );
+            isConnected = false;
+        }
+    }
+
+    /**
+     * Returns the source endpoint of this connection.
+     * 
+     * @return BaseVertex vertex
+     */
+    public BaseVertex getSource() {
+        return source;
+    }
+
+    /**
+     * Returns the target endpoint of this connection.
+     * 
+     * @return BaseVertex vertex
+     */
+    public BaseVertex getTarget() {
+        return target;
+    }
+
+    /**
+     * Gets opposite of specified vertex.
+     * 
+     * Returning <code>null</code> if specified not does not belong into this connection.
+     * 
+     * @param vertex
+     * @return opposite of vertex
+     */
+    public BaseVertex getOpposite(BaseVertex vertex) {
+        // If null or not part of this connection
+        if ( vertex == null || (!vertex.equals( getSource() ) && !vertex.equals( getTarget() )) ) {
+            return null;
+        }
+        if ( vertex.equals( getSource() ) ) {
+            return getTarget();
+        }
+        return getSource();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/GraphicalVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/GraphicalVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/GraphicalVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,287 @@
+package org.drools.eclipse.editors.rete.model;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.spi.Constraint;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Visual vertex representation for ReteGraph.
+ * 
+ * Base impl for all rete vertices.
+ * 
+ * Can be connected with another BaseVertex with a Connector.
+ * 
+ * @author Ahti Kitsik
+ * 
+ */
+abstract public class GraphicalVertex extends ModelElement {
+
+    private static final String          VERTEX_NAME             = "BaseVertex ";
+
+    private static final String          WIDTH                   = "Width";
+
+    private static final String          HEIGHT                  = "Height";
+
+    private static IPropertyDescriptor[] descriptors;
+
+    /** ID for the Height property value (used for by the corresponding property descriptor). */
+    private static final String          HEIGHT_PROP             = VERTEX_NAME + "." + HEIGHT;
+
+    /** ID for the Width property value (used for by the corresponding property descriptor). */
+    private static final String          WIDTH_PROP              = VERTEX_NAME + "." + WIDTH;
+
+    /** Property ID to use when the location of this shape is modified. */
+    public static final String           LOCATION_PROP           = VERTEX_NAME + ".Location";
+
+    /** Property ID to use then the size of this shape is modified. */
+    public static final String           SIZE_PROP               = VERTEX_NAME + ".Size";
+
+    /** Property ID to use when the list of outgoing connections is modified. */
+    public static final String           SOURCE_CONNECTIONS_PROP = VERTEX_NAME + ".SourceConn";
+
+    /** Property ID to use when the list of incoming connections is modified. */
+    public static final String           TARGET_CONNECTIONS_PROP = VERTEX_NAME + ".TargetConn";
+
+    /** ID for the X property value (used for by the corresponding property descriptor).  */
+    private static final String          XPOS_PROP               = VERTEX_NAME + ".xPos";
+
+    /** ID for the Y property value (used for by the corresponding property descriptor).  */
+    private static final String          YPOS_PROP               = VERTEX_NAME + ".yPos";
+
+    /*
+     * Initializes the property descriptors array.
+     * @see #getPropertyDescriptors()
+     * @see #getPropertyValue(Object)
+     * @see #setPropertyValue(Object, Object)
+     */
+    static {
+        descriptors = new IPropertyDescriptor[]{new TextPropertyDescriptor( XPOS_PROP,
+                                                                            "X" ), // id and description pair
+            new TextPropertyDescriptor( YPOS_PROP,
+                                        "Y" ), new TextPropertyDescriptor( WIDTH_PROP,
+                                                                           WIDTH ), new TextPropertyDescriptor( HEIGHT_PROP,
+                                                                                                                HEIGHT ),};
+    } // static
+
+    /** Location of this vertex. */
+    private Point                        location                = new Point( 0,
+                                                                              0 );
+    /** Size of this vertex. */
+    private final static Dimension       size                    = new Dimension( 16,
+                                                                                  16 );
+    /** List of outgoing Connections. */
+    private List                         sourceConnections       = new ArrayList();
+    /** List of incoming Connections. */
+    private List                         targetConnections       = new ArrayList();
+
+    /**
+     * HTML formatted representation of this node
+     * 
+     * @return #getHtml
+     */
+    abstract public String getHtml();
+
+    /**
+     * Color used for filling vertex figure
+     * 
+     * @return color
+     */
+    abstract public Color getFillColor();
+
+    /**
+     * Add an incoming or outgoing connection to this vertex.
+     * @param conn a non-null connection instance
+     * @throws IllegalArgumentException if the connection is null or has not distinct endpoints
+     */
+    public void addConnection(Connection conn) {
+        if ( conn == null || conn.getSource() == conn.getTarget() ) {
+            throw new IllegalArgumentException();
+        }
+        if ( conn.getSource() == this ) {
+            sourceConnections.add( conn );
+            firePropertyChange( SOURCE_CONNECTIONS_PROP,
+                                null,
+                                conn );
+        } else if ( conn.getTarget() == this ) {
+            targetConnections.add( conn );
+            firePropertyChange( TARGET_CONNECTIONS_PROP,
+                                null,
+                                conn );
+        }
+    }
+
+    /**
+     * Return the Location of this vertex.
+     * 
+     * @return a non-null copy of location instance
+     */
+    public Point getLocation() {
+        return location.getCopy();
+    }
+
+    /**
+     * Returns an array of IPropertyDescriptors for this vertex.
+     * 
+     */
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    /**
+     * Return the property value for the given propertyId, or null.
+     */
+    public Object getPropertyValue(Object propertyId) {
+        if ( XPOS_PROP.equals( propertyId ) ) {
+            return Integer.toString( location.x );
+        }
+        if ( YPOS_PROP.equals( propertyId ) ) {
+            return Integer.toString( location.y );
+        }
+        if ( HEIGHT_PROP.equals( propertyId ) ) {
+            return Integer.toString( size.height );
+        }
+        if ( WIDTH_PROP.equals( propertyId ) ) {
+            return Integer.toString( size.width );
+        }
+        return null;
+    }
+
+    /**
+     * Return the Size of this vertex.
+     * @return a non-null copy of Dimension instance
+     */
+    public Dimension getSize() {
+        return size.getCopy();
+    }
+
+    /**
+     * Return a List of outgoing Connections.
+     */
+    public List getSourceConnections() {
+        return new ArrayList( sourceConnections );
+    }
+
+    /**
+     * Return a List of incoming Connections.
+     */
+    public List getTargetConnections() {
+        return new ArrayList( targetConnections );
+    }
+
+    /**
+     * Remove an incoming or outgoing connection from this vertex.
+     * 
+     * @param conn a non-null connection instance
+     * @throws IllegalArgumentException if the parameter is null
+     */
+    public void removeConnection(Connection conn) {
+        if ( conn == null ) {
+            throw new IllegalArgumentException();
+        }
+        if ( conn.getSource() == this ) {
+            sourceConnections.remove( conn );
+            firePropertyChange( SOURCE_CONNECTIONS_PROP,
+                                null,
+                                conn );
+        } else if ( conn.getTarget() == this ) {
+            targetConnections.remove( conn );
+            firePropertyChange( TARGET_CONNECTIONS_PROP,
+                                null,
+                                conn );
+        }
+    }
+
+    /**
+     * Set the Location of this vertex.
+     * @param newLocation a non-null Point instance
+     * @throws IllegalArgumentException if the parameter is null
+     */
+    public void setLocation(Point newLocation) {
+        if ( newLocation == null ) {
+            throw new IllegalArgumentException();
+        }
+        location.setLocation( newLocation );
+        firePropertyChange( LOCATION_PROP,
+                            null,
+                            location );
+    }
+
+    /**
+     * Set the property value for the given property id.
+     */
+    public void setPropertyValue(Object propertyId,
+                                 Object value) {
+        if ( XPOS_PROP.equals( propertyId ) ) {
+            int x = Integer.parseInt( (String) value );
+            setLocation( new Point( x,
+                                    location.y ) );
+        } else if ( YPOS_PROP.equals( propertyId ) ) {
+            int y = Integer.parseInt( (String) value );
+            setLocation( new Point( location.x,
+                                    y ) );
+        } else if ( HEIGHT_PROP.equals( propertyId ) ) {
+            int height = Integer.parseInt( (String) value );
+            setSize( new Dimension( size.width,
+                                    height ) );
+        } else if ( WIDTH_PROP.equals( propertyId ) ) {
+            int width = Integer.parseInt( (String) value );
+            setSize( new Dimension( width,
+                                    size.height ) );
+        }
+    }
+
+    /**
+     * Set the Size of this vertex.
+     * Will not update the size if newSize is null.
+     * @param newSize a non-null Dimension instance or null
+     */
+    public void setSize(Dimension newSize) {
+        if ( newSize != null ) {
+            size.setSize( newSize );
+            firePropertyChange( SIZE_PROP,
+                                null,
+                                size );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString() {
+        return VERTEX_NAME + hashCode();
+    }
+
+    /**
+     * Color used for borders
+     * 
+     * @return draw color
+     */
+    public Color getDrawColor() {
+        return ColorConstants.black;
+    }
+
+    /**
+     * Constructs constraints string
+     * 
+     * @param constraints array of constraints 
+     * @return html-formatted constraints representation
+     */
+    public static String dumpConstraints(final Constraint[] constraints) {
+        if ( constraints == null ) {
+            return null;
+        }
+        final StringBuffer buffer = new StringBuffer();
+        for ( int i = 0, length = constraints.length; i < length; i++ ) {
+            buffer.append( constraints[i].toString() + "<br>" );
+        }
+        return buffer.toString();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ModelElement.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ModelElement.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ModelElement.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,55 @@
+package org.drools.eclipse.editors.rete.model;
+
+import java.beans.PropertyChangeListener;
+import java.beans.PropertyChangeSupport;
+
+/**
+ * Abstract prototype of a model element.
+ */
+public abstract class ModelElement {
+
+    /** Delegate used to implemenent property-change-support. */
+    private transient PropertyChangeSupport pcsDelegate = new PropertyChangeSupport( this );
+
+    /** 
+     * Attach a non-null PropertyChangeListener to this object.
+     * 
+     * @param l a non-null PropertyChangeListener instance
+     * @throws IllegalArgumentException if the parameter is null
+     */
+    public synchronized void addPropertyChangeListener(PropertyChangeListener l) {
+        if ( l == null ) {
+            throw new IllegalArgumentException();
+        }
+        pcsDelegate.addPropertyChangeListener( l );
+    }
+
+    /** 
+     * Report a property change to registered listeners (for example edit parts).
+     * 
+     * @param property the programmatic name of the property that changed
+     * @param oldValue the old value of this property
+     * @param newValue the new value of this property
+     */
+    protected void firePropertyChange(String property,
+                                      Object oldValue,
+                                      Object newValue) {
+        if ( pcsDelegate.hasListeners( property ) ) {
+            pcsDelegate.firePropertyChange( property,
+                                            oldValue,
+                                            newValue );
+        }
+    }
+
+    /** 
+     * Remove a PropertyChangeListener from this component.
+     * 
+     * @param l a PropertyChangeListener instance
+     */
+    public synchronized void removePropertyChangeListener(PropertyChangeListener l) {
+        if ( l != null ) {
+            pcsDelegate.removePropertyChangeListener( l );
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ReteGraph.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ReteGraph.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/ReteGraph.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,79 @@
+package org.drools.eclipse.editors.rete.model;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.reteoo.BaseVertex;
+
+/**
+ * Rete graph containing a set of vertices that form the graph itself.
+ */
+public class ReteGraph extends ModelElement {
+
+    /** Property ID to use when a child is added to this diagram. */
+    public static final String PROP_CHILD_ADDED   = "ReteGraph.ChildAdded";
+
+    /** Property ID to use when a child is removed from this diagram. */
+    public static final String PROP_CHILD_REMOVED = "ReteGraph.ChildRemoved";
+
+    private List               vertices           = new ArrayList();
+
+    /** 
+     * Add new BaseVertex to the graph
+     * 
+     * @param vertex
+     * 
+     * @return true, if vertex was added, false otherwise
+     */
+    public boolean addChild(BaseVertex vertex) {
+        if ( vertex != null && vertices.add( vertex ) ) {
+            firePropertyChange( PROP_CHILD_ADDED,
+                                null,
+                                vertex );
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Return all Vertices in this graph
+     */
+    public List getChildren() {
+        return vertices;
+    }
+
+    /**
+     * Remove a vertex from this graph
+     * 
+     * @param vertex vertex to be removed
+     * @return true, if the vertex removal succeeded, false otherwise
+     */
+    public boolean removeChild(BaseVertex vertex) {
+        if ( vertex != null && vertices.remove( vertex ) ) {
+            firePropertyChange( PROP_CHILD_REMOVED,
+                                null,
+                                vertex );
+            return true;
+        }
+        return false;
+    }
+
+    /**
+     * Removes all vertices from graph.
+     */
+    public void removeAll() {
+        while ( vertices.size() > 0 ) {
+            removeChild( ((BaseVertex) vertices.get( 0 )) );
+        }
+    }
+
+    public void addAll(List children) {
+        final Iterator iter = children.iterator();
+        while ( iter.hasNext() ) {
+            BaseVertex vertex = (BaseVertex) iter.next();
+            addChild( vertex );
+        }
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/VertexPropertySource.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/VertexPropertySource.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/model/VertexPropertySource.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,501 @@
+package org.drools.eclipse.editors.rete.model;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.reteoo.AccumulateNodeVertex;
+import org.drools.reteoo.AlphaNodeVertex;
+import org.drools.reteoo.BaseVertex;
+import org.drools.reteoo.CollectNodeVertex;
+import org.drools.reteoo.EvalConditionNodeVertex;
+import org.drools.reteoo.ExistsNodeVertex;
+import org.drools.reteoo.FromNodeVertex;
+import org.drools.reteoo.JoinNodeVertex;
+import org.drools.reteoo.LeftInputAdapterNodeVertex;
+import org.drools.reteoo.NotNodeVertex;
+import org.drools.reteoo.ObjectTypeNodeVertex;
+import org.drools.reteoo.QueryTerminalNodeVertex;
+import org.drools.reteoo.ReteVertex;
+import org.drools.reteoo.RightInputAdapterNodeVertex;
+import org.drools.reteoo.RuleTerminalNodeVertex;
+import org.drools.spi.Constraint;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Providing IPropertySource for property sheets that show
+ * rete graph vertex properties.
+ * 
+ */
+public class VertexPropertySource
+    implements
+    IPropertySource {
+
+    private static final String       VERTEX_FROM                = "From BaseVertex";
+
+    private static final String       VERTEX_ACCUMULATE          = "Accumulate BaseVertex";
+
+    private static final String       VERTEX_COLLECT             = "Collect BaseVertex";
+
+    private static final String       VERTEX_EXISTS              = "Exists BaseVertex";
+
+    private static final String       VERTEX_TERMINAL            = "Terminal BaseVertex";
+
+    private static final String       VERTEX_QUERY_TERMINAL      = "Query Terminal BaseVertex";
+
+    private static final String       VERTEX_EVAL_CONDITION      = "Eval Condition BaseVertex";
+
+    private static final String       VERTEX_NOT                 = "Not BaseVertex";
+
+    private static final String       VERTEX_JOIN                = "Join BaseVertex";
+
+    private static final String       VERTEX_RIGHT_INPUT_ADAPTER = "Right Input Adapter BaseVertex";
+
+    private static final String       VERTEX_LEFT_INPUT_ADAPTER  = "Left Input Adapter BaseVertex";
+
+    private static final String       VERTEX_ALPHA               = "Alpha BaseVertex";
+
+    private static final String       VERTEX_OBJECT_TYPE         = "Object Type BaseVertex";
+
+    private static final String       VERTEX_RETE                = "Rete BaseVertex";
+
+    private static final String       CONSTRAINT_CAP             = "Constraint";
+
+    private static final String       CONSTRAINT                 = "constraint";
+
+    public String                     ID_ROOT                    = "vertex";                               //$NON-NLS-1$
+
+    public String                     ID_ID                      = "id";                                   //$NON-NLS-1$
+    public String                     ID_HTML                    = "html";                                 //$NON-NLS-1$
+
+    private IPropertyDescriptor[]     descriptors;
+
+    private final IPropertyDescriptor PROP_NAME                  = new PropertyDescriptor( "name",
+                                                                                           "Name" );
+    private final IPropertyDescriptor PROP_ID                    = new PropertyDescriptor( "id",
+                                                                                           "ID" );
+    private final IPropertyDescriptor PROP_RULE                  = new PropertyDescriptor( "rule",
+                                                                                           "Rule" );
+
+    private final IPropertyDescriptor PROP_QUERY                 = new PropertyDescriptor( "query",
+                                                                                           "Query" );
+    // Alpha-specific
+    private final IPropertyDescriptor PROP_ALPHA_FIELD_NAME      = new PropertyDescriptor( "fieldName",
+                                                                                           "Field Name" );
+    private final IPropertyDescriptor PROP_ALPHA_EVALUATOR       = new PropertyDescriptor( "evaluator",
+                                                                                           "Evaluator" );
+    private final IPropertyDescriptor PROP_ALPHA_VALUE           = new PropertyDescriptor( "value",
+                                                                                           "Value" );
+
+    // ObjectType specific
+    private final IPropertyDescriptor PROP_OBJ_TYPE              = new PropertyDescriptor( "objectType",
+                                                                                           "Object Type" );
+
+    private final static String       CAT_GENERAL                = "General";
+    private final static String       CAT_OTHER                  = "Other";
+
+    protected BaseVertex              vertex                     = null;
+
+    // Map<String,NodeValue>
+    private Map                       values                     = new HashMap();
+
+    /**
+     * Constructor initializing properties from <code>vertex</code>
+     * 
+     * @param vertex source vertex for this property source
+     */
+    public VertexPropertySource(BaseVertex vertex) {
+        this.vertex = vertex;
+
+        initProperties( vertex );
+    }
+
+    final private void initProperties(BaseVertex vertex) {
+
+        List descriptorList = new ArrayList();
+
+        if ( vertex instanceof ExistsNodeVertex ) {
+            initExistsNodeProperties( (ExistsNodeVertex) vertex,
+                                      descriptorList,
+                                      values );
+        } else if ( vertex instanceof FromNodeVertex ) {
+            initFromNodeProperties( (FromNodeVertex) vertex,
+                                    descriptorList,
+                                    values );
+        } else if ( vertex instanceof AccumulateNodeVertex ) {
+            initAccumulateNodeProperties( (AccumulateNodeVertex) vertex,
+                                          descriptorList,
+                                          values );
+        } else if ( vertex instanceof CollectNodeVertex ) {
+            initCollectNodeProperties( (CollectNodeVertex) vertex,
+                                       descriptorList,
+                                       values );
+        } else if ( vertex instanceof RuleTerminalNodeVertex ) {
+            initTerminalNodeProperties( (RuleTerminalNodeVertex) vertex,
+                    descriptorList,
+                    values );
+    	} else if ( vertex instanceof QueryTerminalNodeVertex ) {
+            initQueryTerminalNodeProperties( (QueryTerminalNodeVertex) vertex,
+                    descriptorList,
+                    values );
+    	} else if ( vertex instanceof EvalConditionNodeVertex ) {
+            initEvalConditionNodeProperties( (EvalConditionNodeVertex) vertex,
+                                             descriptorList,
+                                             values );
+        } else if ( vertex instanceof NotNodeVertex ) {
+            initNotNodeProperties( (NotNodeVertex) vertex,
+                                   descriptorList,
+                                   values );
+        } else if ( vertex instanceof JoinNodeVertex ) {
+            initJoinNodeProperties( (JoinNodeVertex) vertex,
+                                    descriptorList,
+                                    values );
+        } else if ( vertex instanceof RightInputAdapterNodeVertex ) {
+            initRightInputAdapterNodeProperties( descriptorList,
+                                                 values );
+        } else if ( vertex instanceof LeftInputAdapterNodeVertex ) {
+            initLeftInputAdapterNodeProperties( (LeftInputAdapterNodeVertex) vertex,
+                                                descriptorList,
+                                                values );
+        } else if ( vertex instanceof AlphaNodeVertex ) {
+            initAlphaNodeProperties( (AlphaNodeVertex) vertex,
+                                     descriptorList,
+                                     values );
+        } else if ( vertex instanceof ObjectTypeNodeVertex ) {
+            initObjectTypeNodeProperties( (ObjectTypeNodeVertex) vertex,
+                                          descriptorList,
+                                          values );
+        } else if ( vertex instanceof ReteVertex ) {
+            initReteNodeProperties( (ReteVertex) vertex,
+                                    descriptorList,
+                                    values );
+        }
+
+        descriptors = (IPropertyDescriptor[]) descriptorList.toArray( new IPropertyDescriptor[0] );
+    }
+
+    private void initExistsNodeProperties(ExistsNodeVertex vertex,
+                                          List descriptorList,
+                                          Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_EXISTS,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initCollectNodeProperties(CollectNodeVertex vertex,
+                                           List descriptorList,
+                                           Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_COLLECT,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initAccumulateNodeProperties(AccumulateNodeVertex vertex,
+                                              List descriptorList,
+                                              Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_ACCUMULATE,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initFromNodeProperties(FromNodeVertex vertex,
+                                        List descriptorList,
+                                        Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_FROM,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initReteNodeProperties(ReteVertex vertex,
+                                        List descriptorList,
+                                        Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_RETE,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initObjectTypeNodeProperties(ObjectTypeNodeVertex vertex,
+                                              List descriptorList,
+                                              Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_OBJECT_TYPE,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_OBJ_TYPE,
+                     vertex.getObjectType(),
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initAlphaNodeProperties(AlphaNodeVertex vertex,
+                                         List descriptorList,
+                                         Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_ALPHA,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ALPHA_FIELD_NAME,
+                     vertex.getFieldName(),
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ALPHA_EVALUATOR,
+                     vertex.getEvaluator(),
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ALPHA_VALUE,
+                     vertex.getValue(),
+                     descriptorList,
+                     valueMap );
+
+        Constraint constraint = vertex.getConstraint();
+        if ( constraint == null ) {
+            return;
+        }
+        IPropertyDescriptor prop = new PropertyDescriptor( CONSTRAINT,
+                                                           CONSTRAINT_CAP );
+        addProperty( prop,
+                     constraint.toString(),
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initLeftInputAdapterNodeProperties(LeftInputAdapterNodeVertex vertex,
+                                                    List descriptorList,
+                                                    Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_LEFT_INPUT_ADAPTER,
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initRightInputAdapterNodeProperties(List descriptorList,
+                                                     Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_RIGHT_INPUT_ADAPTER,
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initJoinNodeProperties(JoinNodeVertex vertex,
+                                        List descriptorList,
+                                        Map valueMap) {
+
+        addProperty( PROP_NAME,
+                     VERTEX_JOIN,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+
+        Constraint[] constraints = vertex.getConstraints();
+
+        if ( constraints == null ) {
+            return;
+        }
+
+        for ( int i = 0, length = constraints.length; i < length; i++ ) {
+            PropertyDescriptor prop = new PropertyDescriptor( CONSTRAINT + (i + 1),
+                                                              CONSTRAINT_CAP + " " + (i + 1) );
+            addOther( prop,
+                      constraints[i].toString(),
+                      descriptorList,
+                      valueMap );
+        }
+
+    }
+
+    private void initNotNodeProperties(NotNodeVertex vertex,
+                                       List descriptorList,
+                                       Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_NOT,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initEvalConditionNodeProperties(EvalConditionNodeVertex vertex,
+                                                 List descriptorList,
+                                                 Map valueMap) {
+        addProperty( PROP_NAME,
+                     VERTEX_EVAL_CONDITION,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( vertex.getId() ),
+                     descriptorList,
+                     valueMap );
+    }
+
+    private void initTerminalNodeProperties(RuleTerminalNodeVertex node,
+                                            List descriptorList,
+                                            Map valueMap) {
+
+        addProperty( PROP_NAME,
+                     VERTEX_TERMINAL,
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_ID,
+                     Integer.toString( node.getId() ),
+                     descriptorList,
+                     valueMap );
+        addProperty( PROP_RULE,
+                     node.getRuleName(),
+                     descriptorList,
+                     valueMap );
+
+    }
+
+    private void initQueryTerminalNodeProperties(QueryTerminalNodeVertex node,
+		            List descriptorList,
+		            Map valueMap) {
+		
+		addProperty( PROP_NAME,
+				     VERTEX_QUERY_TERMINAL,
+                     descriptorList,
+                     valueMap );
+		addProperty( PROP_ID,
+                     Integer.toString( node.getId() ),
+                     descriptorList,
+		             valueMap );
+		addProperty( PROP_QUERY,
+		             node.getQueryName(),
+		             descriptorList,
+		             valueMap );
+		
+	}
+
+    private void addProperty(IPropertyDescriptor field,
+                             String value,
+                             List descriptorList,
+                             Map valueMap) {
+        descriptorList.add( field );
+        valueMap.put( field.getId().toString(),
+                      new NodeValue( CAT_GENERAL,
+                                     value ) );
+        if ( field instanceof PropertyDescriptor ) {
+            ((PropertyDescriptor) field).setAlwaysIncompatible( true );
+            ((PropertyDescriptor) field).setCategory( CAT_GENERAL );
+        }
+
+    }
+
+    private void addOther(IPropertyDescriptor field,
+                          String value,
+                          List descriptorList,
+                          Map valueMap) {
+        descriptorList.add( field );
+        valueMap.put( field.getId().toString(),
+                      new NodeValue( CAT_OTHER,
+                                     value ) );
+
+        if ( field instanceof PropertyDescriptor ) {
+            ((PropertyDescriptor) field).setAlwaysIncompatible( true );
+            ((PropertyDescriptor) field).setCategory( CAT_OTHER );
+        }
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.views.properties.IPropertySource#getEditableValue()
+     */
+    public Object getEditableValue() {
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyValue(java.lang.Object)
+     */
+    public Object getPropertyValue(Object propName) {
+        return getPropertyValue( (String) propName );
+    }
+
+    /**
+     * Property value.
+     * 
+     * @param propName
+     * @return
+     */
+    public Object getPropertyValue(String propName) {
+        return ((NodeValue) (values.get( propName ))).value;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.views.properties.IPropertySource#setPropertyValue(java.lang.Object, java.lang.Object)
+     */
+    public void setPropertyValue(Object propName,
+                                 Object value) {
+        setPropertyValue( propName,
+                          value );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.views.properties.IPropertySource#getPropertyDescriptors()
+     */
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    /**
+     * Doing nothing as resetting properties from property sheet is not possible.
+     */
+    public void resetPropertyValue(Object propName) {
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.views.properties.IPropertySource#isPropertySet(java.lang.Object)
+     */
+    public boolean isPropertySet(Object propName) {
+        return values.containsKey( propName );
+    }
+
+    private class NodeValue {
+        final String category;
+        final String value;
+
+        NodeValue(String category,
+                  String value) {
+            this.category = category;
+            this.value = value;
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/ConnectionEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/ConnectionEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/ConnectionEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,82 @@
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.eclipse.editors.rete.part;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+
+import org.drools.eclipse.editors.rete.figure.ConnectionFigure;
+import org.drools.eclipse.editors.rete.model.ModelElement;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.PolylineDecoration;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+
+/**
+ * Edit part for Connection model elements.
+ */
+class ConnectionEditPart extends AbstractConnectionEditPart
+    implements
+    PropertyChangeListener {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+     */
+    public void activate() {
+        if ( !isActive() ) {
+            super.activate();
+            ((ModelElement) getModel()).addPropertyChangeListener( this );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+     */
+    protected void createEditPolicies() {
+        installEditPolicy( EditPolicy.CONNECTION_ENDPOINTS_ROLE,
+                           new ConnectionEndpointEditPolicy() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+     */
+    protected IFigure createFigure() {
+        PolylineConnection connection = new ConnectionFigure();
+        PolylineDecoration decoration = new PolylineDecoration();
+        connection.setTargetDecoration( decoration );
+        return connection;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
+     */
+    public void deactivate() {
+        if ( isActive() ) {
+            super.deactivate();
+            ((ModelElement) getModel()).removePropertyChangeListener( this );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        // Doing nothing   
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/DiagramEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/DiagramEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/DiagramEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,154 @@
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.eclipse.editors.rete.part;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.drools.eclipse.editors.rete.commands.NodeSetConstraintCommand;
+import org.drools.eclipse.editors.rete.model.ModelElement;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.reteoo.BaseVertex;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.FreeformLayer;
+import org.eclipse.draw2d.FreeformLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.ChangeBoundsRequest;
+import org.eclipse.gef.requests.CreateRequest;
+
+/**
+ * EditPart for ReteGraph
+ * 
+ */
+public class DiagramEditPart extends AbstractGraphicalEditPart
+    implements
+    PropertyChangeListener {
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+     */
+    public void activate() {
+        if ( !isActive() ) {
+            super.activate();
+            ((ModelElement) getModel()).addPropertyChangeListener( this );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+     */
+    protected void createEditPolicies() {
+        installEditPolicy( EditPolicy.COMPONENT_ROLE,
+                           new RootComponentEditPolicy() );
+        installEditPolicy( EditPolicy.LAYOUT_ROLE,
+                           new NodesXYLayoutEditPolicy() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+     */
+    protected IFigure createFigure() {
+        Figure f = new FreeformLayer();
+        f.setBorder( new MarginBorder( 3 ) );
+        f.setLayoutManager( new FreeformLayout() );
+        return f;
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
+     */
+    public void deactivate() {
+        if ( isActive() ) {
+            super.deactivate();
+            ((ModelElement) getModel()).removePropertyChangeListener( this );
+        }
+    }
+
+    private ReteGraph getCastedModel() {
+        return (ReteGraph) getModel();
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractEditPart#getModelChildren()
+     */
+    protected List getModelChildren() {
+        return getCastedModel().getChildren(); // return a list of nodes
+    }
+
+    /* (non-Javadoc)
+     * @see java.beans.PropertyChangeListener#propertyChange(PropertyChangeEvent)
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        String prop = evt.getPropertyName();
+        if ( ReteGraph.PROP_CHILD_ADDED.equals( prop ) || ReteGraph.PROP_CHILD_REMOVED.equals( prop ) ) {
+            refreshChildren();
+        }
+    }
+
+    private static class NodesXYLayoutEditPolicy extends XYLayoutEditPolicy {
+
+        /* (non-Javadoc)
+         * @see ConstrainedLayoutEditPolicy#createChangeConstraintCommand(ChangeBoundsRequest, EditPart, Object)
+         */
+        protected Command createChangeConstraintCommand(ChangeBoundsRequest request,
+                                                        EditPart child,
+                                                        Object constraint) {
+            if ( child instanceof NodeEditPart && constraint instanceof Rectangle ) {
+                // return a command that can move and/or resize a BaseVertex
+                return new NodeSetConstraintCommand( (BaseVertex) child.getModel(),
+                                                     request,
+                                                     (Rectangle) constraint );
+            }
+            return super.createChangeConstraintCommand( request,
+                                                        child,
+                                                        constraint );
+        }
+
+        /* (non-Javadoc)
+         * @see ConstrainedLayoutEditPolicy#createChangeConstraintCommand(EditPart, Object)
+         */
+        protected Command createChangeConstraintCommand(EditPart child,
+                                                        Object constraint) {
+            return null;
+        }
+
+        /* (non-Javadoc)
+         * @see LayoutEditPolicy#getCreateCommand(CreateRequest)
+         */
+        protected Command getCreateCommand(CreateRequest request) {
+            return null;
+        }
+
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter(Class key) {
+        return super.getAdapter( key );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,167 @@
+package org.drools.eclipse.editors.rete.part;
+
+import java.beans.PropertyChangeEvent;
+import java.beans.PropertyChangeListener;
+import java.util.List;
+
+import org.drools.eclipse.editors.rete.figure.VertexFigure;
+import org.drools.eclipse.editors.rete.model.GraphicalVertex;
+import org.drools.eclipse.editors.rete.model.ModelElement;
+import org.drools.eclipse.editors.rete.model.VertexPropertySource;
+import org.drools.reteoo.BaseVertex;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.EllipseAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.ui.views.properties.IPropertySource;
+
+/**
+ * EditPart used for Vertices
+ */
+class VertexEditPart extends AbstractGraphicalEditPart
+    implements
+    PropertyChangeListener,
+    org.eclipse.gef.NodeEditPart {
+
+    private IPropertySource  propertySource;
+
+    private ConnectionAnchor anchor;
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#activate()
+     */
+    public void activate() {
+        if ( !isActive() ) {
+            super.activate();
+            ((ModelElement) getModel()).addPropertyChangeListener( this );
+            propertySource = new VertexPropertySource( getCastedModel() );
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractEditPart#createEditPolicies()
+     */
+    protected void createEditPolicies() {
+    }
+
+    /*(non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#createFigure()
+     */
+    protected IFigure createFigure() {
+        return new VertexFigure( getCastedModel().getFillColor(),
+                                 getCastedModel().getDrawColor() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#deactivate()
+     */
+    public void deactivate() {
+        if ( isActive() ) {
+            super.deactivate();
+            ((ModelElement) getModel()).removePropertyChangeListener( this );
+            propertySource = null;
+        }
+    }
+
+    private BaseVertex getCastedModel() {
+        return (BaseVertex) getModel();
+    }
+
+    private ConnectionAnchor getConnectionAnchor() {
+        if ( anchor == null ) {
+            if ( getModel() instanceof BaseVertex ) anchor = new EllipseAnchor( getFigure() );
+            else
+            // if Nodes gets extended the conditions above must be updated
+            throw new IllegalArgumentException( "unexpected model" );
+        }
+        return anchor;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelSourceConnections()
+     */
+    protected List getModelSourceConnections() {
+        return getCastedModel().getSourceConnections();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getModelTargetConnections()
+     */
+    protected List getModelTargetConnections() {
+        return getCastedModel().getTargetConnections();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+     */
+    public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+        return getConnectionAnchor();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.NodeEditPart#getSourceConnectionAnchor(org.eclipse.gef.Request)
+     */
+    public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+        return getConnectionAnchor();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.ConnectionEditPart)
+     */
+    public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+        return getConnectionAnchor();
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.NodeEditPart#getTargetConnectionAnchor(org.eclipse.gef.Request)
+     */
+    public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+        return getConnectionAnchor();
+    }
+
+    /* (non-Javadoc)
+     * @see java.beans.PropertyChangeListener#propertyChange(java.beans.PropertyChangeEvent)
+     */
+    public void propertyChange(PropertyChangeEvent evt) {
+        String prop = evt.getPropertyName();
+        if ( GraphicalVertex.SIZE_PROP.equals( prop ) || GraphicalVertex.LOCATION_PROP.equals( prop ) ) {
+            refreshVisuals();
+        } else if ( GraphicalVertex.SOURCE_CONNECTIONS_PROP.equals( prop ) ) {
+            refreshSourceConnections();
+        } else if ( GraphicalVertex.TARGET_CONNECTIONS_PROP.equals( prop ) ) {
+            refreshTargetConnections();
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractEditPart#refreshVisuals()
+     */
+    protected void refreshVisuals() {
+        Rectangle bounds = new Rectangle( getCastedModel().getLocation(),
+                                          getCastedModel().getSize() );
+        ((GraphicalEditPart) getParent()).setLayoutConstraint( this,
+                                                               getFigure(),
+                                                               bounds );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.gef.editparts.AbstractGraphicalEditPart#getAdapter(java.lang.Class)
+     */
+    public Object getAdapter(Class key) {
+        if ( key == IPropertySource.class ) {
+            return propertySource;
+        }
+        return super.getAdapter( key );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPartFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPartFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/rete/part/VertexEditPartFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,50 @@
+package org.drools.eclipse.editors.rete.part;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.rete.model.Connection;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.reteoo.BaseVertex;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+/**
+ * Factory mapping model elements to edit parts
+ */
+public class VertexEditPartFactory
+    implements
+    EditPartFactory {
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.gef.EditPartFactory#createEditPart(org.eclipse.gef.EditPart, java.lang.Object)
+     */
+    public EditPart createEditPart(EditPart context,
+                                   Object modelElement) {
+        // get EditPart for model element
+        EditPart part = getPartForElement( modelElement );
+        // store model element in EditPart
+        part.setModel( modelElement );
+        return part;
+    }
+
+    /**
+     * Maps object to EditPart.
+     *  
+     * @throws RuntimeException if no match was found
+     */
+    private EditPart getPartForElement(Object modelElement) {
+        if ( modelElement instanceof ReteGraph ) {
+            return new DiagramEditPart();
+        }
+        if ( modelElement instanceof BaseVertex ) {
+            return new VertexEditPart();
+        }
+        if ( modelElement instanceof Connection ) {
+            return new ConnectionEditPart();
+        }
+        DroolsEclipsePlugin.log( new Exception( "Can't create part for model element: " + ((modelElement != null) ? modelElement.getClass().getName() : "null") ) );
+        return null;
+        
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLPartionScanner.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLPartionScanner.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLPartionScanner.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.editors.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.rules.IPredicateRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.MultiLineRule;
+import org.eclipse.jface.text.rules.RuleBasedPartitionScanner;
+import org.eclipse.jface.text.rules.Token;
+
+
+/**
+ * Break apart the rule source, very very simply.
+ *
+ * The job of the partitioner is to identify if the cursor position
+ * is in a rule block, or not.  Comments are also generated as a
+ * separate partition.
+ *  TODO: add support for dialect based partitioning for correct syntaxhighlighting
+ * @author Michael Neale
+ */
+public class DRLPartionScanner extends RuleBasedPartitionScanner {
+
+    public static final String RULE_PART_CONTENT = "__partition_rule_content";
+    public static final String RULE_COMMENT = "__partition_multiline_comment";
+
+    public static final String[] LEGAL_CONTENT_TYPES = {
+    	IDocument.DEFAULT_CONTENT_TYPE,
+    	RULE_PART_CONTENT,
+    	RULE_COMMENT
+    };
+
+    public DRLPartionScanner() {
+        initialise();
+    }
+
+    private void initialise() {
+        List rules = new ArrayList();
+
+        // rules
+        IToken rulePartition = new Token(RULE_PART_CONTENT);
+        rules.add(new MultiLineRule("\nrule", "\nend", rulePartition));
+        //a query is really just a rule for most purposes.
+        rules.add(new MultiLineRule("\nquery", "\nend", rulePartition));
+
+        // comments
+        IToken comment = new Token(RULE_COMMENT);
+        rules.add( new MultiLineRule("/*", "*/", comment, (char) 0, true));
+
+        setPredicateRules((IPredicateRule[]) rules.toArray(new IPredicateRule[rules.size()]));
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLScanner.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLScanner.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/DRLScanner.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,92 @@
+package org.drools.eclipse.editors.scanners;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.editors.ColorManager;
+import org.drools.eclipse.editors.Keywords;
+import org.eclipse.jface.text.TextAttribute;
+import org.eclipse.jface.text.rules.EndOfLineRule;
+import org.eclipse.jface.text.rules.IRule;
+import org.eclipse.jface.text.rules.IToken;
+import org.eclipse.jface.text.rules.RuleBasedScanner;
+import org.eclipse.jface.text.rules.SingleLineRule;
+import org.eclipse.jface.text.rules.Token;
+import org.eclipse.jface.text.rules.WhitespaceRule;
+import org.eclipse.jface.text.rules.WordRule;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+
+
+
+/**
+ * Basic keyword scanner for syntax highlighting.
+ *
+ * @author Michael Neale
+ */
+public class DRLScanner extends RuleBasedScanner {
+
+	private static final Color KEYWORD_COLOR = ColorManager.getInstance().getColor(ColorManager.KEYWORD);
+	private static final Color COMMENT_COLOR = ColorManager.getInstance().getColor(ColorManager.SINGLE_LINE_COMMENT);
+    private static final Color STRING_COLOR = ColorManager.getInstance().getColor(ColorManager.STRING);
+
+    private static final String[] DROOLS_KEYWORDS = Keywords.getInstance().getAllDroolsKeywords();
+    private static final String[] JAVA_KEYWORDS = Keywords.getInstance().getAllJavaKeywords();
+    private static final String[] MVEL_KEYWORDS = Keywords.getInstance().getAllMvelKeywords();
+
+    private static final String[] JAVA_TYPES = { "void", "boolean", "char", "byte", "short", "strictfp", "int", "long", "float", "double" };
+
+    private static final String[] JAVA_CONSTANTS = { "false", "true", "null" };
+    private static final String[] MVEL_CONSTANTS = { "false", "true", "null", "nil", "empty", "this"  };
+
+
+	public DRLScanner() {
+
+		IToken keyword = new Token(new TextAttribute(KEYWORD_COLOR, null, SWT.BOLD));
+		IToken comment= new Token(new TextAttribute(COMMENT_COLOR));
+		IToken string = new Token(new TextAttribute(STRING_COLOR));
+		IToken other = new Token(null);
+
+        List rules = new ArrayList();
+
+		rules.add(new EndOfLineRule("//", comment));
+        rules.add(new EndOfLineRule("#", comment));
+
+        // Add rule for strings and character constants.
+        rules.add(new SingleLineRule("\"", "\"", string, '\\'));
+        rules.add(new SingleLineRule("'", "'", string, '\\'));
+
+        //for unfilled "holes"
+        //rules.add(new SingleLineRule("{", "}", comment));
+
+        // Add generic whitespace rule.
+        rules.add(new WhitespaceRule(new WhitespaceDetector()));
+
+        // Add word rule for keywords, types, and constants.
+        WordRule wordRule= new WordRule(new RuleWordDetector(), other);
+        for (int i= 0; i < DROOLS_KEYWORDS.length; i++)
+            wordRule.addWord(DROOLS_KEYWORDS[i], keyword);
+
+        for (int i= 0; i < JAVA_KEYWORDS.length; i++)
+            wordRule.addWord(JAVA_KEYWORDS[i], keyword);
+        for (int i= 0; i < JAVA_TYPES.length; i++)
+            wordRule.addWord(JAVA_TYPES[i], keyword);
+        for (int i= 0; i < JAVA_CONSTANTS.length; i++)
+            wordRule.addWord(JAVA_CONSTANTS[i], keyword);
+
+        //FIXME: this a bit brutal. we should identify different highlighting for Java and Mvel
+        for (int i= 0; i < MVEL_KEYWORDS.length; i++)
+            wordRule.addWord(MVEL_KEYWORDS[i], keyword);
+        for (int i= 0; i < MVEL_CONSTANTS.length; i++)
+            wordRule.addWord(MVEL_CONSTANTS[i], keyword);
+
+
+        rules.add(wordRule);
+
+        IRule[] result= new IRule[rules.size()];
+        rules.toArray(result);
+
+		setRules(result);
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleEditorMessages.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleEditorMessages.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleEditorMessages.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,48 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2004 IBM Corporation and others.
+ * All rights reserved. This program and the accompanying materials 
+ * are made available under the terms of the Common Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/cpl-v10.html
+ * 
+ * Contributors:
+ *     IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.drools.eclipse.editors.scanners;
+
+import java.util.MissingResourceException;
+import java.util.ResourceBundle;
+
+public class RuleEditorMessages {
+
+    
+    
+	private static final String RESOURCE_BUNDLE= getLocation();
+    
+
+
+    
+	private static ResourceBundle fgResourceBundle= ResourceBundle.getBundle(RESOURCE_BUNDLE);
+
+	private RuleEditorMessages() {
+	}
+
+	public static String getString(String key) {
+        
+		try {
+			return fgResourceBundle.getString(key);
+		} catch (MissingResourceException e) {
+			return "!" + key + "!";//$NON-NLS-2$ //$NON-NLS-1$
+		}
+	}
+	
+	public static ResourceBundle getResourceBundle() {
+		return fgResourceBundle;
+	}
+
+    
+    private static String getLocation()  {
+        return RuleEditorMessages.class.getPackage().getName() + ".RuleEditorMessages";        
+    }    
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleWordDetector.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleWordDetector.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/RuleWordDetector.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,20 @@
+package org.drools.eclipse.editors.scanners;
+
+import org.eclipse.jface.text.rules.IWordDetector;
+
+public class RuleWordDetector implements IWordDetector {
+
+        /* (non-Javadoc)
+         * Method declared on IWordDetector.
+         */
+        public boolean isWordPart(char character) {            
+            return Character.isJavaIdentifierPart(character) || character == '-';
+        }
+        
+        /* (non-Javadoc)
+         * Method declared on IWordDetector.
+         */
+        public boolean isWordStart(char character) {
+            return Character.isJavaIdentifierStart(character);
+        }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/WhitespaceDetector.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/WhitespaceDetector.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/editors/scanners/WhitespaceDetector.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,17 @@
+package org.drools.eclipse.editors.scanners;
+
+import org.eclipse.jface.text.rules.IWhitespaceDetector;
+
+/**
+ * A rule aware white space detector.
+ */
+public class WhitespaceDetector implements IWhitespaceDetector {
+
+    /* (non-Javadoc)
+     * Method declared on IWhitespaceDetector
+     */
+    public boolean isWhitespace(char character) {
+        return Character.isWhitespace(character);
+    }
+}
+

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DataTypeRegistry.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DataTypeRegistry.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DataTypeRegistry.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,52 @@
+package org.drools.eclipse.flow.common.datatype;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Set;
+
+import org.drools.ruleflow.common.datatype.DataTypeFactory;
+
+/**
+ * A registry of datatypes.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataTypeRegistry {
+    
+	/**
+	 * Returns all registered data types.
+	 */
+    Set getDataTypes();
+    
+    void registerDataType(Class type, DataTypeFactory dataTypeFactory, String name,
+        Class valueEditorClass, Class dataTypeEditorClass);
+    
+    /**
+     * Returns the data type info of the data type with the given type
+     * @param type
+     * @return the data type info
+     * @throws IllegalArgumentException if the data type info of this type cannot be found
+     */
+    IDataTypeInfo getDataTypeInfo(Class type);
+    
+    interface IDataTypeInfo {
+        Class getType();
+        DataTypeFactory getDataTypeFactory();
+        String getName();
+        Class getDataTypeEditorClass();
+        Class getValueEditorClass();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DefaultDataTypeRegistry.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DefaultDataTypeRegistry.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/DefaultDataTypeRegistry.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,74 @@
+package org.drools.eclipse.flow.common.datatype;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.datatype.impl.DataTypeRegistryImpl;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.BooleanEditor;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.EmptyEditor;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.IntegerEditor;
+import org.drools.ruleflow.common.datatype.DataTypeFactory;
+import org.drools.ruleflow.common.datatype.impl.InstanceDataTypeFactory;
+import org.drools.ruleflow.common.datatype.impl.type.BooleanDataType;
+import org.drools.ruleflow.common.datatype.impl.type.FloatDataType;
+import org.drools.ruleflow.common.datatype.impl.type.IntegerDataType;
+import org.drools.ruleflow.common.datatype.impl.type.StringDataType;
+import org.drools.ruleflow.common.datatype.impl.type.UndefinedDataType;
+
+//import sun.beans.editors.FloatEditor;
+//import sun.beans.editors.StringEditor;
+
+/**
+ * Default datatype registry containing default datatypes.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DefaultDataTypeRegistry {
+
+	private static final DataTypeRegistry variableDataTypeRegistry = new DataTypeRegistryImpl();
+
+	private DefaultDataTypeRegistry() {
+	}
+
+	static {
+		registerVariableDataType(UndefinedDataType.class,
+				new InstanceDataTypeFactory(UndefinedDataType.class),
+				"Undefined", EmptyEditor.class, EmptyEditor.class);
+		registerVariableDataType(BooleanDataType.class,
+				new InstanceDataTypeFactory(BooleanDataType.class), "Boolean",
+				BooleanEditor.class, EmptyEditor.class);
+		registerVariableDataType(IntegerDataType.class,
+				new InstanceDataTypeFactory(IntegerDataType.class), "Integer",
+				IntegerEditor.class, EmptyEditor.class);
+//		registerVariableDataType(FloatDataType.class,
+//				new InstanceDataTypeFactory(FloatDataType.class), "Float",
+//				FloatEditor.class, EmptyEditor.class);
+//		registerVariableDataType(StringDataType.class,
+//				new InstanceDataTypeFactory(StringDataType.class), "String",
+//				StringEditor.class, EmptyEditor.class);
+	}
+
+	public static void registerVariableDataType(Class type,
+			DataTypeFactory dataTypeFactory, String name,
+			Class valueEditorClass, Class dataTypeEditorClass) {
+		variableDataTypeRegistry.registerDataType(type, dataTypeFactory, name,
+				valueEditorClass, dataTypeEditorClass);
+	}
+
+	public static DataTypeRegistry getInstance() {
+		return variableDataTypeRegistry;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/impl/DataTypeRegistryImpl.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/impl/DataTypeRegistryImpl.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/datatype/impl/DataTypeRegistryImpl.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,95 @@
+package org.drools.eclipse.flow.common.datatype.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
+
+import org.drools.eclipse.flow.common.datatype.DataTypeRegistry;
+import org.drools.ruleflow.common.datatype.DataTypeFactory;
+
+/**
+ * Default implementation of a datatype registry.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DataTypeRegistryImpl implements DataTypeRegistry {
+
+    private Map dataTypes = new HashMap();
+    
+    public Set getDataTypes() {
+        return new HashSet(dataTypes.values());
+    }
+
+    public void registerDataType(Class type, DataTypeFactory dataTypeFactory, String name,
+            Class valueEditorClass, Class dataTypeEditorClass) {
+        if (dataTypeFactory == null) {
+            throw new NullPointerException("Data type factory may not be null");
+        }
+        if (name == null) {
+            throw new NullPointerException("Name may not be null");
+        }
+        if (valueEditorClass == null) {
+            throw new NullPointerException("valueEditorClass may not be null");
+        }
+        if (dataTypeEditorClass == null) {
+            throw new NullPointerException("dataTypeEditorClass may not be null");
+        }
+        dataTypes.put(type, new DataTypeInfo(
+            type, dataTypeFactory, name, valueEditorClass, dataTypeEditorClass));
+    }
+    
+    public IDataTypeInfo getDataTypeInfo(Class type) {
+        IDataTypeInfo dataTypeInfo = (IDataTypeInfo) dataTypes.get(type);
+        if (dataTypeInfo == null) {
+            throw new IllegalArgumentException("Cannot find data type info with type " + type);
+        }
+        return dataTypeInfo;
+    }
+    
+    public class DataTypeInfo implements IDataTypeInfo {
+        private Class type;
+        private DataTypeFactory dataTypeFactory;
+        private String name;
+        private Class valueEditorClass;
+        private Class dataTypeEditorClass;
+        private DataTypeInfo(Class type, DataTypeFactory dataTypeFactory, String name,
+                Class valueEditorClass, Class dataTypeEditorClass) {
+            this.type = type;
+            this.dataTypeFactory = dataTypeFactory;
+            this.name = name;
+            this.valueEditorClass = valueEditorClass;
+            this.dataTypeEditorClass = dataTypeEditorClass;
+        }
+        public Class getType() {
+            return type;
+        }
+        public DataTypeFactory getDataTypeFactory() {
+            return dataTypeFactory;
+        }
+        public String getName() {
+            return name;
+        }
+        public Class getValueEditorClass() {
+            return valueEditorClass;
+        }
+        public Class getDataTypeEditorClass() {
+            return dataTypeEditorClass;
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/DropDownMenuWithDefaultAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/DropDownMenuWithDefaultAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/DropDownMenuWithDefaultAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,159 @@
+package org.drools.eclipse.flow.common.editor;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.ActionContributionItem;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IContributionItem;
+import org.eclipse.jface.action.IMenuCreator;
+import org.eclipse.jface.util.IPropertyChangeListener;
+import org.eclipse.jface.util.PropertyChangeEvent;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+
+public class DropDownMenuWithDefaultAction extends Action
+    implements
+    IMenuCreator {
+
+    private Menu                    dropDownMenu;
+
+    private IAction                 delegate;
+
+    private List                    list;
+
+    private IPropertyChangeListener enabledListener;
+    private SelectionListener       selectionListener;
+
+    public DropDownMenuWithDefaultAction(final IAction action) {
+        this.selectionListener = new ItemSelectionListener( this );
+        setMenuCreator( this );
+        this.dropDownMenu = null;
+        setAction( action );
+        this.list = new ArrayList();
+    }
+
+    public void dispose() {
+        if ( this.dropDownMenu != null ) {
+            this.dropDownMenu.dispose();
+            this.dropDownMenu = null;
+        }
+    }
+
+    public void add(final IContributionItem item) {
+        this.list.add( item );
+    }
+
+    public void add(final IAction action) {
+        this.list.add( action );
+    }
+
+    public Menu getMenu(final Control parent) {
+        if ( this.dropDownMenu == null ) {
+            this.dropDownMenu = new Menu( parent );
+            populateMenu();
+        }
+        return this.dropDownMenu;
+    }
+
+    public Menu getMenu(final Menu parent) {
+        if ( this.dropDownMenu == null ) {
+            this.dropDownMenu = new Menu( parent );
+            populateMenu();
+        }
+        return this.dropDownMenu;
+    }
+
+    private void populateMenu() {
+        for ( final Iterator it = this.list.iterator(); it.hasNext(); ) {
+            final Object object = it.next();
+            if ( object instanceof IContributionItem ) {
+                final IContributionItem item = (IContributionItem) object;
+                item.fill( this.dropDownMenu,
+                           -1 );
+            } else {
+                final IAction action = (IAction) object;
+                final ActionContributionItem item = new ActionContributionItem( action );
+                item.fill( this.dropDownMenu,
+                           -1 );
+            }
+        }
+        final MenuItem[] items = this.dropDownMenu.getItems();
+        for ( int i = 0; i < items.length; i++ ) {
+            items[i].addSelectionListener( this.selectionListener );
+        }
+    }
+
+    public void setAction(final IAction action) {
+        if ( this.enabledListener == null ) {
+            this.enabledListener = new EnabledPropertyChangeListener( this );
+        }
+        setText( action.getText() );
+        setToolTipText( action.getToolTipText() );
+        setImageDescriptor( action.getImageDescriptor() );
+        setDisabledImageDescriptor( action.getDisabledImageDescriptor() );
+        setEnabled( action.isEnabled() );
+        setDescription( action.getDescription() );
+        setHelpListener( action.getHelpListener() );
+        setHoverImageDescriptor( action.getHoverImageDescriptor() );
+        if ( this.delegate != null ) {
+            this.delegate.removePropertyChangeListener( this.enabledListener );
+        }
+        this.delegate = action;
+        this.delegate.addPropertyChangeListener( this.enabledListener );
+    }
+
+    /* (non-Javadoc)
+     * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+     */
+    public void run() {
+        this.delegate.run();
+    }
+
+    public static class EnabledPropertyChangeListener
+        implements
+        IPropertyChangeListener {
+        private IAction action;
+
+        public EnabledPropertyChangeListener(final IAction action) {
+            this.action = action;
+        }
+
+        public void propertyChange(final PropertyChangeEvent event) {
+            if ( event.getProperty().equals( IAction.ENABLED ) ) {
+                this.action.setEnabled( ((Boolean) event.getNewValue()).booleanValue() );
+            }
+        }
+    }
+
+    public static class ItemSelectionListener
+        implements
+        SelectionListener {
+        private DropDownMenuWithDefaultAction dropDownMenu;
+
+        public ItemSelectionListener(final DropDownMenuWithDefaultAction dropDownMenu) {
+            this.dropDownMenu = dropDownMenu;
+        }
+
+        public void widgetDefaultSelected(final SelectionEvent e) {
+            final MenuItem menuItem = (MenuItem) e.getSource();
+            if ( menuItem.getData() instanceof ActionContributionItem ) {
+                final ActionContributionItem item = (ActionContributionItem) menuItem.getData();
+                this.dropDownMenu.setAction( item.getAction() );
+            }
+        }
+
+        public void widgetSelected(final SelectionEvent e) {
+            final MenuItem menuItem = (MenuItem) e.getSource();
+            if ( menuItem.getData() instanceof ActionContributionItem ) {
+                final ActionContributionItem item = (ActionContributionItem) menuItem.getData();
+                this.dropDownMenu.setAction( item.getAction() );
+            }
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericActionBarContributor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericActionBarContributor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericActionBarContributor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,83 @@
+package org.drools.eclipse.flow.common.editor;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.ui.actions.ActionBarContributor;
+import org.eclipse.gef.ui.actions.AlignmentRetargetAction;
+import org.eclipse.gef.ui.actions.DeleteRetargetAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.RedoRetargetAction;
+import org.eclipse.gef.ui.actions.UndoRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.gef.ui.actions.ZoomInRetargetAction;
+import org.eclipse.gef.ui.actions.ZoomOutRetargetAction;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.Separator;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.RetargetAction;
+
+/**
+ * Common implementation of a ActionBarContributor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class GenericActionBarContributor extends ActionBarContributor {
+
+    protected void buildActions() {
+        addRetargetAction( new UndoRetargetAction() );
+        addRetargetAction( new RedoRetargetAction() );
+        addRetargetAction( new DeleteRetargetAction() );
+
+    	addRetargetAction( new ZoomInRetargetAction() );
+    	addRetargetAction( new ZoomOutRetargetAction() );
+    	
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.LEFT ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.CENTER ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.RIGHT ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.TOP ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.MIDDLE ) );
+        addRetargetAction( new AlignmentRetargetAction( PositionConstants.BOTTOM ) );
+        
+    	addRetargetAction( new RetargetAction(
+			GEFActionConstants.TOGGLE_GRID_VISIBILITY, "Grid" ));
+    }
+
+    public void contributeToToolBar(IToolBarManager toolBarManager) {
+        toolBarManager.add( getAction( ActionFactory.UNDO.getId() ) );
+        toolBarManager.add( getAction( ActionFactory.REDO.getId() ) );
+        toolBarManager.add( new Separator() );
+        toolBarManager.add( new ZoomComboContributionItem( getPage() ) );
+        toolBarManager.add( new Separator() );                              
+        
+        DropDownMenuWithDefaultAction alignMenu = new DropDownMenuWithDefaultAction( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_LEFT ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_CENTER ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_RIGHT ) );
+        alignMenu.add( new Separator() );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_TOP ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_MIDDLE ) );
+        alignMenu.add( getActionRegistry().getAction( GEFActionConstants.ALIGN_BOTTOM ) );
+        toolBarManager.add( alignMenu );
+        
+        toolBarManager.add( new Separator() );                              
+        toolBarManager.add( getAction(GEFActionConstants.TOGGLE_GRID_VISIBILITY) );
+    }
+    
+    protected void declareGlobalActionKeys() {
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericContextMenuProvider.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericContextMenuProvider.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericContextMenuProvider.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,65 @@
+package org.drools.eclipse.flow.common.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.GraphicalViewer;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.ui.actions.ActionFactory;
+
+/**
+ * Common implementation of a ContextMenuProvider.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class GenericContextMenuProvider extends ContextMenuProvider {
+
+	private ActionRegistry actionRegistry;
+
+	public GenericContextMenuProvider(GraphicalViewer viewer,
+			ActionRegistry registry) {
+		super(viewer);
+		setActionRegistry(registry);
+	}
+
+	public void buildContextMenu(IMenuManager menu) {
+		GEFActionConstants.addStandardActionGroups(menu);
+
+		IAction action = getActionRegistry().getAction(
+				ActionFactory.UNDO.getId());
+		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+
+		action = getActionRegistry().getAction(ActionFactory.REDO.getId());
+		menu.appendToGroup(GEFActionConstants.GROUP_UNDO, action);
+
+		action = getActionRegistry().getAction(ActionFactory.DELETE.getId());
+		if (action.isEnabled()) {
+			menu.appendToGroup(GEFActionConstants.GROUP_EDIT, action);
+		}
+	}
+
+	private ActionRegistry getActionRegistry() {
+		return actionRegistry;
+	}
+
+	public void setActionRegistry(ActionRegistry registry) {
+		actionRegistry = registry;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,311 @@
+package org.drools.eclipse.flow.common.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectOutputStream;
+import java.io.OutputStream;
+import java.util.EventObject;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.PositionConstants;
+import org.eclipse.gef.ContextMenuProvider;
+import org.eclipse.gef.DefaultEditDomain;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.KeyHandler;
+import org.eclipse.gef.KeyStroke;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.gef.editparts.ZoomManager;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.ui.actions.ActionRegistry;
+import org.eclipse.gef.ui.actions.AlignmentAction;
+import org.eclipse.gef.ui.actions.DirectEditAction;
+import org.eclipse.gef.ui.actions.GEFActionConstants;
+import org.eclipse.gef.ui.actions.ToggleGridAction;
+import org.eclipse.gef.ui.parts.GraphicalEditorWithPalette;
+import org.eclipse.gef.ui.parts.GraphicalViewerKeyHandler;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbenchPart;
+import org.eclipse.ui.actions.ActionFactory;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.SaveAsDialog;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Abstract implementation of a graphical editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class GenericModelEditor extends GraphicalEditorWithPalette {
+
+	private Object model;
+	private boolean savePreviouslyNeeded = false;
+	private KeyHandler sharedKeyHandler;
+	private PaletteRoot root;
+	private OverviewOutlinePage overviewOutlinePage;
+
+	public GenericModelEditor() {
+		setEditDomain(new DefaultEditDomain(this));
+	}
+
+	protected void setModel(Object model) {
+		this.model = model;
+	}
+
+	protected Object getModel() {
+		return model;
+	}
+
+	protected void createActions() {
+		super.createActions();
+		ActionRegistry registry = getActionRegistry();
+
+		IAction action = new DirectEditAction((IWorkbenchPart) this);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.LEFT);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.CENTER);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.RIGHT);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.TOP);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.MIDDLE);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+
+		action = new AlignmentAction((IWorkbenchPart) this,
+				PositionConstants.BOTTOM);
+		registry.registerAction(action);
+		getSelectionActions().add(action.getId());
+	}
+
+	public void commandStackChanged(EventObject event) {
+		if (isDirty()) {
+			if (!savePreviouslyNeeded()) {
+				setSavePreviouslyNeeded(true);
+				firePropertyChange(IEditorPart.PROP_DIRTY);
+			}
+		} else {
+			setSavePreviouslyNeeded(false);
+			firePropertyChange(IEditorPart.PROP_DIRTY);
+		}
+		super.commandStackChanged(event);
+	}
+
+	protected void createOutputStream(OutputStream os) throws IOException {
+		ObjectOutputStream out = new ObjectOutputStream(os);
+		out.writeObject(model);
+		out.close();
+	}
+
+	protected void configureGraphicalViewer() {
+		super.configureGraphicalViewer();
+		getGraphicalViewer().setRootEditPart(new ScalableRootEditPart());
+		getGraphicalViewer().setEditPartFactory(createEditPartFactory());
+		getGraphicalViewer().setKeyHandler(
+				new GraphicalViewerKeyHandler(getGraphicalViewer())
+						.setParent(getCommonKeyHandler()));
+
+		IAction showGrid = new ToggleGridAction(getGraphicalViewer());
+		getActionRegistry().registerAction(showGrid);
+
+		ContextMenuProvider provider = new GenericContextMenuProvider(
+				getGraphicalViewer(), getActionRegistry());
+		getGraphicalViewer().setContextMenu(provider);
+		getSite().registerContextMenu("org.drools.eclipse.flow.editor.contextmenu",
+				provider, getGraphicalViewer());
+	}
+	
+	protected abstract EditPartFactory createEditPartFactory();
+
+	protected void initializeGraphicalViewer() {
+		getGraphicalViewer().setContents(model);
+	}
+
+	public void doSave(IProgressMonitor monitor) {
+		try {
+			ByteArrayOutputStream out = new ByteArrayOutputStream();
+			createOutputStream(out);
+			IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+			file.setContents(new ByteArrayInputStream(out.toByteArray()), true,
+					false, monitor);
+			out.close();
+			getCommandStack().markSaveLocation();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	public void doSaveAs() {
+		SaveAsDialog dialog = new SaveAsDialog(getSite().getWorkbenchWindow()
+				.getShell());
+		dialog.setOriginalFile(((IFileEditorInput) getEditorInput()).getFile());
+		dialog.open();
+		IPath path = dialog.getResult();
+
+		if (path == null) {
+			return;
+		}
+
+		IWorkspace workspace = ResourcesPlugin.getWorkspace();
+		final IFile file = workspace.getRoot().getFile(path);
+
+		WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+			public void execute(final IProgressMonitor monitor)
+					throws CoreException {
+				try {
+					ByteArrayOutputStream out = new ByteArrayOutputStream();
+					createOutputStream(out);
+					file.create(new ByteArrayInputStream(out.toByteArray()),
+							true, monitor);
+					out.close();
+				} catch (Exception e) {
+					e.printStackTrace();
+				}
+			}
+		};
+
+		try {
+			new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
+					.run(false, true, op);
+			setInput(new FileEditorInput(file));
+			getCommandStack().markSaveLocation();
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+	}
+
+	protected KeyHandler getCommonKeyHandler() {
+		if (sharedKeyHandler == null) {
+			sharedKeyHandler = new KeyHandler();
+			sharedKeyHandler
+					.put(KeyStroke.getPressed(SWT.DEL, 127, 0),
+							getActionRegistry().getAction(
+									ActionFactory.DELETE.getId()));
+			sharedKeyHandler.put(KeyStroke.getPressed(SWT.F2, 0),
+					getActionRegistry().getAction(
+							GEFActionConstants.DIRECT_EDIT));
+		}
+		return sharedKeyHandler;
+	}
+
+	public boolean isDirty() {
+		return isSaveOnCloseNeeded();
+	}
+
+	public boolean isSaveAsAllowed() {
+		return true;
+	}
+
+	public boolean isSaveOnCloseNeeded() {
+		return getCommandStack().isDirty();
+	}
+
+	private boolean savePreviouslyNeeded() {
+		return savePreviouslyNeeded;
+	}
+
+	private void setSavePreviouslyNeeded(boolean value) {
+		savePreviouslyNeeded = value;
+	}
+
+	protected PaletteRoot getPaletteRoot() {
+		if (root == null) {
+			root = createPalette();
+		}
+		return root;
+	}
+
+	protected abstract PaletteRoot createPalette();
+
+	protected void setInput(IEditorInput input) {
+		super.setInput(input);
+
+		IFile file = ((IFileEditorInput) input).getFile();
+		setPartName(file.getName());
+		try {
+			InputStream is = file.getContents(false);
+			createInputStream(is);
+		} catch (Exception e) {
+			DroolsEclipsePlugin.log(e);
+			model = createModel();
+		}
+		if (getGraphicalViewer() != null) {
+			initializeGraphicalViewer();
+		}
+	}
+
+	protected void createInputStream(InputStream is) throws Exception {
+		ObjectInputStream ois = new ObjectInputStreamWithLoader(is, getClass()
+				.getClassLoader());
+		model = ois.readObject();
+		ois.close();
+	}
+
+	protected abstract Object createModel();
+
+	public Object getAdapter(Class type) {
+		if (type == IContentOutlinePage.class) {
+			return getOverviewOutlinePage();
+		}
+		if (type == ZoomManager.class) {
+			return ((ScalableRootEditPart) getGraphicalViewer()
+					.getRootEditPart()).getZoomManager();
+		}
+		return super.getAdapter(type);
+	}
+
+	protected OverviewOutlinePage getOverviewOutlinePage() {
+		if (null == overviewOutlinePage && null != getGraphicalViewer()) {
+			ScalableRootEditPart rootEditPart = (ScalableRootEditPart) getGraphicalViewer()
+					.getRootEditPart();
+			overviewOutlinePage = new OverviewOutlinePage(rootEditPart);
+		}
+		return overviewOutlinePage;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/ObjectInputStreamWithLoader.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/ObjectInputStreamWithLoader.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/ObjectInputStreamWithLoader.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,92 @@
+package org.drools.eclipse.flow.common.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.ObjectInputStream;
+import java.io.ObjectStreamClass;
+import java.io.StreamCorruptedException;
+import java.lang.reflect.Array;
+
+/**
+ * Implementation of an ObjectInputStream that has a custom classloader.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ObjectInputStreamWithLoader extends ObjectInputStream {
+
+    private ClassLoader loader;
+
+    /**
+     * Loader must be non-null;
+     */
+    public ObjectInputStreamWithLoader(InputStream in, ClassLoader loader)
+            throws IOException, StreamCorruptedException {
+        super(in);
+        if (loader == null) {
+            throw new IllegalArgumentException("Illegal null argument to ObjectInputStreamWithLoader");
+        }
+        this.loader = loader;
+    }
+
+    /**
+     * Make a primitive array class
+     */
+    private Class primitiveType(char type) {
+        switch (type) {
+            case 'B': return byte.class;
+            case 'C': return char.class;
+            case 'D': return double.class;
+            case 'F': return float.class;
+            case 'I': return int.class;
+            case 'J': return long.class;
+            case 'S': return short.class;
+            case 'Z': return boolean.class;
+            default: return null;
+        }
+    }
+
+    /**
+     * Use the given ClassLoader rather than using the system class
+     */
+    protected Class resolveClass(ObjectStreamClass classDesc)
+            throws IOException, ClassNotFoundException {
+        String cname = classDesc.getName();
+        if (cname.startsWith("[")) {
+            // An array
+            Class component = null;        // component class
+            int dcount;         // dimension
+            for (dcount=1; cname.charAt(dcount)=='['; dcount++);
+            if (cname.charAt(dcount) == 'L') {
+                String className = cname.substring(dcount+1, cname.length()-1);
+                component = loader.loadClass(className);
+            } else {
+                if (cname.length() != dcount + 1) {
+                    throw new ClassNotFoundException(cname);// malformed
+                }
+                component = primitiveType(cname.charAt(dcount));
+            }
+            int dim[] = new int[dcount];
+            for (int i = 0; i < dcount; i++) {
+                dim[i]=0;
+            }
+            return Array.newInstance(component, dim).getClass();
+        }
+        return loader.loadClass(cname);
+    }
+}
+

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/OverviewOutlinePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/OverviewOutlinePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/OverviewOutlinePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,90 @@
+package org.drools.eclipse.flow.common.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.LightweightSystem;
+import org.eclipse.draw2d.MarginBorder;
+import org.eclipse.draw2d.Viewport;
+import org.eclipse.draw2d.parts.ScrollableThumbnail;
+import org.eclipse.draw2d.parts.Thumbnail;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.editparts.ScalableRootEditPart;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Canvas;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.part.Page;
+import org.eclipse.ui.views.contentoutline.IContentOutlinePage;
+
+/**
+ * Common implementation of an outline page.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class OverviewOutlinePage extends Page implements IContentOutlinePage {
+
+	private Canvas overview;
+	private ScalableRootEditPart rootEditPart;
+	private Thumbnail thumbnail;
+
+	public OverviewOutlinePage(ScalableRootEditPart rootEditPart) {
+		this.rootEditPart = rootEditPart;
+	}
+
+	public void addSelectionChangedListener(ISelectionChangedListener listener) {
+	}
+
+	public void createControl(Composite parent) {
+		overview = new Canvas(parent, SWT.NONE);
+		LightweightSystem lws = new LightweightSystem(overview);
+		thumbnail = new ScrollableThumbnail((Viewport) rootEditPart.getFigure());
+		thumbnail.setBorder(new MarginBorder(3));
+		thumbnail.setSource(rootEditPart
+				.getLayer(LayerConstants.PRINTABLE_LAYERS));
+		lws.setContents(thumbnail);
+	}
+
+	public void dispose() {
+		if (null != thumbnail) {
+			thumbnail.deactivate();
+		}
+		super.dispose();
+	}
+
+	public Control getControl() {
+		return overview;
+	}
+
+	public ISelection getSelection() {
+		return StructuredSelection.EMPTY;
+	}
+
+	public void removeSelectionChangedListener(
+			ISelectionChangedListener listener) {
+	}
+
+	public void setFocus() {
+		if (getControl() != null) {
+			getControl().setFocus();
+		}
+	}
+
+	public void setSelection(ISelection selection) {
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/DefaultElementWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/DefaultElementWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/DefaultElementWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,205 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Default wrapper of a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class DefaultElementWrapper implements IPropertySource, ElementWrapper, Serializable {
+
+    protected static IPropertyDescriptor[] descriptors;
+
+    public static final String NAME = "Name";
+    static {
+        descriptors = new IPropertyDescriptor[] {
+            new TextPropertyDescriptor(NAME, "Name"),
+        };
+    }
+    
+    private Object element;
+    private Rectangle constraint;
+    private ProcessWrapper parent;
+    private List incomingConnections = new ArrayList();
+    private List outgoingConnections = new ArrayList();
+    private transient List listeners = new ArrayList();
+    
+    protected void setElement(Object element) {
+		this.element = element;
+	}
+
+	public Object getElement() {
+		return element;
+	}
+
+	public void setConstraint(Rectangle constraint) {
+		this.constraint = constraint;
+		notifyListeners(CHANGE_CONSTRAINT);
+	}
+
+	public Rectangle getConstraint() {
+		return constraint;
+	}
+
+	public void setParent(ProcessWrapper parent) {
+		this.parent = parent;
+	}
+
+	protected ProcessWrapper getParent() {
+		return parent;
+	}
+
+	public List getOutgoingConnections() {
+		return Collections.unmodifiableList(outgoingConnections);
+	}
+
+	public List getIncomingConnections() {
+		return Collections.unmodifiableList(incomingConnections);
+	}
+
+	public void addIncomingConnection(ElementConnection connection) {
+		incomingConnections.add(connection);
+		internalAddIncomingConnection(connection);
+		notifyListeners(CHANGE_INCOMING_CONNECTIONS);
+	}
+
+	protected void internalAddIncomingConnection(ElementConnection connection) {
+	}
+
+	public void removeIncomingConnection(ElementConnection connection) {
+		incomingConnections.remove(connection);
+		internalRemoveIncomingConnection(connection);
+		notifyListeners(CHANGE_INCOMING_CONNECTIONS);
+	}
+
+	protected void internalRemoveIncomingConnection(ElementConnection connection) {
+	}
+
+	public void addOutgoingConnection(ElementConnection connection) {
+		outgoingConnections.add(connection);
+		internalAddOutgoingConnection(connection);
+		notifyListeners(CHANGE_OUTGOING_CONNECTIONS);
+	}
+
+	protected void internalAddOutgoingConnection(ElementConnection connection) {
+	}
+
+	public void removeOutgoingConnection(ElementConnection connection) {
+		outgoingConnections.remove(connection);
+		internalRemoveOutgoingConnection(connection);
+		notifyListeners(CHANGE_OUTGOING_CONNECTIONS);
+	}
+
+	protected void internalRemoveOutgoingConnection(ElementConnection connection) {
+	}
+
+	public void setName(String name) {
+		internalSetName(name);
+		notifyListeners(CHANGE_NAME);
+	}
+
+	protected void internalSetName(String name) {
+	}
+
+	public List getOutgoingConnections(int type) {
+		List result = new ArrayList();
+		for (Iterator it = outgoingConnections.iterator(); it.hasNext();) {
+			ElementConnection connection = (ElementConnection) it.next();
+			if (connection.getType() == type) {
+				result.add(connection);
+			}
+		}
+		return Collections.unmodifiableList(result);
+	}
+
+	public List getIncomingConnections(int type) {
+		List result = new ArrayList();
+		for (Iterator it = incomingConnections.iterator(); it.hasNext();) {
+			ElementConnection connection = (ElementConnection) it.next();
+			if (connection.getType() == type) {
+				result.add(connection);
+			}
+		}
+		return Collections.unmodifiableList(result);
+	}
+
+	public void addListener(ModelListener listener) {
+		listeners.add(listener);
+	}
+
+	public void removeListener(ModelListener listener) {
+		listeners.remove(listener);
+	}
+
+	protected void notifyListeners(int change) {
+		ModelEvent event = new ModelEvent(change);
+		for (Iterator it = listeners.iterator(); it.hasNext();) {
+			ModelListener listener = (ModelListener) it.next();
+			listener.modelChanged(event);
+		}
+	}
+
+	private void readObject(ObjectInputStream aInputStream)
+			throws ClassNotFoundException, IOException {
+		aInputStream.defaultReadObject();
+		listeners = new ArrayList();
+	}
+
+	public IPropertyDescriptor[] getPropertyDescriptors() {
+		return descriptors;
+	}
+
+	public Object getEditableValue() {
+		return this;
+	}
+
+	public boolean isPropertySet(Object id) {
+		return true;
+	}
+
+	public Object getPropertyValue(Object id) {
+		if (NAME.equals(id)) {
+			return getName();
+		}
+		return null;
+	}
+
+	public void resetPropertyValue(Object id) {
+		if (NAME.equals(id)) {
+			setName("");
+		}
+	}
+
+	public void setPropertyValue(Object id, Object value) {
+		if (NAME.equals(id)) {
+			setName((String) value);
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnection.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,146 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Point;
+
+/**
+ * A connection between two model elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementConnection implements Serializable {
+    
+	private static final long serialVersionUID = 400L;
+	
+	public static final int CHANGE_BENDPOINTS = 1;
+	
+	private ElementWrapper source;
+    private ElementWrapper target;
+    private int type;
+    private List bendpoints = new ArrayList();
+    private transient List listeners = new ArrayList();
+    
+    public ElementConnection(int type) {
+        this.type = type;
+    }
+    
+    public ElementConnection(ElementWrapper source, ElementWrapper target, int type) {
+        this(type);
+        if (source == null) {
+        	throw new IllegalArgumentException("source is null");        	
+        }
+        if (target == null) {
+        	throw new IllegalArgumentException("target is null");
+        }
+    	this.source = source;
+        this.target = target;
+    }
+    
+    public void disconnect() {
+    	if (source == null) {
+    		throw new IllegalStateException("Can't disconnect, source is null");
+    	}
+    	if (target == null) {
+    		throw new IllegalStateException("Can't disconnect, target is null");
+    	}
+    	source.removeOutgoingConnection(this);
+    	target.removeIncomingConnection(this);
+    	source = null;
+    	target = null;
+    }
+    
+    public void connect(ElementWrapper source, ElementWrapper target) {
+    	if (source == null) {
+    		throw new IllegalArgumentException("source is null");
+    	}
+        if (this.source != null) {
+            throw new IllegalStateException("The source of a connection cannot be changed");
+        }
+        if (target == null) {
+    		throw new IllegalArgumentException("target is null");
+    	}
+        if (this.target != null) {
+            throw new IllegalStateException("The target of a connection cannot be changed");
+        }
+        this.source = source;
+        this.target = target;
+    	source.addOutgoingConnection(this);
+        target.addIncomingConnection(this);
+    }
+    
+    
+    public ElementWrapper getSource() {
+        return source;
+    }
+    
+    
+    public ElementWrapper getTarget() {
+        return target;
+    }
+
+    public int getType() {
+        return type;
+    }
+    
+    public void addBendpoint(int index, Point point) {
+        bendpoints.add(index, point);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+
+    public void removeBendpoint(int index) {
+        bendpoints.remove(index);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+
+    public void replaceBendpoint(int index, Point point) {
+        bendpoints.set(index, point);
+        notifyListeners(CHANGE_BENDPOINTS);
+    }
+
+    public List getBendpoints() {
+        return bendpoints;
+    }
+
+    public void addListener(ModelListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeListener(ModelListener listener) {
+        listeners.remove(listener);
+    }
+
+    protected void notifyListeners(int change) {
+        ModelEvent event = new ModelEvent(change);
+        for (Iterator it = listeners.iterator(); it.hasNext(); ) {
+        	ModelListener listener = (ModelListener) it.next();
+        	listener.modelChanged(event);
+        }
+    }
+
+    private void readObject(ObjectInputStream aInputStream)
+            throws ClassNotFoundException, IOException {
+        aInputStream.defaultReadObject();
+        listeners = new ArrayList();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnectionFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnectionFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementConnectionFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,39 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Factory for creating element connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementConnectionFactory {
+	
+	private int type;
+	
+	public ElementConnectionFactory(int type) {
+		this.type = type;
+	}
+	
+	public ElementConnection createElementConnection() {
+		ElementConnection connection = new ElementConnection(type);
+		return connection;
+	}
+	
+	protected int getType() {
+		return this.type;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ElementWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,57 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.eclipse.draw2d.geometry.Rectangle;
+
+/**
+ * Wrapper of a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ElementWrapper {
+	
+	static final int CHANGE_INCOMING_CONNECTIONS = 1;
+	static final int CHANGE_OUTGOING_CONNECTIONS = 2;
+	static final int CHANGE_CONSTRAINT = 3;
+	static final int CHANGE_NAME = 4;
+    
+    String getId();
+    String getName();
+    void setName(String name);
+    
+    void setConstraint(Rectangle constraint);
+    Rectangle getConstraint();
+    
+    void setParent(ProcessWrapper parent);
+    
+    List getOutgoingConnections();
+    List getIncomingConnections();
+    void addIncomingConnection(ElementConnection connection);
+    void removeIncomingConnection(ElementConnection connection);
+    void addOutgoingConnection(ElementConnection connection);
+    void removeOutgoingConnection(ElementConnection connection);
+    boolean acceptsIncomingConnection(ElementConnection connection);
+    boolean acceptsOutgoingConnection(ElementConnection connection);
+    List getOutgoingConnections(int type);
+    List getIncomingConnections(int type);
+    
+    void addListener(ModelListener listener);
+    void removeListener(ModelListener listener);
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelEvent.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelEvent.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelEvent.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,35 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * Event notifying a change in a model element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ModelEvent {
+	
+	private int change;
+    
+    public ModelEvent(int change) {
+        this.change = change;
+    }
+    
+    public int getChange() {
+        return change;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelListener.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelListener.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ModelListener.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,27 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * A listener for model events.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface ModelListener {
+
+    void modelChanged(ModelEvent event);
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ProcessWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ProcessWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/ProcessWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,234 @@
+package org.drools.eclipse.flow.common.editor.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.io.Serializable;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.ruleflow.common.core.Process;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertySource;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * A wrapper for process element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ProcessWrapper implements IPropertySource, Serializable {
+
+	public static final int CHANGE_ELEMENTS = 1;
+	public static final int CHANGE_ROUTER_LAYOUT = 2;
+
+    public static final Integer ROUTER_LAYOUT_MANUAL = new Integer(0);
+    public static final Integer ROUTER_LAYOUT_MANHATTAN = new Integer(1);
+    public static final Integer ROUTER_LAYOUT_SHORTEST_PATH = new Integer(2);
+
+    protected static IPropertyDescriptor[] descriptors;
+
+    public static final String NAME = "name";
+    public static final String VERSION = "version";
+    public static final String ID = "id";
+    public static final String PACKAGE_NAME = "packageName";
+    public static final String ROUTER_LAYOUT = "routerLayout";
+    
+    static {
+        descriptors = new IPropertyDescriptor[] {
+            new TextPropertyDescriptor(NAME, "Name"),
+            new TextPropertyDescriptor(VERSION, "Version"),
+            new TextPropertyDescriptor(ID, "Id"),
+            new TextPropertyDescriptor(PACKAGE_NAME, "Package"),
+            new ComboBoxPropertyDescriptor(ROUTER_LAYOUT, "Connection Layout", 
+                new String[] { "Manual", "Manhatten", "Shortest Path" }),
+        };
+    }
+    
+    private Process process;
+    private Map elements = new HashMap();
+    private Integer routerLayout;
+    private transient List listeners = new ArrayList();
+    
+    public ProcessWrapper() {
+        process = createProcess();
+    }
+
+    protected abstract Process createProcess();
+
+    public Process getProcess() {
+        return process;
+    }
+    
+    public String getName() {
+        return process.getName() == null ? "" : process.getName();
+    }
+    
+    public void setName(String name) {
+        process.setName(name);
+    }
+    
+    public String getVersion() {
+        return process.getVersion() == null ? "" : process.getVersion();
+    }
+    
+    public void setVersion(String version) {
+        process.setVersion(version);
+    }
+    
+    public String getId() {
+    	return process.getId();
+    }
+    
+    public void setId(String id) {
+    	process.setId(id);
+    }
+    
+    public String getPackageName() {
+        return process.getPackageName() == null ? "" : process.getPackageName();
+    }
+    
+    public void setPackageName(String packageName) {
+        process.setPackageName(packageName);
+    }
+    
+    public Integer getRouterLayout() {
+    	if (routerLayout == null) {
+    		routerLayout = ROUTER_LAYOUT_SHORTEST_PATH;
+    	}
+    	return routerLayout;
+    }
+    
+    public void setRouterLayout(Integer routerLayout) {
+    	this.routerLayout = routerLayout;
+    	notifyListeners(CHANGE_ROUTER_LAYOUT);
+    }
+    
+    public List getElements() {
+        return Collections.unmodifiableList(new ArrayList(elements.values()));
+    }
+    
+    public ElementWrapper getElement(String id) {
+        return (ElementWrapper) elements.get(id);
+    }
+    
+    public void addElement(ElementWrapper element) {
+        internalAddElement(element);
+		//id is set in methode above
+		elements.put(element.getId(), element);
+		notifyListeners(CHANGE_ELEMENTS);
+    }
+    
+    protected abstract void internalAddElement(ElementWrapper element);
+    
+    public void removeElement(ElementWrapper element) {
+        elements.remove(element.getId());
+        notifyListeners(CHANGE_ELEMENTS);
+        internalRemoveElement(element);
+    }
+    
+    protected abstract void internalRemoveElement(ElementWrapper element);
+    
+    public void addListener(ModelListener listener) {
+        listeners.add(listener);
+    }
+
+    public void removeListener(ModelListener listener) {
+        listeners.remove(listener);
+    }
+    
+    public void notifyListeners(int change) {
+        ModelEvent event = new ModelEvent(change);
+        for (Iterator it = listeners.iterator(); it.hasNext(); ) {
+        	ModelListener listener = (ModelListener) it.next();
+        	listener.modelChanged(event);
+        }
+    }
+    
+    private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException {
+        aInputStream.defaultReadObject();
+        listeners = new ArrayList();
+    }
+    
+    public Object getEditableValue() {
+        return this;
+    }
+
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    public Object getPropertyValue(Object id) {
+        if (NAME.equals(id)) {
+            return getName();
+        }
+        if (VERSION.equals(id)) {
+            return getVersion();
+        }
+        if (ID.equals(id)) {
+            return getId() + "";
+        }
+        if (PACKAGE_NAME.equals(id)) {
+            return getPackageName();
+        }
+        if (ROUTER_LAYOUT.equals(id)) {
+            return routerLayout;
+        }
+        return null;
+    }
+
+    public boolean isPropertySet(Object id) {
+        return true;
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (NAME.equals(id)) {
+            setName("");
+        }
+        if (VERSION.equals(id)) {
+            setVersion("");
+        }
+        if (ID.equals(id)) {
+            setId("");
+        }
+        if (PACKAGE_NAME.equals(id)) {
+            setPackageName("");
+        }
+        if (ROUTER_LAYOUT.equals(id)) {
+            setRouterLayout(null);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (NAME.equals(id)) {
+            setName((String) value);
+        } else if (VERSION.equals(id)) {
+            setVersion((String) value);
+        } else if (ID.equals(id)) {
+            setId((String) value);
+        } else if (PACKAGE_NAME.equals(id)) {
+            setPackageName((String) value);
+        } else if (ROUTER_LAYOUT.equals(id)) {
+            setRouterLayout((Integer) value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/AddElementCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/AddElementCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/AddElementCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,58 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for adding an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class AddElementCommand extends Command {
+
+    private ElementWrapper child;
+    private ProcessWrapper parent;
+
+    public void execute() {
+        parent.addElement(child);
+        child.setParent(parent);
+    }
+
+    protected ProcessWrapper getParent() {
+        return parent;
+    }
+    
+    protected ElementWrapper getChild() {
+        return child;
+    }
+
+    public void setChild(ElementWrapper newChild) {
+        child = newChild;
+    }
+
+    public void setParent(ProcessWrapper newParent) {
+        parent = newParent;
+    }
+
+    public void undo() {
+        parent.removeElement(child);
+        child.setParent(null);
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ChangeConstraintCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ChangeConstraintCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ChangeConstraintCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,49 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for changing a constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ChangeConstraintCommand extends Command {
+
+    private ElementWrapper element;
+    private Rectangle constraint;
+    private Rectangle oldConstraint;
+
+    public void execute() {
+        element.setConstraint(constraint);
+    }
+
+    public void setConstraint(Rectangle rect) {
+        constraint = rect;
+    }
+
+    public void setElement(ElementWrapper element) {
+        this.element = element;
+        oldConstraint = element.getConstraint();
+    }
+    
+    public void undo() {
+        element.setConstraint(oldConstraint);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/CreateBendpointCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/CreateBendpointCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/CreateBendpointCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,52 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for creating a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CreateBendpointCommand extends Command {
+
+    private ElementConnection connection;
+    private Point location;
+    private int index;
+
+    public void execute() {
+        connection.addBendpoint(index, location);
+    }
+
+    public void setConnection(Object model) {
+        connection = (ElementConnection) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void setLocation(Point point) {
+        location = point;
+    }
+
+    public void undo() {
+        connection.removeBendpoint(index);
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteBendpointCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteBendpointCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteBendpointCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,50 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+
+
+/**
+ * A command for deleting a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteBendpointCommand extends Command {
+
+    private ElementConnection connection;
+    private Point oldLocation;
+    private int index;
+
+    public void execute() {
+        oldLocation = (Point) connection.getBendpoints().get(index);
+        connection.removeBendpoint(index);
+    }
+
+    public void setConnectionModel(Object model) {
+        connection = (ElementConnection) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void undo() {
+        connection.addBendpoint(index, oldLocation);
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteConnectionCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteConnectionCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteConnectionCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,52 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for deleting a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteConnectionCommand extends Command {
+
+    private ElementWrapper source;
+    private ElementWrapper target;
+    private ElementConnection connection;
+
+    public void execute() {
+    	connection.disconnect();
+    }
+
+    public void setSource(ElementWrapper action) {
+        source = action;
+    }
+
+    public void setTarget(ElementWrapper action) {
+        target = action;
+    }
+
+    public void setAntecedentTaskConnection(ElementConnection connection) {
+        this.connection = connection;
+    }
+
+    public void undo() {
+    	connection.connect(source, target);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteElementCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteElementCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/DeleteElementCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,101 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for deleting an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DeleteElementCommand extends Command {
+
+    private ElementWrapper child;
+    private ProcessWrapper parent;
+    
+    private List incomingElementWrappers = new ArrayList();
+    private List outgoingElementWrappers = new ArrayList();
+    private List incomingConnections = new ArrayList();
+    private List outgoingConnections = new ArrayList();
+    
+    
+    private void deleteConnections(ElementWrapper element) {
+    	for (Iterator it = element.getIncomingConnections().iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		incomingElementWrappers.add(connection.getSource());
+    		incomingConnections.add(connection);
+    	}
+    	for (Iterator it = element.getOutgoingConnections().iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		outgoingElementWrappers.add(connection.getTarget());
+    		outgoingConnections.add(connection);
+    	} 
+    	for (Iterator it = incomingConnections.iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		connection.disconnect();
+    	}
+    	for (Iterator it = outgoingConnections.iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		connection.disconnect();
+    	}
+    }
+
+    public void execute() {
+        deleteConnections(child);
+        parent.removeElement(child);
+    }
+
+    private void restoreConnections() {
+    	int i = 0;
+    	for (Iterator it = incomingConnections.iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		connection.connect((ElementWrapper) incomingElementWrappers.get(i), child);
+    		i++;
+    	}
+    	i = 0;
+    	for (Iterator it = outgoingConnections.iterator(); it.hasNext(); ) {
+    		ElementConnection connection = (ElementConnection) it.next();
+    		connection.connect(child, (ElementWrapper) outgoingElementWrappers.get(i));
+    		i++;
+    	}
+    	incomingConnections.clear();
+    	incomingElementWrappers.clear();
+    	outgoingConnections.clear();
+    	outgoingElementWrappers.clear();
+    }
+    
+    public void setChild(ElementWrapper child) {
+        this.child = child;
+    }
+
+    public void setParent(ProcessWrapper parent) {
+        this.parent = parent;
+    }
+
+    public void undo() {
+        parent.addElement(child);
+        restoreConnections();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ElementConnectionCreateCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,87 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for creating an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementConnectionCreateCommand extends Command {
+
+	private ElementConnection connection;
+    private ElementWrapper source;
+    private ElementWrapper target;
+
+    public boolean canExecute() {
+        if (source.equals(target)) {
+            return false;
+        }
+        
+        // Check for existence of connection already
+        List connections = source.getOutgoingConnections(connection.getType());
+        for (Iterator it = connections.iterator(); it.hasNext(); ) {
+        	ElementConnection conn = (ElementConnection) it.next();
+            if (conn.getTarget().equals(target)) {
+            	return false;
+            }
+        }
+        return source.acceptsOutgoingConnection(connection)
+            && target != null && target.acceptsIncomingConnection(connection);
+    }
+
+    public void execute() {
+        connection.connect(source, target);
+    }
+
+    public ElementWrapper getSource() {
+        return source;
+    }
+
+    public ElementWrapper getTarget() {
+        return target;
+    }
+
+    
+
+    public void redo() {
+    	connection.connect(source, target);
+    }
+
+    public void setSource(ElementWrapper source) {
+    	this.source = source;
+    }
+
+    public void setConnection(ElementConnection connection) {
+        this.connection = connection;
+    }
+
+    public void setTarget(ElementWrapper target) {
+    	this.target = target;
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/MoveBendpointCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/MoveBendpointCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/MoveBendpointCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for moving a bendpoint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MoveBendpointCommand extends Command {
+
+    private ElementConnection connection;
+    private Point oldLocation, newLocation;
+    private int index;
+
+    public void execute() {
+        oldLocation = (Point) connection.getBendpoints().get(index);
+        connection.replaceBendpoint(index, newLocation);
+    }
+
+    public void setConnectionModel(Object model) {
+        connection = (ElementConnection) model;
+    }
+
+    public void setIndex(int i) {
+        index = i;
+    }
+
+    public void setNewLocation(Point point) {
+        newLocation = point;
+    }
+
+    public void undo() {
+        connection.replaceBendpoint(index, oldLocation);
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionSourceCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,75 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for reconnecting the source of a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ReconnectElementConnectionSourceCommand extends Command {
+
+	private ElementConnection connection;
+	private ElementWrapper target;
+	private ElementWrapper oldSource;
+	private ElementWrapper newSource;
+    
+    public boolean canExecute() {
+        if (connection.getTarget().equals(newSource))
+            return false;
+            
+        List connections = newSource.getOutgoingConnections(connection.getType()); 
+        for (int i = 0; i < connections.size(); i++) {
+            ElementConnection connection = ((ElementConnection)(connections.get(i)));
+            if (connection.getTarget().equals(target) && !connection.getSource().equals(oldSource))
+                return false;
+        }
+        return newSource.acceptsOutgoingConnection(connection); //XXX    
+    }
+
+    public void execute() {
+        if (newSource != null) {
+        	connection.disconnect();
+        	connection.connect(newSource, target); 
+        }
+    }
+
+    public void setSource(ElementWrapper source) {
+    	this.newSource = source;
+    }
+
+    public void setConnection(ElementConnection connection) {
+        this.connection = connection;
+        this.target = connection.getTarget();
+        this.oldSource = connection.getSource();
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    	connection.connect(oldSource, target);    	
+    }
+    
+    public void redo() {
+    	connection.disconnect();
+    	connection.connect(newSource, target);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/ReconnectElementConnectionTargetCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,77 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for reconnecting the target of a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ReconnectElementConnectionTargetCommand extends Command {
+
+    private ElementConnection connection;
+    private ElementWrapper oldTarget;
+    private ElementWrapper newTarget;
+    private ElementWrapper source;
+    
+    
+    public boolean canExecute() {
+        if (connection.getSource().equals(newTarget))
+            return false;
+            
+        List connections = newTarget.getIncomingConnections(connection.getType());
+        for (Iterator it = connections.iterator(); it.hasNext(); ) {
+        	ElementConnection connection = (ElementConnection) it.next();
+            if (connection.getSource().equals(source) && !connection.getTarget().equals(oldTarget))
+                return false;
+        }   
+        return newTarget.acceptsIncomingConnection(connection);    
+    }
+
+    public void execute() {
+        if (newTarget != null) {
+        	connection.disconnect();
+        	connection.connect(source, newTarget);    	
+        }
+    }
+
+    public void setTarget(ElementWrapper target) {
+        this.newTarget = target;
+    }
+
+    public void setConnection(ElementConnection connection) {
+        this.connection = connection;
+        this.source = connection.getSource();
+        this.oldTarget = connection.getTarget();
+    }
+
+    public void undo() {
+    	connection.disconnect();
+    	connection.connect(source, oldTarget);
+    }
+    
+    public void redo() {
+    	connection.disconnect();
+    	connection.connect(source, newTarget);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/RenameElementCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/RenameElementCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/RenameElementCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for renaming an element.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RenameElementCommand extends Command {
+
+    private ElementWrapper source;
+    private String name;
+    private String oldName;
+
+    public void execute() {
+        source.setName(name);
+    }
+
+    public void setName(String string) {
+        name = string;
+    }
+
+    public void setOldName(String string) {
+        oldName = string;
+    }
+
+    public void setSource(ElementWrapper action) {
+        source = action;
+    }
+
+    public void undo() {
+        source.setName(oldName);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/SplitConnectionCommand.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/SplitConnectionCommand.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/core/command/SplitConnectionCommand.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,87 @@
+package org.drools.eclipse.flow.common.editor.core.command;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.eclipse.gef.commands.Command;
+
+/**
+ * A command for splitting a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SplitConnectionCommand extends Command {
+
+    private ProcessWrapper parent;
+    private ElementWrapper oldSource;
+    private ElementWrapper oldTarget;
+    private ElementConnection oldConnection;
+    private ElementConnection secondConnection;    
+    private ElementWrapper newElement;
+    
+    public void setNewSecondConnection(ElementConnection connection) {
+    	if (connection == null) {
+    		throw new IllegalArgumentException("new second connection cannot be null");
+    	}
+    	this.secondConnection = connection;
+    }
+    
+    public void execute() {
+    	if (secondConnection == null) {
+    		throw new IllegalStateException("new second connection is still null");
+    	}
+    	oldConnection.disconnect();
+    	parent.addElement(newElement);
+        newElement.setParent(parent);
+    	oldConnection.connect(oldSource, newElement);
+    	secondConnection.connect(newElement, oldTarget);
+    }
+
+    public void setParent(ProcessWrapper process) {
+    	if (process == null) {
+    		throw new IllegalArgumentException("process is null");
+    	}
+        parent = process;
+    }
+
+    public void setElementConnection(ElementConnection connection) {
+    	if (connection == null) {
+    		throw new IllegalArgumentException("Element connection is null");
+    	}
+        this.oldConnection = connection;
+        oldSource = connection.getSource();
+        oldTarget = connection.getTarget();
+    }
+
+    public void setNewElement(ElementWrapper newElement) {
+    	if (newElement == null) {
+    		throw new IllegalArgumentException("NewElement is null");
+    	}
+        this.newElement = newElement;
+        
+    }
+
+    public void undo() {
+    	oldConnection.disconnect();
+    	secondConnection.disconnect();
+    	parent.removeElement(newElement);
+    	newElement.setParent(null);
+    	oldConnection.connect(oldSource, oldTarget);    	
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/DirectedGraphLayoutVisitor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/DirectedGraphLayoutVisitor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/DirectedGraphLayoutVisitor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,128 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.AbsoluteBendpoint;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Insets;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.draw2d.graph.DirectedGraph;
+import org.eclipse.draw2d.graph.DirectedGraphLayout;
+import org.eclipse.draw2d.graph.Edge;
+import org.eclipse.draw2d.graph.Node;
+import org.eclipse.draw2d.graph.NodeList;
+
+public class DirectedGraphLayoutVisitor {
+
+	private Map partToNodesMap;
+	private DirectedGraph graph;
+
+	public void layoutDiagram(ProcessEditPart diagram) {
+		partToNodesMap = new HashMap();
+		graph = new DirectedGraph();
+		addNodes(diagram);
+		if (graph.nodes.size() > 0) {	
+			addEdges(diagram);
+			new DirectedGraphLayout().visit(graph);
+			applyResults(diagram);
+		}
+	}
+
+	protected void addNodes(ProcessEditPart diagram) {
+		for (int i = 0; i < diagram.getChildren().size(); i++) {
+			ElementEditPart elementEditPart = (ElementEditPart) diagram.getChildren().get(i);
+			addNodes(elementEditPart);
+		}
+	}
+
+	protected void addNodes(ElementEditPart elementEditPart) {
+		Node n = new Node(elementEditPart);
+		n.width = elementEditPart.getFigure().getPreferredSize(400, 300).width;
+		n.height = elementEditPart.getFigure().getPreferredSize(400, 300).height;
+		n.setPadding(new Insets(10, 8, 10, 12));
+		partToNodesMap.put(elementEditPart, n);
+		graph.nodes.add(n);
+	}
+
+	protected void addEdges(ProcessEditPart diagram) {
+		for (int i = 0; i < diagram.getChildren().size(); i++) {
+			ElementEditPart elementEditPart = (ElementEditPart) diagram.getChildren().get(i);
+			addEdges(elementEditPart);
+		}
+	}
+
+	protected void addEdges(ElementEditPart elementEditPart) {
+		List outgoing = elementEditPart.getSourceConnections();
+		for (int i = 0; i < outgoing.size(); i++) {
+			ElementConnectionEditPart connectionPart = (ElementConnectionEditPart) elementEditPart.getSourceConnections().get(i);
+			addEdges(connectionPart);
+		}
+	}
+
+	protected void addEdges(ElementConnectionEditPart connectionPart) {
+		Node source = (Node) partToNodesMap.get(connectionPart.getSource());
+		Node target = (Node) partToNodesMap.get(connectionPart.getTarget());
+		Edge e = new Edge(connectionPart, source, target);
+		e.weight = 2;
+		graph.edges.add(e);
+		partToNodesMap.put(connectionPart, e);
+	}
+
+	protected void applyResults(ProcessEditPart diagram) {
+		applyChildrenResults(diagram);
+	}
+
+	protected void applyChildrenResults(ProcessEditPart diagram) {
+		for (int i = 0; i < diagram.getChildren().size(); i++) {
+			ElementEditPart elementEditPart = (ElementEditPart) diagram.getChildren().get(i);
+			applyResults(elementEditPart);
+		}
+	}
+
+	protected void applyOwnResults(ProcessEditPart diagram) {
+	}
+
+	public void applyResults(ElementEditPart elementEditPart) {
+		Node n = (Node) partToNodesMap.get(elementEditPart);
+		ElementFigure elementFigure = (ElementFigure) elementEditPart.getFigure();
+		Rectangle bounds = new Rectangle(n.x, n.y, elementFigure.getPreferredSize().width,
+				elementFigure.getPreferredSize().height);
+		elementFigure.setBounds(bounds);
+		for (int i = 0; i < elementEditPart.getSourceConnections().size(); i++) {
+			ElementConnectionEditPart connectionPart = (ElementConnectionEditPart) elementEditPart.getSourceConnections().get(i);
+			applyResults(connectionPart);
+		}
+	}
+
+	protected void applyResults(ElementConnectionEditPart connectionPart)	{
+		Edge e = (Edge) partToNodesMap.get(connectionPart);
+		NodeList nodes = e.vNodes;
+		PolylineConnection conn = (PolylineConnection) connectionPart.getConnectionFigure();
+		conn.setTargetDecoration(new PolygonDecoration());
+		if (nodes != null) {
+			List bends = new ArrayList();
+			for (int i = 0; i < nodes.size(); i++) {
+				Node vn = nodes.getNode(i);
+				int x = vn.x;
+				int y = vn.y;
+				if (e.isFeedback()) {
+					bends.add(new AbsoluteBendpoint(x, y + vn.height));
+					bends.add(new AbsoluteBendpoint(x, y));
+				} else {
+					bends.add(new AbsoluteBendpoint(x, y));
+					bends.add(new AbsoluteBendpoint(x, y + vn.height));
+				}
+			}
+			conn.setRoutingConstraint(bends);
+		} else {
+			conn.setRoutingConstraint(Collections.EMPTY_LIST);
+		}
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementCellEditorLocator.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementCellEditorLocator.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementCellEditorLocator.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,57 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Text;
+
+import org.eclipse.jface.viewers.CellEditor;
+
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.geometry.Rectangle;
+
+import org.eclipse.gef.tools.CellEditorLocator;
+
+/**
+ * A CellEditorLocator for elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementCellEditorLocator implements CellEditorLocator {
+
+    private Label label;
+
+    public ElementCellEditorLocator(Label label) {
+        setLabel(label);
+    }
+
+    public void relocate(CellEditor cellEditor) {
+        Text text = (Text) cellEditor.getControl();
+        Point pref = text.computeSize(-1, -1);
+        Rectangle rect = label.getTextBounds().getCopy();
+        label.translateToAbsolute(rect);
+        text.setBounds(rect.x - 1, rect.y - 1, pref.x + 1, pref.y + 1);
+    }
+
+    protected Label getLabel() {
+        return label;
+    }
+
+    protected void setLabel(Label label) {
+        this.label = label;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementConnectionEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,101 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
+import org.drools.eclipse.flow.common.editor.core.ModelEvent;
+import org.drools.eclipse.flow.common.editor.core.ModelListener;
+import org.drools.eclipse.flow.common.editor.policy.ConnectionBendpointEditPolicy;
+import org.drools.eclipse.flow.common.editor.policy.ConnectionEditPolicy;
+import org.eclipse.draw2d.AbsoluteBendpoint;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.editparts.AbstractConnectionEditPart;
+import org.eclipse.gef.editpolicies.ConnectionEndpointEditPolicy;
+
+/**
+ * Implementation of a connection EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementConnectionEditPart extends AbstractConnectionEditPart implements ModelListener {
+    
+    protected void createEditPolicies() {
+    	ConnectionEditPolicy connectionEditPolicy = new ConnectionEditPolicy();
+    	connectionEditPolicy.setDefaultElementConnectionFactory(getDefaultElementConnectionFactory());
+        installEditPolicy(EditPolicy.CONNECTION_ENDPOINTS_ROLE, new ConnectionEndpointEditPolicy());
+        installEditPolicy(EditPolicy.CONNECTION_ROLE, connectionEditPolicy);
+        installEditPolicy(EditPolicy.CONNECTION_BENDPOINTS_ROLE, new ConnectionBendpointEditPolicy());
+    }
+    
+    protected ElementConnectionFactory getDefaultElementConnectionFactory() {
+    	return new ElementConnectionFactory(0);
+    }
+
+    protected IFigure createFigure() {
+        PolylineConnection result = new PolylineConnection();
+        result.setConnectionRouter(new BendpointConnectionRouter());
+        result.setTargetDecoration(new PolygonDecoration());
+        return result;
+    }
+    
+    public void setSelected(int value) {
+        super.setSelected(value);
+        if (value != EditPart.SELECTED_NONE) {
+            ((PolylineConnection)getFigure()).setLineWidth(2);
+        } else {
+            ((PolylineConnection)getFigure()).setLineWidth(1);
+        }
+    }
+    
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == ElementConnection.CHANGE_BENDPOINTS) {
+            refreshBendpoints();
+        }
+    }
+
+    public void activate() {
+        super.activate();
+        ((ElementConnection) getModel()).addListener(this);
+    }
+
+    public void deactivate() {
+        ((ElementConnection) getModel()).removeListener(this);
+        super.deactivate();
+    }
+
+    protected void refreshBendpoints() {
+        List bendpoints = ((ElementConnection) getModel()).getBendpoints();
+        List constraint = new ArrayList();
+        for (int i = 0; i < bendpoints.size(); i++) {
+            constraint.add(new AbsoluteBendpoint((Point) bendpoints.get(i)));
+        }
+        getConnectionFigure().setRoutingConstraint(constraint);
+    }
+
+    protected void refreshVisuals() {
+        refreshBendpoints();
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ElementEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,134 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ModelEvent;
+import org.drools.eclipse.flow.common.editor.core.ModelListener;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.drools.eclipse.flow.common.editor.policy.ElementDirectEditManager;
+import org.drools.eclipse.flow.common.editor.policy.ElementDirectEditPolicy;
+import org.drools.eclipse.flow.common.editor.policy.ElementEditPolicy;
+import org.drools.eclipse.flow.common.editor.policy.ElementNodeEditPolicy;
+import org.eclipse.draw2d.ChopboxAnchor;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.NodeEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.RequestConstants;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.jface.viewers.TextCellEditor;
+
+/**
+ * Default implementation of an element EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ElementEditPart extends AbstractGraphicalEditPart implements NodeEditPart, ModelListener {
+    
+    private DirectEditManager manager;
+    
+    protected void createEditPolicies() {
+        installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, new ElementNodeEditPolicy());
+        installEditPolicy(EditPolicy.COMPONENT_ROLE, new ElementEditPolicy());
+        installEditPolicy(EditPolicy.DIRECT_EDIT_ROLE, new ElementDirectEditPolicy());
+    }
+    
+    protected ElementWrapper getElementWrapper() {
+    	return (ElementWrapper) getModel();
+    }
+
+    protected List getModelSourceConnections() {
+        return getElementWrapper().getOutgoingConnections();
+    }
+    
+    protected List getModelTargetConnections() {
+        return getElementWrapper().getIncomingConnections();
+    }
+    
+    public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+        return new ChopboxAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+        return new ChopboxAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+        return new ChopboxAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+        return new ChopboxAnchor(getFigure());
+    }
+
+    protected void refreshVisuals() {
+        ElementWrapper element = getElementWrapper();
+        ElementFigure figure = (ElementFigure) getFigure();
+        figure.setText(element.getName());
+        if (element.getConstraint().width == -1) {
+            element.getConstraint().width = figure.getBounds().width;
+        }
+        if (element.getConstraint().height == -1) {
+            element.getConstraint().height = figure.getBounds().height;
+        }
+        ((GraphicalEditPart) getParent()).setLayoutConstraint(this, figure, element.getConstraint());
+    }
+    
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == ElementWrapper.CHANGE_INCOMING_CONNECTIONS) {
+            refreshTargetConnections();
+        } else if (event.getChange() == ElementWrapper.CHANGE_OUTGOING_CONNECTIONS) {
+            refreshSourceConnections();
+        } else if (event.getChange() == ElementWrapper.CHANGE_NAME) {
+            refreshVisuals();
+        } else if (event.getChange() == ElementWrapper.CHANGE_CONSTRAINT) {
+            refreshVisuals();
+        }
+    }
+
+    public void activate() {
+        super.activate();
+        ((ElementWrapper) getModel()).addListener(this);
+    }
+
+    public void deactivate() {
+        ((ElementWrapper) getModel()).removeListener(this);
+        super.deactivate();
+    }
+
+    public void performRequest(Request request) {
+        if (request.getType() == RequestConstants.REQ_DIRECT_EDIT) {
+            performDirectEdit();
+        } else {
+            super.performRequest(request);
+        }
+    }
+    
+    private void performDirectEdit() {
+        if (manager == null) {
+            manager = new ElementDirectEditManager(this, TextCellEditor.class,
+                new ElementCellEditorLocator(((ElementFigure) getFigure()).getLabel()));
+        }
+        manager.show();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/GraphLayoutManager.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/GraphLayoutManager.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/GraphLayoutManager.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,26 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+
+import org.eclipse.draw2d.AbstractLayout;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Dimension;
+
+public class GraphLayoutManager extends AbstractLayout {
+
+	private ProcessEditPart diagram;
+
+	public GraphLayoutManager(ProcessEditPart diagram) {
+		this.diagram = diagram;
+	}
+	
+	protected Dimension calculatePreferredSize(IFigure container, int wHint, int hHint) {		
+		container.validate();
+		return container.getSize();
+	}
+
+	
+	public void layout(IFigure container) {
+		new DirectedGraphLayoutVisitor().layoutDiagram(diagram);
+		// diagram.setTableModelBounds();
+	}
+	
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ProcessEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ProcessEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/ProcessEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,141 @@
+package org.drools.eclipse.flow.common.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ModelEvent;
+import org.drools.eclipse.flow.common.editor.core.ModelListener;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.drools.eclipse.flow.common.editor.policy.ProcessLayoutEditPolicy;
+import org.eclipse.draw2d.Animation;
+import org.eclipse.draw2d.AutomaticRouter;
+import org.eclipse.draw2d.BendpointConnectionRouter;
+import org.eclipse.draw2d.ConnectionLayer;
+import org.eclipse.draw2d.FanRouter;
+import org.eclipse.draw2d.Figure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.ManhattanConnectionRouter;
+import org.eclipse.draw2d.ShortestPathConnectionRouter;
+import org.eclipse.draw2d.XYLayout;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPolicy;
+import org.eclipse.gef.LayerConstants;
+import org.eclipse.gef.SnapToGrid;
+import org.eclipse.gef.SnapToHelper;
+import org.eclipse.gef.editparts.AbstractGraphicalEditPart;
+import org.eclipse.gef.editpolicies.RootComponentEditPolicy;
+import org.eclipse.swt.SWT;
+
+/**
+ * Default implementation of a process EditPart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ProcessEditPart extends AbstractGraphicalEditPart implements ModelListener {
+    
+//	private GraphLayoutManager graphLayoutManager;
+	
+    protected IFigure createFigure() {
+        Figure f = new Figure();
+        f.setLayoutManager(new XYLayout());
+//        graphLayoutManager = new GraphLayoutManager(this);
+//        f.setLayoutManager(graphLayoutManager);
+//        graphLayoutManager.layout(f);
+        return f;
+    }
+
+    protected void createEditPolicies() {
+        installEditPolicy(EditPolicy.NODE_ROLE, null);
+        installEditPolicy(EditPolicy.GRAPHICAL_NODE_ROLE, null);
+        installEditPolicy(EditPolicy.SELECTION_FEEDBACK_ROLE, null);
+        installEditPolicy(EditPolicy.LAYOUT_ROLE, new ProcessLayoutEditPolicy());
+        installEditPolicy(EditPolicy.COMPONENT_ROLE, new RootComponentEditPolicy());
+    }
+
+    protected List getModelChildren() {
+        return getProcessWrapper().getElements();
+    }
+    
+    protected ProcessWrapper getProcessWrapper() {
+    	return (ProcessWrapper) getModel();
+    }
+
+    public void activate() {
+        super.activate();
+        ((ProcessWrapper) getModel()).addListener(this);
+    }
+
+    public void deactivate() {
+        ((ProcessWrapper) getModel()).removeListener(this);
+        super.deactivate();
+    }
+
+    public void modelChanged(ModelEvent event) {
+        if (event.getChange() == ProcessWrapper.CHANGE_ELEMENTS) {
+            refreshChildren();
+        } else if (event.getChange() == ProcessWrapper.CHANGE_ROUTER_LAYOUT) {
+    		refreshVisuals();
+    	}
+    }
+    
+    public Object getAdapter(Class adapter) {
+    	if (adapter == SnapToHelper.class) {
+    		Boolean val = (Boolean) getViewer().getProperty(SnapToGrid.PROPERTY_GRID_ENABLED);
+    		if (val != null && val.booleanValue()) {
+    			return new SnapToGrid(this);
+    		}
+    	}
+    	return super.getAdapter(adapter);
+    }
+    
+    protected void refreshVisuals() {
+    	Animation.markBegin();
+    	ConnectionLayer layer = (ConnectionLayer) getLayer(LayerConstants.CONNECTION_LAYER);
+        if ((getViewer().getControl().getStyle() & SWT.MIRRORED ) == 0) {
+            layer.setAntialias(SWT.ON);
+        }
+
+    	if (getProcessWrapper().getRouterLayout().equals(ProcessWrapper.ROUTER_LAYOUT_MANUAL)) {
+    		AutomaticRouter router = new FanRouter();
+    		router.setNextRouter(new BendpointConnectionRouter());
+    		layer.setConnectionRouter(router);
+    	} else if (getProcessWrapper().getRouterLayout().equals(ProcessWrapper.ROUTER_LAYOUT_MANHATTAN)) {
+    		layer.setConnectionRouter(new ManhattanConnectionRouter());
+    	} else {
+    		layer.setConnectionRouter(new ShortestPathConnectionRouter(getFigure()));
+    	}
+    	Animation.run(400);
+    }
+    
+	public boolean setTableModelBounds() {
+		List tableParts = getChildren();
+		for (Iterator iter = tableParts.iterator(); iter.hasNext(); ) {
+			ElementEditPart elementEditPart = (ElementEditPart) iter.next();
+			ElementFigure elementFigure = (ElementFigure) elementEditPart.getFigure();
+			if (elementFigure == null) {
+				continue;
+			}
+			Rectangle constraint = elementFigure.getBounds().getCopy();
+			ElementWrapper elementWrapper = elementEditPart.getElementWrapper();
+			elementWrapper.setConstraint(constraint);
+		}
+		return true;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementFigure.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementFigure.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/editpart/figure/ElementFigure.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,69 @@
+package org.drools.eclipse.flow.common.editor.editpart.figure;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.draw2d.Label;
+import org.eclipse.draw2d.Panel;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * Default implementation of an element Figure.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class ElementFigure extends Panel {
+    
+    private boolean selected;
+    private Label label = new Label();
+
+    public ElementFigure() {
+        add(label);
+        customizeFigure();
+        setSize(80, 40);
+    }
+    
+    public void setIcon(Image icon) {
+        label.setIcon(icon);
+    }
+    
+    public void setText(String text) {
+        label.setText(text);
+    }
+    
+    public Label getLabel() {
+        return label;
+    }
+    
+    public void setBounds(Rectangle bounds) {
+        super.setBounds(bounds);
+        label.setBounds(bounds);
+    }
+    
+    protected abstract void customizeFigure();
+    
+    public void setSelected(boolean b) {
+        selected = b;
+    }
+    
+    public boolean isSelected() {
+        return selected;
+    }
+
+    public void setFocus(boolean b) {
+        repaint();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionBendpointEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionBendpointEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionBendpointEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,64 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.command.CreateBendpointCommand;
+import org.drools.eclipse.flow.common.editor.core.command.DeleteBendpointCommand;
+import org.drools.eclipse.flow.common.editor.core.command.MoveBendpointCommand;
+import org.eclipse.draw2d.geometry.Point;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.BendpointEditPolicy;
+import org.eclipse.gef.requests.BendpointRequest;
+
+/**
+ * Policy for bendpoints of connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionBendpointEditPolicy extends BendpointEditPolicy {
+
+    protected Command getCreateBendpointCommand(BendpointRequest request) {
+        Point point = request.getLocation();
+        getConnection().translateToRelative(point);
+        
+        CreateBendpointCommand command = new CreateBendpointCommand();
+        command.setLocation(point);
+        command.setConnection(getHost().getModel());
+        command.setIndex(request.getIndex());
+        
+        return command;
+    }
+
+    protected Command getDeleteBendpointCommand(BendpointRequest request) {
+        DeleteBendpointCommand command = new DeleteBendpointCommand();
+        command.setConnectionModel(getHost().getModel());
+        command.setIndex(request.getIndex());
+        return command;
+    }
+
+    protected Command getMoveBendpointCommand(BendpointRequest request) {
+        Point location = request.getLocation();
+        getConnection().translateToRelative(location);
+
+        MoveBendpointCommand command = new MoveBendpointCommand();
+        command.setConnectionModel(getHost().getModel());
+        command.setIndex(request.getIndex());
+        command.setNewLocation(location);
+
+        return command;
+
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ConnectionEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,101 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.drools.eclipse.flow.common.editor.core.command.DeleteConnectionCommand;
+import org.drools.eclipse.flow.common.editor.core.command.SplitConnectionCommand;
+import org.drools.eclipse.flow.common.editor.editpart.ElementConnectionEditPart;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.requests.CreateRequest;
+import org.eclipse.gef.requests.GroupRequest;
+
+/**
+ * Policy for editing connections.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionEditPolicy extends org.eclipse.gef.editpolicies.ConnectionEditPolicy {
+
+	private ElementConnectionFactory elementConnectionFactory;
+	
+	
+	public void setDefaultElementConnectionFactory(ElementConnectionFactory factory) {
+		if (factory == null) {
+			throw new IllegalArgumentException("ElementConnectionFactory is null");
+		}
+		this.elementConnectionFactory = factory;
+	}
+	
+	public ElementConnectionFactory getDefaultElementConnectionFactory() {
+		return elementConnectionFactory;
+	}
+	
+    public Command getCommand(Request request) {
+        if (REQ_CREATE.equals(request.getType()))
+            return getSplitTransitionCommand(request);
+        return super.getCommand(request);
+    }
+
+    private PolylineConnection getConnectionFigure() {
+        return ((PolylineConnection) ((ElementConnectionEditPart) getHost()).getFigure());
+    }
+
+    protected Command getDeleteCommand(GroupRequest request) {
+        DeleteConnectionCommand cmd = new DeleteConnectionCommand();
+        ElementConnection connection = (ElementConnection) getHost().getModel();
+        cmd.setAntecedentTaskConnection(connection);
+        cmd.setSource(connection.getSource());
+        cmd.setTarget(connection.getTarget());
+        return cmd;
+    }
+
+    protected Command getSplitTransitionCommand(Request request) {
+    	if (elementConnectionFactory == null) {
+    		throw new IllegalStateException("DefaultElementConnectionFactory is null");
+    	}
+        SplitConnectionCommand cmd = new SplitConnectionCommand();
+        cmd.setElementConnection(((ElementConnection) getHost().getModel()));
+        cmd.setNewSecondConnection(elementConnectionFactory.createElementConnection());
+        cmd.setParent(((ProcessWrapper) ((ElementConnectionEditPart) getHost())
+            .getSource().getParent().getModel()));
+        cmd.setNewElement(((ElementWrapper) ((CreateRequest) request).getNewObject()));
+        return cmd;
+    }
+
+    public EditPart getTargetEditPart(Request request) {
+        if (REQ_CREATE.equals(request.getType()))
+            return getHost();
+        return null;
+    }
+
+    public void eraseTargetFeedback(Request request) {
+        if (REQ_CREATE.equals(request.getType()))
+            getConnectionFigure().setLineWidth(1);
+    }
+
+    public void showTargetFeedback(Request request) {
+        if (REQ_CREATE.equals(request.getType()))
+            getConnectionFigure().setLineWidth(2);
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditManager.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditManager.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditManager.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,44 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.eclipse.gef.GraphicalEditPart;
+import org.eclipse.gef.tools.CellEditorLocator;
+import org.eclipse.gef.tools.DirectEditManager;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Manager for directly editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementDirectEditManager extends DirectEditManager {
+
+    private ElementWrapper element;
+
+    public ElementDirectEditManager(GraphicalEditPart source, Class editorType,
+            CellEditorLocator locator) {
+        super(source, editorType, locator);
+        element = (ElementWrapper) source.getModel();
+    }
+
+    protected void initCellEditor() {
+        getCellEditor().setValue(element.getName());
+        Text text = (Text) getCellEditor().getControl();
+        text.selectAll();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementDirectEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,45 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.command.RenameElementCommand;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.DirectEditPolicy;
+import org.eclipse.gef.requests.DirectEditRequest;
+
+/**
+ * Policy for directly editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementDirectEditPolicy extends DirectEditPolicy {
+
+    protected Command getDirectEditCommand(DirectEditRequest request) {
+        RenameElementCommand cmd = new RenameElementCommand();
+        cmd.setSource((ElementWrapper) getHost().getModel());
+        cmd.setOldName(((ElementWrapper) getHost().getModel()).getName());
+        cmd.setName((String) request.getCellEditor().getValue());
+        return cmd;
+    }
+
+    protected void showCurrentEditValue(DirectEditRequest request) {
+        String value = (String) request.getCellEditor().getValue();
+        ((ElementFigure) getHostFigure()).setText(value);
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.drools.eclipse.flow.common.editor.core.command.DeleteElementCommand;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.ComponentEditPolicy;
+import org.eclipse.gef.requests.GroupRequest;
+
+/**
+ * Policy for editing elements.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementEditPolicy extends ComponentEditPolicy {
+
+    protected Command createDeleteCommand(GroupRequest deleteRequest) {
+        ProcessWrapper parent = (ProcessWrapper) getHost().getParent().getModel();
+        DeleteElementCommand deleteCmd = new DeleteElementCommand();
+        deleteCmd.setParent(parent);
+        deleteCmd.setChild((ElementWrapper) (getHost().getModel()));
+        return deleteCmd;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementNodeEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementNodeEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ElementNodeEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,77 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.command.ElementConnectionCreateCommand;
+import org.drools.eclipse.flow.common.editor.core.command.ReconnectElementConnectionSourceCommand;
+import org.drools.eclipse.flow.common.editor.core.command.ReconnectElementConnectionTargetCommand;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.GraphicalNodeEditPolicy;
+import org.eclipse.gef.requests.CreateConnectionRequest;
+import org.eclipse.gef.requests.ReconnectRequest;
+
+/**
+ * Policy for editing an element node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ElementNodeEditPolicy extends GraphicalNodeEditPolicy {
+
+    protected Command getConnectionCompleteCommand(CreateConnectionRequest request) {
+        ElementConnectionCreateCommand cmd =
+            (ElementConnectionCreateCommand) request.getStartCommand();
+        cmd.setConnection((ElementConnection) request.getNewObject());
+        cmd.setTarget(getElement());
+        return cmd;
+    }
+
+    protected Command getConnectionCreateCommand(CreateConnectionRequest request) {
+        ElementConnectionCreateCommand cmd =
+            new ElementConnectionCreateCommand();
+        cmd.setConnection((ElementConnection) request.getNewObject());
+        cmd.setSource(getElement());
+        request.setStartCommand(cmd);
+        return cmd;
+    }
+
+    protected ElementEditPart getActivityPart() {
+        return (ElementEditPart) getHost();
+    }
+
+    protected ElementWrapper getElement() {
+        return (ElementWrapper) getHost().getModel();
+    }
+
+    protected Command getReconnectSourceCommand(ReconnectRequest request) {
+        ReconnectElementConnectionSourceCommand cmd
+            = new ReconnectElementConnectionSourceCommand();
+        cmd.setConnection((ElementConnection) request.getConnectionEditPart().getModel());
+        cmd.setSource(getElement());
+        return cmd;
+    }
+
+    protected Command getReconnectTargetCommand(ReconnectRequest request) {
+        ReconnectElementConnectionTargetCommand cmd
+            = new ReconnectElementConnectionTargetCommand();
+        cmd.setConnection((ElementConnection) request.getConnectionEditPart().getModel());
+        cmd.setTarget(getElement());
+        return cmd;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ProcessLayoutEditPolicy.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ProcessLayoutEditPolicy.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/policy/ProcessLayoutEditPolicy.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,63 @@
+package org.drools.eclipse.flow.common.editor.policy;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.drools.eclipse.flow.common.editor.core.command.AddElementCommand;
+import org.drools.eclipse.flow.common.editor.core.command.ChangeConstraintCommand;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.gef.commands.Command;
+import org.eclipse.gef.editpolicies.XYLayoutEditPolicy;
+import org.eclipse.gef.requests.CreateRequest;
+
+/**
+ * Policy for performing layout of a process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ProcessLayoutEditPolicy extends XYLayoutEditPolicy {
+    
+    protected Command getCreateCommand(CreateRequest request) {
+        AddElementCommand command = new AddElementCommand();
+        command.setParent((ProcessWrapper) getHost().getModel());
+        ElementWrapper element = (ElementWrapper) request.getNewObject();
+        element.setConstraint((Rectangle) getConstraintFor(request));
+        command.setChild(element);
+        return command;
+    }
+
+    protected Command getDeleteDependantCommand(Request request) {
+        return null;
+    }
+
+    protected Command createAddCommand(EditPart child, Object constraint) {
+        ElementWrapper element = (ElementWrapper) child.getModel();
+        AddElementCommand add = new AddElementCommand();
+        add.setParent((ProcessWrapper) getHost().getModel());
+        add.setChild(element);
+        return add;
+    }
+
+    protected Command createChangeConstraintCommand(EditPart child, Object constraint) {
+        ChangeConstraintCommand command = new ChangeConstraintCommand();
+        command.setElement((ElementWrapper) child.getModel());
+        command.setConstraint((Rectangle)constraint);
+        return command;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/DataTypeEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/DataTypeEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/DataTypeEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.flow.common.view.datatype.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.ruleflow.common.datatype.DataType;
+
+/**
+ * An editor for a datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface DataTypeEditor {
+
+    void setDataType(DataType dataType);
+    
+    DataType getDataType();
+    
+    void reset();
+    
+    void addListener(DataTypeListener listener);
+    
+    void removeListener(DataTypeListener listener);
+
+    public interface DataTypeListener {
+        void dataTypeChanged(DataType dataType);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/Editor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/Editor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/Editor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,38 @@
+package org.drools.eclipse.flow.common.view.datatype.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.ruleflow.common.datatype.DataType;
+
+
+/**
+ * An editor for an object with a given datatype.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public interface Editor {
+
+    void setDataType(DataType dataType);
+    
+	Serializable getValue();
+    
+    void setValue(Serializable value);
+    
+    void reset();
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/BooleanEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/BooleanEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/BooleanEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,75 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.common.datatype.impl.type.BooleanDataType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Default boolean editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class BooleanEditor extends Composite implements Editor {
+
+    private static final String[] TF = { "true", "false" };
+    
+    private Combo combo;
+    
+    public BooleanEditor(Composite parent) {
+        super(parent, SWT.NONE);
+        setLayout(new FillLayout());
+        combo = new Combo(this, SWT.READ_ONLY);
+        combo.setItems(TF);
+        combo.select(1);
+    }
+
+    public void setDataType(DataType dataType) {
+        if (!(dataType instanceof BooleanDataType)) {
+            throw new IllegalArgumentException("Illegal data type " + dataType);
+        }
+    }
+
+    public Serializable getValue() {
+        return Boolean.valueOf(combo.getSelectionIndex() == 0);
+    }
+    
+    public void setValue(Serializable value) {
+        if (value == null) {
+            combo.select(1);
+        } else if (value instanceof Boolean) {
+            combo.select(((Boolean) value).booleanValue() ? 0 : 1);
+        } else {
+            throw new IllegalArgumentException("Value must be a boolean: " + value);
+        }
+    }
+    
+    public void reset() {
+        combo.select(1);
+    }
+    
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        combo.setEnabled(enabled);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeCombo.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeCombo.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeCombo.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,96 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.datatype.DataTypeRegistry;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.eclipse.jface.viewers.ComboViewer;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Combobox for datatypes based on a datatype registry.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DataTypeCombo extends Composite {
+    
+    private DataTypeRegistry registry;
+    private ComboViewer dataTypeCombo;
+    
+    public DataTypeCombo(Composite parent, int style, DataTypeRegistry registry) {
+        super(parent, style);
+        this.registry = registry;
+        setLayout(new FillLayout());
+        dataTypeCombo = new ComboViewer(this, SWT.READ_ONLY);
+        dataTypeCombo.setLabelProvider(new LabelProvider() {
+            public String getText(Object element) {
+                return ((DataTypeRegistry.IDataTypeInfo) element).getName();
+            }
+        });
+        dataTypeCombo.add(registry.getDataTypes().toArray(
+            new DataTypeRegistry.IDataTypeInfo[0]));
+    }
+    
+    private DataTypeRegistry.IDataTypeInfo getSelectedTypeInfo() {
+        ISelection selection = dataTypeCombo.getSelection();
+        if (!selection.isEmpty()) {
+            return (DataTypeRegistry.IDataTypeInfo)
+                ((StructuredSelection) selection).getFirstElement();
+        }
+        return null;
+    }
+    
+    public void setDataType(DataType dataType) {
+        if (dataType == null) {
+        	dataTypeCombo.setSelection(null);
+        } else {
+        	// TODO : check what happens if dataType not in combo
+            try {
+            	dataTypeCombo.setSelection(new StructuredSelection(registry.getDataTypeInfo(dataType.getClass())));
+            } catch (IllegalArgumentException e) {
+            	// "DataTypeInfo not found in registry: " + dataType.getClass()
+            	DroolsEclipsePlugin.log(e);
+            }
+        }
+    }
+    
+    public DataType getDataType() {
+    	DataTypeRegistry.IDataTypeInfo dataTypeInfo =
+    		getSelectedTypeInfo();
+        return dataTypeInfo == null ? null : 
+        	dataTypeInfo.getDataTypeFactory().createDataType();
+    }
+    
+    public void reset() {
+    	dataTypeCombo.setSelection(null);
+    }
+    
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        dataTypeCombo.getCombo().setEnabled(enabled);
+    }
+    
+    public void addSelectionChangedListener(ISelectionChangedListener listener) {
+    	dataTypeCombo.addSelectionChangedListener(listener);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeEditorComposite.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeEditorComposite.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/DataTypeEditorComposite.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,125 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.datatype.DataTypeRegistry;
+import org.drools.eclipse.flow.common.view.datatype.editor.DataTypeEditor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.common.datatype.impl.type.UndefinedDataType;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Default editor for a datatype. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class DataTypeEditorComposite extends Composite implements DataTypeEditor.DataTypeListener {
+    private DataTypeRegistry registry;
+    private DataTypeEditor dataTypeEditor;
+    private List listeners = new ArrayList();
+   
+    public DataTypeEditorComposite(Composite parent, int style, DataTypeRegistry registry) {
+        super(parent, style);
+        this.registry = registry;
+        setLayout(new FillLayout());
+        dataTypeEditor = new EmptyEditor(this);
+    }
+    public void setDataType(DataType dataType) {
+        if (dataType == null) {
+            reset();
+        } else {
+            // update data type editor
+            dataTypeEditor.removeListener(this);
+            ((Composite) dataTypeEditor).dispose();
+            dataTypeEditor = null;
+            Class editorClass = null;
+            try {
+                editorClass = registry.getDataTypeInfo(dataType.getClass()).getDataTypeEditorClass();
+                dataTypeEditor = (DataTypeEditor) editorClass.getConstructor(
+                    new Class[] { Composite.class }).newInstance(new Object[] { this });
+            } catch (IllegalArgumentException e) {
+            	// "Could not find data type info for type " + dataType.getClass()
+                DroolsEclipsePlugin.log(e);
+            } catch (InstantiationException e) {
+                // "Could not create editor for type " + editorClass
+                DroolsEclipsePlugin.log(e);
+            } catch (NoSuchMethodException e) {
+                // "Could not create editor for type " + editorClass
+                DroolsEclipsePlugin.log(e);
+            } catch (InvocationTargetException e) {
+                // "Could not create editor for type " + editorClass
+                DroolsEclipsePlugin.log(e);
+            } catch (IllegalAccessException e) {
+                // "Could not create editor for type " + editorClass
+                DroolsEclipsePlugin.log(e);
+            }
+            
+            if (dataTypeEditor == null) {
+                dataTypeEditor = new EmptyEditor(this);
+            }
+            dataTypeEditor.addListener(this);
+            dataTypeEditor.setDataType(dataType);
+            ((Composite) dataTypeEditor).setBackground(getBackground());
+            layout();
+        }
+    }
+    
+    public DataType getDataType() {
+        return dataTypeEditor.getDataType();
+    }
+    
+   public void reset() {
+        setDataType(UndefinedDataType.getInstance());
+    }
+    
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        ((Composite) dataTypeEditor).setEnabled(enabled);
+    }
+    
+    public void addListener(DataTypeEditor.DataTypeListener listener) {
+        listeners.add(listener);
+    }
+    
+    public void removeListener(DataTypeEditor.DataTypeListener listener) {
+        listeners.remove(listener);
+    }
+    
+    private void notifyListeners() {
+        DataType dataType = getDataType();
+        for (Iterator it = listeners.iterator(); it.hasNext(); ) {
+        	DataTypeEditor.DataTypeListener listener = (DataTypeEditor.DataTypeListener) it.next();
+            listener.dataTypeChanged(dataType);
+        }
+    }
+
+    public void dataTypeChanged(DataType dataType) {
+        notifyListeners();
+    }
+    
+    public void setBackground(Color color) {
+    	super.setBackground(color);
+    	((Composite) dataTypeEditor).setBackground(color);
+    }
+}
Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EditorComposite.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EditorComposite.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EditorComposite.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,97 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+import java.lang.reflect.InvocationTargetException;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.datatype.DataTypeRegistry;
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * Container for an editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EditorComposite extends Composite {
+    
+    private DataTypeRegistry registry;
+    private Editor editor;
+    
+    public EditorComposite(Composite parent, int style, DataTypeRegistry registry) {
+        super(parent, style);
+        this.registry = registry;
+        setLayout(new FillLayout());
+        editor = new EmptyEditor(this);
+    }
+    
+    public void setDataType(DataType type) {
+        ((Composite) editor).dispose();
+        if (type == null) {
+            editor = new EmptyEditor(this);
+        } else {
+        	Class editorClass = null;
+            try {
+                editorClass = registry.getDataTypeInfo(type.getClass()).getValueEditorClass();
+                editor = (Editor) editorClass.getConstructor(
+                    new Class[] { Composite.class }).newInstance(new Object[] { this });
+            } catch (IllegalArgumentException e) {
+                // "Could not find data type info for type " + type.getClass()
+            	DroolsEclipsePlugin.log(e);
+                editor = new EmptyEditor(this);
+            } catch (InstantiationException e) {
+                // "Could not create editor for editor " + editorClass
+            	DroolsEclipsePlugin.log(e);
+                editor = new EmptyEditor(this);
+            } catch (NoSuchMethodException e) {
+            	// "Could not create editor for editor " + editorClass
+            	DroolsEclipsePlugin.log(e);
+                editor = new EmptyEditor(this);
+            } catch (InvocationTargetException e) {
+            	// "Could not create editor for editor " + editorClass
+            	DroolsEclipsePlugin.log(e);
+                editor = new EmptyEditor(this);
+            } catch (IllegalAccessException e) {
+            	// "Could not create editor for editor " + editorClass
+            	DroolsEclipsePlugin.log(e);
+                editor = new EmptyEditor(this);
+            }
+            editor.setDataType(type);
+            layout();
+        }
+    }
+    
+    public void setValue(Serializable value) {
+        editor.setValue(value);
+    }
+    
+    public Serializable getValue() {
+        return editor.getValue();
+    }
+
+    public void reset() {
+        editor.reset();
+    }
+    
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        ((Composite) editor).setEnabled(enabled);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EmptyEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EmptyEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/EmptyEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,79 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.eclipse.flow.common.view.datatype.editor.DataTypeEditor;
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+
+/**
+ * Default empty editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EmptyEditor extends Composite implements Editor, DataTypeEditor {
+
+    private DataType dataType;
+    private Serializable value;
+    private Label label;
+    
+    public EmptyEditor(Composite parent) {
+        super(parent, SWT.NONE);
+        setSize(0, 0);
+        setLayout(new FillLayout());
+        label = new Label(this, SWT.NONE);
+    }
+    
+    public DataType getDataType() {
+        return dataType;
+    }
+    
+    public void setDataType(DataType dataType) {
+        this.dataType = dataType;
+    }
+
+    public Serializable getValue() {
+        return value;
+    }
+
+    public void setValue(Serializable value) {
+        this.value = value;
+    }
+
+    public void reset() {
+        // do nothing
+    }
+
+    public void addListener(DataTypeEditor.DataTypeListener listener) {
+        // do nothing
+    }
+    
+    public void removeListener(DataTypeEditor.DataTypeListener listener) {
+        // do nothing
+    }
+    
+    public void setBackground(Color color) {
+    	super.setBackground(color);
+    	label.setBackground(color);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/FloatEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/FloatEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/FloatEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,80 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.common.datatype.impl.type.FloatDataType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Default float editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class FloatEditor extends Composite implements Editor {
+
+    private Text text;
+    
+    public FloatEditor(Composite parent) {
+        super(parent, SWT.NONE);
+        setLayout(new FillLayout());
+        text = new Text(this, SWT.NONE);
+    }
+
+    public void setDataType(DataType dataType) {
+        if (!(dataType instanceof FloatDataType)) {
+            throw new IllegalArgumentException("Illegal data type " + dataType);
+        }
+    }
+
+    public Serializable getValue() throws IllegalArgumentException {
+        String valueString = text.getText();
+        if ("".equals(valueString)) {
+            return null;
+        }
+        try {
+            return new Float(valueString);
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException("The value " + valueString
+                + " is not a valid float.");
+        }
+    }
+    
+    public void setValue(Serializable value) {
+        if (value == null) {
+            text.setText("");
+        } else if (value instanceof Float) {
+            text.setText(((Float) value).toString());
+        } else {
+            throw new IllegalArgumentException("Value must be a float: " + value);
+        }
+    }
+    
+    public void reset() {
+        text.setText("");
+    }
+
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        text.setEnabled(enabled);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/IntegerEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/IntegerEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/IntegerEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,80 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.common.datatype.impl.type.IntegerDataType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Default integer editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class IntegerEditor extends Composite implements Editor {
+
+    private Text text;
+    
+    public IntegerEditor(Composite parent) {
+        super(parent, SWT.NONE);
+        setLayout(new FillLayout());
+        text = new Text(this, SWT.NONE);
+    }
+
+    public void setDataType(DataType dataType) {
+        if (!(dataType instanceof IntegerDataType)) {
+            throw new IllegalArgumentException("Illegal data type " + dataType);
+        }
+    }
+
+    public Serializable getValue() {
+        String valueString = text.getText();
+        if ("".equals(valueString)) {
+            return null;
+        }
+        try {
+            return new Integer(valueString);
+        } catch (NumberFormatException e) {
+            throw new IllegalArgumentException("The value " + valueString
+                + " is not a valid integer.");
+        }
+    }
+
+    public void setValue(Serializable value) {
+        if (value == null) {
+            text.setText("");
+        } else if (value instanceof Integer) {
+            text.setText(((Integer) value).toString());
+        } else {
+            throw new IllegalArgumentException("Value must be an integer: " + value);
+        }
+    }
+    
+    public void reset() {
+        text.setText("");
+    }
+
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        text.setEnabled(enabled);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/StringEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/StringEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/datatype/editor/impl/StringEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.flow.common.view.datatype.editor.impl;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.Serializable;
+
+import org.drools.eclipse.flow.common.view.datatype.editor.Editor;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.common.datatype.impl.type.StringDataType;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Default string editor.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StringEditor extends Composite implements Editor {
+
+    private Text text;
+    
+    public StringEditor(Composite parent) {
+        super(parent, SWT.NONE);
+        setLayout(new FillLayout());
+        text = new Text(this, SWT.NONE);
+    }
+
+    public void setDataType(DataType dataType) {
+        if (!(dataType instanceof StringDataType)) {
+            throw new IllegalArgumentException("Illegal data type " + dataType);
+        }
+    }
+
+    public Serializable getValue() {
+        return text.getText();
+    }
+
+    public void setValue(Serializable value) {
+        if (value == null) {
+            text.setText("");
+        } else if (value instanceof String) {
+            text.setText(value == null ? "" : (String) value);
+        } else {
+            throw new IllegalArgumentException("Value must be a string: " + value);
+        }
+    }
+
+    public void reset() {
+        text.setText("");
+    }
+
+    public void setEnabled(boolean enabled) {
+        super.setEnabled(enabled);
+        text.setEnabled(enabled);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/BeanDialogCellEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/BeanDialogCellEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/BeanDialogCellEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,60 @@
+package org.drools.eclipse.flow.common.view.property;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.jface.viewers.DialogCellEditor;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for a JavaBean.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class BeanDialogCellEditor extends DialogCellEditor {
+
+    public BeanDialogCellEditor(Composite parent) {
+        super(parent);
+    }
+
+    protected Object openDialogBox(Control cellEditorWindow) {
+        EditBeanDialog dialog = createDialog(cellEditorWindow.getShell());
+        Object value = getValue();
+        if (value != null) {
+            dialog.setValue(value);
+        }
+        int result = dialog.open();
+        if (result == Window.CANCEL) {
+            return null;
+        }
+        return dialog.getValue();
+    }
+    
+    protected abstract EditBeanDialog createDialog(Shell shell);
+
+    protected void updateContents(Object value) {
+        getDefaultLabel().setText(getLabelText(value));
+    }
+    
+    protected String getLabelText(Object value) {
+        if (value == null) {
+            return "";
+        }
+        return value.toString();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditBeanDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditBeanDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditBeanDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,66 @@
+package org.drools.eclipse.flow.common.view.property;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for editing a JavaBean.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class EditBeanDialog extends Dialog {
+
+    private String title;
+    private Object value;
+    
+    protected EditBeanDialog(Shell parentShell, String title) {
+        super(parentShell);
+        this.title = title;
+        setShellStyle(getShellStyle() | SWT.RESIZE);
+    }
+    
+    protected void configureShell(Shell newShell) {
+        super.configureShell(newShell);
+        newShell.setText(title);
+    }
+    
+    protected Point getInitialSize() {
+        return new Point(400, 200);
+    }
+    
+    public Object getValue() {
+        return value;
+    }
+    
+    protected void okPressed() {
+        try {
+            value = updateValue(value);
+            super.okPressed();
+        } catch (IllegalArgumentException e) {
+            // value could not be set, ignoring ok
+        }
+    }
+    
+    protected abstract Object updateValue(Object value);
+    
+    public void setValue(Object value) {
+        this.value = value;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditListDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditListDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/EditListDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,177 @@
+package org.drools.eclipse.flow.common.view.property;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.ListViewer;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for editing a list.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class EditListDialog extends EditBeanDialog {
+    
+    private Class editItemDialogClass;
+    private List newList;
+    private ListViewer listViewer;
+    private Button removeButton;
+    private Button editButton;
+
+    protected EditListDialog(Shell parentShell, String title, Class editItemDialogClass) {
+        super(parentShell, title);
+        this.editItemDialogClass = editItemDialogClass;
+    }
+    
+    protected Control createDialogArea(Composite parent) {
+        Composite composite = (Composite) super.createDialogArea(parent);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 2;
+        composite.setLayout(gridLayout);
+
+        listViewer = new ListViewer(composite, SWT.SINGLE);
+        listViewer.add(newList.toArray());
+        listViewer.addSelectionChangedListener(new ISelectionChangedListener() {
+            public void selectionChanged(SelectionChangedEvent event) {
+                removeButton.setEnabled(!event.getSelection().isEmpty());
+                editButton.setEnabled(!event.getSelection().isEmpty());
+            }
+        });
+        GridData gridData = new GridData();
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.grabExcessVerticalSpace = true;
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.verticalAlignment = GridData.FILL;
+        gridData.verticalSpan = 3;
+        listViewer.getList().setLayoutData(gridData);
+        
+        Button addButton = new Button(composite, SWT.NONE);
+        addButton.setText("Add");
+        gridData = new GridData();
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.verticalAlignment = GridData.BEGINNING;
+        addButton.setLayoutData(gridData);
+        addButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                addItem();
+            }
+        });
+
+        removeButton = new Button(composite, SWT.NONE);
+        removeButton.setText("Remove");
+        removeButton.setEnabled(false);
+        gridData = new GridData();
+        gridData.verticalAlignment = GridData.BEGINNING;
+        removeButton.setLayoutData(gridData);
+        removeButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                removeItem();
+            }
+        });
+
+        editButton = new Button(composite, SWT.NONE);
+        editButton.setText("Edit");
+        editButton.setEnabled(false);
+        gridData = new GridData();
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.verticalAlignment = GridData.BEGINNING;
+        editButton.setLayoutData(gridData);
+        editButton.addSelectionListener(new SelectionAdapter() {
+            public void widgetSelected(SelectionEvent e) {
+                editItem();
+            }
+        });
+
+        return composite;
+    }
+    
+    public void setValue(Object value) {
+        super.setValue(value);
+        this.newList = new ArrayList((List) value);
+    }
+    
+    protected Object updateValue(Object value) {
+        return newList;
+    }
+
+    private void addItem() {
+        EditBeanDialog dialog = createEditItemDialog();
+        dialog.setValue(createItem());
+        int code = dialog.open();
+        Object result = dialog.getValue();
+        if (code != CANCEL) {
+            newList.add(result);
+            listViewer.add(result);
+        }
+    }
+    
+    protected abstract Object createItem();
+    
+    private void editItem() {
+        EditBeanDialog dialog = createEditItemDialog();
+        Iterator iterator = ((StructuredSelection) listViewer.getSelection()).iterator();
+        if (iterator.hasNext()) {
+            dialog.setValue(iterator.next());
+            int code = dialog.open();
+            Object result = dialog.getValue();
+            if (code != CANCEL) {
+                listViewer.update(result, null);
+            }
+        }
+    }
+    
+    private void removeItem() {
+        Iterator iterator = ((StructuredSelection) listViewer.getSelection()).iterator();
+        // single selection only allowed
+        if (iterator.hasNext()) {
+            Object item = iterator.next();
+            newList.remove(item);
+            listViewer.remove(item);
+        }
+    }
+    
+    private EditBeanDialog createEditItemDialog() {
+        try {
+            return (EditBeanDialog) editItemDialogClass.getConstructor(
+                new Class[] { Shell.class }).newInstance(
+                new Object[] { getShell() });
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        } catch (NoSuchMethodException e) {
+            throw new RuntimeException(e);
+        } 
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/ListPropertyDescriptor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/ListPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/view/property/ListPropertyDescriptor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,55 @@
+package org.drools.eclipse.flow.common.view.property;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.reflect.InvocationTargetException;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Property descriptor for a list.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ListPropertyDescriptor extends PropertyDescriptor {
+    
+    private Class cellEditorClass;
+    
+    public ListPropertyDescriptor(Object id, String displayName, Class cellEditorClass) {
+        super(id, displayName);
+        this.cellEditorClass = cellEditorClass;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+        try {
+            CellEditor editor = (CellEditor) cellEditorClass.getConstructor(new Class[] { Composite.class }).newInstance(new Object[] { parent });
+            if (getValidator() != null) {
+                editor.setValidator(getValidator());
+            }
+            return editor;
+        } catch (InvocationTargetException e) {
+            throw new RuntimeException(e);
+        } catch (NoSuchMethodException e) {
+            throw new RuntimeException(e);
+        } catch (InstantiationException e) {
+            throw new RuntimeException(e);
+        } catch (IllegalAccessException e) {
+            throw new RuntimeException(e);
+        }
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFilePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFilePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFilePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,73 @@
+package org.drools.eclipse.flow.ruleflow;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.InputStream;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * Page for creating a new RuleFlow file.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class NewRuleFlowFilePage extends WizardNewFileCreationPage {
+
+    private IWorkbench workbench;
+
+    public NewRuleFlowFilePage(IWorkbench workbench, IStructuredSelection selection) {
+        super("createRuleFlowPage", selection);
+        setTitle("Create RuleFlow File");
+        setDescription("Create a new RuleFlow file");
+        this.workbench = workbench;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        setPageComplete(true);
+    }
+
+    public boolean finish() {
+        String fileName = getFileName();
+        if (!fileName.endsWith(".rf")) {
+            setFileName(fileName + ".rf");
+        }
+        org.eclipse.core.resources.IFile newFile = createNewFile();
+        if (newFile == null)
+            return false;
+        try {
+            IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+            org.eclipse.ui.IWorkbenchPage page = dwindow.getActivePage();
+            if (page != null)
+                IDE.openEditor(page, newFile, true);
+        } catch (PartInitException e) {
+            e.printStackTrace();
+            return false;
+        }
+        return true;
+    }
+    
+    protected InputStream getInitialContents() {
+        String s = "org/drools/eclipse/flow/ruleflow/SampleRuleFlow.rf.template";
+        return getClass().getClassLoader().getResourceAsStream(s);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFileWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFileWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/NewRuleFlowFileWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,49 @@
+package org.drools.eclipse.flow.ruleflow;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * Wizard for creating a new RuleFlow file.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class NewRuleFlowFileWizard extends Wizard implements INewWizard {
+
+    private IWorkbench workbench;
+    private IStructuredSelection selection;
+    private NewRuleFlowFilePage mainPage;
+    
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.workbench = workbench;
+        this.selection = selection;
+        setWindowTitle("New RuleFlow File");
+    }
+    
+    public void addPages() {
+        mainPage = new NewRuleFlowFilePage(workbench, selection);
+        addPage(mainPage);
+     }
+
+    public boolean performFinish() {
+        return mainPage.finish();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ActionWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,92 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.ruleflow.view.property.action.ActionPropertyDescriptor;
+import org.drools.ruleflow.core.ActionNode;
+import org.drools.ruleflow.core.impl.ActionNodeImpl;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+/**
+ * Wrapper for an action node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionWrapper extends NodeWrapper {
+
+	private static final long serialVersionUID = -3618183280436588589L;
+
+	private IPropertyDescriptor[] descriptors;
+
+    public static final String ACTION = "Action";
+
+    public ActionWrapper() {
+        setNode(new ActionNodeImpl());
+        getActionNode().setName("Action");
+    }
+    
+    private void setDescriptors() {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+            new ActionPropertyDescriptor(ACTION, "Action", getActionNode(), ((RuleFlowProcessWrapper) getParent()).getRuleFlowProcess());
+    }
+    
+    public ActionNode getActionNode() {
+        return (ActionNode) getNode();
+    }
+    
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+    	if (descriptors == null) {
+    		setDescriptors();
+    	}
+        return descriptors;
+    }
+
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return getOutgoingConnections().isEmpty();
+    }
+    
+    public Object getPropertyValue(Object id) {
+        if (ACTION.equals(id)) {
+        	Object action = getActionNode().getAction();
+            return action == null ? "" : action.toString();
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (ACTION.equals(id)) {
+        	getActionNode().setAction(null);
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (ACTION.equals(id)) {
+        	getActionNode().setAction(value);
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,56 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.ruleflow.core.Connection;
+import org.drools.ruleflow.core.Node;
+import org.drools.ruleflow.core.impl.ConnectionImpl;
+
+/**
+ * Wrapper for a connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionWrapper extends ElementConnection {
+		
+	private static final long serialVersionUID = 400L;
+
+	private Connection connection;
+	
+	public ConnectionWrapper(int type) {
+		super(type);
+	}
+	
+	public ConnectionWrapper(NodeWrapper source, NodeWrapper target, int type) {
+        super(source, target, type);
+    }
+	
+	public void disconnect() {
+		super.disconnect();
+		connection.terminate();
+		connection = null;
+	}
+	
+	public void connect(ElementWrapper source, ElementWrapper target) {
+		super.connect(source, target);
+		Node from = ((NodeWrapper) getSource()).getNode();
+		Node to = ((NodeWrapper) getTarget()).getNode();
+		int type = getType();
+		connection = new ConnectionImpl(from, to, type);		
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapperFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapperFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/ConnectionWrapperFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
+
+/**
+ * Factory for creating a connection wrapper.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConnectionWrapperFactory extends ElementConnectionFactory {
+	
+	public ConnectionWrapperFactory(int type) {
+		super(type);
+	}
+	
+	public ElementConnection createElementConnection() {
+		ConnectionWrapper connection = new ConnectionWrapper(getType());
+		return connection;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/EndNodeWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,47 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.ruleflow.core.EndNode;
+import org.drools.ruleflow.core.impl.EndNodeImpl;
+
+/**
+ * Wrapper for an end node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EndNodeWrapper extends NodeWrapper {
+
+    private static final long serialVersionUID = 400L;
+
+    public EndNodeWrapper() {
+        setNode(new EndNodeImpl());
+        getEndNode().setName("End");
+    }
+    
+    public EndNode getEndNode() {
+        return (EndNode) getNode();
+    }
+    
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return false;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/JoinWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,88 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.ruleflow.core.Connection;
+import org.drools.ruleflow.core.Join;
+import org.drools.ruleflow.core.impl.JoinImpl;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+/**
+ * Wrapper for a join node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class JoinWrapper extends NodeWrapper {
+
+    private static final long serialVersionUID = 400L;
+    private static IPropertyDescriptor[] descriptors;
+
+    public static final String TYPE = "type";
+    static {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+            new ComboBoxPropertyDescriptor(TYPE, "Type", new String[] { "", "AND", "XOR" });
+    }
+    
+    public JoinWrapper() {
+        setNode(new JoinImpl());
+        getJoin().setName("Join");
+    }
+    
+    public Join getJoin() {
+        return (Join) getNode();
+    }
+    
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return true;
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return connection.getType() == Connection.TYPE_NORMAL
+        	&& getOutgoingConnections().isEmpty();
+    }
+
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    public Object getPropertyValue(Object id) {
+        if (TYPE.equals(id)) {
+            return new Integer(getJoin().getType());
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (TYPE.equals(id)) {
+            getJoin().setType(Join.TYPE_UNDEFINED);
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (TYPE.equals(id)) {
+            getJoin().setType(((Integer) value).intValue());
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/MilestoneWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,91 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.ruleflow.view.property.constraint.MilestoneConstraintPropertyDescriptor;
+import org.drools.ruleflow.core.MilestoneNode;
+import org.drools.ruleflow.core.impl.MilestoneNodeImpl;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+/**
+ * Wrapper for a milestone node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneWrapper extends NodeWrapper {
+
+	private static final long serialVersionUID = -5976489437109982927L;
+	private IPropertyDescriptor[] descriptors;
+
+    public static final String CONSTRAINT = "Constraint";
+
+    public MilestoneWrapper() {
+        setNode(new MilestoneNodeImpl());
+        getMilestoneNode().setName("Milestone");
+    }
+    
+    private void setDescriptors() {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+            new MilestoneConstraintPropertyDescriptor(CONSTRAINT, "Constraint", getMilestoneNode(), ((RuleFlowProcessWrapper) getParent()).getRuleFlowProcess());
+    }
+    
+    public MilestoneNode getMilestoneNode() {
+        return (MilestoneNode) getNode();
+    }
+    
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+    	if (descriptors == null) {
+    		setDescriptors();
+    	}
+        return descriptors;
+    }
+
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return getOutgoingConnections().isEmpty();
+    }
+    
+    public Object getPropertyValue(Object id) {
+        if (CONSTRAINT.equals(id)) {
+        	String constraint = getMilestoneNode().getConstraint();
+            return constraint == null ? "" : constraint;
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (CONSTRAINT.equals(id)) {
+        	getMilestoneNode().setConstraint("");
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (CONSTRAINT.equals(id)) {
+        	getMilestoneNode().setConstraint((String) value);
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/NodeWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/NodeWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/NodeWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,50 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.ruleflow.core.Node;
+
+/**
+ * Wrapper for a node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public abstract class NodeWrapper extends DefaultElementWrapper {
+	
+    protected void setNode(Node node) {
+        setElement(node);
+    }
+    
+    public Node getNode() {
+        return (Node) getElement();
+    }
+    
+    public String getId() {
+        long id = getNode().getId();
+        return id == -1 ? null : getNode().getId() + "-Wrapper";
+    }
+
+    public String getName() {
+        return getNode().getName();
+    }
+
+    public void internalSetName(String name) {
+        getNode().setName(name);    
+        notifyListeners(CHANGE_NAME);
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowProcessWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowProcessWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleFlowProcessWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,85 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ProcessWrapper;
+import org.drools.ruleflow.common.core.Process;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.ruleflow.core.impl.RuleFlowProcessImpl;
+
+/**
+ * Wrapper for a RuleFlow process.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowProcessWrapper extends ProcessWrapper {
+
+	private static final long serialVersionUID = 400L;
+
+//	private static IPropertyDescriptor[] descriptors;
+//
+//    public static final String VARIABLES = "variables";
+//    static {
+//        descriptors = new IPropertyDescriptor[ProcessWrapper.descriptors.length + 1];
+//        System.arraycopy(ProcessWrapper.descriptors, 0, descriptors, 0, ProcessWrapper.descriptors.length);
+//        descriptors[descriptors.length - 1] = 
+//            new ListPropertyDescriptor(VARIABLES, "Variables", VariableListCellEditor.class);
+//   }
+    
+    public RuleFlowProcess getRuleFlowProcess() {
+        return (RuleFlowProcess) getProcess();
+    }
+    
+    protected Process createProcess() {
+        return new RuleFlowProcessImpl();
+    }
+
+    protected void internalAddElement(ElementWrapper element) {
+        getRuleFlowProcess().addNode(((NodeWrapper) element).getNode()); 
+    }
+
+    protected void internalRemoveElement(ElementWrapper element) {
+        getRuleFlowProcess().removeNode(((NodeWrapper) element).getNode()); 
+    }
+    
+//    public IPropertyDescriptor[] getPropertyDescriptors() {
+//        return descriptors;
+//    }
+//
+//    public Object getPropertyValue(Object id) {
+//        if (VARIABLES.equals(id)) {
+//            return getRuleFlowProcess().getVariables();
+//        }
+//        return super.getPropertyValue(id);
+//    }
+//
+//    public void resetPropertyValue(Object id) {
+//        if (VARIABLES.equals(id)) {
+//            getRuleFlowProcess().setVariables(new ArrayList());
+//        } else {
+//            super.resetPropertyValue(id);
+//        }
+//    }
+//
+//    public void setPropertyValue(Object id, Object value) {
+//        if (VARIABLES.equals(id)) {
+//            getRuleFlowProcess().setVariables((List) value);
+//        } else {
+//            super.setPropertyValue(id, value);
+//        }
+//    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/RuleSetNodeWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,87 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.ruleflow.core.RuleSetNode;
+import org.drools.ruleflow.core.impl.RuleSetNodeImpl;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Wrapper for a RuleSet node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleSetNodeWrapper extends NodeWrapper {
+
+    private static final long serialVersionUID = 400L;
+    private static IPropertyDescriptor[] descriptors;
+
+    public static final String RULE_FLOW_GROUP = "RuleFlowGroup";
+    static {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+            new TextPropertyDescriptor(RULE_FLOW_GROUP, "RuleFlowGroup");
+    }
+
+    public RuleSetNodeWrapper() {
+        setNode(new RuleSetNodeImpl());
+        getRuleSetNode().setName("RuleSet");
+        getRuleSetNode().setRuleFlowGroup("");
+    }
+    
+    public RuleSetNode getRuleSetNode() {
+        return (RuleSetNode) getNode();
+    }
+    
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return getOutgoingConnections().isEmpty();
+    }
+    
+    public Object getPropertyValue(Object id) {
+        if (RULE_FLOW_GROUP.equals(id)) {
+            return getRuleSetNode().getRuleFlowGroup();
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (RULE_FLOW_GROUP.equals(id)) {
+        	getRuleSetNode().setRuleFlowGroup("");
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (RULE_FLOW_GROUP.equals(id)) {
+            getRuleSetNode().setRuleFlowGroup((String) value);
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SplitWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,140 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.IOException;
+import java.io.ObjectInputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.ruleflow.view.property.constraint.ConstraintsPropertyDescriptor;
+import org.drools.ruleflow.core.Connection;
+import org.drools.ruleflow.core.Constraint;
+import org.drools.ruleflow.core.Split;
+import org.drools.ruleflow.core.impl.SplitImpl;
+import org.eclipse.ui.views.properties.ComboBoxPropertyDescriptor;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+
+/**
+ * Wrapper for a split node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SplitWrapper extends NodeWrapper {
+
+    public static final String TYPE = "type";
+    public static final String CONSTRAINTS = "constraints";
+    
+    private static final long serialVersionUID = 400L;
+    private transient IPropertyDescriptor[] descriptors;
+
+    public SplitWrapper() {
+        setNode(new SplitImpl());
+        getSplit().setName("Split");
+        setDescriptors();
+    }
+     
+    private void setDescriptors() {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+            new ComboBoxPropertyDescriptor(TYPE, "Type", 
+                new String[] { "", "AND", "XOR", "OR" });
+    }
+    
+    public Split getSplit() {
+        return (Split) getNode();
+    }
+    
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return connection.getType() == Connection.TYPE_NORMAL;
+    }
+
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        if (getParent() != null && (getSplit().getType() == SplitImpl.TYPE_XOR
+                || getSplit().getType() == SplitImpl.TYPE_OR)) {
+            IPropertyDescriptor[] result = new IPropertyDescriptor[descriptors.length + 1];
+            System.arraycopy(descriptors, 0, result, 0, descriptors.length);
+            result[descriptors.length] = 
+                new ConstraintsPropertyDescriptor(CONSTRAINTS, "Constraints", getSplit(), ((RuleFlowProcessWrapper) getParent()).getRuleFlowProcess());
+            return result;
+        }
+        return descriptors;
+    }
+
+    public Object getPropertyValue(Object id) {
+        if (TYPE.equals(id)) {
+            return new Integer(getSplit().getType());
+        }
+        if (CONSTRAINTS.equals(id)) {
+        	return getSplit().getType() == SplitImpl.TYPE_XOR
+        		|| getSplit().getType() == SplitImpl.TYPE_OR
+        		? new MyHashMap(getSplit().getConstraints()) : new MyHashMap();
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (TYPE.equals(id)) {
+            getSplit().setType(Split.TYPE_UNDEFINED);
+        } else if (CONSTRAINTS.equals(id)) {
+        	for (Iterator it = getSplit().getOutgoingConnections().iterator(); it.hasNext(); ) {
+        		Connection connection = (Connection) it.next();
+        		getSplit().setConstraint(connection, null);
+        	}
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (TYPE.equals(id)) {
+            getSplit().setType(((Integer) value).intValue());
+        } else if (CONSTRAINTS.equals(id)) {
+        	Iterator iterator = ((Map) value).entrySet().iterator();
+        	while (iterator.hasNext()) {
+				Map.Entry element = (Map.Entry) iterator.next();
+				getSplit().setConstraint((Connection) element.getKey(), (Constraint) element.getValue()); 
+			}
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+    
+    private void readObject(ObjectInputStream aInputStream) throws ClassNotFoundException, IOException {
+        aInputStream.defaultReadObject();
+        setDescriptors();
+    }
+
+    public class MyHashMap extends HashMap {
+		private static final long serialVersionUID = -1748055291307174539L;
+		public MyHashMap() {
+    	}
+    	public MyHashMap(Map map) {
+    		super(map);
+    	}
+		public String toString() {
+    		return "";
+    	}
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/StartNodeWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,49 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.ruleflow.core.Connection;
+import org.drools.ruleflow.core.StartNode;
+import org.drools.ruleflow.core.impl.StartNodeImpl;
+
+/**
+ * Wrapper for a start node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StartNodeWrapper extends NodeWrapper {
+
+    private static final long serialVersionUID = 400L;
+
+    public StartNodeWrapper() {
+        setNode(new StartNodeImpl());
+        setName("Start");
+    }
+    
+    public StartNode getStartNode() {
+        return (StartNode) getNode();
+    }
+    
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return false;
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return connection.getType() == Connection.TYPE_NORMAL
+    		&& getOutgoingConnections().isEmpty();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/core/SubFlowWrapper.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,88 @@
+package org.drools.eclipse.flow.ruleflow.core;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper;
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.ruleflow.core.SubFlowNode;
+import org.drools.ruleflow.core.impl.SubFlowNodeImpl;
+import org.eclipse.ui.views.properties.IPropertyDescriptor;
+import org.eclipse.ui.views.properties.TextPropertyDescriptor;
+
+/**
+ * Wrapper for a SubFlow node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubFlowWrapper extends NodeWrapper {
+
+	private static final long serialVersionUID = 3668348577732020324L;
+    private static IPropertyDescriptor[] descriptors;
+    
+    public static final String PROCESS_ID = "ProcessId";
+
+    static {
+        descriptors = new IPropertyDescriptor[DefaultElementWrapper.descriptors.length + 1];
+        System.arraycopy(DefaultElementWrapper.descriptors, 0, descriptors, 0, DefaultElementWrapper.descriptors.length);
+        descriptors[descriptors.length - 1] = 
+        	new TextPropertyDescriptor(PROCESS_ID, "ProcessId");
+    }
+    
+    public SubFlowWrapper() {
+        setNode(new SubFlowNodeImpl());
+        getSubFlowNode().setName("SubFlow");
+    }
+    
+    public SubFlowNode getSubFlowNode() {
+        return (SubFlowNode) getNode();
+    }
+    
+    public IPropertyDescriptor[] getPropertyDescriptors() {
+        return descriptors;
+    }
+
+    public boolean acceptsIncomingConnection(ElementConnection connection) {
+        return getIncomingConnections().isEmpty();
+    }
+
+    public boolean acceptsOutgoingConnection(ElementConnection connection) {
+        return getOutgoingConnections().isEmpty();
+    }
+    
+    public Object getPropertyValue(Object id) {
+        if (PROCESS_ID.equals(id)) {
+        	String processId = getSubFlowNode().getProcessId();
+            return processId == null ? "" : processId;
+        }
+        return super.getPropertyValue(id);
+    }
+
+    public void resetPropertyValue(Object id) {
+        if (PROCESS_ID.equals(id)) {
+        	getSubFlowNode().setProcessId("");
+        } else {
+            super.resetPropertyValue(id);
+        }
+    }
+
+    public void setPropertyValue(Object id, Object value) {
+        if (PROCESS_ID.equals(id)) {
+        	getSubFlowNode().setProcessId((String) value);
+        } else {
+            super.setPropertyValue(id, value);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,165 @@
+package org.drools.eclipse.flow.ruleflow.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.GenericModelEditor;
+import org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper;
+import org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.editor.editpart.RuleFlowEditPartFactory;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.EditPartFactory;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.jface.dialogs.ProgressMonitorDialog;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.part.FileEditorInput;
+
+import com.thoughtworks.xstream.XStream;
+
+/**
+ * Graphical editor for a RuleFlow.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowModelEditor extends GenericModelEditor {
+
+    protected EditPartFactory createEditPartFactory() {
+        return new RuleFlowEditPartFactory();
+    }
+
+    protected PaletteRoot createPalette() {
+        return RuleFlowPaletteFactory.createPalette();
+    }
+
+    protected Object createModel() {
+        RuleFlowProcessWrapper result = new RuleFlowProcessWrapper();
+        StartNodeWrapper start = new StartNodeWrapper();
+        start.setConstraint(new Rectangle(100, 100, -1, -1));
+        result.addElement(start);
+        IFile file = ((IFileEditorInput)getEditorInput()).getFile();
+        String name = file.getName();
+        result.setName(name.substring(0, name.length() - 3));
+        return result;
+    }
+    
+    public RuleFlowProcessWrapper getRuleFlowModel() {
+        return (RuleFlowProcessWrapper) getModel();
+    }
+
+    protected void createOutputStream(OutputStream os) throws IOException {
+    	createOutputStream(os, true);
+    }
+
+    
+    protected void createOutputStream(OutputStream os, boolean includeGraphics) throws IOException {
+        OutputStreamWriter writer = new OutputStreamWriter(os);
+        try {
+            XStream stream = new XStream();
+            stream.setMode(XStream.ID_REFERENCES);
+            if (includeGraphics) {
+            	stream.toXML(getRuleFlowModel(), writer);
+            } else {
+            	stream.toXML(getRuleFlowModel().getProcess(), writer);
+            }
+            writer.close();
+        } catch (Throwable t) {
+            DroolsEclipsePlugin.log(t);
+        }
+    }
+    
+    public void doSave(IProgressMonitor monitor) {
+        super.doSave(monitor);
+        // save process as separate model file as well
+        IFile file = ((IFileEditorInput) getEditorInput()).getFile();
+        final IFile modelFile = getModelFile(file);
+
+		if (!modelFile.exists()) {
+	        WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+	            public void execute(final IProgressMonitor monitor)
+	                    throws CoreException {
+	                try {
+	                    ByteArrayOutputStream out = new ByteArrayOutputStream();
+	                    createOutputStream(out, false);
+	                    modelFile.create(new ByteArrayInputStream(out.toByteArray()),
+	                            true, monitor);
+	                    out.close();
+	                } catch (Exception e) {
+	                    e.printStackTrace();
+	                }
+	            }
+	        };
+	        
+	        try {
+	            new ProgressMonitorDialog(getSite().getWorkbenchWindow().getShell())
+	                    .run(false, true, op);
+	            setInput(new FileEditorInput(file));
+	            getCommandStack().markSaveLocation();
+	        } catch (Exception e) {
+	            e.printStackTrace();
+	        }
+		} else {
+	        ByteArrayOutputStream out = new ByteArrayOutputStream();
+	        try {
+	        	createOutputStream(out, false);
+	            modelFile.setContents(
+	        		new ByteArrayInputStream(out.toByteArray()),
+	        		true, false, monitor);
+	            out.close();
+	        } catch (Throwable t) {
+	        	DroolsEclipsePlugin.log(t);
+	        }
+		}
+    }
+
+	private IFile getModelFile(IFile file) {
+		IProject project = file.getProject();
+		IPath path = file.getProjectRelativePath();
+		String fileName = file.getName().substring(0, file.getName().length() - 2) + "rfm";
+		IPath modelPath = path.removeLastSegments(1).append(fileName);
+		IFile modelFile = project.getFile(modelPath);
+		return modelFile;
+	}
+
+    protected void createInputStream(InputStream is) throws Exception {
+        InputStreamReader reader = new InputStreamReader(is);
+        XStream stream = new XStream();
+        stream.setMode(XStream.ID_REFERENCES);
+        
+        ClassLoader oldLoader = Thread.currentThread().getContextClassLoader();
+        ClassLoader newLoader = this.getClass().getClassLoader();
+        try {
+            Thread.currentThread().setContextClassLoader(newLoader);
+            setModel(stream.fromXML(reader));
+        } finally {
+            Thread.currentThread().setContextClassLoader(oldLoader);
+        }
+        reader.close();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,190 @@
+package org.drools.eclipse.flow.ruleflow.editor;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
+import org.drools.eclipse.flow.ruleflow.core.ActionWrapper;
+import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper;
+import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapperFactory;
+import org.drools.eclipse.flow.ruleflow.core.EndNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.JoinWrapper;
+import org.drools.eclipse.flow.ruleflow.core.MilestoneWrapper;
+import org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SplitWrapper;
+import org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SubFlowWrapper;
+import org.drools.ruleflow.core.Connection;
+import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
+import org.eclipse.gef.palette.ConnectionCreationToolEntry;
+import org.eclipse.gef.palette.MarqueeToolEntry;
+import org.eclipse.gef.palette.PaletteContainer;
+import org.eclipse.gef.palette.PaletteDrawer;
+import org.eclipse.gef.palette.PaletteGroup;
+import org.eclipse.gef.palette.PaletteRoot;
+import org.eclipse.gef.palette.SelectionToolEntry;
+import org.eclipse.gef.palette.ToolEntry;
+import org.eclipse.gef.requests.CreationFactory;
+import org.eclipse.gef.requests.SimpleFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+
+/**
+ * Factory for creating a RuleFlow palette.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowPaletteFactory {
+
+    public static PaletteRoot createPalette() {
+        PaletteRoot flowPalette = new PaletteRoot();
+        flowPalette.addAll(createCategories(flowPalette));
+        return flowPalette;
+    }
+    
+    private static List createCategories(PaletteRoot root) {
+        List categories = new ArrayList();
+        categories.add(createControlGroup(root));
+        categories.add(createComponentsDrawer());
+        return categories;
+    }
+
+    private static PaletteContainer createComponentsDrawer() {
+
+        PaletteDrawer drawer = new PaletteDrawer("Components", null);
+
+        List entries = new ArrayList();
+
+        CombinedTemplateCreationEntry combined = new CombinedTemplateCreationEntry(
+            "Start",
+            "Create a new Start",
+            StartNodeWrapper.class,
+            new SimpleFactory(StartNodeWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_start.gif")),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_start.gif"))
+        );
+        entries.add(combined);
+        
+        combined = new CombinedTemplateCreationEntry(
+            "End",
+            "Create a new End",
+            EndNodeWrapper.class,
+            new SimpleFactory(EndNodeWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_stop.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_stop.gif"))
+        );
+        entries.add(combined);
+                
+        combined = new CombinedTemplateCreationEntry(
+            "RuleFlowGroup",
+            "Create a new RuleFlowGroup",
+            RuleSetNodeWrapper.class,
+            new SimpleFactory(RuleSetNodeWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/activity.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/activity.gif"))
+        );
+        entries.add(combined);
+            
+        combined = new CombinedTemplateCreationEntry(
+            "Split",
+            "Create a new Split",
+            SplitWrapper.class,
+            new SimpleFactory(SplitWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/split.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/split.gif"))
+        );
+        entries.add(combined);
+                    
+        combined = new CombinedTemplateCreationEntry(
+            "Join",
+            "Create a new Join",
+            JoinWrapper.class,
+            new SimpleFactory(JoinWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/join.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/join.gif"))
+        );
+        entries.add(combined);
+                        
+        combined = new CombinedTemplateCreationEntry(
+            "Milestone",
+            "Create a new Milestone",
+            MilestoneWrapper.class,
+            new SimpleFactory(MilestoneWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/question.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/question.gif"))
+        );
+        entries.add(combined);
+                            
+        combined = new CombinedTemplateCreationEntry(
+            "SubFlow",
+            "Create a new SubFlow",
+            SubFlowWrapper.class,
+            new SimpleFactory(SubFlowWrapper.class),
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif"))
+        );
+        entries.add(combined);
+                                
+        combined = new CombinedTemplateCreationEntry(
+                "Action",
+                "Create a new Action",
+                ActionWrapper.class,
+                new SimpleFactory(ActionWrapper.class),
+                ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/action.gif")), 
+                ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/action.gif"))
+            );
+            entries.add(combined);
+                                    
+        drawer.addAll(entries);
+        return drawer;
+    }
+
+    private static PaletteContainer createControlGroup(PaletteRoot root) {
+        PaletteGroup controlGroup = new PaletteGroup("Control Group");
+
+        List entries = new ArrayList();
+
+        ToolEntry tool = new SelectionToolEntry();
+        entries.add(tool);
+        root.setDefaultEntry(tool);
+
+        tool = new MarqueeToolEntry();
+        entries.add(tool);
+        
+        final ElementConnectionFactory normalConnectionFactory = new ConnectionWrapperFactory(Connection.TYPE_NORMAL);
+
+        tool = new ConnectionCreationToolEntry(
+            "Connection Creation",
+            "Creating connections",
+            new CreationFactory() {
+                public Object getNewObject() {
+                	return normalConnectionFactory.createElementConnection();
+                }
+                public Object getObjectType() {
+                	return ConnectionWrapper.class;
+                }
+            },
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/connection.gif")), 
+            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/connection.gif"))
+        );
+        entries.add(tool);
+        
+        controlGroup.addAll(entries);
+        return controlGroup;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/action/CheckRuleFlowAction.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/action/CheckRuleFlowAction.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/action/CheckRuleFlowAction.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,74 @@
+package org.drools.eclipse.flow.ruleflow.editor.action;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor;
+import org.drools.ruleflow.core.RuleFlowProcessValidationError;
+import org.drools.ruleflow.core.impl.RuleFlowProcessValidatorImpl;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.ui.IEditorActionDelegate;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.actions.ActionDelegate;
+
+/**
+ * Action for checking a RuleFlow.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class CheckRuleFlowAction extends ActionDelegate implements IEditorActionDelegate {
+
+    private IEditorPart editor;
+    
+    public void run(IAction action) {
+        execute();
+    }
+
+    public void setActiveEditor(IAction action, IEditorPart targetEditor) {
+        editor = targetEditor;
+    }
+
+    private void execute() {
+        RuleFlowProcessValidationError[] errors = RuleFlowProcessValidatorImpl.getInstance().validateProcess(
+            ((RuleFlowModelEditor) editor).getRuleFlowModel().getRuleFlowProcess());
+        if (errors.length == 0) {
+            MessageDialog.openInformation(editor.getSite().getShell(),
+            "Check RuleFlow", "The RuleFlow model was checked successfully.");
+        } else {
+			StringBuffer error = new StringBuffer(errors[0].toString());
+			error.append("\n");
+            for (int i = 1; i < errors.length; i++) {
+				error.append(" ");
+				error.append(errors[i]);
+				error.append("\n");
+            }
+            ErrorDialog.openError(editor.getSite().getShell(),
+                "Check RuleFlow", "The RuleFlow model contains errors.", 
+                new Status(
+                    IStatus.ERROR,
+                    DroolsEclipsePlugin.getDefault().getBundle().getSymbolicName(),
+                    IStatus.ERROR,
+                    error.toString(),
+                    null)
+                );
+        }
+
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ActionEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ActionEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/ActionEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for an action node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 255, 250, 205);
+    
+    protected IFigure createFigure() {
+        return new RuleSetNodeFigure();
+    }
+    
+    public static class RuleSetNodeFigure extends ElementFigure {
+        
+        private static final Image ICON = ImageDescriptor.createFromURL(
+    		DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/action.gif")).createImage();
+            
+        private RoundedRectangle rectangle;
+        
+        protected void customizeFigure() {
+            rectangle = new RoundedRectangle();
+            rectangle.setCornerDimensions(new Dimension(25, 25));
+            add(rectangle, 0);
+            rectangle.setBackgroundColor(color);
+            rectangle.setBounds(getBounds());
+            setSelected(false);
+            setIcon(ICON);
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            this.rectangle.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            rectangle.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/EndNodeEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/EndNodeEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/EndNodeEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * EditPart for an end node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class EndNodeEditPart extends ElementEditPart {
+
+    protected IFigure createFigure() {
+        return new EndNodeFigure();
+    }
+
+    public static class EndNodeFigure extends ElementFigure {
+        
+        private static final Image icon = ImageDescriptor.createFromURL(
+        	DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_stop.gif")).createImage();
+            
+        protected void customizeFigure() {
+            setIcon(icon);
+            setBorder(new LineBorder(1));
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/JoinEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/JoinEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/JoinEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,81 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.EllipseAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for a join node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class JoinEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 70, 130, 180);
+    
+    protected IFigure createFigure() {
+        return new JoinFigure();
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public class JoinFigure extends ElementFigure {
+        
+        private Ellipse ellipse;
+        
+        protected void customizeFigure() {
+            ellipse = new Ellipse();
+            add(ellipse, 0);
+            ellipse.setBackgroundColor(color);
+            ellipse.setBounds(getBounds());
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            ellipse.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            ellipse.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/MilestoneEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/MilestoneEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/MilestoneEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for a RuleSet node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 255, 250, 205);
+    
+    protected IFigure createFigure() {
+        return new RuleSetNodeFigure();
+    }
+    
+    public static class RuleSetNodeFigure extends ElementFigure {
+        
+        private static final Image ICON = ImageDescriptor.createFromURL(
+    		DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/question.gif")).createImage();
+            
+        private RoundedRectangle rectangle;
+        
+        protected void customizeFigure() {
+            rectangle = new RoundedRectangle();
+            rectangle.setCornerDimensions(new Dimension(25, 25));
+            add(rectangle, 0);
+            rectangle.setBackgroundColor(color);
+            rectangle.setBounds(getBounds());
+            setSelected(false);
+            setIcon(ICON);
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            this.rectangle.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            rectangle.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowConnectionEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowConnectionEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowConnectionEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.core.ElementConnectionFactory;
+import org.drools.eclipse.flow.common.editor.editpart.ElementConnectionEditPart;
+import org.drools.eclipse.flow.ruleflow.core.ConnectionWrapperFactory;
+import org.drools.ruleflow.core.Connection;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.PolygonDecoration;
+import org.eclipse.draw2d.PolylineConnection;
+import org.eclipse.draw2d.geometry.PointList;
+
+/**
+ * EditPart for an element connection.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowConnectionEditPart extends ElementConnectionEditPart {
+    
+	protected ElementConnectionFactory getDefaultElementConnectionFactory() {
+		return new ConnectionWrapperFactory(Connection.TYPE_NORMAL);
+	}
+	
+    protected IFigure createFigure() {
+        PolylineConnection result = (PolylineConnection) super.createFigure();
+        if (((ElementConnection) getModel()).getType() == Connection.TYPE_ABORT) {
+	        PolygonDecoration decoration = new PolygonDecoration();
+	        PointList decorationPointList = new PointList();
+	        decorationPointList.addPoint(0,0);
+	        decorationPointList.addPoint(-1,1);
+	        decorationPointList.addPoint(-2,0);
+	        decorationPointList.addPoint(-1,-1);
+	        decoration.setTemplate(decorationPointList);
+	        result.setSourceDecoration(decoration);
+        }
+        return result;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleFlowEditPartFactory.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,69 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.core.ElementConnection;
+import org.drools.eclipse.flow.common.editor.editpart.ProcessEditPart;
+import org.drools.eclipse.flow.ruleflow.core.ActionWrapper;
+import org.drools.eclipse.flow.ruleflow.core.EndNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.JoinWrapper;
+import org.drools.eclipse.flow.ruleflow.core.MilestoneWrapper;
+import org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper;
+import org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SplitWrapper;
+import org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper;
+import org.drools.eclipse.flow.ruleflow.core.SubFlowWrapper;
+import org.eclipse.gef.EditPart;
+import org.eclipse.gef.EditPartFactory;
+
+/**
+ * Factory for RuleFlow EditParts.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowEditPartFactory implements EditPartFactory {
+
+    public EditPart createEditPart(EditPart context, Object model) {
+        EditPart result = null;
+        if (model instanceof RuleFlowProcessWrapper) {
+            result = new ProcessEditPart();
+        } else if (model instanceof RuleSetNodeWrapper) {
+            result = new RuleSetNodeEditPart();
+        } else if (model instanceof ElementConnection) {
+            result = new RuleFlowConnectionEditPart();
+        } else if (model instanceof StartNodeWrapper) {
+            result = new StartNodeEditPart();
+        } else if (model instanceof EndNodeWrapper) {
+            result = new EndNodeEditPart();
+        } else if (model instanceof SplitWrapper) {
+            result = new SplitEditPart();
+        } else if (model instanceof JoinWrapper) {
+            result = new JoinEditPart();
+        } else if (model instanceof MilestoneWrapper) {
+            result = new MilestoneEditPart();
+        } else if (model instanceof SubFlowWrapper) {
+            result = new SubFlowEditPart();
+        } else if (model instanceof ActionWrapper) {
+            result = new ActionEditPart();
+        } else {
+            throw new IllegalArgumentException(
+                "Unknown model object " + model);
+        }
+        result.setModel(model);
+        return result;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleSetNodeEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleSetNodeEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/RuleSetNodeEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,64 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for a RuleSet node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleSetNodeEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 255, 250, 205);
+    
+    protected IFigure createFigure() {
+        return new RuleSetNodeFigure();
+    }
+    
+    public class RuleSetNodeFigure extends ElementFigure {
+        
+        private RoundedRectangle rectangle;
+        
+        protected void customizeFigure() {
+            rectangle = new RoundedRectangle();
+            rectangle.setCornerDimensions(new Dimension(25, 25));
+            add(rectangle, 0);
+            rectangle.setBackgroundColor(color);
+            rectangle.setBounds(getBounds());
+            setSelected(false);
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            this.rectangle.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            rectangle.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SplitEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SplitEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SplitEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,81 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.ConnectionAnchor;
+import org.eclipse.draw2d.Ellipse;
+import org.eclipse.draw2d.EllipseAnchor;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.gef.ConnectionEditPart;
+import org.eclipse.gef.Request;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for a split node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SplitEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 70, 130, 180);
+    
+    protected IFigure createFigure() {
+        return new SplitFigure();
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(ConnectionEditPart connection) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(ConnectionEditPart connection) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getSourceConnectionAnchor(Request request) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public ConnectionAnchor getTargetConnectionAnchor(Request request) {
+        return new EllipseAnchor(getFigure());
+    }
+
+    public class SplitFigure extends ElementFigure {
+        
+        private Ellipse ellipse;
+        
+        protected void customizeFigure() {
+            ellipse = new Ellipse();
+            add(ellipse, 0);
+            ellipse.setBackgroundColor(color);
+            ellipse.setBounds(getBounds());
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            ellipse.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            ellipse.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/StartNodeEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/StartNodeEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/StartNodeEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.LineBorder;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Image;
+
+/**
+ * EditPart for a start node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class StartNodeEditPart extends ElementEditPart {
+
+    protected IFigure createFigure() {
+        return new StartNodeFigure();
+    }
+
+    public static class StartNodeFigure extends ElementFigure {
+        
+        private static final Image icon = ImageDescriptor.createFromURL(
+    		DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process_start.gif")).createImage();
+        
+        protected void customizeFigure() {
+            setIcon(icon);
+            setBorder(new LineBorder(1));
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            ((LineBorder) getBorder()).setWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SubFlowEditPart.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SubFlowEditPart.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/editpart/SubFlowEditPart.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,71 @@
+package org.drools.eclipse.flow.ruleflow.editor.editpart;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.editor.editpart.ElementEditPart;
+import org.drools.eclipse.flow.common.editor.editpart.figure.ElementFigure;
+import org.eclipse.draw2d.IFigure;
+import org.eclipse.draw2d.RoundedRectangle;
+import org.eclipse.draw2d.geometry.Dimension;
+import org.eclipse.draw2d.geometry.Rectangle;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Display;
+
+/**
+ * EditPart for a SubFlow node.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class SubFlowEditPart extends ElementEditPart {
+
+    private static final Color color = new Color(Display.getCurrent(), 255, 250, 205);
+    
+    protected IFigure createFigure() {
+        return new SubFlowNodeFigure();
+    }
+    
+    public static class SubFlowNodeFigure extends ElementFigure {
+        
+        private static final Image ICON = ImageDescriptor.createFromURL(
+        		DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif")).createImage();
+                
+        private RoundedRectangle rectangle;
+        
+        protected void customizeFigure() {
+            rectangle = new RoundedRectangle();
+            rectangle.setCornerDimensions(new Dimension(25, 25));
+            add(rectangle, 0);
+            rectangle.setBackgroundColor(color);
+            rectangle.setBounds(getBounds());
+            setSelected(false);
+            setIcon(ICON);
+        }
+        
+        public void setBounds(Rectangle rectangle) {
+            super.setBounds(rectangle);
+            this.rectangle.setBounds(rectangle);
+        }
+        
+        public void setSelected(boolean b) {
+            super.setSelected(b);
+            rectangle.setLineWidth(b ? 3 : 1);
+            repaint();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionCellEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionCellEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionCellEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.ruleflow.view.property.action;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.core.ActionNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for an action.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionCellEditor extends BeanDialogCellEditor {
+
+    private RuleFlowProcess process;
+    private ActionNode actionNode;
+    
+    public ActionCellEditor(Composite parent, RuleFlowProcess process, ActionNode actionNode) {
+        super(parent);
+        this.process = process;
+        this.actionNode = actionNode;
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new ActionDialog(shell, process, actionNode);
+    }
+    
+    protected String getLabelText(Object value) {
+    	if (actionNode == null || actionNode.getAction() == null) {
+    		return "";
+    	}
+        return actionNode.getAction().toString();
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,216 @@
+package org.drools.eclipse.flow.ruleflow.view.property.action;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.eclipse.flow.ruleflow.view.property.constraint.RuleFlowGlobalsDialog;
+import org.drools.eclipse.flow.ruleflow.view.property.constraint.RuleFlowImportsDialog;
+import org.drools.ruleflow.core.ActionNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.ruleflow.core.impl.DroolsConsequenceAction;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Dialog for editing an action.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionDialog extends EditBeanDialog {
+
+	private RuleFlowProcess process;
+	private TabFolder tabFolder;
+	private SourceViewer actionViewer;
+	//private ActionCompletionProcessor completionProcessor;
+
+	public ActionDialog(Shell parentShell, RuleFlowProcess process, ActionNode actionNode) {
+		super(parentShell, "Action editor");
+		this.process = process;
+		super.setValue(actionNode.getAction());
+	}
+	
+    public void setValue(Object value) {
+        // the value is automatically retrieved from the actionNode
+    	// and cannot be set manually
+    }
+
+	protected Object updateValue(Object value) {
+		if (tabFolder.getSelectionIndex() == 0) {
+			return getAction();
+		}
+		return null;
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 450);
+	}
+
+	private Control createTextualEditor(Composite parent) {
+		actionViewer = new SourceViewer(parent, null, SWT.BORDER);
+//		actionViewer.configure(new DRLSourceViewerConfig(null) {
+//			public IReconciler getReconciler(ISourceViewer sourceViewer) {
+//				return null;
+//			}
+//			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+//				ContentAssistant assistant = new ContentAssistant();
+//				completionProcessor = new ActionCompletionProcessor(process);
+//				assistant.setContentAssistProcessor(
+//					completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+//				assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+//				return assistant;
+//			}
+//		});
+		Object action = getValue();
+		String value = null;
+		if (action instanceof DroolsConsequenceAction) {
+			value = ((DroolsConsequenceAction) action).getConsequence();
+		}
+		if (value == null) {
+			value = "";
+		}
+		IDocument document = new Document(value);
+		actionViewer.setDocument(document);
+		IDocumentPartitioner partitioner =
+            new FastPartitioner(
+                new DRLPartionScanner(),
+                DRLPartionScanner.LEGAL_CONTENT_TYPES);
+        partitioner.connect(document);
+        document.setDocumentPartitioner(partitioner);
+        actionViewer.getControl().addKeyListener(new KeyListener() {
+			public void keyPressed(KeyEvent e) {
+				if (e.character == ' ' && e.stateMask == SWT.CTRL) {
+					actionViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+				}
+			}
+			public void keyReleased(KeyEvent e) {
+			}
+        });
+		return actionViewer.getControl();
+	}
+	
+	private Object getAction() {
+		return new DroolsConsequenceAction(actionViewer.getDocument().get());
+	}
+	
+	public Control createDialogArea(Composite parent) {
+		GridLayout layout = new GridLayout();
+		parent.setLayout(layout);
+		layout.numColumns = 2;
+
+		Composite top = new Composite(parent, SWT.NONE);
+		GridData gd = new GridData();
+		gd.horizontalSpan = 2;
+		gd.grabExcessHorizontalSpace = true;
+		top.setLayoutData(gd);
+
+		layout = new GridLayout();
+		layout.numColumns = 3;
+		top.setLayout(layout);
+
+		Button importButton = new Button(top, SWT.PUSH);
+		importButton.setText("Imports ...");
+		importButton.setFont(JFaceResources.getDialogFont());
+		importButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				importButtonPressed();
+			}
+		});
+		gd = new GridData();
+		importButton.setLayoutData(gd);
+
+		Button globalButton = new Button(top, SWT.PUSH);
+		globalButton.setText("Globals ...");
+		globalButton.setFont(JFaceResources.getDialogFont());
+		globalButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				globalButtonPressed();
+			}
+		});
+		gd = new GridData();
+		globalButton.setLayoutData(gd);
+
+		tabFolder = new TabFolder(parent, SWT.NONE);
+		gd = new GridData();
+		gd.horizontalSpan = 3;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = true;
+		gd.verticalAlignment = GridData.FILL;
+		gd.horizontalAlignment = GridData.FILL;
+		tabFolder.setLayoutData(gd);
+		TabItem textEditorTab = new TabItem(tabFolder, SWT.NONE);
+		textEditorTab.setText("Textual Editor");
+
+		textEditorTab.setControl(createTextualEditor(tabFolder));
+		return tabFolder;
+	}
+	
+	private void importButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowImportsDialog dialog =
+					new RuleFlowImportsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					List imports = dialog.getImports();
+					process.setImports(imports);
+//					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+	
+	private void globalButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowGlobalsDialog dialog =
+					new RuleFlowGlobalsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					Map globals = dialog.getGlobals();
+					process.setGlobals(globals);
+//					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionPropertyDescriptor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/action/ActionPropertyDescriptor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.ruleflow.view.property.action;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.ruleflow.core.ActionNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Property descriptor for an action.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ActionPropertyDescriptor extends PropertyDescriptor {
+    
+    private RuleFlowProcess process;
+    private ActionNode actionNode;
+    
+    public ActionPropertyDescriptor(Object id, String displayName, ActionNode actionNode, RuleFlowProcess process) {
+        super(id, displayName);
+        this.actionNode = actionNode;
+        this.process = process;
+    }
+    
+    public RuleFlowProcess getProcess() {
+        return process;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+    	ActionCellEditor editor = new ActionCellEditor(parent, process, actionNode);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,133 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.drools.eclipse.editors.completion.RuleCompletionProcessor;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Completion for ruleflow constraints. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConstraintCompletionProcessor extends RuleCompletionProcessor {
+
+	private RuleFlowProcess process;
+	private List imports;
+	private List globals;
+	
+	public ConstraintCompletionProcessor(RuleFlowProcess process) {
+		super(null);
+		this.process = process;
+	}
+	
+	public IEditorPart getEditor() {
+		IWorkbench workbench = PlatformUI.getWorkbench();
+		if (workbench != null) { 
+			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+			if (workbenchWindow != null) {
+				IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); 
+				if (workbenchPage != null) {
+					return workbenchPage.getActiveEditor();
+				}
+			}
+		}
+		return null;
+	}
+
+    protected String readBackwards(int documentOffset, IDocument doc) throws BadLocationException {
+        int startPart = doc.getPartition(documentOffset).getOffset();
+        String prefix = doc.get(startPart, documentOffset - startPart);
+        return "rule dummy \n when \n" + prefix;
+    }
+    
+    public List getImports() {
+    	if (imports == null) {
+    		loadImports();
+    	}
+    	return imports;
+    }
+    
+    private void loadImports() {
+    	this.imports = new ArrayList();
+    	List imports = process.getImports();
+    	if (imports != null) {
+	    	Iterator iterator = imports.iterator();
+	        while (iterator.hasNext()) {
+	            String importName = (String) iterator.next();
+	            if (importName.endsWith(".*")) {
+	            	IJavaProject javaProject = getJavaProject();
+	            	if (javaProject != null) {
+		                String packageName = importName.substring(0, importName.length() - 2);
+		                this.imports.addAll(DRLRuleEditor.getAllClassesInPackage(packageName, javaProject));
+	            	}
+	            } else {
+	            	this.imports.add(importName);
+	            }
+	        }
+    	}
+    }
+    
+    public List getGlobals() {
+    	if (globals == null) {
+    		loadGlobals();
+    	}
+    	return globals;
+    }
+    
+    private void loadGlobals() {
+    	this.globals = Arrays.asList(process.getGlobalNames());
+    }
+    
+    private IJavaProject getJavaProject() {
+    	IEditorPart editor = getEditor();
+    	if (editor != null && editor.getEditorInput() instanceof IFileEditorInput) {
+			IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile();
+	    	try {
+	    		if (file.getProject().getNature("org.eclipse.jdt.core.javanature") != null) {
+	    			return JavaCore.create(file.getProject());
+	    		}
+	    	} catch (CoreException e) {
+	    		// do nothing
+	    	}
+		}
+    	return null;
+    }
+    
+    public void reset() {
+    	this.imports = null;
+    	this.globals = null;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListCellEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListCellEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListCellEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,48 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.core.Split;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConstraintListCellEditor extends BeanDialogCellEditor {
+
+    private RuleFlowProcess process;
+    private Split split;
+    
+    public ConstraintListCellEditor(Composite parent, RuleFlowProcess process, Split split) {
+        super(parent);
+        this.process = process;
+        this.split = split;
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new ConstraintListDialog(shell, process, split);
+    }
+    
+    protected String getLabelText(Object value) {
+        return "";
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintListDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,143 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.core.Connection;
+import org.drools.ruleflow.core.Constraint;
+import org.drools.ruleflow.core.Split;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for editing constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConstraintListDialog extends EditBeanDialog {
+
+	private RuleFlowProcess process;
+	private Split split;
+	private Map newMap;
+	private Map labels = new HashMap();
+
+	protected ConstraintListDialog(Shell parentShell, RuleFlowProcess process,
+			Split split) {
+		super(parentShell, "Edit Constraints");
+		this.process = process;
+		this.split = split;
+	}
+
+	protected Control createDialogArea(Composite parent) {
+		Composite composite = (Composite) super.createDialogArea(parent);
+		GridLayout gridLayout = new GridLayout();
+		gridLayout.numColumns = 3;
+		composite.setLayout(gridLayout);
+
+		List outgoingConnections = split.getOutgoingConnections();
+		labels.clear();
+		for (Iterator it = outgoingConnections.iterator(); it.hasNext(); ) {
+			Connection outgoingConnection = (Connection) it.next();
+			Label label1 = new Label(composite, SWT.NONE);
+			label1.setText("To node " + outgoingConnection.getTo().getName()
+					+ ": ");
+
+			Label label2 = new Label(composite, SWT.NONE);
+			labels.put(outgoingConnection, label2);
+			GridData gridData = new GridData();
+			gridData.grabExcessHorizontalSpace = true;
+			gridData.horizontalAlignment = GridData.FILL;
+			label2.setLayoutData(gridData);
+			Constraint constraint = (Constraint) newMap.get(outgoingConnection);
+			if (constraint != null) {
+				label2.setText(constraint.getName());
+			}
+
+			Button editButton = new Button(composite, SWT.NONE);
+			editButton.setText("Edit");
+			editButton.addSelectionListener(new EditButtonListener(
+					outgoingConnection));
+		}
+
+		return composite;
+	}
+
+	public void setValue(Object value) {
+		super.setValue(value);
+		this.newMap = new HashMap((Map) value);
+	}
+
+	protected Object updateValue(Object value) {
+		return newMap;
+	}
+
+	private void editItem(final Connection connection) {
+
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowConstraintDialog dialog = new RuleFlowConstraintDialog(
+						getShell(), process);
+				dialog.create();
+				Constraint constraint = (Constraint) newMap.get(connection);
+				dialog.setConstraint(constraint);
+				int code = dialog.open();
+				if (code != CANCEL) {
+					constraint = dialog.getConstraint();
+					newMap.put(connection, constraint);
+					setConnectionText((Label) labels.get(connection), constraint
+							.getName());
+				}
+			}
+
+		};
+		r.run();
+	}
+
+	private void setConnectionText(final Label connection, final String name) {
+		Display.getDefault().asyncExec(new Runnable() {
+			public void run() {
+				connection.setText(name);
+			}
+		});
+	}
+
+	private class EditButtonListener extends SelectionAdapter {
+		private Connection connection;
+
+		public EditButtonListener(Connection connection) {
+			this.connection = connection;
+		}
+
+		public void widgetSelected(SelectionEvent e) {
+			editItem(connection);
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintsPropertyDescriptor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintsPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ConstraintsPropertyDescriptor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.ruleflow.core.Split;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Property descriptor for constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ConstraintsPropertyDescriptor extends PropertyDescriptor {
+    
+    private RuleFlowProcess process;
+    private Split split;
+    
+    public ConstraintsPropertyDescriptor(Object id, String displayName, Split split, RuleFlowProcess process) {
+        super(id, displayName);
+        this.split = split;
+        this.process = process;
+    }
+    
+    public RuleFlowProcess getProcess() {
+        return process;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+        ConstraintListCellEditor editor = new ConstraintListCellEditor(parent, process, split);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ImportCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ImportCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/ImportCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,147 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.regex.Matcher;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.editors.completion.CompletionUtil;
+import org.drools.eclipse.editors.completion.DefaultCompletionProcessor;
+import org.drools.eclipse.editors.completion.RuleCompletionProcessor;
+import org.drools.eclipse.editors.completion.RuleCompletionProposal;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.ITextViewer;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Completion for ruleflow constraints. 
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class ImportCompletionProcessor extends DefaultCompletionProcessor {
+
+	public ImportCompletionProcessor() {
+		super(null);
+	}
+	
+	public IEditorPart getEditor() {
+		IWorkbench workbench = PlatformUI.getWorkbench();
+		if (workbench != null) { 
+			IWorkbenchWindow workbenchWindow = workbench.getActiveWorkbenchWindow();
+			if (workbenchWindow != null) {
+				IWorkbenchPage workbenchPage = workbenchWindow.getActivePage(); 
+				if (workbenchPage != null) {
+					return workbenchPage.getActiveEditor();
+				}
+			}
+		}
+		return null;
+	}
+
+    protected List getCompletionProposals(ITextViewer viewer,
+            int documentOffset) {
+		try {
+			IDocument doc = viewer.getDocument();
+			String backText = readBackwards(documentOffset, doc);
+
+			String prefix = CompletionUtil.stripLastWord(backText);
+
+			List props = null;
+			Matcher matcher = IMPORT_PATTERN.matcher(backText);
+			if (matcher.matches()) {
+				String classNameStart = backText.substring(backText
+						.lastIndexOf("import") + 7);
+				props = getAllClassProposals(classNameStart, documentOffset,
+						prefix);
+			} else {
+				props = getPossibleProposals(viewer, documentOffset, backText, prefix);
+			}
+			return props;
+		} catch (Throwable t) {
+			DroolsEclipsePlugin.log(t);
+		}
+		return null;
+	}
+
+    
+    public List getImports() {
+    	return Collections.EMPTY_LIST;
+    }
+    
+    public List getGlobals() {
+    	return Collections.EMPTY_LIST;
+    }
+    
+    protected IJavaProject getCurrentJavaProject() {
+    	IEditorPart editor = getEditor();
+    	if (editor != null && editor.getEditorInput() instanceof IFileEditorInput) {
+			IFile file = ((IFileEditorInput) editor.getEditorInput()).getFile();
+	    	try {
+	    		if (file.getProject().getNature("org.eclipse.jdt.core.javanature") != null) {
+	    			return JavaCore.create(file.getProject());
+	    		}
+	    	} catch (CoreException e) {
+	    		// do nothing
+	    	}
+		}
+    	return null;
+    }
+    
+    protected List getPossibleProposals(ITextViewer viewer,
+            int documentOffset,
+            String backText,
+            final String prefix) {
+		List list = new ArrayList();
+		list.add(new RuleCompletionProposal(documentOffset - prefix.length(), prefix.length(), "import", "import "));
+		DefaultCompletionProcessor.filterProposalsOnPrefix(prefix, list);
+		return list;
+	}
+
+    /**
+     * @return a list of "MVELified" RuleCompletionProposal. That list contains only unique proposal based on
+     * the overrriden equals in {@link RuleCompletionProposal} to avoid the situation when several
+     * accessors can exist for one property. for that case we want to keep only one proposal.
+     */
+    protected Collection getJavaMvelCompletionProposals(final int documentOffset,
+                                                     final String javaText,
+                                                     final String prefix,
+                                                     Map params) {
+                                                        final List list = new ArrayList();
+                                                        requestJavaCompletionProposals( javaText,
+                                                                                        prefix,
+                                                                                        documentOffset,
+                                                                                        params,
+                                                                                        list );
+                                                    
+                                                        Collection mvelList = RuleCompletionProcessor.mvelifyProposals( list, false );
+                                                        return mvelList;
+                                                    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintCellEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintCellEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintCellEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.core.MilestoneNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell editor for milestone constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneConstraintCellEditor extends BeanDialogCellEditor {
+
+    private RuleFlowProcess process;
+    private MilestoneNode milestone;
+    
+    public MilestoneConstraintCellEditor(Composite parent, RuleFlowProcess process, MilestoneNode milestone) {
+        super(parent);
+        this.process = process;
+        this.milestone = milestone;
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new MilestoneConstraintDialog(shell, process, milestone);
+    }
+    
+    protected String getLabelText(Object value) {
+    	if (milestone == null || milestone.getConstraint() == null) {
+    		return "";
+    	}
+        return milestone.getConstraint();
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,209 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.editors.DRLSourceViewerConfig;
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.core.MilestoneNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Dialog for editing constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneConstraintDialog extends EditBeanDialog {
+
+	private RuleFlowProcess process;
+	private TabFolder tabFolder;
+	private SourceViewer constraintViewer;
+	private ConstraintCompletionProcessor completionProcessor;
+
+	public MilestoneConstraintDialog(Shell parentShell, RuleFlowProcess process, MilestoneNode milestone) {
+		super(parentShell, "Constraint editor");
+		this.process = process;
+		setValue(milestone.getConstraint());
+	}
+
+	protected Object updateValue(Object value) {
+		if (tabFolder.getSelectionIndex() == 0) {
+			return getConstraintText();
+		}
+		return null;
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 450);
+	}
+
+	private Control createTextualEditor(Composite parent) {
+		constraintViewer = new SourceViewer(parent, null, SWT.BORDER);
+		constraintViewer.configure(new DRLSourceViewerConfig(null) {
+			public IReconciler getReconciler(ISourceViewer sourceViewer) {
+				return null;
+			}
+			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+				ContentAssistant assistant = new ContentAssistant();
+				completionProcessor = new ConstraintCompletionProcessor(process);
+				assistant.setContentAssistProcessor(
+					completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+				assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+				return assistant;
+			}
+		});
+		String value = (String) getValue();
+		if (value == null) {
+			value = "";
+		}
+		IDocument document = new Document(value);
+		constraintViewer.setDocument(document);
+		IDocumentPartitioner partitioner =
+            new FastPartitioner(
+                new DRLPartionScanner(),
+                DRLPartionScanner.LEGAL_CONTENT_TYPES);
+        partitioner.connect(document);
+        document.setDocumentPartitioner(partitioner);
+        constraintViewer.getControl().addKeyListener(new KeyListener() {
+			public void keyPressed(KeyEvent e) {
+				if (e.character == ' ' && e.stateMask == SWT.CTRL) {
+					constraintViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+				}
+			}
+			public void keyReleased(KeyEvent e) {
+			}
+        });
+		return constraintViewer.getControl();
+	}
+	
+	private String getConstraintText() {
+		return constraintViewer.getDocument().get();
+	}
+	
+	public Control createDialogArea(Composite parent) {
+		GridLayout layout = new GridLayout();
+		parent.setLayout(layout);
+		layout.numColumns = 2;
+
+		Composite top = new Composite(parent, SWT.NONE);
+		GridData gd = new GridData();
+		gd.horizontalSpan = 2;
+		gd.grabExcessHorizontalSpace = true;
+		top.setLayoutData(gd);
+
+		layout = new GridLayout();
+		layout.numColumns = 3;
+		top.setLayout(layout);
+
+		Button importButton = new Button(top, SWT.PUSH);
+		importButton.setText("Imports ...");
+		importButton.setFont(JFaceResources.getDialogFont());
+		importButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				importButtonPressed();
+			}
+		});
+		gd = new GridData();
+		importButton.setLayoutData(gd);
+
+		Button globalButton = new Button(top, SWT.PUSH);
+		globalButton.setText("Globals ...");
+		globalButton.setFont(JFaceResources.getDialogFont());
+		globalButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				globalButtonPressed();
+			}
+		});
+		gd = new GridData();
+		globalButton.setLayoutData(gd);
+
+		tabFolder = new TabFolder(parent, SWT.NONE);
+		gd = new GridData();
+		gd.horizontalSpan = 3;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = true;
+		gd.verticalAlignment = GridData.FILL;
+		gd.horizontalAlignment = GridData.FILL;
+		tabFolder.setLayoutData(gd);
+		TabItem textEditorTab = new TabItem(tabFolder, SWT.NONE);
+		textEditorTab.setText("Textual Editor");
+
+		textEditorTab.setControl(createTextualEditor(tabFolder));
+		return tabFolder;
+	}
+	
+	private void importButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowImportsDialog dialog =
+					new RuleFlowImportsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					List imports = dialog.getImports();
+					process.setImports(imports);
+					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+	
+	private void globalButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowGlobalsDialog dialog =
+					new RuleFlowGlobalsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					Map globals = dialog.getGlobals();
+					process.setGlobals(globals);
+					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintPropertyDescriptor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintPropertyDescriptor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/MilestoneConstraintPropertyDescriptor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,51 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.ruleflow.core.MilestoneNode;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.views.properties.PropertyDescriptor;
+
+/**
+ * Property descriptor for a milestone constraint.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class MilestoneConstraintPropertyDescriptor extends PropertyDescriptor {
+    
+    private RuleFlowProcess process;
+    private MilestoneNode milestone;
+    
+    public MilestoneConstraintPropertyDescriptor(Object id, String displayName, MilestoneNode milestone, RuleFlowProcess process) {
+        super(id, displayName);
+        this.milestone = milestone;
+        this.process = process;
+    }
+    
+    public RuleFlowProcess getProcess() {
+        return process;
+    }
+    
+    public CellEditor createPropertyEditor(Composite parent) {
+    	MilestoneConstraintCellEditor editor = new MilestoneConstraintCellEditor(parent, process, milestone);
+        if (getValidator() != null) {
+            editor.setValidator(getValidator());
+        }
+        return editor;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowConstraintDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,323 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.editors.DRLSourceViewerConfig;
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.drools.ruleflow.core.Constraint;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.drools.ruleflow.core.impl.ConstraintImpl;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.resource.JFaceResources;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Dialog for editing constraints.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowConstraintDialog extends Dialog {
+
+	private Constraint constraint;
+	private RuleFlowProcess process;
+	private boolean success;
+	private Button alwaysTrue;
+	private Text nameText;
+	private Text priorityText;
+	private TabFolder tabFolder;
+	private SourceViewer constraintViewer;
+	private ConstraintCompletionProcessor completionProcessor;
+
+	public RuleFlowConstraintDialog(Shell parentShell, RuleFlowProcess process) {
+		super(parentShell);
+		this.process = process;
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+	}
+
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setText("Constraint editor");
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 450);
+	}
+
+	private Control createTextualEditor(Composite parent) {
+		constraintViewer = new SourceViewer(parent, null, SWT.BORDER);
+		constraintViewer.configure(new DRLSourceViewerConfig(null) {
+			public IReconciler getReconciler(ISourceViewer sourceViewer) {
+				return null;
+			}
+			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+				ContentAssistant assistant = new ContentAssistant();
+				completionProcessor = new ConstraintCompletionProcessor(process);
+				assistant.setContentAssistProcessor(
+					completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+				assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+				return assistant;
+			}
+		});
+		IDocument document = new Document();
+		constraintViewer.setDocument(document);
+		IDocumentPartitioner partitioner =
+            new FastPartitioner(
+                new DRLPartionScanner(),
+                DRLPartionScanner.LEGAL_CONTENT_TYPES);
+        partitioner.connect(document);
+        document.setDocumentPartitioner(partitioner);
+        constraintViewer.getControl().addKeyListener(new KeyListener() {
+			public void keyPressed(KeyEvent e) {
+				if (e.character == ' ' && e.stateMask == SWT.CTRL) {
+					constraintViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+				}
+			}
+			public void keyReleased(KeyEvent e) {
+			}
+        });
+		return constraintViewer.getControl();
+	}
+	
+	private String getConstraintText() {
+		return constraintViewer.getDocument().get();
+	}
+	
+	private void setConstraintText(String text) {
+		constraintViewer.getDocument().set(text);
+	}
+
+	public Control createDialogArea(Composite parent) {
+
+		GridLayout layout = new GridLayout();
+		parent.setLayout(layout);
+		layout.numColumns = 2;
+
+		Composite top = new Composite(parent, SWT.NONE);
+		GridData gd = new GridData();
+		gd.horizontalSpan = 2;
+		gd.grabExcessHorizontalSpace = true;
+		top.setLayoutData(gd);
+
+		layout = new GridLayout();
+		layout.numColumns = 4;
+		top.setLayout(layout);
+
+		Label l1 = new Label(top, SWT.None);
+		l1.setText("Name:");
+		gd = new GridData();
+		l1.setLayoutData(gd);
+		nameText = new Text(top, SWT.BORDER);
+		gd = new GridData();
+		gd.horizontalAlignment = GridData.FILL;
+		gd.widthHint = 200;
+		gd.horizontalSpan = 3;
+		nameText.setLayoutData(gd);
+
+		Label l2 = new Label(top, SWT.NONE);
+		gd = new GridData();
+		l2.setLayoutData(gd);
+		l2.setText("Priority:");
+		priorityText = new Text(top, SWT.BORDER);
+		gd = new GridData();
+		gd.widthHint = 200;
+		gd.horizontalSpan = 3;
+		priorityText.setLayoutData(gd);
+
+		alwaysTrue = new Button(top, SWT.CHECK);
+		alwaysTrue.setText("Always true");
+		gd = new GridData();
+		gd.horizontalSpan = 2;
+		alwaysTrue.setLayoutData(gd);
+		
+		Button importButton = new Button(top, SWT.PUSH);
+		importButton.setText("Imports ...");
+		importButton.setFont(JFaceResources.getDialogFont());
+		importButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				importButtonPressed();
+			}
+		});
+		gd = new GridData();
+		gd.grabExcessHorizontalSpace = true;
+		gd.horizontalAlignment = GridData.END;
+		importButton.setLayoutData(gd);
+
+		Button globalButton = new Button(top, SWT.PUSH);
+		globalButton.setText("Globals ...");
+		globalButton.setFont(JFaceResources.getDialogFont());
+		globalButton.addSelectionListener(new SelectionAdapter() {
+			public void widgetSelected(SelectionEvent event) {
+				globalButtonPressed();
+			}
+		});
+		gd = new GridData();
+		gd.horizontalAlignment = GridData.END;
+		globalButton.setLayoutData(gd);
+
+		tabFolder = new TabFolder(parent, SWT.NONE);
+		gd = new GridData();
+		gd.horizontalSpan = 4;
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = true;
+		gd.verticalAlignment = GridData.FILL;
+		gd.horizontalAlignment = GridData.FILL;
+		tabFolder.setLayoutData(gd);
+		TabItem textEditorTab = new TabItem(tabFolder, SWT.NONE);
+		textEditorTab.setText("Textual Editor");
+
+		textEditorTab.setControl(createTextualEditor(tabFolder));
+
+		alwaysTrue.addSelectionListener(new SelectionListener() {
+			public void widgetSelected(SelectionEvent e) {
+				tabFolder.setVisible(!alwaysTrue.getSelection());
+			}
+
+			public void widgetDefaultSelected(SelectionEvent e) {
+				widgetSelected(e);
+			}
+		});
+
+		return tabFolder;
+	}
+	
+	private void importButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowImportsDialog dialog =
+					new RuleFlowImportsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					List imports = dialog.getImports();
+					process.setImports(imports);
+					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+
+	private void globalButtonPressed() {
+		final Runnable r = new Runnable() {
+			public void run() {
+				RuleFlowGlobalsDialog dialog =
+					new RuleFlowGlobalsDialog(getShell(), process);
+				dialog.create();
+				int code = dialog.open();
+				if (code != CANCEL) {
+					Map globals = dialog.getGlobals();
+					process.setGlobals(globals);
+					completionProcessor.reset();
+				}
+			}
+		};
+		r.run();
+	}
+
+	protected void okPressed() {
+		int selectionIndex = tabFolder.getSelectionIndex();
+		if (selectionIndex == 1) {
+			updateTranslation();
+		} else {
+			updateConstraint();
+		}
+		super.okPressed();
+	}
+
+	private void updateTranslation() {
+		// TODO add custom token model checker
+		success = true;
+		constraint = new ConstraintImpl();
+		constraint.setConstraint(null);
+		constraint.setConstraint(getConstraintText());
+		constraint.setName(nameText.getText());
+		try {
+			constraint.setPriority(Integer.parseInt(priorityText.getText()));
+		} catch (NumberFormatException exc) {
+			constraint.setPriority(1);
+		}
+	}
+
+	public boolean isSuccess() {
+		return success;
+	}
+
+	public void updateConstraint() {
+		constraint = new ConstraintImpl();
+		if (!alwaysTrue.getSelection()) {
+			constraint.setConstraint(getConstraintText());
+		} else {
+			constraint.setConstraint("eval(true)");
+		}
+		constraint.setName(nameText.getText());
+		try {
+			constraint.setPriority(Integer.parseInt(priorityText.getText()));
+		} catch (NumberFormatException exc) {
+			constraint.setPriority(1);
+		}
+	}
+
+	public Constraint getConstraint() {
+		return constraint;
+	}
+
+	public void setConstraint(Constraint constraint) {
+		this.constraint = constraint;
+		if (constraint != null) {
+			if ("eval(true)".equals(constraint.getConstraint())) {
+				alwaysTrue.setSelection(true);
+			} else {
+				setConstraintText(constraint.getConstraint().toString());
+			}
+			tabFolder.setVisible(!alwaysTrue.getSelection());
+			nameText.setText(constraint.getName() == null ? "" : constraint
+					.getName());
+			priorityText.setText(constraint.getPriority() + "");
+			setConstraintText(constraint.getConstraint());
+		} else {
+			priorityText.setText("1");
+			nameText.setText("constraint");
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowGlobalsDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowGlobalsDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowGlobalsDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,139 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.eclipse.editors.DRLSourceViewerConfig;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Dialog for editing imports.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowGlobalsDialog extends Dialog {
+
+	private static final Pattern GLOBAL_PATTERN = Pattern.compile(
+		"\\n\\s*global\\s+([^\\s;#]+)\\s+([^\\s;#]+);?", Pattern.DOTALL);
+	
+	private RuleFlowProcess process;
+	private boolean success;
+	private TabFolder tabFolder;
+	private SourceViewer globalsViewer;
+	private Map globals;
+
+	public RuleFlowGlobalsDialog(Shell parentShell, RuleFlowProcess process) {
+		super(parentShell);
+		this.process = process;
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+	}
+
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setText("Globals editor");
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 450);
+	}
+
+	private Control createTextualEditor(Composite parent) {
+		globalsViewer = new SourceViewer(parent, null, SWT.BORDER);
+		globalsViewer.configure(new DRLSourceViewerConfig(null) {
+			public IReconciler getReconciler(ISourceViewer sourceViewer) {
+				return null;
+			}
+			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+				return null;
+			}
+		});
+		IDocument document = new Document(getProcessImports());
+		globalsViewer.setDocument(document);
+		return globalsViewer.getControl();
+	}
+	
+	private String getProcessImports() {
+		String result = "# define your globals here: e.g. global java.util.List myList\n";
+		Map globals = process.getGlobals();
+		if (globals != null) {
+			for (Iterator iterator = globals.entrySet().iterator(); iterator.hasNext(); ) {
+				Map.Entry entry = (Map.Entry) iterator.next();
+				result += "global " + entry.getValue() + " " + entry.getKey() + "\n";
+			}
+		}
+		return result;
+	}
+	
+	public Control createDialogArea(Composite parent) {
+		GridLayout layout = new GridLayout();
+		parent.setLayout(layout);
+		layout.numColumns = 1;
+		tabFolder = new TabFolder(parent, SWT.NONE);
+		GridData gd = new GridData();
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = true;
+		gd.verticalAlignment = GridData.FILL;
+		gd.horizontalAlignment = GridData.FILL;
+		tabFolder.setLayoutData(gd);
+		TabItem textEditorTab = new TabItem(tabFolder, SWT.NONE);
+		textEditorTab.setText("Globals");
+		textEditorTab.setControl(createTextualEditor(tabFolder));
+		return tabFolder;
+	}
+	
+	protected void okPressed() {
+		success = true;
+		updateGlobals();
+		super.okPressed();
+	}
+
+	public boolean isSuccess() {
+		return success;
+	}
+
+	public Map getGlobals() {
+		return globals;
+	}
+	
+	private void updateGlobals() {
+		this.globals = new HashMap();
+		Matcher matcher = GLOBAL_PATTERN.matcher(globalsViewer.getDocument().get());
+		while (matcher.find()) {
+			this.globals.put(matcher.group(2), matcher.group(1));
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowImportsDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowImportsDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/constraint/RuleFlowImportsDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,165 @@
+package org.drools.eclipse.flow.ruleflow.view.property.constraint;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import org.drools.eclipse.editors.DRLSourceViewerConfig;
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.drools.ruleflow.core.RuleFlowProcess;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.contentassist.ContentAssistant;
+import org.eclipse.jface.text.contentassist.IContentAssistProcessor;
+import org.eclipse.jface.text.contentassist.IContentAssistant;
+import org.eclipse.jface.text.reconciler.IReconciler;
+import org.eclipse.jface.text.rules.FastPartitioner;
+import org.eclipse.jface.text.source.ISourceViewer;
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.graphics.Point;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.TabFolder;
+import org.eclipse.swt.widgets.TabItem;
+
+/**
+ * Dialog for editing imports.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowImportsDialog extends Dialog {
+
+	private static final Pattern IMPORT_PATTERN = Pattern.compile(
+		"\\n\\s*import\\s+([^\\s;#]+);?", Pattern.DOTALL);
+	
+	private RuleFlowProcess process;
+	private boolean success;
+	private TabFolder tabFolder;
+	private SourceViewer importsViewer;
+	private List imports;
+
+	public RuleFlowImportsDialog(Shell parentShell, RuleFlowProcess process) {
+		super(parentShell);
+		this.process = process;
+		setShellStyle(getShellStyle() | SWT.RESIZE);
+	}
+
+	protected void configureShell(Shell newShell) {
+		super.configureShell(newShell);
+		newShell.setText("Imports editor");
+	}
+
+	protected Point getInitialSize() {
+		return new Point(600, 450);
+	}
+
+	private Control createTextualEditor(Composite parent) {
+		importsViewer = new SourceViewer(parent, null, SWT.BORDER);
+		importsViewer.configure(new DRLSourceViewerConfig(null) {
+			public IReconciler getReconciler(ISourceViewer sourceViewer) {
+				return null;
+			}
+			public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) {
+				ContentAssistant assistant = new ContentAssistant();
+				IContentAssistProcessor completionProcessor = new ImportCompletionProcessor();
+				assistant.setContentAssistProcessor(
+					completionProcessor, IDocument.DEFAULT_CONTENT_TYPE);
+				assistant.setProposalPopupOrientation(IContentAssistant.PROPOSAL_OVERLAY);
+				return assistant;
+			}
+		});
+		IDocument document = new Document(getProcessImports());
+		importsViewer.setDocument(document);
+		IDocumentPartitioner partitioner =
+            new FastPartitioner(
+                new DRLPartionScanner(),
+                DRLPartionScanner.LEGAL_CONTENT_TYPES);
+        partitioner.connect(document);
+        document.setDocumentPartitioner(partitioner);
+        importsViewer.getControl().addKeyListener(new KeyListener() {
+			public void keyPressed(KeyEvent e) {
+				if (e.character == ' ' && e.stateMask == SWT.CTRL) {
+					importsViewer.doOperation(ISourceViewer.CONTENTASSIST_PROPOSALS);
+				}
+			}
+			public void keyReleased(KeyEvent e) {
+			}
+        });
+		return importsViewer.getControl();
+	}
+	
+	private String getProcessImports() {
+		String result = "# define your imports here: e.g. import com.sample.MyClass\n";
+		List imports = process.getImports();
+		if (imports != null) {
+			for (Iterator iterator = imports.iterator(); iterator.hasNext(); ) {
+				result += "import " + (String) iterator.next() + "\n";
+			}
+		}
+		return result;
+	}
+	
+	public Control createDialogArea(Composite parent) {
+		GridLayout layout = new GridLayout();
+		parent.setLayout(layout);
+		layout.numColumns = 1;
+		tabFolder = new TabFolder(parent, SWT.NONE);
+		GridData gd = new GridData();
+		gd.grabExcessHorizontalSpace = true;
+		gd.grabExcessVerticalSpace = true;
+		gd.verticalAlignment = GridData.FILL;
+		gd.horizontalAlignment = GridData.FILL;
+		tabFolder.setLayoutData(gd);
+		TabItem textEditorTab = new TabItem(tabFolder, SWT.NONE);
+		textEditorTab.setText("Imports");
+		textEditorTab.setControl(createTextualEditor(tabFolder));
+		return tabFolder;
+	}
+	
+	protected void okPressed() {
+		success = true;
+		updateImports();
+		super.okPressed();
+	}
+
+	public boolean isSuccess() {
+		return success;
+	}
+
+	public List getImports() {
+		return imports;
+	}
+	
+	private void updateImports() {
+		this.imports = new ArrayList();
+		Matcher matcher = IMPORT_PATTERN.matcher(importsViewer.getDocument().get());
+		while (matcher.find()) {
+			this.imports.add(matcher.group(1));
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,151 @@
+package org.drools.eclipse.flow.ruleflow.view.property.variable;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.flow.common.datatype.DefaultDataTypeRegistry;
+import org.drools.eclipse.flow.common.view.datatype.editor.DataTypeEditor;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.DataTypeCombo;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.DataTypeEditorComposite;
+import org.drools.eclipse.flow.common.view.datatype.editor.impl.EditorComposite;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.drools.ruleflow.common.datatype.DataType;
+import org.drools.ruleflow.core.Variable;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * Dialog for editing variables.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableDialog extends EditBeanDialog {
+    
+    private Text nameText;
+    private DataTypeCombo dataTypeCombo;
+    private DataTypeEditorComposite dataTypeEditorComposite;
+    private EditorComposite editorComposite;
+
+    public VariableDialog(Shell parentShell) {
+        super(parentShell, "Edit Variable");
+    }
+    
+    protected Control createDialogArea(Composite parent) {
+        final Composite composite = (Composite) super.createDialogArea(parent);
+        GridLayout gridLayout = new GridLayout();
+        gridLayout.numColumns = 2;
+        composite.setLayout(gridLayout);
+        
+        Label nameLabel = new Label(composite, SWT.NONE);
+        nameLabel.setText("Name: ");
+        nameText = new Text(composite, SWT.NONE);
+        GridData gridData = new GridData();
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.horizontalAlignment = GridData.FILL;
+        nameText.setLayoutData(gridData);
+        String name = ((Variable) getValue()).getName();
+        nameText.setText(name == null ? "" : name);
+
+        Label typeLabel = new Label(composite, SWT.NONE);
+        typeLabel.setText("Type: ");
+        
+        dataTypeCombo = new DataTypeCombo(composite,
+    		SWT.NONE, DefaultDataTypeRegistry.getInstance());
+        DataType dataType = ((Variable) getValue()).getType();
+        dataTypeCombo.setDataType(dataType);
+        dataTypeCombo.addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				DataType dataType = dataTypeCombo.getDataType();
+				dataTypeEditorComposite.setDataType(dataType);
+				editorComposite.setDataType(dataType);
+				composite.layout();
+			}
+        });
+        
+    	new Label(composite, SWT.NONE);
+        
+        dataTypeEditorComposite = new DataTypeEditorComposite(composite,
+            SWT.NONE, DefaultDataTypeRegistry.getInstance());
+        gridData = new GridData();
+        gridData.grabExcessHorizontalSpace = true;
+        gridData.horizontalAlignment = GridData.FILL;
+        dataTypeEditorComposite.setLayoutData(gridData);
+        dataTypeEditorComposite.setDataType(dataType);
+        dataTypeEditorComposite.addListener(new DataTypeEditor.DataTypeListener() {
+            public void dataTypeChanged(DataType dataType) {
+                editorComposite.setDataType(dataType);
+                composite.layout();
+            }
+        });
+        
+        Label valueLabel = new Label(composite, SWT.NONE);
+        valueLabel.setText("Value: ");
+        gridData = new GridData();
+        gridData.verticalAlignment = SWT.TOP;
+        valueLabel.setLayoutData(gridData);
+        editorComposite = new EditorComposite(composite,
+            SWT.NONE, DefaultDataTypeRegistry.getInstance());
+        gridData = new GridData();
+        gridData.horizontalAlignment = GridData.FILL;
+        gridData.grabExcessHorizontalSpace = true;
+        editorComposite.setLayoutData(gridData);
+        editorComposite.setDataType(dataType);
+        editorComposite.setValue(((Variable) getValue()).getValue());
+        
+        Composite bottom = new Composite(composite, SWT.NONE);
+        gridData = new GridData();
+        gridData.grabExcessVerticalSpace = true;
+        gridData.horizontalSpan = 2;
+        bottom.setLayoutData(gridData);
+        
+        return composite;
+    }
+    
+    protected Object updateValue(Object value) {
+        Variable variable = (Variable) getValue();
+        variable.setName(nameText.getText());
+        try {
+            variable.setType(dataTypeEditorComposite.getDataType());
+        } catch (IllegalArgumentException e) {
+            showError(e.getMessage());
+            throw e;
+        }
+        try {
+            variable.setValue(editorComposite.getValue());
+        } catch (IllegalArgumentException e) {
+            showError(e.getMessage());
+            throw e;
+        }
+        return variable;
+    }
+    
+    private void showError(String error) {
+        ErrorDialog.openError(getShell(), "Error", error, new Status(
+            IStatus.ERROR, DroolsEclipsePlugin.getDefault().getBundle().getSymbolicName(),
+            IStatus.ERROR, error, null));
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListCellEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListCellEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListCellEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,37 @@
+package org.drools.eclipse.flow.ruleflow.view.property.variable;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.BeanDialogCellEditor;
+import org.drools.eclipse.flow.common.view.property.EditBeanDialog;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Cell edtior for variables.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableListCellEditor extends BeanDialogCellEditor {
+
+    public VariableListCellEditor(Composite parent) {
+        super(parent);
+    }
+
+    protected EditBeanDialog createDialog(Shell shell) {
+        return new VariableListDialog(shell);
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/view/property/variable/VariableListDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,36 @@
+package org.drools.eclipse.flow.ruleflow.view.property.variable;
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import org.drools.eclipse.flow.common.view.property.EditListDialog;
+import org.drools.ruleflow.core.impl.VariableImpl;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Dialog for editing a list of variables.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class VariableListDialog extends EditListDialog {
+    
+    protected VariableListDialog(Shell parentShell) {
+        super(parentShell, "Variable List Editor", VariableDialog.class);
+    }
+
+    protected Object createItem() {
+        return new VariableImpl();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsApplicationLaunchShortcut.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsApplicationLaunchShortcut.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsApplicationLaunchShortcut.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,17 @@
+package org.drools.eclipse.launching;
+
+import org.drools.eclipse.debug.core.IDroolsDebugConstants;
+import org.eclipse.debug.core.ILaunchConfigurationType;
+import org.eclipse.jdt.internal.debug.ui.launcher.JavaApplicationLaunchShortcut;
+
+public class DroolsApplicationLaunchShortcut extends JavaApplicationLaunchShortcut {
+
+	protected ILaunchConfigurationType getConfigurationType() {
+		return getLaunchManager().getLaunchConfigurationType(IDroolsDebugConstants.LAUNCH_CONFIGURATION_TYPE);		
+	}
+
+	protected String getTypeSelectionTitle() {
+		return "Select Drools Application";
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsLaunchConfigurationDelegate.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsLaunchConfigurationDelegate.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsLaunchConfigurationDelegate.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,55 @@
+package org.drools.eclipse.launching;
+
+import java.text.MessageFormat;
+
+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.launching.LaunchingMessages;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.IVMRunner;
+import org.eclipse.jdt.launching.JavaLaunchDelegate;
+
+public class DroolsLaunchConfigurationDelegate extends JavaLaunchDelegate {
+
+	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;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupDirector.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,12 @@
+package org.drools.eclipse.launching;
+
+import org.eclipse.debug.core.sourcelookup.AbstractSourceLookupDirector;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupParticipant;
+
+public class DroolsSourceLookupDirector extends AbstractSourceLookupDirector {
+
+	public void initializeParticipants() {
+		addParticipants(new ISourceLookupParticipant[]{new MVELSourceLookupParticipant(), new DroolsSourceLookupParticipant()} );
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupParticipant.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupParticipant.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourceLookupParticipant.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,26 @@
+package org.drools.eclipse.launching;
+
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.debug.core.DroolsStackFrame;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
+
+public class DroolsSourceLookupParticipant extends JavaSourceLookupParticipant {
+
+	public String getSourceName(Object object) throws CoreException {
+		if (object instanceof DroolsStackFrame) {
+			RuleInfo ruleInfo = ((DroolsStackFrame) object).getExecutingRuleInfo();
+			if (ruleInfo != null) {
+                String p = ruleInfo.getSourcePathName();
+				return p;
+			}
+			FunctionInfo functionInfo = ((DroolsStackFrame) object).getExecutingFunctionInfo();
+			if (functionInfo != null) {
+				return functionInfo.getSourcePathName();
+			}
+		}
+		return super.getSourceName(object);
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourcePathComputerDelegate.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourcePathComputerDelegate.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsSourcePathComputerDelegate.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+package org.drools.eclipse.launching;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.debug.core.sourcelookup.ISourceContainer;
+import org.eclipse.debug.core.sourcelookup.ISourcePathComputerDelegate;
+import org.eclipse.debug.core.sourcelookup.containers.WorkspaceSourceContainer;
+
+public class DroolsSourcePathComputerDelegate implements ISourcePathComputerDelegate {
+
+	public ISourceContainer[] computeSourceContainers(ILaunchConfiguration configuration, IProgressMonitor monitor) throws CoreException {
+		// TODO this shows up the rule in the bin dir
+		// should try to reuse JavaSourcePathComputer
+		return new ISourceContainer[] {new WorkspaceSourceContainer()};
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsVMDebugger.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsVMDebugger.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/DroolsVMDebugger.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,319 @@
+package org.drools.eclipse.launching;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InterruptedIOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.base.mvel.MVELDebugHandler;
+import org.drools.eclipse.debug.core.DroolsDebugModel;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.debug.core.DebugPlugin;
+import org.eclipse.debug.core.ILaunch;
+import org.eclipse.debug.core.IStatusHandler;
+import org.eclipse.debug.core.model.IProcess;
+import org.eclipse.debug.core.model.IStreamsProxy;
+import org.eclipse.jdi.Bootstrap;
+import org.eclipse.jdt.internal.launching.LaunchingMessages;
+import org.eclipse.jdt.internal.launching.LaunchingPlugin;
+import org.eclipse.jdt.internal.launching.LibraryInfo;
+import org.eclipse.jdt.internal.launching.StandardVMDebugger;
+import org.eclipse.jdt.launching.IJavaLaunchConfigurationConstants;
+import org.eclipse.jdt.launching.IVMInstall;
+import org.eclipse.jdt.launching.JavaRuntime;
+import org.eclipse.jdt.launching.SocketUtil;
+import org.eclipse.jdt.launching.VMRunnerConfiguration;
+
+import com.sun.jdi.VirtualMachine;
+import com.sun.jdi.connect.Connector;
+import com.sun.jdi.connect.IllegalConnectorArgumentsException;
+import com.sun.jdi.connect.ListeningConnector;
+
+public class DroolsVMDebugger extends StandardVMDebugger {
+	
+	class ConnectRunnable implements Runnable {
+		
+		private VirtualMachine fVirtualMachine = null;
+		private ListeningConnector fConnector = null;
+		private Map fConnectionMap = null;
+		private Exception fException = null;
+		
+		public ConnectRunnable(ListeningConnector connector, Map map) {
+			fConnector = connector;
+			fConnectionMap = map;
+		}
+		
+		public void run() {
+			try {
+				fVirtualMachine = fConnector.accept(fConnectionMap);
+			} catch (IOException e) {
+				fException = e;
+			} catch (IllegalConnectorArgumentsException e) {
+				fException = e;
+			}
+		}
+		
+		public VirtualMachine getVirtualMachine() {
+			return fVirtualMachine;
+		}
+		
+		public Exception getException() {
+			return fException;
+		}
+	}
+
+	public DroolsVMDebugger(IVMInstall vmInstance) {
+		super(vmInstance);
+	}
+
+	public void run(VMRunnerConfiguration config, ILaunch launch, IProgressMonitor monitor) throws CoreException {
+
+		if (monitor == null) {
+			monitor = new NullProgressMonitor();
+		}
+		
+		IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 1);
+		subMonitor.beginTask(LaunchingMessages.StandardVMDebugger_Launching_VM____1, 4); 
+		subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Finding_free_socket____2); 
+
+		int port= SocketUtil.findFreePort();
+		if (port == -1) {
+			abort(LaunchingMessages.StandardVMDebugger_Could_not_find_a_free_socket_for_the_debugger_1, null, IJavaLaunchConfigurationConstants.ERR_NO_SOCKET_AVAILABLE); 
+		}
+		
+		subMonitor.worked(1);
+		
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}		
+		
+		subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Constructing_command_line____3); 
+				
+		String program= constructProgramString(config);
+
+		List arguments= new ArrayList(12);
+
+		arguments.add(program);
+
+		// VM args are the first thing after the java program so that users can specify
+		// options like '-client' & '-server' which are required to be the first options
+		String[] allVMArgs = combineVmArgs(config, fVMInstance);
+		addArguments(allVMArgs, arguments);
+        arguments.add("-D"+MVELDebugHandler.DEBUG_LAUNCH_KEY+"=true");
+        
+		addBootClassPathArguments(arguments, config);
+		
+		String[] cp= config.getClassPath();
+		if (cp.length > 0) {
+			arguments.add("-classpath"); //$NON-NLS-1$
+			arguments.add(convertClassPath(cp));
+		}
+		double version = getJavaVersion();
+		if (version < 1.5) {
+			arguments.add("-Xdebug"); //$NON-NLS-1$
+			arguments.add("-Xnoagent"); //$NON-NLS-1$
+		}
+		
+		//check if java 1.4 or greater
+		if (version < 1.4) {
+			arguments.add("-Djava.compiler=NONE"); //$NON-NLS-1$
+		}
+		if (version < 1.5) { 
+			arguments.add("-Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
+		} else {
+			arguments.add("-agentlib:jdwp=transport=dt_socket,suspend=y,address=localhost:" + port); //$NON-NLS-1$
+		}
+
+		arguments.add(config.getClassToLaunch());
+		addArguments(config.getProgramArguments(), arguments);
+        
+		String[] cmdLine= new String[arguments.size()];
+		arguments.toArray(cmdLine);
+		
+		String[] envp= config.getEnvironment();
+		
+		// check for cancellation
+		if (monitor.isCanceled()) {
+			return;
+		}		
+		
+		subMonitor.worked(1);
+		subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Starting_virtual_machine____4); 
+
+		ListeningConnector connector= getConnector();
+		if (connector == null) {
+			abort(LaunchingMessages.StandardVMDebugger_Couldn__t_find_an_appropriate_debug_connector_2, null, IJavaLaunchConfigurationConstants.ERR_CONNECTOR_NOT_AVAILABLE); 
+		}
+		Map map= connector.defaultArguments();
+		
+		specifyArguments(map, port);
+		Process p= null;
+		try {
+			try {
+				// check for cancellation
+				if (monitor.isCanceled()) {
+					return;
+				}				
+				
+				connector.startListening(map);
+				
+				File workingDir = getWorkingDir(config);
+				p = exec(cmdLine, workingDir, envp);				
+				if (p == null) {
+					return;
+				}
+				
+				// check for cancellation
+				if (monitor.isCanceled()) {
+					p.destroy();
+					return;
+				}				
+				
+				IProcess process= newProcess(launch, p, renderProcessLabel(cmdLine), getDefaultProcessMap());
+				process.setAttribute(IProcess.ATTR_CMDLINE, renderCommandLine(cmdLine));
+				subMonitor.worked(1);
+				subMonitor.subTask(LaunchingMessages.StandardVMDebugger_Establishing_debug_connection____5); 
+				boolean retry= false;
+				do  {
+					try {
+						
+						ConnectRunnable runnable = new ConnectRunnable(connector, map);
+						Thread connectThread = new Thread(runnable, "Listening Connector"); //$NON-NLS-1$
+                        connectThread.setDaemon(true);
+						connectThread.start();
+						while (connectThread.isAlive()) {
+							if (monitor.isCanceled()) {
+								connector.stopListening(map);
+								p.destroy();
+								return;
+							}
+							try {
+								p.exitValue();
+								// process has terminated - stop waiting for a connection
+								try {
+									connector.stopListening(map); 
+								} catch (IOException e) {
+									// expected
+								}
+								checkErrorMessage(process);
+							} catch (IllegalThreadStateException e) {
+								// expected while process is alive
+							}
+							try {
+								Thread.sleep(100);
+							} catch (InterruptedException e) {
+							}
+						}
+
+						Exception ex = runnable.getException();
+						if (ex instanceof IllegalConnectorArgumentsException)						 {
+							throw (IllegalConnectorArgumentsException)ex;
+						}
+						if (ex instanceof InterruptedIOException) {
+							throw (InterruptedIOException)ex;
+						}
+						if (ex instanceof IOException) {
+							throw (IOException)ex;
+						}
+						
+						VirtualMachine vm= runnable.getVirtualMachine();
+						if (vm != null) {
+							DroolsDebugModel.newDebugTarget(launch, vm, renderDebugTarget(config.getClassToLaunch(), port), process, true, false, config.isResumeOnStartup());
+							subMonitor.worked(1);
+							subMonitor.done();
+						}
+						return;
+					} catch (InterruptedIOException e) {
+						checkErrorMessage(process);
+						
+						// timeout, consult status handler if there is one
+						IStatus status = new Status(IStatus.ERROR, LaunchingPlugin.getUniqueIdentifier(), IJavaLaunchConfigurationConstants.ERR_VM_CONNECT_TIMEOUT, "", e); //$NON-NLS-1$
+						IStatusHandler handler = DebugPlugin.getDefault().getStatusHandler(status);
+						
+						retry= false;
+						if (handler == null) {
+							// if there is no handler, throw the exception
+							throw new CoreException(status);
+						} 
+						Object result = handler.handleStatus(status, this);
+						if (result instanceof Boolean) {
+							retry = ((Boolean)result).booleanValue();
+						}
+					}
+				} while (retry);
+			} finally {
+				connector.stopListening(map);
+			}
+		} catch (IOException e) {
+			abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_4, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);  
+		} catch (IllegalConnectorArgumentsException e) {
+			abort(LaunchingMessages.StandardVMDebugger_Couldn__t_connect_to_VM_5, e, IJavaLaunchConfigurationConstants.ERR_CONNECTION_FAILED);  
+		}
+		if (p != null) {
+			p.destroy();
+		}
+	}
+	
+	private double getJavaVersion() {
+		LibraryInfo libInfo = LaunchingPlugin.getLibraryInfo(fVMInstance.getInstallLocation().getAbsolutePath());
+		if (libInfo == null) {
+		    return 0D;
+		}
+		String version = libInfo.getVersion();
+		int index = version.indexOf("."); //$NON-NLS-1$
+		int nextIndex = version.indexOf(".", index+1); //$NON-NLS-1$
+		try {
+			if (index > 0 && nextIndex>index) {
+				return Double.parseDouble(version.substring(0,nextIndex));
+			} 
+			return Double.parseDouble(version);
+		} catch (NumberFormatException e) {
+			return 0D;
+		}
+
+	}
+
+	protected void checkErrorMessage(IProcess process) throws CoreException {
+		IStreamsProxy streamsProxy = process.getStreamsProxy();
+		if (streamsProxy != null) {
+			String errorMessage= streamsProxy.getErrorStreamMonitor().getContents();
+			if (errorMessage.length() == 0) {
+				errorMessage= streamsProxy.getOutputStreamMonitor().getContents();
+			}
+			if (errorMessage.length() != 0) {
+				abort(errorMessage, null, IJavaLaunchConfigurationConstants.ERR_VM_LAUNCH_ERROR);
+			}
+		}										
+	}
+		
+	protected void specifyArguments(Map map, int portNumber) {
+		// XXX: Revisit - allows us to put a quote (") around the classpath
+		Connector.IntegerArgument port= (Connector.IntegerArgument) map.get("port"); //$NON-NLS-1$
+		port.setValue(portNumber);
+		
+		Connector.IntegerArgument timeoutArg= (Connector.IntegerArgument) map.get("timeout"); //$NON-NLS-1$
+		if (timeoutArg != null) {
+			int timeout = JavaRuntime.getPreferences().getInt(JavaRuntime.PREF_CONNECT_TIMEOUT);
+			timeoutArg.setValue(timeout);
+		}
+	}
+
+	protected ListeningConnector getConnector() {
+		List connectors= Bootstrap.virtualMachineManager().listeningConnectors();
+		for (int i= 0; i < connectors.size(); i++) {
+			ListeningConnector c= (ListeningConnector) connectors.get(i);
+			if ("com.sun.jdi.SocketListen".equals(c.name())) //$NON-NLS-1$
+				return c;
+		}
+		return null;
+	}
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/MVELSourceLookupParticipant.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/MVELSourceLookupParticipant.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/launching/MVELSourceLookupParticipant.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,57 @@
+package org.drools.eclipse.launching;
+
+import org.drools.eclipse.DRLInfo.FunctionInfo;
+import org.drools.eclipse.DRLInfo.RuleInfo;
+import org.drools.eclipse.debug.core.DroolsDebugTarget;
+import org.drools.eclipse.debug.core.MVELStackFrame;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.debug.core.model.IDebugTarget;
+import org.eclipse.debug.core.sourcelookup.ISourceLookupDirector;
+import org.eclipse.jdt.launching.sourcelookup.containers.JavaSourceLookupParticipant;
+
+class MVELSourceLookupParticipant extends JavaSourceLookupParticipant {
+    public void dispose() {
+        //do nothing
+    }
+
+    public Object[] findSourceElements(Object object) throws CoreException {
+        if ( object instanceof MVELStackFrame ) {
+            MVELStackFrame frame = (MVELStackFrame) object;
+
+            //int lineNumber = frame.getBreakpointLineNumber();
+            String mvelName = frame.getMVELName();
+
+            IDebugTarget target = frame.getDebugTarget();
+            if ( target instanceof DroolsDebugTarget ) {
+                DroolsDebugTarget droolsTarget = (DroolsDebugTarget) target;
+                Object bpoint = droolsTarget.getDroolsBreakpoint( mvelName );
+                return new Object[]{bpoint};
+            }
+        }
+        return null;
+    }
+
+    public String getSourceName(Object object) throws CoreException {
+        if ( object instanceof MVELStackFrame ) {
+            MVELStackFrame frame = (MVELStackFrame) object;
+            RuleInfo ruleInfo = frame.getExecutingRuleInfo();
+            if ( ruleInfo != null ) {
+                String sourcePath = ruleInfo.getSourcePathName();
+                return sourcePath;
+            }
+            FunctionInfo functionInfo = frame.getExecutingFunctionInfo();
+            if ( functionInfo != null ) {
+                return functionInfo.getSourcePathName();
+            }
+        }
+        return super.getSourceName( object );
+    }
+
+    public void init(ISourceLookupDirector director) {
+        //do nothing
+    }
+
+    public void sourceContainersChanged(ISourceLookupDirector director) {
+        //do nothing
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/menu/RuleHelperActionDelegate.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,203 @@
+package org.drools.eclipse.menu;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.eclipse.rulebuilder.wizards.NewBrlFileWizard;
+import org.drools.eclipse.wizard.decisiontable.NewDTFileWizard;
+import org.drools.eclipse.wizard.dsl.NewDSLFileWizard;
+import org.drools.eclipse.wizard.project.NewDroolsProjectWizard;
+import org.drools.eclipse.wizard.rule.NewRulePackageWizard;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.MenuItem;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.IWorkbenchWindowPulldownDelegate;
+
+/**
+ * Menu driver for launching wizards etc from the top level toolbar.
+ * 
+ * More can be added to this as needed.
+ * 
+ * @author Michael Neale
+ */
+public class RuleHelperActionDelegate
+    implements
+    IWorkbenchWindowPulldownDelegate {
+
+    private IWorkbench workbench;
+    private Menu menu;
+
+    /** Return a menu which launches the various wizards */
+    public Menu getMenu(Control parent) {
+
+        setMenu( new Menu( parent ) );
+        
+        final Shell shell = parent.getShell();
+        addProjectWizard( menu,
+                shell );
+
+        addRuleWizard( menu,
+                       shell );
+
+        addDSLWizard( menu,
+                      shell );
+        
+        addDTWizard( menu,
+                      shell );        
+        
+        addGuidedEditorWizard( menu,
+                               shell );
+        
+        return menu;
+    }
+    
+    private void setMenu(Menu menu) {
+        if (this.menu != null) {
+            this.menu.dispose();
+        }
+        this.menu = menu;
+    }
+
+    private void addDTWizard(Menu menu,
+                             final Shell shell) {
+        MenuItem dsl = new MenuItem( menu,
+                                     SWT.NONE );
+        dsl.setText( "New Decision Table" );
+        dsl.addSelectionListener( new SelectionListener() {
+
+            public void widgetSelected(SelectionEvent e) {
+                NewDTFileWizard wizard = new NewDTFileWizard();
+                launchWizard( shell, wizard );
+            }
+            public void widgetDefaultSelected(SelectionEvent e) {}
+        });
+        
+    }
+
+    private void addProjectWizard(Menu menu, final Shell shell) {
+		MenuItem rule = new MenuItem(menu, SWT.NONE);
+		rule.setText("New Rule Project");
+
+		rule.addSelectionListener(new SelectionListener() {
+			public void widgetSelected(SelectionEvent e) {
+				NewDroolsProjectWizard wizard = new NewDroolsProjectWizard();
+				launchWizard(shell, wizard);
+			}
+
+			public void widgetDefaultSelected(SelectionEvent e) {
+			}
+		});
+	}
+
+    private void addRuleWizard(Menu menu,
+                               final Shell shell) {
+        MenuItem rule = new MenuItem( menu,
+                                      SWT.NONE );
+        rule.setText( "New Rule resource" );
+
+        rule.addSelectionListener( new SelectionListener() {
+            public void widgetSelected(SelectionEvent e) {
+                NewRulePackageWizard wizard = new NewRulePackageWizard();
+                launchWizard( shell,
+                              wizard );
+            }
+            public void widgetDefaultSelected(SelectionEvent e) {}
+        });
+    }
+
+    private void addDSLWizard(Menu menu,
+                              final Shell shell) {
+        MenuItem dsl = new MenuItem( menu,
+                                     SWT.NONE );
+        dsl.setText( "New Domain Specific Language" );
+        dsl.addSelectionListener( new SelectionListener() {
+
+            public void widgetSelected(SelectionEvent e) {
+                NewDSLFileWizard wizard = new NewDSLFileWizard();
+                launchWizard( shell, wizard );
+            }
+            public void widgetDefaultSelected(SelectionEvent e) {}
+        });
+    }
+    
+    private void addGuidedEditorWizard(Menu menu,
+                                       final Shell shell) {
+        MenuItem dsl = new MenuItem( menu,
+                                     SWT.NONE );
+        dsl.setText( "New Business rule (guided editor)" );
+        dsl.addSelectionListener( new SelectionListener() {
+
+            public void widgetSelected(SelectionEvent e) {
+                NewBrlFileWizard wizard = new NewBrlFileWizard();
+                launchWizard( shell,
+                              wizard );
+            }
+
+            public void widgetDefaultSelected(SelectionEvent e) {
+            }
+        } );
+    }
+
+    private void launchWizard(Shell shell,
+                              INewWizard wizard) {
+        wizard.init( workbench,
+                     new DummySelection() );
+        WizardDialog dialog = new WizardDialog( shell,
+                                                wizard );
+        dialog.open();
+    }    
+
+    public void dispose() {
+    }
+
+    public void init(IWorkbenchWindow window) {
+        workbench = window.getWorkbench();
+    }
+
+    public void run(IAction action) {
+    }
+
+    public void selectionChanged(IAction action,
+                                 ISelection selection) {
+    }
+    
+    /** Stub structured selection listener, as is required to launch the wizard */
+    static class DummySelection implements IStructuredSelection {
+        public Object getFirstElement() {
+            return null;
+        }
+
+        public Iterator iterator() {
+            return (new ArrayList()).iterator();
+        }
+
+        public int size() {
+            return 0;
+        }
+
+        public Object[] toArray() {
+            return null;
+        }
+
+        public List toList() {
+            return null;
+        }
+
+        public boolean isEmpty() {
+            return true;
+        }        
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,80 @@
+package org.drools.eclipse.preferences;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.preference.IPreferenceStore;
+import org.eclipse.jface.preference.PreferencePage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class DroolsPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+	private Button buildAllCheckBox;
+	private Button collapseEditorCheckBox;
+	private Button cacheParsedRulesCheckBox;
+	
+	protected Control createContents(Composite parent) {
+		buildAllCheckBox = createCheckBox(parent,
+			"Automatically reparse all rules if a Java resource is changed.");
+		collapseEditorCheckBox = createCheckBox(parent,
+			"Use code folding in DRL editor.");
+		cacheParsedRulesCheckBox = createCheckBox(parent,
+			"When parsing rules, always cache the result for future use. Warning: when disabled, debugging of rules will not work.");
+
+		initializeValues();
+
+		return new Composite(parent, SWT.NULL);
+	}
+
+	private Button createCheckBox(Composite group, String label) {
+        Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+        button.setText(label);
+        GridData data = new GridData();
+        button.setLayoutData(data);
+        return button;
+    }
+	
+	protected IPreferenceStore doGetPreferenceStore() {
+        return DroolsEclipsePlugin.getDefault().getPreferenceStore();
+    }
+	
+	private void initializeDefaults() {
+        IPreferenceStore store = getPreferenceStore();
+        buildAllCheckBox.setSelection(store.getDefaultBoolean(IDroolsConstants.BUILD_ALL));
+        collapseEditorCheckBox.setSelection(store.getDefaultBoolean(IDroolsConstants.EDITOR_FOLDING));
+        cacheParsedRulesCheckBox.setSelection(store.getDefaultBoolean(IDroolsConstants.CACHE_PARSED_RULES));
+    }
+
+	private void initializeValues() {
+        IPreferenceStore store = getPreferenceStore();
+        buildAllCheckBox.setSelection(store.getBoolean(IDroolsConstants.BUILD_ALL));
+        collapseEditorCheckBox.setSelection(store.getBoolean(IDroolsConstants.EDITOR_FOLDING));
+        cacheParsedRulesCheckBox.setSelection(store.getBoolean(IDroolsConstants.CACHE_PARSED_RULES));
+    }
+
+	protected void performDefaults() {
+        super.performDefaults();
+        initializeDefaults();
+    }
+
+	public boolean performOk() {
+        storeValues();
+        DroolsEclipsePlugin.getDefault().savePluginPreferences();
+        return true;
+    }
+	
+	private void storeValues() {
+        IPreferenceStore store = getPreferenceStore();
+        store.setValue(IDroolsConstants.BUILD_ALL, buildAllCheckBox.getSelection());
+        store.setValue(IDroolsConstants.EDITOR_FOLDING, collapseEditorCheckBox.getSelection());
+        store.setValue(IDroolsConstants.CACHE_PARSED_RULES, cacheParsedRulesCheckBox.getSelection());
+    }
+
+	public void init(IWorkbench workbench) {
+		// do nothing
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+package org.drools.eclipse.preferences;
+
+public interface IDroolsConstants {
+
+	String BUILD_ALL = "Drools.BuildAll";
+	String EDITOR_FOLDING = "Drools.EditorFolding";
+	String CACHE_PARSED_RULES = "Drools.CacheParsedRules";
+	String DRL_EDITOR_MATCHING_BRACKETS = "Drools.DRLMatchingBrackets";
+	String DRL_EDITOR_MATCHING_BRACKETS_COLOR = "Drools.DRLMatchingBracketsColor";
+	
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/BrlPage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/BrlPage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/BrlPage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,69 @@
+package org.drools.eclipse.rulebuilder.editors;
+
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.brms.server.util.BRXMLPersistence;
+import org.drools.eclipse.rulebuilder.ui.RuleModeller;
+import org.eclipse.ui.forms.IManagedForm;
+import org.eclipse.ui.forms.editor.FormPage;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+
+/**
+ * Rule Builder main page used as a tab in {@link RuleEditor} multipage.
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class BrlPage extends FormPage {
+
+    private static final String PAGE_NAME = "Rule Builder";
+    private static final String PAGE_ID   = BrlPage.class.getName();
+
+    private RuleModeller        modeller;
+    private RuleModel           model;
+    private RuleEditor          editor;
+
+    public BrlPage(RuleEditor editor) {
+        super( editor,
+               PAGE_ID,
+               PAGE_NAME );
+        this.editor = editor;
+    }
+
+    protected void createFormContent(IManagedForm managedForm) {
+        ScrolledForm form = managedForm.getForm();
+        FormToolkit toolkit = managedForm.getToolkit();
+
+        modeller = new RuleModeller( form,
+                                     toolkit,
+                                     model,
+                                     editor );
+    }
+
+    public void setModelXML(String xml) {
+        model = BRXMLPersistence.getInstance().unmarshal( xml );
+        modeller.setModel( model );
+        modeller.reloadWidgets();
+    }
+
+    public RuleModel getRuleModel() {
+        return model;
+    }
+
+    public RuleModeller getModeller() {
+        return modeller;
+    }
+
+    public boolean isDirty() {
+        return modeller.isDirty();
+    }
+
+    public void fireDirtyPropertyChanged() {
+        editor.dirtyPropertyChanged();
+    }
+
+    public void refresh() {
+        modeller.refresh();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/editors/RuleEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,394 @@
+package org.drools.eclipse.rulebuilder.editors;
+
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintWriter;
+import java.io.Reader;
+import java.io.StringReader;
+import java.io.StringWriter;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.server.rules.SuggestionCompletionLoader;
+import org.drools.brms.server.util.BRDRLPersistence;
+import org.drools.brms.server.util.BRXMLPersistence;
+import org.drools.compiler.DrlParser;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.dsl.editor.DSLAdapter;
+import org.drools.eclipse.editors.DRLDocumentProvider;
+import org.drools.eclipse.editors.DRLRuleEditor;
+import org.drools.eclipse.util.ProjectClassLoader;
+import org.drools.lang.dsl.DSLMappingFile;
+import org.eclipse.core.internal.resources.Container;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.editors.text.TextEditor;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.ide.ResourceUtil;
+import org.eclipse.ui.part.FileEditorInput;
+import org.eclipse.ui.texteditor.DocumentProviderRegistry;
+import org.eclipse.ui.texteditor.IDocumentProvider;
+
+public class RuleEditor extends FormEditor
+    implements
+    IResourceChangeListener {
+
+    private BrlPage                    guidedEditor;
+
+    private TextEditor                 xmlEditor          = new TextEditor();
+
+    private SuggestionCompletionEngine completion;
+
+    private SuggestionCompletionLoader loader;
+
+    private FileEditorInput            packageEditorInput;
+
+    private final Document             drlDocument;
+
+    private IResourceChangeListener    packageFileTracker = new IResourceChangeListener() {
+
+                                                              public void resourceChanged(IResourceChangeEvent event) {
+                                                                  IResourceDelta delta = getRootDelta( event.getDelta() );
+
+                                                                  IPath p1 = delta.getFullPath();
+                                                                  IPath p2 = packageEditorInput.getFile().getFullPath();
+                                                                  if ( p1.equals( p2 ) ) {
+                                                                      reloadCompletionEngine();
+                                                                  }
+
+                                                              }
+
+                                                          };
+
+    public RuleEditor() {
+        super();
+        ResourcesPlugin.getWorkspace().addResourceChangeListener( this );
+        ResourcesPlugin.getWorkspace().addResourceChangeListener( packageFileTracker,
+                                                                  IResourceChangeEvent.POST_CHANGE );
+        drlDocument = new Document();
+
+    }
+
+    protected FormToolkit createToolkit(Display display) {
+        // Create a toolkit that shares colors between editors.
+        return new FormToolkit( DroolsEclipsePlugin.getDefault().getRuleBuilderFormColors( display ) );
+    }
+
+    protected void addPages() {
+        guidedEditor = new BrlPage( this );
+        try {
+            addPage( guidedEditor );
+            addPage( xmlEditor,
+                     getEditorInput() );
+
+            DRLRuleEditor drlEditor = new DRLRuleEditor() {
+                protected IDocumentProvider createDocumentProvider() {
+                    return new DRLDocumentProvider() {
+                        public boolean isReadOnly(Object element) {
+                            return true;
+                        }
+
+                        public boolean isModifiable(Object element) {
+                            return false;
+                        }
+
+                        protected IDocument getParentDocument(Object element) {
+                            return drlDocument;
+                        }
+                    };
+                }
+
+            };
+
+            addPage( drlEditor,
+                     xmlEditor.getEditorInput() );
+
+            IPath packagePath = getCurrentDirectoryPath( getEditorInput() ).append( "rule.package" );
+
+            IFile file = ResourcesPlugin.getWorkspace().getRoot().getFile( packagePath );
+
+            IJavaProject javaProject = JavaCore.create( file.getProject() );
+
+            ClassLoader classLoader = ProjectClassLoader.getProjectClassLoader( javaProject );
+
+            loader = new SuggestionCompletionLoader( classLoader );
+
+            if ( !file.exists() ) {
+                String defaultHeader = "//This is a package configuration file";
+                defaultHeader += "\n//Add imports, globals etc here which will be used by all the rule assets in thise folder.";
+                InputStream is = new ByteArrayInputStream( defaultHeader.getBytes() );
+                try {
+                    file.create( is,
+                                 true,
+                                 null );
+                } catch ( CoreException e ) {
+                    DroolsEclipsePlugin.log( e );
+                }
+            }
+
+            packageEditorInput = new FileEditorInput( file );
+
+            reloadCompletionEngine();
+
+            setPageText( 1,
+                         "BRL Source" );
+
+            setPageText( 2,
+                         "Generated DRL (read-only)" );
+
+            updateName( false );
+
+        } catch ( PartInitException e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+    }
+
+    private void updateName(boolean forced) {
+        String name = xmlEditor.getTitle();
+        setPartName( name );
+
+        //TODO Add support for other than .brl extensions
+        if ( guidedEditor.getModeller() != null && guidedEditor.getModeller().getModel() != null && (guidedEditor.getModeller().getModel().name == null || forced) ) {
+            String shortName = name.substring( 0,
+                                               name.length() - ".brl".length() );
+            guidedEditor.getModeller().getModel().name = shortName;
+        }
+
+        updateDRLPage();
+
+    }
+
+    private IPath getCurrentDirectoryPath(IEditorInput editorInput) {
+        return ((FileEditorInput) editorInput).getFile().getFullPath().removeLastSegments( 1 ).addTrailingSeparator();
+    }
+
+    private void reloadCompletionEngine() {
+        try {
+
+            // Load all .dsl files from current dir
+            IPath p = (packageEditorInput).getFile().getFullPath().removeLastSegments( 1 );
+
+            Container folder = (Container) ResourcesPlugin.getWorkspace().getRoot().findMember( p,
+                                                                                                false );
+
+            IResource[] files = folder.members( false );
+
+            List dslList = new ArrayList();
+
+            for ( int i = 0; i < files.length; i++ ) {
+                if ( files[i].getName().endsWith( ".dsl" ) ) {
+                    String contents = getFileContents( (IFile) files[i] );
+                    DSLMappingFile dsl = new DSLMappingFile();
+
+                    if ( dsl.parseAndLoad( new StringReader( contents ) ) ) {
+                        dslList.add( dsl );
+                    } else {
+                        //TODO report dsl parse error
+                    }
+                }
+            }
+
+            // Load suggestion engine
+            String str = getFileContents( packageEditorInput.getFile() );
+
+            completion = loader.getSuggestionEngine( str,
+                                                     dslList,
+                                                     dslList );
+
+        } catch ( Exception e ) {
+            DroolsEclipsePlugin.log( e );
+        }
+    }
+
+    private String getFileContents(IFile file) {
+
+        InputStream is;
+        try {
+            is = file.getContents();
+
+            StringBuffer out = new StringBuffer();
+            byte[] b = new byte[4096];
+            for ( int n; (n = is.read( b )) != -1; ) {
+                out.append( new String( b,
+                                        0,
+                                        n ) );
+            }
+
+            return out.toString();
+        } catch ( CoreException e ) {
+            //TODO Report problem with the file loading
+            return "";
+        } catch ( IOException e ) {
+            //TODO Report problem with the file loading
+            return "";
+        }
+
+    }
+
+    public boolean isDirty() {
+        return xmlEditor.isDirty() || guidedEditor.isDirty();
+    }
+
+    protected void pageChange(int newPageIndex) {
+        super.pageChange( newPageIndex );
+
+        IDocument document = getInputDocument();
+
+        if ( newPageIndex == 0 ) {
+
+            boolean newModel = guidedEditor.getModeller().getModel() == null;
+            if ( xmlEditor.isDirty() || newModel ) {
+                guidedEditor.setModelXML( document.get() );
+                if ( newModel ) {
+                    guidedEditor.getModeller().setDirty( false );
+                }
+                updateName( false );
+            }
+
+            guidedEditor.refresh();
+
+        } else if ( newPageIndex == 1 ) {
+
+            if ( guidedEditor.isDirty() ) {
+                document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
+            }
+        } else if ( newPageIndex == 2 ) {
+
+            //Updating main document for proper workflow when page is switched back to "0"
+            if ( guidedEditor.isDirty() ) {
+                document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
+            } else if ( xmlEditor.isDirty() ) {
+                guidedEditor.setModelXML( document.get() );
+            }
+
+            updateDRLPage();
+
+            updateName( false );
+
+        }
+
+    }
+
+    private void updateDRLPage() {
+
+        String drl = "";
+        try {
+            drl = BRDRLPersistence.getInstance().marshal( guidedEditor.getRuleModel() );
+
+            IResource resource = ResourceUtil.getResource( xmlEditor.getEditorInput() );
+
+            Reader reader = DSLAdapter.getDSLContent( drl,
+                                                      resource );
+            DrlParser parser = new DrlParser();
+
+            if ( reader != null ) {
+                drl = parser.getExpandedDRL( drl,
+                                             reader );
+            }
+
+        } catch ( Throwable t ) {
+
+            StringWriter strwriter = new StringWriter();
+            t.printStackTrace( new PrintWriter( strwriter ) );
+            drl = "\nPROBLEM WITH THE DRL CONVERSION!\n\n\nDRL:\n" + drl + "\n\nSTACKTRACE:\n" + strwriter.toString();
+        }
+        drlDocument.set( drl );
+    }
+
+    public void doSave(IProgressMonitor monitor) {
+        IDocument document = getInputDocument();
+
+        if ( xmlEditor.isDirty() ) {
+            guidedEditor.setModelXML( document.get() );
+        } else if ( guidedEditor.isDirty() ) {
+            document.set( BRXMLPersistence.getInstance().marshal( guidedEditor.getRuleModel() ) );
+        }
+
+        xmlEditor.doSave( monitor );
+
+        guidedEditor.getModeller().setDirty( false );
+
+        guidedEditor.refresh();
+
+    }
+
+    private IDocument getInputDocument() {
+        IEditorInput input = getEditorInput();
+        IDocumentProvider docProvider = DocumentProviderRegistry.getDefault().getDocumentProvider( input );
+        IDocument document = docProvider.getDocument( input );
+        return document;
+    }
+
+    public void doSaveAs() {
+        xmlEditor.doSaveAs();
+        guidedEditor.getModeller().setDirty( false );
+        updateName( true );
+        setInput( xmlEditor.getEditorInput() );
+
+        guidedEditor.refresh();
+
+    }
+
+    public boolean isSaveAsAllowed() {
+        return true;
+    }
+
+    public void resourceChanged(final IResourceChangeEvent event) {
+        if ( event.getType() == IResourceChangeEvent.PRE_CLOSE ) {
+            Display.getDefault().asyncExec( new Runnable() {
+                public void run() {
+                    IWorkbenchPage[] pages = getSite().getWorkbenchWindow().getPages();
+                    for ( int i = 0; i < pages.length; i++ ) {
+                        if ( ((FileEditorInput) xmlEditor.getEditorInput()).getFile().getProject().equals( event.getResource() ) ) {
+                            IEditorPart editorPart = pages[i].findEditor( xmlEditor.getEditorInput() );
+                            pages[i].closeEditor( editorPart,
+                                                  true );
+                        }
+                    }
+                }
+            } );
+        }
+    }
+
+    public void dispose() {
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener( this );
+        ResourcesPlugin.getWorkspace().removeResourceChangeListener( packageFileTracker );
+        super.dispose();
+    }
+
+    public void dirtyPropertyChanged() {
+        firePropertyChange( IEditorPart.PROP_DIRTY );
+        guidedEditor.refresh();
+    }
+
+    public SuggestionCompletionEngine getCompletionEngine() {
+        return completion;
+    }
+
+    private IResourceDelta getRootDelta(IResourceDelta delta) {
+        if ( delta.getAffectedChildren().length > 0 ) {
+            return getRootDelta( delta.getAffectedChildren()[0] );
+        }
+        return delta;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/modeldriven/HumanReadable.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,140 @@
+package org.drools.eclipse.rulebuilder.modeldriven;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+import java.util.Set;
+
+/**
+ * This contains some simple mappings between operators, conditional elements
+ * and the human readable equivalent.
+ *
+ * Yes, I am making the presumption that programmers are not human, but I think
+ * they (we) are cool with that.
+ *
+ * @author Michael Neale
+ */
+public class HumanReadable {
+
+    public static Map            operatorDisplayMap   = new HashMap();
+
+    public static Map            ceDisplayMap         = new HashMap();
+
+    public static Map            actionDisplayMap     = new HashMap();
+
+    public static final String[] CONDITIONAL_ELEMENTS = new String[]{"not", "exists", "or"};
+
+    static {
+        operatorDisplayMap.put( "==",
+                                "is equal to" );
+        operatorDisplayMap.put( "!=",
+                                "is not equal to" );
+        operatorDisplayMap.put( "<",
+                                "is less than" );
+        operatorDisplayMap.put( "<=",
+                                "less than or equal to" );
+        operatorDisplayMap.put( ">",
+                                "greater than" );
+        operatorDisplayMap.put( ">=",
+                                "greater than or equal to" );
+        operatorDisplayMap.put( "soundslike", "sounds like" );
+
+        operatorDisplayMap.put( "|| ==",
+                                "or equal to" );
+        operatorDisplayMap.put( "|| !=",
+                                "or not equal to" );
+        operatorDisplayMap.put( "&& !=",
+                                "and not equal to" );
+        operatorDisplayMap.put( "&& >",
+                                "and greater than" );
+        operatorDisplayMap.put( "&& <",
+                                "and less than" );
+        operatorDisplayMap.put( "|| >",
+                                "or greater than" );
+        operatorDisplayMap.put( "|| <",
+                                "or less than" );
+
+        operatorDisplayMap.put( "|| >=",
+                                "or greater than (or equal to)" );
+        operatorDisplayMap.put( "|| <=",
+                                "or less than (or equal to)" );
+        operatorDisplayMap.put( "&& >=",
+                                "and greater than (or equal to)" );
+        operatorDisplayMap.put( "&& <=",
+                                "or less than (or equal to)" );
+        operatorDisplayMap.put( "&& contains",
+                                "and contains" );
+        operatorDisplayMap.put( "|| contains",
+                                "or contains" );
+        operatorDisplayMap.put( "&& matches",
+                                "and matches" );
+        operatorDisplayMap.put( "|| matches",
+                                "or matches" );
+        operatorDisplayMap.put( "|| excludes",
+                                "or excludes" );
+        operatorDisplayMap.put( "&& excludes",
+                                "and excludes" );
+
+        ceDisplayMap.put( "not",
+                          "There is no" );
+        ceDisplayMap.put( "exists",
+                          "There exists" );
+        ceDisplayMap.put( "or",
+                          "Any of" );
+
+        actionDisplayMap.put( "assert",
+                              "Insert" );
+        actionDisplayMap.put( "assertLogical",
+                              "Logically insert" );
+        actionDisplayMap.put( "retract",
+                              "Retract" );
+        actionDisplayMap.put( "set",
+                              "Set" );
+        actionDisplayMap.put( "modify",
+                              "Modify" );
+
+    }
+
+    public static String getActionDisplayName(String action) {
+        return lookup( action,
+                       actionDisplayMap );
+    }
+
+    public static String getOperatorDisplayName(String op) {
+        return lookup( op,
+                       operatorDisplayMap );
+    }
+
+    public static String getCEDisplayName(String ce) {
+        return lookup( ce,
+                       ceDisplayMap );
+    }
+
+    private static String lookup(String ce,
+                                 Map map) {
+        if ( map.containsKey( ce ) ) {
+            return (String) map.get( ce );
+        } else {
+            return ce;
+        }
+    }
+
+    /**
+     * get operator by its display name
+     *
+     * @param op
+     *            operator display name
+     * @return operator
+     */
+    public static String getOperatorName(String op) {
+        Set keys = operatorDisplayMap.keySet();
+        for ( Iterator iter = keys.iterator(); iter.hasNext(); ) {
+            String key = (String) iter.next();
+            if ( op.equals( operatorDisplayMap.get( key ) ) ) {
+                return key;
+            }
+        }
+        throw new RuntimeException( "No operator display name '" + op + "' was found." );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionInsertFactWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,172 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ActionInsertFact;
+import org.drools.brms.client.modeldriven.brl.ActionFieldValue;
+import org.drools.brms.client.modeldriven.brl.ActionInsertLogicalFact;
+import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+/**
+ * 
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class ActionInsertFactWidget extends Widget {
+
+    private final ActionInsertFact fact;
+
+    public ActionInsertFactWidget(FormToolkit toolkit,
+                                  Composite parent,
+                                  RuleModeller mod,
+                                  ActionInsertFact fact,
+                                  int index) {
+        super( parent,
+               toolkit,
+               mod,
+               index );
+
+        this.fact = fact;
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 4;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        l.verticalSpacing = 0;
+        parent.setLayout( l );
+
+        create();
+    }
+
+    private void create() {
+
+        String assertType = "assert";
+        if ( fact instanceof ActionInsertLogicalFact ) {
+            assertType = "assertLogical";
+        }
+
+        toolkit.createLabel( parent,
+                             HumanReadable.getActionDisplayName( assertType ) + " " + this.fact.factType );
+        addDeleteRHSAction();
+        addMoreOptionsAction();
+        Composite constraintComposite = toolkit.createComposite( parent );
+        GridLayout constraintLayout = new GridLayout();
+        constraintLayout.numColumns = 3;
+        constraintComposite.setLayout( constraintLayout );
+        createConstraintRows( constraintComposite );
+        toolkit.paintBordersFor( constraintComposite );
+    }
+
+    private void addMoreOptionsAction() {
+        final Shell shell = new Shell( Display.getCurrent() );
+        ImageHyperlink link = addImage( parent,
+                                        "icons/new_item.gif" );
+
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddNewInsertedFactFieldDialog( shell,
+                                                                      getModeller(),
+                                                                      fact );
+                popup.open();
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        link.setToolTipText( "Add another field to this so you can set its value" );
+    }
+
+    private void createConstraintRows(Composite constraintComposite) {
+        for ( int row = 0; row < fact.fieldValues.length; row++ ) {
+            ActionFieldValue val = fact.fieldValues[row];
+            toolkit.createLabel( constraintComposite,
+                                 val.field );
+            valueEditor( constraintComposite,
+                         val );
+            addRemoveFieldAction( constraintComposite,
+                                  row );
+        }
+    }
+
+    private void addRemoveFieldAction(Composite constraintComposite,
+                                      final int row) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this field action" );
+
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    fact.removeField( row );
+                    getModeller().setDirty( true );
+                    getModeller().reloadRhs();
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+    }
+
+    private void valueEditor(Composite parent,
+                             final ActionFieldValue val) {
+        final Text box = toolkit.createText( parent,
+                                             "" );
+
+        if ( val.value != null ) {
+            box.setText( val.value );
+        }
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
+        box.setLayoutData( gd );
+
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                getModeller().setDirty( true );
+                val.value = box.getText();
+            }
+        } );
+
+        if (val.type.equals( SuggestionCompletionEngine.TYPE_NUMERIC )) {
+        	new NumericKeyFilter(box);
+        } 
+        
+        
+    }
+
+    public SuggestionCompletionEngine getCompletion() {
+        return getModeller().getSuggestionCompletionEngine();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionRetractFactWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,53 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.ActionRetractFact;
+import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * 
+ * @author Anton Arhipov
+ *
+ */
+public class ActionRetractFactWidget extends Widget {
+
+    private final ActionRetractFact fact;
+
+    public ActionRetractFactWidget(FormToolkit toolkit,
+                                   Composite parent,
+                                   RuleModeller modeller,
+                                   ActionRetractFact fact,
+                                   int index) {
+
+        super( parent,
+               toolkit,
+               modeller,
+               index );
+
+        this.fact = fact;
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 4;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        l.verticalSpacing = 0;
+        parent.setLayout( l );
+
+        create();
+    }
+
+    private void create() {
+        toolkit.createLabel( parent,
+                             HumanReadable.getActionDisplayName( "retract" ) );
+        toolkit.createLabel( parent,
+                             "[" + fact.variableName + "]" );
+        addDeleteRHSAction();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,84 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.ActionFieldValue;
+import org.drools.brms.client.modeldriven.brl.ActionSetField;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class ActionSetFieldDialog extends RuleDialog {
+
+    private String[]       fieldCompletions;
+
+    private RuleModeller   modeller;
+
+    private ActionSetField field;
+
+    private String         variableClass;
+
+    public ActionSetFieldDialog(Shell parent,
+                                RuleModeller modeller,
+                                ActionSetField field,
+                                String[] fieldCompletions,
+                                String variableClass) {
+        super( parent,
+               "Add a field",
+               "Add a field" );
+
+        this.fieldCompletions = fieldCompletions;
+        this.modeller = modeller;
+        this.field = field;
+        this.variableClass = variableClass;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+        createLabel( composite,
+                     "Add a field" );
+
+        final Combo fieldsCombo = new Combo( parent,
+                                             SWT.READ_ONLY );
+        fieldsCombo.add( "Choose field..." );
+        for ( int i = 0; i < fieldCompletions.length; i++ ) {
+            fieldsCombo.add( fieldCompletions[i] );
+        }
+        fieldsCombo.select( 0 );
+
+        fieldsCombo.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                if ( fieldsCombo.getSelectionIndex() == 0 ) {
+                    return; // no need to change anything
+                }
+
+                String fieldType = modeller.getSuggestionCompletionEngine().getFieldType( variableClass,
+                                                                                          fieldsCombo.getText() );
+                field.addFieldValue( new ActionFieldValue( fieldsCombo.getText(),
+                                                           "",
+                                                           fieldType ) );
+
+                
+                getShell().getDisplay().asyncExec( new Runnable() {
+
+                    public void run() {
+                        modeller.reloadRhs();
+                        modeller.setDirty( true );
+                        close();
+                    }
+
+                } );
+            }
+        } );
+
+        return composite;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ActionSetFieldWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,181 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ActionFieldValue;
+import org.drools.brms.client.modeldriven.brl.ActionSetField;
+import org.drools.brms.client.modeldriven.brl.ActionUpdateField;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+/**
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ *
+ */
+public class ActionSetFieldWidget extends Widget {
+
+	private ActionSetField set;
+
+	final private String[] fieldCompletions;
+
+	private boolean isBoundFact = false;
+
+	private String variableClass;
+
+	public ActionSetFieldWidget(FormToolkit toolkit, Composite parent,
+			RuleModeller mod, RuleModel rule, ActionSetField set, int index) {
+
+		super(parent, toolkit, mod, index);
+
+		this.set = set;
+
+		if (getCompletion().isGlobalVariable(set.variable)) {
+			this.fieldCompletions = getCompletion()
+					.getFieldCompletionsForGlobalVariable(set.variable);
+			this.variableClass = (String) getCompletion().globalTypes
+					.get(set.variable);
+		} else {
+			FactPattern pattern = rule.getBoundFact(set.variable);
+			this.fieldCompletions = getCompletion().getFieldCompletions(
+					pattern.factType);
+			this.isBoundFact = true;
+			this.variableClass = pattern.factType;
+		}
+
+		GridLayout l = new GridLayout();
+		l.numColumns = 6;
+		l.marginBottom = 0;
+		l.marginHeight = 0;
+		l.marginLeft = 0;
+		l.marginRight = 0;
+		l.marginTop = 0;
+		l.marginWidth = 0;
+		l.verticalSpacing = 0;
+		parent.setLayout(l);
+
+		create();
+
+	}
+
+	private void create() {
+		String modifyType = "set";
+		if (this.set instanceof ActionUpdateField) {
+			modifyType = "modify";
+		}
+
+		toolkit.createLabel(parent, HumanReadable
+				.getActionDisplayName(modifyType)
+				+ " [" + this.set.variable + "]");
+		addDeleteRHSAction();
+		addMoreOptionsAction();
+		addRows();
+	}
+
+	private void addRows() {
+		Composite constraintComposite = toolkit.createComposite(parent);
+		GridLayout constraintLayout = new GridLayout();
+		constraintLayout.numColumns = 3;
+		constraintComposite.setLayout(constraintLayout);
+
+		for (int i = 0; i < set.fieldValues.length; i++) {
+			ActionFieldValue val = set.fieldValues[i];
+			toolkit.createLabel(constraintComposite, val.field);
+			valueEditor(constraintComposite, val);
+			addRemoveFieldAction(constraintComposite, i);
+		}
+
+		toolkit.paintBordersFor(constraintComposite);
+	}
+
+	private void addMoreOptionsAction() {
+		// ImageHyperlink link = addImage(parent,
+		// "icons/add_field_to_fact.gif");
+		ImageHyperlink link = addImage(parent, "icons/new_item.gif");
+
+		link.addHyperlinkListener(new IHyperlinkListener() {
+			public void linkActivated(HyperlinkEvent e) {
+				RuleDialog popup = new ActionSetFieldDialog(parent.getShell(),
+						getModeller(), set, fieldCompletions, variableClass);
+				popup.open();
+
+			}
+
+			public void linkEntered(HyperlinkEvent e) {
+			}
+
+			public void linkExited(HyperlinkEvent e) {
+			}
+		});
+		link.setToolTipText("Add a field");
+	}
+
+	private void addRemoveFieldAction(Composite constraintComposite,
+			final int currentRow) {
+		ImageHyperlink delLink = addImage(constraintComposite,
+				"icons/delete_item_small.gif");
+		delLink.setToolTipText("Remove this field action");
+		delLink.addHyperlinkListener(new IHyperlinkListener() {
+			public void linkActivated(HyperlinkEvent e) {
+				MessageBox dialog = new MessageBox(Display.getCurrent()
+						.getActiveShell(), SWT.YES | SWT.NO | SWT.ICON_WARNING);
+				dialog.setMessage("Remove this item?");
+				dialog.setText("Remove this item?");
+				if (dialog.open() == SWT.YES) {
+					set.removeField(currentRow);
+					getModeller().setDirty(true);
+					getModeller().reloadRhs();
+				}
+			}
+
+			public void linkEntered(HyperlinkEvent e) {
+			}
+
+			public void linkExited(HyperlinkEvent e) {
+			}
+		});
+	}
+
+	private void valueEditor(Composite parent, final ActionFieldValue val) {
+		final Text box = toolkit.createText(parent, "");
+
+		if (val.value != null) {
+			box.setText(val.value);
+		}
+
+		GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
+        box.setLayoutData( gd );
+
+		box.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				val.value = box.getText();
+				getModeller().setDirty(true);
+			}
+		});
+
+		if (val.type.equals(SuggestionCompletionEngine.TYPE_NUMERIC)) {
+			new NumericKeyFilter(box);
+		}
+
+	}
+
+	private SuggestionCompletionEngine getCompletion() {
+		return getModeller().getSuggestionCompletionEngine();
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddCompositeConstraintOptionDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,125 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.CompositeFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class AddCompositeConstraintOptionDialog extends RuleDialog {
+
+    private RuleModeller                   modeller;
+
+    private FactPattern                    pattern;
+
+    private final CompositeFieldConstraint constraint;
+
+    public AddCompositeConstraintOptionDialog(Shell parent,
+                                              RuleModeller modeller,
+                                              CompositeFieldConstraint constraint,
+                                              FactPattern pattern) {
+        super( parent,
+               "Add fields to this constriant",
+               "Pick the value from combo." );
+
+        this.modeller = modeller;
+        this.constraint = constraint;
+        this.pattern = pattern;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+
+        createFieldRestrictionCombo( composite,
+                                     gd );
+        createMultiFieldCombo( composite,
+                               gd );
+
+        return composite;
+    }
+
+    private void createFieldRestrictionCombo(Composite composite,
+                                             GridData gd) {
+        createLabel( composite,
+                     "Add a restriction on a field" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        combo.add( "..." );
+        String[] fields = this.modeller.getSuggestionCompletionEngine().getFieldCompletions( this.pattern.factType );
+        for ( int i = 0; i < fields.length; i++ ) {
+            combo.add( fields[i] );
+        }
+        combo.select( 0 );
+
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
+
+                                   constraint.addConstraint( new SingleFieldConstraint( combo.getText() ) );
+                                   modeller.setDirty( true );
+                                   modeller.reloadLhs();
+                                   close();
+                               }
+                           } );
+
+    }
+
+    private void createMultiFieldCombo(Composite composite,
+                                       GridData gd) {
+        createLabel( composite,
+                     "Multiple field constraint" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        combo.add( "..." );
+        combo.add( "All of (And)" );
+        combo.add( "Any of (Or)" );
+        combo.setData( "All of (And)",
+                       CompositeFieldConstraint.COMPOSITE_TYPE_AND );
+        combo.setData( "Any of (Or)",
+                       CompositeFieldConstraint.COMPOSITE_TYPE_OR );
+        combo.select( 0 );
+
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
+                                   CompositeFieldConstraint comp = new CompositeFieldConstraint();
+                                   comp.compositeJunctionType = combo.getText();
+                                   constraint.addConstraint( comp );
+
+                                   modeller.reloadLhs();
+                                   modeller.setDirty( true );
+                                   close();
+                               }
+                           } );
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewActionDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,263 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.Arrays;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ActionInsertFact;
+import org.drools.brms.client.modeldriven.brl.ActionInsertLogicalFact;
+import org.drools.brms.client.modeldriven.brl.ActionRetractFact;
+import org.drools.brms.client.modeldriven.brl.ActionSetField;
+import org.drools.brms.client.modeldriven.brl.ActionUpdateField;
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This provides a popup for new RHS action selection.
+ *
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ */
+public class AddNewActionDialog extends RuleDialog {
+
+    private RuleModeller      modeller;
+
+    public AddNewActionDialog(Shell parent,
+                              RuleModeller modeller) {
+        super( parent,
+               "Add a new action",
+               "Pick the values from combos and confirm the selection." );
+        this.modeller = modeller;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+        String heading = "Choose...";
+
+        createValuesOfFieldPart( composite,
+                                   heading );
+
+        createModifyFieldPart( composite,
+                                 heading );
+
+        createRetractFieldPart(composite, heading);
+
+
+        String[] facts = getCompletion().getFactTypes();
+
+        createFactAssertionPart( composite,
+                                 heading,
+                                 facts );
+
+        createFactLogicalAssertionPart( composite,
+                                        heading,
+                                        facts );
+
+        createDslSentences( composite,
+                            heading );
+
+        return composite;
+    }
+
+    private void createRetractFieldPart(Composite composite, String heading) {
+    	createLabel( composite, "Retract the fact" );
+
+    	final Combo factsCombo = new Combo( composite, SWT.READ_ONLY );
+
+    	factsCombo.add( heading );
+
+    	List boundFacts = modeller.getModel().getBoundFacts();
+
+        for ( int i = 0; i < boundFacts.size(); i++ ) {
+            factsCombo.add( (String) boundFacts.get( i ) );
+        }
+        factsCombo.select( 0 );
+
+        factsCombo.addListener( SWT.Selection,
+                new Listener() {
+                    public void handleEvent(Event event) {
+                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                            return;
+                        }
+
+                        modeller.getModel().addRhsItem( new ActionRetractFact(factsCombo.getText()) );
+
+                        modeller.setDirty( true );
+                        modeller.reloadRhs();
+                        close();
+                    }
+                } );
+
+	}
+
+	private void createModifyFieldPart(Composite composite,
+                                       String heading) {
+        createLabel( composite,
+                     "Modify a field on a fact" );
+        final Combo factsCombo = new Combo( composite,
+                                                 SWT.READ_ONLY );
+        factsCombo.add( heading );
+
+        List boundFacts = modeller.getModel().getBoundFacts();
+
+        for ( int i = 0; i < boundFacts.size(); i++ ) {
+            factsCombo.add( (String) boundFacts.get( i ) );
+        }
+        factsCombo.select( 0 );
+
+        factsCombo.addListener( SWT.Selection,
+                                     new Listener() {
+                                         public void handleEvent(Event event) {
+                                             if ( factsCombo.getSelectionIndex() == 0 ) {
+                                                 return;
+                                             }
+
+                                             modeller.getModel().addRhsItem(new ActionUpdateField(factsCombo.getText()));
+
+                                             modeller.setDirty( true );
+                                             modeller.reloadRhs();
+                                             close();
+                                         }
+                                     } );
+
+    }
+
+    private void createDslSentences(Composite composite,
+                                    String heading) {
+        if ( getCompletion().getDSLActions().length > 0 ) {
+            createLabel( composite,
+                         "Actions" );
+
+            final Combo dslCombo = new Combo( composite,
+                                              SWT.READ_ONLY );
+            dslCombo.add( heading );
+            for ( int i = 0; i < getCompletion().getDSLActions().length; i++ ) {
+                DSLSentence sen = getCompletion().getDSLActions()[i];
+                dslCombo.add( sen.toString() );
+            }
+
+            dslCombo.select( 0 );
+
+            dslCombo.addListener( SWT.Selection,
+                                  new Listener() {
+                                      public void handleEvent(Event event) {
+                                          if ( dslCombo.getSelectionIndex() == 0 ) {
+                                              return;
+                                          }
+
+                                          DSLSentence sentence = getCompletion().getDSLActions()[dslCombo.getSelectionIndex() - 1];
+										  modeller.getModel().addRhsItem( sentence.copy() );
+                                          modeller.setDirty( true );
+                                          modeller.reloadRhs();
+                                          close();
+                                      }
+                                  } );
+
+        }
+    }
+
+    private void createFactLogicalAssertionPart(Composite composite,
+                                                String heading,
+                                                String[] facts) {
+        createLabel( composite,
+                     "Logically insert a new fact" );
+        final Combo factsCombo = createFactsCombo( composite,
+                                                   heading,
+                                                   facts );
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+
+                                        modeller.getModel().addRhsItem( new ActionInsertLogicalFact( factsCombo.getText() ) );
+                                        modeller.setDirty( true );
+                                        modeller.reloadRhs();
+                                        close();
+                                    }
+                                } );
+    }
+
+    private void createFactAssertionPart(Composite composite,
+                                         String heading,
+                                         String[] facts) {
+        createLabel( composite,
+                     "Assert a new fact" );
+        final Combo factsCombo = createFactsCombo( composite,
+                                                   heading,
+                                                   facts );
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+
+                                        modeller.getModel().addRhsItem( new ActionInsertFact( factsCombo.getText() ) );
+                                        modeller.setDirty( true );
+                                        modeller.reloadRhs();
+                                        close();
+                                    }
+                                } );
+    }
+
+    private Combo createFactsCombo(Composite composite,
+                                   String heading,
+                                   String[] facts) {
+        Combo factsCombo = new Combo( composite,
+                                      SWT.READ_ONLY );
+        factsCombo.add( heading );
+        for ( int i = 0; i < facts.length; i++ ) {
+            factsCombo.add( facts[i] );
+        }
+        factsCombo.select( 0 );
+        return factsCombo;
+    }
+
+    private void createValuesOfFieldPart(Composite composite,
+                                           String heading) {
+        createLabel( composite,
+                     "Set the values of a field on" );
+        final Combo globalVarsCombo = new Combo( composite,
+                                                 SWT.READ_ONLY );
+        globalVarsCombo.add( heading );
+
+        List boundFacts = modeller.getModel().getBoundFacts();
+
+        //adding globals
+        String[] globals = modeller.getSuggestionCompletionEngine().getGlobalVariables();
+        boundFacts.addAll(Arrays.asList(globals));
+
+        for ( int i = 0; i < boundFacts.size(); i++ ) {
+            globalVarsCombo.add( (String) boundFacts.get( i ) );
+        }
+        globalVarsCombo.select( 0 );
+
+        globalVarsCombo.addListener( SWT.Selection,
+                                     new Listener() {
+                                         public void handleEvent(Event event) {
+                                             if ( globalVarsCombo.getSelectionIndex() == 0 ) {
+                                                 return;
+                                             }
+
+                                             modeller.getModel().addRhsItem( new ActionSetField( globalVarsCombo.getText() ) );
+                                             modeller.setDirty( true );
+                                             modeller.reloadRhs();
+                                             close();
+                                         }
+                                     } );
+    }
+
+    public SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewConditionDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,154 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.IPattern;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * This provides a popup for new LHS condition selection. (add new if-condition)
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ */
+public class AddNewConditionDialog extends RuleDialog {
+
+    private IPattern          pattern;
+
+    private RuleModeller      modeller;
+
+    public AddNewConditionDialog(Shell parent,
+                                 RuleModeller modeller) {
+
+        super( parent,
+               "Add new condition to the rule",
+               "Pick the values from combos and confirm the selection." );
+
+        this.modeller = modeller;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Control dialog = super.createDialogArea( parent );
+
+        Composite composite = (Composite) dialog;
+
+        addFacts( composite );
+
+        addConditionType( composite );
+
+        addDSLSentences( composite );
+
+        return composite;
+    }
+
+    private void addFacts(Composite composite) {
+        createLabel( composite,
+                     "Fact" );
+
+        String[] factTypes = getCompletion().getFactTypes();
+        final Combo factsCombo = new Combo( composite,
+                                            SWT.READ_ONLY );
+        factsCombo.add( "Choose fact type..." );
+        for ( int i = 0; i < factTypes.length; i++ ) {
+            factsCombo.add( factTypes[i] );
+        }
+        factsCombo.select( 0 );
+
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+                                        modeller.getModel().addLhsItem( new FactPattern( factsCombo.getText() ) );
+                                        modeller.reloadLhs();
+                                        modeller.setDirty( true );
+                                        close();
+                                    }
+                                } );
+    }
+
+    private void addConditionType(Composite composite) {
+        createLabel( composite,
+                     "Condition type" );
+
+        final Combo conditionalsCombo = new Combo( composite,
+                                                   SWT.READ_ONLY );
+        String[] conditionalElements = getCompletion().getConditionalElements();
+        conditionalsCombo.add( "Choose condition type..." );
+        for ( int i = 0; i < conditionalElements.length; i++ ) {
+            conditionalsCombo.add( conditionalElements[i] );
+        }
+        conditionalsCombo.select( 0 );
+
+        conditionalsCombo.addListener( SWT.Selection,
+                                       new Listener() {
+                                           public void handleEvent(Event event) {
+                                               if ( conditionalsCombo.getSelectionIndex() == 0 ) {
+                                                   return;
+                                               }
+
+                                               modeller.getModel().addLhsItem( new CompositeFactPattern( conditionalsCombo.getText() ) );
+                                               modeller.reloadLhs();
+                                               modeller.setDirty( true );
+                                               close();
+                                           }
+                                       } );
+    }
+
+    //
+    // The list of DSL sentences
+    //
+    private void addDSLSentences(Composite composite) {
+        if ( getCompletion().getDSLConditions().length > 0 ) {
+            createLabel( composite,
+                         "Condition sentences" );
+
+            final Combo dslCombo = new Combo( composite,
+                                              SWT.READ_ONLY );
+            dslCombo.add( "Choose..." );
+
+            for ( int i = 0; i < getCompletion().getDSLConditions().length; i++ ) {
+                DSLSentence sen = getCompletion().getDSLConditions()[i];
+                dslCombo.add( sen.toString() );
+            }
+
+            dslCombo.select( 0 );
+
+            dslCombo.addListener( SWT.Selection,
+                                  new Listener() {
+                                      public void handleEvent(Event event) {
+                                          if ( dslCombo.getSelectionIndex() == 0 ) {
+                                              return;
+                                          }
+
+                                          DSLSentence sentence = getCompletion().getDSLConditions()[dslCombo.getSelectionIndex() - 1];
+										//TODO Handle this kind of situations with care - add* can throw runtime exceptions
+                                          modeller.getModel().addLhsItem( sentence.copy() );
+
+                                          modeller.reloadLhs();
+                                          modeller.setDirty( true );
+                                          close();
+                                      }
+                                  } );
+
+        }
+    }
+
+    public IPattern getPattern() {
+        return pattern;
+    }
+
+    private SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFactConstraintDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,76 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * Adds new fact pattern to a composite fact
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ */
+public class AddNewFactConstraintDialog extends RuleDialog {
+
+    private RuleModeller         modeller;
+
+    private CompositeFactPattern pattern;
+
+    public AddNewFactConstraintDialog(Shell parent,
+                                      RuleModeller modeller,
+                                      CompositeFactPattern pattern) {
+        super( parent,
+               "New fact pattern",
+               "Pick the value from combobox." );
+        this.modeller = modeller;
+        this.pattern = pattern;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        createLabel( composite,
+                     "Choose fact type" );
+
+        String[] fieldCompletitions = getCompletion().getFactTypes();
+        final Combo factsCombo = new Combo( composite,
+                                            SWT.READ_ONLY );
+        factsCombo.add( "Choose fact type..." );
+        for ( int i = 0; i < fieldCompletitions.length; i++ ) {
+            factsCombo.add( fieldCompletitions[i] );
+        }
+        factsCombo.select( 0 );
+
+        factsCombo.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+
+                                        if ( factsCombo.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+
+                                        FactPattern factPattern = new FactPattern();
+                                        factPattern.factType = factsCombo.getText();
+                                        pattern.addFactPattern( factPattern );
+
+                                        modeller.setDirty( true );
+                                        modeller.reloadLhs();
+                                        close();
+                                    }
+                                } );
+
+        return composite;
+    }
+
+    private SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewFieldConstraintDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,201 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.CompositeFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+/**
+ * Adding a new constraint for a field of a FactPattern
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class AddNewFieldConstraintDialog extends RuleDialog {
+
+    private final FormToolkit toolkit;
+
+    private RuleModeller      modeller;
+
+    private FactPattern       pattern;
+
+    private boolean           isNested;
+
+    public AddNewFieldConstraintDialog(Shell parent,
+                                       FormToolkit toolkit,
+                                       RuleModeller modeller,
+                                       FactPattern pattern,
+                                       boolean isNested) {
+        super( parent,
+               "Update constraints",
+               "Pick the values from combos and confirm the selection." );
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.pattern = pattern;
+        this.isNested = isNested;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+
+        createFieldRestrictionCombo( composite,
+                                     gd );
+        createMultipleRestrictionCombo( composite,
+                                        gd );
+        createFormulaRow( composite,
+                          gd );
+        if ( !isNested ) {
+            createVariableBindingRow( composite );
+        }
+
+        toolkit.paintBordersFor( composite );
+        return composite;
+    }
+
+    private void createMultipleRestrictionCombo(Composite composite,
+                                                GridData gd) {
+        createLabel( composite,
+                     "Multiple field constriant" );
+        final Combo composites = new Combo( composite,
+                                            SWT.READ_ONLY );
+
+        composites.setLayoutData( gd );
+
+        composites.add( "..." );
+        composites.add( "All of (And)" );
+        composites.add( "Any of (Or)" );
+        composites.setData( "All of (And)",
+                            CompositeFieldConstraint.COMPOSITE_TYPE_AND );
+        composites.setData( "Any of (Or)",
+                            CompositeFieldConstraint.COMPOSITE_TYPE_OR );
+        composites.select( 0 );
+
+        composites.addListener( SWT.Selection,
+                                new Listener() {
+                                    public void handleEvent(Event event) {
+                                        if ( composites.getSelectionIndex() == 0 ) {
+                                            return;
+                                        }
+
+                                        CompositeFieldConstraint comp = new CompositeFieldConstraint();
+                                        comp.compositeJunctionType = (String) composites.getData( composites.getText() );
+
+                                        pattern.addConstraint( comp );
+                                        modeller.reloadLhs(); //TODO:review, perhaps should be another order of these calls
+                                        modeller.setDirty( true );
+                                        close();
+                                    }
+                                } );
+    }
+
+    private void createFieldRestrictionCombo(Composite composite,
+                                             GridData gd) {
+        createLabel( composite,
+                     "Add a restriction on a field" );
+
+        String[] fieldCompletitions = getCompletion().getFieldCompletions( pattern.factType );
+        final Combo fieldsCombo = new Combo( composite,
+                                             SWT.READ_ONLY );
+        fieldsCombo.setLayoutData( gd );
+        fieldsCombo.add( "..." );
+        for ( int i = 0; i < fieldCompletitions.length; i++ ) {
+            fieldsCombo.add( fieldCompletitions[i] );
+        }
+        fieldsCombo.select( 0 );
+
+        fieldsCombo.addListener( SWT.Selection,
+                                 new Listener() {
+                                     public void handleEvent(Event event) {
+                                         if ( fieldsCombo.getSelectionIndex() == 0 ) {
+                                             return;
+                                         }
+
+                                         SingleFieldConstraint constraint = new SingleFieldConstraint();
+                                         constraint.fieldName = fieldsCombo.getText();
+                                         pattern.addConstraint( constraint );
+                                         modeller.setDirty( true );
+                                         modeller.reloadLhs();
+                                         close();
+                                     }
+                                 } );
+    }
+
+    private void createFormulaRow(Composite composite,
+                                  GridData gd) {
+        createLabel( composite,
+                     "Add a new formula style expression" );
+        Button formulaButton = toolkit.createButton( composite,
+                                                     "New formula",
+                                                     SWT.PUSH );
+
+        formulaButton.addListener( SWT.Selection,
+                                   new Listener() {
+                                       public void handleEvent(Event event) {
+                                           SingleFieldConstraint con = new SingleFieldConstraint();
+                                           con.constraintValueType = ISingleFieldConstraint.TYPE_PREDICATE;
+                                           pattern.addConstraint( con );
+                                           modeller.setDirty( true );
+                                           modeller.reloadLhs();
+                                           close();
+                                       }
+                                   } );
+
+        formulaButton.setLayoutData( gd );
+    }
+
+    private void createVariableBindingRow(Composite composite) {
+        createLabel( composite,
+                     "Variable name" );
+        final Text variableText = createText( composite,
+                                              "" );
+
+        if ( pattern.boundName != null ) {
+            variableText.setText( pattern.boundName );
+        }
+
+        Button varButton = toolkit.createButton( composite,
+                                                 "Set",
+                                                 SWT.PUSH );
+        varButton.addListener( SWT.Selection,
+                               new Listener() {
+                                   public void handleEvent(Event event) {
+                                       pattern.boundName = variableText.getText();
+                                       modeller.reloadLhs();
+                                       modeller.setDirty( true );
+                                       close();
+                                   }
+                               } );
+    }
+
+    private SuggestionCompletionEngine getCompletion() {
+        return modeller.getSuggestionCompletionEngine();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AddNewInsertedFactFieldDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,74 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ActionInsertFact;
+import org.drools.brms.client.modeldriven.brl.ActionFieldValue;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class AddNewInsertedFactFieldDialog extends RuleDialog {
+
+	private RuleModeller modeller;
+
+	private final ActionInsertFact fact;
+
+	public AddNewInsertedFactFieldDialog(Shell parent, RuleModeller modeller,
+			ActionInsertFact fact) {
+		super(parent, "Add new condition to the rule",
+				"Pick the values from combos and confirm the selection.");
+		this.modeller = modeller;
+		this.fact = fact;
+	}
+
+	protected Control createDialogArea(final Composite parent) {
+
+		Composite composite = (Composite) super.createDialogArea(parent);
+
+		createLabel(composite, "Field:");
+
+		final Combo factsCombo = new Combo(composite, SWT.READ_ONLY);
+
+		String[] fields = getCompletion().getFieldCompletions(fact.factType);
+		factsCombo.add("...");
+		for (int i = 0; i < fields.length; i++) {
+			factsCombo.add(fields[i]);
+		}
+		factsCombo.select(0);
+
+		factsCombo.addListener(SWT.Selection, new Listener() {
+			public void handleEvent(Event event) {
+
+				if (factsCombo.getSelectionIndex() == 0) {
+					return;
+				}
+
+				String fieldType = modeller.getSuggestionCompletionEngine()
+						.getFieldType(fact.factType, factsCombo.getText());
+				fact.addFieldValue(new ActionFieldValue(factsCombo.getText(),
+						"", fieldType));
+
+				modeller.setDirty(true);
+				modeller.reloadRhs();
+				close();
+			}
+		});
+
+		return composite;
+	}
+
+	public SuggestionCompletionEngine getCompletion() {
+		return modeller.getSuggestionCompletionEngine();
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/AssignFieldVariableDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,84 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class AssignFieldVariableDialog extends RuleDialog {
+
+    private final FormToolkit     toolkit;
+
+    private RuleModeller          modeller;
+
+    private SingleFieldConstraint con;
+
+    public AssignFieldVariableDialog(Shell parent,
+                                     FormToolkit toolkit,
+                                     RuleModeller modeller,
+                                     SingleFieldConstraint con) {
+        super( parent,
+               "Bind the field called [" + con.fieldName + "] to a variable.",
+               "Type the variable name and hit the button." );
+
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.con = con;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 5;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
+
+        createVariableBindingRow( composite );
+        toolkit.paintBordersFor( composite );
+        return composite;
+    }
+
+    private void createVariableBindingRow(Composite composite) {
+        createLabel( composite,
+                     "Variable name" );
+        final Text variableText = toolkit.createText( composite,
+                                                      "" );
+
+        if ( con.fieldBinding != null ) {
+            variableText.setText( con.fieldBinding );
+        }
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 3;
+
+        variableText.setLayoutData( gd );
+
+        Button varButton = toolkit.createButton( composite,
+                                                 "Set",
+                                                 SWT.PUSH );
+        varButton.addListener( SWT.Selection,
+                               new Listener() {
+                                   public void handleEvent(Event event) {
+                                       con.fieldBinding = variableText.getText();
+                                       modeller.reloadLhs();
+                                       modeller.setDirty( true );
+                                       close();
+                                   }
+                               } );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CompositeFactPatternWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,154 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+/**
+ * This is the new smart widget that works off the model.
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class CompositeFactPatternWidget extends Widget {
+
+    private final CompositeFactPattern pattern;
+
+    public CompositeFactPatternWidget(FormToolkit toolkit,
+                                      Composite parent,
+                                      RuleModeller mod,
+                                      CompositeFactPattern factPattern,
+                                      int idx) {
+
+        super( parent,
+               toolkit,
+               mod,
+               idx );
+        this.pattern = factPattern;
+
+        GridLayout layout = new GridLayout();
+        layout.numColumns = 4;
+        layout.marginBottom = 0;
+        layout.marginHeight = 0;
+        layout.marginLeft = 0;
+        layout.marginRight = 0;
+        layout.marginTop = 0;
+        layout.marginWidth = 0;
+        layout.verticalSpacing = 2;
+        parent.setLayout( layout );
+
+        create();
+    }
+
+    private void create() {
+        Label l = toolkit.createLabel( parent,
+                             HumanReadable.getCEDisplayName( pattern.type ) );
+        
+        GridData labelGD = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
+        labelGD.horizontalSpan = 2;
+        //labelGD.verticalAlignment = SWT.CENTER;
+        //labelGD.horizontalAlignment = SWT.CENTER;
+        l.setLayoutData(labelGD);
+        l.setBackground(new Color(parent.getShell().getDisplay(),240,240,240));
+        
+        l.setLayoutData(labelGD);
+        addDeleteAction();
+        addMoreOptionsAction();
+        Composite composite = toolkit.createComposite( parent );
+        
+
+    	GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+        gd.horizontalAlignment = SWT.CENTER;
+    	composite.setLayoutData(gd);
+    	
+        createFactRows( toolkit,
+                        composite );
+    }
+
+    protected void addDeleteAction() {
+        ImageHyperlink delWholeLink = addImage( parent,
+                                                "icons/delete_obj.gif" );
+        delWholeLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this ENTIRE condition, " + "and all the field constraints that belong to it." );
+                dialog.setText( "Remove this entire condition?" );
+                if ( dialog.open() == SWT.YES ) {
+
+                    if ( getModeller().getModel().removeLhsItem( index ) ) {
+                        getModeller().reloadLhs();
+                        getModeller().setDirty( true );
+                    } else {
+                        showMessage( "Can't remove that item as it is used in the action part of the rule." );
+                    }
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delWholeLink.setToolTipText( "Remove the entire composite condition." );
+    }
+
+    private void addMoreOptionsAction() {
+        final ImageHyperlink link = addImage( parent,
+                                              // "icons/add_field_to_fact.gif");
+                                              "icons/new_item.gif" );
+
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddNewFactConstraintDialog( parent.getShell(),
+                                                                   getModeller(),
+                                                                   pattern );
+                popup.open();
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        link.setToolTipText( "Add a fact to this constraint. " + "If it is an 'or' type, it will need at least 2." );
+    }
+
+    private void createFactRows(FormToolkit toolkit,
+                                Composite constraintComposite) {
+    	
+    	
+        if ( pattern.patterns != null ) {
+            FactPattern[] facts = pattern.patterns;
+            for ( int i = 0; i < facts.length; i++ ) {
+            	
+                new FactPatternWidget( toolkit,
+                                       constraintComposite,
+                                       getModeller(),
+                                       facts[i],
+                                       pattern,
+                                       i,
+                                       false );
+                
+                toolkit.createLabel(constraintComposite, "");
+                toolkit.createLabel(constraintComposite, "");
+            }
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ConstraintValueEditor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,194 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+public class ConstraintValueEditor {
+
+	private Composite composite;
+
+	private ISingleFieldConstraint constraint;
+
+	private FormToolkit toolkit;
+
+	private RuleModeller modeller;
+
+	private boolean numericValue;
+	
+	public ConstraintValueEditor(Composite composite,
+			ISingleFieldConstraint constraint, FormToolkit toolkit,
+			RuleModeller modeller, String numericType /*e.g. is "Numeric"*/) {
+		this.composite = composite;
+		this.constraint = constraint;
+		this.toolkit = toolkit;
+		this.modeller = modeller;
+		
+		if (numericType.equals( SuggestionCompletionEngine.TYPE_NUMERIC )) {
+            this.numericValue = true;
+        }
+		create();
+	}
+
+	private void create() {
+		if (constraint.constraintValueType == ISingleFieldConstraint.TYPE_UNDEFINED) {
+			ImageHyperlink link = addImage(composite, "icons/edit.gif");
+			link.setToolTipText("Choose value editor type");
+			link.addHyperlinkListener(new IHyperlinkListener() {
+				public void linkActivated(HyperlinkEvent e) {
+					RuleDialog popup = new ValueEditorTypeSelectionDialog(
+							composite.getShell(), toolkit, modeller, constraint);
+					popup.open();
+				}
+
+				public void linkEntered(HyperlinkEvent e) {
+				}
+
+				public void linkExited(HyperlinkEvent e) {
+				}
+			});
+
+			GridData gd = new GridData(GridData.FILL_HORIZONTAL
+					| GridData.GRAB_HORIZONTAL
+					| GridData.HORIZONTAL_ALIGN_BEGINNING);
+			gd.horizontalSpan = 2;
+
+			link.setLayoutData(gd);
+		} else {
+			switch (constraint.constraintValueType) {
+			case ISingleFieldConstraint.TYPE_LITERAL:
+				literalValueEditor(composite, constraint, new GridData(
+						GridData.FILL_HORIZONTAL));
+				break;
+			case ISingleFieldConstraint.TYPE_RET_VALUE:
+				addImage(composite, "icons/function_assets.gif");
+				formulaValueEditor(composite, constraint, new GridData(
+						GridData.FILL_HORIZONTAL));
+				break;
+			case ISingleFieldConstraint.TYPE_VARIABLE:
+				variableEditor(composite, constraint, new GridData(
+						GridData.FILL_HORIZONTAL));
+				break;
+			default:
+				break;
+			}
+		}
+
+	}
+
+	private void literalValueEditor(Composite parent,
+			final ISingleFieldConstraint c, GridData gd) {
+		final Text box = toolkit.createText(parent, "");
+
+		if (c.value != null) {
+			box.setText(c.value);
+		}
+
+		gd.horizontalSpan = 2;
+		gd.grabExcessHorizontalSpace = true;
+		gd.minimumWidth = 100;
+		box.setLayoutData(gd);
+
+		box.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				c.value = box.getText();
+				modeller.setDirty(true);
+			}
+		});
+		
+		if (this.numericValue) {
+			box.addKeyListener(new KeyListener(){
+
+				public void keyPressed(KeyEvent e) {
+					if(Character.isLetter(e.character)){
+						e.doit = false;
+					}
+				}
+
+				public void keyReleased(KeyEvent e) {
+					
+				}
+				
+			});
+		}
+	}
+
+	private void formulaValueEditor(Composite parent,
+			final ISingleFieldConstraint c, GridData gd) {
+
+		final Text box = toolkit.createText(parent, "");
+
+		if (c.value != null) {
+			box.setText(c.value);
+		}
+
+		gd.grabExcessHorizontalSpace = true;
+		gd.minimumWidth = 100;
+		box.setLayoutData(gd);
+
+		box.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				c.value = box.getText();
+				modeller.setDirty(true);
+			}
+		});
+	}
+
+	private void variableEditor(Composite composite,
+			final ISingleFieldConstraint c, GridData gd) {
+		List vars = modeller.getModel().getBoundVariablesInScope(c);
+
+		final Combo combo = new Combo(composite, SWT.READ_ONLY);
+
+		gd.horizontalSpan = 2;
+		combo.setLayoutData(gd);
+		if (c.value == null) {
+			combo.add("Choose ...");
+		}
+
+		int idx = 0;
+
+		for (int i = 0; i < vars.size(); i++) {
+			String var = (String) vars.get(i);
+
+			if (c.value != null && c.value.equals(var)) {
+				idx = i;
+			}
+			combo.add(var);
+		}
+
+		combo.select(idx);
+
+		combo.addModifyListener(new ModifyListener() {
+			public void modifyText(ModifyEvent e) {
+				c.value = combo.getText();
+			}
+		});
+
+	}
+
+	public ImageHyperlink addImage(Composite parent, String fileName) {
+		ImageHyperlink imageHyperlink = toolkit.createImageHyperlink(parent, 0);
+		ImageDescriptor imageDescriptor = DroolsEclipsePlugin
+				.getImageDescriptor(fileName);
+		imageHyperlink.setImage(imageDescriptor.createImage());
+		return imageHyperlink;
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CustomRuleDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CustomRuleDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/CustomRuleDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,12 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.dialogs.SelectionDialog;
+
+public class CustomRuleDialog extends SelectionDialog {
+
+    public CustomRuleDialog(Shell parentShell) {
+        super( parentShell );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/DSLSentenceWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,174 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+/**
+ * This displays a widget to edit a DSL sentence.
+ * 
+ * @author Ahti Kitsik
+ * @author Anton Arhipov
+ */
+public abstract class DSLSentenceWidget extends Widget {
+
+    private final DSLSentence sentence;
+
+    private List              widgets = new ArrayList();
+
+    public DSLSentenceWidget(FormToolkit toolkit,
+                             Composite parent,
+                             DSLSentence sentence,
+                             RuleModeller modeller,
+                             int index) {
+        super( parent,
+               toolkit,
+               modeller,
+               index );
+
+        this.sentence = sentence;
+
+        makeWidget();
+        addDeleteAction();
+    }
+
+    protected abstract void updateModel();
+
+    private void addDeleteAction() {
+
+        ImageHyperlink delLink = addImage( parent,
+                                           "icons/delete_item_small.gif" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this DSL sentense?" );
+                dialog.setText( "Remove this DSL sentense?" );
+                if ( dialog.open() == SWT.YES ) {
+                    updateModel();
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setToolTipText( "Remove this condition." );
+    }
+
+    private void makeWidget() {
+
+        int elems = 0;
+
+        char[] chars = this.sentence.sentence.toCharArray();
+        Text currentBox = null;
+        Label currentLabel = null;
+        for ( int i = 0; i < chars.length; i++ ) {
+            char c = chars[i];
+            if ( c == '{' ) {
+                currentLabel = null;
+
+                currentBox = toolkit.createText( parent,
+                                                 "" );
+
+                //final Text thisBox = currentBox;
+                elems++;
+
+                GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+                gd.grabExcessHorizontalSpace = true;
+                gd.minimumWidth = 100;
+                currentBox.setLayoutData( gd );
+                
+                widgets.add( currentBox );
+
+            } else if ( c == '}' ) {
+                currentBox = null;
+            } else {
+                if ( currentBox == null && currentLabel == null ) {
+                    currentLabel = toolkit.createLabel( parent,
+                                                        "" );
+                    elems++;
+
+                    widgets.add( currentLabel );
+                }
+                if ( currentLabel != null ) {
+                    currentLabel.setText( currentLabel.getText() + c );
+                } else if ( currentBox != null ) {
+                    currentBox.setText( currentBox.getText() + c );
+                }
+            }
+        }
+
+        GridLayout l = new GridLayout();
+        int cols = elems + 1;
+        l.numColumns = cols;
+        l.verticalSpacing = 0;
+        l.marginTop = 0;
+        l.marginHeight = 2;
+        l.marginBottom = 0;
+        parent.setLayout( l );
+
+        // Attach listeners
+        Iterator widgetiter = widgets.iterator();
+        while ( widgetiter.hasNext() ) {
+            Object o = (Object) widgetiter.next();
+            if (o instanceof Text) {
+                ((Text)o).addModifyListener( new ModifyListener() {
+                    public void modifyText(ModifyEvent e) {
+                        updateSentence();
+                        /*                        Point p = thisBox.getSize();
+                         
+                         GC gc = new GC(thisBox);
+                         gc.setFont(thisBox.getFont());
+                         FontMetrics fontMetrics = gc.getFontMetrics();
+                         int w = fontMetrics.getAverageCharWidth()*thisBox.getText().length();
+                         gc.dispose();
+                         
+                         
+                         thisBox.setSize( w, p.y );
+                         thisBox.redraw();
+                         parent.redraw();
+                         */
+                        getModeller().setDirty( true );
+                    }
+                } );
+                
+            }
+        }
+        toolkit.paintBordersFor( parent );
+    }
+
+    protected void updateSentence() {
+        String newSentence = "";
+        for ( Iterator iter = widgets.iterator(); iter.hasNext(); ) {
+            Control wid = (Control) iter.next();
+            if ( wid instanceof Label ) {
+                newSentence = newSentence + ((Label) wid).getText();
+            } else if ( wid instanceof Text ) {
+                newSentence = newSentence + "{" + ((Text) wid).getText() + "}";
+            }
+        }
+        this.sentence.sentence = newSentence;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/FactPatternWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,644 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brl.CompositeFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.ConnectiveConstraint;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.FieldConstraint;
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.drools.brms.client.modeldriven.brl.SingleFieldConstraint;
+import org.drools.eclipse.rulebuilder.modeldriven.HumanReadable;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.graphics.Color;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+/**
+ * This is the new smart widget that works off the model.
+ * 
+ * @author Michael Neale
+ * @author Ahti Kitsik
+ * @author Anton Arhipov
+ * 
+ */
+public class FactPatternWidget extends Widget {
+
+    private final CompositeFactPattern parentPattern;
+
+    private final FactPattern          pattern;
+
+    private boolean                    bindable;
+
+    public FactPatternWidget(FormToolkit toolkit,
+                             Composite parent,
+                             RuleModeller mod,
+                             FactPattern factPattern,
+                             CompositeFactPattern parentPattern,
+                             int idx,
+                             boolean canBind) {
+
+        super( parent,
+               toolkit,
+               mod,
+               idx );
+
+        this.pattern = factPattern;
+        this.parentPattern = parentPattern;
+        this.bindable = canBind;
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 4;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        l.verticalSpacing = 0;
+        parent.setLayout( l );
+
+        create();
+    }
+
+    private void create() {
+        Label l = toolkit.createLabel( parent,
+                             getPatternLabel() );
+        
+        GridData labelGD = new GridData(GridData.FILL_BOTH | GridData.GRAB_HORIZONTAL);
+        labelGD.horizontalSpan = 2;
+        //labelGD.verticalAlignment = SWT.CENTER;
+        //labelGD.horizontalAlignment = SWT.CENTER;
+        l.setLayoutData(labelGD);
+        l.setBackground(new Color(parent.getShell().getDisplay(),240,240,240));
+        
+        addDeleteAction();
+        addMoreOptionsAction();
+        
+        Composite constraintComposite = toolkit.createComposite( parent );
+        GridLayout constraintLayout = new GridLayout();
+        constraintLayout.numColumns = 8;
+        constraintComposite.setLayout( constraintLayout );
+
+        for ( int row = 0; row < pattern.getFieldConstraints().length; row++ ) {
+            renderFieldConstraints( constraintComposite,
+                                    pattern.getFieldConstraints()[row],
+                                    null,
+                                    row,
+                                    true,
+                                    false );
+        }
+
+        toolkit.paintBordersFor( constraintComposite );
+    }
+
+    private void addMoreOptionsAction() {
+        ImageHyperlink link = addImage( parent,
+                                        "icons/new_item.gif" );
+
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddNewFieldConstraintDialog( parent.getShell(),
+                                                                    toolkit,
+                                                                    getModeller(),
+                                                                    pattern,
+                                                                    parentPattern != null );
+                popup.open();
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        link.setToolTipText( "Add a field to this condition, or bind a varible to this fact." );
+    }
+
+    private void addDeleteAction() {
+        ImageHyperlink delWholeLink = addImage( parent,
+                                                "icons/delete_obj.gif" );
+        delWholeLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this ENTIRE condition, " + "and all the field constraints that belong to it." );
+                dialog.setText( "Remove this entire condition?" );
+                if ( dialog.open() == SWT.YES ) {
+                    if ( parentPattern == null ) {
+                        if ( getModeller().getModel().removeLhsItem( index ) ) {
+                            getModeller().reloadLhs();
+                        } else {
+                            showMessage( "Can't remove that item as it is used in the action part of the rule." );
+                        }
+                    } else {
+                        deleteBindedFact();
+                    }
+                    getModeller().setDirty( true );
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delWholeLink.setToolTipText( "Remove this condition." );
+    }
+
+    private void renderFieldConstraints(Composite constraintComposite,
+                                        FieldConstraint constraint,
+                                        final CompositeFieldConstraint parentConstraint,
+                                        int row,
+                                        boolean showBinding,
+                                        boolean nested) {
+        if ( constraint instanceof SingleFieldConstraint ) {
+            renderSingleFieldConstraint( constraintComposite,
+                                         row,
+                                         constraint,
+                                         parentConstraint,
+                                         showBinding,
+                                         nested );
+        } else if ( constraint instanceof CompositeFieldConstraint ) {
+            compositeFieldConstraintEditor( constraintComposite,
+                                            (CompositeFieldConstraint) constraint,
+                                            parentConstraint,
+                                            row,
+                                            nested );
+        }
+    }
+
+    private void compositeFieldConstraintEditor(Composite constraintComposite,
+                                                final CompositeFieldConstraint constraint,
+                                                final CompositeFieldConstraint parentConstraint,
+                                                final int row,
+                                                boolean nested) {
+
+        // Label
+        if ( constraint.compositeJunctionType.equals( CompositeFieldConstraint.COMPOSITE_TYPE_AND ) ) {
+            toolkit.createLabel( constraintComposite,
+                                 "All of:" );
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "Any of:" );
+        }
+
+        addRemoveButton( constraintComposite,
+                         parentConstraint,
+                         row,
+                         "icons/delete_obj.gif",
+                         nested );
+
+        // button "add"
+        ImageHyperlink link = addImage( constraintComposite,
+                                        "icons/new_item.gif" );
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                RuleDialog popup = new AddCompositeConstraintOptionDialog( parent.getShell(),
+                                                                           getModeller(),
+                                                                           constraint,
+                                                                           pattern );
+                popup.open();
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+
+        link.setToolTipText("Add fields to this constriant.");
+        
+        addNestedElements( constraintComposite,
+                           constraint );
+    }
+
+    private void addNestedElements(Composite constraintComposite,
+                                   final CompositeFieldConstraint constraint) {
+        // Nested elementss
+        FieldConstraint[] nestedConstraints = constraint.constraints;
+        if ( nestedConstraints != null ) {
+            Composite nestedComposite = toolkit.createComposite( constraintComposite );
+            GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+            gd.horizontalSpan = 5;
+            nestedComposite.setLayoutData( gd );
+
+            GridLayout l = new GridLayout();
+            l.numColumns = 8;
+            l.marginBottom = 0;
+            l.marginHeight = 0;
+            l.marginLeft = 0;
+            l.marginRight = 0;
+            l.marginTop = 0;
+            l.marginWidth = 0;
+            l.verticalSpacing = 0;
+            nestedComposite.setLayout( l );
+
+            for ( int i = 0; i < nestedConstraints.length; i++ ) {
+                renderFieldConstraints( nestedComposite,
+                                        nestedConstraints[i],
+                                        constraint,
+                                        i,
+                                        false,
+                                        true );
+                toolkit.paintBordersFor( nestedComposite );
+            }
+        } else {
+            GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+            gd.horizontalSpan = 5;
+            Label dummyLabel = toolkit.createLabel( constraintComposite,
+                                                    "" ); // dummy
+            dummyLabel.setLayoutData( gd );
+        }
+    }
+
+    private void renderSingleFieldConstraint(Composite constraintComposite,
+                                             int row,
+                                             FieldConstraint constraint,
+                                             CompositeFieldConstraint parentConstraint,
+                                             boolean showBinding,
+                                             boolean nested) {
+        final SingleFieldConstraint c = (SingleFieldConstraint) constraint;
+        if ( c.constraintValueType != ISingleFieldConstraint.TYPE_PREDICATE ) {
+            createConstraintRow( constraintComposite,
+                                 parentConstraint,
+                                 row,
+                                 c,
+                                 showBinding,
+                                 nested );
+        } else {
+            createPredicateConstraintRow( constraintComposite,
+                                          row,
+                                          c );
+        }
+    }
+
+    private void createConstraintRow(Composite constraintComposite,
+                                     CompositeFieldConstraint parentConstraint,
+                                     int row,
+                                     final SingleFieldConstraint c,
+                                     boolean showBinding,
+                                     boolean nested) {
+        addBindingField( constraintComposite,
+                         c,
+                         showBinding );
+        toolkit.createLabel( constraintComposite,
+                             c.fieldName );
+        if ( c.connectives == null || c.connectives.length == 0 ) {
+            addRemoveButton( constraintComposite,
+                             parentConstraint,
+                             row,
+                             "icons/delete_item_small.gif",
+                             nested );
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "" );
+        }
+        operatorDropDown( constraintComposite,
+                          c );
+        
+        constraintValueEditor(constraintComposite, c, c.fieldName);
+        
+        createConnectives( constraintComposite,
+                           c );
+        addConnectiveAction( constraintComposite,
+                             c );
+    }
+
+    private void addBindingField(Composite constraintComposite,
+                                 final SingleFieldConstraint c,
+                                 boolean showBinding) {
+        if ( !c.isBound() ) {
+            if ( bindable && showBinding ) {
+                ImageHyperlink link = addImage( constraintComposite,
+                                                "icons/new_item.gif" );
+                link.addHyperlinkListener( new IHyperlinkListener() {
+                    public void linkActivated(HyperlinkEvent e) {
+                        RuleDialog popup = new AssignFieldVariableDialog( parent.getShell(),
+                                                                          toolkit,
+                                                                          getModeller(),
+                                                                          c );
+                        popup.open();
+                    }
+
+                    public void linkEntered(HyperlinkEvent e) {
+                    }
+
+                    public void linkExited(HyperlinkEvent e) {
+                    }
+                } );
+
+                link.setToolTipText("Bind the field called [" + c.fieldName + "] to a variable.");
+            } else {
+                toolkit.createLabel( constraintComposite,
+                                     "" );
+            }
+        } else {
+            toolkit.createLabel( constraintComposite,
+                                 "[" + c.fieldBinding + "]" );
+        }
+
+    }
+
+    private void createPredicateConstraintRow(Composite constraintComposite,
+                                              int row,
+                                              final SingleFieldConstraint c) {
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 6;
+        addImage( constraintComposite,
+                  "icons/function_assets.gif" );
+        formulaValueEditor( constraintComposite,
+                            c,
+                            gd );
+        addRemoveButton( constraintComposite,
+                         null,
+                         row,
+                         "icons/delete_item_small.gif",
+                         false );
+    }
+
+    private void createConnectives(Composite parent,
+                                   SingleFieldConstraint c) {
+        if ( c.connectives != null && c.connectives.length > 0 ) {
+            for ( int i = 0; i < c.connectives.length; i++ ) {
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                toolkit.createLabel( parent,
+                                     "" ); // dummy
+                ConnectiveConstraint con = c.connectives[i];
+                addRemoveConstraintAction( parent,
+                                           c,
+                                           con );
+                connectiveOperatorDropDown( parent,
+                                            con,
+                                            c.fieldName );
+               constraintValueEditor( parent,
+                                       con, c.fieldName );
+                
+            }
+        }
+    }
+
+    private void constraintValueEditor(Composite parent, ISingleFieldConstraint c, String name ){
+    	String type = this.modeller.getSuggestionCompletionEngine().getFieldType( pattern.factType, name );
+        new ConstraintValueEditor (parent, c, toolkit, modeller, type);
+    }
+    
+    
+    private void addConnectiveAction(Composite constraintComposite,
+                                     final SingleFieldConstraint c) {
+        ImageHyperlink link = addImage( constraintComposite,
+                                        "icons/add_connective.gif" );
+        link.setToolTipText( "Add more options to this fields values." );
+        link.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                c.addNewConnective();
+                getModeller().reloadLhs();
+                getModeller().setDirty( true );
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+
+        link.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING ) );
+    }
+
+    private void addRemoveButton(Composite constraintComposite,
+                                 final CompositeFieldConstraint parentConstraint,
+                                 final int row,
+                                 String iconRef,
+                                 boolean nested) {
+        if ( nested ) {
+            addNestedConstraintDeleteAction( constraintComposite,
+                                             parentConstraint,
+                                             row,
+                                             iconRef );
+        } else {
+            addRemoveFieldAction( constraintComposite,
+                                  row,
+                                  iconRef );
+        }
+
+    }
+
+    private void addNestedConstraintDeleteAction(Composite constraintComposite,
+                                                 final CompositeFieldConstraint parentConstraint,
+                                                 final int row,
+                                                 String iconRef) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           iconRef );
+        // "icons/delete_obj.gif");
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this (nested) restriction." );
+                dialog.setText( "Remove this item from nested constraint?" );
+                if ( dialog.open() == SWT.YES ) {
+                    parentConstraint.removeConstraint( row );
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+    }
+
+    private void addRemoveFieldAction(Composite constraintComposite,
+                                      final int currentRow,
+                                      String iconRef) {
+        ImageHyperlink delLink = addImage( constraintComposite,
+                                           iconRef );
+        delLink.setToolTipText( "Remove this fieldconstraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    pattern.removeConstraint( currentRow );
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_BEGINNING ) );
+    }
+
+    private void addRemoveConstraintAction(Composite composite,
+                                           final SingleFieldConstraint constraint,
+                                           final ConnectiveConstraint connConstraint) {
+        ImageHyperlink delLink = addImage( composite,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this field constraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this item?" );
+                dialog.setText( "Remove this item?" );
+                if ( dialog.open() == SWT.YES ) {
+                    ConnectiveConstraint[] connectives = constraint.connectives;
+                    List nConnectives = new ArrayList();
+                    for ( int i = 0; i < connectives.length; i++ ) {
+                        if ( connectives[i] != connConstraint ) {
+                            nConnectives.add( connectives[i] );
+                        }
+                    }
+                    constraint.connectives = (ConnectiveConstraint[]) nConnectives.toArray( new ConnectiveConstraint[nConnectives.size()] );
+
+                    getModeller().reloadLhs();
+                    getModeller().setDirty( true );
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delLink.setLayoutData( new GridData( GridData.FILL_HORIZONTAL | GridData.HORIZONTAL_ALIGN_END ) );
+    }
+
+    /**
+     * This returns the pattern label.
+     */
+    private String getPatternLabel() {
+        if ( pattern.boundName != null ) {
+            return pattern.factType + " [" + pattern.boundName + "]";
+        }
+        return pattern.factType;
+    }
+
+    private void operatorDropDown(Composite parent,
+                                  final SingleFieldConstraint c) {
+        String[] ops = getCompletions().getOperatorCompletions( pattern.factType,
+                                                                c.fieldName );
+        final Combo box = new Combo( parent,
+                                     SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
+        for ( int i = 0; i < ops.length; i++ ) {
+            String op = ops[i];
+            box.add( HumanReadable.getOperatorDisplayName( op ) );
+            if ( op.equals( c.operator ) ) {
+                box.select( i );
+            }
+        }
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = 2;
+        box.setLayoutData( gridData );
+        box.addListener( SWT.Selection,
+                         new Listener() {
+                             public void handleEvent(Event event) {
+                                 c.operator = HumanReadable.getOperatorName( box.getText() );
+                                 getModeller().setDirty( true );
+                             }
+                         } );
+    }
+
+    private void connectiveOperatorDropDown(Composite parent,
+                                            final ConnectiveConstraint con,
+                                            String fieldName) {
+        String[] ops = getCompletions().getConnectiveOperatorCompletions( pattern.factType,
+                                                                          fieldName );
+        final Combo box = new Combo( parent,
+                                     SWT.SIMPLE | SWT.DROP_DOWN | SWT.READ_ONLY );
+        for ( int i = 0; i < ops.length; i++ ) {
+            String op = ops[i];
+            box.add( HumanReadable.getOperatorDisplayName( op ) );
+            if ( op.equals( con.operator ) ) {
+                box.select( i );
+            }
+        }
+        GridData gridData = new GridData( GridData.FILL_HORIZONTAL );
+        gridData.horizontalSpan = 2;
+        box.setLayoutData( gridData );
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                con.operator = HumanReadable.getOperatorName( box.getText() );
+                getModeller().setDirty( true );
+                
+                
+            }
+        } );
+    }
+
+    private void formulaValueEditor(Composite parent,
+                                    final ISingleFieldConstraint c,
+                                    GridData gd) {
+
+        final Text box = toolkit.createText( parent,
+                                             "" );
+
+        if ( c.value != null ) {
+            box.setText( c.value );
+        }
+        
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
+        box.setLayoutData( gd );
+
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                c.value = box.getText();
+                getModeller().setDirty( true );
+            }
+        } );
+    }
+
+    private void deleteBindedFact() {
+        List newPatterns = new ArrayList();
+        for ( int i = 0; i < parentPattern.patterns.length; i++ ) {
+            if ( parentPattern.patterns[i] != pattern ) {
+                newPatterns.add( parentPattern.patterns[i] );
+            }
+        }
+        parentPattern.patterns = (FactPattern[]) newPatterns.toArray( new FactPattern[newPatterns.size()] );
+        getModeller().reloadLhs();
+    }
+
+    private SuggestionCompletionEngine getCompletions() {
+        return getModeller().getSuggestionCompletionEngine();
+    }
+
+    
+    
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/LHSDSLSentenceWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,32 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class LHSDSLSentenceWidget extends DSLSentenceWidget {
+
+    public LHSDSLSentenceWidget(FormToolkit toolkit,
+                                Composite parent,
+                                DSLSentence sentence,
+                                RuleModeller modeller,
+                                int index) {
+        super( toolkit,
+               parent,
+               sentence,
+               modeller,
+               index );
+
+    }
+
+    protected void updateModel() {
+        if ( getModeller().getModel().removeLhsItem( index ) ) {
+            getModeller().reloadLhs();
+        } else {
+            showMessage( "Can't remove that item as it is used in the action part of the rule." );
+        }
+        getModeller().reloadLhs();
+        getModeller().setDirty( true );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/NumericKeyFilter.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/NumericKeyFilter.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/NumericKeyFilter.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,28 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.eclipse.swt.events.KeyEvent;
+import org.eclipse.swt.events.KeyListener;
+import org.eclipse.swt.widgets.Text;
+
+public class NumericKeyFilter implements KeyListener {
+
+	private Text box;
+	
+	public NumericKeyFilter(Text box){
+		this.box = box;
+		box.addKeyListener(this);
+	}
+	
+	public void keyPressed(KeyEvent e) {
+		char c = e.character;
+		if (Character.isLetter( c ) && c != '='
+            && !(this.box.getText().startsWith( "=" ))) {
+			e.doit = false;
+		}
+	}
+
+	public void keyReleased(KeyEvent e) {
+		
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RHSDSLSentenceWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,27 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class RHSDSLSentenceWidget extends DSLSentenceWidget {
+
+    public RHSDSLSentenceWidget(FormToolkit toolkit,
+                                Composite parent,
+                                DSLSentence sentence,
+                                RuleModeller modeller,
+                                int index) {
+        super( toolkit,
+               parent,
+               sentence,
+               modeller,
+               index );
+    }
+
+    protected void updateModel() {
+        getModeller().getModel().removeRhsItem( index );
+        getModeller().reloadRhs();
+        getModeller().setDirty( true );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributeWidget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,185 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.brl.RuleAttribute;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+public class RuleAttributeWidget extends Widget {
+
+    public RuleAttributeWidget(FormToolkit toolkit,
+                               Composite parent,
+                               RuleModeller modeller) {
+        super( parent,
+               toolkit,
+               modeller,
+               0 );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        // l.marginBottom = 5;
+        // l.marginHeight = 5;
+        // l.marginLeft = 5;
+        // l.marginRight = 5;
+        // l.marginTop = 10;
+        // l.marginWidth = 10;
+        // l.verticalSpacing = 15;
+        parent.setLayout( l );
+
+        create();
+    }
+
+    private void create() {
+
+        RuleAttribute[] attrs = modeller.getModel().attributes;
+        for ( int i = 0; i < attrs.length; i++ ) {
+            RuleAttribute at = attrs[i];
+            addAttribute( at );
+        }
+        toolkit.paintBordersFor( parent );
+    }
+
+    private void addAttribute(RuleAttribute at) {
+        toolkit.createLabel( parent,
+                             at.attributeName );
+
+        if ( at.attributeName.equals( "no-loop" ) ) {
+            toolkit.createLabel( parent,
+                                 "" );
+        } else if ( at.attributeName.equals( "enabled" ) || at.attributeName.equals( "auto-focus" ) || at.attributeName.equals( "lock-on-active" ) ) {
+            createCheckbox( at );
+        } else {
+            createText( at );
+        }
+
+        addDeleteLink( at );
+
+    }
+
+    private void createText(final RuleAttribute at) {
+        final Text box = toolkit.createText( parent,
+                                             "" );
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.grabExcessHorizontalSpace = true;
+        gd.minimumWidth = 100;
+        box.setLayoutData( gd );
+        
+        box.setText( at.value );
+
+        box.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+                at.value = box.getText();
+                modeller.setDirty( true );
+            }
+        } );
+
+        if ( at.attributeName.equals( "date-effective" ) || at.attributeName.equals( "date-expires" ) ) {
+            if ( at.value == null || "".equals( at.value.trim() ) ) {
+                box.setText( "dd-MMM-yyyy" );
+            }
+        }
+
+    }
+
+    private void createCheckbox(final RuleAttribute at) {
+        final Button checkbox = toolkit.createButton( parent,
+                                                      "",
+                                                      SWT.CHECK );
+
+        if ( at.value == null ) {
+            checkbox.setSelection( true );
+            at.value = "true";
+        } else {
+            checkbox.setSelection( at.value.equals( "true" ) ? true : false );
+        }
+
+        checkbox.addSelectionListener( new SelectionListener() {
+
+            public void widgetDefaultSelected(SelectionEvent e) {
+
+            }
+
+            public void widgetSelected(SelectionEvent e) {
+                at.value = (checkbox.getSelection()) ? "true" : "false";
+                modeller.setDirty( true );
+            }
+
+        } );
+
+    }
+
+    private void addDeleteLink(final RuleAttribute at) {
+        ImageHyperlink delLink = addImage( parent,
+                                           "icons/delete_item_small.gif" );
+        delLink.setToolTipText( "Remove this fieldconstraint" );
+        delLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this rule option?" );
+                dialog.setText( "Remove this rule option?" );
+                if ( dialog.open() == SWT.YES ) {
+                    RuleAttribute[] attrs = modeller.getModel().attributes;
+                    for ( int i = 0; i < attrs.length; i++ ) {
+                        if ( attrs[i] == at ) {
+                            modeller.getModel().removeAttribute( i );
+
+                            modeller.setDirty( true );
+                            modeller.reloadOptions();
+                        }
+                    }
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+
+    }
+
+    /**
+     * Return a listbox of choices for rule attributes.
+     * 
+     * @return
+     */
+    public static List getAttributeList() {
+        List list = new ArrayList();
+        list.add( "..." );
+
+        list.add( "salience" );
+        list.add( "enabled" );
+        list.add( "date-effective" );
+        list.add( "date-expires" );
+        list.add( "no-loop" );
+        list.add( "agenda-group" );
+        list.add( "activation-group" );
+        list.add( "duration" );
+        list.add( "auto-focus" );
+        list.add( "lock-on-active" );
+        list.add( "ruleflow-group" );
+        list.add( "dialect" );
+
+        return list;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleAttributesDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,82 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import java.util.Iterator;
+import java.util.List;
+
+import org.drools.brms.client.modeldriven.brl.RuleAttribute;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+
+public class RuleAttributesDialog extends RuleDialog {
+
+    private RuleModeller      modeller;
+
+    public RuleAttributesDialog(Shell parent,
+                                RuleModeller modeller) {
+        super( parent,
+               "Add new option to the rule",
+               "Pick the value from combo." );
+
+        this.modeller = modeller;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        GridLayout l = new GridLayout();
+        l.numColumns = 3;
+        l.marginBottom = 0;
+        l.marginHeight = 0;
+        l.marginLeft = 0;
+        l.marginRight = 0;
+        l.marginTop = 0;
+        l.marginWidth = 0;
+        composite.setLayout( l );
+
+        GridData gd = new GridData( GridData.FILL_HORIZONTAL );
+        gd.horizontalSpan = 2;
+
+        createAtributesSelectionCombo( composite,
+                                       gd );
+
+        return composite;
+    }
+
+    private void createAtributesSelectionCombo(Composite composite,
+                                               GridData gd) {
+        createLabel( composite,
+                     "Attributes" );
+        final Combo combo = new Combo( composite,
+                                       SWT.READ_ONLY );
+        combo.setLayoutData( gd );
+        List attributes = RuleAttributeWidget.getAttributeList();
+        for ( Iterator iterator = attributes.iterator(); iterator.hasNext(); ) {
+            String attr = (String) iterator.next();
+            combo.add( attr );
+        }
+        combo.select( 0 );
+
+        combo.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   if ( combo.getSelectionIndex() == 0 ) {
+                                       return;
+                                   }
+                                   modeller.getModel().addAttribute( new RuleAttribute( combo.getText(),
+                                                                                        "" ) );
+                                   modeller.setDirty( true );
+                                   modeller.reloadOptions();
+                                   close();
+                               }
+                           } );
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,120 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.dialogs.IDialogConstants;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
+
+public class RuleDialog extends Dialog {
+
+    private String title;
+    private String hint;
+
+    public RuleDialog(Shell parent,
+                      String title,
+                      String hint) {
+        //super(parent,INFOPOPUPRESIZE_SHELLSTYLE,true,true,true,true,title,hint);
+        super( (Shell) parent.getParent() );
+        setShellStyle( getShellStyle() | SWT.RESIZE );
+        this.title = title;
+        this.hint = hint;
+    }
+
+    protected void configureShell(Shell newShell) {
+        super.configureShell( newShell );
+        newShell.setText( title );
+        newShell.setToolTipText( hint );
+    }
+
+    protected Control createDialogArea(Composite parent) {
+
+        Composite finalComposite = new Composite( parent,
+                                                  SWT.NONE );
+        finalComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        GridLayout finalLayout = new GridLayout();
+        finalComposite.setLayout( finalLayout );
+
+        Composite titleComposite = new Composite( finalComposite,
+                                                  SWT.NONE );
+        GridLayout layout = new GridLayout();
+        layout.marginHeight = convertVerticalDLUsToPixels( IDialogConstants.VERTICAL_MARGIN );
+        layout.marginWidth = convertHorizontalDLUsToPixels( IDialogConstants.HORIZONTAL_MARGIN );
+        layout.verticalSpacing = 8;
+        layout.horizontalSpacing = 8;
+        titleComposite.setLayout( layout );
+        titleComposite.setLayoutData( new GridData( GridData.FILL_BOTH ) );
+        applyDialogFont( titleComposite );
+
+        Label l = new Label( titleComposite,
+                             SWT.CENTER );
+        l.setToolTipText( hint );
+        l.setText( title );
+
+        Font exFont = l.getFont();
+
+        FontData[] exfds = l.getFont().getFontData();
+        if ( exfds.length > 0 ) {
+            FontData fd = exfds[0];
+            fd.setHeight( fd.getHeight() + 4 );
+            Font f = new Font( exFont.getDevice(),
+                               fd );
+            l.setFont( f );
+        }
+
+        Composite contentComposite = (Composite) super.createDialogArea( finalComposite );
+
+        return contentComposite;
+    }
+
+    protected void createButtonsForButtonBar(Composite parent) {
+        // We have only cancel button
+        createButton( parent,
+                      IDialogConstants.CANCEL_ID,
+                      IDialogConstants.CANCEL_LABEL,
+                      false );
+
+    }
+
+    /*    
+     protected Control createDialogArea(Composite parent) {
+     Composite composite = new Composite(parent, SWT.NONE);
+     
+     GridLayout layout = new GridLayout();
+     layout.marginHeight = 2;
+     layout.marginWidth = 2;
+     layout.verticalSpacing = 2;
+     layout.horizontalSpacing = 2;
+     composite.setLayout(layout);
+     
+     GridData gd = new GridData(GridData.FILL_BOTH);
+     composite.setLayoutData(gd);
+     
+     return composite;
+     }
+     */
+
+    protected Label createLabel(Composite composite,
+                                String string) {
+        Label l = new Label( composite,
+                             0 );
+        l.setText( string );
+        return l;
+    }
+
+    protected Text createText(Composite composite,
+                              String string) {
+        Text t = new Text( composite,
+                           0 );
+        t.setText( string );
+        return t;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/RuleModeller.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,387 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.SuggestionCompletionEngine;
+import org.drools.brms.client.modeldriven.brl.ActionInsertFact;
+import org.drools.brms.client.modeldriven.brl.ActionRetractFact;
+import org.drools.brms.client.modeldriven.brl.ActionSetField;
+import org.drools.brms.client.modeldriven.brl.CompositeFactPattern;
+import org.drools.brms.client.modeldriven.brl.DSLSentence;
+import org.drools.brms.client.modeldriven.brl.FactPattern;
+import org.drools.brms.client.modeldriven.brl.IAction;
+import org.drools.brms.client.modeldriven.brl.IPattern;
+import org.drools.brms.client.modeldriven.brl.RuleModel;
+import org.drools.eclipse.rulebuilder.editors.RuleEditor;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.jface.window.Window;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Font;
+import org.eclipse.swt.graphics.FontData;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Event;
+import org.eclipse.swt.widgets.Listener;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.ToolBar;
+import org.eclipse.swt.widgets.ToolItem;
+import org.eclipse.ui.ISharedImages;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.forms.FormColors;
+import org.eclipse.ui.forms.widgets.ColumnLayout;
+import org.eclipse.ui.forms.widgets.ExpandableComposite;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ScrolledForm;
+import org.eclipse.ui.forms.widgets.Section;
+
+/**
+ * Main modeling class responsible for Eclipse Forms-based rule builder widget
+ * rendering
+ * 
+ * @author Anton Arhipov
+ * @author Ahti Kitsik
+ * 
+ */
+public class RuleModeller {
+
+    private Composite          ifComposite;
+
+    private Composite          thenComposite;
+
+    private Composite          optionsComposite;
+
+    private final ScrolledForm form;
+
+    private final FormToolkit  toolkit;
+
+    private RuleModel          model;
+
+    private boolean            dirty;
+
+    private RuleEditor         editor;
+
+    public boolean isDirty() {
+        return dirty;
+    }
+
+    public void setDirty(boolean dirty) {
+        this.dirty = dirty;
+        editor.dirtyPropertyChanged();
+    }
+
+    public RuleModeller(ScrolledForm form,
+                        FormToolkit toolkit,
+                        RuleModel model,
+                        RuleEditor editor) {
+
+        this.form = form;
+        this.toolkit = toolkit;
+        this.model = model;
+        this.editor = editor;
+
+        setTitleAndFont(form);
+
+        ColumnLayout colLayout = new ColumnLayout();
+        colLayout.minNumColumns = 1;
+        colLayout.maxNumColumns = 1;
+
+        form.getBody().setLayout( colLayout );
+
+        // addToolBar(toolkit, form);
+
+        Shell shell = new Shell( Display.getCurrent() );
+        Window conditionPopup = new AddNewConditionDialog( shell,
+                                                           this );
+        Window actionPopup = new AddNewActionDialog( shell,
+                                                     this );
+
+        Window optionsPopup = new RuleAttributesDialog( shell,
+                                                        this );
+
+        Section ifSection = createMainSection( form,
+                                               toolkit,
+                                               "WHEN",
+                                               conditionPopup );
+        Section thenSection = createMainSection( form,
+                                                 toolkit,
+                                                 "THEN",
+                                                 actionPopup );
+        Section optionsSection = createMainSection( form,
+                                                    toolkit,
+                                                    "(options)",
+                                                    optionsPopup );
+
+        ColumnLayout layout = new ColumnLayout();
+        layout.minNumColumns = 1;
+        layout.maxNumColumns = 1;
+        // layout.verticalSpacing = 0;
+
+        ((Composite) (ifSection.getClient())).setLayout( layout );
+        ((Composite) (thenSection.getClient())).setLayout( layout );
+        ((Composite) (optionsSection.getClient())).setLayout( layout );
+        ifSection.setLayout( layout );
+        thenSection.setLayout( layout );
+        optionsSection.setLayout( layout );
+
+        ifComposite = (Composite) ifSection.getClient();
+        thenComposite = (Composite) thenSection.getClient();
+        optionsComposite = (Composite) optionsSection.getClient();
+
+    }
+
+	private void setTitleAndFont(ScrolledForm form) {
+		form.setText( "Guided rule editor" );
+        
+		Font systemFont = form.getDisplay().getSystemFont();
+		FontData[] exfds = systemFont.getFontData();
+        if ( exfds.length > 0 ) {
+            FontData fd = exfds[0];
+            fd.setHeight( fd.getHeight() + 2 );
+            fd.setStyle(SWT.BOLD);
+            Font f = new Font( systemFont.getDevice(),
+                               fd );
+            form.setFont(f);
+        }
+	}
+
+    public SuggestionCompletionEngine getSuggestionCompletionEngine() {
+        return editor.getCompletionEngine();
+    }
+
+    public RuleModel getModel() {
+        return model;
+    }
+
+    public void setModel(RuleModel model) {
+        this.model = model;
+    }
+
+    private void clearComposite(Composite composite) {
+        if ( composite != null ) {
+            Control[] c = composite.getChildren();
+            for ( int i = 0; i < c.length; i++ ) {
+                Control c2 = c[i];
+                c2.dispose();
+            }
+        }
+    }
+
+    private void reloadCommon() {
+        toolkit.paintBordersFor( form.getBody() );
+        form.redraw();
+        Dialog.applyDialogFont( form.getBody() );
+        form.reflow( true );
+    }
+
+    public void reloadRhs() {
+        clearComposite( thenComposite );
+        redrawRhs();
+        reloadCommon();
+    }
+
+    public void reloadLhs() {
+        clearComposite( ifComposite );
+        redrawLhs();
+        reloadCommon();
+    }
+
+    public void reloadOptions() {
+        clearComposite( optionsComposite );
+        redrawOptions();
+        reloadCommon();
+    }
+
+    public void reloadWidgets() {
+        reloadLhs();
+        reloadRhs();
+        reloadOptions();
+    }
+
+    private void redrawOptions() {
+        Composite comp = toolkit.createComposite( optionsComposite );
+        new RuleAttributeWidget( toolkit,
+                                 comp,
+                                 this );
+    }
+
+    private void redrawRhs() {
+        for ( int i = 0; i < model.rhs.length; i++ ) {
+            IAction action = model.rhs[i];
+
+            if ( action instanceof ActionSetField ) {
+                addActionSetFieldWidget( action,
+                                         i );
+            } else if ( action instanceof ActionInsertFact ) {
+                addActionInsertFactWidget( action,
+                                           i );
+            } else if ( action instanceof ActionRetractFact ) {
+                addActionRetractFactWidget( action,
+                                            i );
+            } else if ( action instanceof DSLSentence ) {
+                addRHSDSLSentenceWidget( i,
+                                         (DSLSentence) action );
+            }
+
+        }
+    }
+
+    private void addActionInsertFactWidget(IAction action,
+                                           int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionInsertFactWidget( toolkit,
+                                    comp,
+                                    this,
+                                    (ActionInsertFact) action,
+                                    i );
+    }
+
+    private void redrawLhs() {
+        for ( int i = 0; i < model.lhs.length; i++ ) {
+            IPattern pattern = model.lhs[i];
+
+            if ( pattern instanceof FactPattern ) {
+                addFactPatternWidget( i,
+                                      (FactPattern) pattern );
+            }
+            if ( pattern instanceof CompositeFactPattern ) {
+                addCompositeFactPatternWidget( i,
+                                               (CompositeFactPattern) pattern );
+            } else if ( pattern instanceof DSLSentence ) {
+                // skip for now
+            } else {
+                // dont' care
+            }
+        }
+
+        for ( int i = 0; i < model.lhs.length; i++ ) {
+            IPattern pattern = model.lhs[i];
+            if ( pattern instanceof DSLSentence ) {
+                addLHSDSLSentenceWidget( i,
+                                         (DSLSentence) pattern );
+            }
+        }
+    }
+
+    private void addActionRetractFactWidget(IAction action,
+                                            int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionRetractFactWidget( toolkit,
+                                     comp,
+                                     this,
+                                     (ActionRetractFact) action,
+                                     i );
+    }
+
+    /*private void addActionAssertFactWidget(IAction action,
+                                           int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionInsertFactWidget( toolkit,
+                                    comp,
+                                    this,
+                                    (ActionInsertFact) action,
+                                    i );
+
+    }*/
+
+    private void addActionSetFieldWidget(IAction action,
+                                         int i) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new ActionSetFieldWidget( toolkit,
+                                  comp,
+                                  this,
+                                  model,
+                                  (ActionSetField) action,
+                                  i );
+    }
+
+    private void addRHSDSLSentenceWidget(int idx,
+                                         DSLSentence pattern) {
+        Composite comp = toolkit.createComposite( thenComposite );
+        new RHSDSLSentenceWidget( toolkit,
+                                  comp,
+                                  pattern,
+                                  this,
+                                  idx );
+    }
+
+    private void addLHSDSLSentenceWidget(int idx,
+                                         DSLSentence pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new LHSDSLSentenceWidget( toolkit,
+                                  comp,
+                                  pattern,
+                                  this,
+                                  idx );
+    }
+
+    private void addCompositeFactPatternWidget(int idx,
+                                               CompositeFactPattern pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new CompositeFactPatternWidget( toolkit,
+                                        comp,
+                                        this,
+                                        pattern,
+                                        idx );
+    }
+
+    private void addFactPatternWidget(int idx,
+                                      FactPattern pattern) {
+        Composite comp = toolkit.createComposite( ifComposite );
+        new FactPatternWidget( toolkit,
+                               comp,
+                               this,
+                               pattern,
+                               null,
+                               idx,
+                               true );
+    }
+
+    private Section createMainSection(final ScrolledForm form,
+                                      FormToolkit toolkit,
+                                      String title,
+                                      Window popup) {
+        ColumnLayout layout = new ColumnLayout();
+        layout.minNumColumns = 1;
+        layout.maxNumColumns = 1;
+        Section l1Sect = toolkit.createSection( form.getBody(),
+                                                ExpandableComposite.TWISTIE | ExpandableComposite.TITLE_BAR | ExpandableComposite.EXPANDED );
+        l1Sect.setActiveToggleColor( toolkit.getHyperlinkGroup().getActiveForeground() );
+        l1Sect.setToggleColor( toolkit.getColors().getColor( FormColors.SEPARATOR ) );
+        l1Sect.setText( title );
+        createAddToolItem( l1Sect,
+                           popup );
+        Composite comp = toolkit.createComposite( l1Sect );
+        l1Sect.setClient( comp );
+        return l1Sect;
+    }
+
+    private void createAddToolItem(Section sect,
+                                   final Window popup) {
+        ToolBar tbar = new ToolBar( sect,
+                                    SWT.FLAT | SWT.HORIZONTAL );
+        ToolItem titem = new ToolItem( tbar,
+                                       SWT.SEPARATOR );
+        titem = new ToolItem( tbar,
+                              SWT.PUSH );
+        titem.setImage( PlatformUI.getWorkbench().getSharedImages().getImage( ISharedImages.IMG_TOOL_NEW_WIZARD ) );
+
+        titem.addListener( SWT.Selection,
+                           new Listener() {
+                               public void handleEvent(Event event) {
+                                   popup.open();
+                               }
+                           } );
+        sect.setTextClient( tbar );
+    }
+
+    public void refresh() {
+        ifComposite.layout();
+        ifComposite.redraw();
+
+        thenComposite.layout();
+        thenComposite.redraw();
+
+        optionsComposite.layout();
+        optionsComposite.redraw();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/ValueEditorTypeSelectionDialog.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,78 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.brms.client.modeldriven.brl.ISingleFieldConstraint;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+
+public class ValueEditorTypeSelectionDialog extends RuleDialog {
+
+    private final FormToolkit      toolkit;
+
+    private RuleModeller           modeller;
+
+    private ISingleFieldConstraint constraint;
+
+    public ValueEditorTypeSelectionDialog(Shell parent,
+                                          FormToolkit toolkit,
+                                          RuleModeller modeller,
+                                          ISingleFieldConstraint constraint) {
+        super( parent,
+               "Select value editor type",
+               "Select value editor type" );
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.constraint = constraint;
+    }
+
+    protected Control createDialogArea(final Composite parent) {
+        Composite composite = (Composite) super.createDialogArea( parent );
+
+        createLabel( composite,
+                     "Field value:" );
+        final Combo valueTypeCombo = new Combo( composite,
+                                                SWT.READ_ONLY );
+        valueTypeCombo.add( "Literal value" ); // 0
+        valueTypeCombo.add( "A formula" ); // 1
+
+        if ( modeller.getModel().getBoundVariablesInScope( constraint ).size() > 0 ) {
+            valueTypeCombo.add( "Bound variable" ); // 2
+        }
+
+        valueTypeCombo.addModifyListener( new ModifyListener() {
+            public void modifyText(ModifyEvent e) {
+
+                switch ( valueTypeCombo.getSelectionIndex() ) {
+                    case 0 :
+                        constraint.constraintValueType = ISingleFieldConstraint.TYPE_LITERAL;
+                        break;
+                    case 1 :
+                        constraint.constraintValueType = ISingleFieldConstraint.TYPE_RET_VALUE;
+                        break;
+                    case 2 :
+                        constraint.constraintValueType = ISingleFieldConstraint.TYPE_VARIABLE;
+                        break;
+                }
+
+                getShell().getDisplay().asyncExec( new Runnable() {
+
+                    public void run() {
+                        modeller.reloadLhs();
+                        modeller.setDirty( true );
+                        close();
+                    }
+
+                } );
+            }
+        } );
+
+        toolkit.paintBordersFor( composite );
+        return composite;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/ui/Widget.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,80 @@
+package org.drools.eclipse.rulebuilder.ui;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.ui.forms.events.HyperlinkEvent;
+import org.eclipse.ui.forms.events.IHyperlinkListener;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.ImageHyperlink;
+
+public abstract class Widget {
+
+    final protected Composite    parent;
+
+    final protected FormToolkit  toolkit;
+
+    final protected RuleModeller modeller;
+
+    final protected int          index;
+
+    public Widget(Composite parent,
+                  FormToolkit toolkit,
+                  RuleModeller modeller,
+                  int index) {
+        this.parent = parent;
+        this.toolkit = toolkit;
+        this.modeller = modeller;
+        this.index = index;
+    }
+
+    public ImageHyperlink addImage(Composite parent,
+                                   String fileName) {
+        ImageHyperlink imageHyperlink = toolkit.createImageHyperlink( parent,
+                                                                      0 );
+        ImageDescriptor imageDescriptor = DroolsEclipsePlugin.getImageDescriptor( fileName );
+        imageHyperlink.setImage( imageDescriptor.createImage() );
+        return imageHyperlink;
+    }
+
+    protected void addDeleteRHSAction() {
+        ImageHyperlink delWholeLink = addImage( parent,
+                                                "icons/delete_obj.gif" );
+        delWholeLink.addHyperlinkListener( new IHyperlinkListener() {
+            public void linkActivated(HyperlinkEvent e) {
+                MessageBox dialog = new MessageBox( Display.getCurrent().getActiveShell(),
+                                                    SWT.YES | SWT.NO | SWT.ICON_WARNING );
+                dialog.setMessage( "Remove this action?" );
+                dialog.setText( "Remove this action?" );
+                if ( dialog.open() == SWT.YES ) {
+                    getModeller().getModel().removeRhsItem( index );
+                    getModeller().setDirty( true );
+                    getModeller().reloadRhs();
+                }
+            }
+
+            public void linkEntered(HyperlinkEvent e) {
+            }
+
+            public void linkExited(HyperlinkEvent e) {
+            }
+        } );
+        delWholeLink.setToolTipText( "Remove this action." );
+    }
+
+    protected void showMessage(String msg) {
+        MessageBox dialog = new MessageBox( Display.getDefault().getActiveShell(),
+                                            SWT.OK | SWT.ICON_INFORMATION );
+        dialog.setMessage( msg );
+        dialog.setText( "Information" );
+        dialog.open();
+    }
+
+    protected RuleModeller getModeller() {
+        return modeller;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,35 @@
+package org.drools.eclipse.rulebuilder.wizards;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * A wizard to create a BRL guided rule file.
+ */
+public class NewBrlFileWizard extends Wizard implements INewWizard {
+
+    private IWorkbench workbench;
+    private IStructuredSelection selection;
+    private NewBrlFileWizardPage mainPage;
+
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.workbench = workbench;
+        this.selection = selection;
+        setWindowTitle("New Guided Rule");
+    	ImageDescriptor desc = DroolsEclipsePlugin.getImageDescriptor("icons/drools-large.PNG");
+        setDefaultPageImageDescriptor(desc);
+    }
+
+    public void addPages() {
+        mainPage = new NewBrlFileWizardPage(workbench, selection);
+        addPage(mainPage);
+     }
+
+    public boolean performFinish() {
+        return mainPage.finish();
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizardPage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizardPage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/rulebuilder/wizards/NewBrlFileWizardPage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,63 @@
+package org.drools.eclipse.rulebuilder.wizards;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+
+
+/**
+ * A page to create a new rule using the Guided Editor.
+ */
+public class NewBrlFileWizardPage extends WizardNewFileCreationPage {
+
+    private static final String BRL_EXTENSION = ".brl";
+    private IWorkbench workbench;
+
+    public NewBrlFileWizardPage(IWorkbench workbench, IStructuredSelection selection) {
+        super("createGuidedRuleFilePage", selection);
+        setTitle( "RuleBuilder Editor File" );
+        setDescription( "This wizard creates a new file with *.brl extension that can be opened by a multi-page editor." );
+        this.workbench = workbench;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        setPageComplete(true);
+    }
+
+    public boolean finish() {
+        String fileName = getFileName();
+        if (!fileName.endsWith(BRL_EXTENSION)) {
+            setFileName(fileName + BRL_EXTENSION);
+        }
+        org.eclipse.core.resources.IFile newFile = createNewFile();
+        if (newFile == null)
+            return false;
+        try {
+            IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+            org.eclipse.ui.IWorkbenchPage page = dwindow.getActivePage();
+            if (page != null)
+                IDE.openEditor(page, newFile, true);
+        } catch (PartInitException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+        return true;
+    }
+
+    protected InputStream getInitialContents() {
+//            return DroolsEclipsePlugin.getDefault().getBundle().getResource(
+//                "org/drools/eclipse/rulebuilder/wizards/template.brl").openStream();
+            String contents = "";
+            return new ByteArrayInputStream( contents.getBytes() );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,102 @@
+package org.drools.eclipse.util;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.runtime.FileLocator;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+public class DroolsClasspathContainer implements IClasspathContainer {
+
+    IClasspathEntry droolsLibraryEntries[];
+    IPath path;
+    IJavaProject javaProject;
+
+    public DroolsClasspathContainer(IJavaProject project, IPath path) {
+        javaProject = null;
+        javaProject = project;
+        this.path = path;
+    }
+
+    public IClasspathEntry[] getClasspathEntries() {
+        if (droolsLibraryEntries == null) {
+            droolsLibraryEntries = createDroolsLibraryEntries(javaProject);
+        }
+        return droolsLibraryEntries;
+    }
+
+    public String getDescription() {
+        return "Drools Library";
+    }
+
+    public int getKind() {
+        return 1;
+    }
+
+    public IPath getPath() {
+        return path;
+    }
+
+    private IClasspathEntry[] createDroolsLibraryEntries(IJavaProject project) {
+        List jarNames = getJarNames();
+        List list = new ArrayList();
+        for (int i = 0; i < jarNames.size(); i++) {
+            Path path = new Path((String) jarNames.get(i));
+            list.add(JavaCore.newLibraryEntry(
+                path, path, null));
+        }
+        // also add jdt core jar from eclipse itself
+        String pluginRootString = Platform.getInstallLocation().getURL().getPath() + "plugins/";
+        File pluginRoot = new Path(pluginRootString).toFile();
+        File[] files = pluginRoot.listFiles();
+        for (int i = 0; i < files.length; i++) {
+	        if (files[i].getAbsolutePath().indexOf("org.eclipse.jdt.core_3.3") > -1) {
+	        	Path path = new Path(files[i].getAbsolutePath());
+	        	list.add(JavaCore.newLibraryEntry(path, path, null));
+	        	break;
+	        }
+        }
+        return (IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]);
+    }
+
+    private List getJarNames() {
+        String s = getDroolsLocation();
+        List list = new ArrayList();
+        File file = (new Path(s)).toFile();
+        addJarNames(file, list);
+        return list;
+    }
+
+    private void addJarNames(File file, List list) {
+        File[] files = file.listFiles();
+        for (int i = 0; i < files.length; i++) {
+	        if (files[i].isDirectory() && files[i].getName().equals("lib")) {
+	            File[] jarFiles = files[i].listFiles();
+	            for (int j = 0; j < jarFiles.length; j++) {
+	                if (jarFiles[j].getPath().endsWith(".jar")) {
+	                    list.add(jarFiles[j].getAbsolutePath());
+	                }
+	            }
+            }
+        }
+    }
+
+    private String getDroolsLocation() {
+        try {
+            return FileLocator.toFileURL(Platform.getBundle("org.drools.eclipse")
+                .getEntry("/")).getFile().toString();
+        } catch (IOException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+        return null;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainerInitializer.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainerInitializer.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/DroolsClasspathContainerInitializer.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,18 @@
+package org.drools.eclipse.util;
+
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.ClasspathContainerInitializer;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+
+public class DroolsClasspathContainerInitializer extends ClasspathContainerInitializer {
+
+    public void initialize(IPath ipath, IJavaProject project) throws CoreException {
+        DroolsClasspathContainer container =
+            new DroolsClasspathContainer(project, ipath);
+        JavaCore.setClasspathContainer(ipath, new IJavaProject[] { project },
+            new IClasspathContainer[] { container }, null);
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/util/ProjectClassLoader.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,121 @@
+package org.drools.eclipse.util;
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IFileEditorInput;
+
+public class ProjectClassLoader {
+	
+	public static URLClassLoader getProjectClassLoader(IEditorPart editor) {
+		IEditorInput input = editor.getEditorInput();
+		if (input instanceof IFileEditorInput) {
+			return getProjectClassLoader(((IFileEditorInput) input).getFile());
+		}
+		return null;
+	}
+
+	public static URLClassLoader getProjectClassLoader(IFile file) {
+		IProject project = file.getProject();
+		IJavaProject javaProject = JavaCore.create(project);
+		return getProjectClassLoader(javaProject);
+	}
+
+    public static URLClassLoader getProjectClassLoader(IJavaProject project) {
+        List pathElements = getProjectClassPathURLs(project);
+        URL urlPaths[] = (URL[]) pathElements.toArray(new URL[pathElements.size()]);
+        return new URLClassLoader(urlPaths, Thread.currentThread().getContextClassLoader());
+    }
+
+    private static URL getRawLocationURL(IPath simplePath)
+            throws MalformedURLException {
+        File file = getRawLocationFile(simplePath);
+        return file.toURI().toURL();
+    }
+
+    private static File getRawLocationFile(IPath simplePath) {
+        IResource resource = ResourcesPlugin.getWorkspace().getRoot().findMember(simplePath);
+        File file = null;
+        if (resource != null) {
+            file = ResourcesPlugin.getWorkspace().getRoot().findMember(
+                    simplePath).getRawLocation().toFile();
+        } else {
+            file = simplePath.toFile();
+        }
+        return file;
+    }
+
+    public static List getProjectClassPathURLs(IJavaProject project) {
+        List pathElements = new ArrayList();
+        try {
+            IClasspathEntry[] paths = project.getResolvedClasspath(true);
+            Set outputPaths = new HashSet();
+            if (paths != null) {
+                for ( int i = 0; i < paths.length; i++ ) {
+                    IClasspathEntry path = paths[i];
+                    if (path.getEntryKind() == IClasspathEntry.CPE_LIBRARY) {
+                        URL url = getRawLocationURL(path.getPath());
+                        pathElements.add(url);
+                    } else if (path.getEntryKind() == IClasspathEntry.CPE_SOURCE) {
+                    	IPath output = path.getOutputLocation();
+                    	if (path.getOutputLocation() != null) {
+                    		outputPaths.add(output);
+                    	}
+                    }
+                }
+            }
+            IPath location = getProjectLocation(project.getProject());
+            IPath outputPath = location.append(project.getOutputLocation().removeFirstSegments(1));
+            pathElements.add(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());
+            }
+            
+            // also add classpath of required projects
+            String[] names = project.getRequiredProjectNames();
+            for ( int i = 0; i < names.length; i++ ) {
+                String projectName = names[i];
+                IProject reqProject = project.getProject().getWorkspace()
+                    .getRoot().getProject(projectName);
+                if (reqProject != null) {
+                    IJavaProject reqJavaProject = JavaCore.create(reqProject);
+                    pathElements.addAll(getProjectClassPathURLs(reqJavaProject));
+                }
+            }
+        } catch (JavaModelException e) {
+            DroolsEclipsePlugin.log(e);
+        } catch (MalformedURLException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+        return pathElements;
+    }
+    
+    public static IPath getProjectLocation(IProject project) {
+        if (project.getRawLocation() == null) {
+            return project.getLocation();
+        } else {
+            return project.getRawLocation();
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/rules/RulesView.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/rules/RulesView.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/view/rules/RulesView.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,288 @@
+package org.drools.eclipse.view.rules;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.eclipse.DRLInfo;
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.core.DroolsElement;
+import org.drools.eclipse.core.DroolsModelBuilder;
+import org.drools.eclipse.core.Function;
+import org.drools.eclipse.core.Global;
+import org.drools.eclipse.core.Package;
+import org.drools.eclipse.core.Query;
+import org.drools.eclipse.core.Rule;
+import org.drools.eclipse.core.RuleSet;
+import org.drools.eclipse.core.Template;
+import org.drools.eclipse.core.ui.DroolsContentProvider;
+import org.drools.eclipse.core.ui.DroolsLabelProvider;
+import org.drools.eclipse.core.ui.DroolsTreeSorter;
+import org.drools.eclipse.core.ui.FilterActionGroup;
+import org.drools.lang.descr.FactTemplateDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceChangeEvent;
+import org.eclipse.core.resources.IResourceChangeListener;
+import org.eclipse.core.resources.IResourceDelta;
+import org.eclipse.core.resources.IResourceDeltaVisitor;
+import org.eclipse.core.resources.IResourceVisitor;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jface.viewers.DoubleClickEvent;
+import org.eclipse.jface.viewers.IDoubleClickListener;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IEditorPart;
+import org.eclipse.ui.IMemento;
+import org.eclipse.ui.IViewSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.forms.editor.FormEditor;
+import org.eclipse.ui.ide.IDE;
+import org.eclipse.ui.part.ViewPart;
+import org.eclipse.ui.texteditor.ITextEditor;
+
+public class RulesView extends ViewPart implements IDoubleClickListener, IResourceVisitor, IResourceChangeListener {
+
+	private final RuleSet ruleSet = DroolsModelBuilder.createRuleSet();
+
+	private Map resourcesMap = new HashMap();
+	private TreeViewer treeViewer;
+	
+	public void createPartControl(Composite parent) {
+		treeViewer = new TreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
+		treeViewer.setContentProvider(new DroolsContentProvider());
+		treeViewer.setLabelProvider(new DroolsLabelProvider());
+		treeViewer.setSorter(new DroolsTreeSorter());
+		treeViewer.addDoubleClickListener(this);
+		treeViewer.setUseHashlookup(true);
+		treeViewer.setInput(ruleSet);
+		FilterActionGroup filterActionGroup = new FilterActionGroup(
+			treeViewer, "org.drools.eclipse.view.rules.RulesView");
+		filterActionGroup.fillActionBars(getViewSite().getActionBars());
+	}
+	
+	public void init(IViewSite site, IMemento memento) throws PartInitException {
+		super.init(site, memento);
+		try {
+			ResourcesPlugin.getWorkspace().getRoot().accept(this);
+		} catch (CoreException e) {
+			DroolsEclipsePlugin.log(e);
+		}
+		ResourcesPlugin.getWorkspace().addResourceChangeListener(this);
+	}
+	
+	public void dispose() {
+		ResourcesPlugin.getWorkspace().removeResourceChangeListener(this);
+	}
+	
+	public void setFocus() {
+		treeViewer.getControl().setFocus();
+	}
+
+	public boolean visit(IResource resource) throws CoreException {
+		return updateResource(resource);
+	}
+	
+	private boolean updateResource(IResource resource) {
+    	IProject project = resource.getProject();
+    	if (project != null) {
+            IJavaProject javaProject = JavaCore.create(project);
+            if (!javaProject.exists()) {
+            	return false;
+            }
+    		if (resource instanceof IFile 
+    				&& "drl".equals(resource.getFileExtension())
+    				&& javaProject.isOnClasspath(resource)) {
+    			try {
+    				IFile file = (IFile) resource;
+    				DRLInfo drlInfo = DroolsEclipsePlugin.getDefault().parseResource(resource, false);
+    				String packageName = drlInfo.getPackageName();
+    				Package pkg = ruleSet.getPackage(packageName);
+    				if (pkg == null) {
+    					pkg = DroolsModelBuilder.addPackage(ruleSet, packageName, 0, 0);
+    				}
+    				// add rules
+    				List rules = drlInfo.getPackageDescr().getRules();
+    				for (Iterator iterator = rules.iterator(); iterator.hasNext();) {
+    					RuleDescr ruleDescr = (RuleDescr) iterator.next();
+    					boolean isQuery = ruleDescr instanceof QueryDescr;
+    					String ruleName = ruleDescr.getName();
+    					if (!isQuery) {
+    						Rule rule = DroolsModelBuilder.addRule(
+								pkg, ruleName, file, ruleDescr.getStartCharacter(),
+								ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1, null);
+	    					// create link between resource and created rule nodes
+	    					List droolsElements = (List) resourcesMap.get(file);
+	    					if (droolsElements == null) {
+	    						droolsElements = new ArrayList();
+	    						resourcesMap.put(file, droolsElements);
+	    					}
+	    					droolsElements.add(rule);
+    					} else {
+    						Query query = DroolsModelBuilder.addQuery(
+								pkg, ruleName, file, ruleDescr.getStartCharacter(), 
+								ruleDescr.getEndCharacter() - ruleDescr.getStartCharacter() + 1);
+	    					// create link between resource and created rule nodes
+	    					List droolsElements = (List) resourcesMap.get(file);
+	    					if (droolsElements == null) {
+	    						droolsElements = new ArrayList();
+	    						resourcesMap.put(file, droolsElements);
+	    					}
+	    					droolsElements.add(query);
+    					}
+    				}
+    				// add templates
+    				List templates = drlInfo.getPackageDescr().getFactTemplates();
+    				for (Iterator iterator = templates.iterator(); iterator.hasNext();) {
+    					FactTemplateDescr templateDescr = (FactTemplateDescr) iterator.next();
+						Template template = DroolsModelBuilder.addTemplate(
+							pkg, templateDescr.getName(), file, templateDescr.getStartCharacter(),
+							templateDescr.getEndCharacter() - templateDescr.getStartCharacter() + 1);
+    					// create link between resource and created rule nodes
+    					List droolsElements = (List) resourcesMap.get(file);
+    					if (droolsElements == null) {
+    						droolsElements = new ArrayList();
+    						resourcesMap.put(file, droolsElements);
+    					}
+    					droolsElements.add(template);
+    				}
+    				// add globals
+    				List globals = drlInfo.getPackageDescr().getGlobals();
+    				for (Iterator iterator = globals.iterator(); iterator.hasNext();) {
+    					GlobalDescr globalDescr = (GlobalDescr) iterator.next();
+    					Global global = DroolsModelBuilder.addGlobal(
+							pkg, globalDescr.getIdentifier(), file, globalDescr.getStartCharacter(),
+							globalDescr.getEndCharacter() - globalDescr.getStartCharacter() + 1);
+    					// create link between resource and created rule nodes
+    					List droolsElements = (List) resourcesMap.get(file);
+    					if (droolsElements == null) {
+    						droolsElements = new ArrayList();
+    						resourcesMap.put(file, droolsElements);
+    					}
+    					droolsElements.add(global);
+    				}
+    				// add functions
+    				List functions = drlInfo.getPackageDescr().getFunctions();
+    				for (Iterator iterator = functions.iterator(); iterator.hasNext();) {
+    					FunctionDescr functionDescr = (FunctionDescr) iterator.next();
+    					String functionName = functionDescr.getName();
+    					Function function = DroolsModelBuilder.addFunction(
+							pkg, functionName, file, functionDescr.getStartCharacter(),
+							functionDescr.getEndCharacter() - functionDescr.getStartCharacter() + 1);
+    					// create link between resource and created rule nodes
+    					List droolsElements = (List) resourcesMap.get(file);
+    					if (droolsElements == null) {
+    						droolsElements = new ArrayList();
+    						resourcesMap.put(file, droolsElements);
+    					}
+    					droolsElements.add(function);
+    				}
+    			} catch (Throwable t) {
+    				DroolsEclipsePlugin.log(t);
+    			}
+    			return false;
+    		}
+        }
+        return true;
+	}
+
+	public void resourceChanged(final IResourceChangeEvent event) {
+		try {
+			if (event.getType() == IResourceChangeEvent.POST_CHANGE) {
+				IResourceDelta delta = event.getDelta();
+				if (delta != null) {
+					delta.accept(new IResourceDeltaVisitor() {
+						public boolean visit(IResourceDelta delta) throws CoreException {
+							IResource resource = delta.getResource();
+							removeElementsFromResource(resource);
+							boolean result = true;
+							if (delta.getKind() != IResourceDelta.REMOVED) {
+								result = updateResource(resource);
+							}
+							treeViewer.getControl().getDisplay().asyncExec(
+						        new Runnable() {
+									public void run() {
+										treeViewer.refresh();
+									}
+								}
+					        );
+							return result;
+						}
+					});
+				}
+			} else if (event.getType() == IResourceChangeEvent.PRE_DELETE) {
+				IResource resource = event.getResource();
+				if (resource != null) {
+					resource.accept(new IResourceVisitor() {
+						public boolean visit(IResource resource) throws CoreException {
+							removeElementsFromResource(resource);
+							return true;
+						}
+					});
+				}
+			} else if (event.getType() == IResourceChangeEvent.PRE_CLOSE) {
+				IResource resource = event.getResource();
+				if (resource != null) {
+					resource.accept(new IResourceVisitor() {
+						public boolean visit(IResource resource) throws CoreException {
+							removeElementsFromResource(resource);
+							return true;
+						}
+					});
+				}
+			}
+		} catch (Throwable t) {
+			DroolsEclipsePlugin.log(t);
+		}
+	}
+	
+	private void removeElementsFromResource(IResource resource) {
+		List droolsElements = (List) resourcesMap.get(resource);
+		if (droolsElements != null) {
+			for (Iterator iterator = droolsElements.iterator(); iterator.hasNext();) {
+				DroolsModelBuilder.removeElement((DroolsElement) iterator.next());
+			}
+			resourcesMap.remove(resource);
+		}
+	}
+
+	public void doubleClick(DoubleClickEvent event) {
+		ISelection selection = event.getSelection();
+		if (selection instanceof IStructuredSelection) {
+			Object selected = ((StructuredSelection) selection).getFirstElement();
+			if (selected != null && selected instanceof DroolsElement) {
+				DroolsElement droolsSelected = (DroolsElement) selected;
+				IFile file = droolsSelected.getFile();
+				if (file != null) {
+					try {
+						IEditorPart editor = IDE.openEditor(getSite().getPage(), file);
+						if (editor instanceof FormEditor) {
+							editor = ((FormEditor) editor).getActiveEditor();
+						}
+						if (editor instanceof ITextEditor) {
+							((ITextEditor)editor).selectAndReveal(
+								droolsSelected.getOffset(), droolsSelected.getLength());
+						}
+					} catch (Throwable t) {
+						DroolsEclipsePlugin.log(t);
+					}
+				}
+			}
+		}
+	}
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFilePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFilePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFilePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,69 @@
+package org.drools.eclipse.wizard.decisiontable;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * A page to create a new Decision table scaffolding based on a template.
+ *
+ * @author Michael Neale
+ */
+public class NewDTFilePage extends WizardNewFileCreationPage {
+
+    private static final String XLS_EXTENSION = ".xls";
+    private IWorkbench workbench;
+
+    public NewDTFilePage(IWorkbench workbench, IStructuredSelection selection) {
+        super("createDTFilePage", selection);
+        setTitle("New Decision Table");
+        setDescription("Create a new Decision Table scaffolding.");
+        this.workbench = workbench;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        setPageComplete(true);
+    }
+
+    public boolean finish() {
+        String fileName = getFileName();
+        if (!fileName.endsWith(XLS_EXTENSION)) {
+            setFileName(fileName + XLS_EXTENSION);
+        }
+        org.eclipse.core.resources.IFile newFile = createNewFile();
+        if (newFile == null)
+            return false;
+        try {
+            IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+            org.eclipse.ui.IWorkbenchPage page = dwindow.getActivePage();
+            if (page != null)
+                IDE.openEditor(page, newFile, true);
+        } catch (PartInitException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+        return true;
+    }
+
+    protected InputStream getInitialContents() {
+        try {
+            return DroolsEclipsePlugin.getDefault().getBundle().getResource(
+                "org/drools/eclipse/wizard/decisiontable/template.xls").openStream();
+        } catch (IOException e) {
+            return null;
+        } catch (NullPointerException e) {
+            return null;
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFileWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFileWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/decisiontable/NewDTFileWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,40 @@
+package org.drools.eclipse.wizard.decisiontable;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * A wizard to create a Decision Table scaffold.
+ * 
+ * @author Michael Neale
+ */
+public class NewDTFileWizard extends Wizard implements INewWizard {
+
+    private IWorkbench workbench;
+    private IStructuredSelection selection;
+    private NewDTFilePage mainPage;
+    
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.workbench = workbench;
+        this.selection = selection;
+        setWindowTitle("New Decision Table");
+    	ImageDescriptor desc = DroolsEclipsePlugin.getImageDescriptor("icons/dt-large.gif");
+        setDefaultPageImageDescriptor(desc);        
+    }
+    
+    public void addPages() {
+        mainPage = new NewDTFilePage(workbench, selection);
+        addPage(mainPage);
+     }
+
+    public boolean performFinish() {
+        return mainPage.finish();
+    }
+    
+
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFilePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,74 @@
+/*
+ * Created on 11-jan-2005
+ *
+ */
+package org.drools.eclipse.wizard.dsl;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * A page to create a new Domain Specific Language configuration.
+ * There may be additional options here in future.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ * @author Michael Neale
+ */
+public class NewDSLFilePage extends WizardNewFileCreationPage {
+
+    private IWorkbench workbench;
+
+    public NewDSLFilePage(IWorkbench workbench, IStructuredSelection selection) {
+        super("createDSLFilePage", selection);
+        setTitle("New DSL");
+        setDescription("Create a new Domain Specific Language configuration");
+        this.workbench = workbench;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        setPageComplete(true);
+    }
+
+    public boolean finish() {
+        String fileName = getFileName();
+        if (!fileName.endsWith(".dsl")) {
+            setFileName(fileName + ".dsl");
+        }
+        org.eclipse.core.resources.IFile newFile = createNewFile();
+        if (newFile == null)
+            return false;
+        try {
+            IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+            org.eclipse.ui.IWorkbenchPage page = dwindow.getActivePage();
+            if (page != null)
+                IDE.openEditor(page, newFile, true);
+        } catch (PartInitException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+        return true;
+    }
+    
+    protected InputStream getInitialContents() {
+        try {
+            return DroolsEclipsePlugin.getDefault().getBundle().getResource(
+                "org/drools/eclipse/wizard/dsl/template.dsl").openStream();
+        } catch (IOException e) {
+            return null;
+        } catch (NullPointerException e) {
+            return null;
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/dsl/NewDSLFileWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,41 @@
+package org.drools.eclipse.wizard.dsl;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * A wizard to create a new Domain Specific Language.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ * @author Michael Neale
+ */
+public class NewDSLFileWizard extends Wizard implements INewWizard {
+
+    private IWorkbench workbench;
+    private IStructuredSelection selection;
+    private NewDSLFilePage mainPage;
+    
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.workbench = workbench;
+        this.selection = selection;
+        setWindowTitle("New Domain Specific Language configuration");
+    	ImageDescriptor desc = DroolsEclipsePlugin.getImageDescriptor("icons/dsl-large.png");
+        setDefaultPageImageDescriptor(desc);        
+    }
+    
+    public void addPages() {
+        mainPage = new NewDSLFilePage(workbench, selection);
+        addPage(mainPage);
+     }
+
+    public boolean performFinish() {
+        return mainPage.finish();
+    }
+    
+
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,436 @@
+package org.drools.eclipse.wizard.project;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.builder.DroolsBuilder;
+import org.drools.eclipse.util.DroolsClasspathContainer;
+import org.eclipse.core.resources.ICommand;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IProjectDescription;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IResourceStatus;
+import org.eclipse.core.resources.IWorkspace;
+import org.eclipse.core.resources.IncrementalProjectBuilder;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IPath;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.OperationCanceledException;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.core.runtime.SubProgressMonitor;
+import org.eclipse.jdt.core.IClasspathContainer;
+import org.eclipse.jdt.core.IClasspathEntry;
+import org.eclipse.jdt.core.IJavaProject;
+import org.eclipse.jdt.core.IPackageFragment;
+import org.eclipse.jdt.core.IPackageFragmentRoot;
+import org.eclipse.jdt.core.JavaCore;
+import org.eclipse.jdt.core.JavaModelException;
+import org.eclipse.jdt.ui.PreferenceConstants;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.actions.WorkspaceModifyOperation;
+import org.eclipse.ui.dialogs.WizardNewProjectCreationPage;
+import org.eclipse.ui.wizards.newresource.BasicNewResourceWizard;
+
+/**
+ * A wizard to create a new Drools project.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class NewDroolsProjectWizard extends BasicNewResourceWizard {
+
+    public static final String DROOLS_CLASSPATH_CONTAINER_PATH = "DROOLS/Drools";
+    
+    private IProject newProject;
+    private WizardNewProjectCreationPage mainPage;
+    private NewDroolsProjectWizardPage extraPage;
+    
+    public void addPages() {
+        super.addPages();
+        mainPage = new WizardNewProjectCreationPage("basicNewProjectPage");
+        mainPage.setTitle("New Drools Project");
+        mainPage.setDescription("Create a new Drools Project");
+        this.addPage(mainPage);
+        extraPage = new NewDroolsProjectWizardPage();
+        addPage(extraPage);
+        setNeedsProgressMonitor(true);
+    }
+
+    public boolean performFinish() {
+        createDroolsProject();
+        if (newProject == null) {
+            return false;
+        }
+        selectAndReveal(newProject);
+        return true;
+    }
+
+    private void createDroolsProject() {
+        newProject = createNewProject();
+        WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+            protected void execute(IProgressMonitor monitor)
+                    throws CoreException {
+                try {
+                	IJavaProject project = JavaCore.create(newProject);
+                    createOutputLocation(project, monitor);
+                    addJavaBuilder(project, monitor);
+                    setClasspath(project, monitor);
+                    createInitialContent(project, monitor);
+                	newProject.build(IncrementalProjectBuilder.FULL_BUILD, monitor);
+                } catch (IOException _ex) {
+                	ErrorDialog.openError(getShell(), "Problem creating Drools project",
+                        null, null);
+                }
+            }
+        };
+        try {
+            getContainer().run(true, true, op);
+        } catch (Throwable t) {
+            DroolsEclipsePlugin.log(t);
+        }
+    }
+    
+    private IProject createNewProject() {
+        if (newProject != null) {
+            return newProject;
+        }
+        final IProject newProjectHandle = mainPage.getProjectHandle();
+
+        // get a project descriptor
+        IPath newPath = null;
+        if (!mainPage.useDefaults())
+            newPath = mainPage.getLocationPath();
+
+        IWorkspace workspace = ResourcesPlugin.getWorkspace();
+        final IProjectDescription description = workspace
+                .newProjectDescription(newProjectHandle.getName());
+        description.setLocation(newPath);
+        addNatures(description);
+
+        // create the new project operation
+        WorkspaceModifyOperation op = new WorkspaceModifyOperation() {
+            protected void execute(IProgressMonitor monitor)
+                    throws CoreException {
+                createProject(description, newProjectHandle, monitor);
+            }
+        };
+
+        // run the new project creation operation
+        try {
+            getContainer().run(true, true, op);
+        } catch (InterruptedException e) {
+            return null;
+        } catch (InvocationTargetException e) {
+            Throwable t = e.getTargetException();
+            if (t instanceof CoreException) {
+                if (((CoreException) t).getStatus().getCode() == IResourceStatus.CASE_VARIANT_EXISTS) {
+                    MessageDialog.openError(getShell(),
+                        "NewProject.errorMessage",
+                        "NewProject.caseVariantExistsError"
+                                + newProjectHandle.getName());
+                } else {
+                    ErrorDialog.openError(getShell(),
+                        "NewProject.errorMessage", null, // no special message
+                        ((CoreException) t).getStatus());
+                }
+            } else {
+                DroolsEclipsePlugin.log(e);
+            }
+            return null;
+        }
+
+        return newProjectHandle;
+    }
+    
+    private void addNatures(IProjectDescription projectDescription) {
+        List list = new ArrayList();
+        list.addAll(Arrays.asList(projectDescription.getNatureIds()));
+        list.add("org.eclipse.jdt.core.javanature");
+        projectDescription.setNatureIds((String[]) list
+            .toArray(new String[list.size()]));
+    }
+    
+    private void createProject(IProjectDescription description,
+            IProject projectHandle, IProgressMonitor monitor)
+            throws CoreException, OperationCanceledException {
+        try {
+            monitor.beginTask("", 2000);
+            projectHandle.create(description, new SubProgressMonitor(monitor,
+                    1000));
+            if (monitor.isCanceled()) {
+                throw new OperationCanceledException();
+            }
+            projectHandle.open(IResource.BACKGROUND_REFRESH,
+                new SubProgressMonitor(monitor, 1000));
+        } finally {
+            monitor.done();
+        }
+    }
+    
+    private void createOutputLocation(IJavaProject project, IProgressMonitor monitor)
+            throws JavaModelException, CoreException {
+        IFolder folder = project.getProject().getFolder("bin");
+        createFolder(folder, monitor);
+        IPath path = folder.getFullPath();
+        project.setOutputLocation(path, null);
+    }
+
+    private void addJavaBuilder(IJavaProject project, IProgressMonitor monitor) throws CoreException {
+        IProjectDescription description = project.getProject().getDescription();
+        ICommand[] commands = description.getBuildSpec();
+        ICommand[] newCommands = new ICommand[commands.length + 2];
+        System.arraycopy(commands, 0, newCommands, 0, commands.length);
+
+        ICommand javaCommand = description.newCommand();
+        javaCommand.setBuilderName("org.eclipse.jdt.core.javabuilder");
+        newCommands[commands.length] = javaCommand;
+        
+        ICommand droolsCommand = description.newCommand();
+        droolsCommand.setBuilderName(DroolsBuilder.BUILDER_ID);
+        newCommands[commands.length + 1] = droolsCommand;
+        
+        description.setBuildSpec(newCommands);
+        project.getProject().setDescription(description, monitor);
+    }
+
+    private void setClasspath(IJavaProject project, IProgressMonitor monitor)
+            throws JavaModelException, CoreException {
+        project.setRawClasspath(new IClasspathEntry[0], monitor);
+        addSourceFolders(project, monitor);
+        addJRELibraries(project, monitor);
+        addDroolsLibraries(project, monitor);
+    }
+
+    private void addSourceFolders(IJavaProject project, IProgressMonitor monitor) throws JavaModelException, CoreException {
+        List list = new ArrayList();
+        list.addAll(Arrays.asList(project.getRawClasspath()));
+        addSourceFolder(project, list, "src/main/java", monitor);
+        addSourceFolder(project, list, "src/main/rules", monitor);
+        project.setRawClasspath((IClasspathEntry[]) list.toArray(new IClasspathEntry[list.size()]), null);
+    }
+    
+    private void addJRELibraries(IJavaProject project, IProgressMonitor monitor) throws JavaModelException {
+        List list = new ArrayList();
+        list.addAll(Arrays.asList(project.getRawClasspath()));
+        list.addAll(Arrays.asList(PreferenceConstants.getDefaultJRELibrary()));
+        project.setRawClasspath((IClasspathEntry[]) list
+            .toArray(new IClasspathEntry[list.size()]), monitor);
+    }
+
+    private static IPath getClassPathContainerPath() {
+        return new Path(DROOLS_CLASSPATH_CONTAINER_PATH);
+    }
+
+    private static void createDroolsLibraryContainer(IJavaProject project, IProgressMonitor monitor)
+            throws JavaModelException {
+        JavaCore.setClasspathContainer(getClassPathContainerPath(),
+            new IJavaProject[] { project },
+            new IClasspathContainer[] { new DroolsClasspathContainer(
+                    project, getClassPathContainerPath()) }, monitor);
+    }
+
+    public static void addDroolsLibraries(IJavaProject project, IProgressMonitor monitor)
+            throws JavaModelException {
+        createDroolsLibraryContainer(project, monitor);
+        List list = new ArrayList();
+        list.addAll(Arrays.asList(project.getRawClasspath()));
+        list.add(JavaCore.newContainerEntry(getClassPathContainerPath()));
+        project.setRawClasspath((IClasspathEntry[]) list
+            .toArray(new IClasspathEntry[list.size()]), monitor);
+    }
+
+    private void createInitialContent(IJavaProject project, IProgressMonitor monitor)
+            throws CoreException, JavaModelException, IOException {
+    	try {
+	    	if (extraPage.createJavaRuleFile()) {
+	    		createRuleSampleLauncher(project);
+	    	}
+	    	if (extraPage.createRuleFile()) {
+	    		createRule(project, monitor);
+	    	}
+	    	if (extraPage.createDecisionTableFile()) {
+	    		createDecisionTable(project, monitor);
+	    	}
+	    	if (extraPage.createJavaDecisionTableFile()) {
+	    		createDecisionTableSampleLauncher(project);
+	    	}
+	    	if (extraPage.createRuleFlowFile()) {
+	    		createRuleFlow(project, monitor);
+	    	}
+	    	if (extraPage.createJavaRuleFlowFile()) {
+	    		createRuleFlowSampleLauncher(project);
+	    	}
+    	} catch (Throwable t) {
+    		t.printStackTrace();
+    	}
+	}
+
+    /**
+     * Create the sample rule launcher file.
+     */
+    private void createRuleSampleLauncher(IJavaProject project)
+            throws JavaModelException, IOException {
+        
+        String s = "org/drools/eclipse/wizard/project/RuleLauncherSample.java.template";
+        IFolder folder = project.getProject().getFolder("src/main/java");
+        IPackageFragmentRoot packageFragmentRoot = project
+                .getPackageFragmentRoot(folder);
+        IPackageFragment packageFragment = packageFragmentRoot
+                .createPackageFragment("com.sample", true, null);
+        InputStream inputstream = getClass().getClassLoader()
+                .getResourceAsStream(s);
+        packageFragment.createCompilationUnit("DroolsTest.java", new String(
+                readStream(inputstream)), true, null);
+    }
+
+    /**
+     * Create the sample decision table launcher file.
+     */
+    private void createDecisionTableSampleLauncher(IJavaProject project)
+            throws JavaModelException, IOException {
+        
+        String s = "org/drools/eclipse/wizard/project/DecisionTableLauncherSample.java.template";
+        IFolder folder = project.getProject().getFolder("src/main/java");
+        IPackageFragmentRoot packageFragmentRoot = project
+                .getPackageFragmentRoot(folder);
+        IPackageFragment packageFragment = packageFragmentRoot
+                .createPackageFragment("com.sample", true, null);
+        InputStream inputstream = getClass().getClassLoader()
+                .getResourceAsStream(s);
+        packageFragment.createCompilationUnit("DecisionTableTest.java", new String(
+                readStream(inputstream)), true, null);
+    }
+
+    /**
+     * Create the sample rule file.
+     */
+    private void createRule(IJavaProject project, IProgressMonitor monitor)
+            throws CoreException {
+        String fileName = "org/drools/eclipse/wizard/project/Sample.drl.template";
+        IFolder folder = project.getProject().getFolder("src/main/rules");
+        IFile file = folder.getFile("Sample.drl");
+        InputStream inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
+        if (!file.exists()) {
+        	file.create(inputstream, true, monitor);
+        } else {
+        	file.setContents(inputstream, true, false, monitor);
+        }
+    }
+
+    /**
+     * Create the sample decision table file.
+     */
+    private void createDecisionTable(IJavaProject project, IProgressMonitor monitor)
+            throws CoreException {
+        String fileName = "org/drools/eclipse/wizard/project/Sample.xls.template";
+        IFolder folder = project.getProject().getFolder("src/main/rules");
+        IFile file = folder.getFile("Sample.xls");
+        InputStream inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
+        if (!file.exists()) {
+        	file.create(inputstream, true, monitor);
+        } else {
+        	file.setContents(inputstream, true, false, monitor);
+        }
+    }
+
+    /**
+     * Create the sample RuleFlow file.
+     */
+    private void createRuleFlow(IJavaProject project, IProgressMonitor monitor)
+            throws CoreException {
+        String fileName = "org/drools/eclipse/wizard/project/ruleflow.rf.template";
+        IFolder folder = project.getProject().getFolder("src/main/rules");
+        IFile file = folder.getFile("ruleflow.rf");
+        InputStream inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
+        if (!file.exists()) {
+        	file.create(inputstream, true, monitor);
+        } else {
+        	file.setContents(inputstream, true, false, monitor);
+        }
+        fileName = "org/drools/eclipse/wizard/project/ruleflow.rfm.template";
+        folder = project.getProject().getFolder("src/main/rules");
+        file = folder.getFile("ruleflow.rfm");
+        inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
+        if (!file.exists()) {
+        	file.create(inputstream, true, monitor);
+        } else {
+        	file.setContents(inputstream, true, false, monitor);
+        }
+        fileName = "org/drools/eclipse/wizard/project/ruleflow.drl.template";
+        folder = project.getProject().getFolder("src/main/rules");
+        file = folder.getFile("ruleflow.drl");
+        inputstream = getClass().getClassLoader().getResourceAsStream(fileName);
+        if (!file.exists()) {
+        	file.create(inputstream, true, monitor);
+        } else {
+        	file.setContents(inputstream, true, false, monitor);
+        }
+    }
+
+    /**
+     * Create the sample RuleFlow launcher file.
+     */
+    private void createRuleFlowSampleLauncher(IJavaProject project)
+            throws JavaModelException, IOException {
+        
+        String s = "org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template";
+        IFolder folder = project.getProject().getFolder("src/main/java");
+        IPackageFragmentRoot packageFragmentRoot = project
+                .getPackageFragmentRoot(folder);
+        IPackageFragment packageFragment = packageFragmentRoot
+                .createPackageFragment("com.sample", true, null);
+        InputStream inputstream = getClass().getClassLoader()
+                .getResourceAsStream(s);
+        packageFragment.createCompilationUnit("RuleFlowTest.java", new String(
+                readStream(inputstream)), true, null);
+    }
+
+    protected void initializeDefaultPageImageDescriptor() {
+    	ImageDescriptor desc = DroolsEclipsePlugin.getImageDescriptor("icons/drools-large.PNG");
+        setDefaultPageImageDescriptor(desc);
+    }
+
+    private byte[] readStream(InputStream inputstream) throws IOException {
+		byte bytes[] = (byte[]) null;
+		int i = 0;
+		byte tempBytes[] = new byte[1024];
+		for (int j = inputstream.read(tempBytes); j != -1; j = inputstream.read(tempBytes)) {
+			byte tempBytes2[] = new byte[i + j];
+			if (i > 0) {
+				System.arraycopy(bytes, 0, tempBytes2, 0, i);
+			}
+			System.arraycopy(tempBytes, 0, tempBytes2, i, j);
+			bytes = tempBytes2;
+			i += j;
+		}
+
+		return bytes;
+	}
+    
+    private void addSourceFolder(IJavaProject project, List list, String s, IProgressMonitor monitor) throws CoreException {
+        IFolder folder = project.getProject().getFolder(s);
+        createFolder(folder, monitor);
+        IPackageFragmentRoot ipackagefragmentroot = project.getPackageFragmentRoot(folder);
+        list.add(JavaCore.newSourceEntry(ipackagefragmentroot.getPath()));
+    }
+    
+    private void createFolder(IFolder folder, IProgressMonitor monitor) throws CoreException {
+        IContainer container = folder.getParent();
+        if (container != null && !container.exists()
+                && (container instanceof IFolder))
+            createFolder((IFolder) container, monitor);
+        if (!folder.exists()) {
+        	folder.create(true, true, monitor);
+        }
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizardPage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizardPage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/project/NewDroolsProjectWizardPage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,147 @@
+package org.drools.eclipse.wizard.project;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+
+public class NewDroolsProjectWizardPage extends WizardPage {
+
+	private Button addSampleJavaRuleCodeButton;
+	private Button addSampleRuleButton;
+	private Button addSampleJavaDecisionTableCodeButton;
+	private Button addSampleDecisionTableCodeButton;
+	private Button addSampleRuleFlowButton;
+	private Button addSampleJavaRuleFlowCodeButton;
+	private boolean addSampleJavaRuleCode = true;
+	private boolean addSampleRule = true;
+	private boolean addSampleJavaDecisionTableCode = false;
+	private boolean addSampleDecisionTableCode = false;
+	private boolean addSampleJavaRuleFlowCode = false;
+	private boolean addSampleRuleFlow = false;
+	
+	public NewDroolsProjectWizardPage() {
+		super("extendedNewProjectPage");
+		setTitle("New Drools Project");
+        setDescription("Create a new Drools Project");
+	}
+	
+	public void createControl(Composite parent) {
+        Composite composite = new Composite(parent, SWT.NULL);
+        composite.setFont(parent.getFont());
+        composite.setLayout(new GridLayout());
+        composite.setLayoutData(new GridData(GridData.FILL_BOTH));
+        createControls(composite);
+        setPageComplete(true);
+        // Show description on opening
+        setErrorMessage(null);
+        setMessage(null);
+        setControl(composite);
+	}
+	
+	private void createControls(Composite parent) {
+		addSampleRuleButton = createCheckBox(parent,
+			"Add a sample HelloWorld rule file to this project.");
+		addSampleRuleButton.setSelection(addSampleRule);
+		addSampleRuleButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleRule = ((Button) e.widget).getSelection();
+			}
+		});
+		addSampleJavaRuleCodeButton = createCheckBox(parent,
+			"Add a sample Java class for loading and executing the HelloWorld rules.");
+		addSampleJavaRuleCodeButton.setSelection(addSampleJavaRuleCode);
+		addSampleJavaRuleCodeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleJavaRuleCode = ((Button) e.widget).getSelection();
+			}
+		});
+		addSampleDecisionTableCodeButton = createCheckBox(parent,
+			"Add a sample HelloWorld decision table file to this project.");
+		addSampleDecisionTableCodeButton.setSelection(addSampleDecisionTableCode);
+		addSampleDecisionTableCodeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleDecisionTableCode = ((Button) e.widget).getSelection();
+			}
+		});
+		addSampleJavaDecisionTableCodeButton = createCheckBox(parent,
+			"Add a sample Java class for loading and executing the HelloWorld decision table.");
+		addSampleJavaDecisionTableCodeButton.setSelection(addSampleDecisionTableCode);
+		addSampleJavaDecisionTableCodeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleJavaDecisionTableCode = ((Button) e.widget).getSelection();
+			}
+		});
+		addSampleRuleFlowButton = createCheckBox(parent,
+			"Add a sample RuleFlow file to this project.");
+		addSampleRuleFlowButton.setSelection(addSampleRuleFlow);
+		addSampleRuleFlowButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleRuleFlow = ((Button) e.widget).getSelection();
+			}
+		});
+		addSampleJavaRuleFlowCodeButton = createCheckBox(parent,
+			"Add a sample Java class for loading and executing the RuleFlow.");
+		addSampleJavaRuleFlowCodeButton.setSelection(addSampleJavaRuleFlowCode);
+		addSampleJavaRuleFlowCodeButton.addSelectionListener(new SelectionListener() {
+			public void widgetDefaultSelected(SelectionEvent e) {
+				// do nothing
+			}
+			public void widgetSelected(SelectionEvent e) {
+				addSampleJavaRuleFlowCode = ((Button) e.widget).getSelection();
+			}
+		});
+
+	}
+
+	private Button createCheckBox(Composite group, String label) {
+        Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+        button.setText(label);
+        GridData data = new GridData();
+        button.setLayoutData(data);
+        return button;
+    }
+	
+	public boolean createRuleFile() {
+		return addSampleRule;
+	}
+	
+	public boolean createJavaRuleFile() {
+		return addSampleJavaRuleCode;
+	}
+	
+	public boolean createDecisionTableFile() {
+		return addSampleDecisionTableCode;
+	}
+	
+	public boolean createJavaDecisionTableFile() {
+		return addSampleJavaDecisionTableCode;
+	}
+	
+	public boolean createRuleFlowFile() {
+		return addSampleRuleFlow;
+	}
+	
+	public boolean createJavaRuleFlowFile() {
+		return addSampleJavaRuleFlowCode;
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/DRLGenerator.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/DRLGenerator.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/DRLGenerator.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,83 @@
+package org.drools.eclipse.wizard.rule;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.UnsupportedEncodingException;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.regex.Pattern;
+
+/**
+ * This will generate DRL bits and bobs based on various templates.
+ * For use by the wizards only. 
+ * TODO: move this to string template (as it is being used elsewhere in drools)
+ * @author Michael Neale
+ */
+public class DRLGenerator {
+
+    private static final Pattern packageDec = Pattern.compile( "\\$package\\$" );
+    private static final Pattern dateDec = Pattern.compile( "\\$date\\$" );
+    private static final Pattern functionsDec = Pattern.compile( "\\$functions\\$" );
+    private static final Pattern expanderDec = Pattern.compile( "\\$expander\\$" );
+    
+    public InputStream generateRule(String packageName,
+                                    InputStream template) throws IOException {
+        
+        String temp = readTemplate( template );
+        temp = doHeader( packageName,
+                         temp );
+        
+        return toStream( temp );
+        
+
+    }
+    
+    public InputStream generatePackage(String packageName, boolean functions, boolean expander, InputStream template) throws IOException {
+        String temp = readTemplate( template );
+        temp = doHeader(packageName, temp );
+        if (functions) {
+            temp = functionsDec.matcher( temp ).replaceFirst( "function myFunction( ... ) " + System.getProperty("line.separator") + "    #function content (can have multiple functions) " + System.getProperty("line.separator") + "end" + System.getProperty("line.separator"));
+        } else {
+            temp = functionsDec.matcher( temp ).replaceFirst( "");
+        }
+        if (expander) {
+            temp = expanderDec.matcher( temp ).replaceFirst( "expander customLanguage.dsl" + System.getProperty("line.separator") + "");
+        } else {
+            temp = expanderDec.matcher( temp ).replaceFirst( "");
+        }
+        return toStream( temp );
+
+        
+    }    
+
+    private ByteArrayInputStream toStream(String temp) throws UnsupportedEncodingException {
+        ByteArrayInputStream stream = new ByteArrayInputStream(temp.getBytes( "UTF-8" ));
+        return stream;
+    }
+
+    private String doHeader(String packageName,
+                            String temp) {
+        temp = packageDec.matcher( temp ).replaceFirst( "package " + packageName + System.getProperty("line.separator") );
+        temp = dateDec.matcher( temp ).replaceFirst( DateFormat.getDateInstance().format( new Date()) );
+        return temp;
+    }
+
+    private String readTemplate(InputStream template) throws IOException {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(template));
+        String line = null;
+        StringBuffer buf = new StringBuffer();
+        while ((line = reader.readLine())  != null) {
+            buf.append(line + System.getProperty("line.separator"));
+        }
+        String temp = buf.toString();
+        return temp;
+    }
+    
+
+
+    
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackagePage.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackagePage.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackagePage.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,194 @@
+/*
+ * Created on 11-jan-2005
+ *
+ */
+package org.drools.eclipse.wizard.rule;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWindow;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.dialogs.WizardNewFileCreationPage;
+import org.eclipse.ui.ide.IDE;
+
+/**
+ * A page to create a new .drl package/package file.
+ * There is only one page for this wizard, its very simple.
+ * 
+ * Enhancements may be made to allow configuration of semantic languages, DSLs (locate a DSL) and other 
+ * package level options.
+ * 
+ * @author Michael Neale
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class NewRulePackagePage extends WizardNewFileCreationPage {
+
+    private static final int TYPE_RULE = 1;
+    private static final int TYPE_PACKAGE = 0;
+    private IWorkbench workbench;
+    private Combo  ruleFileType;
+    private Button  expander;
+    private Button  function;
+    private Text    packageName;
+    
+    
+    public NewRulePackagePage(IWorkbench workbench, IStructuredSelection selection) {
+        super("createDRLFilePage", selection);
+        setTitle("New Rules File");
+        setDescription("Create a new rules file (drl)");
+        this.workbench = workbench;
+    }
+
+    public void createControl(Composite parent) {
+        super.createControl(parent);
+        setPageComplete(true);
+        super.setMessage( "Hint: Press CTRL+SPACE when editing rules to get content sensitive assistance/popups.");
+    }
+    
+    
+    protected void createAdvancedControls(Composite parent) {
+        Composite container = new Composite(parent, SWT.NONE);
+        final GridLayout layout = new GridLayout();
+        layout.numColumns = 2;
+        container.setLayout( layout );
+        setControl( container );
+
+        //setup the controls.
+        createType( container );
+        createDSL( container );
+        createFunctions( container );
+        createPackageName( container );
+        
+        super.createAdvancedControls( parent );
+    }
+
+    private void createPackageName(Composite container) {
+        //package name
+        Label pack = new Label(container, SWT.NONE);
+        pack.setText( "Rule package name:" );
+        pack.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_END) );
+        pack.setFont( this.getFont() );
+        packageName = new Text(container, SWT.BORDER);
+        packageName.setLayoutData(  new GridData(GridData.FILL_HORIZONTAL) );
+        packageName.setToolTipText( "Rules require a namespace." );
+        packageName.setFont( this.getFont() );
+    }
+
+    private void createFunctions(Composite container) {
+        //function
+        Label func = new Label(container, SWT.NONE);
+        func.setText( "Use functions:" );
+        func.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_END) );
+        func.setFont( this.getFont() );
+        function = new Button(container, SWT.CHECK);
+        function.setSelection( false );
+        function.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING) );
+        function.setToolTipText( "Functions are methods you embed in your rule source." );
+    }
+
+    private void createDSL(Composite container) {
+        //expander
+        Label exp = new Label(container, SWT.NONE);
+        exp.setText( "Use a DSL:" );
+        exp.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_END) );
+        exp.setFont( this.getFont() );
+        expander = new Button(container, SWT.CHECK);
+        expander.setSelection( false );
+        expander.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING) );
+        expander.setToolTipText( "Domain Specific Language: allows you to create your own domain specific languages\n for use in rules." );
+    }
+
+    private void createType(Composite container) {
+        //type
+        Label type = new Label(container, SWT.NONE);
+        type.setText( "Type of rule resource:" );
+        type.setFont( this.getFont() );
+        type.setLayoutData( new GridData(GridData.HORIZONTAL_ALIGN_END) );
+        ruleFileType = new Combo( container,
+                           SWT.READ_ONLY);
+        ruleFileType.add( "New DRL (rule package)", TYPE_PACKAGE );
+        ruleFileType.add( "New Rule (individual rule)", TYPE_RULE );
+        ruleFileType.select( 0 );
+        ruleFileType.setLayoutData( new GridData(GridData.FILL_HORIZONTAL) );
+        ruleFileType.setFont( this.getFont() );
+        
+    }
+    
+    public boolean finish() {
+        if (!validate()) {
+            return false;
+        }
+        String fileName = getFileName();
+        String extension = expander.getSelection() ? ".dslr" : ".drl";
+        if (!fileName.endsWith(extension)) {
+            setFileName(fileName + extension);
+        }
+        org.eclipse.core.resources.IFile newFile = createNewFile();
+        if (newFile == null)
+            return false;
+        try {
+            IWorkbenchWindow dwindow = workbench.getActiveWorkbenchWindow();
+            org.eclipse.ui.IWorkbenchPage page = dwindow.getActivePage();
+            if (page != null)
+                IDE.openEditor(page, newFile, true);
+        } catch (PartInitException e) {
+            DroolsEclipsePlugin.log(e);
+            return false;
+        }
+        return true;
+    }
+
+    private boolean validate() {
+        if (this.packageName.getText() == null || packageName.getText().equals( "" )) {
+            setErrorMessage( "You must provide a rule package name" );
+            return false;
+        } else {
+            return true;
+        }
+    }
+    
+    protected InputStream getInitialContents() {
+        
+        try {
+        	
+            DRLGenerator gen = new DRLGenerator();
+            if (this.ruleFileType.getSelectionIndex() == TYPE_RULE) {
+                InputStream template = getTemplate("org/drools/eclipse/wizard/rule/new_rule.drl.template");                
+                return gen.generateRule( this.packageName.getText(), 
+                                         template );
+            } else {
+                InputStream template = getTemplate("org/drools/eclipse/wizard/rule/new_package.drl.template");                
+                return gen.generatePackage( this.packageName.getText(), 
+                                            function.getSelection(), 
+                                            expander.getSelection(), 
+                                            template );
+            }
+        } catch (IOException e) {
+            return null;
+        } catch (NullPointerException e) {
+            return null;
+        }
+    }
+
+    private InputStream getTemplate(String templatePath) throws IOException {
+        return DroolsEclipsePlugin.getDefault().getBundle().getResource(templatePath).openStream();
+    }
+    
+
+    
+    
+    
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackageWizard.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackageWizard.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/eclipse/wizard/rule/NewRulePackageWizard.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,41 @@
+package org.drools.eclipse.wizard.rule;
+
+import org.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.INewWizard;
+import org.eclipse.ui.IWorkbench;
+
+/**
+ * This is a wizard to create a new .drl file (for example a rule or a whole rule package).
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ * @author Michael Neale
+ */
+public class NewRulePackageWizard extends Wizard implements INewWizard {
+
+    private IWorkbench workbench;
+    private IStructuredSelection selection;
+    private NewRulePackagePage mainPage;
+    
+    public void init(IWorkbench workbench, IStructuredSelection selection) {
+        this.workbench = workbench;
+        this.selection = selection;
+        setWindowTitle("New Rule Package...");
+        
+    	ImageDescriptor desc = DroolsEclipsePlugin.getImageDescriptor("icons/drools-large.PNG");
+        setDefaultPageImageDescriptor(desc);
+    }
+    
+    public void addPages() {
+        mainPage = new NewRulePackagePage(workbench, selection);
+        addPage(mainPage);
+     }
+
+    public boolean performFinish() {
+        return mainPage.finish();
+    }
+    
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AccumulateNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AccumulateNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AccumulateNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link AccumulateNode} and adds visual extras like color information
+ *
+ */
+public class AccumulateNodeVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "AccumulateNode";
+    
+    private final AccumulateNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public AccumulateNodeVertex(final AccumulateNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId() + " : Chared count=" + this.node.getSharedCount();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.lightGreen;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AlphaNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AlphaNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/AlphaNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,119 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.drools.base.ClassFieldExtractor;
+import org.drools.rule.LiteralConstraint;
+import org.drools.spi.AlphaNodeFieldConstraint;
+import org.drools.spi.Constraint;
+import org.drools.spi.FieldExtractor;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link AlphaNode} and adds visual extras like color information
+ *
+ */
+public class AlphaNodeVertex extends BaseVertex {
+
+    private final AlphaNode node;
+
+    private final String    NODE_NAME = "AlphaNode";
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public AlphaNodeVertex(final AlphaNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+    	AlphaNodeFieldConstraint constraint = this.node.getConstraint();
+        if (constraint instanceof LiteralConstraint) {
+        	LiteralConstraint literalConstraint = (LiteralConstraint) constraint;
+            FieldExtractor extractor = literalConstraint.getFieldExtractor();
+            if (extractor instanceof ClassFieldExtractor) {
+            	ClassFieldExtractor classFieldExtractor = (ClassFieldExtractor) extractor;
+            	return NODE_NAME + "<BR/>field : " + classFieldExtractor.getFieldName() + "<BR/>evaluator : " + literalConstraint.getEvaluator() + "<BR/>value :  " + literalConstraint.getField();
+            }
+        }
+        return NODE_NAME + "<BR/>";
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return this.node.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.blue;
+    }
+
+    /**
+     * Constraint has field extractor and this method is returning fieldName
+     * it.
+     * 
+     * @return field name
+     */
+    public String getFieldName() {
+    	AlphaNodeFieldConstraint constraint = this.node.getConstraint();
+        if (constraint instanceof LiteralConstraint) {
+        	LiteralConstraint literalConstraint = (LiteralConstraint) constraint;
+            FieldExtractor extractor = literalConstraint.getFieldExtractor();
+            if (extractor instanceof ClassFieldExtractor) {
+            	return ((ClassFieldExtractor) extractor).getFieldName();
+            }
+        }
+        return null;
+    }
+
+    /**
+     * Constraint's evaluator string
+     * 
+     * @return evaluator string
+     */
+    public String getEvaluator() {
+    	AlphaNodeFieldConstraint constraint = this.node.getConstraint();
+        if (constraint instanceof LiteralConstraint) {
+        	LiteralConstraint literalConstraint = (LiteralConstraint) constraint;
+        	return literalConstraint.getEvaluator().toString();
+        }
+        return null;
+    }
+
+    /**
+     * Constraint field string
+     * 
+     * @return field string
+     */
+    public String getValue() {
+    	AlphaNodeFieldConstraint constraint = this.node.getConstraint();
+        if (constraint instanceof LiteralConstraint) {
+        	LiteralConstraint literalConstraint = (LiteralConstraint) constraint;
+        	return literalConstraint.getField().toString();
+        }
+        return null;
+    }
+
+    /**
+     * Constraint
+     * 
+     * @return constraint
+     */
+    public Constraint getConstraint() {
+        return this.node.getConstraint();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/BaseVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/BaseVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/BaseVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,33 @@
+/*
+ * Copyright 2006 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.drools.reteoo;
+
+import org.drools.eclipse.editors.rete.model.GraphicalVertex;
+
+/**
+ * Intermediate class to have a workaround for *Node default visibility  
+ * and ReteooVisitor.
+ * 
+ * It's not good to have {@link GraphicalVertex} dependency in
+ * org.drools.reteoo package. 
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+abstract public class BaseVertex extends GraphicalVertex {
+
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/CollectNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/CollectNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/CollectNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link CollectNode} and adds visual extras like color information
+ *
+ */
+public class CollectNodeVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "CollectNode";
+    
+    private final CollectNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public CollectNodeVertex(final CollectNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId() + " : Chared count = " + this.node.getSharedCount();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.lightGray;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/EvalConditionNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/EvalConditionNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/EvalConditionNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,57 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link EvalConditionNode} and adds visual extras like color information
+ *
+ */
+public class EvalConditionNodeVertex extends BaseVertex {
+    
+    private static final String     NODE_NAME = "EvalConditionNode";
+    private final EvalConditionNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public EvalConditionNodeVertex(final EvalConditionNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME + " : " + this.node.getId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return node id
+     */
+    public int getId() {
+        return node.getId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.white;
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ExistsNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ExistsNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ExistsNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link ExistsNode} and adds visual extras like color information
+ *
+ */
+public class ExistsNodeVertex extends BaseVertex {
+
+    private static final String NODE_NAME = "ExistsNode";
+
+    private final ExistsNode    node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public ExistsNodeVertex(final ExistsNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME + " : " + this.node.getId() + " : Chared count=" + this.node.getSharedCount();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.cyan;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/FromNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/FromNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/FromNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link FromNode} and adds visual extras like color information
+ *
+ */
+public class FromNodeVertex extends BaseVertex {
+
+    private static final String NODE_NAME = "FromNode";
+
+    private final FromNode      node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public FromNodeVertex(final FromNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME + " : " + this.node.getId() + " : Chared count=" + this.node.getSharedCount();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.lightBlue;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/JoinNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/JoinNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/JoinNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,69 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.drools.spi.Constraint;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link JoinNode} and adds visual extras like color information
+ *
+ */
+public class JoinNodeVertex extends BaseVertex {
+
+    private static final String NODE_NAME = "JoinNode";
+
+    private final JoinNode      node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public JoinNodeVertex(final JoinNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME + "<BR/>" + dumpConstraints( this.node.getConstraints() );
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.green;
+    }
+
+    /**
+     * Node constraints
+     * 
+     * @return array of constraints
+     */
+    public Constraint[] getConstraints() {
+        return node.getConstraints();
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return node id
+     */
+    public int getId() {
+        return node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/LeftInputAdapterNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/LeftInputAdapterNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/LeftInputAdapterNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,50 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link LeftInputAdapterNode} and adds visual extras like color information
+ *
+ */
+public class LeftInputAdapterNodeVertex extends BaseVertex {
+
+    private static final String        NODE_NAME = "LeftInputAdapterNode";
+
+    private final LeftInputAdapterNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public LeftInputAdapterNodeVertex(final LeftInputAdapterNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return this.node.toString();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.yellow;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/NotNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/NotNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/NotNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link NotNode} and adds visual extras like color information
+ *
+ */
+public class NotNodeVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "NotNode";
+    
+    private final NotNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public NotNodeVertex(final NotNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.cyan;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return node id
+     */
+    public int getId() {
+        return node.getId();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ObjectTypeNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ObjectTypeNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ObjectTypeNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.drools.spi.ObjectType;
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link ObjectTypeNode} and adds visual extras like color information
+ *
+ */
+public class ObjectTypeNodeVertex extends BaseVertex {
+
+    private static final String  NODE_NAME = "ObjectTypeNode";
+
+    private final ObjectTypeNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public ObjectTypeNodeVertex(final ObjectTypeNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME + " : " + this.node.getObjectType();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.red;
+    }
+
+    /**
+     * {@link ObjectType} as {@link String}
+     * 
+     * @return object type as string
+     */
+    public String getObjectType() {
+        return node.getObjectType().toString();
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/QueryTerminalNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/QueryTerminalNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/QueryTerminalNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,66 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link QueryTerminalNode} and adds visual extras like color information
+ *
+ */
+public class QueryTerminalNodeVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "QueryTerminalNode";
+    
+    private final QueryTerminalNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public QueryTerminalNodeVertex(final QueryTerminalNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId() + " : " + this.node.getRule();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.darkGray;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+    /**
+     * @return
+     */
+    public String getQueryName() {
+        return node.getRule().getName();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,59 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link Rete} and adds visual extras like color information
+ *
+ */
+public class ReteVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "Rete";
+    
+    private final Rete node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public ReteVertex(final Rete node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return node id
+     */
+    public int getId() {
+        return node.getId();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.white;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteooVisitor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteooVisitor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/ReteooVisitor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,149 @@
+package org.drools.reteoo;
+
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.drools.common.BaseNode;
+import org.drools.eclipse.editors.rete.model.Connection;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.util.Iterator;
+import org.drools.util.ObjectHashMap;
+import org.drools.util.ReflectiveVisitor;
+import org.drools.util.ObjectHashMap.ObjectEntry;
+
+/**
+ * Produces a graph in GraphViz DOT format.
+ *
+ * @see http://www.research.att.com/sw/tools/graphviz/ 
+ * @see http://www.pixelglow.com/graphviz/
+ *
+ * @author Andy Barnett
+ */
+public class ReteooVisitor extends ReflectiveVisitor {
+
+    private static final String PACKAGE_NAME = "org.drools.reteoo.";
+
+    /**
+     * Keeps track of visited JoinNode DOT IDs. This mapping allows the visitor
+     * to recognize JoinNodes it has already visited and as a consequence link
+     * existing nodes back together. This is vital to the Visitor being able to
+     * link two JoinNodeInputs together through their common JoinNode.
+     */
+    private final Map           visitedNodes = new HashMap();
+
+    private ReteGraph           graph;
+
+    private BaseVertex          rootVertex;
+
+    private BaseVertex          parentVertex;
+
+    /**
+     * Constructor.
+     */
+    public ReteooVisitor(final ReteGraph graph) {
+        this.graph = graph;
+    }
+
+    public ReteGraph getGraph() {
+        return this.graph;
+    }
+
+    public BaseVertex getRootVertex() {
+        return this.rootVertex;
+    }
+
+    /**
+     * RuleBaseImpl visits its Rete.
+     */
+    public void visitReteooRuleBase(final ReteooRuleBase ruleBase) {
+        visit( (ruleBase).getRete() );
+    }
+
+    /**
+     * Rete visits each of its ObjectTypeNodes.
+     */
+    public void visitRete(final Rete rete) {
+        this.rootVertex = (ReteVertex) this.visitedNodes.get( dotId( rete ) );
+        if ( this.rootVertex == null ) {
+            this.rootVertex = new ReteVertex( rete );
+            this.visitedNodes.put( dotId( rete ),
+                                   this.rootVertex );
+        }
+
+        this.graph.addChild( this.rootVertex );
+        this.parentVertex = this.rootVertex;
+
+        final ObjectHashMap map = rete.getObjectTypeNodes();
+
+        final Iterator it = map.iterator();
+        for ( ObjectEntry entry = (ObjectEntry) it.next(); entry != null; entry = (ObjectEntry) it.next() ) {
+            visit( entry.getValue() );
+        }
+
+    }
+
+    public void visitBaseNode(final BaseNode node) {
+        BaseVertex vertex = (BaseVertex) this.visitedNodes.get( dotId( node ) );
+        if ( vertex == null ) {
+            try {
+                String name = node.getClass().getName();
+                name = name.substring( name.lastIndexOf( '.' ) + 1 ) + "Vertex";
+                final Class clazz = Class.forName( PACKAGE_NAME + name );
+                vertex = (BaseVertex) clazz.getConstructor( new Class[]{node.getClass()} ).newInstance( new Object[]{node} );
+            } catch ( final Exception e ) {
+                throw new RuntimeException( "problem visiting vertex " + node.getClass().getName(),
+                                            e );
+            }
+            this.graph.addChild( vertex );
+            this.visitedNodes.put( dotId( node ),
+                                   vertex );
+
+            new Connection( this.parentVertex,
+                            vertex );
+
+            final BaseVertex oldParentVertex = this.parentVertex;
+            this.parentVertex = vertex;
+
+            List list = null;
+            if ( node instanceof ObjectSource ) {
+                list = Arrays.asList( ((ObjectSource) node).getSinkPropagator().getSinks() );
+            } else if ( node instanceof TupleSource ) {
+                list = Arrays.asList( ((TupleSource) node).getSinkPropagator().getSinks() );
+            }
+
+            if ( list != null ) {
+                for ( final java.util.Iterator it = list.iterator(); it.hasNext(); ) {
+                    final Object nextNode = it.next();
+                    visitNode( nextNode );
+                }
+            }
+            this.parentVertex = oldParentVertex;
+        } else {
+            new Connection( this.parentVertex,
+                            vertex );
+        }
+    }
+
+    /**
+     * Helper method to ensure nodes are not visited more than once.
+     */
+    private void visitNode(final Object node) {
+        Object realNode = node;
+        if ( node instanceof ObjectHashMap.ObjectEntry ) {
+            ObjectHashMap.ObjectEntry entry = (ObjectHashMap.ObjectEntry) node;
+            realNode = entry.getValue();
+        }
+        visit( realNode );
+    }
+
+    /**
+     * The identity hashCode for the given object is used as its unique DOT
+     * identifier.
+     */
+    private static String dotId(final Object object) {
+        return Integer.toHexString( System.identityHashCode( object ) ).toUpperCase();
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RightInputAdapterNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RightInputAdapterNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RightInputAdapterNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,38 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link RightInputAdapterNode} and adds visual extras like color information
+ *
+ */
+public class RightInputAdapterNodeVertex extends BaseVertex {
+
+    private static final String NODE_NAME = "RightInputAdapterNode";
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public RightInputAdapterNodeVertex(final RightInputAdapterNode node) {
+        super();
+    }
+
+    public String getHtml() {
+        return NODE_NAME;
+    }
+
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    public Color getFillColor() {
+        return ColorConstants.orange;
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RuleTerminalNodeVertex.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RuleTerminalNodeVertex.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/java/org/drools/reteoo/RuleTerminalNodeVertex.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,66 @@
+/**
+ * 
+ */
+package org.drools.reteoo;
+
+import org.eclipse.draw2d.ColorConstants;
+import org.eclipse.swt.graphics.Color;
+
+/**
+ * Wraps {@link TerminalNode} and adds visual extras like color information
+ *
+ */
+public class RuleTerminalNodeVertex extends BaseVertex {
+    
+    private static final String NODE_NAME = "TerminalNode";
+    
+    private final RuleTerminalNode node;
+
+    /**
+     * Constructor
+     * 
+     * @param node node to be wrapped
+     */
+    public RuleTerminalNodeVertex(final RuleTerminalNode node) {
+        super();
+        this.node = node;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getHtml()
+     */
+    public String getHtml() {
+        return NODE_NAME+" : " + this.node.getId() + " : " + this.node.getRule();
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.eclipse.editors.rete.model.BaseVertex#toString()
+     */
+    public String toString() {
+        return NODE_NAME;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.reteoo.BaseNodeVertex#getFillColor()
+     */
+    public Color getFillColor() {
+        return ColorConstants.darkGray;
+    }
+
+    /**
+     * Node ID
+     * 
+     * @return id
+     */
+    public int getId() {
+        return this.node.getId();
+    }
+
+    /**
+     * @return
+     */
+    public String getRuleName() {
+        return node.getRule().getName();
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/java_keywords.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/java_keywords.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/java_keywords.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,43 @@
+# this contains the java keywords for syntax highlighting
+# all java keywords are present, those that are not relevant are commented out
+
+# abstract
+# assert
+break
+case
+catch
+# class
+# const
+continue
+default
+do
+else
+# enum
+# extends
+final
+finally
+for
+goto
+if
+# implements
+# import
+instanceof
+# interface
+# native
+new
+# package
+# private
+# protected
+# public
+return
+# static
+# super
+switch
+# synchronized
+# this
+throw
+# throws
+# transient
+try
+# volatile
+while
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/keywords.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,46 @@
+# This contains the keywords for syntax highlighting.
+when
+then
+rule
+end
+update
+modify
+retract
+insert
+insertLogical
+salience
+import
+expander
+package
+function
+global
+query
+exists
+eval
+agenda-group
+lock-on-active
+no-loop
+duration
+->
+not
+auto-focus
+activation-group
+new
+contains
+matches
+excludes
+template
+from
+accumulate
+collect
+date-effective
+date-expires
+enabled
+forall
+dialect
+ruleflow-group
+modifyRetract
+modifyInsert
+memberOf
+and
+or
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/mvel_keywords.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/mvel_keywords.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/mvel_keywords.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,20 @@
+# this contains the mvel keywords for syntax highlighting
+if
+else
+foreach
+switch
+var
+while
+do
+for
+return
+instanceof
+is
+contains
+soundslike
+strsim
+convertable_to
+new
+in
+with
+

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/scanners/RuleEditorMessages.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/scanners/RuleEditorMessages.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/editors/scanners/RuleEditorMessages.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,20 @@
+###############################################################################
+# Used to configure content assistance
+###############################################################################
+
+## Actions ##
+
+ContentAssistProposal.label=Content Assist at Ctrl+SPACE
+ContentAssistProposal.tooltip=Content Assist
+ContentAssistProposal.image=
+ContentAssistProposal.description=Content Assist
+
+ContentAssistTip.label=Content Tip at Ctrl+SHIFT+SPACE
+ContentAssistTip.tooltip=Content Tip
+ContentAssistTip.image=
+ContentAssistTip.description=Content Tip
+
+DefineFoldingRegion.label=Define Folding Region
+DefineFoldingRegion.tooltip=Define Folding Region
+DefineFoldingRegion.image=
+DefineFoldingRegion.description=Define Folding Region

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/ruleflow/SampleRuleFlow.rf.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/ruleflow/SampleRuleFlow.rf.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/flow/ruleflow/SampleRuleFlow.rf.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,44 @@
+<org.drools.eclipse.flow.ruleflow.core.WorkflowProcessWrapper id="1" serialization="custom">
+  <org.drools.eclipse.flow.common.editor.core.ProcessWrapper>
+    <default>
+      <elements id="2">
+        <entry>
+          <string>1-Wrapper</string>
+          <org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper id="3" serialization="custom">
+            <org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+              <default>
+                <constraint id="4">
+                  <x>100</x>
+                  <y>100</y>
+                  <width>80</width>
+                  <height>40</height>
+                </constraint>
+                <element class="org.drools.ruleflow.core.impl.StartNode" id="5">
+                  <id>1</id>
+                  <name>Start</name>
+                  <incomingConnections id="6"/>
+                  <outgoingConnections id="7"/>
+                </element>
+                <incomingConnections id="8"/>
+                <outgoingConnections id="9"/>
+              </default>
+            </org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+          </org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper>
+        </entry>
+      </elements>
+      <process class="org.drools.ruleflow.core.impl.RuleFlowProcess" id="10">
+        <nodes id="11">
+          <entry>
+            <long>1</long>
+            <org.drools.ruleflow.core.impl.StartNode reference="5"/>
+          </entry>
+        </nodes>
+        <variables id="12"/>
+        <lastNodeId>1</lastNodeId>
+        <id>0</id>
+        <name>flow</name>
+        <type>Workflow</type>
+      </process>
+    </default>
+  </org.drools.eclipse.flow.common.editor.core.ProcessWrapper>
+</org.drools.eclipse.flow.ruleflow.core.WorkflowProcessWrapper>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/decisiontable/template.xls
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/decisiontable/template.xls
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/dsl/template.dsl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/dsl/template.dsl	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/dsl/template.dsl	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,9 @@
+#This is a starter DSL to show off some of the features. Make sure you change it to be what you need !.
+[when]There is an Instance with field of "{value}"=i: Instance(field=="{value}")
+[when]Instance is at least {number} and field is "{value}"=i: Instance(number > {number}, location=="{value}")
+[then]Log : "{message}"=System.out.println("{message}");
+[then]Set field of instance to "{value}"=i.setField("{value}");
+[then]Create instance : "{value}"=insert(new Instance("{value}"));
+[when]There is no current Instance with field : "{value}"=not Instance(field == "{value}")
+[then]Report error : "{error}"=System.err.println("{error}");
+[then]Retract the fact : '{variable}'=retract({variable}); //this would retract bound variable {variable}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/DecisionTableLauncherSample.java.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/DecisionTableLauncherSample.java.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/DecisionTableLauncherSample.java.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,91 @@
+package com.sample;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.io.StringReader;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.decisiontable.InputType;
+import org.drools.decisiontable.SpreadsheetCompiler;
+import org.drools.rule.Package;
+
+public class DecisionTableTest {
+
+    public static final void main(String[] args) {
+        try {
+        	
+        	//load up the rulebase
+            RuleBase ruleBase = readDecisionTable();
+            WorkingMemory workingMemory = ruleBase.newStatefulSession();
+            
+            //go !
+            Message message = new Message();
+            message.setMessage(  "Hello World" );
+            message.setStatus( Message.HELLO );
+            workingMemory.insert( message );
+            workingMemory.fireAllRules();   
+            
+            
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
+
+    /**
+     * Please note that this is the "low level" rule assembly API.
+     */
+	private static RuleBase readDecisionTable() throws Exception {
+		//read in the source
+        final SpreadsheetCompiler converter = new SpreadsheetCompiler();
+        final String drl = converter.compile( "/Sample.xls", InputType.XLS );
+		PackageBuilder builder = new PackageBuilder();
+		builder.addPackageFromDrl( new StringReader( drl ) );
+		Package pkg = builder.getPackage();
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+		ruleBase.addPackage( pkg );
+		return ruleBase;
+	}
+
+	public static class Message {
+		public static final int HELLO = 0;
+		public static final int GOODBYE = 1;
+		
+		private String message;
+		
+		private int status;
+		
+		public String getMessage() {
+			return this.message;
+		}
+		
+		public void setMessage(String message) {
+			this.message = message;
+		}
+		
+		public int getStatus() {
+			return this.status;
+		}
+		
+		public void setStatus( int status ) {
+			this.status = status;
+		}
+	}
+    
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleFlowLauncherSample.java.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,99 @@
+package com.sample;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.rule.Package;
+
+/**
+ * This is a sample file to launch a ruleflow.
+ */
+public class RuleFlowTest {
+
+    public static final void main(String[] args) {
+        try {
+        	
+        	//load up the rulebase
+            RuleBase ruleBase = readRule();
+            WorkingMemory workingMemory = ruleBase.newStatefulSession();
+            
+            //go !
+            Message message = new Message();
+            message.setMessage(  "Hello World" );
+            message.setStatus( Message.HELLO );
+            workingMemory.insert( message );
+            
+            workingMemory.startProcess("com.sample.ruleflow");
+            workingMemory.fireAllRules();   
+            
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
+
+    /**
+     * Please note that this is the "low level" rule assembly API.
+     */
+	private static RuleBase readRule() throws Exception {
+		//read in the source
+		Reader source = new InputStreamReader( RuleFlowTest.class.getResourceAsStream( "/ruleflow.drl" ) );
+		
+		//optionally read in the DSL (if you are using it).
+		//Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
+
+		//Use package builder to build up a rule package.
+		//An alternative lower level class called "DrlParser" can also be used...
+		
+		PackageBuilder builder = new PackageBuilder();
+
+		//this wil parse and compile in one step
+		//NOTE: There are 2 methods here, the one argument one is for normal DRL.
+		builder.addPackageFromDrl( source );
+
+		//Use the following instead of above if you are using a DSL:
+		//builder.addPackageFromDrl( source, dsl );
+		
+		//add ruleflow
+		source = new InputStreamReader( RuleFlowTest.class.getResourceAsStream( "/ruleflow.rfm" ) );
+		builder.addRuleFlow(source);
+		
+		//get the compiled package (which is serializable)
+		Package pkg = builder.getPackage();
+		
+		//add the package to a rulebase (deploy the rule package).
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+		ruleBase.addPackage( pkg );
+		
+		return ruleBase;
+	}
+	
+	public static class Message {
+		public static final int HELLO = 0;
+		public static final int GOODBYE = 1;
+		
+		private String message;
+		
+		private int status;
+		
+		public String getMessage() {
+			return this.message;
+		}
+		
+		public void setMessage(String message) {
+			this.message = message;
+		}
+		
+		public int getStatus() {
+			return this.status;
+		}
+		
+		public void setStatus( int status ) {
+			this.status = status;
+		}
+	}
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/RuleLauncherSample.java.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,93 @@
+package com.sample;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.WorkingMemory;
+import org.drools.compiler.PackageBuilder;
+import org.drools.rule.Package;
+
+/**
+ * This is a sample file to launch a rule package from a rule source file.
+ */
+public class DroolsTest {
+
+    public static final void main(String[] args) {
+        try {
+        	
+        	//load up the rulebase
+            RuleBase ruleBase = readRule();
+            WorkingMemory workingMemory = ruleBase.newStatefulSession();
+            
+            //go !
+            Message message = new Message();
+            message.setMessage(  "Hello World" );
+            message.setStatus( Message.HELLO );
+            workingMemory.insert( message );
+            workingMemory.fireAllRules();   
+            
+            
+        } catch (Throwable t) {
+            t.printStackTrace();
+        }
+    }
+
+    /**
+     * Please note that this is the "low level" rule assembly API.
+     */
+	private static RuleBase readRule() throws Exception {
+		//read in the source
+		Reader source = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/Sample.drl" ) );
+		
+		//optionally read in the DSL (if you are using it).
+		//Reader dsl = new InputStreamReader( DroolsTest.class.getResourceAsStream( "/mylang.dsl" ) );
+
+		//Use package builder to build up a rule package.
+		//An alternative lower level class called "DrlParser" can also be used...
+		
+		PackageBuilder builder = new PackageBuilder();
+
+		//this wil parse and compile in one step
+		//NOTE: There are 2 methods here, the one argument one is for normal DRL.
+		builder.addPackageFromDrl( source );
+
+		//Use the following instead of above if you are using a DSL:
+		//builder.addPackageFromDrl( source, dsl );
+		
+		//get the compiled package (which is serializable)
+		Package pkg = builder.getPackage();
+		
+		//add the package to a rulebase (deploy the rule package).
+		RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+		ruleBase.addPackage( pkg );
+		return ruleBase;
+	}
+	
+	public static class Message {
+		public static final int HELLO = 0;
+		public static final int GOODBYE = 1;
+		
+		private String message;
+		
+		private int status;
+		
+		public String getMessage() {
+			return this.message;
+		}
+		
+		public void setMessage(String message) {
+			this.message = message;
+		}
+		
+		public int getStatus() {
+			return this.status;
+		}
+		
+		public void setStatus( int status ) {
+			this.status = status;
+		}
+	}
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.drl.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.drl.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.drl.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,23 @@
+package com.sample
+ 
+import com.sample.DroolsTest.Message;
+ 
+rule "Hello World"
+	when
+		m : Message( status == Message.HELLO, message : message )
+	then
+		System.out.println( message ); 
+		m.setMessage( "Goodbye cruel world" );
+		m.setStatus( Message.GOODBYE );
+		update( m );
+end
+
+rule "GoodBye"
+	no-loop true
+	when
+		m : Message( status == Message.GOODBYE, message : message )
+	then
+		System.out.println( message ); 
+		m.setMessage( message );
+		
+end
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.xls.template
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/Sample.xls.template
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.drl.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,23 @@
+package com.sample
+ 
+import com.sample.RuleFlowTest.Message;
+ 
+rule "Hello World" ruleflow-group "hello"
+	when
+		m : Message( status == Message.HELLO, message : message )
+	then
+		System.out.println( message ); 
+		m.setMessage( "Goodbye cruel world" );
+		m.setStatus( Message.GOODBYE );
+		update( m );
+end
+
+rule "GoodBye" ruleflow-group "goodbye"
+	no-loop true
+	when
+		m : Message( status == Message.GOODBYE, message : message )
+	then
+		System.out.println( message ); 
+		m.setMessage( message );
+		
+end
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rf.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,211 @@
+<org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper id="1" serialization="custom">
+  <org.drools.eclipse.flow.common.editor.core.ProcessWrapper>
+    <default>
+      <elements id="2">
+        <entry>
+          <string>2-Wrapper</string>
+          <org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper id="3" serialization="custom">
+            <org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+              <default>
+                <constraint id="4">
+                  <x>190</x>
+                  <y>101</y>
+                  <width>80</width>
+                  <height>40</height>
+                </constraint>
+                <element class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" id="5">
+                  <ruleFlowGroup>hello</ruleFlowGroup>
+                  <id>2</id>
+                  <name>hello</name>
+                  <incomingConnections id="6">
+                    <org.drools.ruleflow.core.impl.ConnectionImpl id="7">
+                      <type>1</type>
+                      <from class="org.drools.ruleflow.core.impl.StartNodeImpl" id="8">
+                        <id>1</id>
+                        <name>Start</name>
+                        <incomingConnections id="9"/>
+                        <outgoingConnections id="10">
+                          <org.drools.ruleflow.core.impl.ConnectionImpl reference="7"/>
+                        </outgoingConnections>
+                      </from>
+                      <to class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="5"/>
+                    </org.drools.ruleflow.core.impl.ConnectionImpl>
+                  </incomingConnections>
+                  <outgoingConnections id="11">
+                    <org.drools.ruleflow.core.impl.ConnectionImpl id="12">
+                      <type>1</type>
+                      <from class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="5"/>
+                      <to class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" id="13">
+                        <ruleFlowGroup>goodbye</ruleFlowGroup>
+                        <id>3</id>
+                        <name>goodbye</name>
+                        <incomingConnections id="14">
+                          <org.drools.ruleflow.core.impl.ConnectionImpl reference="12"/>
+                        </incomingConnections>
+                        <outgoingConnections id="15">
+                          <org.drools.ruleflow.core.impl.ConnectionImpl id="16">
+                            <type>1</type>
+                            <from class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="13"/>
+                            <to class="org.drools.ruleflow.core.impl.EndNodeImpl" id="17">
+                              <id>4</id>
+                              <name>End</name>
+                              <incomingConnections id="18">
+                                <org.drools.ruleflow.core.impl.ConnectionImpl reference="16"/>
+                              </incomingConnections>
+                              <outgoingConnections id="19"/>
+                            </to>
+                          </org.drools.ruleflow.core.impl.ConnectionImpl>
+                        </outgoingConnections>
+                      </to>
+                    </org.drools.ruleflow.core.impl.ConnectionImpl>
+                  </outgoingConnections>
+                </element>
+                <incomingConnections id="20">
+                  <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper id="21" serialization="custom">
+                    <org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                      <default>
+                        <type>1</type>
+                        <bendpoints id="22"/>
+                        <source class="org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper" id="23" serialization="custom">
+                          <org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                            <default>
+                              <constraint id="24">
+                                <x>57</x>
+                                <y>100</y>
+                                <width>80</width>
+                                <height>40</height>
+                              </constraint>
+                              <element class="org.drools.ruleflow.core.impl.StartNodeImpl" reference="8"/>
+                              <incomingConnections id="25"/>
+                              <outgoingConnections id="26">
+                                <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper reference="21"/>
+                              </outgoingConnections>
+                            </default>
+                          </org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                        </source>
+                        <target class="org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper" reference="3"/>
+                      </default>
+                    </org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                    <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                      <default>
+                        <connection class="org.drools.ruleflow.core.impl.ConnectionImpl" reference="7"/>
+                      </default>
+                    </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                  </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                </incomingConnections>
+                <outgoingConnections id="27">
+                  <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper id="28" serialization="custom">
+                    <org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                      <default>
+                        <type>1</type>
+                        <bendpoints id="29"/>
+                        <source class="org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper" reference="3"/>
+                        <target class="org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper" id="30" serialization="custom">
+                          <org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                            <default>
+                              <constraint id="31">
+                                <x>336</x>
+                                <y>101</y>
+                                <width>80</width>
+                                <height>40</height>
+                              </constraint>
+                              <element class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="13"/>
+                              <incomingConnections id="32">
+                                <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper reference="28"/>
+                              </incomingConnections>
+                              <outgoingConnections id="33">
+                                <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper id="34" serialization="custom">
+                                  <org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                                    <default>
+                                      <type>1</type>
+                                      <bendpoints id="35"/>
+                                      <source class="org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper" reference="30"/>
+                                      <target class="org.drools.eclipse.flow.ruleflow.core.EndNodeWrapper" id="36" serialization="custom">
+                                        <org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                                          <default>
+                                            <constraint id="37">
+                                              <x>473</x>
+                                              <y>102</y>
+                                              <width>80</width>
+                                              <height>40</height>
+                                            </constraint>
+                                            <element class="org.drools.ruleflow.core.impl.EndNodeImpl" reference="17"/>
+                                            <incomingConnections id="38">
+                                              <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper reference="34"/>
+                                            </incomingConnections>
+                                            <outgoingConnections id="39"/>
+                                            <parent class="org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper" reference="1"/>
+                                          </default>
+                                        </org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                                      </target>
+                                    </default>
+                                  </org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                                  <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                                    <default>
+                                      <connection class="org.drools.ruleflow.core.impl.ConnectionImpl" reference="16"/>
+                                    </default>
+                                  </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                                </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                              </outgoingConnections>
+                              <parent class="org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper" reference="1"/>
+                            </default>
+                          </org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+                        </target>
+                      </default>
+                    </org.drools.eclipse.flow.common.editor.core.ElementConnection>
+                    <org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                      <default>
+                        <connection class="org.drools.ruleflow.core.impl.ConnectionImpl" reference="12"/>
+                      </default>
+                    </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                  </org.drools.eclipse.flow.ruleflow.core.ConnectionWrapper>
+                </outgoingConnections>
+                <parent class="org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper" reference="1"/>
+              </default>
+            </org.drools.eclipse.flow.common.editor.core.DefaultElementWrapper>
+          </org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper>
+        </entry>
+        <entry>
+          <string>4-Wrapper</string>
+          <org.drools.eclipse.flow.ruleflow.core.EndNodeWrapper reference="36"/>
+        </entry>
+        <entry>
+          <string>3-Wrapper</string>
+          <org.drools.eclipse.flow.ruleflow.core.RuleSetNodeWrapper reference="30"/>
+        </entry>
+        <entry>
+          <string>1-Wrapper</string>
+          <org.drools.eclipse.flow.ruleflow.core.StartNodeWrapper reference="23"/>
+        </entry>
+      </elements>
+      <process class="org.drools.ruleflow.core.impl.RuleFlowProcessImpl" id="40">
+        <nodes id="41">
+          <entry>
+            <long>2</long>
+            <org.drools.ruleflow.core.impl.RuleSetNodeImpl reference="5"/>
+          </entry>
+          <entry>
+            <long>4</long>
+            <org.drools.ruleflow.core.impl.EndNodeImpl reference="17"/>
+          </entry>
+          <entry>
+            <long>1</long>
+            <org.drools.ruleflow.core.impl.StartNodeImpl reference="8"/>
+          </entry>
+          <entry>
+            <long>3</long>
+            <org.drools.ruleflow.core.impl.RuleSetNodeImpl reference="13"/>
+          </entry>
+        </nodes>
+        <variables id="42"/>
+        <lastNodeId>4</lastNodeId>
+        <id>com.sample.ruleflow</id>
+        <name>Ruleflow</name>
+        <version>1.0</version>
+        <type>RuleFlow</type>
+        <packageName>com.sample</packageName>
+      </process>
+      <routerLayout>2</routerLayout>
+    </default>
+  </org.drools.eclipse.flow.common.editor.core.ProcessWrapper>
+</org.drools.eclipse.flow.ruleflow.core.RuleFlowProcessWrapper>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/project/ruleflow.rfm.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,73 @@
+<org.drools.ruleflow.core.impl.RuleFlowProcessImpl id="1">
+  <nodes id="2">
+    <entry>
+      <long>2</long>
+      <org.drools.ruleflow.core.impl.RuleSetNodeImpl id="3">
+        <ruleFlowGroup>hello</ruleFlowGroup>
+        <id>2</id>
+        <name>hello</name>
+        <incomingConnections id="4">
+          <org.drools.ruleflow.core.impl.ConnectionImpl id="5">
+            <type>1</type>
+            <from class="org.drools.ruleflow.core.impl.StartNodeImpl" id="6">
+              <id>1</id>
+              <name>Start</name>
+              <incomingConnections id="7"/>
+              <outgoingConnections id="8">
+                <org.drools.ruleflow.core.impl.ConnectionImpl reference="5"/>
+              </outgoingConnections>
+            </from>
+            <to class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="3"/>
+          </org.drools.ruleflow.core.impl.ConnectionImpl>
+        </incomingConnections>
+        <outgoingConnections id="9">
+          <org.drools.ruleflow.core.impl.ConnectionImpl id="10">
+            <type>1</type>
+            <from class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="3"/>
+            <to class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" id="11">
+              <ruleFlowGroup>goodbye</ruleFlowGroup>
+              <id>3</id>
+              <name>goodbye</name>
+              <incomingConnections id="12">
+                <org.drools.ruleflow.core.impl.ConnectionImpl reference="10"/>
+              </incomingConnections>
+              <outgoingConnections id="13">
+                <org.drools.ruleflow.core.impl.ConnectionImpl id="14">
+                  <type>1</type>
+                  <from class="org.drools.ruleflow.core.impl.RuleSetNodeImpl" reference="11"/>
+                  <to class="org.drools.ruleflow.core.impl.EndNodeImpl" id="15">
+                    <id>4</id>
+                    <name>End</name>
+                    <incomingConnections id="16">
+                      <org.drools.ruleflow.core.impl.ConnectionImpl reference="14"/>
+                    </incomingConnections>
+                    <outgoingConnections id="17"/>
+                  </to>
+                </org.drools.ruleflow.core.impl.ConnectionImpl>
+              </outgoingConnections>
+            </to>
+          </org.drools.ruleflow.core.impl.ConnectionImpl>
+        </outgoingConnections>
+      </org.drools.ruleflow.core.impl.RuleSetNodeImpl>
+    </entry>
+    <entry>
+      <long>4</long>
+      <org.drools.ruleflow.core.impl.EndNodeImpl reference="15"/>
+    </entry>
+    <entry>
+      <long>1</long>
+      <org.drools.ruleflow.core.impl.StartNodeImpl reference="6"/>
+    </entry>
+    <entry>
+      <long>3</long>
+      <org.drools.ruleflow.core.impl.RuleSetNodeImpl reference="11"/>
+    </entry>
+  </nodes>
+  <variables id="18"/>
+  <lastNodeId>4</lastNodeId>
+  <id>com.sample.ruleflow</id>
+  <name>Ruleflow</name>
+  <version>1.0</version>
+  <type>RuleFlow</type>
+  <packageName>com.sample</packageName>
+</org.drools.ruleflow.core.impl.RuleFlowProcessImpl>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_package.drl.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_package.drl.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_package.drl.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,28 @@
+#created on: $date$
+$package$
+#list any import classes here.
+
+$expander$
+
+#declare any global variables here
+
+$functions$
+
+
+rule "Your First Rule"
+	
+	when
+		#conditions
+	then 
+		#actions
+		
+end
+
+rule "Your Second Rule"
+	#include attributes such as "salience" here...
+	when
+		#conditions
+	then 
+		#actions
+		
+end
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_rule.drl.template
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_rule.drl.template	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-plugin/src/main/resources/org/drools/eclipse/wizard/rule/new_rule.drl.template	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+#created on: $date$
+$package$
+rule "A stand alone rule"
+	
+	when
+		#conditions
+	then 
+		#actions
+		
+end
+

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.classpath	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,8 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/test/java"/>
+	<classpathentry kind="src" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4"/>
+	<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+	<classpathentry kind="output" path="bin"/>
+</classpath>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.project	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>drools-eclipse-test</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.ManifestBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.eclipse.pde.SchemaBuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.pde.PluginNature</nature>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+	</natures>
+</projectDescription>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.settings/org.eclipse.jdt.core.prefs
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.settings/org.eclipse.jdt.core.prefs	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/.settings/org.eclipse.jdt.core.prefs	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,58 @@
+#Tue Apr 03 23:12:19 PDT 2007
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=disabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.2
+org.eclipse.jdt.core.compiler.compliance=1.4
+org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
+org.eclipse.jdt.core.compiler.problem.deprecation=warning
+org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=enabled
+org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=enabled
+org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
+org.eclipse.jdt.core.compiler.problem.emptyStatement=ignore
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=warning
+org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
+org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
+org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
+org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
+org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
+org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
+org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
+org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
+org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=ignore
+org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
+org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
+org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=ignore
+org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
+org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
+org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
+org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
+org.eclipse.jdt.core.compiler.problem.nullReference=ignore
+org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
+org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
+org.eclipse.jdt.core.compiler.problem.rawTypeReference=ignore
+org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
+org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
+org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
+org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
+org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
+org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
+org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
+org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
+org.eclipse.jdt.core.compiler.problem.unnecessaryElse=ignore
+org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=ignore
+org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=ignore
+org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
+org.eclipse.jdt.core.compiler.problem.unusedImport=warning
+org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
+org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
+org.eclipse.jdt.core.compiler.problem.unusedParameter=ignore
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
+org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
+org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
+org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
+org.eclipse.jdt.core.compiler.source=1.3

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/META-INF/MANIFEST.MF
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/META-INF/MANIFEST.MF	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/META-INF/MANIFEST.MF	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: JBoss Rules Eclipse Test fragment
+Bundle-SymbolicName: org.drools.eclipse.test
+Bundle-Version: 4.0.3.SNAPSHOT
+Bundle-Vendor: krisv,mic
+Fragment-Host: org.drools.eclipse;bundle-version="4.0.3.SNAPSHOT"
+Bundle-Localization: plugin
+Require-Bundle: org.junit
+Bundle-ClassPath: .
+Bundle-RequiredExecutionEnvironment: J2SE-1.4

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/build.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,14 @@
+bin.includes = META-INF/,\
+               .,\
+               test.xml
+jars.compile.order = .
+source.. = src/test/java/,\
+           src/test/resources/
+output.. = bin/
+src.includes = .classpath,\
+               .project,\
+               .settings/,\
+               META-INF/,\
+               build.properties,\
+               src/,\
+               test.xml

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTests.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,9 @@
+package org.drools.eclipse;
+import junit.framework.Test;
+
+
+public class AllTests {
+	public static Test suite() {
+		return AllTestsUtil.suite();
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/AllTestsUtil.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,166 @@
+package org.drools.eclipse;
+
+//Copyright (c) 2006 Alex Blewitt
+//All rights reserved. This program and the accompanying materials
+//are made available under the terms of the Eclipse Public License v1.0
+//which accompanies this distribution, and is available at
+//http://www.eclipse.org/legal/epl-v10.html
+//
+//Contributors:
+//Alex Blewitt - Initial API and implementation
+//
+import java.lang.reflect.Modifier;
+import java.net.URL;
+import java.util.Enumeration;
+import java.util.Vector;
+import junit.framework.Test;
+import junit.framework.TestSuite;
+import junit.runner.ClassPathTestCollector;
+import junit.runner.TestCollector;
+import org.eclipse.core.runtime.Platform;
+/**
+* Run all the tests in this project, either computed from the classpath or from
+* the bundlepath. To use this as-is, drop it into a non-default package that
+* has the same name as the plugin. For example, if the plugin is called
+* <code>org.example.foo</code>, this should be placed in a package
+* <code>org.example.foo</code>, and all tests should live under the
+* <code>org.example.foo</code> package structure (either directly, or in any
+* subpackage). By default this will include all non-abstract classes named
+* <code>XxxTest</code>, excluding <code>XxxPlatformTest</code> if running
+* outside of the platform.
+*/
+
+public class AllTestsUtil {
+	/**
+	 * Detects classes from the bundle PLUGIN_NAME's entries. Uses
+	 * <code>bundle.findEntries</code> to obtain a list of classes that live
+	 * in the specified PACKAGE_NAME, and adds those to the test path, providing
+	 * that they are {@link AllTests#isValidTest(String, boolean) valid}.
+	 */
+	private static class BundleTestDetector implements TestCollector {
+		/*
+		 * @see junit.runner.TestCollector#collectTests()
+		 */
+		public Enumeration collectTests() {
+			final Vector tests = new Vector();
+			try {
+				Enumeration entries = Platform.getBundle(PLUGIN_NAME).findEntries("/", "*" + SUFFIX + ".class", true);
+				while (entries.hasMoreElements()) {
+					URL entry = (URL) entries.nextElement();
+					// Change the URLs to have Java class names
+					String path = entry.getPath().replace('/', '.');
+					int start = path.indexOf(PACKAGE_NAME);
+					String name = path.substring(start, path.length()
+							- ".class".length());
+					if (isValidTest(name, true)) {
+						tests.add(name);
+					}
+				}
+			} catch (Exception e) {
+				// If we get here, the Platform isn't installed and so we fail
+				// quietly. This isn't a problem; we might be outside of the
+				// Platform framework and just running tests locally. It's not
+				// even worth printing anything out to the error log as it would
+				// just confuse people investigating stack traces etc.
+			}
+			return tests.elements();
+		}
+	}
+	/**
+	 * Searches the current classpath for tests, which are those ending with
+	 * SUFFIX, excluding those which end in IN_CONTAINER_SUFFIX, providing that
+	 * they are {@link AllTests#isValidTest(String, boolean) valid}.
+	 */
+	private static class ClassFileDetector extends ClassPathTestCollector {
+		/*
+		 * @see junit.runner.ClassPathTestCollector#isTestClass(java.lang.String)
+		 */
+		protected boolean isTestClass(String classFileName) {
+			return classFileName.endsWith(SUFFIX + ".class")
+					&& isValidTest(classNameFromFile(classFileName), false);
+		}
+	}
+	/**
+	 * All tests should end in XxxTest
+	 */
+	public static final String SUFFIX = "Test";
+	/**
+	 * All in-container tests should end in XxxPlatformTest
+	 */
+	public static final String IN_CONTAINER_SUFFIX = "Platform" + SUFFIX;
+	/**
+	 * The base package name of the tests to run. This defaults to the name of
+	 * the package that the AllTests class is in for ease of management but may
+	 * be trivially changed if required. Note that at least some identifiable
+	 * part must be provided here (so default package names are not allowed)
+	 * since the URL that comes up in the bundle entries have a prefix that is
+	 * not detectable automatically. Even if this is "org" or "com" that should
+	 * be enough.
+	 */
+	public static final String PACKAGE_NAME = AllTests.class.getPackage()
+			.getName();
+	/**
+	 * The name of the plugin to search if the platform is loaded. This defaults
+	 * to the name of the package that the AllTests class is in for ease of
+	 * management but may be trivially changed if required.
+	 */
+	
+	//PO: this is wrong. we need to use the PLUGIN_ID of the host, not that of the 
+	// fragment
+//	public static final String PLUGIN_NAME = AllTests.class.getPackage()
+//	.getName();
+	public static final String PLUGIN_NAME = "org.drools.eclipse";
+	
+	/**
+	 * Add the tests reported by collector to the list of tests to run
+	 * @param collector the test collector to run
+	 * @param suite the suite to add the tests to
+	 */
+	private static void addTestsToSuite(TestCollector collector, TestSuite suite) {
+		Enumeration e = collector.collectTests();
+		while (e.hasMoreElements()) {
+			String name = (String) e.nextElement();
+			try {
+				suite.addTestSuite(Class.forName(name));
+			} catch (ClassNotFoundException e1) {
+				System.err.println("Cannot load test: " + e1);
+			}
+		}
+	}
+	/**
+	 * Is the test a valid test?
+	 * @param name the name of the test
+	 * @param inContainer true if we want to include the inContainer tests
+	 * @return true if the name is a valid class (can be loaded), that it is not
+	 *         abstract, and that it ends with SUFFIX, and that either
+	 *         inContainer tests are to be included or the name does not end
+	 *         with IN_CONTAINER_SUFFIX
+	 */
+	private static boolean isValidTest(String name, boolean inContainer) {
+		try {
+			return name.endsWith(SUFFIX)
+					&& (inContainer || !name.endsWith(IN_CONTAINER_SUFFIX))
+					&& ((Class.forName(name).getModifiers() & Modifier.ABSTRACT) == 0);
+		} catch (ClassNotFoundException e) {
+			System.err.println(e.toString());
+			return false;
+		}
+	}
+	/**
+	 * Return all the tests. If we're in a platform, return everything. If not,
+	 * we return those tests that end in SUFFIX but excluding those ending in
+	 * IN_CONTAINER_SUFFIX.
+	 * @return a suite of tests for JUnit to run
+	 * @throws Error if there are no tests to run.
+	 */
+	public static Test suite() {
+		TestSuite suite = new TestSuite(AllTests.class.getName());
+		addTestsToSuite(new ClassFileDetector(), suite);
+		addTestsToSuite(new BundleTestDetector(), suite);
+		if (suite.countTestCases() == 0) {
+			throw new Error("There are no test cases to run");
+		} else {
+			return suite;
+		}
+	}
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/debug/DebugViewsTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/debug/DebugViewsTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/debug/DebugViewsTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,109 @@
+package org.drools.eclipse.debug;
+
+import java.io.InputStreamReader;
+import java.io.Reader;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map.Entry;
+
+import junit.framework.TestCase;
+
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.base.MapGlobalResolver;
+import org.drools.compiler.PackageBuilder;
+import org.drools.reteoo.ReteooStatefulSession;
+import org.drools.spi.Activation;
+import org.drools.spi.AgendaGroup;
+
+/**
+ *
+ * WARNING: DO NOT CHANGE ANYTHING IN THIS TEST CLASS
+ * WITHOUT ALSO CHANGING THE IMPLEMENTATION IN THE DEBUG
+ * VIEWS (which are using reflection)
+ *    
+ * @author Kris Verlaenen
+ */
+public class DebugViewsTest extends TestCase {
+	
+	/*
+	 * WARNING: DO NOT CHANGE ANYTHING IN THIS TEST CLASS
+	 * WITHOUT ALSO CHANGING THE IMPLEMENTATION IN THE DEBUG
+	 * VIEWS (which are using reflection)
+	 */
+    
+    public void testApplicationDataView() throws Exception {
+    	Reader source = new InputStreamReader(DebugViewsTest.class.getResourceAsStream("/debug.drl"));
+    	PackageBuilder builder = new PackageBuilder();
+    	builder.addPackageFromDrl(source);
+    	RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+    	ruleBase.addPackage(builder.getPackage());
+    	ReteooStatefulSession session = (ReteooStatefulSession) ruleBase.newStatefulSession();
+    	session.setGlobal("s", "String");
+    	List list = new ArrayList();
+    	list.add("Value");
+    	session.setGlobal("list", list);
+    	Entry[] globals = ((MapGlobalResolver) session.getGlobalResolver()).getGlobals();
+    	assertEquals(2, globals.length);
+    	if ("list".equals(globals[0].getKey())) {
+	    	assertEquals("list", globals[0].getKey());
+	    	assertEquals(list, globals[0].getValue());
+	    	assertEquals("s", globals[1].getKey());
+	    	assertEquals("String", globals[1].getValue());
+    	} else {
+	    	assertEquals("list", globals[1].getKey());
+	    	assertEquals(list, globals[1].getValue());
+	    	assertEquals("s", globals[0].getKey());
+	    	assertEquals("String", globals[0].getValue());
+    	}
+    }
+    
+	/*
+	 * WARNING: DO NOT CHANGE ANYTHING IN THIS TEST CLASS
+	 * WITHOUT ALSO CHANGING THE IMPLEMENTATION IN THE DEBUG
+	 * VIEWS (which are using reflection)
+	 */
+    
+    public void testAgendaView() throws Exception {
+    	Reader source = new InputStreamReader(DebugViewsTest.class.getResourceAsStream("/debug.drl"));
+    	PackageBuilder builder = new PackageBuilder();
+    	builder.addPackageFromDrl(source);
+    	RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+    	ruleBase.addPackage(builder.getPackage());
+    	ReteooStatefulSession session = (ReteooStatefulSession) ruleBase.newStatefulSession();
+    	List list = new ArrayList();
+    	session.setGlobal("list", list);
+    	session.insert("String1");
+    	AgendaGroup focus = session.getAgenda().getFocus();
+    	assertEquals("MAIN", focus.getName());
+    	AgendaGroup[] agendaGroups = session.getAgenda().getAgendaGroups();
+    	assertEquals(1, agendaGroups.length);
+    	assertEquals("MAIN", agendaGroups[0].getName());
+    	assertEquals(1, agendaGroups[0].getActivations().length);
+    	
+    	Activation activation = agendaGroups[0].getActivations()[0];
+    	assertEquals("ActivationCreator", activation.getRule().getName());
+    	Entry[] parameters = session.getActivationParameters(activation.getActivationNumber());
+    	assertEquals(1, parameters.length);
+    	assertEquals("o", parameters[0].getKey());
+    	assertEquals("String1", parameters[0].getValue());
+    }
+    
+	/*
+	 * WARNING: DO NOT CHANGE ANYTHING IN THIS TEST CLASS
+	 * WITHOUT ALSO CHANGING THE IMPLEMENTATION IN THE DEBUG
+	 * VIEWS (which are using reflection)
+	 */
+    
+    public void testWorkingMemoryView() throws Exception {
+    	RuleBase ruleBase = RuleBaseFactory.newRuleBase();
+    	ReteooStatefulSession session = (ReteooStatefulSession) ruleBase.newStatefulSession();
+    	session.insert("Test1");
+    	session.insert("Test2");
+    	Object[] objects = session.iterateObjectsToList().toArray();
+    	assertEquals(2, objects.length);
+    	assertTrue(("Test1".equals(objects[0]) && "Test2".equals(objects[1])) ||
+    			   ("Test2".equals(objects[0]) && "Test1".equals(objects[1])));
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/DSLAdapterTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/DSLAdapterTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/DSLAdapterTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,52 @@
+package org.drools.eclipse.dsl.editor;
+
+import junit.framework.TestCase;
+
+import org.drools.eclipse.dsl.editor.DSLAdapter;
+
+/**
+ * 
+ * @author Michael Neale
+ */
+public class DSLAdapterTest extends TestCase {
+    
+    public void testFindExpander() {
+        
+        StringBuffer buf = largeString();
+        
+        String pat = "\nexpander  \t abc.dsl ";
+        
+        assertEquals("abc.dsl", DSLAdapter.findDSLConfigName( pat ));
+        
+        
+        assertEquals("abc.dsl", DSLAdapter.findDSLConfigName( buf.toString() ));
+        
+        assertEquals(null, DSLAdapter.findDSLConfigName( "abc /n/n" ));
+        
+        assertEquals(null, DSLAdapter.findDSLConfigName( "fdfds" ));
+        
+    }
+    
+    public void testLoadGrammar() throws Exception {
+        DSLAdapter ad = new DSLAdapter();
+        
+        ad.readConfig( this.getClass().getResourceAsStream( "test.dsl" ) );
+        assertNotNull(ad.listConditionItems());
+        assertNotNull(ad.listConsequenceItems());
+    }
+
+    private StringBuffer largeString() {
+        StringBuffer buf = new StringBuffer();
+        for (int i = 0; i < 1000; i++) {
+            if (i == 42) {
+                buf.append( "\n   expander abc.dsl  \n" );
+            }
+            
+            buf.append( "\n" );
+            buf.append( " fdsfdsfds && " + i);
+            
+        }
+        return buf;
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/test.dsl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/test.dsl	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/dsl/editor/test.dsl	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,3 @@
+#this is a DSL
+[condition][]Left hand side=Right hand side
+[condition][]Something else=boo
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessorTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessorTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/AbstractCompletionProcessorTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,55 @@
+package org.drools.eclipse.editors.completion;
+
+import org.drools.eclipse.editors.scanners.DRLPartionScanner;
+import org.eclipse.jface.text.BadLocationException;
+import org.eclipse.jface.text.Document;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.IDocumentPartitioner;
+import org.eclipse.jface.text.rules.FastPartitioner;
+
+import junit.framework.TestCase;
+
+public class AbstractCompletionProcessorTest extends TestCase {
+
+    public void testReadBackwards() throws BadLocationException {
+        //setup
+        IDocument doc = getDoc();
+        int rhsStartOffset = 150;
+
+        AbstractCompletionProcessor proc = new MockCompletionProcessor();
+        String backText = proc.readBackwards( rhsStartOffset,
+                                              doc );
+        String rule2 = "\nrule YourRule \n" + //
+                       "   dialect \"mvel\"\n" + //
+                       "   when\n" + //
+                       "       Class ( )\n" + //
+                       "   then\n";
+
+        assertEquals( rule2,
+                      backText );
+    }
+
+    private IDocument getDoc() {
+        String input = "rule MyRule \n" + //
+                       "   when\n" + //
+                       "       Class ( )\n" + //
+                       "   then\n" + //
+                       "       System.out.println(\"Hey\");\n" + //
+                       "end\n" + //
+                       "rule YourRule \n" + //
+                       "   dialect \"mvel\"\n" + //
+                       "   when\n" + //
+                       "       Class ( )\n" + //
+                       "   then\n" + //
+                       "       " +//
+                       "end\n\n" ;
+
+        IDocument doc = new Document( input );
+        IDocumentPartitioner partitioner = new FastPartitioner( new DRLPartionScanner(),
+                                                                DRLPartionScanner.LEGAL_CONTENT_TYPES );
+        partitioner.connect( doc );
+        doc.setDocumentPartitioner( partitioner );
+        return doc;
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionContextTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionContextTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionContextTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,1899 @@
+package org.drools.eclipse.editors.completion;
+
+import org.drools.lang.Location;
+
+import junit.framework.TestCase;
+
+/**
+ * Test to check the location determination when doing code completion inside
+ * rule condtions.
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ *
+ */
+public class CompletionContextTest extends TestCase {
+
+    public void testColumnOperatorPattern() {
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(    property ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property   ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( name : property ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(name:property ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(    name:property ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( name:property   ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(   name  :  property  ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property1 == \"value\", property2 ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property1 == \"value\", name : property2 ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property1 == \"value\", name:property2 ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property1 == \"value\",   name  :  property2  ").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(    prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( name:prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(name:prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( name : prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(   name  :  prop").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property <= ").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( name : property == ").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("(property==").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property contains ").matches());
+    	assertFalse(CompletionContext.PATTERN_PATTERN_OPERATOR.matcher("( property1 == \"value\", property2 >= ").matches());
+    }
+
+    public void testColumnArgumentPattern() {
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property == ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property >= ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("(property== ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("(   property   ==   ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( name : property == ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("(name:property== ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("(  name  :  property  ==  ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property1 == \"value\", property2 == ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property1 == \"value\",property2== ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property1 == \"value\",  property2  ==  ").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("( property == otherProp").matches());
+    	assertTrue(CompletionContext.PATTERN_PATTERN_COMPARATOR_ARGUMENT.matcher("(property==otherProp").matches());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( condition == true ) \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		class: Class( condition == true, condition2 == null ) \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION5() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( condition == true ) \n" +
+        	"		Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION6() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		class: Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION7() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		class:Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    /** Inside of condition: start */
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START2() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( na";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("na", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START3() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name.subProperty['test'].subsu";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("name.subProperty['test'].subsu", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START4() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( condition == true, ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START5() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( condition == true, na";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START6() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( \n" +
+        	"			";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START7() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( condition == true, \n" +
+        	"			";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START8() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( c: condition, \n" +
+        	"			";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9a() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       Class ( name:";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START9b() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name: ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START10() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name:";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+
+    }
+
+    /** Inside of  condition: Operator */
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR1() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR2() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class(property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR3() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name : property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR4() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class (name:property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR5() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class (name:property   ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR6() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1 : property1, name : property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR7() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1 : property1 == \"value\", name : property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR8() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1 : property1 == \"value\",property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR9() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1 : property1, \n" +
+        	"			name : property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+    }
+
+    /** Inside of condition: argument */
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT1() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property== ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT3() {
+        String input =
+            "rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name : property <= ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("<=", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name:property != ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("!=", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT5() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1 : property1, property2 == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class (name:property== ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT7() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property == otherPropertyN";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT8() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property == \"someth";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT9() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property contains ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("contains", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT10() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property excludes ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("excludes", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT11() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property matches \"prop";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("matches", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT12() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property in ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("in", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property in ('1', '2') ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START11() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property in ('1', '2'), ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT13() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not in ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("in", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not in ('1', '2') ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START12() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not in ('1', '2'), ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT14() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property memberOf ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("memberOf", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property memberOf collection ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START13() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property memberOf collection, ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT15() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not memberOf ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("memberOf", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not memberOf collection ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START14() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property not memberOf collection, ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    /** EXISTS */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists(";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS5() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists ( Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists ( name : Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDeterminationINSIDE_CONDITION_START16() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    /** NOT */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS7() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not exists ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS8() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not exists Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START21() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START22() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not exists Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START23() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not exists name : Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION9() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		not Class () \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    /** AND */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) &&  ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class () and   ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		name : Class ( name: property ) and ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR5() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name: property ) \n" +
+        	"       and ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR7() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and name : Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR8() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) && name : Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION31() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION32() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and not Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION33() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and exists Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START20() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and Class ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR21() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and Class ( name ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("name", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR22() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and Class ( name == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_NOT() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class ( ) and not ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class ( ) and exists ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION30() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) and not Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+
+        /** OR */
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR21() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR22() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) || ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR23() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class () or   ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR24() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		name : Class ( name: property ) or ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR25() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name: property ) \n" +
+        	"       or ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR26() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR27() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or name : Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_AND_OR28() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) || name : Cl";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_AND_OR, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION40() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or Class ( ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START40() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or Class ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or Class ( name ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("name", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT30() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( ) or Class ( name == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_EGIN_OF_CONDITION_NOT() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class ( ) or not ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_NOT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION_EXISTS40() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		exists Class ( ) or exists ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION_EXISTS, location.getType());
+        }
+
+    /** EVAL */
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval(";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( myCla";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("myCla", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL4() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getMetho";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getMetho", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL5() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getMethod(";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getMethod(", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getMethod().get";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getMethod().get", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL7() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getMethod(\"someStringWith)))\").get";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getMethod(\"someStringWith)))\").get", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL8() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getMethod(\"someStringWith(((\").get";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getMethod(\"someStringWith(((\").get", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL9() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( true )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION50() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getProperty(name).isTrue() )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION51() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getProperty(\"someStringWith(((\").isTrue() )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_EVAL10() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getProperty((((String) s) )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_EVAL, location.getType());
+        assertEquals("param.getProperty((((String) s) )", location.getProperty(Location.LOCATION_EVAL_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION52() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( param.getProperty((((String) s))))";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION53() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		eval( true ) \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    /** MULTIPLE RESTRICTIONS */
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR12() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 && ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR13() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name : property1, property2 > 0 && ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR14() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property1 < 20, property2 > 0 && ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT20() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 && < ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("<", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 && < 10 ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START41() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 && < 10, ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR60() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 || ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR61() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 || \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR62() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name : property1, property2 > 0 || ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR63() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property1 < 20, property2 > 0 || ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property2", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END10() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END11() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END12() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 && < 10 ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END13() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 || < 10 ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_END14() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property == \"test\" || == \"test2\" ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_END, location.getType());
+        }
+
+    /** FROM */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION60() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION61() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) fr";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM, location.getType());
+        assertEquals("", location.getProperty(Location.LOCATION_FROM_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from myGlob";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM, location.getType());
+        assertEquals("myGlob", location.getProperty(Location.LOCATION_FROM_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from myGlobal.get";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM, location.getType());
+        assertEquals("myGlobal.get", location.getProperty(Location.LOCATION_FROM_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION75() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from myGlobal.getList() \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION71() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from getDroolsFunction() \n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    /** FROM ACCUMULATE */
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate(";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION73() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total = 0; ), \n" +
+        	"			action( total += $cheese.getPrice(); ), \n" +
+        	"           result( new Integer( total ) ) \n" +
+        	"		) \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE, location.getType());
+        assertEquals("", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total = 0; ), \n" +
+        	"			action( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE, location.getType());
+        assertEquals(" int total = 0; ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        assertEquals("", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total = 0; ), \n" +
+        	"			action( total += $cheese.getPrice(); ), \n" +
+        	"           result( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE, location.getType());
+        assertEquals(" int total = 0; ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        assertEquals(" total += $cheese.getPrice(); ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
+        assertEquals("", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_INIT_INSIDE2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total =";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_INIT_INSIDE, location.getType());
+        assertEquals("int total =", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_ACTION_INSIDE2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total = 0; ), \n" +
+        	"			action( total += $ch";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_ACTION_INSIDE, location.getType());
+        assertEquals(" int total = 0; ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        assertEquals("total += $ch", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_ACCUMULATE_RESULT_INSIDE2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == $likes ), \n" +
+        	"			init( int total = 0; ), \n" +
+        	"			action( total += $cheese.getPrice(); ), \n" +
+        	"           result( new Integer( tot";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_ACCUMULATE_RESULT_INSIDE, location.getType());
+        assertEquals(" int total = 0; ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_INIT_CONTENT));
+        assertEquals(" total += $cheese.getPrice(); ", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_ACTION_CONTENT));
+        assertEquals("new Integer( tot", location.getProperty(Location.LOCATION_PROPERTY_FROM_ACCUMULATE_RESULT_CONTENT));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR40() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("type", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from accumulate( \n" +
+        	"			$cheese : Cheese( type == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("type", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    /** FROM COLLECT */
+    public void testCheckLHSLocationDetermination_FROM_COLLECT1() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_COLLECT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM_COLLECT2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect(";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM_COLLECT, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION67() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect ( \n" +
+        	"			Cheese( type == $likes )" +
+        	"		) \n" +
+        	"		";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START31() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect ( \n" +
+        	"			Cheese( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR31() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect ( \n" +
+        	"			Cheese( type ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("type", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT21() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from collect ( \n" +
+        	"			Cheese( type == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Cheese", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("type", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    /** NESTED FROM */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION68() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM5() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) from ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION69() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from collect( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION70() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_FROM6() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_FROM, location.getType());
+        }
+
+    /** FORALL */
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION81() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		forall ( ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START32() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		forall ( " +
+        	"           Class ( pr";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("pr", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_OPERATOR32() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		forall ( " +
+        	"           Class ( property ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_OPERATOR, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_ARGUMENT22() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		forall ( " +
+        	"           Class ( property == ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_ARGUMENT, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+        assertEquals("property", location.getProperty(Location.LOCATION_PROPERTY_PROPERTY_NAME));
+        assertEquals("==", location.getProperty(Location.LOCATION_PROPERTY_OPERATOR));
+        }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION76() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		forall ( " +
+        	"           Class ( property == \"test\")" +
+        	"           C";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77a() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() ) ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_BEGIN_OF_CONDITION77b() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       ArrayList(size > 50) from accumulate( Person( disabled == \"yes\", income > 100000 ) from town.getPersons() )";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45a() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       Class ( name :";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckLHSLocationDetermination_INSIDE_CONDITION_START45b() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       Class ( name : ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+
+    public void testCheckRHSLocationDetermination_firstLineOfLHS() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when\n" +
+        	"		Class ( )\n" +
+        	"   then\n" +
+        	"       ";
+
+        Location location = new CompletionContext(input).getLocation();
+
+        assertEquals(Location.LOCATION_RHS, location.getType());
+        assertEquals("", location.getProperty(Location.LOCATION_RHS_CONTENT));
+    }
+
+    public void testCheckRHSLocationDetermination_startOfNewlINE() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when\n" +
+        	"		Class ( )\n" +
+        	"   then\n" +
+        	"       assert(null);\n" +
+        	"       ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RHS, location.getType());
+        assertEquals("assert(null);\n       ", location.getProperty(Location.LOCATION_RHS_CONTENT));
+    }
+
+    public void testCheckRHSLocationDetermination3() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when\n" +
+        	"		Class ( )\n" +
+        	"   then\n" +
+        	"       meth";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RHS, location.getType());
+        assertEquals("meth", location.getProperty(Location.LOCATION_RHS_CONTENT));
+    }
+
+    public void testCheckRuleHeaderLocationDetermination() {
+        String input =
+        	"rule MyRule ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void testCheckRuleHeaderLocationDetermination2() {
+        String input =
+        	"rule MyRule \n" +
+        	"	salience 12 activation-group \"my";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void FAILINGtestCheckRuleHeaderLocationDetermination3() {
+        // KRISV: still can't make this work... apparently, ANTLR is trying to recover from
+        // the error (unkown token) by deleting the token. I don't know why it continues to
+        // execute actions though, if the EOF is found.
+        String input =
+          "rule \"Hello World\" ruleflow-group \"hello\" s";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void testCheckRuleHeaderLocationDetermination_dialect1() {
+        String input  =
+        	"rule MyRule \n" +
+        	"	dialect \"java\"";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void testCheckRuleHeaderLocationDetermination_dialect2() {
+        String input  =
+        	"rule MyRule \n" +
+        	"	dialect \"mvel\"";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void testCheckRuleHeaderLocationDetermination_dialect3() {
+        String input  =
+        	"rule MyRule \n" +
+        	"	dialect ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    public void testCheckRuleHeaderLocationDetermination_dialect4() {
+        String input  =
+        	"rule MyRule \n" +
+        	"	dialect \"";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+    }
+
+    //TODO: add tests for dialect defined at package header level
+
+    public void testCheckQueryLocationDetermination_RULE_HEADER1() {
+        String input =
+        	"query MyQuery ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+        }
+
+    public void testCheckQueryLocationDetermination_RULE_HEADER2() {
+        String input =
+        	"query \"MyQuery\" ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_RULE_HEADER, location.getType());
+        }
+
+    public void testCheckQueryLocationDetermination_LHS_BEGIN_OF_CONDITION() {
+        String input =
+            "query MyQuery() ";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_BEGIN_OF_CONDITION, location.getType());
+        }
+
+    public void testCheckQueryLocationDetermination_LHS_INSIDE_CONDITION_START() {
+        String input =
+        	"query MyQuery \n" +
+        	"	Class (";
+        Location location = new CompletionContext(input).getLocation();
+        assertEquals(Location.LOCATION_LHS_INSIDE_CONDITION_START, location.getType());
+        assertEquals("Class", location.getProperty(Location.LOCATION_PROPERTY_CLASS_NAME));
+    }
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionUtilTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionUtilTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/CompletionUtilTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,341 @@
+package org.drools.eclipse.editors.completion;
+
+import org.eclipse.jdt.core.Signature;
+
+import junit.framework.TestCase;
+
+public class CompletionUtilTest extends TestCase {
+
+    public void testIsGetter() {
+        assertTrue( CompletionUtil.isGetter( "getThis",
+                                             0,
+                                             "String" ) );
+    }
+
+    public void testIsGetterCannotReturnVoid() {
+        assertFalse( CompletionUtil.isGetter( "getThis",
+                                              0,
+                                              Signature.SIG_VOID ) );
+    }
+
+    public void testIsGetterWrongPrefix() {
+        assertFalse( CompletionUtil.isGetter( "hasThis",
+                                              0,
+                                              Signature.SIG_VOID ) );
+    }
+
+    public void testIsGetterTooManyArgs() {
+        assertFalse( CompletionUtil.isGetter( "getThis",
+                                              2,
+                                              "String" ) );
+    }
+
+    public void testIsGetterMethodNameTooShort() {
+        assertFalse( CompletionUtil.isGetter( "get",
+                                              2,
+                                              "String" ) );
+    }
+
+    public void testIsIsGetter() {
+        assertTrue( CompletionUtil.isIsGetter( "isGood",
+                                               0,
+                                               Signature.SIG_BOOLEAN ) );
+    }
+
+    public void testIsIsGetterWrongPrefix() {
+        assertFalse( CompletionUtil.isIsGetter( "getThis",
+                                                0,
+                                                Signature.SIG_BOOLEAN ) );
+    }
+
+    public void testIsIsGetterAlwaysReturnsBoolean() {
+        assertFalse( CompletionUtil.isIsGetter( "isThis",
+                                                0,
+                                                Signature.SIG_VOID ) );
+    }
+
+    public void testIsIsGetterTooManyArgs() {
+        assertFalse( CompletionUtil.isIsGetter( "isThis",
+                                                2,
+                                                "String" ) );
+    }
+
+    public void testIsIsGetterMethodNameTooShort() {
+        assertFalse( CompletionUtil.isIsGetter( "is",
+                                                2,
+                                                "String" ) );
+    }
+
+    public void testIsSetter() {
+        assertTrue( CompletionUtil.isSetter( "setThat",
+                                             1,
+                                             Signature.SIG_VOID ) );
+    }
+
+    public void testIsSetterWrongPrefix() {
+        assertFalse( CompletionUtil.isSetter( "getThat",
+                                              1,
+                                              Signature.SIG_VOID ) );
+    }
+
+    public void testIsSetterTooShort() {
+        assertFalse( CompletionUtil.isSetter( "se",
+                                              1,
+                                              Signature.SIG_VOID ) );
+    }
+
+    public void testIsSetterNoArgs() {
+        assertFalse( CompletionUtil.isSetter( "setThat",
+                                              0,
+                                              Signature.SIG_VOID ) );
+    }
+
+    public void testIsSetterWrongType() {
+        assertFalse( CompletionUtil.isSetter( "setThat",
+                                              1,
+                                              "String" ) );
+    }
+
+    public void testGetPropertyName() {
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "getMe",
+                                                      0,
+                                                      "String" ) );
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "isMe",
+                                                      0,
+                                                      Signature.SIG_BOOLEAN ) );
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "setMe",
+                                                      1,
+                                                      Signature.SIG_VOID ) );
+
+        assertEquals( "setMe",
+                      CompletionUtil.getPropertyName( "setMe",
+                                                      0,
+                                                      Signature.SIG_VOID ) );
+
+        assertEquals( "MySuperMethod",
+                      CompletionUtil.getPropertyName( "MySuperMethod",
+                                                      1,
+                                                      Signature.SIG_VOID ) );
+    }
+
+    public void testGetPropertyNameStripsParenthesis() {
+
+        assertEquals( "MySuperMethod()",
+                      CompletionUtil.getPropertyName( "MySuperMethod()",
+                                                      1,
+                                                      Signature.SIG_VOID ) );
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "getMe()",
+                                                      0,
+                                                      "String" ) );
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "isMe()",
+                                                      0,
+                                                      Signature.SIG_BOOLEAN ) );
+        assertEquals( "me",
+                      CompletionUtil.getPropertyName( "setMe()",
+                                                      1,
+                                                      Signature.SIG_VOID ) );
+    }
+
+    public void testStripLastWord() {
+        String backtext = "rule \"GoodBye\"\r\n" + "	no-loop true\r\n" + "	when\r\n" + "		m : Message( status == Message.GOODBYE, message : message )\r\n" + "	then\r\n" + "		m.message=message;\r\n" + "		m.last";
+
+        String lastword = "last";
+        assertEquals( lastword,
+                      CompletionUtil.stripLastWord( backtext ) );
+    }
+
+    public void testGetPreviousExpression1() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression2() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message== ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression3() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message(sdasdasd, ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression4() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message( ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression5() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   this.asd ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression6() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message(){ ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetPreviousExpression7() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';message== ";
+        String previous = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';";
+        assertEquals( previous,
+                      CompletionUtil.getPreviousExpression( backText ) );
+    }
+
+    public void testGetLastExpression11() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d'";
+        String previous = "\r\n" + "   adasd ='d'";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression1() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';";
+        String previous = "\r\n   adasd ='d'";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression10() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';\r\n";
+        assertEquals( backText,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression2() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message== ";
+        String previous = "\r\n   message== ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression3() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message(sdasdasd, ";
+        String previous = "\r\n   message(sdasdasd, ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression4() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message( ";
+        String previous = "\r\n   message( ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression5() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   this.asd ";
+        String previous = "\r\n   this.asd ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression6() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   message(){ ";
+        String previous = "\r\n   message(){ ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression7() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';message== ";
+        String previous = "message== ";
+        assertEquals( previous,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetInnerExpression() {
+        String backText = "  \r\n" + "   System.out.println( message );\r\n" + "   m.message = \"Goodbyte cruel world\";\r\n" + "   m.status = 1;\r\n" + "   adasd ='d';message== ";
+        String previous = "";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetInnerExpression2() {
+        String backText = "System.out.println(m ";
+        String previous = "m";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetInnerExpression3() {
+        String backText = "update(m) {";
+        String previous = "";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetInnerExpression4() {
+        String backText = "update(m) {some=";
+        String previous = "";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetInnerExpression5() {
+        String backText = "update(m) {asdasdas==asdasd, asdasd";
+        String previous = "asdasd";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetInnerExpression6() {
+        String backText = "update(m) {asdasdas==asdasd, asdasd}";
+        String previous = "";
+        assertEquals( previous,
+                      CompletionUtil.getInnerExpression( backText ) );
+    }
+
+    public void testGetLastExpression_withComments() {
+        String backText = "dasdasdas\nsasasasa\n //fsdfsdfdsfdsf\n\n";
+        String exp = "dasdasdas\n" + "sasasasa\n" + " //fsdfsdfdsfdsf\n" + "\n";
+        assertEquals( exp,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetLastExpression_withComments2() {
+        String backText = "dasdasdas\nsasasasa\n //fsdfsdfdsfdsf\n";
+        String exp = "dasdasdas\n" + "sasasasa\n" + " //fsdfsdfdsfdsf\n" ;
+        assertEquals( exp,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+    public void testGetLastExpression_withComments3() {
+        String backText = "dasdasdas\nsasasasa\n //fsdfsdfdsfdsf\n";
+        String exp = "dasdasdas\n" + "sasasasa\n" + " //fsdfsdfdsfdsf\n" ;
+        assertEquals( exp,
+                      CompletionUtil.getLastExpression( backText ) );
+    }
+
+    public void testGetTextWithoutPrefix() {
+        String text = "modify(m) {asdasdas==asdasd, asdasd.asa";
+        String expected = "modify(m) {asdasdas==asdasd, asdasd.";
+        assertEquals( expected,
+                      CompletionUtil.getTextWithoutPrefix( text,
+                                                           "asa" ) );
+    }
+
+    public void testGetTextWithoutPrefix2() {
+        String text = "it";
+        String expected = "";
+        assertEquals( expected,
+                      CompletionUtil.getTextWithoutPrefix( text,
+                                                           text ) );
+    }
+
+}
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/ContextScanningTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/ContextScanningTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/ContextScanningTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,34 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import junit.framework.TestCase;
+
+public class ContextScanningTest extends TestCase {
+
+    public void testCheckAfterToken() {
+        
+        
+        
+        assertTrue(checkContains("when", "rule something \nwhen \t blah"));
+        assertTrue(checkContains("when", "rule something when nothing"));
+        assertFalse(checkContains("when", "rule something whennothing"));
+        assertTrue(checkContains("when", "rule something \twhen nothing"));
+    }
+
+    private boolean checkContains(String keyword,
+                                 String chunk) {
+        //Pattern p = Pattern.compile(".*(.)" + keyword + "(.).*", Pattern.DOTALL);
+        Pattern p = Pattern.compile(".*rule.*\\W" + keyword + "\\W.*", Pattern.DOTALL);
+        Matcher matcher = p.matcher(chunk);
+       
+        return matcher.matches();
+    }
+    
+    
+
+
+
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/DRLCompletionProcessorTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/DRLCompletionProcessorTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/DRLCompletionProcessorTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,60 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+public class DRLCompletionProcessorTest extends TestCase {
+
+    public void testLookBehind() {
+        assertEquals("something", CompletionUtil.stripLastWord(" something"));
+        assertEquals("another", CompletionUtil.stripLastWord("another"));
+
+        String s = "rule something \n\nwhen";
+        assertEquals("when", CompletionUtil.stripLastWord(s));
+    }
+
+    public void testPrefixFiltering_FiltersBasedOnDisplayedStringNotContent() {
+        List list = new ArrayList();
+        list.add(new RuleCompletionProposal(0, 0, "abcd", "zxyz"));
+        list.add(new RuleCompletionProposal(0, 0, "azard","good"));
+        list.add(new RuleCompletionProposal(0, 0, "art","apple"));
+        list.add(new RuleCompletionProposal(0, 0, "spe", "ape"));
+
+        DefaultCompletionProcessor.filterProposalsOnPrefix("a", list);
+        assertEquals(3, list.size());
+        assertEquals("zxyz", list.get(0).toString());
+        assertEquals("good", list.get(1).toString());
+        assertEquals("apple", list.get(2).toString());
+
+    }
+
+    public void testPrefixFiltering_FiltersAllWhenThereisNoMatches() {
+        List list = new ArrayList();
+        list = new ArrayList();
+        list.add(new RuleCompletionProposal(0, 0, "aardvark", "something"));
+        list.add(new RuleCompletionProposal(0, 0, "smeg"));
+        list.add(new RuleCompletionProposal(0, 0, "apple"));
+        list.add(new RuleCompletionProposal(0, 0, "ape", "zzzzz"));
+        DefaultCompletionProcessor.filterProposalsOnPrefix("xzyz", list);
+        assertEquals(0, list.size());
+
+    }
+
+    public void testPrefixFiltering_IgnoreCase() {
+        List list = new ArrayList();
+        list = new ArrayList();
+        list.add(new RuleCompletionProposal(0, 0, "ART"));
+        list.add(new RuleCompletionProposal(0, 0, "art"));
+        list.add(new RuleCompletionProposal(0, 0, "aRT"));
+        list.add(new RuleCompletionProposal(0, 0, "Art", "zzzzz"));
+        DefaultCompletionProcessor.filterProposalsOnPrefix("art", list);
+        assertEquals(4, list.size());
+
+        DefaultCompletionProcessor.filterProposalsOnPrefix("ART", list);
+        assertEquals(4, list.size());
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/IncompleteParsingTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,589 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+
+/**
+ * Test to check the results from parsing incomplete rule fragments.
+ *
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">kris verlaenen </a>
+ */
+public class IncompleteParsingTest extends TestCase {
+
+	private RuleDescr parseRuleString(String s) {
+		PackageDescr packageDescr = parseString(s);
+		if (packageDescr != null) {
+			List rules = packageDescr.getRules();
+			if (rules != null && rules.size() == 1) {
+				return (RuleDescr) rules.get(0);
+			}
+		}
+		return null;
+	}
+
+	private PackageDescr parseString(String s) {
+		DrlParser parser = new DrlParser();
+		try {
+			return parser.parse(s);
+		} catch (DroolsParserException exc) {
+			exc.printStackTrace();
+		}
+		return null;
+	}
+
+
+    public void testParsingColumn() {
+        String input =
+        	"rule MyRule \n" +
+        	"  when \n" +
+        	"    ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(0, rule.getLhs().getDescrs().size());
+
+
+        /**
+         * This is how the parsed tree should look like:
+         *
+         * RuleDescr
+         *   PatternDescr [objectType = "Class"]
+         *     FieldConstraintDescr [fieldName = "condition"]
+         *       LiteralRestrictionDescr [evaluator = "==", text = "true"]
+         */
+    }
+
+
+    public void testParsingColumn1() {
+        String input =
+        	"rule MyRule \n" +
+        	"  when \n" +
+        	"    Class( condition == true ) \n" +
+        	"    ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertTrue(pattern.getEndLine() != -1 || pattern.getEndColumn() != -1);
+        assertEquals(1, pattern.getDescrs().size());
+        assertEquals(input.indexOf( "Class" ), pattern.getStartCharacter());
+        assertEquals(input.indexOf( "(" ), pattern.getLeftParentCharacter());
+        assertEquals(input.indexOf( ")" ), pattern.getRightParentCharacter());
+        assertEquals(input.indexOf( ")" ), pattern.getEndCharacter());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("condition", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        LiteralRestrictionDescr restriction = (LiteralRestrictionDescr) field.getRestrictions().get(0);
+        assertEquals("==", restriction.getEvaluator());
+        assertEquals("true", restriction.getText());
+    }
+
+
+    public void testParsingColumn2() {
+        String input =
+
+        	"rule MyRule \n" +
+	    	"  when \n" +
+	    	"    class: Class( condition == true, condition2 == null ) \n" +
+	    	"    ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertTrue(pattern.getEndCharacter() != -1);
+    }
+
+
+    public void testParsingColumn3() {
+        String input =
+	    	"rule MyRule \n" +
+	    	"  when \n" +
+	    	"    Cl";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(0, rule.getLhs().getDescrs().size());
+
+    }
+
+
+    public void testParsingColumn4() {
+        String input =
+	    	"rule MyRule \n" +
+	    	"  when \n" +
+	    	"    Class( condition == true ) \n" +
+	    	"    Cl";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertTrue(pattern.getEndCharacter() != -1);
+
+    }
+
+
+    public void testParsingColumn5() {
+        String input =
+			"rule MyRule \n" +
+			"  when \n" +
+			"    class:";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("class", pattern.getIdentifier());
+        assertNull(pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn6() {
+        String input =
+			"rule MyRule \n" +
+			"  when \n" +
+			"    class: Cl";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("class", pattern.getIdentifier());
+        assertEquals("Cl", pattern.getObjectType());
+        assertTrue(pattern.getEndLine() == -1 && pattern.getEndColumn() == -1);
+        assertEquals(0, pattern.getDescrs().size());
+        assertEquals(-1, pattern.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn7() {
+        String input =
+			"rule MyRule \n" +
+			"  when \n" +
+			"    class:Cl";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("class", pattern.getIdentifier());
+        assertEquals("Cl", pattern.getObjectType());
+        assertTrue(pattern.getEndLine() == -1 && pattern.getEndColumn() == -1);
+        assertEquals(0, pattern.getDescrs().size());
+        assertEquals(-1, pattern.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn8() {
+        /** Inside of condition: start */
+        String input =
+			"rule MyRule \n" +
+			"  when \n" +
+			"    Class (";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertTrue(pattern.getEndLine() == -1 && pattern.getEndColumn() == -1);
+        assertEquals(0, pattern.getDescrs().size());
+        assertEquals(-1, pattern.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn9() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( na";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals( "na", field.getFieldName() );
+        assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn10() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name['xyz'].subname.subsubn";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals( "name['xyz'].subname.subsubn", field.getFieldName() );
+        assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn11() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( condition == true, ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn12() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( c : condition, ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldBindingDescr fieldBinding = (FieldBindingDescr) pattern.getDescrs().get(0);
+        assertEquals(-1, fieldBinding.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn13() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( condition == true, na";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(2, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals(-1, field.getEndCharacter());
+        assertEquals( "condition", field.getFieldName() );
+         field = (FieldConstraintDescr) pattern.getDescrs().get(1);
+        assertEquals( "na", field.getFieldName() );
+        assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void FAILINGtestParsingColumn14() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name:";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldBindingDescr binding1 = (FieldBindingDescr) pattern.getDescrs().get(0);
+        assertEquals("name", binding1.getIdentifier());
+        assertNull(binding1.getFieldName());
+
+    }
+
+
+    public void testParsingColumn15() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(0, field.getRestrictions().size());
+        assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn16() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name: property ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldBindingDescr binding = (FieldBindingDescr) pattern.getDescrs().get(0);
+        assertEquals("name", binding.getIdentifier());
+        assertEquals("property", binding.getFieldName());
+
+    }
+
+
+    public void testParsingColumn17() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( name1: property1 == \"value1\", name2: property2 ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(3, pattern.getDescrs().size());
+        FieldBindingDescr binding = (FieldBindingDescr) pattern.getDescrs().get(0);
+        assertEquals("name1", binding.getIdentifier());
+        assertEquals("property1", binding.getFieldName());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(1);
+        assertEquals("property1", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        LiteralRestrictionDescr literal = (LiteralRestrictionDescr) field.getRestrictions().get(0);
+        assertEquals("==", literal.getEvaluator());
+        assertEquals("value1", literal.getText());
+        binding = (FieldBindingDescr) pattern.getDescrs().get(2);
+        assertEquals("name2", binding.getIdentifier());
+        assertEquals("property2", binding.getFieldName());
+
+    }
+
+
+    public void testParsingColumn18() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class(name:property==";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(2, pattern.getDescrs().size());
+        FieldBindingDescr binding = (FieldBindingDescr) pattern.getDescrs().get(0);
+        assertEquals("name", binding.getIdentifier());
+        assertEquals("property", binding.getFieldName());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(1);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+
+    }
+
+
+    public void testParsingColumn19() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( property == otherPropertyN";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        VariableRestrictionDescr variable = (VariableRestrictionDescr) field.getRestrictions().get(0);
+        assertEquals("==", variable.getEvaluator());
+        assertEquals("otherPropertyN", variable.getIdentifier());
+        assertEquals(-1, field.getEndCharacter());
+    }
+
+
+    public void testParsingColumn20() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( property == \"someth";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        LiteralRestrictionDescr literal = (LiteralRestrictionDescr) field.getRestrictions().get(0);
+        // KRISV: for now, it would be really messy to make this work. String is a
+        // lexer rule (not parser), and changing that or controling the behavior of it
+        // is not simple. Can we leave the way it is for now?
+        //
+        // TODO literal should be a LiteralRestrictionDescr with filled in evaluator and text, not null
+        // assertEquals("==", literal.getEvaluator());
+        // assertEquals("someth", literal.getText());
+        // TODO this method does not yet exist
+        // assertEquals(-1, field.getEndCharacter());
+
+    }
+
+
+    public void testParsingColumn21() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( property contains ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        // KRISV: you are right
+        //
+        // now I would like to access the evaluator 'contains', but this seems
+        // not possible because the parser cannot create this descr yet
+        // since it does not know what class to create (VariableRestrictionDescr
+        // or LiteralRestrictionDescr or ?)
+        // so maybe I should just extract this info myself, based on the
+        // starting character of this FieldConstraintDescr?
+        // TODO this method does not yet exist
+        assertEquals(-1, field.getEndCharacter());
+    }
+
+
+    public void testParsingColumn22() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class( property matches \"someth";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        LiteralRestrictionDescr literal = (LiteralRestrictionDescr) field.getRestrictions().get(0);
+        // KRISV: see comments above
+        //
+        // TODO literal should be a LiteralRestrictionDescr with filled in evaluator and text, not null
+        // assertEquals("matches", literal.getEvaluator());
+        // assertEquals("someth", literal.getText());
+        // TODO this method does not yet exist
+        // assertEquals(-1, field.getEndCharacter());
+    }
+
+
+    public void testParsingColumn23() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       eval ( ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        EvalDescr eval = (EvalDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals(input.indexOf( "eval" ), eval.getStartCharacter());
+        assertEquals(-1, eval.getEndCharacter());
+    }
+
+
+    public void testParsingColumn24() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       Class ( property > 0 & ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        assertEquals(-1, pattern.getEndCharacter());
+        assertEquals(1, pattern.getDescrs().size());
+        FieldConstraintDescr field = (FieldConstraintDescr) pattern.getDescrs().get(0);
+        assertEquals("property", field.getFieldName());
+        assertEquals(1, field.getRestrictions().size());
+        LiteralRestrictionDescr literal = (LiteralRestrictionDescr) field.getRestrictions().get(0);
+        assertEquals(">", literal.getEvaluator());
+        assertEquals("0", literal.getText());
+        RestrictionConnectiveDescr connective = (RestrictionConnectiveDescr) field.getRestriction();
+        assertEquals(RestrictionConnectiveDescr.AND, connective.getConnective());
+    }
+
+
+    public void testParsingColumn25() {
+        String input =
+            "rule MyRule \n" +
+            "   when \n" +
+            "       Class ( ) from a";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals("Class", pattern.getObjectType());
+        FromDescr from = (FromDescr) pattern.getSource();
+        assertEquals(-1, from.getEndCharacter());
+        assertTrue(pattern.getEndCharacter() != -1);
+    }
+
+
+    public void testParsingColumn26() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from myGlobal.getList() \n" +
+        	"       ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        FromDescr from = (FromDescr) pattern.getSource();
+        assertTrue(from.getEndCharacter() != -1);
+    }
+
+
+    public void testParsingColumn27() {
+        String input =
+        	"rule MyRule \n" +
+        	"	when \n" +
+        	"		Class ( property > 0 ) from getDroolsFunction() \n" +
+        	"       ";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(1, rule.getLhs().getDescrs().size());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        FromDescr from = (FromDescr) pattern.getSource();
+        assertTrue(from.getEndCharacter() != -1);
+    }
+
+    public void testParsingCharactersStartEnd() {
+        String input =
+        	"package test; \n" +
+        	"rule MyRule \n" +
+        	"  when \n" +
+        	"    Class( condition == true ) \n" +
+        	"  then \n" +
+        	"    System.out.println(\"Done\") \n" +
+        	"end \n";
+        RuleDescr rule = parseRuleString(input);
+        assertEquals(input.indexOf( "rule" ), rule.getStartCharacter());
+        assertEquals(input.indexOf( "end" )+2, rule.getEndCharacter());
+        PatternDescr pattern = (PatternDescr) rule.getLhs().getDescrs().get(0);
+        assertEquals(input.indexOf( "Class" ), pattern.getStartCharacter());
+        assertEquals(input.indexOf( "(" ), pattern.getLeftParentCharacter());
+        assertEquals(input.indexOf( ")" ), pattern.getRightParentCharacter());
+        assertEquals(input.indexOf( ")" ), pattern.getEndCharacter());
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/KeywordsTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/KeywordsTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/KeywordsTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,17 @@
+package org.drools.eclipse.editors.completion;
+
+import org.drools.eclipse.editors.Keywords;
+
+import junit.framework.TestCase;
+
+public class KeywordsTest extends TestCase {
+
+    public void testAll() {
+        Keywords keys = Keywords.getInstance();
+        String[] all = keys.getAllDroolsKeywords();
+        assertTrue(all.length > 0);
+        assertEquals("when", all[0]);
+
+    }
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MockCompletionProcessor.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MockCompletionProcessor.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MockCompletionProcessor.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,17 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.List;
+
+import org.eclipse.jface.text.ITextViewer;
+
+public class MockCompletionProcessor extends AbstractCompletionProcessor {
+
+    public MockCompletionProcessor() {
+        super( null );
+    }
+
+    protected List getCompletionProposals(ITextViewer viewer,
+                                          int documentOffset) {
+        return null;
+    }
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MvelParsingTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MvelParsingTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/MvelParsingTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,25 @@
+package org.drools.eclipse.editors.completion;
+
+import junit.framework.TestCase;
+
+public class MvelParsingTest extends TestCase {
+    public void testGetInnerExpression4() {
+        String backText =
+            "modify(m) {some=";
+        String previous ="";
+        assertEquals(previous, CompletionUtil.getInnerExpression( backText ));
+    }
+    public void testGetInnerExpression5() {
+        String backText =
+            "modify(m) {asdasdas==asdasd, asdasd";
+        String previous ="asdasd";
+        assertEquals(previous, CompletionUtil.getInnerExpression( backText ));
+    }
+    public void testGetInnerExpression6() {
+        String backText =
+            "modify(m) {asdasdas==asdasd, asdasd}";
+        String previous ="";
+        assertEquals(previous, CompletionUtil.getInnerExpression( backText ));
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/RuleCompletionProcessorTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/RuleCompletionProcessorTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/completion/RuleCompletionProcessorTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,117 @@
+package org.drools.eclipse.editors.completion;
+
+import java.util.ArrayList;
+import java.util.Collection;
+
+import org.drools.rule.builder.dialect.java.KnowledgeHelperFixer;
+import org.eclipse.jface.text.IDocument;
+import org.eclipse.jface.text.contentassist.ICompletionProposal;
+import org.eclipse.jface.text.contentassist.IContextInformation;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.graphics.Point;
+
+import junit.framework.TestCase;
+
+public class RuleCompletionProcessorTest extends TestCase {
+
+    class MockCompletionProposal
+        implements
+        ICompletionProposal {
+
+        String displayString;
+
+        public MockCompletionProposal(String displayString) {
+            this.displayString = displayString;
+        }
+
+        public void apply(IDocument document) {
+            // TODO Auto-generated method stub
+
+        }
+
+        public String getAdditionalProposalInfo() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public IContextInformation getContextInformation() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public String getDisplayString() {
+            return displayString;
+        }
+
+        public Image getImage() {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+        public Point getSelection(IDocument document) {
+            // TODO Auto-generated method stub
+            return null;
+        }
+
+    }
+
+    public void testContainsProposal() {
+        Collection proposals = new ArrayList();
+
+        MockCompletionProposal c1 = new MockCompletionProposal( "getName() Object - MyObject" );
+        proposals.add( c1 );
+
+        String newProposal = "getName() String - CompletionProposal";
+
+        assertTrue( RuleCompletionProcessor.containsProposal( proposals,
+                                                              newProposal ) );
+
+        MockCompletionProposal c2 = new MockCompletionProposal( "getNoName() Object - MyObject" );
+        proposals.add( c2 );
+        assertFalse( RuleCompletionProcessor.containsProposal( proposals,
+                                                               "getNoName" ) );
+    }
+
+    public void testAddAllNewProposals() {
+        ArrayList proposals = new ArrayList();
+        MockCompletionProposal c = new MockCompletionProposal( "getName() Object - MyObject" );
+        proposals.add( c );
+
+        ArrayList newProposals = new ArrayList();
+        MockCompletionProposal c1 = new MockCompletionProposal( "getName() Objectw - MyObject" );
+        newProposals.add( c1 );
+        MockCompletionProposal c2 = new MockCompletionProposal( "getNoName() Object - MyObject" );
+        newProposals.add( c2 );
+        MockCompletionProposal c3 = new MockCompletionProposal( "getNoName() NoObject - MyObject" );
+        newProposals.add( c3 );
+
+        RuleCompletionProcessor.addAllNewProposals( proposals,
+                                                    newProposals );
+
+        assertTrue( proposals.size() == 2 );
+
+        ICompletionProposal prop = (ICompletionProposal) proposals.get( 1 );
+        assertEquals( "getNoName() Object - MyObject",
+                      prop.getDisplayString() );
+    }
+
+    public void testProcessMacros() {
+        String text = "";
+        final String[] functions = new String[]{"update", "retract", "insert", "insertLogical"};
+        for ( int i = 0; i < functions.length; i++ ) {
+            String string = functions[i];
+            String expected = "drools." + string;
+
+            assertEquals( expected,
+                          new KnowledgeHelperFixer().fix( string ) );
+
+        }
+    }
+
+    public void testIsStartOfDialectExpression() {
+        //for now inside a method start, we are not starting a new expression for completion purpose
+        String s = "System.out.println(\"\");\r\n" + "  update(";
+        assertFalse( CompletionUtil.isStartOfDialectExpression( s ) );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/outline/RuleContentOutlineTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/outline/RuleContentOutlineTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/outline/RuleContentOutlineTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,42 @@
+package org.drools.eclipse.editors.outline;
+
+import junit.framework.TestCase;
+
+import org.drools.eclipse.core.DroolsElement;
+import org.drools.eclipse.core.Function;
+import org.drools.eclipse.core.Package;
+import org.drools.eclipse.core.RuleSet;
+import org.drools.eclipse.editors.AbstractRuleEditor;
+import org.drools.eclipse.editors.outline.RuleContentOutlinePage;
+
+public class RuleContentOutlineTest extends TestCase {
+
+	public void testNodeBuild() {		
+        RuleContentOutlinePage page = new RuleContentOutlinePage( null );
+        String source = "package test;\nexpander foobar.dsl\nimport foo\nfunction void smeg(s) {\n \n}\n";
+        page.populatePackageTreeNode( source );
+        RuleSet ruleSet = page.getRuleSet();
+        Package p = ruleSet.getPackage("test");
+        assertNotNull(p);
+        DroolsElement[] nodes = p.getChildren();
+
+        for ( int i = 0; i < nodes.length; i++ ) {
+            if ( nodes[i] instanceof Function ) {
+                Function func = (Function) nodes[i];
+                assertEquals( "smeg()",
+                              func.getFunctionName() );
+
+            }
+        }
+
+        source = "package test;\n function String foo(String bar) {";
+        page.populatePackageTreeNode( source );
+        p = ruleSet.getPackage("test");
+        assertNotNull(p);
+        Function func = (Function) p.getChildren()[0];
+        assertEquals( "foo()",
+                      func.getFunctionName() );
+
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ReteooLayoutFactoryTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ReteooLayoutFactoryTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ReteooLayoutFactoryTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,224 @@
+package org.drools.eclipse.editors.rete;
+
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.List;
+
+import junit.framework.TestCase;
+
+import org.drools.PackageIntegrationException;
+import org.drools.RuleBase;
+import org.drools.RuleBaseFactory;
+import org.drools.compiler.DrlParser;
+import org.drools.compiler.DroolsParserException;
+import org.drools.compiler.PackageBuilder;
+import org.drools.eclipse.editors.rete.model.ReteGraph;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.reteoo.AlphaNodeVertex;
+import org.drools.reteoo.BaseVertex;
+import org.drools.reteoo.LeftInputAdapterNodeVertex;
+import org.drools.reteoo.ObjectTypeNodeVertex;
+import org.drools.reteoo.ReteVertex;
+import org.drools.reteoo.ReteooRuleBase;
+import org.drools.reteoo.ReteooVisitor;
+import org.drools.reteoo.RuleTerminalNodeVertex;
+import org.drools.rule.Package;
+
+/**
+ * 
+ * Integration-like tests
+ * 
+ * Testing {@link ReteooLayoutFactory}
+ * It is using following components:
+ * {@link Row},
+ * {@link RowList},
+ * org.drools.reteoo.*Vertex,
+ * org.drools.ide.editors.rete.model.*
+ * 
+ * @author Ahti Kitsik
+ *
+ */
+public class ReteooLayoutFactoryTest extends TestCase {
+
+    /**
+     * Constructor.
+     * 
+     * @param name case name
+     */
+    public ReteooLayoutFactoryTest(String name) {
+        super( name );
+    }
+
+    /**
+     * Test method for {@link org.drools.eclipse.editors.rete.ReteooLayoutFactory#calculateReteRows(org.drools.reteoo.BaseVertex)}.
+     * @throws IOException 
+     * @throws DroolsParserException 
+     * @throws PackageIntegrationException 
+     * @throws DroolsParserException 
+     * @throws PackageIntegrationException 
+     */
+    public final void testCalculateReteRows() throws IOException,
+                                             PackageIntegrationException,
+                                             DroolsParserException {
+        ReteGraph graph = new ReteGraph();
+        BaseVertex root = loadRete( graph );
+        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );
+
+        int rownum = rows.getDepth();
+
+        assertEquals( 5,
+                      rownum );
+
+        int[] expectedDepths = new int[]{-1, 0, 1, 2, 3};
+        int[] expectedSizes = new int[]{1, 1, 2, 2, 2};
+
+        for ( int j = 0; j < rownum; j++ ) {
+            final Row row = rows.get( j );
+            final int rowDepth = row.getDepth();
+            assertEquals( expectedDepths[j],
+                          rowDepth );
+            assertEquals( expectedSizes[j],
+                          row.getVertices().size() );
+        }
+
+    }
+
+    /**
+     * Test method for {@link org.drools.eclipse.editors.rete.ReteooLayoutFactory#layoutRowList(org.drools.eclipse.editors.rete.model.ReteGraph, org.drools.eclipse.editors.rete.RowList)}.
+     * 
+     * @throws IOException 
+     * @throws DroolsParserException 
+     * @throws PackageIntegrationException 
+     * @throws DroolsParserException 
+     * @throws PackageIntegrationException 
+     */
+    public final void testLayoutRowList() throws IOException,
+                                         PackageIntegrationException,
+                                         DroolsParserException {
+        ReteGraph graph = new ReteGraph();
+        BaseVertex root = loadRete( graph );
+        final RowList rows = ReteooLayoutFactory.calculateReteRows( root );
+
+        ReteooLayoutFactory.layoutRowList( graph,
+                                           rows );
+
+        final List nodes = graph.getChildren();
+
+        BaseVertex[] yOrder = (BaseVertex[]) nodes.toArray( new BaseVertex[0] );
+        Arrays.sort( yOrder,
+                     new Comparator() {
+                         public int compare(Object o1,
+                                            Object o2) {
+                             BaseVertex v1 = (BaseVertex) o1;
+                             BaseVertex v2 = (BaseVertex) o2;
+                             int y1 = v1.getLocation().y;
+                             int y2 = v2.getLocation().y;
+                             return new Integer( y1 ).compareTo( new Integer( y2 ) );
+                         }
+
+                     } );
+
+        Class[] expectedTypes = new Class[]{ReteVertex.class, ObjectTypeNodeVertex.class, AlphaNodeVertex.class, AlphaNodeVertex.class, LeftInputAdapterNodeVertex.class, LeftInputAdapterNodeVertex.class, RuleTerminalNodeVertex.class,
+                RuleTerminalNodeVertex.class};
+
+        for ( int i = 0; i < yOrder.length; i++ ) {
+            assertEquals( expectedTypes[i],
+                          yOrder[i].getClass() );
+            if ( i > 0 ) {
+                // If current vertex has same type as previous then
+                // y-pos should match and x-pos should not match.                
+                // If type is different then y-pos should *not* match.
+
+                BaseVertex current = yOrder[i];
+                BaseVertex previous = yOrder[i - 1];
+                if ( current.getClass().equals( previous.getClass() ) ) {
+                    assertEquals( current.getLocation().y,
+                                  previous.getLocation().y );
+                    assertNotSame( new Integer( current.getLocation().x ),
+                                   new Integer( previous.getLocation().x ) );
+                } else {
+                    assertNotSame( new Integer( current.getLocation().y ),
+                                   new Integer( previous.getLocation().y ) );
+                }
+            }
+        }
+
+    }
+
+    private BaseVertex loadRete(ReteGraph graph) throws IOException,
+                                                PackageIntegrationException,
+                                                DroolsParserException {
+        final InputStream is = getClass().getClassLoader().getResourceAsStream( "simplerule.drl" );
+        String drl = streamToString( is );
+
+        DrlParser parser = new DrlParser();
+        PackageDescr packageDescr = parser.parse(drl);
+        PackageBuilder builder = new PackageBuilder();
+        builder.addPackage(packageDescr);
+        Package pkg = builder.getPackage();
+		ReteooRuleBase ruleBase = (ReteooRuleBase) RuleBaseFactory.newRuleBase(RuleBase.RETEOO);
+		ruleBase.addPackage(pkg);
+
+        final ReteooVisitor visitor = new ReteooVisitor( graph );
+        visitor.visit( ruleBase );
+
+        BaseVertex root = visitor.getRootVertex();
+        return root;
+    }
+
+    private String streamToString(InputStream is) throws IOException {
+        byte[] buffer = new byte[4096];
+        OutputStream outputStream = new ByteArrayOutputStream();
+
+        while ( true ) {
+            int read = is.read( buffer );
+
+            if ( read == -1 ) {
+                break;
+            }
+
+            outputStream.write( buffer,
+                                0,
+                                read );
+        }
+
+        outputStream.close();
+        is.close();
+
+        return outputStream.toString();
+    }
+
+    /**
+     * Used by simplerule.drl
+     *
+     */
+    public static class Message {
+        public static final int HELLO   = 0;
+        public static final int GOODBYE = 1;
+
+        private String          message;
+
+        private int             status;
+
+        public String getMessage() {
+            return this.message;
+        }
+
+        public void setMessage(final String message) {
+            this.message = message;
+        }
+
+        public int getStatus() {
+            return this.status;
+        }
+
+        public void setStatus(final int status) {
+            this.status = status;
+        }
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ZoomControlTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ZoomControlTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/editors/rete/ZoomControlTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,223 @@
+package org.drools.eclipse.editors.rete;
+
+import java.io.ByteArrayInputStream;
+import java.io.InputStream;
+
+import junit.framework.TestCase;
+
+import org.drools.eclipse.editors.DRLRuleEditor2;
+import org.drools.eclipse.editors.ZoomInAction2;
+import org.drools.eclipse.editors.ZoomOutAction2;
+import org.eclipse.core.filebuffers.manipulation.ContainerCreator;
+import org.eclipse.core.resources.IContainer;
+import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
+import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IWorkspaceRoot;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.NullProgressMonitor;
+import org.eclipse.core.runtime.Path;
+import org.eclipse.gef.ui.actions.ZoomComboContributionItem;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPage;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.ide.IDE;
+
+public class ZoomControlTest extends TestCase {
+
+    private IFile                         fFile1;
+    private IFile                         fFile2;
+
+    private final static IProgressMonitor NULL_MONITOR     = new NullProgressMonitor();
+
+    private static final String           ORIGINAL_CONTENT = "package test\nrule \"a\"\nend\nrule \"b\"\nend";
+
+    public ZoomControlTest(String name) {
+        super( name );
+    }
+
+    private String getOriginalContent() {
+        return ORIGINAL_CONTENT;
+    }
+
+    /*
+     * @see junit.framework.TestCase#setUp()
+     */
+    protected void setUp() throws Exception {
+        IFolder folder = createFolder( "ZoomControlTestProject/multipleEditorTest/" );
+        fFile1 = createFile( folder,
+                             "myfile1.drl",
+                             getOriginalContent() );
+        fFile2 = createFile( folder,
+                             "myfile2.drl",
+                             getOriginalContent() );
+    }
+
+    /*
+     * @see junit.framework.TestCase#tearDown()
+     */
+    protected void tearDown() throws Exception {
+        deleteProject( "ZoomControlTestProject" );
+        fFile1 = null;
+        fFile2 = null;
+    }
+
+    public void testMultipleEditors() throws PartInitException {
+
+        IWorkbench workbench = PlatformUI.getWorkbench();
+        IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+
+        DRLRuleEditor2 part1 = (DRLRuleEditor2) IDE.openEditor( page,
+                                                                fFile1 );
+        DRLRuleEditor2 part2 = (DRLRuleEditor2) IDE.openEditor( page,
+                                                                fFile2 );
+
+        checkVisibility( part1,
+                         part2,
+                         false );
+
+        // Editor1 active
+        page.activate( part1 );
+        checkVisibility( part1,
+                         part2,
+                         false );
+// TODO
+//        part1.setActivePage( 1 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//
+//        part1.setActivePage( 0 );
+//        checkVisibility( part1,
+//                         part2,
+//                         false );
+//
+//        part1.setActivePage( 1 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//
+//        // Editor2 active
+//        page.activate( part2 );
+//        part2.setActivePage( 0 );
+//        checkVisibility( part1,
+//                         part2,
+//                         false );
+//
+//        part2.setActivePage( 1 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//
+//        // Editor1 active
+//        page.activate( part1 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//
+//        // Editor2 active
+//        page.activate( part2 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//
+//        part2.setActivePage( 0 );
+//        checkVisibility( part1,
+//                         part2,
+//                         false );
+//
+//        // Editor1 active
+//        page.activate( part1 );
+//        checkVisibility( part1,
+//                         part2,
+//                         true );
+//        part2.setActivePage( 0 );
+//        checkVisibility( part1,
+//                         part2,
+//                         false );
+
+    }
+
+    public void testSecondEditorAfterFirst() throws PartInitException {
+
+        IWorkbench workbench = PlatformUI.getWorkbench();
+        IWorkbenchPage page = workbench.getActiveWorkbenchWindow().getActivePage();
+
+        DRLRuleEditor2 part1 = (DRLRuleEditor2) IDE.openEditor( page,
+                                                                fFile1 );
+// TODO
+//        // Editor1 active
+//        page.activate( part1 );
+//        part1.setActivePage( 1 );
+//        checkVisibility( part1,
+//                         null,
+//                         true );
+//
+//        DRLRuleEditor2 part2 = (DRLRuleEditor2) IDE.openEditor( page,
+//                                                                fFile2 );
+//        page.activate( part2 );
+//        checkVisibility( part1,
+//                         part2,
+//                         false );
+
+    }
+
+    private void checkVisibility(DRLRuleEditor2 part1,
+                                 DRLRuleEditor2 part2,
+                                 boolean enabled) {
+        if ( part1 != null ) {
+            checkVisibility( part1,
+                             enabled );
+        }
+
+        if ( part2 != null ) {
+            checkVisibility( part2,
+                             enabled );
+        }
+    }
+
+    private void checkVisibility(DRLRuleEditor2 editor,
+                                 boolean enabled) {
+        ZoomInAction2 zoomIn = (ZoomInAction2) editor.getAdapter( ZoomInAction2.class );
+        ZoomOutAction2 zoomOut = (ZoomOutAction2) editor.getAdapter( ZoomOutAction2.class );
+        ZoomComboContributionItem zitem = (ZoomComboContributionItem) editor.getAdapter( ZoomComboContributionItem.class );
+
+        assertEquals( enabled,
+                      zoomIn.isEnabled() );
+        assertEquals( enabled,
+                      zoomOut.isEnabled() );
+        assertEquals( enabled,
+                      zitem.getZoomManager() != null );
+
+    }
+
+    private IFile createFile(IFolder folder,
+                             String name,
+                             String contents) throws CoreException {
+        IFile file = folder.getFile( name );
+        InputStream inputStream = new ByteArrayInputStream( contents.getBytes() );
+        file.create( inputStream,
+                     true,
+                     NULL_MONITOR );
+        return file;
+    }
+
+    private IFolder createFolder(String portableFolderPath) throws CoreException {
+        ContainerCreator creator = new ContainerCreator( ResourcesPlugin.getWorkspace(),
+                                                         new Path( portableFolderPath ) );
+        IContainer container = creator.createContainer( NULL_MONITOR );
+        return (IFolder) container;
+    }
+
+    private void deleteProject(String projectName) throws CoreException {
+        IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot();
+        IProject project = root.getProject( projectName );
+        if ( project.exists() ) project.delete( true,
+                                                true,
+                                                NULL_MONITOR );
+    }
+
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/rule/DRLGenTemplateTest.java
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/rule/DRLGenTemplateTest.java	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/java/org/drools/eclipse/wizard/rule/DRLGenTemplateTest.java	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,50 @@
+package org.drools.eclipse.wizard.rule;
+
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+
+import junit.framework.TestCase;
+
+public class DRLGenTemplateTest extends TestCase {
+    
+    public void testNewRule() throws Exception {
+        DRLGenerator gen = new DRLGenerator();
+        InputStream result = gen.generateRule("myPackage", getClass().getResourceAsStream( "new_rule.drl.template" ));
+        
+        assertNotNull(result);
+        StringBuffer buf = getResult( result );
+        assertTrue(buf.toString().indexOf( "package myPackage" ) > -1);
+        assertFalse(buf.toString().indexOf( "$date$" ) > -1);
+        
+    }
+    
+    public void testNewPackage() throws Exception {
+        DRLGenerator gen = new DRLGenerator();
+        InputStream result = gen.generatePackage("myPackage", true, true, getClass().getResourceAsStream( "new_rule.drl.template" ));
+        
+        assertNotNull(result);
+        StringBuffer buf = getResult( result );
+        assertTrue(buf.toString().indexOf( "package myPackage" ) > -1);
+        assertFalse(buf.toString().indexOf( "$date$" ) > -1);
+        assertFalse(buf.toString().indexOf( "$expander$" ) > -1);
+        assertFalse(buf.toString().indexOf( "$functions$" ) > -1);
+     
+        
+        
+    }
+    
+
+    private StringBuffer getResult(InputStream result) throws IOException {
+        BufferedReader reader = new BufferedReader(new InputStreamReader(result));
+        String line = null;
+        StringBuffer buf = new StringBuffer();
+        while ((line = reader.readLine())  != null) {
+            buf.append(line + "\n");
+        }
+        return buf;
+    }
+    
+    
+}

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/debug.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/debug.drl	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/debug.drl	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+package com.sample
+ 
+global String s
+global java.util.List list
+
+rule "ActivationCreator"
+    when
+        o: String()
+    then
+        list.add(o);
+end

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/simplerule.drl
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/simplerule.drl	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/src/test/resources/simplerule.drl	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,24 @@
+package org.drools.examples
+
+// Rules for ReteooLayoutFactoryTest
+
+import org.drools.eclipse.editors.rete.ReteooLayoutFactoryTest.Message;
+
+rule "Hello World"
+        when
+                m : Message( status == Message.HELLO, message : message )
+        then
+                System.out.println( message );
+                m.setMessage( "Goodbye cruel world" );
+                m.setStatus( Message.GOODBYE );
+                update( m );
+end
+
+rule "GoodBye"
+        no-loop true
+        when
+                m : Message( status == Message.GOODBYE, message : message )
+        then
+                System.out.println( message );
+                m.setMessage( message );
+end

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/test.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/test.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test/test.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,46 @@
+<?xml version="1.0"?>
+<project name="testsuite" default="run" basedir="."> 
+  <property name="eclipse-home" value="${baseLocation}"/>
+  <property name="plugin-name" value="org.drools.eclipse"/>
+  <property name="library-file" location="${eclipse-home}/plugins/org.eclipse.test_3.2.0/library.xml"/>
+  
+  <!-- This target holds all initialization code that needs to be done for
+       all tests that are to be run. Initialization for individual tests
+       should be done within the body of the suite target. -->
+  <target name="init">
+    <tstamp/>
+    <delete>
+      <fileset dir="${eclipse-home}" includes="org*.xml"/>
+    </delete>
+  </target>
+  
+  <!-- This target defines the tests that need to be run. -->
+  <target name="suite">
+    <property name="test-workspace" location="${eclipse-home}/test-workspace"/>
+    
+    <delete dir="${test-workspace}" quiet="true"/>
+    
+    <ant target="ui-test" antfile="${library-file}" dir="${eclipse-home}">
+      <property name="data-dir" value="${test-workspace}"/>
+      <property name="plugin-name" value="${plugin-name}"/>
+      <property name="classname" value="org.drools.eclipse.AllTests"/>
+    </ant>           
+  </target>
+  
+  <!-- This target holds code to cleanup the testing environment after
+       after all of the tests have been run. We can use this target to
+       delete temporary files that have been created. -->
+  <target name="cleanup">
+  
+  </target>
+  
+  <!-- This target runs the test suite. Any actions that need to happen
+       after all the tests have been run should go here. -->
+  <target name="run" depends="init,suite,cleanup">
+    <copy todir="${base}/surefire-reports">
+      <fileset dir="${eclipse-home}" includes="org*.xml"/>
+    </copy>    
+    
+    <rename src="${base}/surefire-reports/org.drools.eclipse.AllTests.xml" dest="${base}/surefire-reports/TEST-org.drools.eclipse.AllTests.xml"/>
+  </target>
+</project>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/.project	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>drools-eclipse-test-feature</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+	</buildSpec>
+	<natures>
+	</natures>
+</projectDescription>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/build.properties
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/build.properties	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/build.properties	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1 @@
+bin.includes = feature.xml

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/feature.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/feature.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/feature.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<feature
+      id="org.drools.eclipse.test-feature"
+      label="JBossRules Feature"
+      version="4.0.3.SNAPSHOT"
+      provider-name="JBoss, Inc.">
+
+   <description url="http://www.example.com/description">
+      [Enter Feature Description here.]
+   </description>
+
+   <copyright url="http://www.example.com/copyright">
+      [Enter Copyright Description here.]
+   </copyright>
+
+   <license url="http://www.example.com/license">
+      [Enter License Description here.]
+   </license>
+
+   <plugin
+         id="org.drools.eclipse.test"
+         download-size="0"
+         install-size="0"
+         version="4.0.3.SNAPSHOT"/>
+
+</feature>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/pom.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/drools-eclipse-test-feature/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,25 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/P
+OM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+        <modelVersion>4.0.0</modelVersion>
+        <groupId>drools</groupId>
+        <artifactId>drools-eclipse-test-feature</artifactId>
+        <packaging>eclipse-feature</packaging>
+        <version>1.0-SNAPSHOT</version>
+        <build>
+                <plugins>
+                        <plugin>
+                                <groupId>org.codehaus.tycho</groupId>
+                                <artifactId>maven-osgi-lifecycle-plugin</artifactId>
+                                <extensions>true</extensions>
+                        </plugin>
+                </plugins>
+        </build>
+  <dependencies>
+    <dependency>
+      <groupId>drools</groupId>
+      <artifactId>drools-eclipse-plugin</artifactId>
+      <version>1.0-SNAPSHOT</version>
+    </dependency>
+  </dependencies>
+
+</project>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/genericTargets.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/genericTargets.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/genericTargets.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,175 @@
+<project name="Generic Build Targets" default="noDefault">
+
+<!-- Properties that must be passed to this script:
+	buildDirectory
+	id
+	type
+	ignoreTagInfo
+	recursiveGeneration
+	workingDirectory
+	configInfo
+-->
+
+<!-- ===================================================================== -->
+<!-- Setup default values -->
+<!--   configs : by default build a platform-independent configuration -->
+<!--   fetchTag : by default use the CVS tags as spec'd in directory.txt -->
+<!-- ===================================================================== -->
+<property name="configs" value="*,*,*"/>
+<property name="fetchTag" value=""/>
+<property name="buildingOSGi" value="true"/>
+<property name="generateJnlp" value="false"/>
+<property name="signJars" value="false"/>
+<property name="generateFeatureVersionSuffix" value="false" />
+<property name="generateVersionsLists" value="true" />
+<property name="groupConfigurations" value="false"/>
+<property name="pluginPath" value=""/>
+<property name="filteredDependencyCheck" value="false"/>
+
+<!-- ===================================================================== -->
+<!-- Fetch a single element (feature, plugin, fragment) -->
+<!-- ===================================================================== -->
+<target name="fetchElement" description="Checking out source from repository..." depends="init">
+	<mkdir dir="${buildDirectory}/features"/>
+	<mkdir dir="${buildDirectory}/plugins"/>
+	<eclipse.fetch
+		elements="${type}@${id}"
+		buildDirectory="${buildDirectory}"
+		directory="${buildDirectory}/directory.txt"
+		fetchTag="${fetchTag}"
+		configInfo="${configs}"
+		baseLocation="${baseLocation}"
+	/>
+	
+	<!-- Run generated fetch script -->
+	<ant antfile="${buildDirectory}/fetch_${id}.xml">
+		<!-- ************  should not have to spec these  *************** -->
+		<property name="featureOnly" value="true"/>
+		<property name="featureAndPlugins" value="true"/>
+		<property name="featuresRecursively" value="true"/>
+	</ant>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Clean previously built elements -->
+<!-- ===================================================================== -->
+<target name="cleanElement" description="Scrubbing features and plugins of old jars..." depends="init">
+<echo message="${elementPath}"/>
+	<ant antfile="build.xml" dir="${elementPath}" target="clean"/>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Generate a build.xml file for an element -->
+<!-- ===================================================================== -->
+<target name="generateScript" description="Generating build scripts..." depends="init">
+	<eclipse.buildScript 
+		elements="${type}@${id}" 
+		buildDirectory="${buildDirectory}"
+		configInfo="${configs}"
+		baseLocation="${baseLocation}"
+		buildingOSGi="${buildingOSGi}"
+		outputUpdateJars="${outputUpdateJars}"
+		archivesFormat="${archivesFormat}"
+		product="${product}"
+		forceContextQualifier="${forceContextQualifier}"
+		generateJnlp="${generateJnlp}"
+		signJars="${signJars}"
+		generateFeatureVersionSuffix="${generateFeatureVersionSuffix}"
+		significantVersionDigits="${significantVersionDigits}"
+		generatedVersionLength="${generatedVersionLength}"
+		generateVersionsLists="${generateVersionsLists}"
+		groupConfiguration="${groupConfigurations}"
+		pluginPath="${pluginPath}"
+		filteredDependencyCheck="${filteredDependencyCheck}"
+		platformProperties="${platformProperties}"
+	/>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Run build.xml for a single element-->
+<!-- ===================================================================== -->
+<target name="processElement" description="Processing build scripts..." depends="init">
+	<ant antfile="build.xml" dir="${elementPath}" target="build.jars">
+		<property name="target" value="build.jars"/>
+	</ant>
+</target>
+
+<!-- **********************
+1) the gather targets do more than just gather.  These are packaging targets.
+We need to continue ot separate the two concepts (gather and package) as 
+the packaging is different if we wanted to create an update site packaging
+(for example).  The gathers are commented out for now as the new generated
+scripts do not seem to have them.
+
+2) do we really need the ws and os properties?  In all cases?  Do they have to be 
+set here?
+-->
+
+<!-- ===================================================================== -->
+<!-- Gather items listed in bin.includes -->
+<!-- ===================================================================== -->
+<target name="gatherBinaries" description="Gathering binary distribution..." depends="init">
+	<!-- ant antfile="build.xml" dir="${elementPath}" target="gather.bin.parts"/ -->
+	<ant antfile="build.xml" dir="${elementPath}" target="zip.distribution">
+		<property name="os" value="${os}" />
+		<property name="ws" value="${ws}" />	
+	</ant>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Gather source for a build element -->
+<!-- ===================================================================== -->
+<target name="gatherSources" description="Gathering source distribution..." depends="init">
+	<!--suspect:  this call is required to create the *.src.zip inside each plugin-->
+	<ant antfile="build.xml" dir="${elementPath}" target="build.sources">
+		<property name="os" value="${os}" />
+		<property name="ws" value="${ws}" />	
+	</ant>
+	<ant antfile="build.xml" dir="${elementPath}" target="zip.sources">
+		<property name="os" value="${os}" />
+		<property name="ws" value="${ws}" />	
+	</ant>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Gather log files for an element -->
+<!-- Suspect: We just unzip these right away -->
+<!-- ===================================================================== -->
+<target name="gatherLogs" description="Gathering build logs..." depends="init">
+	<ant antfile="build.xml" dir="${elementPath}" target="zip.logs" >
+		<property name="buildDirectory" value="${buildDirectory}" />
+	</ant>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Default target                                                        -->
+<!-- ===================================================================== -->
+<target name="noDefault">
+	<echo message="This file must be called with explicit targets" />
+</target>
+
+<!-- ===================================================================== -->
+<!-- Assemble one build element -->
+<!-- ===================================================================== -->
+<target name="assembleElement" description="Assembling the build..." depends="init">
+	<ant antfile="assemble.${id}.all.xml" dir="${buildDirectory}"/>
+</target>
+
+<!-- ===================================================================== -->
+<!-- Package one build element -->
+<!-- ===================================================================== -->
+<target name="packageElement" description="Packaging the build..." depends="init">
+	<ant antfile="package.${id}.all.xml" dir="${buildDirectory}"/>
+</target>
+	
+<!-- ===================================================================== -->
+<!-- Miscellaneous helper targets -->
+<!-- ===================================================================== -->
+<target name="init">
+	<condition property="elementPath" value="${buildDirectory}/plugins/${id}">
+		<equals arg1="${type}" arg2="fragment" />
+	</condition>
+	<property name="elementPath" value="${buildDirectory}/${type}s/${id}" />
+</target>
+
+</project>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/package.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/package.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/package.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,88 @@
+<project name="packager" default="main" basedir=".">
+	<target name="init">
+		<mkdir dir="${workingDirectory}"/>
+		<mkdir dir="${downloadDirectory}"/>
+		<mkdir dir="${tempDirectory}"/>
+	</target>
+
+	<target name="retrieveMapFiles" unless="skipMaps">
+		<available property="mapsFetched" file="${workingDirectory}/all.maps"/>
+		<ant antfile="${customTargets}" target="getMapFiles" />
+		<concat destfile="${workingDirectory}/all.maps">
+			<fileset dir="${downloadDirectory}" includes="**/*.map"/>
+		</concat>
+	</target>
+
+	<!-- take the content of all.maps, retrieve the files according to the filtering options (config, content), 
+	and generate a directory.txt for the rest of the process using config as a key, and containing the name of the zip and the directory -->
+	<target name="retrieveFiles" unless="skipFetch">
+		<eclipse.fetchFilesGenerator map="${workingDirectory}/all.maps"
+									workingDirectory="${workingDirectory}"
+									configInfo="${config}"
+									contentFilter="${contentFilter}"
+									componentFilter="${componentFilter}"/>
+		<ant antfile="fetch.xml" dir="${workingDirectory}" />
+	</target>
+
+	<!-- Process the directory.txt to create unzipper.xml, and run unzipper.xml-->
+	<target name="prepareResources" unless="skipUnzip">
+		<eclipse.unzipperBuilder 	workingDirectory="${workingDirectory}" 
+											configInfo="${config}"
+											packagePropertyFile="${packagingPropertyFile}"/>
+		<ant antfile="${workingDirectory}/unzipper.xml"/>
+	</target>
+
+	<!-- Generate an assemble script (assemble.xml) for the given features -->
+	<target name="generateAssembleScripts">
+		<echo message="${target}"/>
+		<eclipse.assembler featureList="${featureList}" 
+									workingDirectory="${workingDirectory}" 
+									configInfo="${config}" 
+									baseLocation="${target}" 
+									packagePropertyFile="${packagingPropertyFile}" 
+									deltaPack="${deltaPack}"
+									archivesFormat="${archivesFormat}"
+									filteredDependencyCheck="${filteredDependencyCheck}"
+									normalize="${normalizeWhilePackaging}"/>
+	</target>
+
+	<!-- Call the assemble.xml script -->
+	<target name="callAssembleScripts">
+		<ant antfile="package.all.xml" dir="${workingDirectory}"/>
+	</target>
+
+	<target name="main" description="Start the packager for a given config">
+		<property file="${packagingInfo}/packager.properties" />
+		<property name="customTargets" location="${packagingInfo}/customTargets.xml" />
+		<property name="packagingPropertyFile" location="${packagingInfo}/${packagingProperties}" />
+		
+		<condition property="skipMaps" value="true">
+			<isset property="prefilledTarget" />
+		</condition>
+		<condition property="skipFetch" value="true">
+			<isset property="prefilledTarget" />
+		</condition>
+		<condition property="skipUnzip" value="true">
+			<isset property="prefilledTarget" />
+		</condition>
+		
+		<!-- Compatibility -->
+		<property name="filteredDependencyCheck" value="false"/>
+		<condition property="skipMaps" value="true">
+			<isset property="localMaps"/>
+		</condition>
+		<condition property="target" value="${tempDirectory}/${featurePaths}">
+			<isset property="featurePaths"/>
+		</condition>
+		<property name="normalizeWhilePackaging" value="true"/>
+		
+		<!-- End of compatibility -->
+			
+		<antcall target="init" />
+		<antcall target="retrieveMapFiles"/>
+		<antcall target="retrieveFiles"/>
+		<antcall target="prepareResources"/>
+		<antcall target="generateAssembleScripts"/>
+		<antcall target="callAssembleScripts"/>
+	</target>
+</project>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/pom.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,286 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+
+  <parent>
+    <artifactId>drools</artifactId>
+    <groupId>org.drools</groupId>
+    <version>4.0.3.SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+  <artifactId>drools-eclipse3.3</artifactId>
+  <packaging>pom</packaging>
+
+  <name>Drools :: Eclipse-Plugin3.3</name>
+  <build>
+    <plugins>    
+     <plugin>
+       <artifactId>maven-antrun-plugin</artifactId>
+       <inherited>false</inherited>
+       <executions>
+         <execution>
+           <id>clean lib</id>
+           <phase>clean</phase>
+           <configuration>
+             <tasks>                              
+                <delete>
+                  <fileset dir="drools-eclipse-plugin/lib" includes="**/*.jar" excludes="**/.svn" />                 
+                </delete>
+                <delete dir="drools-eclipse-plugin/help/shared" />     
+                <delete dir="drools-eclipse-plugin/help/eclipse" />     
+             </tasks>
+           </configuration>
+           <goals>
+             <goal>run</goal>
+           </goals>
+         </execution>    
+         
+         <execution>
+           <id>unzip manual</id>
+           <phase>process-resources</phase>
+           <configuration>
+             <tasks>     
+               <unzip src="drools-eclipse-plugin/lib/drools-documentation.jar" dest="drools-eclipse-plugin/help">
+                  <patternset>
+                      <include name="eclipse/**/**"/>
+                      <include name="shared/**/**"/>
+                  </patternset>               
+               </unzip>         
+               
+               <delete dir="drools-eclipse-plugin/lib/drools-documentation.jar" />     
+             </tasks>
+           </configuration>
+           <goals>
+             <goal>run</goal>
+           </goals>           
+         </execution>
+       
+         <execution>
+           <id>compile-plugin</id>
+           <phase>compile</phase>
+           <configuration>
+             <tasks>                              
+                <property name="eclipse.home" value="target/eclipse" />             
+                
+                <property name="localEclipseDrop" value="${basedir}/local-eclipse-drop-mirror" />                
+                <delete  dir="target/eclipse.build" />
+                
+                <ant target="setupLocalEclipse" antfile="setupEclipse.xml">
+                  <property name="localEclipseDrop" value="${localEclipseDrop}" />
+                </ant>
+                 
+                <java jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar"
+                      fork="true"
+                      failonerror="true"
+                      maxmemory="128m">
+                     <arg line="-application org.eclipse.ant.core.antRunner -DmavenCompilePhase=true"/>
+                </java>                 
+             </tasks>
+           </configuration>
+           <goals>
+             <goal>run</goal>
+           </goals>
+         </execution>
+         
+         <execution>
+           <id>test-plugin</id>
+           <phase>test</phase>
+           <configuration>
+             <tasks>            
+               <!-- Determine OS -->
+               <condition property="baseos" value="win32">
+                   <contains string="${os.name}" substring="Windows" />
+               </condition>
+             
+               <condition property="baseos" value="linux">
+                   <contains string="${os.name}" substring="Linux" />
+               </condition>
+               
+               <condition property="baseos" value="macosx">
+                   <contains string="${os.name}" substring="Mac OS X" />
+               </condition>
+               
+               <condition property="baseos" value="win32">
+                   <contains string="${os.name}" substring="Windows" />
+               </condition>        
+             
+               <condition property="baseos" value="aix">
+                   <contains string="${os.name}" substring="AIX" />
+               </condition>    
+               
+               <condition property="baseos" value="hpux">
+                   <contains string="${os.name}" substring="HP-UX" />
+               </condition> 
+               
+               <condition property="baseos" value="solaris">
+                   <contains string="${os.name}" substring="Solaris" />
+               </condition>  
+               
+               <condition property="baseos" value="qnx">
+                   <contains string="${os.name}" substring="QNX" />
+               </condition>                        
+               
+               <!-- Determine WS -->
+               <condition property="basews" value="win32">
+                   <contains string="${os.name}" substring="Windows" />
+               </condition>    
+               
+               <condition property="basews" value="gtk">
+                   <contains string="${os.name}" substring="Linux" />
+               </condition>    
+               
+               <condition property="basews" value="carbon">
+                   <contains string="${os.name}" substring="Mac OS X" />
+               </condition>        
+                   
+               <!-- Determine ARCH -->
+               <condition property="basearch" value="x86">
+                 <or>
+                   <contains string="${os.arch}" substring="i386" />
+                   <contains string="${os.arch}" substring="i686" />
+                   <contains string="${os.arch}" substring="x86" />
+                   <contains string="${os.arch}" substring="Pentium" />
+                 </or>
+               </condition>
+             
+               <condition property="basearch" value="linux">
+                   <contains string="${os.name}" substring="Linux" />
+               </condition>
+               
+               <condition property="basearch" value="ppc">
+                   <contains string="${os.name}" substring="ppc" />
+               </condition>                     
+               
+               <condition property="basearch" value="sparc">
+                   <contains string="${os.name}" substring="sparc" />
+               </condition>                   
+               
+               <condition property="mavenTestPhase" value="" else="-DmavenTestPhase=true">
+                   <isset property="maven.test.skip" />
+               </condition>                
+              
+                <property name="eclipse.home" value="target/eclipse" />                             
+                
+                <echo>-application org.eclipse.ant.core.antRunner -Dbaseos=${baseos} -Dbasews=${basews} -Dbasearch=${basearch} ${mavenTestPhase}</echo>
+                 
+                <java jar="${eclipse.home}/plugins/org.eclipse.equinox.launcher_1.0.1.R33x_v20070828.jar"
+                      fork="true"
+                      failonerror="true"
+                      maxmemory="128m">
+                     <arg line="-application org.eclipse.ant.core.antRunner -Dbaseos=${baseos} -Dbasews=${basews} -Dbasearch=${basearch} ${mavenTestPhase}"/>
+                </java>                 
+             </tasks>
+           </configuration>
+           <goals>
+             <goal>run</goal>
+           </goals>
+         </execution>         
+         
+         <execution>
+           <id>unzip</id>
+           <phase>package</phase>
+           <configuration>
+             <tasks>                
+                <unzip src="target/drools-eclipse3.3-${project.version}.zip" dest="../target/eclipse3.3"/>                         
+             </tasks>
+           </configuration>
+           <goals>
+             <goal>run</goal>
+           </goals>
+         </execution>         
+       </executions>
+     </plugin>
+     
+     <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-dependency-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>copy-dependencies</id>
+            <phase>generate-resources</phase>
+            <goals>
+              <goal>copy-dependencies</goal>
+            </goals>
+            <configuration>
+              <outputDirectory>drools-eclipse-plugin/lib</outputDirectory>
+              <overWriteReleases>true</overWriteReleases>
+              <overWriteSnapshots>true</overWriteSnapshots>
+              <overWriteIfNewer>true</overWriteIfNewer>
+              <stripVersion>true</stripVersion>              
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>     
+    </plugins>
+  </build>
+
+  <repositories>
+    <repository>
+      <id>basedir</id>
+      <url>file://${basedir}/../m2_repo</url>
+    </repository>
+  </repositories>
+
+  <dependencies>
+
+    <!-- this should include core and compiler -->
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-jsr94</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jdt</groupId>
+          <artifactId>core</artifactId>
+        </exclusion>
+
+        <exclusion>
+          <groupId>janino</groupId>
+          <artifactId>janino</artifactId>
+        </exclusion>
+
+        <exclusion>
+          <groupId>jsr94</groupId>
+          <artifactId>jsr94-sigtest</artifactId>
+        </exclusion>
+
+        <exclusion>
+          <groupId>jsr94</groupId>
+          <artifactId>jsr94-tck</artifactId>
+        </exclusion>
+
+      </exclusions>
+    </dependency>
+
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-decisiontables</artifactId>
+      <exclusions>
+        <exclusion>
+          <groupId>org.eclipse.jdt</groupId>
+          <artifactId>core</artifactId>
+        </exclusion>
+
+        <exclusion>
+          <groupId>janino</groupId>
+          <artifactId>janino</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+    <dependency>
+      <groupId>com.thoughtworks.xstream</groupId>
+      <artifactId>xstream</artifactId>
+    </dependency>
+    <dependency>
+      <!-- TODO remove this dependency and change MANIFEST.MF to use xpp3_min.jar (non-optional dep of xstream) -->
+      <groupId>xpp3</groupId>
+      <artifactId>xpp3</artifactId>
+      <scope>runtime</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.drools</groupId>
+      <artifactId>drools-documentation</artifactId>         
+   </dependency>      
+</dependencies>
+
+</project>

Added: labs/jbossrules/branches/4.0.x/drools-eclipse3.3/setupEclipse.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-eclipse3.3/setupEclipse.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/drools-eclipse3.3/setupEclipse.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,125 @@
+<project name="Setup Local  Eclipse" default="setupLocalEclipse">   
+  
+  <property file="build.properties"/>
+
+  <property name="localEclipseDrop" value="${basedir}/local-eclipse-drop-mirror" />   
+ 
+  <!-- set the OS name, make sure each condition is mutally exclusive -->
+	<condition property="download.type" value="win32">
+		<os family="windows" />
+	</condition>	
+			
+	<condition property="download.type" value="macosx-carbon">
+		<and>
+			<os family="mac" />
+			<os family="unix" />
+		</and>
+	</condition>
+	
+	<condition property="download.type" value="linux-gtk">
+		<and>
+			<not>
+				<os family="mac" />
+			</not>
+			<os family="unix" />
+		</and>
+	</condition>		
+	
+	<condition property="download.extension" value="zip">
+		<os family="windows" />
+	</condition>		
+	
+	<condition property="download.extension" value="tar.gz">
+		<or>
+			<os family="mac" />
+			<os family="unix" />
+		</or>
+	</condition>	
+		  		        
+   <condition property="expandTypeZip" value="true">
+       <equals arg1="${download.extension}" arg2="zip" />
+   </condition>   
+
+   <condition property="expandTypeTarGz" value="true">
+       <equals arg1="${download.extension}" arg2="tar.gz" />
+   </condition>   
+   
+  <!-- make sure the directory exists -->   
+  <target name="makeLocalEclipseDropDir">
+    <mkdir dir="${localEclipseDrop}" />    
+  </target>   
+   
+  <target name="getEclipseJar" depends="checkEclipseJar" unless="skipGetEclipseJar">
+    <mkdir dir="${localEclipseDrop}/eclipse/${eclipseBuildRevision}" />    
+    
+    <get usetimestamp="true" src="${eclipseURL}/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-${download.type}.${download.extension}" 
+         dest="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-${download.type}.${download.extension}" /> 
+  </target>  
+  
+  <target name="getTestJar" depends="checkTestJar" unless="skipGetTestJar">
+    <mkdir dir="${localEclipseDrop}/eclipse/${eclipseBuildRevision}" />    
+    <get usetimestamp="true" src="${eclipseURL}/${eclipseBuildRevision}/eclipse-test-framework-${eclipseBuildId}.zip"
+         dest="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-test-framework-${eclipseBuildId}.zip"/>    
+  </target>
+
+  <target name="getGefJar" depends="checkGefJar" unless="skipGetGefJar">
+    <mkdir dir="${localEclipseDrop}/tools/gef/${eclipseGefBuildRevision}" />    
+    <get usetimestamp="true" src="${eclipseGefURL}/${eclipseGefBuildRevision}/GEF-runtime-${eclipseBuildId}.zip" 
+         dest="${localEclipseDrop}/tools/gef/${eclipseGefBuildRevision}/GEF-runtime-${eclipseBuildId}.zip" />
+  </target>      
+
+	<target name="checkEclipseJar">	
+		<available file="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-win32.zip" property="skipGetEclipseJar" />
+	</target>
+	
+	<target name="checkTestJar">	
+		<available file="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-test-framework-${eclipseBuildId}.zip" property="skipGetTestJar" />
+	</target>	
+		
+	<target name="checkGefJar">	
+		<available file="${localEclipseDrop}/tools/gef/${eclipseGefBuildRevision}/GEF-runtime-${eclipseBuildId}.zip" property="skipGetGefJar" />
+	</target>	  
+
+  <target name="setupLocalEclipseDrop"  depends="checkEclipseDir" unless="skipUnzipEclipseJars">
+    <antcall target="makeLocalEclipseDropDir" />
+    <antcall target="getEclipseJar" />
+    <antcall target="getTestJar" />    
+    <antcall target="getGefJar" />      
+  </target>
+  
+  <target name="expandEclipseJars">   
+    <antcall target="unzipEclipse" />	
+    <antcall target="untarEclipse" />
+    
+    <unzip dest="${base}" overwrite="true"
+           src="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-test-framework-${eclipseBuildId}.zip" />   				
+				
+		<unzip dest="${base}" overwrite="true" 
+		       src="${localEclipseDrop}/tools/gef/${eclipseGefBuildRevision}/GEF-runtime-${eclipseBuildId}.zip" />				         
+  </target>    
+  
+  <target name="unzipEclipse" if="expandTypeZip">
+  	<unzip dest="${base}" overwrite="true" 
+  	       src="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-${download.type}.${download.extension}" />  
+  </target>
+
+  <target name="untarEclipse" if="expandTypeTarGz">
+	<gunzip src="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-${download.type}.tar.gz"/>
+	<untar dest="${base}" src="${localEclipseDrop}/eclipse/${eclipseBuildRevision}/eclipse-SDK-${eclipseBuildId}-${download.type}.tar" />
+  </target>
+  
+  <target name="checkEclipseDir">
+    <available file="${base}/eclipse" property="skipUnzipEclipseJars" />
+  </target>
+    
+  <target name="setupLocalEclipse" depends="checkLocalEclipse" unless="skipSetupLocalEcipse">  
+    <echo>local eclipse drop mirror - ${localEclipseDrop}</echo>
+    <antcall target="setupLocalEclipseDrop" />
+    <antcall target="expandEclipseJars" />
+  </target>	
+  
+  <target name="checkLocalEclipse">
+      <available type="dir" file="${base}/eclipse" property="skipSetupLocalEcipse" />
+  </target>
+  
+</project>

Modified: labs/jbossrules/branches/4.0.x/drools-jbrms/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-jbrms/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-jbrms/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,56 +5,56 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="src" path="/drools-core"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.3.1.ga/hibernate-entitymanager-3.3.1.ga.jar"/>
-  <classpathentry kind="var" path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar" sourcepath="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.3.0/slf4j-api-1.3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-text-extractors/1.3/jackrabbit-text-extractors-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
   <classpathentry kind="var" path="M2_REPO/emma/emma/2.0.5312/emma-2.0.5312.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jboss/javassist/3.3.ga/javassist-3.3.ga.jar"/>
-  <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-commons-annotations/3.0.0.ga/hibernate-commons-annotations-3.0.0.ga.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar" sourcepath="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/com/google/gwt/gwt-servlet/1.4.60/gwt-servlet-1.4.60.jar"/>
-  <classpathentry kind="src" path="/drools-repository"/>
-  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar" sourcepath="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/jcr/jcr/1.0/jcr-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar" sourcepath="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-api/1.3/jackrabbit-api-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/tmatesoft/svnkit/1.1.2/svnkit-1.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-jcr-commons/1.3/jackrabbit-jcr-commons-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/thoughtworks/xstream/xstream/1.2.2/xstream-1.2.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-text-extractors/1.3/jackrabbit-text-extractors-1.3.jar"/>
   <classpathentry kind="var" path="M2_REPO/asm/asm-attrs/1.5.3/asm-attrs-1.5.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar" sourcepath="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
   <classpathentry kind="var" path="M2_REPO/jboss/jboss-common-core/2.0.4.GA/jboss-common-core-2.0.4.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.0.0-SNAPSHOT/jboss-seam-2.0.0-SNAPSHOT.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar" sourcepath="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/asm/asm/1.5.3/asm-1.5.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.1/commons-io-1.1.jar" sourcepath="M2_REPO/commons-io/commons-io/1.1/commons-io-1.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-core/1.3/jackrabbit-core-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.2.4.sp1/hibernate-3.2.4.sp1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/derby/derby/10.2.1.6/derby-10.2.1.6.jar"/>
-  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6/dom4j-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-entitymanager/3.3.1.ga/hibernate-entitymanager-3.3.1.ga.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+  <classpathentry kind="var" path="M2_REPO/com/google/gwt/gwt-servlet/1.4.60/gwt-servlet-1.4.60.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/tmatesoft/svnkit/1.1.2/svnkit-1.1.2.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-api/1.3/jackrabbit-api-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/jcr/jcr/1.0/jcr-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/seam/jboss-el/2.0.0.CR1/jboss-el-2.0.0.CR1.jar"/>
+  <classpathentry kind="src" path="/drools-core"/>
   <classpathentry kind="var" path="M2_REPO/javax/el/el-api/1.2/el-api-1.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-annotations/3.3.0.ga/hibernate-annotations-3.3.0.ga.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/jboss/seam/jboss-el/2.0.0.CR1/jboss-el-2.0.0.CR1.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/3.0.0.ga/hibernate-validator-3.0.0.GA.jar"/>
+  <classpathentry kind="src" path="/drools-repository"/>
   <classpathentry kind="var" path="M2_REPO/commons-fileupload/commons-fileupload/1.1.1/commons-fileupload-1.1.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/antlr/antlr/2.7.6/antlr-2.7.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jboss/javassist/3.3.ga/javassist-3.3.ga.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/el/el-ri/1.2/el-ri-1.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar" sourcepath="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar" sourcepath="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/transaction/jta/1.0.1B/jta-1.0.1B.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.3.0/slf4j-log4j12-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.3.0/slf4j-api-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/cglib/cglib/2.1_3/cglib-2.1_3.jar"/>
   <classpathentry kind="src" path="/drools-decisiontables"/>
+  <classpathentry kind="var" path="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/jboss/seam/jboss-seam/2.0.0.CR2/jboss-seam-2.0.0.CR2.jar"/>
   <classpathentry kind="var" path="M2_REPO/javassist/javassist/3.4.GA/javassist-3.4.GA.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate-validator/3.0.0.GA/hibernate-validator-3.0.0.GA.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-core/1.3/jackrabbit-core-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/dom4j/dom4j/1.6/dom4j-1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-io/commons-io/1.1/commons-io-1.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/jexcelapi/jxl/2.4.2/jxl-2.4.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xpp3/xpp3_min/1.1.3.4.O/xpp3_min-1.1.3.4.O.jar"/>
+  <classpathentry kind="var" path="M2_REPO/javax/servlet/servlet-api/2.3/servlet-api-2.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.3.0/slf4j-log4j12-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/derby/derby/10.2.1.6/derby-10.2.1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/hibernate/hibernate/3.2.4.sp1/hibernate-3.2.4.sp1.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-jbrms/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-jbrms/.project	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-jbrms/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -2,8 +2,8 @@
   <name>drools-jbrms</name>
   <comment>A rule production system</comment>
   <projects>
+    <project>drools-compiler</project>
     <project>drools-core</project>
-    <project>drools-compiler</project>
     <project>drools-repository</project>
     <project>drools-decisiontables</project>
   </projects>

Modified: labs/jbossrules/branches/4.0.x/drools-jsr94/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-jsr94/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-jsr94/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,18 +5,18 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+  <classpathentry kind="src" path="/drools-core"/>
+  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jsr94/jsr94-sigtest/1.1/jsr94-sigtest-1.1.jar"/>
   <classpathentry kind="src" path="/drools-decisiontables"/>
+  <classpathentry kind="src" path="/drools-compiler"/>
+  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar"/>
   <classpathentry kind="var" path="M2_REPO/janino/janino/2.5.10/janino-2.5.10.jar"/>
-  <classpathentry kind="src" path="/drools-core"/>
-  <classpathentry kind="var" path="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2.jar" sourcepath="M2_REPO/xml-apis/xml-apis/1.0.b2/xml-apis-1.0.b2-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/jsr94/jsr94/1.1/jsr94-1.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/jexcelapi/jxl/2.4.2/jxl-2.4.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jsr94/jsr94-sigtest/1.1/jsr94-sigtest-1.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/jsr94/jsr94-tck/1.0.3/jsr94-tck-1.0.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/mvel/mvel14/1.2.8/mvel14-1.2.8.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/antlr/antlr-runtime/3.0/antlr-runtime-3.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/eclipse/jdt/core/3.2.3.v_686_R32x/core-3.2.3.v_686_R32x.jar"/>
-  <classpathentry kind="src" path="/drools-compiler"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/jsr94/jsr94/1.1/jsr94-1.1.jar"/>
 </classpath>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/drools-jsr94/.project
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-jsr94/.project	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-jsr94/.project	2007-10-22 17:56:29 UTC (rev 15989)
@@ -2,8 +2,8 @@
   <name>drools-jsr94</name>
   <comment>A rule production system</comment>
   <projects>
+    <project>drools-core</project>
     <project>drools-decisiontables</project>
-    <project>drools-core</project>
     <project>drools-compiler</project>
   </projects>
   <buildSpec>

Modified: labs/jbossrules/branches/4.0.x/drools-repository/.classpath
===================================================================
--- labs/jbossrules/branches/4.0.x/drools-repository/.classpath	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/drools-repository/.classpath	2007-10-22 17:56:29 UTC (rev 15989)
@@ -5,20 +5,20 @@
   <classpathentry kind="src" path="src/test/resources" output="target/test-classes" excluding="**/*.java"/>
   <classpathentry kind="output" path="target/classes"/>
   <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-text-extractors/1.3/jackrabbit-text-extractors-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar" sourcepath="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/derby/derby/10.2.1.6/derby-10.2.1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar"/>
+  <classpathentry kind="var" path="M2_REPO/concurrent/concurrent/1.3.4/concurrent-1.3.4.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.3.0/slf4j-api-1.3.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/lucene/lucene-core/2.0.0/lucene-core-2.0.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar" sourcepath="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0-sources.jar"/>
+  <classpathentry kind="var" path="M2_REPO/xerces/xercesImpl/2.4.0/xercesImpl-2.4.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/javax/jcr/jcr/1.0/jcr-1.0.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.3.0/slf4j-log4j12-1.3.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-core/1.3/jackrabbit-core-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/derby/derby/10.2.1.6/derby-10.2.1.6.jar"/>
+  <classpathentry kind="var" path="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-api/1.3/jackrabbit-api-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar"/>
+  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-jcr-commons/1.3/jackrabbit-jcr-commons-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-api/1.3/jackrabbit-api-1.3.jar"/>
-  <classpathentry kind="var" path="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13.jar" sourcepath="M2_REPO/log4j/log4j/1.2.13/log4j-1.2.13-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1.jar" sourcepath="M2_REPO/commons-collections/commons-collections/3.1/commons-collections-3.1-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210.jar" sourcepath="M2_REPO/ch/ethz/ganymed/ganymed-ssh2/build210/ganymed-ssh2-build210-sources.jar"/>
-  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-api/1.3.0/slf4j-api-1.3.0.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/apache/jackrabbit/jackrabbit-text-extractors/1.3/jackrabbit-text-extractors-1.3.jar"/>
+  <classpathentry kind="var" path="M2_REPO/org/slf4j/slf4j-log4j12/1.3.0/slf4j-log4j12-1.3.0.jar"/>
   <classpathentry kind="var" path="M2_REPO/org/tmatesoft/svnkit/1.1.2/svnkit-1.1.2.jar"/>
-  <classpathentry kind="var" path="M2_REPO/junit/junit/3.8.1/junit-3.8.1.jar" sourcepath="M2_REPO/junit/junit/3.8.1/junit-3.8.1-sources.jar"/>
 </classpath>
\ No newline at end of file

Added: labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar
===================================================================
(Binary files differ)


Property changes on: labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.jar
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Added: labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.pom
===================================================================
--- labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.pom	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/m2_repo/org/mvel/mvel14/1.2.10/mvel14-1.2.10.pom	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,47 @@
+<?xml version="1.0" encoding="UTF-8"?><project>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.mvel</groupId>
+
+  <artifactId>mvel14</artifactId>
+
+  <name>mvel</name>
+
+  <version>1.2.10</version>
+
+  <description></description>
+
+  <inceptionYear>2005</inceptionYear>
+
+  <url>http://wiki.mvflex.org/index.php?title=MVFLEX_Expression_Language</url>
+
+  <issueManagement>
+    <url>http://jira.codehaus.org/browse/MVEL</url>
+  </issueManagement>
+
+  <licenses>
+    <license>
+      <name>The Apache Software License, Version 2.0</name>
+      <url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
+      <distribution>repo</distribution>
+    </license>
+  </licenses>
+
+  <mailingLists/>
+
+  <scm>
+    <connection>scm:svn:http://svn.codehaus.org/mvel/</connection>
+    <developerConnection>scm:svn:https://svn.codehaus.org/mvel/</developerConnection>
+    <url>http://svn.mvel.codehaus.org/</url>
+  </scm>
+
+  <organization>
+    <name>Codehaus</name>
+    <url>http://codehaus.org</url>
+  </organization>
+
+  <build>
+    <sourceDirectory></sourceDirectory>
+    <testSourceDirectory></testSourceDirectory>
+  </build>
+</project>
\ No newline at end of file

Modified: labs/jbossrules/branches/4.0.x/pom.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/pom.xml	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/pom.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -278,7 +278,8 @@
             <property><name>eclipse</name></property>
         </activation>
         <modules>
-            <module>drools-eclipse</module>
+            <module>drools-eclipse3.2</module>
+            <module>drools-eclipse3.3</module>
         </modules>
     </profile>
     <profile>
@@ -387,7 +388,8 @@
             <descriptor>src/main/assembly/bin.xml</descriptor>
             <descriptor>src/main/assembly/src.xml</descriptor>
             <descriptor>src/main/assembly/brms.xml</descriptor>
-            <descriptor>src/main/assembly/eclipse.xml</descriptor>
+            <descriptor>src/main/assembly/eclipse3.2.xml</descriptor>
+            <descriptor>src/main/assembly/eclipse3.3.xml</descriptor>
             <descriptor>src/main/assembly/examples.xml</descriptor>
           </descriptors>
         </configuration>
@@ -732,7 +734,7 @@
 	    <dependency>
         <groupId>org.mvel</groupId>
         <artifactId>mvel14</artifactId>
-        <version>1.2.8</version>
+        <version>1.2.10</version>
       </dependency>
 
       <!-- drools-compiler -->

Deleted: labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse.xml	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -1,26 +0,0 @@
-<assembly>
-  <id>eclipse</id>
-  <formats>
-    <format>zip</format>
-  </formats>
-  
-  <includeBaseDirectory>false</includeBaseDirectory>
-  
-  <fileSets>
-    <fileSet>
-      <includes>
-        <include>LICENSE-ASL-2.0.txt</include>
-        <include>JBossORG-EULA.txt</include>
-        <include>README_DEPENDENCIES.txt</include>
-      </includes>
-    </fileSet>
-      
-    <fileSet>
-      <directory>target/eclipse</directory>
-      <outputDirectory></outputDirectory>
-      <includes>
-         <include>**/**</include>
-      </includes>      
-    </fileSet>
-  </fileSets>
-</assembly>

Added: labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.2.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.2.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.2.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,26 @@
+<assembly>
+  <id>eclipse</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  
+  <includeBaseDirectory>false</includeBaseDirectory>
+  
+  <fileSets>
+    <fileSet>
+      <includes>
+        <include>LICENSE-ASL-2.0.txt</include>
+        <include>JBossORG-EULA.txt</include>
+        <include>README_DEPENDENCIES.txt</include>
+      </includes>
+    </fileSet>
+      
+    <fileSet>
+      <directory>target/eclipse3.2</directory>
+      <outputDirectory></outputDirectory>
+      <includes>
+         <include>**/**</include>
+      </includes>      
+    </fileSet>
+  </fileSets>
+</assembly>

Copied: labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.3.xml (from rev 15973, labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse.xml)
===================================================================
--- labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.3.xml	                        (rev 0)
+++ labs/jbossrules/branches/4.0.x/src/main/assembly/eclipse3.3.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -0,0 +1,26 @@
+<assembly>
+  <id>eclipse</id>
+  <formats>
+    <format>zip</format>
+  </formats>
+  
+  <includeBaseDirectory>false</includeBaseDirectory>
+  
+  <fileSets>
+    <fileSet>
+      <includes>
+        <include>LICENSE-ASL-2.0.txt</include>
+        <include>JBossORG-EULA.txt</include>
+        <include>README_DEPENDENCIES.txt</include>
+      </includes>
+    </fileSet>
+      
+    <fileSet>
+      <directory>target/eclipse3.3</directory>
+      <outputDirectory></outputDirectory>
+      <includes>
+         <include>**/**</include>
+      </includes>      
+    </fileSet>
+  </fileSets>
+</assembly>

Modified: labs/jbossrules/branches/4.0.x/update-version.xml
===================================================================
--- labs/jbossrules/branches/4.0.x/update-version.xml	2007-10-22 17:22:15 UTC (rev 15988)
+++ labs/jbossrules/branches/4.0.x/update-version.xml	2007-10-22 17:56:29 UTC (rev 15989)
@@ -15,23 +15,23 @@
       <replaceregexp match="Bundle-Version: ${current}"
                      replace="Bundle-Version: ${new}"
                      byline="true">
-          <fileset dir="drools-eclipse" includes="drools-eclipse-plugin/META-INF/MANIFEST.MF, drools-eclipse-test/META-INF/MANIFEST.MF"/>        
+          <fileset dir="drools-eclipse*" includes="drools-eclipse-plugin/META-INF/MANIFEST.MF, drools-eclipse-test/META-INF/MANIFEST.MF"/>        
       </replaceregexp>       
 
       <replaceregexp match="Fragment-Host: org.drools.eclipse;bundle-version=&#34;${current}&#34;"
                      replace="Fragment-Host: org.drools.eclipse;bundle-version=&#34;${new}&#34;"
                      byline="true">
-          <fileset dir="drools-eclipse" includes="drools-eclipse-plugin/META-INF/MANIFEST.MF, drools-eclipse-test/META-INF/MANIFEST.MF"/>        
+          <fileset dir="drools-eclipse*" includes="drools-eclipse-plugin/META-INF/MANIFEST.MF, drools-eclipse-test/META-INF/MANIFEST.MF"/>        
       </replaceregexp>       
       
       <replaceregexp match="version=&#34;${current}&#34;"
                      replace="version=&#34;${new}&#34;"
                      byline="true">
-          <fileset dir="drools-eclipse" includes="drools-eclipse-feature/feature.xml, drools-eclipse-test-feature/feature.xml"/>        
+          <fileset dir="drools-eclipse*" includes="drools-eclipse-feature/feature.xml, drools-eclipse-test-feature/feature.xml"/>        
       </replaceregexp>                     
                      
     
-      <replaceregexp file="drools-eclipse/build.properties"
+      <replaceregexp file="drools-eclipse*/build.properties"
                      match="droolsVersion=${current}"
                      replace="droolsVersion=${new}"
                      byline="true" />    




More information about the jboss-svn-commits mailing list