[jboss-svn-commits] JBL Code SVN: r24221 - in labs/jbossrules/trunk: drools-eclipse/org.drools.eclipse and 6 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Dec 2 17:55:45 EST 2008


Author: KrisVerlaenen
Date: 2008-12-02 17:55:45 -0500 (Tue, 02 Dec 2008)
New Revision: 24221

Added:
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsFlowNodesPreferencePage.java
Modified:
   labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/plugin.xml
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/skin/DefaultSkinProvider.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsProjectPreferencePage.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsRuntimesPreferencePage.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
   labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java
   labs/jbossrules/trunk/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/session/SingleSessionCommandService.java
Log:
JBRULES-1882: Make Drools Flow nodes configurable
 - added Drools Flow Nodes preference page

Modified: labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java
===================================================================
--- labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-core/src/main/java/org/drools/impl/KnowledgeBaseImpl.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -80,6 +80,10 @@
         ruleBase = new ReteooRuleBase();
         ruleBase.readExternal( in );
     }
+    
+    public RuleBase getRuleBase() {
+    	return ruleBase;
+    }
 
     public void addEventListener(KnowledgeBaseEventListener listener) {
         KnowledgeBaseEventListenerWrapper wrapper = new KnowledgeBaseEventListenerWrapper( this,

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/plugin.xml	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/plugin.xml	2008-12-02 22:55:45 UTC (rev 24221)
@@ -218,6 +218,11 @@
             class="org.drools.eclipse.preferences.DroolsRuntimesPreferencePage"
             id="org.drools.eclipse.preferences.DroolsRuntimesPreferencePage">
       </page>
+      <page name="Drools Flow nodes"
+            category="org.drools.eclipse.preferences.DroolsPreferencePage"
+            class="org.drools.eclipse.preferences.DroolsFlowNodesPreferencePage"
+            id="org.drools.eclipse.preferences.DroolsFlowNodesPreferencePage">
+      </page>
    </extension>
 
    <extension point="org.eclipse.ui.propertyPages">

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/DroolsEclipsePlugin.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -250,6 +250,10 @@
                           "default" );
         store.setDefault( IDroolsConstants.ALLOW_NODE_CUSTOMIZATION,
         				  false );
+        store.setDefault( IDroolsConstants.INTERNAL_API,
+        				  2 );
+        store.setDefault( IDroolsConstants.FLOW_NODES, 
+        		          "1111111111111" );
     }
 
     public DRLInfo parseResource(IResource resource,

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowPaletteFactory.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -50,7 +50,10 @@
         String skin = DroolsEclipsePlugin.getDefault().getPreferenceStore().getString(IDroolsConstants.SKIN);
         SkinProvider skinProvider = SkinManager.getInstance().getSkinProvider(skin);
         categories.add(skinProvider.createComponentsDrawer());
-        categories.add(createWorkNodesDrawer());
+        String flowNodes = DroolsEclipsePlugin.getDefault().getPluginPreferences().getString(IDroolsConstants.FLOW_NODES);
+        if (flowNodes.charAt(12) == '1') {
+            categories.add(createWorkNodesDrawer());
+        }
         return categories;
     }
     

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/skin/DefaultSkinProvider.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/skin/DefaultSkinProvider.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/flow/ruleflow/skin/DefaultSkinProvider.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -37,6 +37,7 @@
 import org.drools.eclipse.flow.ruleflow.editor.editpart.JoinEditPart.JoinFigureInterface;
 import org.drools.eclipse.flow.ruleflow.editor.editpart.SplitEditPart.SplitFigureInterface;
 import org.drools.eclipse.flow.ruleflow.editor.editpart.WorkItemEditPart.WorkItemFigureInterface;
+import org.drools.eclipse.preferences.IDroolsConstants;
 import org.eclipse.draw2d.IFigure;
 import org.eclipse.gef.palette.CombinedTemplateCreationEntry;
 import org.eclipse.gef.palette.ConnectionCreationToolEntry;
@@ -50,6 +51,8 @@
 public class DefaultSkinProvider implements SkinProvider {
 	
     public PaletteContainer createComponentsDrawer() {
+    	
+    	String flowNodes = DroolsEclipsePlugin.getDefault().getPluginPreferences().getString(IDroolsConstants.FLOW_NODES);
 
         PaletteDrawer drawer = new PaletteDrawer("Components", null);
 
@@ -75,125 +78,149 @@
         );
         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);
+        if (flowNodes.charAt(0) == '1') {
+	        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);
+        if (flowNodes.charAt(1) == '1') {
+        	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);
+        if (flowNodes.charAt(2) == '1') {
+	        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(
-            "Event Wait",
-            "Create a new Event Wait",
-            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);
+        if (flowNodes.charAt(3) == '1') {
+	        combined = new CombinedTemplateCreationEntry(
+	            "Event Wait",
+	            "Create a new Event Wait",
+	            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",
-            SubProcessWrapper.class,
-            new SimpleFactory(SubProcessWrapper.class),
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif")), 
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/process.gif"))
-        );
-        entries.add(combined);
+        if (flowNodes.charAt(4) == '1') {
+	        combined = new CombinedTemplateCreationEntry(
+	            "SubFlow",
+	            "Create a new SubFlow",
+	            SubProcessWrapper.class,
+	            new SimpleFactory(SubProcessWrapper.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);
+        if (flowNodes.charAt(5) == '1') {
+        	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);
+        }
                       
-        combined = new CombinedTemplateCreationEntry(
-            "Timer",
-            "Create a new Timer",
-            TimerWrapper.class,
-            new SimpleFactory(TimerWrapper.class),
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/timer.gif")), 
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/timer.gif"))
-        );
-        entries.add(combined);
+        if (flowNodes.charAt(6) == '1') {
+	        combined = new CombinedTemplateCreationEntry(
+	            "Timer",
+	            "Create a new Timer",
+	            TimerWrapper.class,
+	            new SimpleFactory(TimerWrapper.class),
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/timer.gif")), 
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/timer.gif"))
+	        );
+	        entries.add(combined);
+        }
                       
-        combined = new CombinedTemplateCreationEntry(
-            "Fault",
-            "Create a new Fault",
-            FaultNodeWrapper.class,
-            new SimpleFactory(FaultNodeWrapper.class),
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/fault.gif")), 
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/fault.gif"))
-        );
-        entries.add(combined);
+        if (flowNodes.charAt(7) == '1') {
+	        combined = new CombinedTemplateCreationEntry(
+	            "Fault",
+	            "Create a new Fault",
+	            FaultNodeWrapper.class,
+	            new SimpleFactory(FaultNodeWrapper.class),
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/fault.gif")), 
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/fault.gif"))
+	        );
+	        entries.add(combined);
+        }
                           
-        combined = new CombinedTemplateCreationEntry(
-		    "Event",
-		    "Create a new Event Node",
-		    EventNodeWrapper.class,
-		    new SimpleFactory(EventNodeWrapper.class),
-		    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/event.gif")), 
-		    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/event.gif"))
-		);
-		entries.add(combined);
+        if (flowNodes.charAt(8) == '1') {
+        	combined = new CombinedTemplateCreationEntry(
+			    "Event",
+			    "Create a new Event Node",
+			    EventNodeWrapper.class,
+			    new SimpleFactory(EventNodeWrapper.class),
+			    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/event.gif")), 
+			    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/event.gif"))
+			);
+			entries.add(combined);
+        }
 	                    
-        combined = new CombinedTemplateCreationEntry(
-            "Human Task",
-            "Create a new Human Task",
-            HumanTaskNodeWrapper.class,
-            new SimpleFactory(HumanTaskNodeWrapper.class),
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/human_task.gif")), 
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/human_task.gif"))
-        );
-        entries.add(combined);
+        if (flowNodes.charAt(9) == '1') {
+        	combined = new CombinedTemplateCreationEntry(
+	            "Human Task",
+	            "Create a new Human Task",
+	            HumanTaskNodeWrapper.class,
+	            new SimpleFactory(HumanTaskNodeWrapper.class),
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/human_task.gif")), 
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/human_task.gif"))
+	        );
+	        entries.add(combined);
+        }
                               
-        combined = new CombinedTemplateCreationEntry(
-            "Composite",
-            "Create a new Composite Node",
-            CompositeContextNodeWrapper.class,
-            new SimpleFactory(CompositeContextNodeWrapper.class),
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")), 
-            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
-        );
-        entries.add(combined);
+        if (flowNodes.charAt(10) == '1') {
+	        combined = new CombinedTemplateCreationEntry(
+	            "Composite",
+	            "Create a new Composite Node",
+	            CompositeContextNodeWrapper.class,
+	            new SimpleFactory(CompositeContextNodeWrapper.class),
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")), 
+	            ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
+	        );
+	        entries.add(combined);
+        }
                           
-	    combined = new CombinedTemplateCreationEntry(
-		    "For Each",
-		    "Create a new ForEach Node",
-		    ForEachNodeWrapper.class,
-		    new SimpleFactory(ForEachNodeWrapper.class),
-		    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")), 
-		    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
-		);
-		entries.add(combined);
+        if (flowNodes.charAt(11) == '1') {
+		    combined = new CombinedTemplateCreationEntry(
+			    "For Each",
+			    "Create a new ForEach Node",
+			    ForEachNodeWrapper.class,
+			    new SimpleFactory(ForEachNodeWrapper.class),
+			    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif")), 
+			    ImageDescriptor.createFromURL(DroolsEclipsePlugin.getDefault().getBundle().getEntry("icons/composite.gif"))
+			);
+			entries.add(combined);
+        }
                     
         drawer.addAll(entries);
         return drawer;

Added: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsFlowNodesPreferencePage.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsFlowNodesPreferencePage.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsFlowNodesPreferencePage.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -0,0 +1,156 @@
+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.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.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchPreferencePage;
+
+public class DroolsFlowNodesPreferencePage extends PreferencePage implements IWorkbenchPreferencePage {
+
+	private Button ruleFlowGroupButton;
+	private Button splitButton;
+	private Button joinButton;
+	private Button eventWaitButton;
+	private Button subFlowButton;
+	private Button actionButton;
+	private Button timerButton;
+	private Button faultButton;
+	private Button eventButton;
+	private Button humanTaskButton;
+	private Button compositeButton;
+	private Button forEachButton;
+	private Button workItemsButton;
+	
+	public DroolsFlowNodesPreferencePage() {
+		super("Drools Flow nodes");
+	}
+
+	public void init(IWorkbench workbench) {
+	}
+
+	protected Control createContents(Composite ancestor) {
+		initializeDialogUnits(ancestor);
+		noDefaultAndApplyButton();
+		GridLayout layout= new GridLayout();
+		layout.numColumns= 1;
+		layout.marginHeight = 0;
+		layout.marginWidth = 0;
+		ancestor.setLayout(layout);
+		Label l = new Label(ancestor, SWT.WRAP);
+		l.setFont(ancestor.getFont());
+		l.setText("Select which nodes are shown in the Drools Flow editor");
+		GridData gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.horizontalSpan = 1;
+		gd.widthHint = 300;
+		l.setLayoutData(gd);
+		l = new Label(ancestor, SWT.NONE);
+		gd = new GridData(GridData.FILL_HORIZONTAL);
+		gd.heightHint = 1;
+		l.setLayoutData(gd);
+		
+		Button startButton = createCheckBox(ancestor, "Start");
+		startButton.setSelection(true);
+		startButton.setEnabled(false);
+		Button endButton = createCheckBox(ancestor, "End");
+		endButton.setSelection(true);
+		endButton.setEnabled(false);
+		ruleFlowGroupButton = createCheckBox(ancestor, "RuleFlowGroup");
+		splitButton = createCheckBox(ancestor, "Split");
+		joinButton = createCheckBox(ancestor, "Join");
+		eventWaitButton = createCheckBox(ancestor, "Event Wait");
+		subFlowButton = createCheckBox(ancestor, "SubFlow");
+		actionButton = createCheckBox(ancestor, "Action");
+		timerButton = createCheckBox(ancestor, "Timer");
+		faultButton = createCheckBox(ancestor, "Fault");
+		eventButton = createCheckBox(ancestor, "Event");
+		humanTaskButton = createCheckBox(ancestor, "HumanTask");
+		compositeButton = createCheckBox(ancestor, "Composite");
+		forEachButton = createCheckBox(ancestor, "ForEach");
+		workItemsButton = createCheckBox(ancestor, "WorkItems");
+		initializeValues();
+		
+		applyDialogFont(ancestor);
+		return ancestor;
+	}
+	
+	private Button createCheckBox(Composite group, String label) {
+        Button button = new Button(group, SWT.CHECK | SWT.LEFT);
+        button.setText(label);
+        GridData data = new GridData();
+        data.horizontalSpan = 2;
+        button.setLayoutData(data);
+        return button;
+    }
+	
+	protected IPreferenceStore doGetPreferenceStore() {
+        return DroolsEclipsePlugin.getDefault().getPreferenceStore();
+    }
+	
+	private void initializeDefaults() {
+        initializeValues("1111111111111");
+	}
+
+	private void initializeValues() {
+        IPreferenceStore store = getPreferenceStore();
+        String flowNodes = store.getString(IDroolsConstants.FLOW_NODES);
+        if (flowNodes == null || flowNodes.length() != 13) {
+        	flowNodes = "1111111111111";
+        }
+        initializeValues(flowNodes);
+	}
+	
+	private void initializeValues(String flowNodes) {
+    	ruleFlowGroupButton.setSelection(flowNodes.charAt(0) == '1');
+		splitButton.setSelection(flowNodes.charAt(1) == '1');
+		joinButton.setSelection(flowNodes.charAt(2) == '1');
+		eventWaitButton.setSelection(flowNodes.charAt(3) == '1');
+		subFlowButton.setSelection(flowNodes.charAt(4) == '1');
+		actionButton.setSelection(flowNodes.charAt(5) == '1');
+		timerButton.setSelection(flowNodes.charAt(6) == '1');
+		faultButton.setSelection(flowNodes.charAt(7) == '1');
+		eventButton.setSelection(flowNodes.charAt(8) == '1');
+		humanTaskButton.setSelection(flowNodes.charAt(9) == '1');
+		compositeButton.setSelection(flowNodes.charAt(10) == '1');
+		forEachButton.setSelection(flowNodes.charAt(11) == '1');
+		workItemsButton.setSelection(flowNodes.charAt(12) == '1');
+    }
+
+	protected void performDefaults() {
+        super.performDefaults();
+        initializeDefaults();
+    }
+
+	public boolean performOk() {
+        storeValues();
+        DroolsEclipsePlugin.getDefault().savePluginPreferences();
+        return true;
+    }
+	
+	private void storeValues() {
+        IPreferenceStore store = getPreferenceStore();
+        String flowNodes = "" +
+        	(ruleFlowGroupButton.getSelection() ? '1' : '0') +
+			(splitButton.getSelection() ? '1' : '0') +
+			(joinButton.getSelection() ? '1' : '0') +
+			(eventWaitButton.getSelection() ? '1' : '0') +
+			(subFlowButton.getSelection() ? '1' : '0') +
+			(actionButton.getSelection() ? '1' : '0') +
+			(timerButton.getSelection() ? '1' : '0') +
+			(faultButton.getSelection() ? '1' : '0') +
+			(eventButton.getSelection() ? '1' : '0') +
+			(humanTaskButton.getSelection() ? '1' : '0') +
+			(compositeButton.getSelection() ? '1' : '0') +
+			(forEachButton.getSelection() ? '1' : '0') +
+			(workItemsButton.getSelection() ? '1' : '0');
+        store.setValue(IDroolsConstants.FLOW_NODES, flowNodes);
+    }
+
+}

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsPreferencePage.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -21,6 +21,7 @@
 	private Button cacheParsedRulesCheckBox;
 	private Combo processSkinCombo;
 	private Button allowNodeCustomizationCheckBox;
+	private Combo internalAPICombo;
 	
 	protected Control createContents(Composite parent) {
 		final Composite composite = new Composite(parent, SWT.NONE);
@@ -41,7 +42,12 @@
 		processSkinCombo.add("BPMN");
 		allowNodeCustomizationCheckBox = createCheckBox(composite,
 			"Allow the customization of process nodes.");
-
+		label = new Label(composite, SWT.NONE);
+		label.setText("Internal Drools classes are: ");
+		internalAPICombo = new Combo(composite, SWT.LEFT);
+		internalAPICombo.add("Accessible");
+		internalAPICombo.add("Not accessible");
+		internalAPICombo.add("Discouraged");
 		initializeValues();
 
 		return composite;
@@ -72,6 +78,7 @@
         }
         processSkinCombo.select(index);
         allowNodeCustomizationCheckBox.setSelection(store.getDefaultBoolean(IDroolsConstants.ALLOW_NODE_CUSTOMIZATION));
+        internalAPICombo.select(store.getDefaultInt(IDroolsConstants.ALLOW_NODE_CUSTOMIZATION));
 	}
 
 	private void initializeValues() {
@@ -86,6 +93,7 @@
         }
         processSkinCombo.select(index);
         allowNodeCustomizationCheckBox.setSelection(store.getBoolean(IDroolsConstants.ALLOW_NODE_CUSTOMIZATION));
+        internalAPICombo.select(store.getInt(IDroolsConstants.INTERNAL_API));
     }
 
 	protected void performDefaults() {
@@ -107,6 +115,7 @@
         store.setValue(IDroolsConstants.SKIN,
     		(String) processSkinCombo.getItem(processSkinCombo.getSelectionIndex()));
         store.setValue(IDroolsConstants.ALLOW_NODE_CUSTOMIZATION, allowNodeCustomizationCheckBox.getSelection());
+        store.setValue(IDroolsConstants.INTERNAL_API, internalAPICombo.getSelectionIndex());
     }
 
 	public void init(IWorkbench workbench) {

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsProjectPreferencePage.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsProjectPreferencePage.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsProjectPreferencePage.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -6,10 +6,8 @@
 import org.drools.eclipse.preferences.DroolsRuntimesBlock.DroolsRuntime;
 import org.drools.eclipse.util.DroolsRuntimeManager;
 import org.eclipse.core.resources.IFile;
+import org.eclipse.core.resources.IFolder;
 import org.eclipse.core.resources.IProject;
-import org.eclipse.jdt.core.IClasspathContainer;
-import org.eclipse.jdt.core.IJavaProject;
-import org.eclipse.jdt.core.JavaCore;
 import org.eclipse.jdt.internal.ui.preferences.PropertyAndPreferencePage;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.layout.GridData;
@@ -67,17 +65,21 @@
 	}
 
 	protected boolean hasProjectSpecificOptions(IProject project) {
-		return project.getFile(".drools.runtime").exists();
+		return project.getFile(".settings/.drools.runtime").exists();
 	}
 
 	public boolean performOk() {
 		try {
-			IFile file = getProject().getFile(".drools.runtime");
+			IFile file = getProject().getFile(".settings/.drools.runtime");
 			if (useProjectSettings()) {
 				String runtime = "<runtime>"
 					+ droolsRuntimeCombo.getItem(droolsRuntimeCombo.getSelectionIndex())
 					+ "</runtime>";
 				if (!file.exists()) {
+					IFolder folder = getProject().getFolder(".settings");
+					if (!folder.exists()) {
+						folder.create(true, true, null);
+					}
 					file.create(new ByteArrayInputStream(runtime.getBytes()), true, null);
 				} else {
 					file.setContents(new ByteArrayInputStream(runtime.getBytes()), true, false, null);

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsRuntimesPreferencePage.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsRuntimesPreferencePage.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/DroolsRuntimesPreferencePage.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -1,9 +1,5 @@
 package org.drools.eclipse.preferences;
 
-import java.util.ArrayList;
-import java.util.List;
-
-import org.drools.eclipse.DroolsEclipsePlugin;
 import org.drools.eclipse.preferences.DroolsRuntimesBlock.DroolsRuntime;
 import org.drools.eclipse.util.DroolsRuntimeManager;
 import org.eclipse.jface.dialogs.MessageDialog;

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/preferences/IDroolsConstants.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -11,5 +11,7 @@
 	String SKIN = "Drools.Flow.Skin";
 	String ALLOW_NODE_CUSTOMIZATION = "Drools.Flow.AllowNodeCustomization";
 	String DROOLS_RUNTIMES = "Drools.Runtimes";
+	String INTERNAL_API = "Drools.InternalAPI";
+	String FLOW_NODES = "Drools.FlowNodes";
 	
 }

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsClasspathContainer.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -7,6 +7,7 @@
 import java.util.List;
 
 import org.drools.eclipse.DroolsEclipsePlugin;
+import org.drools.eclipse.preferences.IDroolsConstants;
 import org.drools.eclipse.preferences.DroolsRuntimesBlock.DroolsRuntime;
 import org.eclipse.core.resources.IFile;
 import org.eclipse.core.runtime.IPath;
@@ -51,20 +52,23 @@
     }
 
     private IClasspathEntry[] createDroolsLibraryEntries(IJavaProject project) {
+    	int internalAPI = DroolsEclipsePlugin.getDefault()
+    		.getPluginPreferences().getInt(IDroolsConstants.INTERNAL_API);
         List jarNames = getJarNames(project);
         List list = new ArrayList();
         for (int i = 0; i < jarNames.size(); i++) {
         	String jarName = (String) jarNames.get(i);
         	Path path = new Path(jarName);
-//            if (jarName.contains("drools-api")) {
-            	list.add(JavaCore.newLibraryEntry(path, path, null));
-//            } else {
-//                IAccessRule[] accessRules = new IAccessRule[1];
-//                accessRules[0] = new ClasspathAccessRule(new Path("**"), IAccessRule.K_DISCOURAGED);
-//                list.add(JavaCore.newLibraryEntry(
-//                    path, path, null, accessRules, ClasspathEntry.NO_EXTRA_ATTRIBUTES, false));
-//            }
-            
+        	if (internalAPI != 0) {
+		        if (jarName.contains("drools-api")) {
+		        	list.add(JavaCore.newLibraryEntry(path, path, null));
+		        } else {
+		        	IAccessRule[] accessRules = new IAccessRule[1];
+		            accessRules[0] = new ClasspathAccessRule(new Path("**"), internalAPI);
+		            list.add(JavaCore.newLibraryEntry(
+		                path, path, null, accessRules, ClasspathEntry.NO_EXTRA_ATTRIBUTES, false));
+		        }
+        	}
         }
         // also add jdt core jar from eclipse itself
 //        String pluginRootString = Platform.getInstallLocation().getURL().getPath() + "plugins/";

Modified: labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-eclipse/org.drools.eclipse/src/main/java/org/drools/eclipse/util/DroolsRuntimeManager.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -143,7 +143,7 @@
 	
     public static String getDroolsRuntime(IProject project) {
         try {
-        	IFile file = project.getFile(".drools.runtime");
+        	IFile file = project.getFile(".settings/.drools.runtime");
         	if (file.exists()) {
         		BufferedReader reader = new BufferedReader(new InputStreamReader(file.getContents()));
         		String location = reader.readLine();

Modified: labs/jbossrules/trunk/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/session/SingleSessionCommandService.java
===================================================================
--- labs/jbossrules/trunk/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/session/SingleSessionCommandService.java	2008-12-02 22:45:13 UTC (rev 24220)
+++ labs/jbossrules/trunk/drools-process/drools-process-enterprise/src/main/java/org/drools/persistence/session/SingleSessionCommandService.java	2008-12-02 22:55:45 UTC (rev 24221)
@@ -2,9 +2,11 @@
 
 import javax.transaction.xa.XAException;
 
+import org.drools.KnowledgeBase;
 import org.drools.RuleBase;
 import org.drools.StatefulSession;
 import org.drools.common.InternalWorkingMemory;
+import org.drools.impl.KnowledgeBaseImpl;
 import org.drools.marshalling.PlaceholderResolverStrategyFactory;
 import org.drools.persistence.Persister;
 import org.drools.persistence.Transaction;
@@ -37,6 +39,22 @@
 		init();
 	}
 	
+	public SingleSessionCommandService(KnowledgeBase kbase) {
+		this(((KnowledgeBaseImpl) kbase).getRuleBase(), (PlaceholderResolverStrategyFactory) null);
+	}
+	
+	public SingleSessionCommandService(KnowledgeBase kbase, PlaceholderResolverStrategyFactory factory) {
+		this(((KnowledgeBaseImpl) kbase).getRuleBase(), factory);
+	}
+	
+	public SingleSessionCommandService(KnowledgeBase kbase, String sessionId) {
+		this(((KnowledgeBaseImpl) kbase).getRuleBase(), sessionId, null);
+	}
+	
+	public SingleSessionCommandService(KnowledgeBase kbase, String sessionId, PlaceholderResolverStrategyFactory factory) {
+		this(((KnowledgeBaseImpl) kbase).getRuleBase(), sessionId, factory);
+	}
+	
 	private void init() {
 		StatefulSession session = persister.getObject();
 		((JPAProcessInstanceManager) ((InternalWorkingMemory) session).getProcessInstanceManager())




More information about the jboss-svn-commits mailing list