Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [bpel-dev] adding source view - patch #1

Hey Vitaly,

I created a branch in the CVS called "MultiTab-DomFacade" - this will be
the our playground, independant of M3 etc. ;-)

(Embedded image moved to file: pic13770.jpg)


I also checked your patch for the source view in on that stream. I propose
that we start working on this branch w.r.t. the Dom Facading / Mult Tab
Editor that we are onto no.
In other words, whenever you create a new patch for this, pls. sent me a
patch based on that branch. I will review and check it in then (remember
that we should follow a policy of small patches rather than huge code
chunks)

Cheers
Simon

Simon Moser, M.Eng.


                                                                          
 Websphere Integration       Mail:           IBM Deutschland Entwicklung  
 Developer Development       smoser@xxxxxx.  GmbH                         
 Team Lead BPEL Editor       com             Vorsitzender des             
 Dept. 4722, Bldg.           Phone:          Aufsichtsrats: Martin Jetter 
 71032-01, Room 086          +49-7031-16-43  Geschäftsführung: Herbert    
 Websphere Solutions and     04              Kircher                      
 Services                    Fax:            Sitz der Gesellschaft:       
 IBM Deutschland             +49-7031-16-48  Böblingen                    
 Entwicklung GmbH            90              Registergericht: Amtsgericht 
 Schönaicherstr. 220, D –                    Stuttgart, HRB 243294        
 71032 Boeblingen                                                         
                                                                          








                                                                           
             "Tishkov, Vitaly                                              
             V"                                                            
             <vitaly.v.tishkov                                          To 
             @intel.com>               "BPEL Designer project developer    
             Sent by:                  discussions."                       
             bpel-dev-bounces@         <bpel-dev@xxxxxxxxxxx>              
             eclipse.org                                                cc 
                                                                           
                                                                   Subject 
             05/21/2007 04:17          [bpel-dev] adding source view -     
             PM                        patch #1                            
                                                                           
                                                                           
             Please respond to                                             
              "BPEL Designer                                               
             project developer                                             
               discussions."                                               
             <bpel-dev@eclipse                                             
                   .org>                                                   
                                                                           
                                                                           




Hello,

Please find attached the first patch re source view development.
A source view itself is added, it reacts on the designer area (=BPELEditor)
selection changes. I.e. if you select an element in the design view and
switch to the source view then you see the corresponding piece of text
selected.
I used ideas and code from the XML editor.

What is in the patch.
1. BPELMultipageEditorPart (extends
org.eclipse.ui.part.MultiPageEditorPart) is taken as the base class for
BPEL multipage editor.
This class will hold all the “core” functionality of the editor UI:
handling events, etc. Design and text views (BPELEditor and
org.eclipse.wst.sse.ui.StructuredTextEditor) will be just views.
I haven’t moved any core functionality from BPELEditor to this class yet.

2. org.eclipse.wst.sse.ui is added to the org.eclipse.bpel.ui dependencies.
This is needed to make possible import of
org.eclipse.wst.sse.ui.StructuredTextEditor.

3. Editor class BPELEditor is changed to BPELMultipageEditorPart in the
org.eclipse.ui.editors extension point of org.eclipse.bpel.ui.

Feel free to express your opinion  J

Thanks,
            Vitaly.


 (See attached file: multipage_patch_1.txt)
_______________________________________________
bpel-dev mailing list
bpel-dev@xxxxxxxxxxx
https://dev.eclipse.org/mailman/listinfo/bpel-dev

Attachment: pic13770.jpg
Description: JPEG image

### Eclipse Workspace Patch 1.0
#P org.eclipse.bpel.ui
Index: plugin.xml
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.ui/plugin.xml,v
retrieving revision 1.17
diff -u -r1.17 plugin.xml
--- plugin.xml	17 May 2007 00:34:02 -0000	1.17
+++ plugin.xml	21 May 2007 13:56:25 -0000
@@ -11,7 +11,7 @@
    <extension
          point="org.eclipse.ui.editors">
       <editor
-            class="org.eclipse.bpel.ui.BPELEditor"
+            class="org.eclipse.bpel.ui.BPELMultipageEditorPart"
             contributorClass="org.eclipse.bpel.ui.BPELActionBarContributor"
             default="true"
             extensions="bpel"
Index: META-INF/MANIFEST.MF
===================================================================
RCS file: /cvsroot/technology/org.eclipse.bpel/plugins/org.eclipse.bpel.ui/META-INF/MANIFEST.MF,v
retrieving revision 1.9
diff -u -r1.9 MANIFEST.MF
--- META-INF/MANIFEST.MF	13 Apr 2007 19:09:31 -0000	1.9
+++ META-INF/MANIFEST.MF	21 May 2007 13:56:25 -0000
@@ -22,7 +22,8 @@
  org.eclipse.bpel.common.model,
  org.eclipse.bpel.model,
  org.eclipse.wst.xml.core,
- org.eclipse.bpel.wsil.model
+ org.eclipse.bpel.wsil.model,
+ org.eclipse.wst.sse.ui
 Eclipse-LazyStart: true
 Export-Package: org.eclipse.bpel.ui,
  org.eclipse.bpel.ui.actions,
Index: src/org/eclipse/bpel/ui/BPELMultipageEditorPart.java
===================================================================
RCS file: src/org/eclipse/bpel/ui/BPELMultipageEditorPart.java
diff -N src/org/eclipse/bpel/ui/BPELMultipageEditorPart.java
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/org/eclipse/bpel/ui/BPELMultipageEditorPart.java	1 Jan 1970 00:00:00 -0000
@@ -0,0 +1,190 @@
+/*******************************************************************************
+ * Copyright (c) 2007 Intel Corporation.
+ * 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:
+ *    Vitaly Tishkov, Intel - Initial API and Implementation
+ *
+ *******************************************************************************/ 
+
+package org.eclipse.bpel.ui;
+
+import org.eclipse.bpel.model.ExtensibleElement;
+import org.eclipse.bpel.ui.uiextensionmodel.StartNode;
+
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.jface.dialogs.ErrorDialog;
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.ui.IEditorInput;
+import org.eclipse.ui.IEditorSite;
+import org.eclipse.ui.PartInitException;
+import org.eclipse.ui.part.MultiPageEditorPart;
+import org.eclipse.wst.sse.ui.StructuredTextEditor;
+
+import org.w3c.dom.Element;
+
+public class BPELMultipageEditorPart extends MultiPageEditorPart {
+
+	private StructuredTextEditor fTextEditor = null;
+	private BPELEditor fDesignViewer = null;
+	
+	private static int DESIGN_PAGE_INDEX = 0;
+	private static int SOURCE_PAGE_INDEX = 1;
+	
+	/**
+	 * Adds the source page of the multi-page editor.
+	 */
+	private void addSourcePage() throws PartInitException {
+	    try
+	    {
+	    	addPage(SOURCE_PAGE_INDEX, fTextEditor, getEditorInput());
+	    	//FIXME I18N
+	    	setPageText(SOURCE_PAGE_INDEX, "Source");
+	    	firePropertyChange(PROP_TITLE);
+	    } catch (PartInitException e) {
+	    	ErrorDialog.openError(getSite().getShell(), "Error creating nested text editor", null, e.getStatus()); //$NON-NLS-1$
+	    }
+	}
+
+	/**
+	 * Connects the design viewer with the viewer selection manager. Should be
+	 * done after createSourcePage() is done because we need to get the
+	 * ViewerSelectionManager from the TextEditor. setModel is also done here
+	 * because getModel() needs to reference the TextEditor.
+	 */
+	private void connectDesignPage() {
+		/*
+		 * Connect selection from the Design page to the selection provider
+		 * for the BPELMultiPageEditorPart so that selection changes in the
+		 * Design page will propogate across the workbench
+		 */
+		/*fDesignViewer.getAdaptingSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				((MultiPageSelectionProvider) getSite().getSelectionProvider()).fireSelectionChanged(event);
+			}
+		});*/
+
+		/*
+		 * Connect selection from the Design page to the selection provider of
+		 * the Source page so that selection in the Design page will drive
+		 * selection in the Source page. 
+		 */
+		fDesignViewer.getAdaptingSelectionProvider().addSelectionChangedListener(new ISelectionChangedListener() {
+			public void selectionChanged(SelectionChangedEvent event) {
+				//force selection update if only source page is not active
+				if (getActivePage() != SOURCE_PAGE_INDEX) {
+					try {
+						ISelection sel = fDesignViewer.getSelection();
+						Object selectedNode = ((IStructuredSelection)sel).getFirstElement();
+						Element selectedNodeElement = null;
+						
+						if (selectedNode instanceof StartNode) {
+							selectedNodeElement = ((StartNode)selectedNode).getProcess().getElement();
+						} else if (selectedNode instanceof ExtensibleElement) {
+							selectedNodeElement = ((ExtensibleElement)selectedNode).getElement();
+						} 
+					
+						if (selectedNodeElement != null) {
+							int charStart = ((Number)selectedNodeElement.getUserData("location.charStart")).intValue();
+							//-1 to point to the '<' literal  
+							TextSelection textSelection = new TextSelection(charStart - 1, 0);
+							getTextEditor().getSelectionProvider().setSelection(textSelection);
+						}
+					} catch (Exception e) {
+						e.printStackTrace();
+					}
+				}
+			}
+		});
+	}
+
+	private void createAndAddDesignPage() {
+		fDesignViewer = new BPELEditor();
+
+		try
+	    {
+			addPage(DESIGN_PAGE_INDEX, fDesignViewer, getEditorInput());
+			//FIXME I18N
+			setPageText(DESIGN_PAGE_INDEX, "Design");
+			firePropertyChange(PROP_TITLE);
+	    } catch (PartInitException e) {
+	    	ErrorDialog.openError(getSite().getShell(), "Error creating nested BPEL editor", null, e.getStatus()); //$NON-NLS-1$
+	    }
+	}
+
+	private void createSourcePage() {
+		fTextEditor = new StructuredTextEditor();
+	}
+
+	
+	/**
+	 * Creates the pages of this multi-page editor.
+	 */
+	protected void createPages() {
+		// source page must be created before design page
+			
+		try {
+			createSourcePage();
+			createAndAddDesignPage();
+			addSourcePage();
+			connectDesignPage();
+		} catch (PartInitException e) {
+			//Logger.logException(e);
+			throw new RuntimeException(e);
+		} 
+	}
+
+
+	/**
+	 * @see org.eclipse.ui.IEditorPart#doSave(org.eclipse.core.runtime.IProgressMonitor)
+	 */
+	public void doSave(IProgressMonitor progressMonitor) {
+		fDesignViewer.doSave(progressMonitor);
+		fTextEditor.doSave(progressMonitor);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.ISaveablePart#doSaveAs()
+	 */
+	public void doSaveAs() {
+		//saveAs is not allowed; do nothing
+	}
+	
+	StructuredTextEditor getTextEditor() {
+		return fTextEditor;
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.IEditorPart#init(org.eclipse.ui.IEditorSite,
+	 *      org.eclipse.ui.IEditorInput)
+	 */
+	public void init(IEditorSite site, IEditorInput input) throws PartInitException {
+		try {
+			super.init(site, input);
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		setPartName(input.getName());
+	}
+	
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see org.eclipse.ui.ISaveablePart#isSaveAsAllowed()
+	 */
+	public boolean isSaveAsAllowed() {
+		return false;
+	}
+}
+

Back to the top