Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
   *
   * Copyright 2010 Oracle and/or its affiliates. All rights reserved.
   *
   * Oracle and Java are registered trademarks of Oracle and/or its affiliates.
   * Other names may be trademarks of their respective owners.
   *
   * 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.  Oracle designates this
  * particular file as subject to the "Classpath" exception as provided
  * by Oracle 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]"
  *
  * 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.
  *
  * Contributor(s):
  *
  * Portions Copyrighted 2009 Sun Microsystems, Inc.
  */
 
 /*
  * RestSupportPanel.java
  *
  * Created on 26-Oct-2009, 13:14:19
  */
 
 package org.netbeans.modules.websvc.rest.spi;
 
 import java.awt.Point;
 

Author(s):
mkuchtiak
 
 public class ApplicationConfigPanel extends javax.swing.JPanel {

    
Creates new form RestSupportPanel
 
 
     public ApplicationConfigPanel(String configTypeString resourcesPath
             boolean isJerseyLibboolean annotationConfigAvailableboolean
             hasServerJerseyLibraryString jerseyConfig ) 
     {
         initComponents();
         if (!annotationConfigAvailable) {
             .setVisible(false);
         }
         if ( ..equalsjerseyConfig )){
             .setSelectedIndex(0 );
         }
         else if (..equalsjerseyConfig )){
             .setSelectedIndex(1 );
         }
         if (!isJerseyLib) {
             .setSelected(false);
         }
         if (..equals(configType)) {
             if (annotationConfigAvailable.setSelected(true);
             else .setSelected(true);
             if (!isJerseyLib) {
                 .setSelected(false);
             }
         } else if (..equals(configType)) {
             .setSelected(true);
             .setEnabled(false);
         } else {
             .setSelected(true);
         }
         .setText(resourcesPath);
         .setVisible(hasServerJerseyLibrary);
         .setVisible(hasServerJerseyLibrary);
        addListeners();
    }
    public ApplicationConfigPanel(boolean annotationConfigAvailable,
            boolean hasServerJerseyLibrary
    {
        initComponents();
        if (!annotationConfigAvailable) {
            .setVisible(false);
            .setSelected(true);
        }
        .setVisible(hasServerJerseyLibrary);
        .setVisible(hasServerJerseyLibrary);
        addListeners();
    }
    private void addListeners() {
        ItemListener l = new MyItemListener();
        .addItemListener(l);
        .addItemListener(l);
        .addItemListener(l);
        
        ActionListener listener = new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                boolean enable = .isSelected();
                .setEnabled(enable);
                .setEnabled(enable);
            }
        };
        if ( .isVisible() ){
            .addActionListener(listener);
        }
        
        // Fix for BZ#202054 - Bad size of "REST Resources Configuration" dialog
        addHierarchyListenernew HierarchyListener() {
            @Override
            public void hierarchyChanged(HierarchyEvent e) {
                Point location = .getLocation();
                double bottomY = location.getY()+.getHeight();
                location = .getLocation();
                double topY = location.getY();
                bottomY = bottomY +topY ;
                Dimension dim = getPreferredSize();
                int newHeight = (int)bottomY;
                if ( dim.height < newHeight ) {
                    setPreferredSizenew Dimensiondim.widthnewHeight ));
                }
            }
        });
    }
    
    private ComboBoxModel getSourceModel(){
        String serverLibrary = NbBundle.getMessage(ApplicationConfigPanel.class
                "TXT_UseServerLibrary");                    // NO18N
        String nbLibrary = NbBundle.getMessage(ApplicationConfigPanel.class
                "TXT_UseNbLibrary");                        // NO18N
        Object items[] = new Object[]{serverLibrary,nbLibrary };
        return new DefaultComboBoxModel(items);
    }
    private class MyItemListener implements ItemListener {
        @Override
        public void itemStateChanged(ItemEvent e) {
            if (.isSelected()) {
                .setEnabled(true);
                .setEnabled(true);
                .setEnabled(true);
            } else if (.isSelected()) {
                .setEnabled(false);
                .setEnabled(false);
                .setEnabled(true);
            } else if (.isSelected()){
                .setEnabled(true);
                .setEnabled(true);
                .setSelected(true);
                .setEnabled(false);
            }
        }
    }
    public String getConfigType() {
        if (.isSelected()) return .;
        else if (.isSelected()) return .;
        else return .;
    }
    public boolean isJerseyLibSelected() {
        if ( !.isSelected() ){
            return false;
        }
        if ( !.isVisible() ){
            return true;
        }
        return .getSelectedIndex() ==1;
    }
    
    public boolean isServerJerseyLibSelected(){
        boolean visible = .isVisible();
        if ( !visible || !.isSelected() ){
            return false;
        }
        return .getSelectedIndex() ==0;
    }
    public String getApplicationPath() {
        return .getText().trim();
    }

    
This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
         = new javax.swing.ButtonGroup();
         = new javax.swing.JLabel();
         = new javax.swing.JTextField();
         = new javax.swing.JPanel();
         = new javax.swing.JRadioButton();
         = new javax.swing.JRadioButton();
         = new javax.swing.JRadioButton();
         = new javax.swing.JCheckBox();
         = new javax.swing.JSeparator();
         = new javax.swing.JComboBox();
         = new javax.swing.JLabel();
         = new javax.swing.JLabel();
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jLabel1.text")); // NOI18N
        .setText(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jTextField1.text")); // NOI18N
        .setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0)));
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jRadioButton3.text")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jRadioButton2.text")); // NOI18N
        .setSelected(true);
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jRadioButton1.text")); // NOI18N
        .setAutoscrolls(true);
        .setSelected(true);
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jCheckBox1.text")); // NOI18N
        org.openide.awt.Mnemonics.setLocalizedText(, org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"LBL_Source")); // NOI18N
        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout();
        .setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(....)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(....)
                    .addComponent(..., 564, .)
                    .addGroup(jPanel1Layout.createParallelGroup(....false)
                        .addGroup(....jPanel1Layout.createSequentialGroup()
                            .addGap(134, 134, 134)
                            .addComponent()
                            .addPreferredGap(....)
                            .addComponent(..., 202, ...))))
                .addContainerGap())
            .addGroup(jPanel1Layout.createParallelGroup(....)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addGroup(jPanel1Layout.createParallelGroup(....)
                        .addComponent(..., 572, .))
                    .addContainerGap()))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(....)
            .addGroup(....jPanel1Layout.createSequentialGroup()
                .addContainerGap(152, .)
                .addGroup(jPanel1Layout.createParallelGroup(....)
                    .addComponent())
                .addContainerGap())
            .addGroup(jPanel1Layout.createParallelGroup(....)
                .addGroup(jPanel1Layout.createSequentialGroup()
                    .addContainerGap()
                    .addPreferredGap(....)
                    .addPreferredGap(....)
                    .addContainerGap(92, .)))
        );
        .getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ACSN_Source")); // NOI18N
        .getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ACSD_Source")); // NOI18N
        .setText(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jLabel2.text")); // NOI18N
        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(....)
                    .addComponent()
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(..., 217, .)
                        .addPreferredGap(....)
                        .addComponent(..., 361, ...)))
                .addContainerGap())
        );
        layout.setVerticalGroup(
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent()
                .addGroup(layout.createParallelGroup(....)
                    .addComponent())
        );
        getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"TTL_ApplicationConfigPanel")); // NOI18N
        getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(ApplicationConfigPanel.class"ApplicationConfigPanel.jLabel2.text")); // NOI18N
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox jCheckBox1;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JPanel jPanel1;
    // End of variables declaration//GEN-END:variables
New to GrepCode? Check out our FAQ X