[jboss-svn-commits] JBL Code SVN: r19583 - in labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin: src/main/java/org/drools/eclipse/flow/common/editor and 1 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Tue Apr 15 19:18:59 EDT 2008


Author: KrisVerlaenen
Date: 2008-04-15 19:18:59 -0400 (Tue, 15 Apr 2008)
New Revision: 19583

Added:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor2.java
Modified:
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
   labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
Log:
 - XML tab for ruleflow editor (uneditable)

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml	2008-04-15 22:44:12 UTC (rev 19582)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/plugin.xml	2008-04-15 23:18:59 UTC (rev 19583)
@@ -431,7 +431,7 @@
             extensions="rf, ruleflow, rflow"
             icon="icons/process.gif"
             contributorClass="org.drools.eclipse.flow.common.editor.GenericActionBarContributor"
-            class="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor"
+            class="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor2"
             id="org.drools.eclipse.flow.ruleflow.editor.RuleFlowModelEditor">
       </editor>
    </extension>

Modified: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java	2008-04-15 22:44:12 UTC (rev 19582)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/common/editor/GenericModelEditor.java	2008-04-15 23:18:59 UTC (rev 19583)
@@ -79,7 +79,7 @@
 		this.model = model;
 	}
 
-	protected Object getModel() {
+	public Object getModel() {
 		return model;
 	}
 

Added: labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor2.java
===================================================================
--- labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor2.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-eclipse/drools-eclipse-plugin/src/main/java/org/drools/eclipse/flow/ruleflow/editor/RuleFlowModelEditor2.java	2008-04-15 23:18:59 UTC (rev 19583)
@@ -0,0 +1,145 @@
+package org.drools.eclipse.flow.ruleflow.editor;
+
+/*
+ * 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.drools.eclipse.DroolsEclipsePlugin;
+import org.eclipse.core.runtime.IProgressMonitor;
+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.editors.text.TextEditor;
+import org.eclipse.ui.forms.editor.FormEditor;
+
+/**
+ * This is a multi table editor wrapper for both the text editor and the flow
+ * chart.
+ * 
+ * @author <a href="mailto:kris_verlaenen at hotmail.com">Kris Verlaenen</a>
+ */
+public class RuleFlowModelEditor2 extends FormEditor {
+
+    private RuleFlowModelEditor editor;
+    private TextEditor xmlEditor;
+
+    public void init(IEditorSite site, IEditorInput input)
+            throws PartInitException {
+        super.init(site, input);
+        setPartName(input.getName());
+    }
+
+    protected void addPages() {
+        try {
+            editor = new RuleFlowModelEditor();
+            xmlEditor = new TextEditor() {
+                public boolean isEditable() {
+                    return false;
+                }
+                
+                public void close(boolean save) {
+                    super.close(save);
+                    RuleFlowModelEditor2.this.close(save);
+                }
+
+                protected void setPartName(String partName) {
+                    super.setPartName(partName);
+                    RuleFlowModelEditor2.this.setPartName(partName);
+                }
+            };
+
+            int graph = addPage(editor, getEditorInput());
+
+            int xml = addPage(xmlEditor, getEditorInput());
+
+            setPageText(graph, "Graph");
+            setPageText(xml, "XML");
+
+            xmlEditor.getDocumentProvider().getDocument(getEditorInput())
+                .addDocumentListener(new IDocumentListener() {
+                        public void documentAboutToBeChanged(DocumentEvent event) {
+                        }
+                        public void documentChanged(DocumentEvent event) {
+                            editor.setInput(getEditorInput());
+                        }
+                    });
+        } catch (PartInitException e) {
+            DroolsEclipsePlugin.log(e);
+        }
+    }
+
+    public void doSave(IProgressMonitor monitor) {
+        editor.doSave(monitor);
+        setInput(getEditorInput());
+    }
+
+    public void doSaveAs() {
+        editor.doSaveAs();
+    }
+
+    public boolean isSaveAsAllowed() {
+        return editor.isSaveAsAllowed();
+    }
+    
+    public Object getAdapter(Class adapter) {
+        return editor.getAdapter(adapter);
+    }
+
+//    public void setFocus() {
+//        if (getActivePage() == 0) {
+//            try {
+//                String content = xmlEditor.getDocumentProvider().getDocument(getEditorInput()).get();
+//                PackageBuilderConfiguration configuration = new PackageBuilderConfiguration();
+//                XmlProcessReader xmlReader = new XmlProcessReader( configuration.getSemanticModules() );
+//                final String isValidatingString = System.getProperty("drools.schema.validating");
+//                System.setProperty("drools.schema.validating", "true");
+//                RuleFlowProcess process = (RuleFlowProcess) xmlReader.read(new StringReader(content));
+//                System.setProperty("drools.schema.validating", isValidatingString);
+//                if (process != null) {
+//                    xmlEditor.doSave(null);
+//                    editor.setInput(getEditorInput());
+//                }
+//            } catch (Throwable t) {
+//                DroolsEclipsePlugin.log(t);
+//                handleError(t);
+//                setActivePage(1);
+//            }
+//        } else if (getActivePage() == 1) {
+//            editor.doSave(null);
+//            xmlEditor.setInput(getEditorInput());
+//        }
+//        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(), "Rete Tree Build Error!",
+//                "Unable to parse XML!", status);
+//
+//    }
+
+}




More information about the jboss-svn-commits mailing list