001: /*
002: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003: *
004: * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005: *
006: * The contents of this file are subject to the terms of either the GNU
007: * General Public License Version 2 only ("GPL") or the Common
008: * Development and Distribution License("CDDL") (collectively, the
009: * "License"). You may not use this file except in compliance with the
010: * License. You can obtain a copy of the License at
011: * http://www.netbeans.org/cddl-gplv2.html
012: * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013: * specific language governing permissions and limitations under the
014: * License. When distributing the software, include this License Header
015: * Notice in each file and include the License file at
016: * nbbuild/licenses/CDDL-GPL-2-CP. Sun designates this
017: * particular file as subject to the "Classpath" exception as provided
018: * by Sun in the GPL Version 2 section of the License file that
019: * accompanied this code. If applicable, add the following below the
020: * License Header, with the fields enclosed by brackets [] replaced by
021: * your own identifying information:
022: * "Portions Copyrighted [year] [name of copyright owner]"
023: *
024: * Contributor(s):
025: *
026: * The Original Software is NetBeans. The Initial Developer of the Original
027: * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
028: * Microsystems, Inc. All Rights Reserved.
029: *
030: * If you wish your version of this file to be governed by only the CDDL
031: * or only the GPL Version 2, indicate your decision by adding
032: * "[Contributor] elects to include this software in this distribution
033: * under the [CDDL or GPL Version 2] license." If you do not indicate a
034: * single choice of license, a recipient has the option to distribute
035: * your version of this file under either the CDDL, the GPL Version 2 or
036: * to extend the choice of license to its licensees as provided above.
037: * However, if you add GPL Version 2 code and therefore, elected the GPL
038: * Version 2 license, then the option applies only if the new code is
039: * made subject to such option by the copyright holder.
040: */
041:
042: package org.netbeans.modules.ruby.rubyproject.ui.customizer;
043:
044: import javax.swing.JPanel;
045: import javax.swing.event.ChangeListener;
046:
047: import org.openide.filesystems.FileObject;
048:
049: /** Shows a warning that no main class is set and allows choose a main class.
050: *
051: * @author Jiri Rechtacek
052: */
053: public class MainClassWarning extends JPanel {
054:
055: private String message;
056: private FileObject[] sourcesRoots;
057:
058: /** Creates new form LibrariesChooser */
059: public MainClassWarning(String message, FileObject[] sourcesRoots) {
060: this .sourcesRoots = sourcesRoots;
061: this .message = message;
062: initComponents();
063: // add MainClassChooser
064: }
065:
066: /** Returns the selected main class.
067: *
068: * @return name of class or null if no class with the main method is selected
069: */
070: public String getSelectedMainClass() {
071: return ((MainClassChooser) jPanel1).getSelectedMainClass();
072: }
073:
074: public void addChangeListener(ChangeListener l) {
075: ((MainClassChooser) jPanel1).addChangeListener(l);
076: }
077:
078: public void removeChangeListener(ChangeListener l) {
079: ((MainClassChooser) jPanel1).removeChangeListener(l);
080: }
081:
082: /** This method is called from within the constructor to
083: * initialize the form.
084: * WARNING: Do NOT modify this code. The content of this method is
085: * always regenerated by the Form Editor.
086: */
087: private void initComponents() {//GEN-BEGIN:initComponents
088: java.awt.GridBagConstraints gridBagConstraints;
089:
090: jLabel1 = new javax.swing.JLabel();
091: jScrollPane1 = new javax.swing.JScrollPane();
092: jPanel1 = new MainClassChooser(sourcesRoots,
093: org.openide.util.NbBundle.getBundle(
094: MainClassWarning.class).getString(
095: "CTL_SelectAvaialableMainClasses"));
096:
097: setLayout(new java.awt.GridBagLayout());
098:
099: getAccessibleContext().setAccessibleDescription(
100: org.openide.util.NbBundle.getBundle(
101: MainClassWarning.class).getString(
102: "AD_MainClassWarning"));
103: org.openide.awt.Mnemonics.setLocalizedText(jLabel1,
104: this .message);
105: gridBagConstraints = new java.awt.GridBagConstraints();
106: gridBagConstraints.gridx = 0;
107: gridBagConstraints.gridy = 0;
108: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
109: gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
110: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
111: gridBagConstraints.weightx = 1.0;
112: gridBagConstraints.insets = new java.awt.Insets(12, 12, 6, 12);
113: add(jLabel1, gridBagConstraints);
114:
115: jScrollPane1.setBorder(null);
116: jScrollPane1.setViewportView(jPanel1);
117:
118: gridBagConstraints = new java.awt.GridBagConstraints();
119: gridBagConstraints.gridx = 1;
120: gridBagConstraints.gridy = 1;
121: gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
122: gridBagConstraints.gridheight = java.awt.GridBagConstraints.REMAINDER;
123: gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
124: gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
125: gridBagConstraints.weightx = 1.0;
126: gridBagConstraints.weighty = 1.0;
127: add(jScrollPane1, gridBagConstraints);
128:
129: }//GEN-END:initComponents
130:
131: // Variables declaration - do not modify//GEN-BEGIN:variables
132: private javax.swing.JLabel jLabel1;
133: private javax.swing.JPanel jPanel1;
134: private javax.swing.JScrollPane jScrollPane1;
135: // End of variables declaration//GEN-END:variables
136:
137: }
|