Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
   *
   * The contents of this file are subject to the terms of either the GNU
   * General Public License Version 2 only ("GPL") or the Common
   * Development and Distribution License("CDDL") (collectively, the
   * "License"). You may not use this file except in compliance with the
  * License. You can obtain a copy of the License at
  * http://www.netbeans.org/cddl-gplv2.html
  * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
  * specific language governing permissions and limitations under the
  * License.  When distributing the software, include this License Header
  * Notice in each file and include the License file at
  * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Sun in the GPL Version 2 section of the License file that
  * accompanied this code. If applicable, add the following below the
  * License Header, with the fields enclosed by brackets [] replaced by
  * your own identifying information:
  * "Portions Copyrighted [year] [name of copyright owner]"
  *
  * Contributor(s):
  *
  * The Original Software is NetBeans. The Initial Developer of the Original
  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
  * Microsystems, Inc. All Rights Reserved.
  *
  * If you wish your version of this file to be governed by only the CDDL
  * or only the GPL Version 2, indicate your decision by adding
  * "[Contributor] elects to include this software in this distribution
  * under the [CDDL or GPL Version 2] license." If you do not indicate a
  * single choice of license, a recipient has the option to distribute
  * your version of this file under either the CDDL, the GPL Version 2 or
  * to extend the choice of license to its licensees as provided above.
  * However, if you add GPL Version 2 code and therefore, elected the GPL
  * Version 2 license, then the option applies only if the new code is
  * made subject to such option by the copyright holder.
  */
 /*
  * CommonAttributePanel.java
  *
  * Created on October 10, 2002
  */
 
 package org.netbeans.modules.j2ee.sun.ide.sunresources.wizards;
 
 
 
A single panel descriptor for a wizard. You probably want to make a wizard iterator to hold it.

Author(s):
shirleyc
 
 public class CommonAttributePanel extends ResourceWizardPanel {
    
    
The visual component that displays this panel. If you need to access the component from this class, just use getComponent().
 
     private Component component;
     private ResourceConfigHelper helper;    
     private Wizard wizardInfo;
     private String[] groupNames;
     private boolean setupValid = true;
     private String panelType;
     private boolean isConnPool = false;
    
    
Create the wizard panel descriptor.
 
     public CommonAttributePanel(ResourceConfigHelper helperWizard wizardInfoString[] groupNames) {
         this. = helper;
         this. = wizardInfo;
         this. = groupNames;
     }
     
     // Get the visual component for the panel. In this template, the component
     // is kept separate. This can be more efficient: if the wizard is created
     // but never displayed, or not all panels are displayed, it is better to
     // create only those which really need to be visible.
     public Component getComponent() {
         if ( == null) {
                FieldGroup[] groups = new FieldGroup[.];
                 for (int i = 0; i < this..lengthi++) {
                     groups[i] = FieldGroupHelper.getFieldGroup(this.[i]);  //NOI18N
                 }
                 if (.getName().equals()) {
                      = .;
                     = new ConnectionPoolOptionalVisualPanel(thisthis.); 
                }else if (.getName().equals()) {
                     = .;
                     = new CommonAttributeVisualPanel(thisgroupsthis.);
                }else if (.getName().equals()) {
                     = .;
                     = new CommonAttributeVisualPanel(thisgroupsthis.);
                }
                setIsConnPool();
        }
        return ;
    }
    
    public boolean isNewResourceSelected() {
        if ( == null)
            return false;
        else {
            if(! getIsConnPool()) {
                return ((CommonAttributeVisualPanel)).isNewResourceSelected(); 
            } else {
                return false;
            }
        }    
    }
    
    public void setInitialFocus(){
        if( != null) {
            if(! getIsConnPool()) {
                ((CommonAttributeVisualPanel)).setInitialFocus(); 
            }
        }
    }
    
    public void setPropInitialFocus(){
        if( != null) {
            if(! getIsConnPool()) {
                ((CommonAttributeVisualPanel)).setPropInitialFocus(); 
            }
        }
    }
    
    public String getResourceName() {
        return this..getName();
    }
    
    public HelpCtx getHelp() {
        if (.getName().equals()) {
            return new HelpCtx("AS_Wiz_ConnPool_poolSettings"); //NOI18N
        }else if (.getName().equals()) {
            return new HelpCtx("AS_Wiz_DataSource_general"); //NOI18N
            return new HelpCtx("AS_Wiz_PMF_general"); //NOI18N
        }else {
            return .;
        }
    }
    
    public ResourceConfigHelper getHelper() {
        return ;
    }
    
    public Wizard getWizard() {
        return ;
    }
    
     
Checks if the JNDI Name in the wizard is duplicate name in the Unregistered resource list for JDBC Data Sources, Persistenc Managers, and Java Mail Sessions.

Returns:
boolean true if there is a duplicate name. false if not.
      public boolean isValid () {
          // If it is always OK to press Next or Finish, then:
          if(! ){
              setErrorMsg (.getString ("Err_InvalidSetup"));
              return false;
          }
          setErrorMsg (.getString ("Empty_String"));
          if(! getIsConnPool()) {
              CommonAttributeVisualPanel visComponent = (CommonAttributeVisualPanel;
              if (visComponent != null && visComponent.jLabels != null && visComponent.jFields != null) {
                  for (int i = 0; i < visComponent.jLabels.lengthi++) {
                      String jLabel = (StringvisComponent.jLabels[i].getText ();
                      if (jLabel.equals(Util.getCorrectedLabel())) { // NO18N
                          String jndiName = (String) ((JTextField)visComponent.jFields[i]).getText ();
                          if (jndiName == null || jndiName.length() == 0) {
                              setErrorMsg(.getString("Err_InvalidJndiName"));
                              return false;
                          } else if (!ResourceUtils.isLegalResourceName(jndiName)) {
                              setErrorMsg(.getString("Err_InvalidJndiName"));
                              return false;
                          } else {
                              FileObject resFolder = this..getData().getTargetFileObject();
                              if (resFolder != null) {
                                  if (.getName().equals()) {
                                      if (!ResourceUtils.isUniqueFileName(jndiNameresFolder)) {
                                          setErrorMsg(.getString("Err_DuplFileJndiName"));
                                          return false;
                                      }
                                  } else if (.getName().equals()) {
                                      if (!ResourceUtils.isUniqueFileName(jndiNameresFolder)) {
                                          setErrorMsg(.getString("Err_DuplFileJndiName"));
                                          return false;
                                      }
                                  }
                              }
                          }
                      } //if
                  } //for
              }
              if (!isNewResourceSelected()) {
                  //Need to check the poolname for jdbc
                  if ((this..getData().getResourceName()).equals()) {
                      String cpname = this..getData().getString();
                      if (cpname == null || cpname.trim().equals("")) { //NOI18N
                          setErrorMsg(.getString("Err_ChooseOrCreatePool"));
                          return false;
                      }
                  }
                  //Need to get jdbc data if pmf and make sure it has a poolname
                  if ((this..getData().getResourceName()).equals()) {
                      if (this..getData().getHolder().hasDSHelper()) {
                          String cpname = this..getData().getHolder().getDSHelper().getData().getString();
                          if (cpname == null || cpname.trim().equals("")) { //NOI18N
                              setErrorMsg(.getString("Err_ChooseOrCreatePool"));
                              return false;
                          }
                      } else {
                          String dsname = this..getData().getString();
                          if (dsname == null || dsname.trim().equals("")) { //NOI18N
                              setErrorMsg(.getString("Err_ChooseOrCreateDS"));
                              return false;
                          }
                      }
                  }
              }
          } else {
              ConnectionPoolOptionalVisualPanel visComponent = (ConnectionPoolOptionalVisualPanel;
              return visComponent.hasValidData();
          }
          return true;
      }
    
    public void initData() {
        if(! getIsConnPool()) {
            CommonAttributeVisualPanel visComponent = (CommonAttributeVisualPanel;
            visComponent.initData();
        }      
    }
    
    public void readSettings(Object settings) {
        this. = (WizardDescriptor)settings;
        TemplateWizard wizard = (TemplateWizard)settings;
        String targetName = wizard.getTargetName();
        FileObject resFolder = ResourceUtils.getResourceDirectory(this..getData().getTargetFileObject());
        this..getData().setTargetFileObject (resFolder);
        if( == null)
            getComponent();
        if(resFolder != null){
            String resourceName = this..getData().getString("jndi-name");
            if((resourceName != null) && (! resourceName.equals(""))) {
                this..getData().setTargetFile(resourceName);
            } else {
                if (.getName().equals()) {
                    if (this..getData().getString().equals("true")) { //NOI18N
                        targetName = null;
                    }
                    targetName = ResourceUtils.createUniqueFileName(targetNameresFolder);
                    this..getData().setTargetFile(targetName);
                } else if (.getName().equals()) {
                    targetName = ResourceUtils.createUniqueFileName(targetNameresFolder);
                    this..getData().setTargetFile(targetName);
                }
            }
            if(! getIsConnPool()) {
              CommonAttributeVisualPanel visComponent = (CommonAttributeVisualPanel;
              visComponent.setHelper (this.);
            }
        }else
             = false;
    }
    
    public boolean isFinishPanel() {
       if(isNewResourceSelected())
            return false;
       else
           return isValid();
    }
    
    private boolean setupValid(){
        return ;
    }
    
    private void setIsConnPool(){
             = false;
        }else{
             = true;
        }
    }
    
    private boolean getIsConnPool(){
        return ;
    }
//    protected final void fireChangeEvent (Object source) {
//       super.fireChange(this);
//    }
New to GrepCode? Check out our FAQ X