A11Y - Tab to traverse through widgets. tests-1-0
authordararamesh@netbeans.org
Sat, 04 Aug 2007 18:43:48 +0000
changeset 9377392a168d182
parent 936 c915ce7a1745
child 938 a8a4a5ffb670
A11Y - Tab to traverse through widgets.
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/design/CasaModelGraphScene.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaConnectionWidget.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaFactory.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidget.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetBinding.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetEngine.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaPinWidget.java
compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/actions/CycleCasaSceneSelectProvider.java
     1.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/design/CasaModelGraphScene.java	Sat Aug 04 02:42:54 2007 +0000
     1.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/design/CasaModelGraphScene.java	Sat Aug 04 18:43:48 2007 +0000
     1.3 @@ -42,7 +42,6 @@
     1.4  import java.util.Set;
     1.5  import java.util.logging.Level;
     1.6  import java.util.logging.Logger;
     1.7 -import org.netbeans.api.project.ProjectManager;
     1.8  import org.netbeans.api.visual.action.RectangularSelectDecorator;
     1.9  import org.netbeans.api.visual.router.RouterFactory;
    1.10  import org.netbeans.modules.compapp.casaeditor.CasaDataEditorSupport;
    1.11 @@ -270,6 +269,7 @@
    1.12          getActions().addAction(mPopupMenuAction);
    1.13          getActions().addAction(new CasaRemoveAction(this, mModel));
    1.14          getActions().addAction(CasaFactory.createAcceptAction(new CasaPaletteAcceptProvider(this, mModel)));
    1.15 +        getActions().addAction(CasaFactory.createCycleCasaSceneSelectAction());        
    1.16          
    1.17          addSceneListener(new BannerSceneListener(this));
    1.18      }
    1.19 @@ -774,4 +774,74 @@
    1.20      public String getSourcesPath() {
    1.21          return mDataObject.getFolder().getPrimaryFile().getParent().getPath();
    1.22      }
    1.23 +        /**
    1.24 +     * This method returns an identity code. It should be unique for each object in the scene.
    1.25 +     * The identity code is a Comparable and could be used for sorting.
    1.26 +     * The method implementation should be fast.
    1.27 +     * @param object the object
    1.28 +     * @return the identity code of the object; null, if the object is null
    1.29 +     */
    1.30 +    public Comparable getIdentityCode (Object object) {
    1.31 +        if(object == null || object instanceof CasaRegion) {
    1.32 +            return null;
    1.33 +        }
    1.34 +        String idCode = "";
    1.35 +        if(object instanceof CasaPort) {
    1.36 +            idCode = getIdentityCode((CasaPort) object).toString();
    1.37 +        } else if(object instanceof CasaConnection) {
    1.38 +            idCode = getIdentityCode((CasaConnection) object).toString();
    1.39 +        } else if(object instanceof CasaServiceEngineServiceUnit) {
    1.40 +            idCode = getIdentityCode((CasaServiceEngineServiceUnit) object).toString();
    1.41 +        } else if(object instanceof CasaConsumes) {
    1.42 +            idCode = getIdentityCode((CasaConsumes) object).toString();
    1.43 +        } else if(object instanceof CasaProvides) {
    1.44 +            idCode = getIdentityCode((CasaProvides) object).toString();
    1.45 +        } else {
    1.46 +        }
    1.47 +        return idCode;
    1.48 +    }
    1.49 +    
    1.50 +    private StringBuffer getIdentityCode(CasaPort casaPort) {
    1.51 +        StringBuffer retString = new StringBuffer("A");
    1.52 +        retString.append(String.format("%010d",casaPort.getX()));
    1.53 +        retString.append(String.format("%010d",casaPort.getY()));
    1.54 +        return retString;
    1.55 +    }
    1.56 +    
    1.57 +    private StringBuffer getIdentityCode(CasaServiceEngineServiceUnit casaSU) {
    1.58 +        String code = casaSU.isInternal() ? "C" : "E";
    1.59 +        StringBuffer retString = new StringBuffer(code);
    1.60 +        retString.append(String.format("%010d",casaSU.getY()));
    1.61 +        retString.append(String.format("%010d",casaSU.getX()));
    1.62 +        return retString;
    1.63 +    }
    1.64 +    private StringBuffer getIdentityCode(CasaConsumes casaConsumes) {
    1.65 +        StringBuffer retString = new StringBuffer("");
    1.66 +        CasaComponent parent = casaConsumes.getParent();
    1.67 +        if(parent instanceof CasaPort) {
    1.68 +            retString = getIdentityCode((CasaPort) parent);
    1.69 +        } else if(parent instanceof CasaServiceEngineServiceUnit) {
    1.70 +            retString = getIdentityCode((CasaServiceEngineServiceUnit) parent);
    1.71 +        }
    1.72 +        retString.append("C");
    1.73 +        retString.append(String.format("%010d",casaConsumes.findPosition()));
    1.74 +        return retString;
    1.75 +    }
    1.76 +    private StringBuffer getIdentityCode(CasaProvides casaProvides) {
    1.77 +        StringBuffer retString = new StringBuffer("");
    1.78 +        CasaComponent parent = casaProvides.getParent();
    1.79 +        if(parent instanceof CasaPort) {
    1.80 +            retString = getIdentityCode((CasaPort) parent);
    1.81 +        } else if(parent instanceof CasaServiceEngineServiceUnit) {
    1.82 +            retString = getIdentityCode((CasaServiceEngineServiceUnit) parent);
    1.83 +        }
    1.84 +        retString.append("P");
    1.85 +        retString.append(String.format("%010d",casaProvides.findPosition()));
    1.86 +        return retString;
    1.87 +    }
    1.88 +    private StringBuffer getIdentityCode(CasaConnection casaConnection) {
    1.89 +        StringBuffer retString = new StringBuffer("G");
    1.90 +        retString.append(String.format("%010d",casaConnection.findPosition()));
    1.91 +        return retString;
    1.92 +    }
    1.93  }
     2.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaConnectionWidget.java	Sat Aug 04 02:42:54 2007 +0000
     2.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaConnectionWidget.java	Sat Aug 04 18:43:48 2007 +0000
     2.3 @@ -48,7 +48,7 @@
     2.4       * @param state the new state
     2.5       */
     2.6      public void notifyStateChanged (ObjectState previousState, ObjectState state) {
     2.7 -        if (state.isSelected ()) {
     2.8 +        if (state.isSelected () || state.isFocused()) {
     2.9              bringToFront();
    2.10              setStroke(STROKE_SELECTED);
    2.11              setForeground (CasaFactory.getCasaCustomizer().getCOLOR_SELECTION());
     3.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaFactory.java	Sat Aug 04 02:42:54 2007 +0000
     3.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaFactory.java	Sat Aug 04 18:43:48 2007 +0000
     3.3 @@ -29,7 +29,9 @@
     3.4  package org.netbeans.modules.compapp.casaeditor.graph;
     3.5  
     3.6  import java.beans.PropertyChangeListener;
     3.7 +import org.netbeans.api.visual.action.ActionFactory;
     3.8  import org.netbeans.api.visual.action.WidgetAction;
     3.9 +import org.netbeans.modules.compapp.casaeditor.graph.actions.CycleCasaSceneSelectProvider;
    3.10  import org.netbeans.modules.compapp.casaeditor.palette.CasaAcceptProvider;
    3.11  import org.netbeans.modules.compapp.casaeditor.palette.CasaPaletteAcceptAction;
    3.12  
    3.13 @@ -39,10 +41,12 @@
    3.14   */
    3.15  public class CasaFactory {
    3.16      
    3.17 -    static CasaCustomizer msCasaCustomizer = new CasaCustomizer();
    3.18 +    private static CasaCustomizer msCasaCustomizer = new CasaCustomizer();
    3.19      
    3.20 -    static CasaCustomizerRegistor msCasaCustomizerRegistor = new CasaCustomizerRegistor();
    3.21 -    
    3.22 +    private static CasaCustomizerRegistor msCasaCustomizerRegistor = new CasaCustomizerRegistor();
    3.23 +
    3.24 +    private static final WidgetAction msCasaCycleCasaSceneSelectAction = ActionFactory.createCycleFocusAction (new CycleCasaSceneSelectProvider());
    3.25 +
    3.26      /** Creates a new instance of CasaFactory */
    3.27      public CasaFactory() {
    3.28      }
    3.29 @@ -69,4 +73,7 @@
    3.30          return msCasaCustomizerRegistor;
    3.31      }
    3.32      
    3.33 +    public static WidgetAction createCycleCasaSceneSelectAction() {
    3.34 +        return msCasaCycleCasaSceneSelectAction;
    3.35 +    }
    3.36  }
     4.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidget.java	Sat Aug 04 02:42:54 2007 +0000
     4.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidget.java	Sat Aug 04 18:43:48 2007 +0000
     4.3 @@ -20,6 +20,7 @@
     4.4  package org.netbeans.modules.compapp.casaeditor.graph;
     4.5  
     4.6  import java.awt.Rectangle;
     4.7 +import org.netbeans.api.visual.action.CycleFocusProvider;
     4.8  import org.netbeans.api.visual.anchor.Anchor;
     4.9  import org.netbeans.api.visual.widget.*;
    4.10  
    4.11 @@ -31,7 +32,7 @@
    4.12   *
    4.13   * @author David Kaspar
    4.14   */
    4.15 -public abstract class CasaNodeWidget extends Widget {
    4.16 +public abstract class CasaNodeWidget extends Widget implements CycleFocusProvider {
    4.17      
    4.18      protected Widget mContainerWidget;
    4.19      
    4.20 @@ -119,4 +120,13 @@
    4.21              getScene().validate();
    4.22          }
    4.23      }
    4.24 +
    4.25 +    public boolean switchPreviousFocus(Widget widget) {
    4.26 +        throw new UnsupportedOperationException("Not supported yet.");
    4.27 +    }
    4.28 +
    4.29 +    public boolean switchNextFocus(Widget widget) {
    4.30 +        throw new UnsupportedOperationException("Not supported yet.");
    4.31 +    }
    4.32 +    
    4.33  }
     5.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetBinding.java	Sat Aug 04 02:42:54 2007 +0000
     5.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetBinding.java	Sat Aug 04 18:43:48 2007 +0000
     5.3 @@ -24,11 +24,15 @@
     5.4  
     5.5  import java.awt.*;
     5.6  import java.awt.image.BufferedImage;
     5.7 +import java.util.HashSet;
     5.8 +import java.util.Set;
     5.9  import javax.swing.border.Border;
    5.10 +import org.netbeans.api.visual.action.ActionFactory;
    5.11  import org.netbeans.api.visual.anchor.Anchor;
    5.12  import org.netbeans.api.visual.border.BorderFactory;
    5.13  import org.netbeans.api.visual.layout.Layout;
    5.14  import org.netbeans.api.visual.model.ObjectState;
    5.15 +import org.netbeans.modules.compapp.casaeditor.design.CasaModelGraphScene;
    5.16  import org.openide.util.NbBundle;
    5.17  
    5.18  /**
    5.19 @@ -107,6 +111,8 @@
    5.20          mNameWidget.setForeground(CasaFactory.getCasaCustomizer().getCOLOR_BC_LABEL());
    5.21          
    5.22          regenerateHeaderBorder();
    5.23 +        
    5.24 +        //getActions().addAction(ActionFactory.createCycleFocusAction(this));
    5.25      }
    5.26      
    5.27      
    5.28 @@ -165,9 +171,11 @@
    5.29  
    5.30      protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
    5.31          super.notifyStateChanged(previousState, state);
    5.32 -        if (!previousState.isSelected() && state.isSelected()) {
    5.33 +        if ((!previousState.isSelected() && state.isSelected()) ||
    5.34 +            (!previousState.isFocused() && state.isFocused())){
    5.35              regenerateHeaderBorder();
    5.36 -        } else if (previousState.isSelected() && !state.isSelected()) {
    5.37 +        } else if ((previousState.isSelected() && !state.isSelected()) ||
    5.38 +                   (previousState.isFocused() && !state.isFocused())) {
    5.39              regenerateHeaderBorder();
    5.40          }
    5.41      }
    5.42 @@ -226,7 +234,7 @@
    5.43      
    5.44      public void regenerateHeaderBorder() {
    5.45          BorderDefinition definition = null;
    5.46 -        if (getState().isSelected()) {
    5.47 +        if (getState().isSelected() || getState().isFocused()) {
    5.48              definition = BorderDefinition.createSelectedDefinition();
    5.49              mBodyWidget.setBorder(BorderFactory.createSwingBorder(
    5.50                      getScene(), 
    5.51 @@ -372,4 +380,90 @@
    5.52                  CasaFactory.getCasaCustomizer().getCOLOR_SELECTION());
    5.53          }
    5.54      }
    5.55 -}
    5.56 +
    5.57 +    public boolean switchPreviousFocus(Widget widget) {
    5.58 +        boolean bSwitchSuccessful = true;
    5.59 +        CasaModelGraphScene scene = (CasaModelGraphScene) widget.getScene();
    5.60 +        widget = scene.getFocusedWidget();
    5.61 +        Object nextSelectedObject = null;
    5.62 +        Set selectedObjects = new HashSet();
    5.63 +
    5.64 +        if (widget instanceof CasaPinWidgetBindingProvides) {
    5.65 +            nextSelectedObject = scene.findObject(getConsumesPinWidget((CasaPinWidgetBindingProvides) widget));
    5.66 +        } else if(widget instanceof CasaPinWidgetBindingConsumes) {
    5.67 +            nextSelectedObject = scene.findObject(getCasaNodeWidgetBinding((CasaPinWidgetBindingConsumes) widget));
    5.68 +        }
    5.69 +        if(widget instanceof CasaNodeWidgetBinding) {
    5.70 +            nextSelectedObject = scene.findObject(((CasaNodeWidgetBinding)widget).getConsumesPinWidget());
    5.71 +        } else if (widget instanceof CasaPinWidgetBindingConsumes) {
    5.72 +            nextSelectedObject = scene.findObject(getProvidesPinWidget((CasaPinWidgetBindingConsumes) widget));
    5.73 +        } else {
    5.74 +            bSwitchSuccessful = false;
    5.75 +        }
    5.76 +        if(bSwitchSuccessful) {
    5.77 +            selectedObjects.add(nextSelectedObject);
    5.78 +            scene.setSelectedObjects(selectedObjects);
    5.79 +            scene.setFocusedObject(nextSelectedObject);
    5.80 +        }
    5.81 +        return bSwitchSuccessful;
    5.82 +    }
    5.83 +
    5.84 +    public boolean switchNextFocus(Widget widget) {
    5.85 +        boolean bSwitchSuccessful = true;
    5.86 +        CasaModelGraphScene scene = (CasaModelGraphScene) widget.getScene();
    5.87 +        widget = scene.getFocusedWidget();
    5.88 +        Object nextSelectedObject = null;
    5.89 +        Set selectedObjects = new HashSet();
    5.90 +        if(widget instanceof CasaNodeWidgetBinding) {
    5.91 +            nextSelectedObject = scene.findObject(((CasaNodeWidgetBinding)widget).getConsumesPinWidget());
    5.92 +        } else if (widget instanceof CasaPinWidgetBindingConsumes) {
    5.93 +            //nextSelectedObject = scene.findObject(getCasaBindingodeWidgetBinding((CasaPinWidgetBindingConsumes)widget).getProvidesPinWdiget());
    5.94 +            nextSelectedObject = scene.findObject(getProvidesPinWidget((CasaPinWidgetBindingConsumes)widget));
    5.95 +        } else {
    5.96 +            bSwitchSuccessful = false;
    5.97 +        }
    5.98 +        if(bSwitchSuccessful) {
    5.99 +            selectedObjects.add(nextSelectedObject);
   5.100 +            scene.setSelectedObjects(selectedObjects);
   5.101 +            scene.setFocusedObject(nextSelectedObject);
   5.102 +        }
   5.103 +        return bSwitchSuccessful;
   5.104 +    }
   5.105 +    
   5.106 +    public CasaPinWidget getConsumesPinWidget() {
   5.107 +        CasaPinWidget consumes = null;
   5.108 +        for (Widget child : mPinsHolderWidget.getChildren()) {
   5.109 +            if (child instanceof CasaPinWidgetBindingConsumes) {
   5.110 +                consumes = (CasaPinWidgetBindingConsumes) child;
   5.111 +                break;
   5.112 +            }
   5.113 +        }
   5.114 +        return consumes;
   5.115 +    }
   5.116 +    
   5.117 +    public CasaPinWidget getConsumesPinWidget(CasaPinWidgetBindingProvides provides) {
   5.118 +        return getCasaNodeWidgetBinding(provides).getConsumesPinWidget();
   5.119 +    }
   5.120 +    
   5.121 +    public CasaPinWidget getProvidesPinWidget() {
   5.122 +        CasaPinWidget provides = null;
   5.123 +        for (Widget child : mPinsHolderWidget.getChildren()) {
   5.124 +            if (child instanceof CasaPinWidgetBindingProvides) {
   5.125 +                provides = (CasaPinWidgetBindingProvides) child;
   5.126 +                break;
   5.127 +            }
   5.128 +        }
   5.129 +        return provides;
   5.130 +    }
   5.131 +
   5.132 +    public CasaPinWidget getProvidesPinWidget(CasaPinWidgetBindingConsumes consumes) {
   5.133 +        return getCasaNodeWidgetBinding(consumes).getProvidesPinWidget();
   5.134 +    }
   5.135 +    public CasaNodeWidgetBinding getCasaNodeWidgetBinding(CasaPinWidgetBinding pinWidget) {
   5.136 +        Widget parentWidget = pinWidget.getParentWidget();
   5.137 +        while(!(parentWidget instanceof CasaNodeWidgetBinding)) {
   5.138 +            parentWidget = parentWidget.getParentWidget();
   5.139 +        }
   5.140 +        return (CasaNodeWidgetBinding) parentWidget;
   5.141 +    }
   5.142 +}
   5.143 \ No newline at end of file
     6.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetEngine.java	Sat Aug 04 02:42:54 2007 +0000
     6.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaNodeWidgetEngine.java	Sat Aug 04 18:43:48 2007 +0000
     6.3 @@ -2,16 +2,16 @@
     6.4   * The contents of this file are subject to the terms of the Common Development
     6.5   * and Distribution License (the License). You may not use this file except in
     6.6   * compliance with the License.
     6.7 - * 
     6.8 + *
     6.9   * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    6.10   * or http://www.netbeans.org/cddl.txt.
    6.11 - * 
    6.12 + *
    6.13   * When distributing Covered Code, include this CDDL Header Notice in each file
    6.14   * and include the License file at http://www.netbeans.org/cddl.txt.
    6.15   * If applicable, add the following below the CDDL Header, with the fields
    6.16   * enclosed by brackets [] replaced by your own identifying information:
    6.17   * "Portions Copyrighted [year] [name of copyright owner]"
    6.18 - * 
    6.19 + *
    6.20   * The Original Software is NetBeans. The Initial Developer of the Original
    6.21   * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
    6.22   * Microsystems, Inc. All Rights Reserved.
    6.23 @@ -21,8 +21,8 @@
    6.24  
    6.25  import org.netbeans.api.visual.layout.LayoutFactory;
    6.26  import org.netbeans.api.visual.widget.*;
    6.27 -
    6.28  import java.awt.*;
    6.29 +import org.netbeans.api.visual.action.ActionFactory;
    6.30  import org.netbeans.api.visual.anchor.Anchor;
    6.31  import org.netbeans.api.visual.anchor.AnchorFactory;
    6.32  import org.netbeans.api.visual.model.ObjectState;
    6.33 @@ -37,24 +37,23 @@
    6.34   *
    6.35   * @author rdara
    6.36   */
    6.37 -public class CasaNodeWidgetEngine extends CasaNodeWidget 
    6.38 -        implements StateModel.Listener, CasaMinimizable {
    6.39 -    
    6.40 -    public static final int ARROW_PIN_WIDTH           = 25;
    6.41 +public class CasaNodeWidgetEngine extends CasaNodeWidget implements StateModel.Listener, CasaMinimizable {
    6.42 +
    6.43 +    public static final int ARROW_PIN_WIDTH = 25;
    6.44      public static final int MARGIN_SE_ROUNDED_RECTANGLE = ARROW_PIN_WIDTH * 77 / 100;
    6.45 -    private static final int PIN_VERTICAL_GAP         = 5;
    6.46 -    
    6.47 +    private static final int PIN_VERTICAL_GAP = 5;
    6.48 +
    6.49      // The amount of space below the widget,
    6.50      // to help visually separate it from other widgets that might
    6.51      // be immediately below it.
    6.52 -    private static final int TRAILING_VERTICAL_GAP    = 4;
    6.53 -    
    6.54 +    private static final int TRAILING_VERTICAL_GAP = 4;
    6.55 +
    6.56      private CasaEngineTitleWidget mTitleWidget;
    6.57      private StateModel mStateModel = new StateModel(2);
    6.58      private Anchor mNodeAnchor = new CasaNodeAnchor(this);
    6.59      private boolean mIsHighlighted;
    6.60 -    
    6.61 -    
    6.62 +
    6.63 +
    6.64      /**
    6.65       * Creates a node widget.
    6.66       * @param scene the scene
    6.67 @@ -63,23 +62,26 @@
    6.68          super(scene);
    6.69          setOpaque(false);
    6.70          setLayout(LayoutFactory.createVerticalFlowLayout());
    6.71 -        
    6.72 +
    6.73          mStateModel = new StateModel();
    6.74          mStateModel.addListener(this);
    6.75 -        
    6.76 +
    6.77          mTitleWidget = new CasaEngineTitleWidget(scene, mStateModel);
    6.78 -        
    6.79 +
    6.80          final BorderedRectangularProvider provider = new BorderedRectangularProvider() {
    6.81 +
    6.82              public Color getBorderColor() {
    6.83 -                if (getState().isSelected()) {
    6.84 +                if (getState().isSelected() || getState().isFocused()) {
    6.85                      return CasaFactory.getCasaCustomizer().getCOLOR_SELECTION();
    6.86                  } else {
    6.87                      return CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_BORDER();
    6.88                  }
    6.89              }
    6.90 +
    6.91              public Color getBackgroundColor() {
    6.92                  return CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_BACKGROUND();
    6.93              }
    6.94 +
    6.95              public Rectangle getHeaderRect() {
    6.96                  Rectangle titleBounds = mTitleWidget.getBounds();
    6.97                  if (titleBounds != null) {
    6.98 @@ -89,32 +91,36 @@
    6.99                  }
   6.100                  return null;
   6.101              }
   6.102 +
   6.103              public Color getHeaderColor() {
   6.104                  return CasaFactory.getCasaCustomizer().getCOLOR_BC_TITLE_BACKGROUND();
   6.105              }
   6.106 +
   6.107              public Rectangle getClipRect() {
   6.108                  Rectangle clientArea = mContainerWidget.getClientArea();
   6.109                  Rectangle gradientRect = new Rectangle();
   6.110 -                
   6.111 +
   6.112                  gradientRect.x = clientArea.x + MARGIN_SE_ROUNDED_RECTANGLE;
   6.113 -                gradientRect.y = clientArea.y ;
   6.114 +                gradientRect.y = clientArea.y;
   6.115                  gradientRect.width = clientArea.width - MARGIN_SE_ROUNDED_RECTANGLE - MARGIN_SE_ROUNDED_RECTANGLE;
   6.116                  gradientRect.height = clientArea.height;
   6.117 -                
   6.118 +
   6.119                  return gradientRect;
   6.120              }
   6.121 +
   6.122              public boolean isRounded() {
   6.123                  return true;
   6.124              }
   6.125          };
   6.126 -        
   6.127 +
   6.128          Painter customWidgetPainter = new Painter() {
   6.129 +
   6.130              public void paint(Graphics2D g) {
   6.131                  // Draw a line below the title widget to separate
   6.132                  // the title from the pin area.
   6.133                  Rectangle rect = provider.getHeaderRect();
   6.134                  if (rect != null) {
   6.135 -                    if (getState().isSelected()) {
   6.136 +                    if (getState().isSelected() || getState().isFocused()) {
   6.137                          g.setColor(CasaFactory.getCasaCustomizer().getCOLOR_SELECTION());
   6.138                      } else {
   6.139                          g.setColor(CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_BORDER());
   6.140 @@ -122,42 +128,32 @@
   6.141                      g.drawLine(rect.x, rect.y + rect.height, rect.x + rect.width, rect.y + rect.height);
   6.142                  }
   6.143                  if (isHighlighted()) {
   6.144 -                    InnerGlowBorderDrawer.paintInnerGlowBorder(
   6.145 -                            getGraphics(),
   6.146 -                            provider.getClipRect(),
   6.147 -                            CasaFactory.getCasaCustomizer().getCOLOR_SELECTION(),
   6.148 -                            0.6f,
   6.149 -                            10);
   6.150 +                    InnerGlowBorderDrawer.paintInnerGlowBorder(getGraphics(), provider.getClipRect(), CasaFactory.getCasaCustomizer().getCOLOR_SELECTION(), 0.6f, 10);
   6.151                  }
   6.152              }
   6.153          };
   6.154 -        
   6.155 -        mContainerWidget = new PainterWidget(
   6.156 -                scene,
   6.157 -                new BorderedRectangularPainter(provider, customWidgetPainter));
   6.158 +
   6.159 +        mContainerWidget = new PainterWidget(scene, new BorderedRectangularPainter(provider, customWidgetPainter));
   6.160          mContainerWidget.setOpaque(false);
   6.161          mContainerWidget.addChild(mTitleWidget);
   6.162 -        
   6.163 -        mContainerWidget.setLayout(LayoutFactory.createVerticalFlowLayout(
   6.164 -                LayoutFactory.SerialAlignment.LEFT_TOP,
   6.165 -                PIN_VERTICAL_GAP));
   6.166 +
   6.167 +        mContainerWidget.setLayout(LayoutFactory.createVerticalFlowLayout(LayoutFactory.SerialAlignment.LEFT_TOP, PIN_VERTICAL_GAP));
   6.168          addChild(mContainerWidget);
   6.169 +        //getActions().addAction(ActionFactory.createCycleObjectSceneFocusAction());
   6.170      }
   6.171 -    
   6.172 -    
   6.173 +
   6.174 +
   6.175      protected void notifyAdded() {
   6.176          super.notifyAdded();
   6.177 -        
   6.178 +
   6.179          notifyStateChanged(ObjectState.createNormal(), ObjectState.createNormal());
   6.180      }
   6.181 -    
   6.182 +
   6.183      public Rectangle getEntireBounds() {
   6.184          Dimension d = getBounds().getSize();
   6.185 -        return new Rectangle(
   6.186 -                getLocation(),
   6.187 -                new Dimension(d.width, d.height + TRAILING_VERTICAL_GAP));
   6.188 +        return new Rectangle(getLocation(), new Dimension(d.width, d.height + TRAILING_VERTICAL_GAP));
   6.189      }
   6.190 -    
   6.191 +
   6.192      /**
   6.193       * Sets all node properties at once.
   6.194       */
   6.195 @@ -165,19 +161,19 @@
   6.196          boolean hasNodeName = nodeName != null && nodeName.length() >= 0;
   6.197          boolean hasNodeType = nodeType != null && nodeType.length() > 0;
   6.198          if (hasNodeType && hasNodeName) {
   6.199 -            mTitleWidget.setLabel("(" + nodeType + ") " + nodeName);    // NOI18N
   6.200 +            mTitleWidget.setLabel("(" + nodeType + ") " + nodeName); // NOI18N
   6.201          } else if (hasNodeType) {
   6.202 -            mTitleWidget.setLabel("(" + nodeType + ")");                // NOI18N
   6.203 +            mTitleWidget.setLabel("(" + nodeType + ")"); // NOI18N
   6.204          } else if (hasNodeName) {
   6.205 -            mTitleWidget.setLabel(nodeName);                            // NOI18N
   6.206 +            mTitleWidget.setLabel(nodeName); // NOI18N
   6.207          }
   6.208          readjustBounds();
   6.209      }
   6.210 -    
   6.211 +
   6.212      public void stateChanged() {
   6.213          setMinimized(mStateModel.getBooleanState());
   6.214      }
   6.215 -    
   6.216 +
   6.217      public void setMinimized(boolean isMinimized) {
   6.218          for (Widget child : mContainerWidget.getChildren()) {
   6.219              if (child instanceof CasaMinimizable) {
   6.220 @@ -191,36 +187,40 @@
   6.221      protected Color getBackgroundColor() {
   6.222          return CasaFactory.getCasaCustomizer().getCOLOR_REGION_ENGINE();
   6.223      }
   6.224 +
   6.225      protected Color getPinHolderBorderColor() {
   6.226          return CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_BORDER();
   6.227      }
   6.228 +
   6.229      protected Color getPinHolderTitleColor() {
   6.230          return CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_TITLE();
   6.231      }
   6.232 +
   6.233      protected Color getPinHolderBackgroundColor() {
   6.234          return CasaFactory.getCasaCustomizer().getCOLOR_SU_INTERNAL_BACKGROUND();
   6.235      }
   6.236 -    
   6.237 +
   6.238      public void setTitleFont(Font font) {
   6.239          mTitleWidget.setTitleFont(font);
   6.240          readjustBounds();
   6.241      }
   6.242 -    
   6.243 +
   6.244      public void setTitleColor(Color color) {
   6.245          mTitleWidget.setTitleColor(color);
   6.246      }
   6.247 -    
   6.248 -    
   6.249 +
   6.250 +
   6.251      public void initializeGlassLayer(LayerWidget layer) {
   6.252      }
   6.253 -    
   6.254 +
   6.255      protected void notifyStateChanged(ObjectState previousState, ObjectState state) {
   6.256          super.notifyStateChanged(previousState, state);
   6.257 -        if (previousState.isSelected() != state.isSelected()) {
   6.258 +        if ((previousState.isSelected() != state.isSelected()) ||
   6.259 +            (previousState.isFocused() != state.isFocused())){
   6.260              repaint();
   6.261          }
   6.262      }
   6.263 -    
   6.264 +
   6.265      /**
   6.266       * Attaches a pin widget to the node widget.
   6.267       * @param widget the pin widget
   6.268 @@ -232,7 +232,7 @@
   6.269          setPinColor(getPinColor());
   6.270          mContainerWidget.setPreferredBounds(null);
   6.271      }
   6.272 -    
   6.273 +
   6.274      /*
   6.275       * mPinsHolderWidget is having a mTitleWidget followed by Provide and Consume pin widgets, will be ended by cushioning
   6.276       * widget. CasaPinWidets need to be from 2nd position to the last but one position.
   6.277 @@ -243,12 +243,13 @@
   6.278       *
   6.279       */
   6.280      private void addPinWithOrdering(CasaPinWidget widget) {
   6.281 -        if(mContainerWidget.getChildren().size() <= 1) {       //Add cushoningWidget only once!
   6.282 -            Widget cushioningWidget = new Widget(getScene());   //mTitlewidget is already present and thus checking the size with "1"
   6.283 -            cushioningWidget.setPreferredBounds(new Rectangle(0,PIN_VERTICAL_GAP));
   6.284 +        if (mContainerWidget.getChildren().size() <= 1) {
   6.285 +            //Add cushoningWidget only once!
   6.286 +            Widget cushioningWidget = new Widget(getScene()); //mTitlewidget is already present and thus checking the size with "1"
   6.287 +            cushioningWidget.setPreferredBounds(new Rectangle(0, PIN_VERTICAL_GAP));
   6.288              mContainerWidget.addChild(cushioningWidget);
   6.289          }
   6.290 -        int insertionIndex = 1;    //TitleWidget is already there
   6.291 +        int insertionIndex = 1; //TitleWidget is already there
   6.292          boolean isProvides = false;
   6.293          if (widget instanceof CasaPinWidgetEngineProvides) {
   6.294              isProvides = true;
   6.295 @@ -269,16 +270,16 @@
   6.296          }
   6.297          mContainerWidget.addChild(insertionIndex, widget);
   6.298      }
   6.299 -    
   6.300 +
   6.301      /**
   6.302       * Creates an extended pin anchor with an ability of reconnecting to the node anchor when the node is minimized.
   6.303       * @param anchor the original pin anchor from which the extended anchor is created
   6.304       * @return the extended pin anchor
   6.305       */
   6.306 -    public Anchor createAnchorPin (Anchor pinAnchor) {
   6.307 +    public Anchor createAnchorPin(Anchor pinAnchor) {
   6.308          return AnchorFactory.createProxyAnchor(mStateModel, pinAnchor, mNodeAnchor);
   6.309      }
   6.310 -    
   6.311 +
   6.312      /**
   6.313       * If no pin anchor is found, return the node anchor.
   6.314       */
   6.315 @@ -289,48 +290,51 @@
   6.316          }
   6.317          return anchor;
   6.318      }
   6.319 -    
   6.320 -    public boolean getConfigurationStatus(){
   6.321 +
   6.322 +    public boolean getConfigurationStatus() {
   6.323          return mTitleWidget.getConfigurationStatus();
   6.324      }
   6.325 -    
   6.326 +
   6.327      public void setConfigurationStatus(boolean bConfStatus) {
   6.328          mTitleWidget.setConfigurationStatus(bConfStatus);
   6.329      }
   6.330 -    
   6.331 +
   6.332      public void setEditable(boolean bValue) {
   6.333          super.setEditable(bValue);
   6.334          mTitleWidget.setEditable(bValue);
   6.335      }
   6.336 -    
   6.337 +
   6.338      public Font getPinFont() {
   6.339          return null;
   6.340      }
   6.341 +
   6.342      public Color getPinColor() {
   6.343          return null;
   6.344      }
   6.345 +
   6.346      public void setPinFont(Font font) {
   6.347          for (Widget child : mContainerWidget.getChildren()) {
   6.348              if (child instanceof CasaPinWidgetEngine) {
   6.349 -                ((CasaPinWidgetEngine)child).setLabelFont(font);
   6.350 +                ((CasaPinWidgetEngine) child).setLabelFont(font);
   6.351              }
   6.352          }
   6.353      }
   6.354 +
   6.355      public void setPinColor(Color color) {
   6.356          for (Widget child : mContainerWidget.getChildren()) {
   6.357              if (child instanceof CasaPinWidgetEngine) {
   6.358 -                ((CasaPinWidgetEngine)child).setLabelColor(color);
   6.359 +                ((CasaPinWidgetEngine) child).setLabelColor(color);
   6.360              }
   6.361          }
   6.362      }
   6.363 -    
   6.364 +
   6.365      public void setHighlighted(boolean isHighlighted) {
   6.366          if (mIsHighlighted != isHighlighted) {
   6.367              mIsHighlighted = isHighlighted;
   6.368              repaint();
   6.369          }
   6.370      }
   6.371 -    
   6.372 +
   6.373      public boolean isHighlighted() {
   6.374          return mIsHighlighted;
   6.375      }
     7.1 --- a/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaPinWidget.java	Sat Aug 04 02:42:54 2007 +0000
     7.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/CasaPinWidget.java	Sat Aug 04 18:43:48 2007 +0000
     7.3 @@ -107,9 +107,11 @@
     7.4       */
     7.5      protected void notifyStateChanged (ObjectState previousState, ObjectState state) {
     7.6          super.notifyStateChanged(previousState, state);
     7.7 -        if (!previousState.isSelected() && state.isSelected()) {
     7.8 +        if ((!previousState.isSelected() && state.isSelected()) ||
     7.9 +            (!previousState.isFocused() && state.isFocused())   ) {
    7.10              setSelected(true);
    7.11 -        } else if (previousState.isSelected() && !state.isSelected()) {
    7.12 +        } else if ((previousState.isSelected() && !state.isSelected())||
    7.13 +                   (previousState.isFocused() && !state.isFocused())){
    7.14              setSelected(false);
    7.15          }
    7.16          
     8.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.2 +++ b/compapp.casaeditor/src/org/netbeans/modules/compapp/casaeditor/graph/actions/CycleCasaSceneSelectProvider.java	Sat Aug 04 18:43:48 2007 +0000
     8.3 @@ -0,0 +1,110 @@
     8.4 +/*
     8.5 + * The contents of this file are subject to the terms of the Common Development
     8.6 + * and Distribution License (the License). You may not use this file except in
     8.7 + * compliance with the License.
     8.8 + * 
     8.9 + * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
    8.10 + * or http://www.netbeans.org/cddl.txt.
    8.11 + * 
    8.12 + * When distributing Covered Code, include this CDDL Header Notice in each file
    8.13 + * and include the License file at http://www.netbeans.org/cddl.txt.
    8.14 + * If applicable, add the following below the CDDL Header, with the fields
    8.15 + * enclosed by brackets [] replaced by your own identifying information:
    8.16 + * "Portions Copyrighted [year] [name of copyright owner]"
    8.17 + * 
    8.18 + * Portions Copyrighted 2007 Sun Microsystems, Inc.
    8.19 + */
    8.20 +package org.netbeans.modules.compapp.casaeditor.graph.actions;
    8.21 +
    8.22 +import java.util.HashSet;
    8.23 +import java.util.Set;
    8.24 +import org.netbeans.api.visual.action.CycleFocusProvider;
    8.25 +import org.netbeans.api.visual.widget.Scene;
    8.26 +import org.netbeans.api.visual.widget.Widget;
    8.27 +import org.netbeans.modules.compapp.casaeditor.design.CasaModelGraphScene;
    8.28 +import org.netbeans.modules.compapp.casaeditor.graph.CasaNodeWidgetBinding;
    8.29 +import org.netbeans.modules.compapp.casaeditor.graph.CasaPinWidget;
    8.30 +import org.netbeans.modules.compapp.casaeditor.graph.CasaRegionWidget;
    8.31 +
    8.32 +/**
    8.33 + *
    8.34 + * @author rdara
    8.35 + */
    8.36 +
    8.37 +
    8.38 +public class CycleCasaSceneSelectProvider implements CycleFocusProvider {
    8.39 +
    8.40 +    public boolean switchPreviousFocus (Widget widget) {
    8.41 +        Scene scene = widget.getScene ();
    8.42 +        return scene instanceof CasaModelGraphScene  &&  switchFocus ((CasaModelGraphScene) scene, false);
    8.43 +    }
    8.44 +
    8.45 +    public boolean switchNextFocus (Widget widget) {
    8.46 +        Scene scene = widget.getScene ();
    8.47 +        return scene instanceof CasaModelGraphScene  &&  switchFocus ((CasaModelGraphScene) scene, true);
    8.48 +    }
    8.49 +
    8.50 +    @SuppressWarnings ("unchecked")
    8.51 +    private boolean switchFocus (CasaModelGraphScene scene, boolean forwardDirection) {
    8.52 +        Object object = scene.getFocusedObject ();
    8.53 +        Comparable identityCode = scene.getIdentityCode (object);
    8.54 +
    8.55 +        Object bestObject = null;
    8.56 +        Comparable bestIdentityCode = null;
    8.57 +
    8.58 +        if (identityCode != null) {
    8.59 +            for (Object o : scene.getObjects ()) {
    8.60 +                if(scene.getIdentityCode (o) != null) {
    8.61 +                    Comparable ic = scene.getIdentityCode (o);
    8.62 +                    if (forwardDirection) {
    8.63 +                        if (identityCode.compareTo (ic) < 0) {
    8.64 +                            if (bestIdentityCode == null  ||  bestIdentityCode.compareTo (ic) > 0) {
    8.65 +                                bestObject = o;
    8.66 +                                bestIdentityCode = ic;
    8.67 +                            }
    8.68 +                        }
    8.69 +                    } else {
    8.70 +                        if (identityCode.compareTo (ic) > 0) {
    8.71 +                            if (bestIdentityCode == null  ||  bestIdentityCode.compareTo (ic) < 0) {
    8.72 +                                bestObject = o;
    8.73 +                                bestIdentityCode = ic;
    8.74 +                            }
    8.75 +                        }
    8.76 +                    }
    8.77 +                }
    8.78 +            }
    8.79 +        }
    8.80 +
    8.81 +        
    8.82 +        if (bestIdentityCode == null) {
    8.83 +            for (Object o : scene.getObjects ()) {
    8.84 +                if(scene.getIdentityCode (o) != null) {
    8.85 +                    Comparable ic = scene.getIdentityCode (o);
    8.86 +                    if (forwardDirection) {
    8.87 +                        if (bestIdentityCode == null  ||  bestIdentityCode.compareTo (ic) > 0) {
    8.88 +                            bestObject = o;
    8.89 +                            bestIdentityCode = ic;
    8.90 +                        }
    8.91 +                    } else {
    8.92 +                        if (bestIdentityCode == null  ||  bestIdentityCode.compareTo (ic) < 0) {
    8.93 +                            bestObject = o;
    8.94 +                            bestIdentityCode = ic;
    8.95 +                        }
    8.96 +                    }
    8.97 +                }
    8.98 +            }
    8.99 +        }
   8.100 +        if(bestObject != null ) {
   8.101 +            scene.setFocusedObject (bestObject);
   8.102 +            Set selectedObjects = new HashSet();
   8.103 +            selectedObjects.add(bestObject);
   8.104 +            scene.setSelectedObjects(selectedObjects);
   8.105 +            Widget w = scene.findWidget(bestObject);
   8.106 +            scene.getView().scrollRectToVisible(w.convertLocalToScene(w.getBounds()));
   8.107 +            return true;
   8.108 +        } else {
   8.109 +            return false;
   8.110 +        }
   8.111 +        //return true;
   8.112 +    }
   8.113 +}