| /* |
| * Licensed to the Apache Software Foundation (ASF) under one |
| * or more contributor license agreements. See the NOTICE file |
| * distributed with this work for additional information |
| * regarding copyright ownership. The ASF licenses this file |
| * to you under the Apache License, Version 2.0 (the |
| * "License"); you may not use this file except in compliance |
| * with the License. You may obtain a copy of the License at |
| * |
| * http://www.apache.org/licenses/LICENSE-2.0 |
| * |
| * Unless required by applicable law or agreed to in writing, |
| * software distributed under the License is distributed on an |
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| * KIND, either express or implied. See the License for the |
| * specific language governing permissions and limitations |
| * under the License. |
| */ |
| |
| /* |
| * RestApplicationsPanel.java |
| * |
| * Created on 23-Oct-2009, 16:20:37 |
| */ |
| |
| package org.netbeans.modules.websvc.rest.projects; |
| |
| import java.awt.Component; |
| import java.awt.event.ItemEvent; |
| import java.awt.event.ItemListener; |
| import java.util.List; |
| import javax.swing.DefaultComboBoxModel; |
| import javax.swing.JLabel; |
| import javax.swing.JList; |
| import javax.swing.ListCellRenderer; |
| import org.netbeans.modules.websvc.rest.model.api.RestApplication; |
| |
| /** |
| * |
| * @author mkuchtiak |
| */ |
| public class RestApplicationsPanel extends javax.swing.JPanel { |
| |
| /** Creates new form RestApplicationsPanel */ |
| public RestApplicationsPanel(List<RestApplication> restApplications) { |
| initComponents(); |
| DefaultComboBoxModel cbModel = new DefaultComboBoxModel(restApplications.toArray()); |
| jComboBox1.setModel(cbModel); |
| jComboBox1.setRenderer(new ApplicationPathRenderer()); |
| jLabel3.setText(((RestApplication)jComboBox1.getItemAt(0)).getApplicationClass()); |
| |
| jComboBox1.addItemListener(new ItemListener() { |
| |
| public void itemStateChanged(ItemEvent e) { |
| RestApplication appl = (RestApplication)e.getItem(); |
| jLabel3.setText(appl.getApplicationClass()); |
| } |
| |
| }); |
| } |
| |
| public String getApplicationPath() { |
| return ((RestApplication)jComboBox1.getSelectedItem()).getApplicationPath(); |
| } |
| |
| /** 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() { |
| |
| jComboBox1 = new javax.swing.JComboBox(); |
| jLabel1 = new javax.swing.JLabel(); |
| jLabel2 = new javax.swing.JLabel(); |
| jLabel3 = new javax.swing.JLabel(); |
| |
| setOpaque(false); |
| |
| jLabel1.setLabelFor(jComboBox1); |
| org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(RestApplicationsPanel.class, "RestApplicationsPanel.jLabel1.text")); // NOI18N |
| |
| jLabel2.setLabelFor(jLabel3); |
| org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(RestApplicationsPanel.class, "RestApplicationsPanel.jLabel2.text")); // NOI18N |
| |
| javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); |
| this.setLayout(layout); |
| layout.setHorizontalGroup( |
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addGroup(layout.createSequentialGroup() |
| .addContainerGap() |
| .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) |
| .addComponent(jLabel2, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) |
| .addComponent(jLabel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 179, javax.swing.GroupLayout.PREFERRED_SIZE)) |
| .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) |
| .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addComponent(jComboBox1, 0, 285, Short.MAX_VALUE) |
| .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 285, Short.MAX_VALUE)) |
| .addContainerGap()) |
| ); |
| layout.setVerticalGroup( |
| layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addGroup(layout.createSequentialGroup() |
| .addContainerGap() |
| .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) |
| .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) |
| .addComponent(jLabel1)) |
| .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) |
| .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) |
| .addComponent(jLabel2) |
| .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 17, javax.swing.GroupLayout.PREFERRED_SIZE)) |
| .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) |
| ); |
| |
| getAccessibleContext().setAccessibleName(org.openide.util.NbBundle.getMessage(RestApplicationsPanel.class, "TTL_RestResourcesPath")); // NOI18N |
| getAccessibleContext().setAccessibleDescription(org.openide.util.NbBundle.getMessage(RestApplicationsPanel.class, "DESC_RestResourcesPath")); // NOI18N |
| }// </editor-fold>//GEN-END:initComponents |
| |
| |
| // Variables declaration - do not modify//GEN-BEGIN:variables |
| private javax.swing.JComboBox jComboBox1; |
| private javax.swing.JLabel jLabel1; |
| private javax.swing.JLabel jLabel2; |
| private javax.swing.JLabel jLabel3; |
| // End of variables declaration//GEN-END:variables |
| |
| private static class ApplicationPathRenderer extends JLabel implements ListCellRenderer { |
| |
| public Component getListCellRendererComponent( |
| JList list, |
| Object value, |
| int index, |
| boolean isSelected, |
| boolean cellHasFocus) |
| { |
| setText(((RestApplication)value).getApplicationPath()); |
| return this; |
| } |
| } |
| } |