Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2018, Gluon Software
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* * Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
*
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* * Neither the name of the copyright holder nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package com.gluonhq.plugin.netbeans.options;
import com.gluonhq.plugin.netbeans.template.OptInHelper;
import com.gluonhq.plugin.templates.ProjectConstants;
import com.gluonhq.plugin.templates.TemplateUtils;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;
import java.util.prefs.Preferences;
final class GluonPanel extends JPanel {
private final static Preferences PREFERENCES = Preferences.userRoot().node("com.gluonhq.plugin.netbeans");
private final GluonOptionsPanelController controller;
private final DocumentListener docListener = new DocumentListener() {
@Override
public void insertUpdate(DocumentEvent e) {
errorLabel.setVisible(!valid());
controller.changed();
}
@Override
public void removeUpdate(DocumentEvent e) {
errorLabel.setVisible(!valid());
controller.changed();
}
@Override
public void changedUpdate(DocumentEvent e) {
errorLabel.setVisible(!valid());
controller.changed();
}
};
GluonPanel(final GluonOptionsPanelController controller) {
this.controller = controller;
initComponents();
errorLabel.setVisible(false);
jTextEmailAddress.getDocument().addDocumentListener(docListener);
jTextMobileLicense.getDocument().addDocumentListener(docListener);
jTextDesktopLicense.getDocument().addDocumentListener(docListener);
jCheckUpToDate.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
controller.changed();
}
});
}
/**
* 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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new JPanel();
jLabel1 = new javax.swing.JLabel();
jTextEmailAddress = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jCheckUpToDate = new javax.swing.JCheckBox();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
errorLabel = new javax.swing.JLabel();
jTextMobileLicense = new javax.swing.JTextField();
jTextDesktopLicense = new javax.swing.JTextField();
setBorder(javax.swing.BorderFactory.createTitledBorder(org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.border.title"))); // NOI18N
setLayout(new java.awt.BorderLayout());
org.openide.awt.Mnemonics.setLocalizedText(jLabel1, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jLabel1.text")); // NOI18N
jTextEmailAddress.setText(org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jTextEmailAddress.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel2, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jLabel2.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jCheckUpToDate, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jCheckUpToDate.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel3, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jLabel3.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(jLabel4, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jLabel4.text")); // NOI18N
errorLabel.setForeground(new java.awt.Color(255, 0, 0));
org.openide.awt.Mnemonics.setLocalizedText(errorLabel, org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.errorLabel.text")); // NOI18N
jTextMobileLicense.setText(org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jTextMobileLicense.text")); // NOI18N
jTextDesktopLicense.setText(org.openide.util.NbBundle.getMessage(GluonPanel.class, "GluonPanel.jTextDesktopLicense.text")); // NOI18N
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(34, 34, 34)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(errorLabel)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel2)
.addComponent(jLabel3)
.addComponent(jLabel4))
.addGap(55, 55, 55)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jCheckUpToDate)
.addComponent(jTextEmailAddress, javax.swing.GroupLayout.DEFAULT_SIZE, 320, Short.MAX_VALUE)
.addComponent(jTextMobileLicense)
.addComponent(jTextDesktopLicense))))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.addGap(19, 19, 19)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(jTextEmailAddress, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel2)
.addComponent(jCheckUpToDate))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel3)
.addComponent(jTextMobileLicense, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel4)
.addComponent(jTextDesktopLicense, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 30, Short.MAX_VALUE)
.addComponent(errorLabel)
.addGap(29, 29, 29))
);
add(jPanel1, java.awt.BorderLayout.CENTER);
}// //GEN-END:initComponents
void load() {
// read settings and initialize GUI
jTextEmailAddress.setText(PREFERENCES.get(ProjectConstants.PARAM_USER_EMAIL, ""));
jCheckUpToDate.setSelected(PREFERENCES.getBoolean(ProjectConstants.PARAM_USER_UPTODATE, true));
jTextMobileLicense.setText(PREFERENCES.get(ProjectConstants.PARAM_USER_LICENSE_MOBILE, ""));
jTextDesktopLicense.setText(PREFERENCES.get(ProjectConstants.PARAM_USER_LICENSE_DESKTOP, ""));
}
void store() {
boolean changed = false;
if (!jTextEmailAddress.getText().equals(PREFERENCES.get(ProjectConstants.PARAM_USER_EMAIL, "")) ||
jCheckUpToDate.isSelected() != PREFERENCES.getBoolean(ProjectConstants.PARAM_USER_UPTODATE, true) ||
!jTextMobileLicense.getText().equals(PREFERENCES.get(ProjectConstants.PARAM_USER_LICENSE_MOBILE, "")) ||
!jTextDesktopLicense.getText().equals(PREFERENCES.get(ProjectConstants.PARAM_USER_LICENSE_DESKTOP, "")) ||
PREFERENCES.get(ProjectConstants.PARAM_USER_MAC_ADDRESS, "").isEmpty() ||
PREFERENCES.get(ProjectConstants.PARAM_USER_PLUGIN_VERSION, "").isEmpty()) {
changed = true;
}
// store modified settings
OptInHelper.persistOptIn(jTextEmailAddress.getText(), jCheckUpToDate.isSelected(),
jTextMobileLicense.getText(), jTextDesktopLicense.getText());
if (changed) {
// send modified settings
com.gluonhq.plugin.templates.OptInHelper.optIn(jTextEmailAddress.getText(),
jCheckUpToDate.isSelected(), "pluginnetbeans",
PREFERENCES.get(ProjectConstants.PARAM_USER_MAC_ADDRESS, ""),
PREFERENCES.get(ProjectConstants.PARAM_USER_PLUGIN_VERSION, ProjectConstants.PLUGIN_VERSION),
true);
}
}
boolean valid() {
return TemplateUtils.isValidEmail(jTextEmailAddress.getText());
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JLabel errorLabel;
private javax.swing.JCheckBox jCheckUpToDate;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private JPanel jPanel1;
private javax.swing.JTextField jTextDesktopLicense;
private javax.swing.JTextField jTextEmailAddress;
private javax.swing.JTextField jTextMobileLicense;
// End of variables declaration//GEN-END:variables
}