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.vmd.game.preview;
043:
044: import java.awt.event.ActionEvent;
045: import java.awt.event.ActionListener;
046: import java.util.List;
047: import javax.swing.ComboBoxModel;
048: import javax.swing.DefaultComboBoxModel;
049: import org.netbeans.modules.vmd.game.model.Sequence;
050: import org.netbeans.modules.vmd.game.model.SequenceContainer;
051:
052: /**
053: *
054: * @author kherink
055: */
056: public class SequenceContainerPreview extends javax.swing.JPanel
057: implements ActionListener {
058:
059: private SequenceContainer sequenceContainer;
060: private SequencePreviewPanel sequencePreviewPanel;
061: private String labelTypeName;
062:
063: /**
064: * Creates new form SequenceContainerPreview
065: */
066: public SequenceContainerPreview(String labelTypeName,
067: SequenceContainer sequenceContainer) {
068: this .labelTypeName = labelTypeName;
069: this .sequenceContainer = sequenceContainer;
070: this .sequencePreviewPanel = (SequencePreviewPanel) this .sequenceContainer
071: .getDefaultSequence().getPreview();
072: initComponents();
073: }
074:
075: private ComboBoxModel getSequenceComboModel() {
076: List sequences = this .sequenceContainer.getSequences();
077: return new DefaultComboBoxModel(sequences.toArray());
078: }
079:
080: public void actionPerformed(ActionEvent e) {
081: if (e.getSource() == this .comboBoxSequence) {
082: Sequence currentSequence = (Sequence) this .comboBoxSequence
083: .getSelectedItem();
084: this .sequencePreviewPanel.setSequence(currentSequence);
085: }
086: }
087:
088: /** This method is called from within the constructor to
089: * initialize the form.
090: * WARNING: Do NOT modify this code. The content of this method is
091: * always regenerated by the Form Editor.
092: */
093: // <editor-fold defaultstate="collapsed" desc=" Generated Code ">//GEN-BEGIN:initComponents
094: private void initComponents() {
095: labelSprite = new javax.swing.JLabel();
096: textFieldSprite = new javax.swing.JTextField();
097: comboBoxSequence = new javax.swing.JComboBox();
098: sequencePanel = new javax.swing.JPanel();
099:
100: setBackground(new java.awt.Color(255, 255, 255));
101: setMinimumSize(new java.awt.Dimension(10, 180));
102: labelSprite.setText(this .labelTypeName);
103:
104: textFieldSprite
105: .setBackground(new java.awt.Color(255, 255, 255));
106: textFieldSprite.setEditable(false);
107: textFieldSprite.setText(this .sequenceContainer.getName());
108: textFieldSprite.setBorder(null);
109:
110: comboBoxSequence
111: .setBackground(new java.awt.Color(255, 255, 255));
112: comboBoxSequence.setModel(getSequenceComboModel());
113: this .comboBoxSequence.addActionListener(this );
114:
115: sequencePanel.setLayout(new java.awt.BorderLayout());
116:
117: sequencePanel.setBackground(new java.awt.Color(255, 255, 255));
118: this .sequencePanel.add(this .sequencePreviewPanel);
119:
120: org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(
121: this );
122: this .setLayout(layout);
123: layout
124: .setHorizontalGroup(layout
125: .createParallelGroup(
126: org.jdesktop.layout.GroupLayout.LEADING)
127: .add(
128: org.jdesktop.layout.GroupLayout.LEADING,
129: layout
130: .createSequentialGroup()
131: .addContainerGap()
132: .add(
133: layout
134: .createParallelGroup(
135: org.jdesktop.layout.GroupLayout.TRAILING)
136: .add(
137: org.jdesktop.layout.GroupLayout.LEADING,
138: layout
139: .createSequentialGroup()
140: .add(
141: labelSprite)
142: .addPreferredGap(
143: org.jdesktop.layout.LayoutStyle.RELATED)
144: .add(
145: textFieldSprite,
146: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
147: 101,
148: Short.MAX_VALUE))
149: .add(
150: org.jdesktop.layout.GroupLayout.LEADING,
151: comboBoxSequence,
152: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
153: 197,
154: Short.MAX_VALUE))
155: .addContainerGap())
156: .add(
157: sequencePanel,
158: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
159: 221, Short.MAX_VALUE));
160: layout
161: .setVerticalGroup(layout
162: .createParallelGroup(
163: org.jdesktop.layout.GroupLayout.LEADING)
164: .add(
165: org.jdesktop.layout.GroupLayout.LEADING,
166: layout
167: .createSequentialGroup()
168: .addContainerGap()
169: .add(
170: layout
171: .createParallelGroup(
172: org.jdesktop.layout.GroupLayout.BASELINE)
173: .add(
174: labelSprite)
175: .add(
176: textFieldSprite,
177: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
178: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
179: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
180: .addPreferredGap(
181: org.jdesktop.layout.LayoutStyle.RELATED)
182: .add(
183: comboBoxSequence,
184: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE,
185: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
186: org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
187: .addPreferredGap(
188: org.jdesktop.layout.LayoutStyle.RELATED)
189: .add(
190: sequencePanel,
191: org.jdesktop.layout.GroupLayout.DEFAULT_SIZE,
192: 237, Short.MAX_VALUE)));
193: }// </editor-fold>//GEN-END:initComponents
194:
195: // Variables declaration - do not modify//GEN-BEGIN:variables
196: public javax.swing.JComboBox comboBoxSequence;
197: public javax.swing.JLabel labelSprite;
198: private javax.swing.JPanel sequencePanel;
199: public javax.swing.JTextField textFieldSprite;
200: // End of variables declaration//GEN-END:variables
201:
202: }
|