Package org.netbeans.modules.php.nette.wizards

Source Code of org.netbeans.modules.php.nette.wizards.NewNetteProjectPanel

/*
* The MIT license
*
* Copyright (c) 2010 Radek Ježdík <redhead@email.cz>, Ondřej Brejla <ondrej@brejla.cz>
*
* Permission is hereby granted, free of charge, to any person
* obtaining a copy of this software and associated documentation
* files (the "Software"), to deal in the Software without
* restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following
* conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*/

/*
* NewNetteProjectPanel.java
*
* Created on 23.8.2010, 21:39:50
*/

package org.netbeans.modules.php.nette.wizards;

import javax.swing.event.ChangeListener;
import org.netbeans.api.options.OptionsDisplayer;
import org.netbeans.modules.php.nette.options.NetteOptions;
import org.netbeans.modules.php.nette.validators.NetteEmptyPathValidator;
import org.netbeans.modules.php.nette.validators.NetteLoaderExistsValidator;
import org.netbeans.modules.php.nette.validators.Validable;
import org.openide.util.ChangeSupport;
import org.openide.util.NbBundle;

/**
*
* @author Ondřej Brejla
*/
public class NewNetteProjectPanel extends javax.swing.JPanel {

  private ChangeSupport changeSupport = new ChangeSupport(this);

    /** Creates new form NewNetteProjectPanel */
    public NewNetteProjectPanel() {
        initComponents();
    }

    /** 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() {

        copyNetteCheckbox = new javax.swing.JCheckBox();
        optionsLabel = new javax.swing.JLabel();

        copyNetteCheckbox.setText(org.openide.util.NbBundle.getMessage(NewNetteProjectPanel.class, "NewNetteProjectPanel.copyNetteCheckbox.text")); // NOI18N
        copyNetteCheckbox.addChangeListener(new javax.swing.event.ChangeListener() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                copyNetteCheckboxStateChanged(evt);
            }
        });

        optionsLabel.setForeground(java.awt.Color.blue);
        optionsLabel.setText(org.openide.util.NbBundle.getMessage(NewNetteProjectPanel.class, "NewNetteProjectPanel.optionsLabel.text")); // NOI18N
        optionsLabel.setCursor(new java.awt.Cursor(java.awt.Cursor.HAND_CURSOR));
        optionsLabel.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                optionsLabelMouseReleased(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(copyNetteCheckbox)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 97, Short.MAX_VALUE)
                .addComponent(optionsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(optionsLabel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addContainerGap()
                        .addComponent(copyNetteCheckbox)))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

  private void copyNetteCheckboxStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_copyNetteCheckboxStateChanged
    changeSupport.fireChange();
  }//GEN-LAST:event_copyNetteCheckboxStateChanged

  private void optionsLabelMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_optionsLabelMouseReleased
    OptionsDisplayer.getDefault().open(NetteOptions.getInstance().getOptionsPath());
  }//GEN-LAST:event_optionsLabelMouseReleased


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JCheckBox copyNetteCheckbox;
    private javax.swing.JLabel optionsLabel;
    // End of variables declaration//GEN-END:variables

  public void addChangeListener(ChangeListener cl) {
    changeSupport.addChangeListener(cl);
  }

  public void removeChangeListener(ChangeListener cl) {
    changeSupport.removeChangeListener(cl);
  }

  public String getErrorMessage() {
    if (copyNetteCheckbox.isSelected()) {
      Validable emptyPathValidator = new NetteEmptyPathValidator();

      if (emptyPathValidator.validate(NetteOptions.getInstance().getNetteFile())) {
        return NbBundle.getMessage(NewNetteProjectPanel.class, "ERR_no_nette_file");
      }

      Validable loaderPathValidator = new NetteLoaderExistsValidator();

      if (!loaderPathValidator.validate(NetteOptions.getInstance().getNetteFile())) {
        return NbBundle.getMessage(NewNetteProjectPanel.class, "ERR_nette_file_not_exists");
      }
    }

    return null;
  }

  public boolean isCopyNetteCheckboxSelected() {
    return copyNetteCheckbox.isSelected();
  }

}
TOP

Related Classes of org.netbeans.modules.php.nette.wizards.NewNetteProjectPanel

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.