Bugfixes of JNDI module BLD200203110100
authortzezula@netbeans.org
Fri, 08 Mar 2002 18:12:51 +0000
changeset 209899d3bf2c8e99
parent 2097 c06654b6ba60
child 2099 7fdc159b6389
Bugfixes of JNDI module
jndi/src/org/netbeans/modules/jndi/JndiChildren.java
jndi/src/org/netbeans/modules/jndi/JndiDisabledNode.java
jndi/src/org/netbeans/modules/jndi/JndiFailedNode.java
jndi/src/org/netbeans/modules/jndi/JndiLeafNode.java
jndi/src/org/netbeans/modules/jndi/JndiNode.java
jndi/src/org/netbeans/modules/jndi/JndiProvidersNode.java
jndi/src/org/netbeans/modules/jndi/JndiRootNode.java
jndi/src/org/netbeans/modules/jndi/ProviderNode.java
jndi/src/org/netbeans/modules/jndi/utils/APCTarget.java
jndi/src/org/netbeans/modules/jndi/utils/Request.java
     1.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiChildren.java	Fri Mar 08 16:40:31 2002 +0000
     1.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiChildren.java	Fri Mar 08 18:12:51 2002 +0000
     1.3 @@ -1,11 +1,11 @@
     1.4  /*
     1.5   *                 Sun Public License Notice
     1.6 - * 
     1.7 + *
     1.8   * The contents of this file are subject to the Sun Public License
     1.9   * Version 1.0 (the "License"). You may not use this file except in
    1.10   * compliance with the License. A copy of the License is available at
    1.11   * http://www.sun.com/
    1.12 - * 
    1.13 + *
    1.14   * The Original Code is NetBeans. The Initial Developer of the Original
    1.15   * Code is Sun Microsystems, Inc. Portions Copyright 1997-2001 Sun
    1.16   * Microsystems, Inc. All Rights Reserved.
    1.17 @@ -31,28 +31,28 @@
    1.18   *  It's responsible for lazy initialization as well
    1.19   *  as it is an data model for JndiNode.
    1.20   *
    1.21 - *  @author Ales Novak, Tomas Zezula 
    1.22 + *  @author Ales Novak, Tomas Zezula
    1.23   */
    1.24  public final class JndiChildren extends Children.Keys implements APCTarget {
    1.25 -
    1.26 +    
    1.27      /** This constant represents the name of context class */
    1.28      public final static String CONTEXT_CLASS_NAME = "javax.naming.Context";
    1.29 -
    1.30 +    
    1.31      /** Class object for javax.naming.Context */
    1.32      private static Class ctxClass;
    1.33 -
    1.34 +    
    1.35      /** Current Directory context */
    1.36      private final Context thisContext;
    1.37 -
    1.38 -
    1.39 +    
    1.40 +    
    1.41      /** The shadow key list for merginag and handling errors*/
    1.42      private ArrayList keys;
    1.43 -
    1.44 +    
    1.45      /** Wait node hoder*/
    1.46      private WaitNode waitNode;
    1.47      
    1.48      private CompositeName offset;
    1.49 -
    1.50 +    
    1.51      /** Constructor
    1.52       *  @param parentContext the initial context
    1.53       *  @param offset the relative offset of Node in context
    1.54 @@ -62,7 +62,7 @@
    1.55          this.offset = offset;
    1.56          this.keys = new ArrayList();
    1.57      }
    1.58 -
    1.59 +    
    1.60      /** Called when node is being opened
    1.61       */
    1.62      protected void addNotify(){
    1.63 @@ -71,13 +71,13 @@
    1.64          this.add( new Node[] { this.waitNode});
    1.65          prepareKeys();
    1.66      }
    1.67 -
    1.68 +    
    1.69      /** Called when node is not being used any more
    1.70       */
    1.71      protected void removeNotify(){
    1.72 -        setKeys (Collections.EMPTY_SET);
    1.73 +        setKeys(Collections.EMPTY_SET);
    1.74      }
    1.75 -
    1.76 +    
    1.77      /** Returns actual offset
    1.78       *  @return the relative offset of Node
    1.79       */
    1.80 @@ -87,24 +87,24 @@
    1.81      
    1.82      /** From compatibility reasons
    1.83       */
    1.84 -    public String getOffsetAsString () {
    1.85 -	return JndiObjectCreator.stringifyCompositeName(this.offset); // No I18N 
    1.86 +    public String getOffsetAsString() {
    1.87 +        return JndiObjectCreator.stringifyCompositeName(this.offset); // No I18N
    1.88      }
    1.89 -
    1.90 +    
    1.91      /** Returns context
    1.92       *  @return the initial context
    1.93       */
    1.94      public Context getContext() {
    1.95          return thisContext;
    1.96      }
    1.97 -
    1.98 +    
    1.99      /** This method creates keys
   1.100       *  exception NamingException if Context.list() failed
   1.101       */
   1.102      public void prepareKeys(){
   1.103 -        JndiRootNode.getDefault().refresher.post (new Request (this));
   1.104 +        JndiRootNode.getDefault().refresher.post(new Request(this));
   1.105      }
   1.106 -
   1.107 +    
   1.108      /** Creates Node for key
   1.109       *  @param key the key for which the Node should be created
   1.110       *  @return the array of created Nodes
   1.111 @@ -136,7 +136,7 @@
   1.112              return new Node[0];
   1.113          }
   1.114      }
   1.115 -
   1.116 +    
   1.117      /** Heuristicaly decides whether specified class is a Context or not.
   1.118       *  @param className the name of Class
   1.119       *  @return true if className represents the name of Context*/
   1.120 @@ -153,26 +153,26 @@
   1.121              return (binding.getObject() instanceof javax.naming.Context);
   1.122          }
   1.123      }
   1.124 -
   1.125 +    
   1.126      /** Decides if the string represents the name of primitive type
   1.127       *  @param s the name of type
   1.128 -     *  @return true iff s is one of int, long, char, boolean, float, byte, double 
   1.129 +     *  @return true iff s is one of int, long, char, boolean, float, byte, double
   1.130       */
   1.131      private static boolean isPrimitive(String s) {
   1.132          if (s.indexOf('.') >= 0) {
   1.133              return false;
   1.134          }
   1.135 -
   1.136 +        
   1.137          return s.equals("int") ||
   1.138 -               s.equals("short") ||
   1.139 -               s.equals("long") ||
   1.140 -               s.equals("byte") ||
   1.141 -               s.equals("char") ||
   1.142 -               s.equals("float") ||
   1.143 -               s.equals("double") ||
   1.144 -               s.equals("boolean");
   1.145 +        s.equals("short") ||
   1.146 +        s.equals("long") ||
   1.147 +        s.equals("byte") ||
   1.148 +        s.equals("char") ||
   1.149 +        s.equals("float") ||
   1.150 +        s.equals("double") ||
   1.151 +        s.equals("boolean");
   1.152      }
   1.153 -
   1.154 +    
   1.155      /** Returns the super class for classes representing the Context
   1.156       *  @return Class object for javax.naming.Context
   1.157       */
   1.158 @@ -182,13 +182,13 @@
   1.159          }
   1.160          return ctxClass;
   1.161      }
   1.162 -
   1.163 +    
   1.164      /** This method is called by Refreshd thread before performing
   1.165       *  main action
   1.166       */
   1.167      public void preAction() throws Exception{
   1.168      }
   1.169 -
   1.170 +    
   1.171      /** This is the main action called by Refreshd
   1.172       */
   1.173      public void performAction() throws Exception {
   1.174 @@ -201,23 +201,45 @@
   1.175              this.keys.add(new JndiKey(b));
   1.176          }
   1.177      }
   1.178 -
   1.179 -
   1.180 +    
   1.181 +    
   1.182      /** This action is called by Refreshd after performing main action
   1.183       */
   1.184      public void postAction() throws Exception {
   1.185          this.setKeys(this.keys);
   1.186 -        if (this.waitNode != null)
   1.187 -            this.remove ( new Node[]{ this.waitNode});
   1.188 +        if (this.waitNode != null) {
   1.189 +            this.remove( new Node[]{ this.waitNode});
   1.190 +            this.waitNode = null;
   1.191 +        }
   1.192      }
   1.193 -
   1.194 +    
   1.195 +    /** Called when APCTarget operation caused an exception
   1.196 +     *  to perform clean up
   1.197 +     */
   1.198 +    public void actionFailed() {
   1.199 +        try {
   1.200 +            Children parentChildren = this.getNode().getParentNode().getChildren();
   1.201 +            if (parentChildren instanceof JndiChildren) {
   1.202 +                JndiKey key = ((JndiNode)this.getNode()).getKey();
   1.203 +                key.failed = true;
   1.204 +                ((JndiChildren)parentChildren).updateKey (key);
   1.205 +            }
   1.206 +            else if (this.waitNode != null) {
   1.207 +                this.remove( new Node[] {this.waitNode});
   1.208 +                this.waitNode = null;
   1.209 +            }
   1.210 +        }catch (Exception exception) {
   1.211 +            // Ignore it
   1.212 +        }
   1.213 +    }
   1.214 +    
   1.215      /** public method that returns the node for which the Children is created
   1.216       *  @return Node
   1.217       */
   1.218      public final Node getOwner(){
   1.219          return this.getNode();
   1.220      }
   1.221 -
   1.222 +    
   1.223      /** This method calls the refreshKey method of Children,
   1.224       *  used by Refreshd for changing the failed nodes
   1.225       * @see org.netbeans.modules.jndi.utils.Refreshd
   1.226 @@ -231,25 +253,25 @@
   1.227  
   1.228  /*
   1.229   * <<Log>>
   1.230 - *  14   Jaga      1.11.2.0.1.03/29/00  Tomas Zezula    
   1.231 + *  14   Jaga      1.11.2.0.1.03/29/00  Tomas Zezula
   1.232   *  13   Gandalf-post-FCS1.11.2.0    2/24/00  Ian Formanek    Post FCS changes
   1.233 - *  12   Gandalf   1.11        1/14/00  Tomas Zezula    
   1.234 - *  11   Gandalf   1.10        12/17/99 Tomas Zezula    
   1.235 - *  10   Gandalf   1.9         12/15/99 Tomas Zezula    
   1.236 - *  9    Gandalf   1.8         12/15/99 Tomas Zezula    
   1.237 - *  8    Gandalf   1.7         11/5/99  Tomas Zezula    
   1.238 + *  12   Gandalf   1.11        1/14/00  Tomas Zezula
   1.239 + *  11   Gandalf   1.10        12/17/99 Tomas Zezula
   1.240 + *  10   Gandalf   1.9         12/15/99 Tomas Zezula
   1.241 + *  9    Gandalf   1.8         12/15/99 Tomas Zezula
   1.242 + *  8    Gandalf   1.7         11/5/99  Tomas Zezula
   1.243   *  7    Gandalf   1.6         10/23/99 Ian Formanek    NO SEMANTIC CHANGE - Sun
   1.244   *       Microsystems Copyright in File Comment
   1.245 - *  6    Gandalf   1.5         7/9/99   Ales Novak      localization + code 
   1.246 + *  6    Gandalf   1.5         7/9/99   Ales Novak      localization + code
   1.247   *       requirements followed
   1.248 - *  5    Gandalf   1.4         6/18/99  Ales Novak      redesigned + delete 
   1.249 + *  5    Gandalf   1.4         6/18/99  Ales Novak      redesigned + delete
   1.250   *       action
   1.251 - *  4    Gandalf   1.3         6/9/99   Ales Novak      refresh action + 
   1.252 + *  4    Gandalf   1.3         6/9/99   Ales Novak      refresh action +
   1.253   *       destroying subcontexts
   1.254 - *  3    Gandalf   1.2         6/9/99   Ian Formanek    ---- Package Change To 
   1.255 + *  3    Gandalf   1.2         6/9/99   Ian Formanek    ---- Package Change To
   1.256   *       org.openide ----
   1.257 - *  2    Gandalf   1.1         6/8/99   Ales Novak      sources beautified + 
   1.258 + *  2    Gandalf   1.1         6/8/99   Ales Novak      sources beautified +
   1.259   *       subcontext creation
   1.260 - *  1    Gandalf   1.0         6/4/99   Ales Novak      
   1.261 + *  1    Gandalf   1.0         6/4/99   Ales Novak
   1.262   * $
   1.263   */
     2.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiDisabledNode.java	Fri Mar 08 16:40:31 2002 +0000
     2.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiDisabledNode.java	Fri Mar 08 18:12:51 2002 +0000
     2.3 @@ -24,6 +24,7 @@
     2.4  import org.openide.util.actions.SystemAction;
     2.5  import org.openide.actions.DeleteAction;
     2.6  import org.openide.actions.PropertiesAction;
     2.7 +import org.openide.util.HelpCtx;
     2.8  import org.netbeans.modules.jndi.utils.Refreshable;
     2.9  import org.netbeans.modules.jndi.utils.JndiPropertyMutator;
    2.10  
    2.11 @@ -126,4 +127,12 @@
    2.12          return true;
    2.13      }
    2.14      
    2.15 +    /** Returns the help context for the root Context
    2.16 +     *  which could not be restored after the start of
    2.17 +     *  the IDE, e.g. because of the service is not started.
    2.18 +     */
    2.19 +    public HelpCtx getHelpCtx () {
    2.20 +        return HelpCtx.DEFAULT_HELP;
    2.21 +    }
    2.22 +    
    2.23  }
    2.24 \ No newline at end of file
     3.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiFailedNode.java	Fri Mar 08 16:40:31 2002 +0000
     3.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiFailedNode.java	Fri Mar 08 18:12:51 2002 +0000
     3.3 @@ -21,6 +21,7 @@
     3.4  import javax.naming.Context;
     3.5  import javax.naming.NamingException;
     3.6  import javax.naming.CompositeName;
     3.7 +import org.openide.util.HelpCtx;
     3.8  
     3.9  public class JndiFailedNode extends JndiLeafNode {
    3.10  
    3.11 @@ -29,4 +30,12 @@
    3.12          super (key, offset);
    3.13          this.setIconBase(JndiIcons.ICON_BASE + JndiIcons.getIconName(JndiDisabledNode.DISABLED_CONTEXT_ICON));
    3.14      }
    3.15 +    
    3.16 +    /** Returns help context for the failed JNDI node,
    3.17 +     *  the node inside some JNDI context, which can not
    3.18 +     *  be accessed, e.g. for security reasons
    3.19 +     */
    3.20 +    public HelpCtx getHelpCtx () {
    3.21 +        return HelpCtx.DEFAULT_HELP;
    3.22 +    }
    3.23  }
    3.24 \ No newline at end of file
     4.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiLeafNode.java	Fri Mar 08 16:40:31 2002 +0000
     4.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiLeafNode.java	Fri Mar 08 18:12:51 2002 +0000
     4.3 @@ -30,6 +30,7 @@
     4.4  import org.openide.nodes.AbstractNode;
     4.5  import org.openide.nodes.Children;
     4.6  import org.openide.nodes.Sheet;
     4.7 +import org.openide.util.HelpCtx;
     4.8  import org.openide.util.actions.SystemAction;
     4.9  
    4.10  /** This class represents Leaf Node (Not context) in JNDI tree
    4.11 @@ -137,6 +138,14 @@
    4.12          return this.getKey().name.getClassName();
    4.13      }
    4.14      
    4.15 +    /** Returns help context for the
    4.16 +     *  JNDI leaf node, the node representing 
    4.17 +     *  the end bound object (e.g. EJB HomeInterface)
    4.18 +     */
    4.19 +    public HelpCtx getHelpCtx () {
    4.20 +        return HelpCtx.DEFAULT_HELP;
    4.21 +    }
    4.22 +    
    4.23      protected void handleChangeJndiPropertyValue (Attributes attrs) throws NamingException {
    4.24          ((DirContext)this.getContext()).modifyAttributes(this.getKey().name.getName(),DirContext.REPLACE_ATTRIBUTE,attrs);
    4.25      }
     5.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiNode.java	Fri Mar 08 16:40:31 2002 +0000
     5.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiNode.java	Fri Mar 08 18:12:51 2002 +0000
     5.3 @@ -40,6 +40,7 @@
     5.4  import org.openide.util.actions.SystemAction;
     5.5  import org.openide.util.datatransfer.NewType;
     5.6  import org.openide.util.datatransfer.ExClipboard;
     5.7 +import org.openide.util.HelpCtx;
     5.8  import org.openide.DialogDescriptor;
     5.9  import org.netbeans.modules.jndi.utils.Refreshable;
    5.10  import org.netbeans.modules.jndi.utils.DisconnectCtxCookie;
    5.11 @@ -261,6 +262,13 @@
    5.12          return sheet;
    5.13      }
    5.14      
    5.15 +    /** Return help context for the JNDI Context Node,
    5.16 +     *  the JNDI directory
    5.17 +     */
    5.18 +    public HelpCtx getHelpCtx () {
    5.19 +        return HelpCtx.DEFAULT_HELP;
    5.20 +    }
    5.21 +    
    5.22      protected void handleChangeJndiPropertyValue (Attributes attrs) throws NamingException {
    5.23          ((DirContext)this.getContext()).modifyAttributes("",DirContext.REPLACE_ATTRIBUTE,attrs); // No I18N
    5.24      }
     6.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiProvidersNode.java	Fri Mar 08 16:40:31 2002 +0000
     6.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiProvidersNode.java	Fri Mar 08 18:12:51 2002 +0000
     6.3 @@ -26,6 +26,7 @@
     6.4  import org.openide.nodes.Children;
     6.5  import org.openide.nodes.DefaultHandle;
     6.6  import org.openide.nodes.Sheet;
     6.7 +import org.openide.util.HelpCtx;
     6.8  import org.netbeans.modules.jndi.utils.Refreshable;
     6.9  import org.netbeans.modules.jndi.settings.JndiSystemOption;
    6.10  
    6.11 @@ -163,4 +164,12 @@
    6.12          this.getChildren().remove ( this.getChildren().getNodes());
    6.13          this.installProperties (true);
    6.14      }
    6.15 +    
    6.16 +    
    6.17 +    /** Returns help context for providers node,
    6.18 +     *  the parent node for provider nodes
    6.19 +     */
    6.20 +    public HelpCtx getHelpCtx () {
    6.21 +        return HelpCtx.DEFAULT_HELP;
    6.22 +    }
    6.23  }
    6.24 \ No newline at end of file
     7.1 --- a/jndi/src/org/netbeans/modules/jndi/JndiRootNode.java	Fri Mar 08 16:40:31 2002 +0000
     7.2 +++ b/jndi/src/org/netbeans/modules/jndi/JndiRootNode.java	Fri Mar 08 18:12:51 2002 +0000
     7.3 @@ -44,6 +44,7 @@
     7.4  import org.openide.util.actions.SystemAction;
     7.5  import org.openide.util.datatransfer.NewType;
     7.6  import org.openide.util.RequestProcessor;
     7.7 +import org.openide.util.HelpCtx;
     7.8  import org.netbeans.modules.jndi.settings.JndiSystemOption;
     7.9  
    7.10  /** Top Level JNDI Node
    7.11 @@ -369,6 +370,13 @@
    7.12      public static void showLocalizedStatus (String message) {
    7.13          showStatus(getLocalizedString(message));
    7.14      }
    7.15 +    
    7.16 +    /** Returns the help context for the
    7.17 +     *  JNDI root node
    7.18 +     */
    7.19 +    public HelpCtx getHelpCtx () {
    7.20 +        return HelpCtx.DEFAULT_HELP;
    7.21 +    }
    7.22  
    7.23  
    7.24  }
     8.1 --- a/jndi/src/org/netbeans/modules/jndi/ProviderNode.java	Fri Mar 08 16:40:31 2002 +0000
     8.2 +++ b/jndi/src/org/netbeans/modules/jndi/ProviderNode.java	Fri Mar 08 18:12:51 2002 +0000
     8.3 @@ -31,6 +31,7 @@
     8.4  import org.openide.nodes.Children;
     8.5  import org.openide.nodes.Node.Cookie;
     8.6  import org.openide.nodes.Sheet;
     8.7 +import org.openide.util.HelpCtx;
     8.8  import org.netbeans.modules.jndi.settings.JndiSystemOption;
     8.9  
    8.10  
    8.11 @@ -347,6 +348,13 @@
    8.12          }
    8.13      }
    8.14      
    8.15 +    /** Returns the help context for
    8.16 +     *  provider node
    8.17 +     */
    8.18 +    public HelpCtx getHelpCtx () {
    8.19 +        return HelpCtx.DEFAULT_HELP;
    8.20 +    }
    8.21 +    
    8.22      
    8.23      private JndiSystemOption getSettings () {
    8.24          if (this.settings == null) {
     9.1 --- a/jndi/src/org/netbeans/modules/jndi/utils/APCTarget.java	Fri Mar 08 16:40:31 2002 +0000
     9.2 +++ b/jndi/src/org/netbeans/modules/jndi/utils/APCTarget.java	Fri Mar 08 18:12:51 2002 +0000
     9.3 @@ -22,4 +22,5 @@
     9.4      public void preAction() throws Exception;
     9.5      public void performAction() throws Exception;
     9.6      public void postAction() throws Exception;
     9.7 +    public void actionFailed ();
     9.8  }
    10.1 --- a/jndi/src/org/netbeans/modules/jndi/utils/Request.java	Fri Mar 08 16:40:31 2002 +0000
    10.2 +++ b/jndi/src/org/netbeans/modules/jndi/utils/Request.java	Fri Mar 08 18:12:51 2002 +0000
    10.3 @@ -34,7 +34,9 @@
    10.4              this.target.performAction();
    10.5              this.target.postAction();
    10.6          }catch (Exception e) {
    10.7 -            TopManager.getDefault().getErrorManager().notify (ErrorManager.USER,e);
    10.8 +            this.target.actionFailed ();
    10.9 +            ErrorManager em = TopManager.getDefault().getErrorManager();
   10.10 +            em.notify (ErrorManager.INFORMATIONAL, e);
   10.11          }
   10.12      }
   10.13