com.gluonhq.plugin.netbeans.template.visuals.GluonViewPanelVisual Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of com-gluonhq-plugin-netbeans
Show all versions of com-gluonhq-plugin-netbeans
Gluon Plugin allows developers to create Java applications and their native images targeting Android, iOS, Linux, MacOS and Windows platforms using the same codebase.
/*
* 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.template.visuals;
import com.gluonhq.plugin.templates.ProjectConstants;
import com.gluonhq.plugin.templates.TemplateUtils;
import java.util.Locale;
import org.openide.WizardDescriptor;
public class GluonViewPanelVisual extends GluonBasePanelVisual {
private final boolean useFXML;
public GluonViewPanelVisual(GluonViewWizardPanel panel, boolean useFXML, boolean useGAf) {
initComponents();
this.panel = panel;
this.useFXML = useFXML;
// Register listener on the textFields to make the automatic updates
primaryViewNameTextField.getDocument().addDocumentListener(this);
secondaryViewNameTextField.getDocument().addDocumentListener(this);
cssProjectCheckbox.addChangeListener(this);
this.afterburnerCheckbox.setVisible(useFXML && !useGAf);
this.fxmlLabel.setVisible(useFXML && !useGAf);
this.cssPrimaryViewCheckbox.setEnabled(!useGAf);
this.cssSecondaryViewCheckbox.setEnabled(!useGAf);
}
public String getPrimaryViewName() {
return this.primaryViewNameTextField.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.
*/
// //GEN-BEGIN:initComponents
private void initComponents() {
primaryViewNameLabel = new javax.swing.JLabel();
primaryViewNameTextField = new javax.swing.JTextField();
secondaryViewNameLabel = new javax.swing.JLabel();
secondaryViewNameTextField = new javax.swing.JTextField();
cssFilesLabel = new javax.swing.JLabel();
cssProjectCheckbox = new javax.swing.JCheckBox();
cssPrimaryViewCheckbox = new javax.swing.JCheckBox();
cssSecondaryViewCheckbox = new javax.swing.JCheckBox();
afterburnerCheckbox = new javax.swing.JCheckBox();
fxmlLabel = new javax.swing.JLabel();
primaryViewNameLabel.setLabelFor(primaryViewNameTextField);
org.openide.awt.Mnemonics.setLocalizedText(primaryViewNameLabel, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.primaryViewNameLabel.text")); // NOI18N
secondaryViewNameLabel.setLabelFor(secondaryViewNameTextField);
org.openide.awt.Mnemonics.setLocalizedText(secondaryViewNameLabel, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.secondaryViewNameLabel.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(cssFilesLabel, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.cssFilesLabel.text")); // NOI18N
cssProjectCheckbox.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(cssProjectCheckbox, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.cssProjectCheckbox.text")); // NOI18N
cssPrimaryViewCheckbox.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(cssPrimaryViewCheckbox, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.cssPrimaryViewCheckbox.text")); // NOI18N
cssSecondaryViewCheckbox.setSelected(true);
org.openide.awt.Mnemonics.setLocalizedText(cssSecondaryViewCheckbox, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.cssSecondaryViewCheckbox.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(afterburnerCheckbox, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.afterburnerCheckbox.text")); // NOI18N
org.openide.awt.Mnemonics.setLocalizedText(fxmlLabel, org.openide.util.NbBundle.getMessage(GluonViewPanelVisual.class, "GluonViewPanelVisual.fxmlLabel.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)
.addComponent(primaryViewNameLabel)
.addComponent(secondaryViewNameLabel)
.addComponent(cssFilesLabel)
.addComponent(fxmlLabel))
.addGap(28, 28, 28)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(afterburnerCheckbox)
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(primaryViewNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE)
.addComponent(secondaryViewNameTextField, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 141, Short.MAX_VALUE))
.addGap(112, 112, 112))
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cssSecondaryViewCheckbox)
.addComponent(cssPrimaryViewCheckbox)
.addComponent(cssProjectCheckbox))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(primaryViewNameLabel)
.addComponent(primaryViewNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(secondaryViewNameLabel)
.addComponent(secondaryViewNameTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cssFilesLabel)
.addComponent(cssProjectCheckbox))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cssPrimaryViewCheckbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cssSecondaryViewCheckbox)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(afterburnerCheckbox)
.addComponent(fxmlLabel))
.addContainerGap(147, Short.MAX_VALUE))
);
}// //GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JCheckBox afterburnerCheckbox;
private javax.swing.JLabel cssFilesLabel;
private javax.swing.JCheckBox cssPrimaryViewCheckbox;
private javax.swing.JCheckBox cssProjectCheckbox;
private javax.swing.JCheckBox cssSecondaryViewCheckbox;
private javax.swing.JLabel fxmlLabel;
private javax.swing.JLabel primaryViewNameLabel;
private javax.swing.JTextField primaryViewNameTextField;
private javax.swing.JLabel secondaryViewNameLabel;
private javax.swing.JTextField secondaryViewNameTextField;
// End of variables declaration//GEN-END:variables
@Override
public void addNotify() {
super.addNotify();
//same problem as in 31086, initial focus on Cancel button
primaryViewNameTextField.requestFocus();
}
@Override
protected boolean valid(WizardDescriptor wizardDescriptor) {
if (!TemplateUtils.isValidNameView(primaryViewNameTextField.getText().trim())) {
// TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_ERROR_MESSAGE:
wizardDescriptor.putProperty("WizardPanel_errorMessage",
primaryViewNameTextField.getText().trim() + " is not a valid view name for Primary View Name");
return false; // Display name not specified
}
if (!TemplateUtils.isValidNameView(secondaryViewNameTextField.getText().trim())) {
// TODO if using org.openide.dialogs >= 7.8, can use WizardDescriptor.PROP_ERROR_MESSAGE:
wizardDescriptor.putProperty("WizardPanel_errorMessage",
secondaryViewNameTextField.getText().trim() + " is not a valid view name for Secondary View Name.");
return false; // Display name not specified
}
wizardDescriptor.putProperty("WizardPanel_errorMessage", "");
return true;
}
@Override
protected void store(WizardDescriptor d) {
final String primary = TemplateUtils.getCorrectNameView(primaryViewNameTextField.getText().trim(), "Primary");
d.putProperty(ProjectConstants.PARAM_PRIMARY_VIEW, TemplateUtils.upperCaseWord(primary));
d.putProperty(ProjectConstants.PARAM_PRIMARY_CSS, primary.toLowerCase(Locale.ROOT));
final String secondary = TemplateUtils.getCorrectNameView(secondaryViewNameTextField.getText().trim(), "Secondary");
d.putProperty(ProjectConstants.PARAM_SECONDARY_VIEW, TemplateUtils.upperCaseWord(secondary));
d.putProperty(ProjectConstants.PARAM_SECONDARY_CSS, secondary.toLowerCase(Locale.ROOT));
d.putProperty(ProjectConstants.PARAM_PROJECT_CSS_ENABLED, cssProjectCheckbox.isSelected());
d.putProperty(ProjectConstants.PARAM_PRIMARY_CSS_ENABLED, cssPrimaryViewCheckbox.isSelected());
d.putProperty(ProjectConstants.PARAM_SECONDARY_CSS_ENABLED, cssSecondaryViewCheckbox.isSelected());
if (useFXML) {
d.putProperty(ProjectConstants.PARAM_AFTERBURNER_ENABLED, afterburnerCheckbox.isSelected());
}
}
@Override
protected void read(WizardDescriptor settings) {
String primaryViewName = (String) settings.getProperty(ProjectConstants.PARAM_PRIMARY_VIEW);
if (primaryViewName == null) {
primaryViewName = "Primary";
}
this.primaryViewNameTextField.setText(primaryViewName);
this.primaryViewNameTextField.selectAll();
String secondaryViewName = (String) settings.getProperty(ProjectConstants.PARAM_SECONDARY_VIEW);
if (secondaryViewName == null) {
secondaryViewName = "Secondary";
}
this.secondaryViewNameTextField.setText(secondaryViewName);
Boolean cssProjectEnabled = (Boolean) settings.getProperty(ProjectConstants.PARAM_PROJECT_CSS_ENABLED);
if (cssProjectEnabled == null) {
cssProjectEnabled = true;
}
this.cssProjectCheckbox.setSelected(cssProjectEnabled);
Boolean cssPrimaryViewEnabled = (Boolean) settings.getProperty(ProjectConstants.PARAM_PRIMARY_CSS_ENABLED);
if (cssPrimaryViewEnabled == null) {
cssPrimaryViewEnabled = true;
}
this.cssPrimaryViewCheckbox.setSelected(cssPrimaryViewEnabled);
Boolean cssSecondaryViewEnabled = (Boolean) settings.getProperty(ProjectConstants.PARAM_SECONDARY_CSS_ENABLED);
if (cssSecondaryViewEnabled == null) {
cssSecondaryViewEnabled = true;
}
this.cssSecondaryViewCheckbox.setSelected(cssSecondaryViewEnabled);
if (useFXML) {
Boolean afterburnerEnabled = (Boolean) settings.getProperty(ProjectConstants.PARAM_AFTERBURNER_ENABLED);
if (afterburnerEnabled == null) {
afterburnerEnabled = false;
}
this.afterburnerCheckbox.setSelected(afterburnerEnabled);
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy