Transplanting fix for 131656 from trunk
authoralexeyyarmolenko@netbeans.org
Fri, 04 Apr 2008 12:08:27 +0400
changeset 41593d5d7cc3c38d
parent 4157 718e28d73c8f
child 4160 ad97378ced3f
Transplanting fix for 131656 from trunk
bpel.editors/src/org/netbeans/modules/bpel/design/CopyPasteHandler.java
bpel.editors/src/org/netbeans/modules/bpel/design/DnDHandler.java
bpel.editors/src/org/netbeans/modules/bpel/design/OverlayPanel.java
bpel.editors/src/org/netbeans/modules/bpel/design/TriScrollPane.java
bpel.editors/src/org/netbeans/modules/bpel/design/decoration/providers/LinkToolDecorationProvider.java
bpel.editors/src/org/netbeans/modules/bpel/design/selection/FlowlinkTool.java
     1.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/CopyPasteHandler.java	Thu Apr 03 10:51:45 2008 +0400
     1.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/CopyPasteHandler.java	Fri Apr 04 12:08:27 2008 +0400
     1.3 @@ -18,8 +18,12 @@
     1.4   */
     1.5  package org.netbeans.modules.bpel.design;
     1.6  
     1.7 +import java.awt.Point;
     1.8  import java.awt.Rectangle;
     1.9  import java.awt.event.ActionEvent;
    1.10 +import java.awt.event.MouseEvent;
    1.11 +import java.awt.event.MouseListener;
    1.12 +import java.awt.event.MouseMotionListener;
    1.13  import java.util.ArrayList;
    1.14  import java.util.Collections;
    1.15  import java.util.Comparator;
    1.16 @@ -27,6 +31,7 @@
    1.17  import java.util.List;
    1.18  import org.netbeans.modules.bpel.design.actions.DesignModeAction;
    1.19  import org.netbeans.modules.bpel.design.actions.PasteModeAction;
    1.20 +import org.netbeans.modules.bpel.design.geometry.FPoint;
    1.21  import org.netbeans.modules.bpel.design.model.patterns.Pattern;
    1.22  import org.netbeans.modules.bpel.design.model.patterns.ProcessPattern;
    1.23  import org.netbeans.modules.bpel.design.selection.PlaceHolderManager;
    1.24 @@ -34,19 +39,18 @@
    1.25  import org.netbeans.modules.bpel.model.api.BpelEntity;
    1.26  import org.netbeans.modules.bpel.model.api.support.UniqueId;
    1.27  
    1.28 -
    1.29  /**
    1.30   *
    1.31   * @author Vitaly Bychkov
    1.32   * @version 1.0
    1.33   */
    1.34 -public class CopyPasteHandler {
    1.35 +public class CopyPasteHandler implements MouseListener {
    1.36  
    1.37      private DesignView designView;
    1.38      private Pattern copiedPattern;
    1.39      private PlaceHolderManager[] managers;
    1.40      private PlaceHolder currentPlaceholder;
    1.41 -    
    1.42 +
    1.43      public CopyPasteHandler(DesignView designView) {
    1.44          this.designView = designView;
    1.45          managers = new PlaceHolderManager[]{
    1.46 @@ -59,127 +63,131 @@
    1.47      public void enterPasteMode(Pattern pattern) {
    1.48          copiedPattern = pattern;
    1.49          currentPlaceholder = null;
    1.50 -        for (PlaceHolderManager m : managers){
    1.51 +        for (PlaceHolderManager m : managers) {
    1.52              m.init(pattern);
    1.53 +            m.getDiagramView().addMouseListener(this);
    1.54          }
    1.55          tabNextPlaceholder(true);
    1.56      }
    1.57 -    
    1.58 +
    1.59      public void exitPasteMode() {
    1.60          copiedPattern = null;
    1.61          currentPlaceholder = null;
    1.62 -        for (PlaceHolderManager m : managers){
    1.63 +        for (PlaceHolderManager m : managers) {
    1.64              m.clear();
    1.65 +            m.getDiagramView().removeMouseListener(this);
    1.66          }
    1.67  
    1.68      }
    1.69 -    
    1.70 +
    1.71      public boolean isActive() {
    1.72          return copiedPattern != null;
    1.73      }
    1.74 -    
    1.75 -    public CopyAction getCopyAction(){
    1.76 +
    1.77 +    public CopyAction getCopyAction() {
    1.78          return new CopyAction();
    1.79      }
    1.80 -    
    1.81 -    public CutAction getCutAction(){
    1.82 +
    1.83 +    public CutAction getCutAction() {
    1.84          return new CutAction();
    1.85      }
    1.86 -    
    1.87 -    public PasteAction getPasteAction(){
    1.88 +
    1.89 +    public PasteAction getPasteAction() {
    1.90          return new PasteAction();
    1.91      }
    1.92 -    
    1.93 -    
    1.94 -    
    1.95 +
    1.96      public void tabNextPlaceholder(boolean forward) {
    1.97  
    1.98          PlaceHolder next;
    1.99          ArrayList<PlaceHolder> placeholders = new ArrayList<PlaceHolder>();
   1.100 -        
   1.101 -        for (PlaceHolderManager m: managers){
   1.102 -            
   1.103 +
   1.104 +        for (PlaceHolderManager m : managers) {
   1.105 +
   1.106              List<PlaceHolder> viewPhs = m.getPlaceHolders();
   1.107              Collections.sort(viewPhs, new Comparator<PlaceHolder>() {
   1.108  
   1.109                  public int compare(PlaceHolder o1, PlaceHolder o2) {
   1.110                      Rectangle r1 = o1.getShape().getBounds();
   1.111                      Rectangle r2 = o2.getShape().getBounds();
   1.112 -                    return ((r1.x * r1.x) + (r1.y * r1.y)) - 
   1.113 -                           ((r2.x * r2.x) + (r2.y * r2.y));  
   1.114 -                    
   1.115 +                    return ((r1.x * r1.x) + (r1.y * r1.y)) -
   1.116 +                            ((r2.x * r2.x) + (r2.y * r2.y));
   1.117 +
   1.118                  }
   1.119              });
   1.120 -            
   1.121 +
   1.122              placeholders.addAll(viewPhs);
   1.123          }
   1.124 -        
   1.125 -        if (placeholders.isEmpty()){
   1.126 +
   1.127 +        if (placeholders.isEmpty()) {
   1.128              return;
   1.129          }
   1.130 -        
   1.131 +
   1.132          if (currentPlaceholder == null) {
   1.133              next = placeholders.get(forward ? 0 : placeholders.size() - 1);
   1.134          } else {
   1.135              int pos = placeholders.indexOf(currentPlaceholder);
   1.136              pos = forward ? (pos + 1) : (pos - 1);
   1.137 -            if (pos < 0){
   1.138 +            if (pos < 0) {
   1.139                  pos = placeholders.size() - 1;
   1.140 -            } else if (pos >= placeholders.size()){
   1.141 +            } else if (pos >= placeholders.size()) {
   1.142                  pos = 0;
   1.143              }
   1.144              next = placeholders.get(pos);
   1.145          }
   1.146 -        
   1.147 -        for (PlaceHolderManager m: managers){
   1.148 +
   1.149 +        for (PlaceHolderManager m : managers) {
   1.150              m.setCurrentPlaceholder(next);
   1.151          }
   1.152 -        
   1.153 +
   1.154          currentPlaceholder = next;
   1.155          //find the view owning current placeholder and scroll it to make this placeholder visible
   1.156 -        if (currentPlaceholder != null ){
   1.157 -               for (PlaceHolderManager m: managers){
   1.158 -                    if (m.getPlaceHolders().contains(currentPlaceholder)){
   1.159 -                        m.getDiagramView().scrollPlaceholderToView(currentPlaceholder);
   1.160 -                        break;
   1.161 -                    }
   1.162 -               }
   1.163 +        if (currentPlaceholder != null) {
   1.164 +            for (PlaceHolderManager m : managers) {
   1.165 +                if (m.getPlaceHolders().contains(currentPlaceholder)) {
   1.166 +                    m.getDiagramView().scrollPlaceholderToView(currentPlaceholder);
   1.167 +                    break;
   1.168 +                }
   1.169 +            }
   1.170  
   1.171          }
   1.172 -        
   1.173 +
   1.174      }
   1.175 +
   1.176      class PasteAction extends PasteModeAction {
   1.177 -        public PasteAction(){
   1.178 +
   1.179 +        public PasteAction() {
   1.180              super(designView);
   1.181          }
   1.182 -        
   1.183          private static final long serialVersionUID = 1L;
   1.184 +
   1.185          public boolean isEnabled() {
   1.186              if (!super.isEnabled()) {
   1.187                  return false;
   1.188              }
   1.189  
   1.190 -            
   1.191 +
   1.192              return currentPlaceholder != null;
   1.193          }
   1.194 +
   1.195          public void actionPerformed(ActionEvent e) {
   1.196              if (!isEnabled()) {
   1.197                  return;
   1.198              }
   1.199 -            
   1.200 -           
   1.201 +
   1.202 +
   1.203              currentPlaceholder.drop();
   1.204 -            
   1.205 +
   1.206              exitPasteMode();
   1.207  
   1.208          }
   1.209      }
   1.210 -    
   1.211 +
   1.212      public class CutAction extends DesignModeAction {
   1.213 -        public CutAction(){
   1.214 +
   1.215 +        public CutAction() {
   1.216              super(designView);
   1.217          }
   1.218 -        
   1.219 +
   1.220          public boolean isEnabled() {
   1.221              if (!super.isEnabled()) {
   1.222                  return false;
   1.223 @@ -193,10 +201,11 @@
   1.224              if (!isEnabled()) {
   1.225                  return;
   1.226              }
   1.227 -            
   1.228 +
   1.229              enterPasteMode(getPatternCopy(designView.getSelectionModel().getSelectedPattern()));
   1.230 -            
   1.231 +
   1.232          }
   1.233 +
   1.234          private Pattern getPatternCopy(Pattern pattern) {
   1.235              if (pattern == null) {
   1.236                  return null;
   1.237 @@ -208,17 +217,18 @@
   1.238              }
   1.239  
   1.240              copiedPattern = designView.getModel().createPattern(entity.cut());
   1.241 -            
   1.242 -            
   1.243 +
   1.244 +
   1.245              return copiedPattern;
   1.246          }
   1.247 +    }
   1.248  
   1.249 -    }
   1.250      public class CopyAction extends DesignModeAction {
   1.251 -        public CopyAction(){
   1.252 +
   1.253 +        public CopyAction() {
   1.254              super(designView);
   1.255          }
   1.256 -        
   1.257 +
   1.258          public boolean isEnabled() {
   1.259              if (!super.isEnabled()) {
   1.260                  return false;
   1.261 @@ -238,7 +248,7 @@
   1.262  
   1.263              Pattern copiedPattern = getPatternCopy(designView.getSelectionModel().getSelectedPattern());
   1.264              enterPasteMode(copiedPattern);
   1.265 -            
   1.266 +
   1.267          }
   1.268  
   1.269          private Pattern getPatternCopy(Pattern pattern) {
   1.270 @@ -256,4 +266,37 @@
   1.271              return copiedPattern;
   1.272          }
   1.273      }
   1.274 +
   1.275 +    public void mouseClicked(MouseEvent e) {
   1.276 +    }
   1.277 +
   1.278 +    public void mousePressed(MouseEvent e) {
   1.279 +        if (e.getComponent() instanceof DiagramView) {
   1.280 +            DiagramView view = (DiagramView) e.getComponent();
   1.281 +            List<PlaceHolder> placeholders =
   1.282 +                    view.getPlaceholderManager().getPlaceHolders();
   1.283 +            FPoint pt = view.convertScreenToDiagram(new Point(e.getX(), e.getY()));        
   1.284 +            for (PlaceHolder p : placeholders) {
   1.285 +                if (p.contains(pt.x, pt.y)) {
   1.286 +                    p.drop();
   1.287 +                    break;
   1.288 +                }
   1.289 +            }
   1.290 +            exitPasteMode();
   1.291 +
   1.292 +        }
   1.293 +
   1.294 +    }
   1.295 +
   1.296 +    public void mouseReleased(MouseEvent e) {
   1.297 +    }
   1.298 +
   1.299 +    public void mouseEntered(MouseEvent e) {
   1.300 +    }
   1.301 +
   1.302 +    public void mouseExited(MouseEvent e) {
   1.303 +    }
   1.304 +
   1.305 +    public void mouseDragged(MouseEvent e) {
   1.306 +    }
   1.307  }
     2.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/DnDHandler.java	Thu Apr 03 10:51:45 2008 +0400
     2.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/DnDHandler.java	Fri Apr 04 12:08:27 2008 +0400
     2.3 @@ -287,7 +287,8 @@
     2.4          DnDTool tool = null;
     2.5  
     2.6          if (tr.isDataFlavorSupported(flowDataFlavor)) {
     2.7 -            //FIXME tool = getFlowLinkTool();
     2.8 +            tool = getFlowLinkTool();
     2.9 +            tool.move(null);
    2.10          } else {
    2.11  
    2.12                  DiagramView view = (DiagramView) dtde.getDropTargetContext().getComponent();
     3.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/OverlayPanel.java	Thu Apr 03 10:51:45 2008 +0400
     3.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/OverlayPanel.java	Fri Apr 04 12:08:27 2008 +0400
     3.3 @@ -97,11 +97,11 @@
     3.4      protected void paintComponent(Graphics g) {
     3.5         
     3.6     
     3.7 -        double zoom = designView.getCorrectedZoom();
     3.8 -        
     3.9 +//        double zoom = designView.getCorrectedZoom();
    3.10 +//        
    3.11          Graphics2D g2 = GUtils.createGraphics(g);
    3.12 -        
    3.13 -        g2.scale(zoom, zoom);
    3.14 +//        
    3.15 +//        g2.scale(zoom, zoom);
    3.16  
    3.17          //fixme - render DND status here
    3.18          
     4.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/TriScrollPane.java	Thu Apr 03 10:51:45 2008 +0400
     4.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/TriScrollPane.java	Fri Apr 04 12:08:27 2008 +0400
     4.3 @@ -165,10 +165,10 @@
     4.4      public JComponent getComponent(Point pt) {
     4.5          if (rightComponent.getBounds().contains(pt)) {
     4.6              return right;
     4.7 +        } else if (leftComponent.getBounds().contains(pt)) {
     4.8 +            return left;
     4.9          } else if (viewport.getBounds().contains(pt)) {
    4.10              return center;
    4.11 -        } else if (leftComponent.getBounds().contains(pt)) {
    4.12 -            return left;
    4.13          } else {
    4.14              return null;
    4.15          }
     5.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/decoration/providers/LinkToolDecorationProvider.java	Thu Apr 03 10:51:45 2008 +0400
     5.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/decoration/providers/LinkToolDecorationProvider.java	Fri Apr 04 12:08:27 2008 +0400
     5.3 @@ -69,10 +69,11 @@
     5.4      
     5.5      
     5.6      public Decoration getDecoration(BpelEntity entity) {
     5.7 -        
     5.8 +        // FIXME FLOW LINK TOOL disabled
     5.9          UniqueId entityID = entity.getUID();
    5.10          UniqueId selectedEntityID = getDesignView().getSelectionModel().getSelectedID();
    5.11          
    5.12 +
    5.13          
    5.14          if (entityID!= null && entityID.equals(selectedEntityID) &&
    5.15              entity instanceof PartnerLinkReference &&
    5.16 @@ -141,7 +142,7 @@
    5.17                  
    5.18                  DiagramView view = pattern.getView();
    5.19                  Point p = view.convertDiagramToScreen(
    5.20 -                        new FPoint(bounds.getX(), bounds.getCenterY()));
    5.21 +                        new FPoint(bounds.getCenterX(), bounds.getCenterY()));
    5.22                  
    5.23                  
    5.24                  btn.setPosition(p);
     6.1 --- a/bpel.editors/src/org/netbeans/modules/bpel/design/selection/FlowlinkTool.java	Thu Apr 03 10:51:45 2008 +0400
     6.2 +++ b/bpel.editors/src/org/netbeans/modules/bpel/design/selection/FlowlinkTool.java	Fri Apr 04 12:08:27 2008 +0400
     6.3 @@ -16,8 +16,6 @@
     6.4   * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
     6.5   * Microsystems, Inc. All Rights Reserved.
     6.6   */
     6.7 -
     6.8 -
     6.9  package org.netbeans.modules.bpel.design.selection;
    6.10  
    6.11  import java.awt.Color;
    6.12 @@ -40,6 +38,7 @@
    6.13  import org.netbeans.modules.bpel.model.api.PortTypeReference;
    6.14  import org.netbeans.modules.bpel.model.api.Reply;
    6.15  import org.netbeans.modules.bpel.design.DesignView;
    6.16 +import org.netbeans.modules.bpel.design.DiagramView;
    6.17  import org.netbeans.modules.bpel.design.GUtils;
    6.18  import org.netbeans.modules.bpel.design.decoration.components.LinkToolButton;
    6.19  import org.netbeans.modules.bpel.design.model.connections.Direction;
    6.20 @@ -54,313 +53,268 @@
    6.21  import org.netbeans.modules.xml.wsdl.model.Operation;
    6.22  import org.netbeans.modules.xml.wsdl.model.PortType;
    6.23  
    6.24 +public class FlowlinkTool implements DnDTool {
    6.25  
    6.26 -public class FlowlinkTool implements DnDTool {
    6.27 -    
    6.28      private VisualElement startElement;
    6.29      private VisualElement endElement;
    6.30 -    
    6.31      private static final int INPUT = 1;
    6.32      private static final int OUTPUT = 2;
    6.33 -    private static final int INPUT_OUTOUT = INPUT|OUTPUT;
    6.34 -    
    6.35 +    private static final int INPUT_OUTOUT = INPUT | OUTPUT;
    6.36      private DesignView designView;
    6.37 -    
    6.38 -    private double startX;
    6.39 -    private double startY;
    6.40 -    
    6.41 -    private double currentX;
    6.42 -    private double currentY;
    6.43 -    
    6.44 +    private int currentX;
    6.45 +    private int currentY;
    6.46 +    private DiagramView currentView;
    6.47      private LinkToolButton button;
    6.48 -    
    6.49 +
    6.50      public FlowlinkTool(DesignView designView) {
    6.51          this.designView = designView;
    6.52      }
    6.53 -    
    6.54 -    
    6.55 +
    6.56      public DesignView getDesignView() {
    6.57          return designView;
    6.58      }
    6.59 -    
    6.60 -    
    6.61 -    public void init(LinkToolButton  btn) {
    6.62 +
    6.63 +    public void init(LinkToolButton btn) {
    6.64          this.button = btn;
    6.65 +
    6.66 +        btn.setVisible(false);
    6.67 +
    6.68          VisualElement e = btn.getPattern().getFirstElement();
    6.69 -        
    6.70 +
    6.71          // DND can start only from operation element
    6.72          // or fromdiagram element involved into messageflow
    6.73 -        if ((e == null) || (!isOperation(e) && !isTask(e))) return;
    6.74 -        
    6.75 +        if ((e == null) || (!isOperation(e) && !isTask(e))) {
    6.76 +            return;
    6.77 +        }
    6.78 +
    6.79          startElement = e;
    6.80 -        
    6.81 -        if (isTask(e)) {
    6.82 -            
    6.83 -            startX = e.getX();
    6.84 -            startY = e.getCenterY();
    6.85 -            
    6.86 -        } else {
    6.87 -            startX = e.getX() + e.getWidth();
    6.88 -            startY = e.getCenterY();
    6.89 -        }
    6.90 -        
    6.91 +
    6.92          getDesignView().getDecorationManager().decorationChanged();
    6.93      }
    6.94 -    
    6.95 -    
    6.96 -    
    6.97 -    private void move() {
    6.98 +
    6.99 +    public void move(FPoint fp) {
   6.100 +        if (!isActive()) {
   6.101 +            return;
   6.102 +        }
   6.103 +
   6.104          Point p = getDesignView().getOverlayView().getMousePosition();
   6.105          if (p != null) {
   6.106 -            FPoint fp = getDesignView().convertScreenToDiagram(p);
   6.107 -            moveImpl(fp.x, fp.y);
   6.108 +            currentView = getDesignView().getView(p);
   6.109 +            currentX = p.x;
   6.110 +            currentY = p.y;
   6.111 +
   6.112 +
   6.113 +            FPoint viewPt = currentView.convertPointFromParent(p);
   6.114 +            VisualElement e = currentView.findElement(viewPt.x, viewPt.y);
   6.115 +
   6.116 +            endElement = (e != null && isValidLinkTo(e)) ? e : null;
   6.117 +           
   6.118 +            getDesignView().repaint();
   6.119          }
   6.120      }
   6.121 -    
   6.122 -    public boolean isValidLocation(){
   6.123 +
   6.124 +    public boolean isValidLocation() {
   6.125          return endElement != null;
   6.126      }
   6.127 -    
   6.128 -    public void move(FPoint p) {
   6.129 -        moveImpl(p.x, p.y);
   6.130 -        
   6.131 -        //button.setPosition(getDesignView().convertDiagramToScreen(p));
   6.132 -        
   6.133 -        getDesignView().repaint();
   6.134 -    }
   6.135 -    
   6.136 -    
   6.137 -    private void moveImpl(double x, double y) {
   6.138 -        if (!isActive()) return;
   6.139 -        currentX = x;
   6.140 -        currentY = y;
   6.141 -        
   6.142 -        
   6.143 -        VisualElement e = null;//getDesignView().findElement(x, y);
   6.144 -        
   6.145 -        endElement = (e != null && isValidLinkTo(e)) ? e : null;
   6.146 -        
   6.147 -    }
   6.148 -    
   6.149 -    
   6.150 +
   6.151 +
   6.152 +
   6.153      public void drop(FPoint p) {
   6.154          drop(p.x, p.y);
   6.155      }
   6.156 -    
   6.157 +
   6.158      public void drop(double x, double y) {
   6.159 -        if (!isActive()) return;
   6.160 -        
   6.161 -        moveImpl(x, y);
   6.162 -        
   6.163 +        if (!isActive()) {
   6.164 +            return;
   6.165 +        }
   6.166 +
   6.167 +       move(null);
   6.168 +
   6.169          if (endElement != null && (isValidLinkTo(endElement))) {
   6.170              VisualElement operation = isOperation(startElement)
   6.171 -            ? startElement : endElement;
   6.172 -            if (operation != null){
   6.173 -                VisualElement task = isOperation(startElement)?endElement:startElement;
   6.174 -                
   6.175 -                PartnerlinkPattern pattern = (PartnerlinkPattern)operation.getPattern();
   6.176 -                
   6.177 +                    ? startElement : endElement;
   6.178 +            if (operation != null) {
   6.179 +                VisualElement task = isOperation(startElement) ? endElement : startElement;
   6.180 +
   6.181 +                PartnerlinkPattern pattern = (PartnerlinkPattern) operation.getPattern();
   6.182 +
   6.183                  BpelEntity activity = (BpelEntity) task.getPattern().getOMReference();
   6.184 -                
   6.185 -                BpelReference<PartnerLink> pl_ref = ((ReferenceCollection)activity)
   6.186 -                .createReference((PartnerLink)pattern.getOMReference(), PartnerLink.class);
   6.187 -                
   6.188 +
   6.189 +                BpelReference<PartnerLink> pl_ref = ((ReferenceCollection) activity).createReference((PartnerLink) pattern.getOMReference(), PartnerLink.class);
   6.190 +
   6.191                  if (pl_ref != null) {
   6.192 -                    ((PartnerLinkReference)activity).setPartnerLink(pl_ref);
   6.193 +                    ((PartnerLinkReference) activity).setPartnerLink(pl_ref);
   6.194                  }
   6.195 -                
   6.196 -                
   6.197 +
   6.198 +
   6.199                  Operation op = pattern.getOperation(operation);
   6.200 -                
   6.201 -                if (op != null){
   6.202 -                    WSDLReference<Operation> op_ref = ((ReferenceCollection)activity)
   6.203 -                    .createWSDLReference(op, Operation.class);
   6.204 -                    
   6.205 -                    if (op_ref!= null){
   6.206 -                        ((OperationReference)activity).setOperation(op_ref);
   6.207 +
   6.208 +                if (op != null) {
   6.209 +                    WSDLReference<Operation> op_ref = ((ReferenceCollection) activity).createWSDLReference(op, Operation.class);
   6.210 +
   6.211 +                    if (op_ref != null) {
   6.212 +                        ((OperationReference) activity).setOperation(op_ref);
   6.213                      }
   6.214 -                    PortType pt = (PortType)op.getParent();
   6.215 -                    if (pt != null){
   6.216 -                        WSDLReference<PortType> pt_ref = ((ReferenceCollection)activity)
   6.217 -                        .createWSDLReference(pt, PortType.class);
   6.218 -                        
   6.219 -                        if (pt_ref!= null){
   6.220 -                            ((PortTypeReference)activity).setPortType(pt_ref);
   6.221 +                    PortType pt = (PortType) op.getParent();
   6.222 +                    if (pt != null) {
   6.223 +                        WSDLReference<PortType> pt_ref = ((ReferenceCollection) activity).createWSDLReference(pt, PortType.class);
   6.224 +
   6.225 +                        if (pt_ref != null) {
   6.226 +                            ((PortTypeReference) activity).setPortType(pt_ref);
   6.227                          } else {
   6.228 -                            ((PortTypeReference)activity).removePortType();
   6.229 +                            ((PortTypeReference) activity).removePortType();
   6.230                          }
   6.231 -                        
   6.232 -                        
   6.233 +
   6.234 +
   6.235                      }
   6.236                  }
   6.237              }
   6.238          }
   6.239          clear();
   6.240      }
   6.241 -    
   6.242 -    
   6.243 -    public void clear(){
   6.244 +
   6.245 +    public void clear() {
   6.246          startElement = null;
   6.247          endElement = null;
   6.248 -        
   6.249 +
   6.250          if (button != null) {
   6.251 -            BpelEntity be = button.getPattern().getOMReference();
   6.252 -            if (be !=  null) {
   6.253 -                getDesignView().getDecorationManager().decorationChanged();
   6.254 -            }
   6.255 +            button.setVisible(true);
   6.256 +            button = null;
   6.257 +
   6.258          }
   6.259 -        
   6.260 +
   6.261          //FIXME designView.getDecorationManager().repositionComponentsRecursive();
   6.262          getDesignView().repaint();
   6.263      }
   6.264 -    
   6.265 -    
   6.266 -    public boolean isActive(){
   6.267 +
   6.268 +    public boolean isActive() {
   6.269          return (startElement != null);
   6.270      }
   6.271 -    
   6.272 -    
   6.273 -    private boolean isValidLinkTo(VisualElement to){
   6.274 -        if (to == null){
   6.275 +
   6.276 +    private boolean isValidLinkTo(VisualElement to) {
   6.277 +        if (to == null) {
   6.278              return false;
   6.279          } else if (to == startElement) {
   6.280              return false;
   6.281 -        } if ((isOperation(to) && isTask(startElement)) ||
   6.282 +        }
   6.283 +        if ((isOperation(to) && isTask(startElement)) ||
   6.284                  (isOperation(startElement) && isTask(to))) {
   6.285 -            return ((getDirections(to)|getDirections(startElement)) == (INPUT|OUTPUT));
   6.286 +            return ((getDirections(to) | getDirections(startElement)) == (INPUT | OUTPUT));
   6.287          }
   6.288          return false;
   6.289      }
   6.290 -    
   6.291 -    
   6.292 -    private int getDirections(VisualElement e){
   6.293 -        BpelEntity ref = (BpelEntity)e.getPattern().getOMReference();
   6.294 -        if (e instanceof ReceiveOperationElement){
   6.295 +
   6.296 +    private int getDirections(VisualElement e) {
   6.297 +        BpelEntity ref = (BpelEntity) e.getPattern().getOMReference();
   6.298 +        if (e instanceof ReceiveOperationElement) {
   6.299              return INPUT;
   6.300 -        } else if (e instanceof InvokeOperationElement){
   6.301 -            return INPUT|OUTPUT;
   6.302 -        } else if ( isTask(ref)){
   6.303 -            if (ref instanceof Reply){
   6.304 +        } else if (e instanceof InvokeOperationElement) {
   6.305 +            return INPUT | OUTPUT;
   6.306 +        } else if (isTask(ref)) {
   6.307 +            if (ref instanceof Reply) {
   6.308                  return OUTPUT;
   6.309 -            } else if (ref instanceof Invoke){
   6.310 +            } else if (ref instanceof Invoke) {
   6.311                  return OUTPUT;
   6.312              } else {
   6.313                  return INPUT;
   6.314              }
   6.315          }
   6.316 -        
   6.317 +
   6.318          return 0;
   6.319      }
   6.320 -    
   6.321 -    
   6.322 -    private boolean isOperation(VisualElement e){
   6.323 +
   6.324 +    private boolean isOperation(VisualElement e) {
   6.325          return e instanceof OperationElement;
   6.326      }
   6.327 -    
   6.328 -    
   6.329 -    private boolean isSendTask(VisualElement e){
   6.330 +
   6.331 +    private boolean isSendTask(VisualElement e) {
   6.332          Object o = e.getPattern().getOMReference();
   6.333          return (o instanceof Invoke) || (o instanceof Reply);
   6.334      }
   6.335 -    
   6.336 -    
   6.337 -    private boolean isTask(VisualElement e){
   6.338 -        return isTask((BpelEntity)e.getPattern().getOMReference());
   6.339 +
   6.340 +    private boolean isTask(VisualElement e) {
   6.341 +        return isTask((BpelEntity) e.getPattern().getOMReference());
   6.342      }
   6.343 -    
   6.344 -    
   6.345 -    private boolean isTask(BpelEntity o){
   6.346 +
   6.347 +    private boolean isTask(BpelEntity o) {
   6.348          return (o instanceof OperationReference) && (o instanceof PartnerLinkReference) && (o instanceof PortTypeReference);
   6.349      }
   6.350 -    
   6.351 -    
   6.352 +
   6.353      public void paint(Graphics2D g2) {
   6.354 -        if (!isActive()) return;
   6.355 +        if (!isActive()) {
   6.356 +            return;
   6.357 +        }
   6.358  //        if (getDesignView().getModel().isReadOnly()) return; //127263
   6.359 -        
   6.360 -        move();
   6.361 -        
   6.362 -        double x1, y1, x2, y2;
   6.363 -        
   6.364 -        if (isValidLocation()) {
   6.365 -            x1 = startElement.getCenterX();
   6.366 -            y1 = startElement.getCenterY();
   6.367 +
   6.368 +
   6.369 +        if (currentView != null) {
   6.370              
   6.371 -            x2 = endElement.getCenterX();
   6.372 -            y2 = endElement.getCenterY();
   6.373 +            Point pt1 = getDesignView().getProcessView().convertPointToParent(
   6.374 +                    new FPoint(startElement.getCenterX(), startElement.getCenterY()));
   6.375 +           
   6.376 +            Point pt2 = new Point(currentX, currentY);
   6.377              
   6.378 -            double w1 = startElement.getWidth() / 2;
   6.379 -            double w2 = endElement.getWidth() / 2;
   6.380 -            
   6.381 -            if (x1 <= x2) {
   6.382 -                x1 += w1;
   6.383 -                x2 -= w2;
   6.384 -            } else {
   6.385 -                x1 -= w1;
   6.386 -                x2 += w2;
   6.387 -            }
   6.388 -        } else {
   6.389 -            x1 = startX;
   6.390 -            y1 = startY;
   6.391 -            
   6.392 -            x2 = currentX;
   6.393 -            y2 = currentY;
   6.394 -        }
   6.395 -        
   6.396 -        FPath path = createPath(x1, y1, x2, y2, !isForwardDirection());
   6.397 +            if (isValidLocation()) {
   6.398 +                pt2 = currentView.convertPointToParent(
   6.399 +                        new FPoint(endElement.getCenterX(), endElement.getCenterY()));
   6.400 +            } 
   6.401  
   6.402 -        if (path != null) {
   6.403 +
   6.404 +            FPath path = createPath(pt1.x, pt1.y, pt2.x, pt2.y, !isForwardDirection());
   6.405 +   
   6.406 +            if (path != null) {
   6.407  //            GUtils.setSolidStroke(g2, 8);
   6.408  //            GUtils.setPaint(g2, new Color(0x88FFFFFF, true));
   6.409  //            GUtils.draw(g2, GUtils.convert(path), true);
   6.410 -            Connection.paintConnection(g2, path, true, true, false, true,
   6.411 -                    (isValidLocation()) ? null : Color.RED);
   6.412 +                Connection.paintConnection(g2, path, true, true, false, true,
   6.413 +                        (isValidLocation()) ? null : Color.RED);
   6.414 +            }
   6.415 +
   6.416          }
   6.417 -        
   6.418          Graphics2D buttonGraphics = (Graphics2D) g2.create();
   6.419 -        
   6.420 -        double scale = GUtils.getScale(buttonGraphics.getTransform());
   6.421 -        
   6.422 +
   6.423          buttonGraphics.translate(currentX, currentY);
   6.424 -        buttonGraphics.scale(1 / scale, 1 / scale);
   6.425 +        //buttonGraphics.scale( 1 / scale, 1 / scale);
   6.426          buttonGraphics.translate(-button.getWidth() / 2, -button.getHeight() / 2);
   6.427          button.paint(buttonGraphics);
   6.428          buttonGraphics.dispose();
   6.429 +
   6.430 +
   6.431 +
   6.432      }
   6.433 -    
   6.434 -    
   6.435 +
   6.436      private boolean isForwardDirection() {
   6.437          BpelEntity omRef = startElement.getPattern().getOMReference();
   6.438 -        
   6.439 -        if (omRef == null) return true;
   6.440 -        
   6.441 -        if (omRef instanceof OnMessage ||
   6.442 -            omRef instanceof OnEvent ||
   6.443 -            omRef instanceof Receive) {
   6.444 -            
   6.445 -            return false;
   6.446 -        } else if (omRef instanceof Invoke
   6.447 -                || omRef instanceof Reply) {
   6.448 +
   6.449 +        if (omRef == null) {
   6.450              return true;
   6.451          }
   6.452 -        
   6.453 +
   6.454 +        if (omRef instanceof OnMessage ||
   6.455 +                omRef instanceof OnEvent ||
   6.456 +                omRef instanceof Receive) {
   6.457 +
   6.458 +            return false;
   6.459 +        } else if (omRef instanceof Invoke || omRef instanceof Reply) {
   6.460 +            return true;
   6.461 +        }
   6.462 +
   6.463          return true;
   6.464      }
   6.465 -    
   6.466 -    
   6.467 -    private FPath createPath(double x1, double y1, double x2, double y2, 
   6.468 +
   6.469 +    private FPath createPath(double x1, double y1, double x2, double y2,
   6.470              boolean invert) {
   6.471 -        
   6.472 +
   6.473          if (invert) {
   6.474 -            double t = x1; 
   6.475 -            x1 = x2; 
   6.476 +            double t = x1;
   6.477 +            x1 = x2;
   6.478              x2 = t;
   6.479 -            
   6.480 +
   6.481              t = y1;
   6.482              y1 = y2;
   6.483              y2 = t;
   6.484          }
   6.485 -        
   6.486 +
   6.487          boolean nonZeroDX = x1 != x2;
   6.488          boolean nonZeroDY = y1 != y2;
   6.489  
   6.490 @@ -370,19 +324,15 @@
   6.491          } else if (nonZeroDX || nonZeroDY) {
   6.492              return new FPath(x1, y1, x2, y2);
   6.493          }
   6.494 -        
   6.495 +
   6.496          return null;
   6.497      }
   6.498 -    
   6.499 -    
   6.500 +
   6.501      public Point getPosition() {
   6.502          return designView.convertDiagramToScreen(new FPoint(currentX, currentY));
   6.503      }
   6.504 -    
   6.505 -    
   6.506      // Rendering constants
   6.507      private static final Shape END_MARKER_SHAPE = new Ellipse2D.Float(-2, -2, 4, 4);
   6.508 -    
   6.509      private static final Color ACCEPT_FILL_COLOR = new Color(0x00A000);
   6.510      private static final Color ACCEPT_STROKE_COLOR = new Color(0x20A020);
   6.511      private static final Color DECLINE_FILL_COLOR = new Color(0xA00000);