Fixes for 124275, 86800, 91593, 94374, 122739, 101603. partial_reparse_t2b_a
authorksorokin@netbeans.org
Fri, 21 Dec 2007 13:42:26 +0000
changeset 1485cf26dbbb538f
parent 1484 c2a39a240d79
child 1486 241d242da406
Fixes for 124275, 86800, 91593, 94374, 122739, 101603.
bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/api/EditorContextBridge.java
bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/spi/EditorContext.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/Breakpoint.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/BreakpointEnableAction.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BpelBreakpointListener.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BreakpointTranslator.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelAnnotation.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelEditorContext.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/plinks/PLinksTreeModel.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesActionProvider.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesNodeModel.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesTreeModel.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/Bundle.properties
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/EditorUtil.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/VariablesUtil.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsColumnModel_Value.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTableModel.java
bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTreeModel.java
bpel.debugger/src/org/netbeans/modules/bpel/debugger/BpelDebuggerImpl.java
bpel.debugger/src/org/netbeans/modules/bpel/debugger/Bundle.properties
bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/SimpleVariableImpl.java
bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/WsdlMessageVariableImpl.java
bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/XmlElementVariableImpl.java
     1.1 --- a/bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/api/EditorContextBridge.java	Fri Dec 21 12:46:40 2007 +0000
     1.2 +++ b/bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/api/EditorContextBridge.java	Fri Dec 21 13:42:26 2007 +0000
     1.3 @@ -110,6 +110,10 @@
     1.4          getContext().removeAnnotation(annotation);
     1.5      }
     1.6      
     1.7 +    public static boolean isAttached(Object annotation) {
     1.8 +        return getContext().isAttached(annotation);
     1.9 +    }
    1.10 +    
    1.11      public static AnnotationType getAnnotationType(Object annotation) {
    1.12          return getContext().getAnnotationType(annotation);
    1.13      }
     2.1 --- a/bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/spi/EditorContext.java	Fri Dec 21 12:46:40 2007 +0000
     2.2 +++ b/bpel.debugger.api/src/org/netbeans/modules/bpel/debugger/spi/EditorContext.java	Fri Dec 21 13:42:26 2007 +0000
     2.3 @@ -60,6 +60,8 @@
     2.4       */
     2.5      void removeAnnotation(Object annotation);
     2.6      
     2.7 +    boolean isAttached(Object annotation);
     2.8 +    
     2.9      AnnotationType getAnnotationType(Object annotation);
    2.10      
    2.11      String getXpath(Object annotation);
     3.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/Breakpoint.java	Fri Dec 21 12:46:40 2007 +0000
     3.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/Breakpoint.java	Fri Dec 21 13:42:26 2007 +0000
     3.3 @@ -24,8 +24,6 @@
     3.4  import java.util.Collections;
     3.5  import java.util.Set;
     3.6  import java.util.concurrent.atomic.AtomicBoolean;
     3.7 -import javax.swing.JEditorPane;
     3.8 -import javax.swing.text.Caret;
     3.9  import javax.swing.text.StyledDocument;
    3.10  import org.netbeans.api.debugger.ActionsManager;
    3.11  import org.netbeans.api.debugger.DebuggerManager;
    3.12 @@ -42,12 +40,10 @@
    3.13  import org.netbeans.modules.bpel.model.api.support.UniqueId;
    3.14  import org.netbeans.modules.soa.ui.nodes.InstanceRef;
    3.15  import org.netbeans.spi.debugger.ActionsProviderSupport;
    3.16 -import org.openide.cookies.EditorCookie;
    3.17  import org.openide.filesystems.FileObject;
    3.18  import org.openide.filesystems.FileUtil;
    3.19  import org.openide.loaders.DataObject;
    3.20  import org.openide.nodes.Node;
    3.21 -import org.openide.text.NbDocument;
    3.22  import org.openide.util.WeakListeners;
    3.23  import org.openide.windows.TopComponent;
    3.24  import org.openide.windows.WindowManager;
    3.25 @@ -131,7 +127,7 @@
    3.26              bpelEntityId = bpelEntity.getUID();
    3.27              lineNumber = ModelUtil.getLineNumber(bpelEntityId);
    3.28          } else {
    3.29 -            lineNumber = getCurrentLineNumber(node);
    3.30 +            lineNumber = EditorUtil.getLineNumber(node);
    3.31              
    3.32              if (lineNumber > 0) {
    3.33                  final int translatedLineNumber = EditorContextBridge.
    3.34 @@ -224,35 +220,6 @@
    3.35          return fileObject.getExt();
    3.36      }
    3.37      
    3.38 -    private int getCurrentLineNumber(
    3.39 -            final Node node) {
    3.40 -        
    3.41 -        final EditorCookie editorCookie = 
    3.42 -                node.getLookup().lookup(EditorCookie.class);
    3.43 -        if (editorCookie == null) {
    3.44 -            return -1;
    3.45 -        }
    3.46 -        
    3.47 -        final JEditorPane[] editorPanes = editorCookie.getOpenedPanes();
    3.48 -        if (editorPanes == null || editorPanes.length == 0) {
    3.49 -            return -1;
    3.50 -        }
    3.51 -        
    3.52 -        final Caret caret = editorPanes[0].getCaret();
    3.53 -        if (caret == null) {
    3.54 -            return -1;
    3.55 -        }
    3.56 -        
    3.57 -        final int offset = caret.getDot();
    3.58 -        
    3.59 -        final StyledDocument document = editorCookie.getDocument();
    3.60 -        if (document == null) {
    3.61 -            return -1;
    3.62 -        }
    3.63 -        
    3.64 -        return NbDocument.findLineNumber(document, offset) + 1;
    3.65 -    }
    3.66 -    
    3.67      private BpelBreakpointListener getBreakpointAnnotationListener() {
    3.68          if (myBreakpointAnnotationListener == null) {
    3.69              myBreakpointAnnotationListener = (BpelBreakpointListener) 
     4.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/BreakpointEnableAction.java	Fri Dec 21 12:46:40 2007 +0000
     4.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/action/BreakpointEnableAction.java	Fri Dec 21 13:42:26 2007 +0000
     4.3 @@ -42,11 +42,10 @@
     4.4   * @author Alexander Zgursky
     4.5   */
     4.6  public class BreakpointEnableAction extends BooleanStateAction {
     4.7 +    
     4.8      private BpelBreakpointListener myBreakpointAnnotationListener;
     4.9 -
    4.10 -//TODO: the whole class needs refactoring - most of the code was copy-pasted from
    4.11 -//org.netbeans.modules.bpel.debugger.ui.action.Breakpoint
    4.12 -
    4.13 +    
    4.14 +    @Override
    4.15      public boolean isEnabled() {
    4.16          LineBreakpoint b = findCurrentBreakpoint();
    4.17          if (b != null) {
    4.18 @@ -61,6 +60,7 @@
    4.19          return NbBundle.getMessage(BreakpointEnableAction.class, "CTL_enabled");
    4.20      }
    4.21      
    4.22 +    @Override
    4.23      public void setBooleanState(boolean value) {
    4.24          LineBreakpoint b = findCurrentBreakpoint();
    4.25          if (value) {
    4.26 @@ -123,7 +123,7 @@
    4.27          
    4.28          return getBreakpointAnnotationListener().findBreakpoint(url, xpath, lineNumber);
    4.29      }
    4.30 -
    4.31 +    
    4.32      private Node getCurrentNode() {
    4.33          Node [] nodes = WindowManager.getDefault().getRegistry().getCurrentNodes();
    4.34          
    4.35 @@ -154,5 +154,6 @@
    4.36          }
    4.37          return myBreakpointAnnotationListener;
    4.38      }
    4.39 -
    4.40 +    
    4.41 +    private static final long serialVersionUID = 1L;
    4.42  }
     5.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BpelBreakpointListener.java	Fri Dec 21 12:46:40 2007 +0000
     5.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BpelBreakpointListener.java	Fri Dec 21 13:42:26 2007 +0000
     5.3 @@ -192,20 +192,28 @@
     5.4          if (lbp == null) {
     5.5              return;
     5.6          }
     5.7 +        
     5.8 +        // if the annotation is still attached, then we need to just update the 
     5.9 +        // breakpoint, otherwise we need to remove the breakpoint
    5.10 +        if (EditorContextBridge.isAttached(annotation)) {
    5.11 +            final String xpath = 
    5.12 +                    EditorContextBridge.getXpath(annotation);
    5.13 +            final int lineNumber = 
    5.14 +                    EditorContextBridge.getLineNumber(annotation);
    5.15  
    5.16 -        final String xpath = EditorContextBridge.getXpath(annotation);
    5.17 -        final int lineNumber = EditorContextBridge.getLineNumber(annotation);
    5.18 -        
    5.19 -        final LineBreakpoint existing = 
    5.20 -                findBreakpoint(lbp.getURL(), xpath, lineNumber);
    5.21 -        
    5.22 -        if ((existing != null) && !existing.equals(lbp)) {
    5.23 +            final LineBreakpoint existing = 
    5.24 +                    findBreakpoint(lbp.getURL(), xpath, lineNumber);
    5.25 +
    5.26 +            if ((existing != null) && !existing.equals(lbp)) {
    5.27 +                DebuggerManager.getDebuggerManager().removeBreakpoint(lbp);
    5.28 +            } else {
    5.29 +                lbp.setXpath(xpath);
    5.30 +                lbp.setLineNumber(lineNumber);
    5.31 +
    5.32 +                lbp.touch();
    5.33 +            }
    5.34 +        } else {
    5.35              DebuggerManager.getDebuggerManager().removeBreakpoint(lbp);
    5.36 -        } else {
    5.37 -            lbp.setXpath(xpath);
    5.38 -            lbp.setLineNumber(lineNumber);
    5.39 -            
    5.40 -            lbp.touch();
    5.41          }
    5.42      }
    5.43      
     6.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BreakpointTranslator.java	Fri Dec 21 12:46:40 2007 +0000
     6.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/breakpoint/BreakpointTranslator.java	Fri Dec 21 13:42:26 2007 +0000
     6.3 @@ -20,17 +20,8 @@
     6.4  
     6.5  package org.netbeans.modules.bpel.debugger.ui.breakpoint;
     6.6  
     6.7 -import java.io.File;
     6.8 -import java.io.FileReader;
     6.9  import java.io.StringReader;
    6.10 -import javax.swing.JEditorPane;
    6.11 -import org.openide.cookies.EditorCookie;
    6.12 -import org.openide.cookies.LineCookie;
    6.13 -import org.openide.filesystems.FileObject;
    6.14 -import org.openide.filesystems.FileUtil;
    6.15 -import org.openide.loaders.DataObject;
    6.16 -import org.openide.loaders.DataObjectNotFoundException;
    6.17 -import org.openide.text.Line;
    6.18 +import org.netbeans.modules.bpel.debugger.ui.util.EditorUtil;
    6.19  import org.xml.sax.InputSource;
    6.20  import org.xml.sax.XMLReader;
    6.21  import org.xml.sax.helpers.XMLReaderFactory;
    6.22 @@ -46,14 +37,9 @@
    6.23          
    6.24          try {
    6.25              final BPELActivityFinderSaxHandler saxHandler = 
    6.26 -                    parse(getText(url), lineNumber);
    6.27 +                    parse(EditorUtil.getText(url), lineNumber);
    6.28              
    6.29              final BPELNode bpelNode = getValidNode(saxHandler.getFoundNode());
    6.30 -//            if (lineNumber < saxHandler.getFirstActivity().getLineNumber()) {
    6.31 -//                bpelnode = saxHandler.getFirstActivity();
    6.32 -//            } else if (lineNumber > saxHandler.getLastActivity().getLineNumber()) {
    6.33 -//                bpelnode = saxHandler.getLastActivity();
    6.34 -//            }
    6.35              
    6.36              if (bpelNode != null) {
    6.37                  return bpelNode.getLineNumber();
    6.38 @@ -82,8 +68,9 @@
    6.39      }
    6.40      
    6.41      private static BPELNode getValidNode(BPELNode bpelNode) {
    6.42 -        if (bpelNode == null)
    6.43 +        if (bpelNode == null) {
    6.44              return null;
    6.45 +        }
    6.46          
    6.47          if (bpelNode.isActivity() || 
    6.48                  bpelNode.getName().equals("copy") ||
    6.49 @@ -98,40 +85,4 @@
    6.50          }
    6.51          
    6.52      }
    6.53 -    
    6.54 -    private static String getText(String url) {
    6.55 -        DataObject dataObject = getDataObject(url);
    6.56 -        if (dataObject == null) {
    6.57 -            return "";
    6.58 -        }  
    6.59 -        EditorCookie editorCookie = (EditorCookie) dataObject.getCookie(EditorCookie.class);
    6.60 -        
    6.61 -        if (editorCookie == null) {
    6.62 -            return "";
    6.63 -        }
    6.64 -        JEditorPane[] editorPanes = editorCookie.getOpenedPanes();
    6.65 -        
    6.66 -        if (editorPanes == null) {
    6.67 -              return "" ;
    6.68 -        }
    6.69 -        if (editorPanes.length == 0) {
    6.70 -            return "";
    6.71 -        }
    6.72 -        return editorPanes[0].getText();
    6.73 -
    6.74 -        
    6.75 -    }
    6.76 -    
    6.77 -    private static DataObject getDataObject(String url) {
    6.78 -        FileObject fileObject = FileUtil.toFileObject(new File(url));
    6.79 -        
    6.80 -        if (fileObject == null) {
    6.81 -            return null;
    6.82 -        }
    6.83 -        try {
    6.84 -            return DataObject.find(fileObject);
    6.85 -        } catch (DataObjectNotFoundException e) {
    6.86 -            return null;
    6.87 -        }
    6.88 -    }
    6.89  }
     7.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelAnnotation.java	Fri Dec 21 12:46:40 2007 +0000
     7.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelAnnotation.java	Fri Dec 21 13:42:26 2007 +0000
     7.3 @@ -44,6 +44,7 @@
     7.4      private final AnnotationType myAnnotationType;
     7.5      private final DataObject myDataObject;
     7.6      private final String myXpath;
     7.7 +    private final UniqueId myBpelEntityId;
     7.8      private final int myLineNumber;
     7.9  
    7.10      private State myState;
    7.11 @@ -62,6 +63,8 @@
    7.12          myAnnotationType = annotationType;
    7.13          myDataObject = dataObject;
    7.14          myXpath = xpath;
    7.15 +        myBpelEntityId = ModelUtil.getBpelEntityId(
    7.16 +                getBpelModel(), xpath);
    7.17          myLineNumber = lineNumber;
    7.18          
    7.19          myPcs = new PropertyChangeSupport(this);
    7.20 @@ -89,8 +92,6 @@
    7.21              return;
    7.22          }
    7.23          
    7.24 -        assert myDiagramAnnotation != null;
    7.25 -        
    7.26          removeDiagramAnnotation();
    7.27          removeLineAnnotation();
    7.28          
    7.29 @@ -171,9 +172,16 @@
    7.30              return;
    7.31          }
    7.32          
    7.33 -        updateDiagramAnnotation();
    7.34 -        updateLineAnnotation();
    7.35 -        firePropertyChange(null, null, null);
    7.36 +        // if the bpel entity was deleted -- we need to remove the annotations
    7.37 +        // and the breakpoint
    7.38 +        if (getBpelModel().getEntity(myBpelEntityId) == null) {
    7.39 +            detach();
    7.40 +        } else {
    7.41 +            updateDiagramAnnotation();
    7.42 +            updateLineAnnotation();
    7.43 +            
    7.44 +            firePropertyChange(null, null, null);
    7.45 +        }
    7.46      }
    7.47  
    7.48      /**
    7.49 @@ -213,8 +221,7 @@
    7.50                  entityId, myAnnotationType.getType());
    7.51          
    7.52          final AnnotationManagerCookie annotationManager =
    7.53 -                (AnnotationManagerCookie) myDataObject.getCookie(
    7.54 -                AnnotationManagerCookie.class);
    7.55 +                myDataObject.getCookie(AnnotationManagerCookie.class);
    7.56          
    7.57          annotationManager.addAnnotation(diagramAnnotation);
    7.58          
    7.59 @@ -228,14 +235,15 @@
    7.60              return;
    7.61          }
    7.62          
    7.63 -        final AnnotationManagerCookie annotationManager =
    7.64 -                (AnnotationManagerCookie) myDataObject.getCookie(
    7.65 -                AnnotationManagerCookie.class);
    7.66 -        
    7.67 -        annotationManager.removeAnnotation(myDiagramAnnotation);
    7.68 -        myDiagramAnnotation = null;
    7.69 -        
    7.70 -        BpelAnnotationsObserver.unsubscribe(this);
    7.71 +        if (myDiagramAnnotation != null) {
    7.72 +            final AnnotationManagerCookie annotationManager =
    7.73 +                    myDataObject.getCookie(AnnotationManagerCookie.class);
    7.74 +                    
    7.75 +            annotationManager.removeAnnotation(myDiagramAnnotation);
    7.76 +            myDiagramAnnotation = null;
    7.77 +            
    7.78 +            BpelAnnotationsObserver.unsubscribe(this);
    7.79 +        }
    7.80      }
    7.81      
    7.82      private void updateLineAnnotation() {
     8.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelEditorContext.java	Fri Dec 21 12:46:40 2007 +0000
     8.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/editor/BpelEditorContext.java	Fri Dec 21 13:42:26 2007 +0000
     8.3 @@ -18,7 +18,6 @@
     8.4   */
     8.5  package org.netbeans.modules.bpel.debugger.ui.editor;
     8.6  
     8.7 -import java.beans.PropertyChangeEvent;
     8.8  import java.beans.PropertyChangeListener;
     8.9  import java.beans.PropertyChangeSupport;
    8.10  import java.util.ArrayList;
    8.11 @@ -27,6 +26,7 @@
    8.12  import java.util.List;
    8.13  import java.util.Map;
    8.14  import java.util.Set;
    8.15 +import javax.swing.SwingUtilities;
    8.16  import javax.xml.namespace.QName;
    8.17  import org.netbeans.core.api.multiview.MultiViewHandler;
    8.18  import org.netbeans.core.api.multiview.MultiViewPerspective;
    8.19 @@ -62,15 +62,9 @@
    8.20      private Map<BpelAnnotation, PropertyChangeSupport> myAnnotationToListeners =
    8.21              new IdentityHashMap<BpelAnnotation, PropertyChangeSupport>();
    8.22      
    8.23 -    private Map<EditorCookie, EditorObserver> myEditorToObserver =
    8.24 -            new HashMap<EditorCookie, EditorObserver>();
    8.25 -    
    8.26      private Map<EditorCookie, Set<BpelAnnotation>> myEditorToAnnotations =
    8.27              new HashMap<EditorCookie, Set<BpelAnnotation>>();
    8.28      
    8.29 -    private EditorObserverListener myEditorObserverListener =
    8.30 -            new EditorObserverListener();
    8.31 -    
    8.32      private BreakpointTranslator myTranslator;
    8.33      
    8.34      /**{@inheritDoc}*/
    8.35 @@ -107,10 +101,16 @@
    8.36      
    8.37      /**{@inheritDoc}*/
    8.38      public void removeAnnotation(Object annotation) {
    8.39 -        BpelAnnotation bpelAnnotation = (BpelAnnotation) annotation;
    8.40 +        final BpelAnnotation bpelAnnotation = (BpelAnnotation) annotation;
    8.41          bpelAnnotation.detach();
    8.42      }
    8.43      
    8.44 +    public boolean isAttached(Object annotation) {
    8.45 +        final BpelAnnotation bpelAnnotation = (BpelAnnotation) annotation;
    8.46 +        
    8.47 +        return bpelAnnotation.getState() == BpelAnnotation.State.ATTACHED;
    8.48 +    }
    8.49 +    
    8.50      public AnnotationType getAnnotationType(Object annotation) {
    8.51          BpelAnnotation bpelAnnotation = (BpelAnnotation) annotation;
    8.52          return bpelAnnotation.getType();
    8.53 @@ -155,8 +155,7 @@
    8.54              return null;
    8.55          }
    8.56          
    8.57 -        final BpelModel model = 
    8.58 -                (BpelModel) nodes[0].getLookup().lookup(BpelModel.class);
    8.59 +        final BpelModel model = nodes[0].getLookup().lookup(BpelModel.class);
    8.60          if (model == null) {
    8.61              return null;
    8.62          }
    8.63 @@ -193,46 +192,6 @@
    8.64          
    8.65          showBpelEntity(bpelEntityId);
    8.66          
    8.67 -//        int lineNumber = ModelUtil.getLineNumber(bpelEntityId, true);
    8.68 -//        if (lineNumber < 0) {
    8.69 -//            Log.out("Failed to get line number for UniqueId: " + bpelEntityId);
    8.70 -//            return false;
    8.71 -//        }
    8.72 -//        final Line line = Util.getLine(dataObject, lineNumber);
    8.73 -//        
    8.74 -//        if (line == null) {
    8.75 -//            return false;
    8.76 -//        }
    8.77 -//        javax.swing.SwingUtilities.invokeLater (new Runnable () {
    8.78 -//            public void run () {
    8.79 -////                TopComponent tc = WindowManager.getDefault().getRegistry().getActivated();
    8.80 -////
    8.81 -////                MultiViewHandler mvh = MultiViews.findMultiViewHandler(tc);
    8.82 -////                if (mvh == null) {
    8.83 -////                    return;
    8.84 -////                }
    8.85 -////
    8.86 -////                String tabId = "orch-designer";
    8.87 -////                MultiViewPerspective[] mvps = mvh.getPerspectives();
    8.88 -////                if (mvps != null && mvps.length >0) {
    8.89 -////                    for (MultiViewPerspective mvp : mvps) {
    8.90 -////                        if (mvp.preferredID().equals(tabId)) {
    8.91 -////                            mvh.requestVisible(mvp);
    8.92 -////                            mvh.requestActive(mvp);
    8.93 -////                        }
    8.94 -////                    }
    8.95 -////                }
    8.96 -////                Line line = Util.getLine(url, position.getLineNumber());
    8.97 -////
    8.98 -////                if (line == null) {
    8.99 -////                    return;
   8.100 -////                }
   8.101 -////                //TODO: see the openActiveSourceEditor method's todo
   8.102 -////                //"bpelsource"
   8.103 -//                line.show (Line.SHOW_GOTO);
   8.104 -//                openActiveEditorTab("bpelsource");
   8.105 -//            }
   8.106 -//        });
   8.107          return true;
   8.108      }
   8.109  
   8.110 @@ -243,118 +202,21 @@
   8.111                  url, lineNumber);
   8.112      }
   8.113      
   8.114 -    public synchronized void addAnnotationListener(Object annotation, PropertyChangeListener l) {
   8.115 +    public synchronized void addAnnotationListener(
   8.116 +            final Object annotation, 
   8.117 +            final PropertyChangeListener l) {
   8.118          BpelAnnotation bpelAnnotation = (BpelAnnotation)annotation;
   8.119          bpelAnnotation.addPropertyChangeListener(l);
   8.120 -//        BpelAnnotation bpelAnnotation = (BpelAnnotation)annotation;
   8.121 -//        DataObject dataObject = (DataObject)bpelAnnotation.getBpelEntityId().
   8.122 -//                getModel().getModelSource().getLookup().lookup(DataObject.class);
   8.123 -//        
   8.124 -//        if (dataObject == null) {
   8.125 -//            return;
   8.126 -//        }
   8.127 -//        
   8.128 -//        EditorCookie editor = (EditorCookie)dataObject.
   8.129 -//                getCookie(EditorCookie.class);
   8.130 -//        
   8.131 -//        if (editor == null || !(editor instanceof EditorCookie.Observable)) {
   8.132 -//            return;
   8.133 -//        }
   8.134 -//        
   8.135 -//                    
   8.136 -//        PropertyChangeSupport pcs = myAnnotationToListeners.get(bpelAnnotation);
   8.137 -//        if (pcs == null) {
   8.138 -//            pcs = new PropertyChangeSupport(bpelAnnotation);
   8.139 -//            myAnnotationToListeners.put(bpelAnnotation, pcs);
   8.140 -//        }
   8.141 -//        pcs.addPropertyChangeListener(l);
   8.142 -//        
   8.143 -//        
   8.144 -//        Set<BpelAnnotation> editorAnnotations = myEditorToAnnotations.get(editor);
   8.145 -//        if (editorAnnotations == null) {
   8.146 -//            editorAnnotations = new HashSet<BpelAnnotation>();
   8.147 -//            myEditorToAnnotations.put(editor, editorAnnotations);
   8.148 -//        }
   8.149 -//        editorAnnotations.add(bpelAnnotation);
   8.150 -//        
   8.151 -//        
   8.152 -//        EditorObserver observer = myEditorToObserver.get(editor);
   8.153 -//        if (observer == null) {
   8.154 -//            observer = new EditorObserver((EditorCookie.Observable)editor);
   8.155 -//            myEditorToObserver.put(editor, observer);
   8.156 -//            observer.subscribe(myEditorObserverListener);
   8.157 -//        }
   8.158      }
   8.159  
   8.160 -    public synchronized void removeAnnotationListener(Object annotation, PropertyChangeListener l) {
   8.161 +    public synchronized void removeAnnotationListener(
   8.162 +            final Object annotation, 
   8.163 +            final PropertyChangeListener l) {
   8.164          BpelAnnotation bpelAnnotation = (BpelAnnotation)annotation;
   8.165          bpelAnnotation.removePropertyChangeListener(l);
   8.166 -//        BpelAnnotation bpelAnnotation = (BpelAnnotation)annotation;
   8.167 -//        DataObject dataObject = (DataObject)bpelAnnotation.getBpelEntityId().
   8.168 -//                getModel().getModelSource().getLookup().lookup(DataObject.class);
   8.169 -//        
   8.170 -//        if (dataObject == null) {
   8.171 -//            return;
   8.172 -//        }
   8.173 -//        
   8.174 -//        EditorCookie editor = (EditorCookie)dataObject.
   8.175 -//                getCookie(EditorCookie.class);
   8.176 -//        
   8.177 -//        if (editor == null || !(editor instanceof EditorCookie.Observable)) {
   8.178 -//            return;
   8.179 -//        }
   8.180 -//        
   8.181 -//        
   8.182 -//        PropertyChangeSupport pcs = myAnnotationToListeners.get(bpelAnnotation);
   8.183 -//        if (pcs != null) {
   8.184 -//            pcs.removePropertyChangeListener(l);
   8.185 -//            if (!pcs.hasListeners(null)) {
   8.186 -//                myAnnotationToListeners.remove(bpelAnnotation);
   8.187 -//            }
   8.188 -//        }
   8.189 -//        
   8.190 -//        Set<BpelAnnotation> editorAnnotations = myEditorToAnnotations.get(editor);
   8.191 -//        if (editorAnnotations != null) {
   8.192 -//            editorAnnotations.remove(bpelAnnotation);
   8.193 -//            if (editorAnnotations.isEmpty()) {
   8.194 -//                myEditorToAnnotations.remove(editor);
   8.195 -//                
   8.196 -//                EditorObserver observer = myEditorToObserver.get(editor);
   8.197 -//                if (observer != null) {
   8.198 -//                    observer.unsubscribe();
   8.199 -//                    myEditorToObserver.remove(editor);
   8.200 -//                }
   8.201 -//            }
   8.202 -//        }
   8.203      }
   8.204      
   8.205      // Private /////////////////////////////////////////////////////////////////
   8.206 -    private void notifyAnnotationChanged(EditorCookie editor) {
   8.207 -        PropertyChangeSupport[] changeSupports = null;
   8.208 -        
   8.209 -        synchronized (this) {
   8.210 -            Set<BpelAnnotation> annotations = myEditorToAnnotations.get(editor);
   8.211 -            if (annotations == null) {
   8.212 -                return;
   8.213 -            }
   8.214 -
   8.215 -            changeSupports = new PropertyChangeSupport[annotations.size()];
   8.216 -
   8.217 -            int i = 0;
   8.218 -            for (BpelAnnotation annotation : annotations) {
   8.219 -                PropertyChangeSupport pcs = myAnnotationToListeners.get(annotation);
   8.220 -                if (pcs != null) {
   8.221 -                    changeSupports[i++] = pcs;
   8.222 -                }
   8.223 -            }
   8.224 -        }
   8.225 -        
   8.226 -        for (PropertyChangeSupport pcs : changeSupports) {
   8.227 -            pcs.firePropertyChange(null, null, null);
   8.228 -        }
   8.229 -
   8.230 -    }
   8.231 -    
   8.232      private BreakpointTranslator getBreakpointTranslator() {
   8.233          if (myTranslator == null) {
   8.234              myTranslator = new BreakpointTranslator();
   8.235 @@ -363,55 +225,66 @@
   8.236      }
   8.237      
   8.238      private void showBpelEntity(final UniqueId bpelEntityId) {
   8.239 -        BpelModel model = bpelEntityId.getModel();
   8.240 +        final BpelModel model = bpelEntityId.getModel();
   8.241          final BpelEntity bpelEntity = model.getEntity(bpelEntityId);
   8.242          
   8.243 -        final DataObject d = (DataObject)model.getModelSource().getLookup().lookup(DataObject.class);
   8.244 -        final LineCookie lc = (LineCookie) d.getCookie(LineCookie.class);
   8.245 -        final EditCookie ec = (EditCookie) d.getCookie(EditCookie.class);
   8.246 -        if (lc == null || ec == null) {
   8.247 +        final DataObject dataObject = 
   8.248 +                model.getModelSource().getLookup().lookup(DataObject.class);
   8.249 +        final LineCookie lineCookie = 
   8.250 +                dataObject.getCookie(LineCookie.class);
   8.251 +        final EditCookie editorCookie = 
   8.252 +                dataObject.getCookie(EditCookie.class);
   8.253 +        if ((lineCookie == null) || (editorCookie == null)) {
   8.254              return;
   8.255          }
   8.256          
   8.257 -        javax.swing.SwingUtilities.invokeLater(new Runnable() {
   8.258 +        SwingUtilities.invokeLater(new Runnable() {
   8.259              
   8.260              public void run() {
   8.261 -                ec.edit();
   8.262 +                editorCookie.edit();
   8.263                  
   8.264 -                TopComponent tc = WindowManager.getDefault().getRegistry()
   8.265 -                .getActivated();
   8.266 -                MultiViewHandler mvh = MultiViews.findMultiViewHandler(tc);
   8.267 +                final TopComponent tc = 
   8.268 +                        WindowManager.getDefault().getRegistry().getActivated();
   8.269 +                final MultiViewHandler mvh = 
   8.270 +                        MultiViews.findMultiViewHandler(tc);
   8.271                  
   8.272                  if (mvh == null) {
   8.273                      return;
   8.274                  }
   8.275                  
   8.276 -                MultiViewPerspective mvp = mvh.getSelectedPerspective();
   8.277 +                final MultiViewPerspective mvp = mvh.getSelectedPerspective();
   8.278                  if (mvp.preferredID().equals("orch-designer")) {
   8.279 -                    List<TopComponent> list = getAssociatedTopComponents(d);
   8.280 +                    final List<TopComponent> list = 
   8.281 +                            getAssociatedTopComponents(dataObject);
   8.282 +                    
   8.283                      for (TopComponent topComponent : list) {
   8.284                          // Make sure this is a multiview window, and not just
   8.285 -                        // some
   8.286 -                        // window that has our DataObject (e.g. Projects,Files).
   8.287 -                        MultiViewHandler handler = MultiViews
   8.288 +                        // some window that has our DataObject 
   8.289 +                        // (e.g. Projects, Files).
   8.290 +                        final MultiViewHandler handler = MultiViews
   8.291                                  .findMultiViewHandler(topComponent);
   8.292 +                        
   8.293                          if (handler != null && topComponent != null) {
   8.294 -                            SelectBpelElement selectElement =
   8.295 -                                    (SelectBpelElement) topComponent.getLookup()
   8.296 -                                    .lookup(SelectBpelElement.class);
   8.297 -                            if (selectElement == null)
   8.298 +                            final SelectBpelElement selectElement = 
   8.299 +                                    topComponent.getLookup().lookup(
   8.300 +                                    SelectBpelElement.class);
   8.301 +                            
   8.302 +                            if (selectElement == null) {
   8.303                                  return;
   8.304 +                            }
   8.305 +                            
   8.306                              selectElement.select(bpelEntity);
   8.307                          }
   8.308                      }
   8.309                  } else if (mvp.preferredID().equals("bpelsource")) {
   8.310 -                    int lineNum = ModelUtil.getLineNumber(bpelEntityId);
   8.311 -                    if (lineNum < 0) {
   8.312 +                    int lineNumber = ModelUtil.getLineNumber(bpelEntityId);
   8.313 +                    if (lineNumber < 0) {
   8.314                          return;
   8.315                      }
   8.316 -                    Line l = lc.getLineSet().getCurrent(lineNum - 1);
   8.317 -                    l.show(Line.SHOW_GOTO);
   8.318                      
   8.319 +                    final Line line = 
   8.320 +                            lineCookie.getLineSet().getCurrent(lineNumber - 1);
   8.321 +                    line.show(Line.SHOW_GOTO);
   8.322                  }
   8.323              }
   8.324          });
   8.325 @@ -424,55 +297,22 @@
   8.326          // any mode that are associated with the DataObject.
   8.327          // [Note that EDITOR_MODE does not contain editors in
   8.328          // split mode.]
   8.329 -        List<TopComponent> associatedTCs = new ArrayList<TopComponent>();
   8.330 -        TopComponent activeTC = TopComponent.getRegistry().getActivated();
   8.331 -        if (activeTC != null
   8.332 -                && targetDO == (DataObject) activeTC.getLookup().lookup(
   8.333 -                DataObject.class)) {
   8.334 +        final List<TopComponent> associatedTCs = new ArrayList<TopComponent>();
   8.335 +        final TopComponent activeTC = TopComponent.getRegistry().getActivated();
   8.336 +        if ((activeTC != null) && (
   8.337 +                targetDO == activeTC.getLookup().lookup(DataObject.class))) {
   8.338              associatedTCs.add(activeTC);
   8.339          }
   8.340 -        Set openTCs = TopComponent.getRegistry().getOpened();
   8.341 +        
   8.342 +        final Set openTCs = TopComponent.getRegistry().getOpened();
   8.343          for (Object tc : openTCs) {
   8.344 -            TopComponent tcc = (TopComponent) tc;
   8.345 -            if (targetDO == (DataObject) tcc.getLookup().lookup(
   8.346 -                    DataObject.class)) {
   8.347 +            final TopComponent tcc = (TopComponent) tc;
   8.348 +            
   8.349 +            if (targetDO == tcc.getLookup().lookup(DataObject.class)) {
   8.350                  associatedTCs.add(tcc);
   8.351              }
   8.352          }
   8.353 +        
   8.354          return associatedTCs;
   8.355      }
   8.356 -    
   8.357 -    //TODO:check it out
   8.358 -    //Maybe it's not a good way to ensure that the source editor pane
   8.359 -    //is opened when Line.show() is inovked. It seems that it is the
   8.360 -    //responsibility of some of the BPELDataObject's cookie implementations
   8.361 -    //(i.e. EditorCookie or LineCookie)
   8.362 -    private static void openActiveEditorTab(String tabId) {
   8.363 -//        EditorCookie editorCookie;
   8.364 -//        editorCookie.getOpenedPanes()
   8.365 -        
   8.366 -        TopComponent tc = WindowManager.getDefault().getRegistry().getActivated();
   8.367 -        MultiViewHandler mvh = MultiViews.findMultiViewHandler(tc);
   8.368 -        if (mvh == null) {
   8.369 -            return;
   8.370 -        }
   8.371 -
   8.372 -        MultiViewPerspective[] mvps = mvh.getPerspectives();
   8.373 -        if (mvps != null && mvps.length >0) {
   8.374 -            for (MultiViewPerspective mvp : mvps) {
   8.375 -                if (mvp.preferredID().equals(tabId)) {
   8.376 -                    mvh.requestVisible(mvp);
   8.377 -                    mvh.requestActive(mvp);
   8.378 -                }
   8.379 -            }
   8.380 -        }
   8.381 -    }
   8.382 -    
   8.383 -    ////////////////////////////////////////////////////////////////////////////
   8.384 -    // Inner Classes
   8.385 -    private class EditorObserverListener implements PropertyChangeListener {
   8.386 -        public void propertyChange(PropertyChangeEvent evt) {
   8.387 -            notifyAnnotationChanged((EditorCookie)evt.getSource());
   8.388 -        }
   8.389 -    }
   8.390  }
     9.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/plinks/PLinksTreeModel.java	Fri Dec 21 12:46:40 2007 +0000
     9.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/plinks/PLinksTreeModel.java	Fri Dec 21 13:42:26 2007 +0000
     9.3 @@ -36,6 +36,7 @@
     9.4  import org.netbeans.modules.bpel.debugger.ui.plinks.models.RoleRefWrapper.RoleType;
     9.5  import org.netbeans.modules.bpel.debugger.ui.util.VariablesUtil;
     9.6  import org.netbeans.modules.bpel.debugger.ui.util.XmlUtil;
     9.7 +import org.netbeans.modules.bpel.model.api.BpelModel;
     9.8  import org.netbeans.modules.bpel.model.api.PartnerLink;
     9.9  import org.netbeans.modules.bpel.model.api.Scope;
    9.10  import org.netbeans.spi.debugger.ContextProvider;
    9.11 @@ -216,7 +217,7 @@
    9.12          
    9.13          final PartnerLink[] pLinks = getStaticPartnerLinks();
    9.14          final RuntimePartnerLink[] rLinks = 
    9.15 -                myDebugger.getCurrentProcessInstance().getRuntimePartnerLinks();
    9.16 +                processInstance.getRuntimePartnerLinks();
    9.17          
    9.18          final PartnerLinkWrapper[] result = 
    9.19                  new PartnerLinkWrapper[pLinks.length];
    9.20 @@ -237,11 +238,16 @@
    9.21      
    9.22      private PartnerLink[] getStaticPartnerLinks() {
    9.23          final VariablesUtil helper = new VariablesUtil(myDebugger);
    9.24 +        final BpelModel model = helper.getBpelModel();
    9.25 +        
    9.26 +        if (model == null) {
    9.27 +            return new PartnerLink[0];
    9.28 +        }
    9.29          
    9.30          final List<PartnerLink> pLinks = new LinkedList<PartnerLink>();
    9.31          
    9.32          // Add the variables from the process
    9.33 -        pLinks.addAll(Arrays.asList(helper.getBpelModel().getProcess().
    9.34 +        pLinks.addAll(Arrays.asList(model.getProcess().
    9.35                  getPartnerLinkContainer().getPartnerLinks()));
    9.36          
    9.37          final String xpath = myDebugger.getCurrentProcessInstance().
    10.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesActionProvider.java	Fri Dec 21 12:46:40 2007 +0000
    10.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesActionProvider.java	Fri Dec 21 13:42:26 2007 +0000
    10.3 @@ -179,7 +179,7 @@
    10.4              final Object object) {
    10.5          
    10.6          if (object instanceof ProcessInstance) {
    10.7 -            object.equals(myDebugger.getCurrentProcessInstance());
    10.8 +            return !object.equals(myDebugger.getCurrentProcessInstance());
    10.9          }
   10.10          
   10.11          return false;
    11.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesNodeModel.java	Fri Dec 21 12:46:40 2007 +0000
    11.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesNodeModel.java	Fri Dec 21 13:42:26 2007 +0000
    11.3 @@ -135,12 +135,12 @@
    11.4      
    11.5      // Private /////////////////////////////////////////////////////////////////
    11.6      private boolean isProcessInstanceCurrent(
    11.7 -            final ProcessInstance process) {
    11.8 +            final ProcessInstance instance) {
    11.9          
   11.10          if (myDebugger == null) {
   11.11              return false;
   11.12          } else {
   11.13 -            return process == myDebugger.getCurrentProcessInstance();
   11.14 +            return instance == myDebugger.getCurrentProcessInstance();
   11.15          }
   11.16      }
   11.17      
    12.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesTreeModel.java	Fri Dec 21 12:46:40 2007 +0000
    12.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/process/ProcessesTreeModel.java	Fri Dec 21 13:42:26 2007 +0000
    12.3 @@ -268,8 +268,8 @@
    12.4      private int getProcessInstancesCount(
    12.5              final BpelProcess process) {
    12.6          if (myDebugger != null) {
    12.7 -            return myDebugger.
    12.8 -                    getProcessInstancesModel().getProcessInstances().length;
    12.9 +            return myDebugger.getProcessInstancesModel().
   12.10 +                    getProcessInstances(process).length;
   12.11          }
   12.12          
   12.13          return 0;
    13.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/Bundle.properties	Fri Dec 21 12:46:40 2007 +0000
    13.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/Bundle.properties	Fri Dec 21 13:42:26 2007 +0000
    13.3 @@ -18,9 +18,9 @@
    13.4  #
    13.5  
    13.6  # VariablesUtil
    13.7 -VU_CannotResolveDN= > Cannot resolve display name for {0} < 
    13.8 -VU_CannotResolveType= > Cannot resolve type for {0} < 
    13.9 -VU_CannotResolveValue= > Cannot resolve vaue for {0} < 
   13.10 +VU_CannotResolveDN=> Cannot resolve display name for {0} <
   13.11 +VU_CannotResolveType=> Cannot resolve type for {0} <
   13.12 +VU_CannotResolveValue=> Cannot resolve value for {0} <
   13.13  
   13.14  VU_TypeElement=XML Element
   13.15  VU_TypeAttribute=XML Attribute
    14.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/EditorUtil.java	Fri Dec 21 12:46:40 2007 +0000
    14.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/EditorUtil.java	Fri Dec 21 13:42:26 2007 +0000
    14.3 @@ -51,8 +51,10 @@
    14.4  
    14.5      private EditorUtil() {}
    14.6      
    14.7 -    public static Line getLine(DataObject dataObject, int lineNumber) {
    14.8 -        LineCookie lineCookie = (LineCookie)dataObject.getCookie(LineCookie.class);
    14.9 +    public static Line getLine(
   14.10 +            final DataObject dataObject, 
   14.11 +            final int lineNumber) {
   14.12 +        LineCookie lineCookie = dataObject.getCookie(LineCookie.class);
   14.13          if (lineCookie == null) {
   14.14              Log.out("Line cookie is null: " + dataObject); // NOI18N
   14.15              return null;
   14.16 @@ -72,7 +74,8 @@
   14.17          }
   14.18      }
   14.19      
   14.20 -    public static DataObject getDataObject(String url) {
   14.21 +    public static DataObject getDataObject(
   14.22 +            final String url) {
   14.23          FileObject fileObject = FileUtil.toFileObject(new File(url));
   14.24          if (fileObject == null) {
   14.25              Log.out("fileObject is null :" + url); // NOI18N
   14.26 @@ -87,17 +90,19 @@
   14.27          }
   14.28      }
   14.29      
   14.30 -    public static BpelModel getBpelModel(DataObject dataObject) {
   14.31 +    public static BpelModel getBpelModel(
   14.32 +            final DataObject dataObject) {
   14.33          if (dataObject instanceof Lookup.Provider) {
   14.34              Lookup.Provider lookupProvider = (Lookup.Provider)dataObject;
   14.35 -            return (BpelModel)lookupProvider.getLookup().lookup(BpelModel.class);
   14.36 +            return lookupProvider.getLookup().lookup(BpelModel.class);
   14.37          } else {
   14.38              Log.out("Can't lookup a BpelModel - not a Lookup.Provider :" + dataObject); // NOI18N
   14.39              return null;
   14.40          }
   14.41      }
   14.42      
   14.43 -    public static BpelModel getBpelModel(String url) {
   14.44 +    public static BpelModel getBpelModel(
   14.45 +            final String url) {
   14.46          DataObject dataObject = getDataObject(url);
   14.47          if (dataObject == null) {
   14.48              Log.out("DataObject is null :" + url); // NOI18N
   14.49 @@ -107,9 +112,10 @@
   14.50          return getBpelModel(dataObject);
   14.51      }
   14.52      
   14.53 -    public static StyledDocument getDocument(DataObject dataObject) {
   14.54 +    public static StyledDocument getDocument(
   14.55 +            final DataObject dataObject) {
   14.56          EditorCookie editorCookie =
   14.57 -                (EditorCookie)dataObject.getCookie(EditorCookie.class);
   14.58 +                dataObject.getCookie(EditorCookie.class);
   14.59          if (editorCookie == null) {
   14.60              Log.out("Editor cookie is null"); // NOI18N
   14.61              return null;
   14.62 @@ -118,11 +124,14 @@
   14.63          return editorCookie.getDocument();
   14.64      }
   14.65      
   14.66 -    public static String getFileName(String name) {
   14.67 +    public static String getFileName(
   14.68 +            final String name) {
   14.69          return getTail(getTail(name, "/"), "\\"); // NOI18N
   14.70      }
   14.71      
   14.72 -    public static int findOffset(Document doc, int lineNumber) {
   14.73 +    public static int findOffset(
   14.74 +            final Document doc, 
   14.75 +            final int lineNumber) {
   14.76          Element rootElement = doc.getDefaultRootElement();
   14.77          Element lineElement = rootElement.getElement(lineNumber - 1);
   14.78          int lineOffset = lineElement.getStartOffset();
   14.79 @@ -141,26 +150,27 @@
   14.80          return lineOffset + column;
   14.81      }
   14.82      
   14.83 -    public static int getLineNumber(Node node) {
   14.84 -        EditorCookie editorCookie = node.getLookup().lookup(EditorCookie.class);
   14.85 +    public static int getLineNumber(
   14.86 +            final Node node) {
   14.87 +        final EditorCookie editorCookie = 
   14.88 +                node.getLookup().lookup(EditorCookie.class);
   14.89          if (editorCookie == null) {
   14.90              return -1;
   14.91          }
   14.92          
   14.93 -        
   14.94 -        JEditorPane[] editorPanes = editorCookie.getOpenedPanes();
   14.95 -        if (editorPanes == null || editorPanes.length == 0) {
   14.96 +        final JEditorPane pane = getEditorPane(editorCookie);
   14.97 +        if (pane == null) {
   14.98              return -1;
   14.99          }
  14.100          
  14.101 -        Caret caret = editorPanes[0].getCaret();
  14.102 +        final Caret caret = pane.getCaret();
  14.103          if (caret == null) {
  14.104              return -1;
  14.105          }
  14.106          
  14.107          int offset = caret.getDot();
  14.108          
  14.109 -        StyledDocument document = editorCookie.getDocument();
  14.110 +        final StyledDocument document = editorCookie.getDocument();
  14.111          if (document == null) {
  14.112              return -1;
  14.113          }
  14.114 @@ -179,8 +189,9 @@
  14.115      public static Line getCurrentLine() {
  14.116          final Node[] nodes = TopComponent.getRegistry().getCurrentNodes();
  14.117          
  14.118 -        if (nodes == null) return null;
  14.119 -        if (nodes.length != 1) return null;
  14.120 +        if ((nodes == null) || (nodes.length != 1)) {
  14.121 +            return null;
  14.122 +        }
  14.123          
  14.124          Node node = nodes[0];
  14.125          
  14.126 @@ -191,61 +202,87 @@
  14.127                  fileObject = dobj.getPrimaryFile();
  14.128              }
  14.129          }
  14.130 -        if (fileObject == null) return null;
  14.131 +        if (fileObject == null) {
  14.132 +            return null;
  14.133 +        }
  14.134          
  14.135          if (!BPELDataLoader.MIME_TYPE.equals(fileObject.getMIMEType())) {
  14.136              return null;
  14.137          }
  14.138          
  14.139          final LineCookie lineCookie = node.getCookie(LineCookie.class);
  14.140 -        if (lineCookie == null) return null;
  14.141 +        if (lineCookie == null) {
  14.142 +            return null;
  14.143 +        }
  14.144          
  14.145          final EditorCookie editorCookie = node.getCookie(EditorCookie.class);
  14.146 -        if (editorCookie == null) return null;
  14.147 +        if (editorCookie == null) {
  14.148 +            return null;
  14.149 +        }
  14.150                  
  14.151          final JEditorPane jEditorPane = getEditorPane(editorCookie);
  14.152 -        if (jEditorPane == null) return null;
  14.153 +        if (jEditorPane == null) {
  14.154 +            return null;
  14.155 +        }
  14.156          
  14.157          final StyledDocument document = editorCookie.getDocument();
  14.158 -        if (document == null) return null;
  14.159 +        if (document == null) {
  14.160 +            return null;
  14.161 +        }
  14.162          
  14.163          final Caret caret = jEditorPane.getCaret();
  14.164 -        if (caret == null) return null;
  14.165 +        if (caret == null) {
  14.166 +            return null;
  14.167 +        }
  14.168          
  14.169          final int lineNumber = 
  14.170                  NbDocument.findLineNumber(document, caret.getDot());
  14.171          try {
  14.172              Line.Set lineSet = lineCookie.getLineSet();
  14.173 -            assert lineSet != null : lineCookie;
  14.174 +            
  14.175              return lineSet.getCurrent(lineNumber);
  14.176          } catch (IndexOutOfBoundsException ex) {
  14.177              return null;
  14.178          }
  14.179      }
  14.180      
  14.181 -    /* (non-javadoc)
  14.182 -     * 
  14.183 -     * Mostly copied from org.netbeans.modules.ruby.debugger.EditorUtil
  14.184 -     */
  14.185 -    private static JEditorPane getEditorPane_(EditorCookie editorCookie) {
  14.186 -        JEditorPane[] op = editorCookie.getOpenedPanes();
  14.187 -        if ((op == null) || (op.length < 1)) return null;
  14.188 -        return op [0];
  14.189 +    public static String getText(
  14.190 +            final String url) {
  14.191 +        final DataObject dataObject = getDataObject(url);
  14.192 +        if (dataObject == null) {
  14.193 +            return "";
  14.194 +        }
  14.195 +        
  14.196 +        final EditorCookie editorCookie = 
  14.197 +                dataObject.getCookie(EditorCookie.class);
  14.198 +        if (editorCookie == null) {
  14.199 +            return "";
  14.200 +        }
  14.201 +        
  14.202 +        final JEditorPane pane = getEditorPane(editorCookie);
  14.203 +        if (pane == null) {
  14.204 +              return "" ;
  14.205 +        }
  14.206 +        
  14.207 +        return pane.getText();
  14.208      }
  14.209      
  14.210 -    /* (non-javadoc)
  14.211 -     * 
  14.212 -     * Mostly copied from org.netbeans.modules.ruby.debugger.EditorUtil
  14.213 -     */
  14.214 -    private static JEditorPane getEditorPane(final EditorCookie editorCookie) {
  14.215 +    private static JEditorPane getEditorPane(
  14.216 +            final EditorCookie editorCookie) {
  14.217          if (SwingUtilities.isEventDispatchThread()) {
  14.218 -            return getEditorPane_(editorCookie);
  14.219 +            final JEditorPane[] panes = editorCookie.getOpenedPanes();
  14.220 +            
  14.221 +            if ((panes == null) || (panes.length < 1)) {
  14.222 +                return null;
  14.223 +            }
  14.224 +            
  14.225 +            return panes[0];
  14.226          } else {
  14.227 -            final JEditorPane[] ce = new JEditorPane[1];
  14.228 +            final JEditorPane[] panes = new JEditorPane[1];
  14.229              try {
  14.230                  EventQueue.invokeAndWait(new Runnable() {
  14.231                      public void run() {
  14.232 -                        ce[0] = getEditorPane_(editorCookie);
  14.233 +                        panes[0] = getEditorPane(editorCookie);
  14.234                      }
  14.235                  });
  14.236              } catch (InvocationTargetException ex) {
  14.237 @@ -254,11 +291,12 @@
  14.238                  //Util.severe(ex);
  14.239                  Thread.currentThread().interrupt();
  14.240              }
  14.241 -            return ce[0];
  14.242 +            return panes[0];
  14.243          }
  14.244      }
  14.245      
  14.246 -    private static int findNotSpace(String str) {
  14.247 +    private static int findNotSpace(
  14.248 +            final String str) {
  14.249          for (int i=0; i < str.length(); i++) {
  14.250              if (str.charAt(i) > ' ') {
  14.251                  return i;
  14.252 @@ -267,7 +305,9 @@
  14.253          return -1;
  14.254      }
  14.255      
  14.256 -    private static String getTail (String value, String delim) {
  14.257 +    private static String getTail(
  14.258 +            final String value, 
  14.259 +            final String delim) {
  14.260          int k = value.lastIndexOf (delim);
  14.261  
  14.262          if (k != -1) {
    15.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/VariablesUtil.java	Fri Dec 21 12:46:40 2007 +0000
    15.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/util/VariablesUtil.java	Fri Dec 21 13:42:26 2007 +0000
    15.3 @@ -24,6 +24,7 @@
    15.4  import java.util.List;
    15.5  import java.util.StringTokenizer;
    15.6  import javax.xml.namespace.QName;
    15.7 +import org.netbeans.api.debugger.DebuggerEngine;
    15.8  import org.netbeans.api.debugger.DebuggerManager;
    15.9  import org.netbeans.modules.bpel.debugger.api.BpelDebugger;
   15.10  import org.netbeans.modules.bpel.debugger.api.ProcessInstance;
   15.11 @@ -464,24 +465,24 @@
   15.12              final Object object) {
   15.13          if (object instanceof NamedValueHost) {
   15.14              if (object instanceof WsdlMessageVariable) {
   15.15 -                return " " + getValue((WsdlMessageVariable) object) + " ";
   15.16 +                return getValue((WsdlMessageVariable) object);
   15.17              }
   15.18  
   15.19              if (object instanceof WsdlMessageValue.Part) {
   15.20 -                return " " + getValue((WsdlMessageValue.Part) object) + " ";
   15.21 +                return getValue((WsdlMessageValue.Part) object);
   15.22              }
   15.23  
   15.24              if (object instanceof XmlElementVariable) {
   15.25 -                return " " + getValue((XmlElementVariable) object) + " ";
   15.26 +                return getValue((XmlElementVariable) object);
   15.27              }
   15.28  
   15.29              if (object instanceof SimpleVariable) {
   15.30 -                return " " + getValue((SimpleVariable) object) + " ";
   15.31 +                return getValue((SimpleVariable) object);
   15.32              }
   15.33          }
   15.34  
   15.35          if (object instanceof Node) {
   15.36 -            return " " + getValue((Node) object) + " ";
   15.37 +            return getValue((Node) object);
   15.38          }
   15.39  
   15.40          return NbBundle.getMessage(
   15.41 @@ -655,7 +656,7 @@
   15.42      
   15.43      private boolean isValueReadOnly(
   15.44              final SimpleVariable object) {
   15.45 -        return false;
   15.46 +        return object.getValue() == null;
   15.47      }
   15.48      
   15.49      private boolean isValueReadOnly(
   15.50 @@ -721,6 +722,13 @@
   15.51      private void setValue(
   15.52              final Node object,
   15.53              final String value) {
   15.54 +        if (XmlUtil.isTextOnlyNode(object)) {
   15.55 +            setValue(object.getChildNodes().item(0), value);
   15.56 +            return;
   15.57 +        }
   15.58 +        
   15.59 +        object.setNodeValue(value);
   15.60 +        
   15.61          final XmlElementValue xmlValue = XmlElementValue.Helper.find(object);
   15.62          final NamedValueHost valueHost = xmlValue.getValueHost();
   15.63          
   15.64 @@ -843,12 +851,23 @@
   15.65      
   15.66      // Miscellaneous ///////////////////////////////////////////////////////////
   15.67      public BpelModel getBpelModel() {
   15.68 -        final SourcePath sourcePath = (SourcePath) DebuggerManager.
   15.69 -                getDebuggerManager().
   15.70 -                getCurrentEngine().lookupFirst(null, SourcePath.class);
   15.71 -
   15.72 -        return EditorUtil.getBpelModel(sourcePath.getSourcePath(myDebugger.
   15.73 -                getCurrentProcessInstance().getProcess().getQName()));
   15.74 +        final DebuggerEngine engine = DebuggerManager.getDebuggerManager().
   15.75 +                getCurrentEngine();
   15.76 +        
   15.77 +        if (engine == null) {
   15.78 +            return null;
   15.79 +        }
   15.80 +        
   15.81 +        final SourcePath sourcePath = 
   15.82 +                (SourcePath) engine.lookupFirst(null, SourcePath.class);
   15.83 +        final ProcessInstance instance = myDebugger.getCurrentProcessInstance();
   15.84 +        
   15.85 +        if ((sourcePath == null) || (instance == null)) {
   15.86 +            return null;
   15.87 +        }
   15.88 +        
   15.89 +        return EditorUtil.getBpelModel(sourcePath.getSourcePath(
   15.90 +                instance.getProcess().getQName()));
   15.91      }
   15.92      
   15.93      /**
   15.94 @@ -865,8 +884,14 @@
   15.95              final String name) {
   15.96          final List<Variable> variables = new LinkedList<Variable>();
   15.97          
   15.98 +        final BpelModel model = getBpelModel();
   15.99 +        
  15.100 +        if (model == null) {
  15.101 +            return null;
  15.102 +        }
  15.103 +        
  15.104          // Add the variables from the process
  15.105 -        variables.addAll(Arrays.asList(getBpelModel().getProcess().
  15.106 +        variables.addAll(Arrays.asList(model.getProcess().
  15.107                  getVariableContainer().getVariables()));
  15.108          
  15.109          final String xpath = myDebugger.getCurrentProcessInstance().
  15.110 @@ -902,7 +927,13 @@
  15.111      public Scope getScopeEntity(
  15.112              final String xpath) {
  15.113          
  15.114 -        BpelEntity currentEntity = getBpelModel().getProcess();
  15.115 +        final BpelModel model = getBpelModel();
  15.116 +        
  15.117 +        if (model == null) {
  15.118 +            return null;
  15.119 +        }
  15.120 +        
  15.121 +        BpelEntity currentEntity = model.getProcess();
  15.122          
  15.123          final StringTokenizer tokenizer = 
  15.124                  new StringTokenizer(xpath, "/"); // NOI18N
    16.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsColumnModel_Value.java	Fri Dec 21 12:46:40 2007 +0000
    16.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsColumnModel_Value.java	Fri Dec 21 13:42:26 2007 +0000
    16.3 @@ -21,16 +21,15 @@
    16.4  
    16.5  import java.awt.BorderLayout;
    16.6  import java.awt.Component;
    16.7 +import java.beans.PropertyChangeEvent;
    16.8 +import java.beans.PropertyChangeListener;
    16.9  import java.beans.PropertyEditor;
   16.10  import java.beans.PropertyEditorSupport;
   16.11 -import java.util.ResourceBundle;
   16.12  import javax.swing.JEditorPane;
   16.13  import javax.swing.JPanel;
   16.14  import javax.swing.JScrollPane;
   16.15  import javax.swing.border.CompoundBorder;
   16.16  import javax.swing.border.EmptyBorder;
   16.17 -import javax.swing.event.DocumentEvent;
   16.18 -import javax.swing.event.DocumentListener;
   16.19  import org.netbeans.modules.bpel.debugger.api.BpelDebugger;
   16.20  import org.netbeans.modules.bpel.debugger.ui.util.AbstractColumn;
   16.21  import org.netbeans.modules.bpel.debugger.ui.util.VariablesUtil;
   16.22 @@ -38,7 +37,6 @@
   16.23  import org.netbeans.spi.debugger.ui.Constants;
   16.24  import org.openide.explorer.propertysheet.ExPropertyEditor;
   16.25  import org.openide.explorer.propertysheet.PropertyEnv;
   16.26 -import org.openide.util.NbBundle;
   16.27  
   16.28  /**
   16.29   * 
   16.30 @@ -68,8 +66,9 @@
   16.31      // Inner Classes
   16.32      public static class ColumnPropertyEditor extends PropertyEditorSupport
   16.33              implements ExPropertyEditor {
   16.34 -            
   16.35 +        
   16.36          private VariablesUtil myHelper;
   16.37 +        private PropertyEnv myPropertyEnv;
   16.38          
   16.39          public ColumnPropertyEditor(
   16.40                  final BpelDebugger debugger) {
   16.41 @@ -83,54 +82,66 @@
   16.42          }
   16.43          
   16.44          @Override
   16.45 +        public void setAsText(
   16.46 +                final String value) {
   16.47 +            
   16.48 +            myHelper.setValue(getValue(), value);
   16.49 +        }
   16.50 +        
   16.51 +        @Override
   16.52          public boolean supportsCustomEditor() {
   16.53              return myHelper.supportsCustomEditor(getValue());
   16.54          }
   16.55          
   16.56          @Override
   16.57          public Component getCustomEditor() {
   16.58 -            final String text = 
   16.59 -                    myHelper.getCustomEditorValue(getValue());
   16.60 -            final String mimeType = 
   16.61 -                    myHelper.getCustomEditorMimeType(getValue());
   16.62 -            final boolean editable = 
   16.63 -                    !myHelper.isValueReadOnly(getValue());
   16.64 -            
   16.65 -            return new ColumnCustomEditor(text, mimeType, editable, this);
   16.66 +            return new ColumnCustomEditor(
   16.67 +                    this, myHelper, myPropertyEnv);
   16.68          }
   16.69          
   16.70          public void attachEnv(
   16.71                  final PropertyEnv propertyEnv) {
   16.72 -            // does nothing
   16.73 +            myPropertyEnv = propertyEnv;
   16.74          }
   16.75      }
   16.76      
   16.77 -    public static class ColumnCustomEditor extends JPanel {
   16.78 +    public static class ColumnCustomEditor extends JPanel 
   16.79 +            implements PropertyChangeListener {
   16.80          
   16.81          private JEditorPane myEditorPane;
   16.82          
   16.83 -        private String myText;
   16.84 -        private String myMimeType;
   16.85 -        private boolean myEditable;
   16.86          private ColumnPropertyEditor myEditor;
   16.87 +        private VariablesUtil myHelper;
   16.88 +        private PropertyEnv myPropertyEnv;
   16.89          
   16.90          public ColumnCustomEditor(
   16.91 -                final String text, 
   16.92 -                final String mimeType,
   16.93 -                final boolean editable, 
   16.94 -                final ColumnPropertyEditor editor) {
   16.95 -            myText = text;
   16.96 -            myMimeType = mimeType;
   16.97 -            myEditable = editable;
   16.98 +                final ColumnPropertyEditor editor,
   16.99 +                final VariablesUtil helper,
  16.100 +                final PropertyEnv propertyEnv) {
  16.101 +            myHelper = helper;
  16.102              myEditor = editor;
  16.103 +            myPropertyEnv = propertyEnv;
  16.104              
  16.105              init();
  16.106 +            
  16.107 +            myPropertyEnv.setState(PropertyEnv.STATE_NEEDS_VALIDATION);
  16.108 +            myPropertyEnv.addPropertyChangeListener(this);
  16.109          }
  16.110          
  16.111 -        public void init() {
  16.112 -            final ResourceBundle bundle = 
  16.113 -                    NbBundle.getBundle(LocalsColumnModel_Value.class);
  16.114 -            
  16.115 +        public void propertyChange(PropertyChangeEvent evt) {
  16.116 +            if (PropertyEnv.PROP_STATE.equals(evt.getPropertyName()) && 
  16.117 +                    (evt.getNewValue() == PropertyEnv.STATE_VALID)) {
  16.118 +                myEditor.setAsText(myEditorPane.getText());
  16.119 +            }
  16.120 +        }
  16.121 +        
  16.122 +        private void init() {
  16.123 +            final String text = 
  16.124 +                    myHelper.getCustomEditorValue(myEditor.getValue());
  16.125 +            final String mimeType = 
  16.126 +                    myHelper.getCustomEditorMimeType(myEditor.getValue());
  16.127 +            final boolean editable = 
  16.128 +                    !myHelper.isValueReadOnly(myEditor.getValue());
  16.129              
  16.130              setLayout(new BorderLayout());
  16.131              setBorder(new EmptyBorder(12, 12, 0, 11));
  16.132 @@ -139,32 +150,32 @@
  16.133              getAccessibleContext().setAccessibleDescription(
  16.134                      "ACSD_BpelVariableCustomEditor"); // NOI18N
  16.135              
  16.136 -            myEditorPane = new JEditorPane(myMimeType, myText); // NOI18N
  16.137 +            myEditorPane = new JEditorPane(mimeType, text); // NOI18N
  16.138              
  16.139              myEditorPane.setBorder(
  16.140                  new CompoundBorder(myEditorPane.getBorder(),
  16.141                  new EmptyBorder(2, 0, 2, 0))
  16.142              );
  16.143 -            myEditorPane.setEditable(myEditable);
  16.144 -            myEditorPane.setText(myText);
  16.145 +            myEditorPane.setEditable(editable);
  16.146 +            myEditorPane.setText(text);
  16.147              myEditorPane.requestFocus();
  16.148              myEditorPane.setCaretPosition(0);
  16.149              
  16.150 -            myEditorPane.getDocument().addDocumentListener(
  16.151 -                    new DocumentListener() {
  16.152 -                public void insertUpdate(DocumentEvent event) {
  16.153 -                    myEditor.setValue(myEditorPane.getText());
  16.154 -                }
  16.155 -                
  16.156 -                public void removeUpdate(DocumentEvent event) {
  16.157 -                    myEditor.setValue(myEditorPane.getText());
  16.158 -                }
  16.159 -                
  16.160 -                public void changedUpdate(DocumentEvent event) {
  16.161 -                    myEditor.setValue(myEditorPane.getText());
  16.162 -                }
  16.163 -            });
  16.164 -            
  16.165 +//            myEditorPane.getDocument().addDocumentListener(
  16.166 +//                    new DocumentListener() {
  16.167 +//                public void insertUpdate(DocumentEvent event) {
  16.168 +//                    myEditor.setValue(myEditorPane.getText());
  16.169 +//                }
  16.170 +//                
  16.171 +//                public void removeUpdate(DocumentEvent event) {
  16.172 +//                    myEditor.setValue(myEditorPane.getText());
  16.173 +//                }
  16.174 +//                
  16.175 +//                public void changedUpdate(DocumentEvent event) {
  16.176 +//                    myEditor.setValue(myEditorPane.getText());
  16.177 +//                }
  16.178 +//            });
  16.179 +//            
  16.180              myEditorPane.getAccessibleContext().
  16.181                      setAccessibleName("ACS_EditorPane"); // NOI18N
  16.182              myEditorPane.getAccessibleContext().
  16.183 @@ -173,5 +184,7 @@
  16.184              final JScrollPane scrollPane = new JScrollPane(myEditorPane);
  16.185              add(scrollPane, BorderLayout.CENTER);
  16.186          }
  16.187 +        
  16.188 +        private static final long serialVersionUID = 1L;
  16.189      }
  16.190  }
    17.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTableModel.java	Fri Dec 21 12:46:40 2007 +0000
    17.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTableModel.java	Fri Dec 21 13:42:26 2007 +0000
    17.3 @@ -43,7 +43,7 @@
    17.4      private BpelDebugger myDebugger;
    17.5      private VariablesUtil myHelper;
    17.6      
    17.7 -    private Vector myListeners = new Vector();
    17.8 +    private Vector<ModelListener> myListeners = new Vector<ModelListener>();
    17.9      
   17.10      /**{@inheritDoc}*/
   17.11      public LocalsTableModel(
   17.12 @@ -141,20 +141,16 @@
   17.13      }
   17.14      
   17.15      // Private /////////////////////////////////////////////////////////////////
   17.16 -    
   17.17 -    //TODO:this is neither an effecient nor right way to notify about variable
   17.18 -    //change. Need to fire event on the BpelDebugger level and subscribe tree
   17.19 -    //model to listen for "variable changed" events. With this approach 
   17.20 -    //WatchesTreeModel can subscribe as well
   17.21      private void fireTableValueChanged(
   17.22              final Object node, 
   17.23 -            final String propertyName) {
   17.24 +            final String columnId) {
   17.25          
   17.26          final Vector clone = (Vector) myListeners.clone();
   17.27 +        final ModelEvent.TableValueChanged event = 
   17.28 +                new ModelEvent.TableValueChanged(this, node, columnId);
   17.29          
   17.30          for (int i = 0; i < clone.size(); i++) {
   17.31 -            ((ModelListener) clone.get(i)).modelChanged(
   17.32 -                    new ModelEvent.TreeChanged(this));
   17.33 +            ((ModelListener) clone.get(i)).modelChanged(event);
   17.34          }
   17.35      }
   17.36  }
    18.1 --- a/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTreeModel.java	Fri Dec 21 12:46:40 2007 +0000
    18.2 +++ b/bpel.debugger.ui/src/org/netbeans/modules/bpel/debugger/ui/variable/LocalsTreeModel.java	Fri Dec 21 13:42:26 2007 +0000
    18.3 @@ -46,7 +46,7 @@
    18.4      private VariablesUtil myHelper;
    18.5      
    18.6      private PositionListener myListener;
    18.7 -    private Vector myListeners = new Vector();
    18.8 +    private Vector<ModelListener> myListeners = new Vector<ModelListener>();
    18.9      
   18.10      /**
   18.11       * Creates a new instance of BpelVariableTreeModel.
   18.12 @@ -123,7 +123,7 @@
   18.13      private static class PositionListener implements PropertyChangeListener {
   18.14  
   18.15          private BpelDebugger myDebugger;
   18.16 -        private WeakReference myModel;
   18.17 +        private WeakReference<LocalsTreeModel> myModel;
   18.18  
   18.19          // currently waiting / running refresh task
   18.20          // there is at most one
   18.21 @@ -133,7 +133,7 @@
   18.22                  final LocalsTreeModel model, 
   18.23                  final BpelDebugger debugger) {
   18.24              myDebugger = debugger;
   18.25 -            myModel = new WeakReference(model);
   18.26 +            myModel = new WeakReference<LocalsTreeModel>(model);
   18.27              
   18.28              debugger.addPropertyChangeListener(this);
   18.29          }
   18.30 @@ -149,8 +149,7 @@
   18.31          }
   18.32  
   18.33          private LocalsTreeModel getModel() {
   18.34 -            final LocalsTreeModel model =
   18.35 -                    (LocalsTreeModel) myModel.get();
   18.36 +            final LocalsTreeModel model = myModel.get();
   18.37              
   18.38              if (model == null) {
   18.39                  destroy();
    19.1 --- a/bpel.debugger/src/org/netbeans/modules/bpel/debugger/BpelDebuggerImpl.java	Fri Dec 21 12:46:40 2007 +0000
    19.2 +++ b/bpel.debugger/src/org/netbeans/modules/bpel/debugger/BpelDebuggerImpl.java	Fri Dec 21 13:42:26 2007 +0000
    19.3 @@ -139,9 +139,14 @@
    19.4              mStartingThread.interrupt();
    19.5              mStartingThread = null;
    19.6          }
    19.7 -
    19.8 +        
    19.9 +        Exception disconnectionException = null;
   19.10          if (mConnector != null) {
   19.11 -            mConnector.detach();
   19.12 +            try {
   19.13 +                mConnector.detach();
   19.14 +            } catch (Exception e) {
   19.15 +                disconnectionException = e;
   19.16 +            }
   19.17          }
   19.18          
   19.19          if (oldState == BpelDebugger.STATE_STARTING) {
   19.20 @@ -165,7 +170,13 @@
   19.21                          "MSG_SessionFinished")); 
   19.22              }
   19.23          }
   19.24 -
   19.25 +        
   19.26 +        if (disconnectionException != null) {
   19.27 +            traceDebugException(NbBundle.getMessage(
   19.28 +                    BpelDebuggerImpl.class, 
   19.29 +                    "ERR_ErrorWhileDisconnecting"), disconnectionException);
   19.30 +        }
   19.31 +        
   19.32          if (myDebuggerEngineProvider.getDestructor() != null) {
   19.33              myDebuggerEngineProvider.getDestructor().killEngine();
   19.34          }
   19.35 @@ -414,11 +425,28 @@
   19.36      }
   19.37  
   19.38      public void setCurrentProcessInstance(ProcessInstance processInstance) {
   19.39 -        ProcessInstanceImpl newProcessInstance = (ProcessInstanceImpl) processInstance;
   19.40 -        ProcessInstanceImpl oldProcessInstance =
   19.41 +        ProcessInstanceImpl newProcessInstance = 
   19.42 +                (ProcessInstanceImpl) processInstance;
   19.43 +        
   19.44 +        // Automatically switch oto the first suspended process instance in
   19.45 +        // case we're about to lose the current one
   19.46 +        if (newProcessInstance == null) {
   19.47 +            for (ProcessInstanceImpl instance: 
   19.48 +                    mProcessInstancesModel.getProcessInstances()) {
   19.49 +                if (instance.getState() == ProcessInstance.STATE_SUSPENDED) {
   19.50 +                    newProcessInstance = instance;
   19.51 +                    break;
   19.52 +                }
   19.53 +            }
   19.54 +        }
   19.55 +        
   19.56 +        final ProcessInstanceImpl oldProcessInstance =
   19.57                  mCurrentProcessInstanceRef.getAndSet(newProcessInstance);
   19.58          
   19.59 -        firePropertyChange(PROP_CURRENT_PROCESS_INSTANCE, oldProcessInstance, newProcessInstance);
   19.60 +        firePropertyChange(
   19.61 +                PROP_CURRENT_PROCESS_INSTANCE, 
   19.62 +                oldProcessInstance, 
   19.63 +                newProcessInstance);
   19.64          
   19.65          if (newProcessInstance != null) {
   19.66              setCurrentPosition(newProcessInstance.getCurrentPosition());
   19.67 @@ -427,8 +455,8 @@
   19.68          }
   19.69      }
   19.70      
   19.71 -    private void traceDebugException(String message, DebugException dex) {
   19.72 -        if (dex == null) {
   19.73 +    private void traceDebugException(String message, Exception exception) {
   19.74 +        if (exception == null) {
   19.75              getTracer().println(message); // the message is already localized
   19.76              return;
   19.77          }
   19.78 @@ -440,19 +468,19 @@
   19.79          if (message != null) {
   19.80              sb.append(message);
   19.81          }
   19.82 -        if (dex.getMessage() != null) {
   19.83 +        if (exception.getMessage() != null) {
   19.84              if (sb.length() > 0) {
   19.85                  sb.append(sep);
   19.86              }
   19.87 -            sb.append(dex.getMessage());
   19.88 +            sb.append(exception.getMessage());
   19.89          }
   19.90          
   19.91 -        if (dex.getCause() != null) {
   19.92 +        if (exception.getCause() != null) {
   19.93              Throwable cause;
   19.94 -            if (dex.getCause() instanceof UndeclaredThrowableException) {
   19.95 -                cause = dex.getCause().getCause();
   19.96 +            if (exception.getCause() instanceof UndeclaredThrowableException) {
   19.97 +                cause = exception.getCause().getCause();
   19.98              } else {
   19.99 -                cause = dex.getCause();
  19.100 +                cause = exception.getCause();
  19.101              }
  19.102              
  19.103              if (cause.getMessage() != null) {
    20.1 --- a/bpel.debugger/src/org/netbeans/modules/bpel/debugger/Bundle.properties	Fri Dec 21 12:46:40 2007 +0000
    20.2 +++ b/bpel.debugger/src/org/netbeans/modules/bpel/debugger/Bundle.properties	Fri Dec 21 13:42:26 2007 +0000
    20.3 @@ -23,6 +23,7 @@
    20.4  #BpelDebuggerImpl
    20.5  ERR_UnableToStartSession=Unable to start a debug session
    20.6  ERR_SessionTerminated=Debug session terminated
    20.7 +ERR_ErrorWhileDisconnecting=Additionally an error was encountered while trying to disconnect from the server
    20.8  # {0} -- host, {1} -- port
    20.9  ERR_AlreadyConnected=Already connected to {0}:{1}
   20.10  # {0} -- host, {1} -- port
    21.1 --- a/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/SimpleVariableImpl.java	Fri Dec 21 12:46:40 2007 +0000
    21.2 +++ b/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/SimpleVariableImpl.java	Fri Dec 21 13:42:26 2007 +0000
    21.3 @@ -56,10 +56,14 @@
    21.4                  getBreakPosition().getFrame().getDebuggableEngine();
    21.5          try {
    21.6              varContext.changeVariableSchemaTypeValue(getName(), newValue);
    21.7 -            myValue = null;
    21.8 +            
    21.9 +            myValueIsInitialized = false;
   21.10          } catch (SchemaViolationException ex) {
   21.11              //TODO:implement
   21.12              ex.printStackTrace();
   21.13 +        } catch (Exception e) {
   21.14 +            // almost anything can be thrown..
   21.15 +            e.printStackTrace();
   21.16          }
   21.17      }
   21.18  }
    22.1 --- a/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/WsdlMessageVariableImpl.java	Fri Dec 21 12:46:40 2007 +0000
    22.2 +++ b/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/WsdlMessageVariableImpl.java	Fri Dec 21 13:42:26 2007 +0000
    22.3 @@ -64,16 +64,20 @@
    22.4          String xpath = XmlElementValue.Helper.xpath(node);
    22.5          try {
    22.6              varContext.changeVariableMessageTypeValue(getName(), part.getName(), xpath, newValue);
    22.7 +            
    22.8 +            myValueIsInitialized = false;
    22.9          } catch (XpathExpressionException ex) {
   22.10              //TODO:handle this
   22.11              ex.printStackTrace();
   22.12          } catch (SchemaViolationException ex) {
   22.13              //TODO:handle this
   22.14              ex.printStackTrace();
   22.15 +        } catch (Exception e) {
   22.16 +            // almost anything can be thrown..
   22.17 +            e.printStackTrace();
   22.18          }
   22.19 -
   22.20      }
   22.21 -
   22.22 +    
   22.23      public void setPartSimpleValue(WsdlMessageValue.Part part, String newValue) {
   22.24          DebuggableEngine varContext = getBreakPosition().getFrame().getDebuggableEngine();
   22.25          
    23.1 --- a/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/XmlElementVariableImpl.java	Fri Dec 21 12:46:40 2007 +0000
    23.2 +++ b/bpel.debugger/src/org/netbeans/modules/bpel/debugger/variables/XmlElementVariableImpl.java	Fri Dec 21 13:42:26 2007 +0000
    23.3 @@ -19,6 +19,9 @@
    23.4  
    23.5  package org.netbeans.modules.bpel.debugger.variables;
    23.6  
    23.7 +import javax.xml.xpath.XPathConstants;
    23.8 +import javax.xml.xpath.XPathExpressionException;
    23.9 +import javax.xml.xpath.XPathFactory;
   23.10  import org.netbeans.modules.bpel.debugger.api.variables.Value;
   23.11  import org.netbeans.modules.bpel.debugger.api.variables.XmlElementValue;
   23.12  import org.netbeans.modules.bpel.debugger.api.variables.XmlElementVariable;
   23.13 @@ -68,12 +71,17 @@
   23.14          String xpath = XmlElementValue.Helper.xpath(node);
   23.15          try {
   23.16              varContext.changeVariableSchemaTypeValue(getName(), xpath, newValue);
   23.17 +            
   23.18 +            myValueIsInitialized = false;
   23.19          } catch (XpathExpressionException ex) {
   23.20              //TODO:handle this
   23.21              ex.printStackTrace();
   23.22          } catch (SchemaViolationException ex) {
   23.23              //TODO:handle this
   23.24              ex.printStackTrace();
   23.25 +        } catch (Exception e) {
   23.26 +            // almost anything can be thrown..
   23.27 +            e.printStackTrace();
   23.28          }
   23.29      }
   23.30  }