Please wait. This can take some minutes ...
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.
jaxx.demo.component.swing.JCheckBoxDemo Maven / Gradle / Ivy
package jaxx.demo.component.swing;
/*-
* #%L
* JAXX :: Demo
* %%
* Copyright (C) 2008 - 2016 CodeLutin
* %%
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program 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 Lesser Public License for more details.
*
* You should have received a copy of the GNU General Lesser Public
* License along with this program. If not, see
* .
* #L%
*/
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.Insets;
import java.awt.LayoutManager;
import javax.swing.ButtonModel;
import javax.swing.JCheckBox;
import javax.swing.JLabel;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import jaxx.demo.DemoPanel;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObjectDescriptor;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.binding.DefaultJAXXBinding;
import jaxx.runtime.swing.Table;
import jaxx.runtime.swing.VBox;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import static org.nuiton.i18n.I18n.t;
public class JCheckBoxDemo extends DemoPanel {
/*-----------------------------------------------------------------------*/
/*--------------- Constants for all none public bindings ---------------*/
/*-----------------------------------------------------------------------*/
private static final String BINDING_$JLABEL0_TEXT = "$JLabel0.text";
/*-----------------------------------------------------------------------*/
/*------------------------- Other static fields -------------------------*/
/*-----------------------------------------------------------------------*/
private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAKVTy27TQBS9CXk0fVDa0NKqRWohCBCSw4INatUHrSqowkMUoYpsGNtDM8UZD+Nxa1ggPoFPgD0bJHasEAvWLNggfgEhFmwRdyaJkxS3jRQvxva955459/XuJ2QDCfO7JIosGXLF6tTaXN3evmvvUket08CRTChfQuNJpSFdhSE3tgcKzlcrOrzcDC+v+XXhc8o7ohcqMBio5x4NapQqBWe7I5wgKG/F7oVIhLLFGotKYn3z+1f6tfvqbRogEqguj6nMHRfVziRTgTRzFYzjTXuk7BG+gzIk4zuod0Tb1jwSBHdInT6Dl5CvQE4QiWQKzvWesuEw8ZFQMFRap3X/HuHUu6rgohHrosVyWhRWsI8KrM21GnWe3vAjjRfCMOQU5EoP0YahZ7rybMRol8YVYni+9IDYHkX8VALe+DRyOA7I2L6HJZnQ2UcHpWjMaAwdKG1WiG3yGO+CG2s3NscU8Zij/053ewohd6n0GKedTgkzXXpxQqz2hLRbmKpCVoZoxgSr/w/VfXQ1xmnqwDhpQuP9O1n89vHHh43WDA3i3ROJ0I4VwN4K6QsqFdNXjzYGKFTMK98mYqEKhYB6uD9mP2YThG013SgO7xvT4ZYOt26SoIYU2fz3T58nH389AekNGPR84m4Qjb8FBVWTWAXsUiSWV4yi4f0BPE9pbQqKNV+yFz7Heq96bIfXzbyOLzKuazxHFA64HSq6FGFVZhOqEkuzC1/+FLfer7Qqk0Kl04fC29XJPsJ2m9vMfjVXJ3GfhkRAQ9dvr0jS0qT0e0Q0d2DenBeSUh/b0w1xOhLX0EtRqF+XTQb660rPhBlFo6M4ij1wDNQ5LjBvzH4fPJknvm7kyUWXKDJnM+7iri0l800ey6fN1/Sx3DfDITlN98RwvW+GozTM9K1BM/wDcEokViQHAAA=";
private static final Log log = LogFactory.getLog(JCheckBoxDemo.class);
private static final long serialVersionUID = 1L;
/*-----------------------------------------------------------------------*/
/*--------------------------- Internal states ---------------------------*/
/*-----------------------------------------------------------------------*/
private boolean allComponentsCreated;
/*-----------------------------------------------------------------------*/
/*------------------------ Protected components ------------------------*/
/*-----------------------------------------------------------------------*/
protected JCheckBox bold;
protected JCheckBox italic;
protected JCheckBox underline;
/*-----------------------------------------------------------------------*/
/*------------------------- Private components -------------------------*/
/*-----------------------------------------------------------------------*/
private JCheckBoxDemo $DemoPanel0 = this;
private JLabel $JLabel0;
private Table $Table0;
private VBox $VBox0;
/*-----------------------------------------------------------------------*/
/*---------------------- Raw body code from script ----------------------*/
/*-----------------------------------------------------------------------*/
public String getText(boolean bold, boolean italic, boolean underline) {
String text ="Sample Text";
if (bold)
text = "" + text + " ";
if (italic)
text = "" + text + " ";
if (underline)
text = "" + text + " ";
return "" + text;
}
/*-----------------------------------------------------------------------*/
/*---------------------------- Constructors ----------------------------*/
/*-----------------------------------------------------------------------*/
public JCheckBoxDemo(LayoutManager param0, boolean param1) {
super(param0 ,param1);
$initialize();
}
public JCheckBoxDemo(JAXXContext param0, LayoutManager param1, boolean param2) {
super(param0 ,param1 ,param2);
$initialize();
}
public JCheckBoxDemo(LayoutManager param0) {
super(param0);
$initialize();
}
public JCheckBoxDemo(JAXXContext param0, LayoutManager param1) {
super(param0 ,param1);
$initialize();
}
public JCheckBoxDemo() {
$initialize();
}
public JCheckBoxDemo(JAXXContext param0) {
super(param0);
$initialize();
}
public JCheckBoxDemo(boolean param0) {
super(param0);
$initialize();
}
public JCheckBoxDemo(JAXXContext param0, boolean param1) {
super(param0 ,param1);
$initialize();
}
/*-----------------------------------------------------------------------*/
/*--------------------------- Statics methods ---------------------------*/
/*-----------------------------------------------------------------------*/
public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
}
/*-----------------------------------------------------------------------*/
/*----------------------- Public acessor methods -----------------------*/
/*-----------------------------------------------------------------------*/
public JCheckBox getBold() {
return bold;
}
public JCheckBox getItalic() {
return italic;
}
public JCheckBox getUnderline() {
return underline;
}
/*-----------------------------------------------------------------------*/
/*--------------------- Protected acessors methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected JLabel get$JLabel0() {
return $JLabel0;
}
protected Table get$Table0() {
return $Table0;
}
protected VBox get$VBox0() {
return $VBox0;
}
/*-----------------------------------------------------------------------*/
/*--------------------- Components creation methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected void createBold() {
$objectMap.put("bold", bold = new JCheckBox());
bold.setName("bold");
bold.setText(t("Bold"));
bold.setMnemonic(66);
}
protected void createItalic() {
$objectMap.put("italic", italic = new JCheckBox());
italic.setName("italic");
italic.setText(t("Italic"));
italic.setMnemonic(73);
}
protected void createUnderline() {
$objectMap.put("underline", underline = new JCheckBox());
underline.setName("underline");
underline.setText(t("Underline"));
underline.setMnemonic(85);
}
/*-----------------------------------------------------------------------*/
/*------------------------ Internal jaxx methods ------------------------*/
/*-----------------------------------------------------------------------*/
private void $completeSetup() {
allComponentsCreated = true;
if (log.isDebugEnabled()) {
log.debug(this);
}
// inline complete setup of $DemoPanel0
add($VBox0);
// inline complete setup of $VBox0
$VBox0.add($Table0);
// inline complete setup of $Table0
$Table0.add(bold, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
$Table0.add($JLabel0, new GridBagConstraints(1, 0, 1, 3, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
$Table0.add(italic, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
$Table0.add(underline, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0, 17, 0, new Insets(3, 3, 3, 3), 0, 0));
// apply 1 data bindings
JAXXUtil.applyDataBinding(this, $bindings.keySet());
// apply 1 property setters
$JLabel0.setFont(new Font("Arial", 0, 18));
}
private void $initialize() {
if (allComponentsCreated) {
return;
}
if (log.isDebugEnabled()) {
log.debug(this);
}
$objectMap.put("$DemoPanel0", $DemoPanel0);
// inline creation of $VBox0
$objectMap.put("$VBox0", $VBox0 = new VBox());
$VBox0.setName("$VBox0");
$VBox0.setHorizontalAlignment(0);
$VBox0.setVerticalAlignment(0);
// inline creation of $Table0
$objectMap.put("$Table0", $Table0 = new Table());
$Table0.setName("$Table0");
createBold();
// inline creation of $JLabel0
$objectMap.put("$JLabel0", $JLabel0 = new JLabel());
$JLabel0.setName("$JLabel0");
createItalic();
createUnderline();
// inline creation of $DemoPanel0
setName("$DemoPanel0");
// registers 1 data bindings
$registerDefaultBindings();
$completeSetup();
}
private void $registerDefaultBindings() {
// register 1 data bindings
registerDataBinding(new DefaultJAXXBinding(this, BINDING_$JLABEL0_TEXT, true, true) {
@Override
public void applyDataBinding() {
if (bold != null) {
$bindingSources.put("bold.getModel()", bold.getModel());
bold.getModel().addChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
bold.addPropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
if (italic != null) {
$bindingSources.put("italic.getModel()", italic.getModel());
italic.getModel().addChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
italic.addPropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
if (underline != null) {
$bindingSources.put("underline.getModel()", underline.getModel());
underline.getModel().addChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
underline.addPropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
}
@Override
public void processDataBinding() {
if (bold != null && italic != null && underline != null) {
$JLabel0.setText(t(getText(bold.isSelected(), italic.isSelected(), underline.isSelected())));
}
}
@Override
public void removeDataBinding() {
if (bold != null) {
ButtonModel $target = (ButtonModel) $bindingSources.remove("bold.getModel()");
if ($target != null) {
$target.removeChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
}
bold.removePropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
if (italic != null) {
ButtonModel $target = (ButtonModel) $bindingSources.remove("italic.getModel()");
if ($target != null) {
$target.removeChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
}
italic.removePropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
if (underline != null) {
ButtonModel $target = (ButtonModel) $bindingSources.remove("underline.getModel()");
if ($target != null) {
$target.removeChangeListener( JAXXUtil.getEventListener(ChangeListener.class, this, "$pr$u0"));
}
underline.removePropertyChangeListener("model", JAXXUtil.getDataBindingUpdateListener(jaxx.demo.component.swing.JCheckBoxDemo.this, BINDING_$JLABEL0_TEXT));
}
}
public void $pr$u0(ChangeEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
propertyChange(null);
}
});
}
}