/*
* The contents of this file are subject to the terms of the Common Development
* and Distribution License (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.html
* or http://www.netbeans.org/cddl.txt.
*
* When distributing Covered Code, include this CDDL Header Notice in each file
* and include the License file at http://www.netbeans.org/cddl.txt.
* If applicable, add the following below the CDDL Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* The Original Software is NetBeans. The Initial Developer of the Original
* Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
* Microsystems, Inc. All Rights Reserved.
*/
package org.netbeans.modules.gwt4nb;
import javax.swing.SwingUtilities;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
/**
* New module.
*
* @author Tomasz.Slota@Sun.COM
* @author see https://github.com/gwt4nb/gwt4nb/
*/
public class NewModulePanelVisual extends javax.swing.JPanel {
public static final long serialVersionUID = 1;
private NewModulePanel controller;
/**
* @param controller controller for this panel
*/
public NewModulePanelVisual(NewModulePanel controller) {
this.controller = controller;
initComponents();
txtModuleName.getDocument().addDocumentListener(new ChangeListener());
SwingUtilities.invokeLater(new Runnable(){ // Avoid endless loop
public void run() {
update();
}
});
}
/**
* Returns the name of the module
*
* @return module name like "org.yournamehere.Main"
*/
public String getModuleName(){
return txtModuleName.getText();
}
/**
* @return true if the client package should be created
*/
public boolean getCreateClientPackage() {
return jCheckBoxClient.isSelected();
}
/**
* @return true if the server package should be created
*/
public boolean getCreateServerPackage() {
return jCheckBoxServer.isSelected();
}
/**
* @return true if the public package should be created
*/
public boolean getCreatePublicPackage() {
return jCheckBoxPublic.isSelected();
}
private void update(){
controller.fireChangeEvent();
}
/** 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.
*/
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblServiceName = new javax.swing.JLabel();
txtModuleName = new javax.swing.JTextField();
jCheckBoxClient = new javax.swing.JCheckBox();
jCheckBoxServer = new javax.swing.JCheckBox();
jCheckBoxPublic = new javax.swing.JCheckBox();
setName(org.openide.util.NbBundle.getMessage(NewModulePanelVisual.class, "panelNameConstants")); // NOI18N
lblServiceName.setLabelFor(txtModuleName);
lblServiceName.setText(org.openide.util.NbBundle.getMessage(NewModulePanelVisual.class, "NewModulePanelVisual.lblServiceName.text")); // NOI18N
txtModuleName.setText("org.yournamehere.Main"); // NOI18N
jCheckBoxClient.setSelected(true);
jCheckBoxClient.setText(org.openide.util.NbBundle.getMessage(NewModulePanelVisual.class, "NewModulePanelVisual.jCheckBoxClient.text")); // NOI18N
jCheckBoxClient.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxClientActionPerformed(evt);
}
});
jCheckBoxServer.setSelected(true);
jCheckBoxServer.setText(org.openide.util.NbBundle.getMessage(NewModulePanelVisual.class, "NewModulePanelVisual.jCheckBoxServer.text")); // NOI18N
jCheckBoxServer.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxServerActionPerformed(evt);
}
});
jCheckBoxPublic.setText(org.openide.util.NbBundle.getMessage(NewModulePanelVisual.class, "NewModulePanelVisual.jCheckBoxPublic.text")); // NOI18N
jCheckBoxPublic.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jCheckBoxPublicActionPerformed(evt);
}
});
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(lblServiceName)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.UNRELATED)
.add(txtModuleName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE))
.add(layout.createSequentialGroup()
.add(jCheckBoxClient)
.addContainerGap())
.add(layout.createSequentialGroup()
.add(jCheckBoxServer)
.addContainerGap())
.add(layout.createSequentialGroup()
.add(jCheckBoxPublic)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(lblServiceName)
.add(txtModuleName, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBoxClient)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBoxServer)
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(jCheckBoxPublic)
.addContainerGap(178, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
private void jCheckBoxClientActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxClientActionPerformed
update();
}//GEN-LAST:event_jCheckBoxClientActionPerformed
private void jCheckBoxServerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxServerActionPerformed
update();
}//GEN-LAST:event_jCheckBoxServerActionPerformed
private void jCheckBoxPublicActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jCheckBoxPublicActionPerformed
update();
}//GEN-LAST:event_jCheckBoxPublicActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox jCheckBoxClient;
private javax.swing.JCheckBox jCheckBoxPublic;
private javax.swing.JCheckBox jCheckBoxServer;
private javax.swing.JLabel lblServiceName;
private javax.swing.JTextField txtModuleName;
// End of variables declaration//GEN-END:variables
private class ChangeListener implements DocumentListener{
public void insertUpdate(DocumentEvent arg0) {
update();
}
public void removeUpdate(DocumentEvent arg0) {
update();
}
public void changedUpdate(DocumentEvent arg0) {
update();
}
}
}