com.codename1.designer.GenerateNetBeansProjectDialog Maven / Gradle / Ivy
The newest version!
/*
* Copyright (c) 2012, Codename One and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Codename One designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Codename One through http://www.codenameone.com/ if you
* need additional information or have any questions.
*/
package com.codename1.designer;
import com.codename1.ui.util.EditableResources;
import java.io.File;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JFrame;
import javax.swing.SwingUtilities;
/**
*
* @author Shai Almog
*/
public class GenerateNetBeansProjectDialog extends javax.swing.JDialog {
private boolean canceled = true;
/** Creates new form GenerateNetBeansProjectDialog */
public GenerateNetBeansProjectDialog(java.awt.Component c, EditableResources res) {
super((JFrame)SwingUtilities.windowForComponent(c), true);
initComponents();
initialForm.setModel(new DefaultComboBoxModel(res.getUIResourceNames()));
initialForm.setSelectedIndex(0);
destinationDirectory.setText(System.getProperty("user.home"));
setLocationByPlatform(true);
pack();
setVisible(true);
}
public boolean canceled() {
return canceled;
}
public String getProjectName() {
return projectName.getText();
}
public String getPackageName() {
return mainPackageName.getText();
}
public String getMainClassName() {
return mainClassName.getText();
}
public String getInitialForm() {
return (String)initialForm.getSelectedItem();
}
public String getDestinationDirectory() {
return destinationDirectory.getText();
}
/** 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")
// //GEN-BEGIN:initComponents
private void initComponents() {
jLabel1 = new javax.swing.JLabel();
projectName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
mainClassName = new javax.swing.JTextField();
mainPackageName = new javax.swing.JTextField();
destinationDirectory = new javax.swing.JTextField();
initialForm = new javax.swing.JComboBox();
directoryPicker = new javax.swing.JButton();
jPanel1 = new javax.swing.JPanel();
jPanel2 = new javax.swing.JPanel();
okButton = new javax.swing.JButton();
cancelButton = new javax.swing.JButton();
FormListener formListener = new FormListener();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("Generate NetBeans Project");
jLabel1.setText("Project Name");
jLabel1.setName("jLabel1"); // NOI18N
projectName.setText("NewProject");
projectName.setName("projectName"); // NOI18N
jLabel2.setText("Main Class Name");
jLabel2.setName("jLabel2"); // NOI18N
jLabel3.setText("Package Name");
jLabel3.setName("jLabel3"); // NOI18N
jLabel4.setText("Initial Form");
jLabel4.setName("jLabel4"); // NOI18N
jLabel5.setText("Destination Directory");
jLabel5.setName("jLabel5"); // NOI18N
mainClassName.setText("Main");
mainClassName.setName("mainClassName"); // NOI18N
mainPackageName.setText("com.mycompany.myapp");
mainPackageName.setName("mainPackageName"); // NOI18N
destinationDirectory.setName("destinationDirectory"); // NOI18N
initialForm.setName("initialForm"); // NOI18N
directoryPicker.setText("...");
directoryPicker.setName("directoryPicker"); // NOI18N
directoryPicker.addActionListener(formListener);
jPanel1.setName("jPanel1"); // NOI18N
jPanel2.setName("jPanel2"); // NOI18N
jPanel2.setLayout(new java.awt.GridLayout(1, 2, 20, 0));
okButton.setText("OK");
okButton.setName("okButton"); // NOI18N
okButton.addActionListener(formListener);
jPanel2.add(okButton);
cancelButton.setText("Cancel");
cancelButton.setName("cancelButton"); // NOI18N
cancelButton.addActionListener(formListener);
jPanel2.add(cancelButton);
jPanel1.add(jPanel2);
org.jdesktop.layout.GroupLayout layout = new org.jdesktop.layout.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(org.jdesktop.layout.GroupLayout.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.TRAILING)
.add(jPanel1, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 498, Short.MAX_VALUE)
.add(layout.createSequentialGroup()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(jLabel5)
.add(jLabel4)
.add(jLabel2)
.add(jLabel3)
.add(jLabel1))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(projectName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
.add(mainClassName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
.add(mainPackageName, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE)
.add(initialForm, 0, 269, Short.MAX_VALUE)
.add(destinationDirectory, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, 269, Short.MAX_VALUE))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED)
.add(directoryPicker)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(org.jdesktop.layout.GroupLayout.LEADING)
.add(layout.createSequentialGroup()
.addContainerGap()
.add(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel1)
.add(projectName, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel2)
.add(mainClassName, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel3)
.add(mainPackageName, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel4)
.add(initialForm, 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(layout.createParallelGroup(org.jdesktop.layout.GroupLayout.BASELINE)
.add(jLabel5)
.add(destinationDirectory, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE)
.add(directoryPicker))
.addPreferredGap(org.jdesktop.layout.LayoutStyle.RELATED, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.add(jPanel1, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE, org.jdesktop.layout.GroupLayout.DEFAULT_SIZE, org.jdesktop.layout.GroupLayout.PREFERRED_SIZE))
);
pack();
}
// Code for dispatching events from components to event handlers.
private class FormListener implements java.awt.event.ActionListener {
FormListener() {}
public void actionPerformed(java.awt.event.ActionEvent evt) {
if (evt.getSource() == directoryPicker) {
GenerateNetBeansProjectDialog.this.directoryPickerActionPerformed(evt);
}
else if (evt.getSource() == okButton) {
GenerateNetBeansProjectDialog.this.okButtonActionPerformed(evt);
}
else if (evt.getSource() == cancelButton) {
GenerateNetBeansProjectDialog.this.cancelButtonActionPerformed(evt);
}
}
}// //GEN-END:initComponents
private void directoryPickerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_directoryPickerActionPerformed
File[] f = ResourceEditorView.showSaveDirFileChooser();
if(f != null && f.length > 0) {
destinationDirectory.setText(f[0].getAbsolutePath());
}
}//GEN-LAST:event_directoryPickerActionPerformed
private void okButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed
canceled = false;
dispose();
}//GEN-LAST:event_okButtonActionPerformed
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
canceled = true;
dispose();
}//GEN-LAST:event_cancelButtonActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton cancelButton;
private javax.swing.JTextField destinationDirectory;
private javax.swing.JButton directoryPicker;
private javax.swing.JComboBox initialForm;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JPanel jPanel1;
private javax.swing.JPanel jPanel2;
private javax.swing.JTextField mainClassName;
private javax.swing.JTextField mainPackageName;
private javax.swing.JButton okButton;
private javax.swing.JTextField projectName;
// End of variables declaration//GEN-END:variables
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy