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.runtime.swing.config.ConfigCategoryUI Maven / Gradle / Ivy
package jaxx.runtime.swing.config;
/*-
* #%L
* JAXX :: Config
* %%
* 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.BorderLayout;
import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.LayoutManager;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import javax.swing.DefaultListSelectionModel;
import javax.swing.JButton;
import javax.swing.JLabel;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JPopupMenu;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ListSelectionModel;
import javax.swing.ScrollPaneConstants;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import javax.swing.event.TableModelEvent;
import javax.swing.event.TableModelListener;
import jaxx.runtime.JAXXBinding;
import jaxx.runtime.JAXXContext;
import jaxx.runtime.JAXXObject;
import jaxx.runtime.JAXXObjectDescriptor;
import jaxx.runtime.JAXXUtil;
import jaxx.runtime.SwingUtil;
import jaxx.runtime.binding.DefaultJAXXBinding;
import jaxx.runtime.context.DefaultJAXXContext;
import jaxx.runtime.swing.config.model.CategoryModel;
import jaxx.runtime.swing.config.model.ConfigTableModel;
import jaxx.runtime.swing.config.model.ConfigUIModel;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jdesktop.swingx.JXTable;
import static org.nuiton.i18n.I18n.t;
public class ConfigCategoryUI extends JPanel implements JAXXObject {
/*-----------------------------------------------------------------------*/
/*---------------- Constants for all javaBean properties ----------------*/
/*-----------------------------------------------------------------------*/
public static final String PROPERTY_CATEGORY_MODEL = "categoryModel";
public static final String PROPERTY_SELECTION_MODEL = "selectionModel";
/*-----------------------------------------------------------------------*/
/*------------------ Constants for all public bindings ------------------*/
/*-----------------------------------------------------------------------*/
public static final String BINDING_RESET_ENABLED = "reset.enabled";
public static final String BINDING_SAVE_ENABLED = "save.enabled";
public static final String BINDING_TABLE_PANE_COLUMN_HEADER_VIEW = "tablePane.columnHeaderView";
/*-----------------------------------------------------------------------*/
/*------------------------- Other static fields -------------------------*/
/*-----------------------------------------------------------------------*/
private static final String $jaxxObjectDescriptor = "H4sIAAAAAAAAAKVWT28bRRSfuHHSJE0aapq2SlvcFBUHkXVS1AtFUMckiqNNHNlOW5JDGHsn9rTjne3sbOPUKuIj8BHgzgWJGydUJM4cuCC+AkIcuCLezK53vfGmcUUOm/Xse7/3//fmuz9R2hXo1hPc6RjCsyVtE2Oz8Phxuf6ENORnxG0I6kgukP83kkKpfTRlheeuRLf3TaWeD9TzRd52uE3sPu37Jpp05TEjbosQKdGNuEbDdfPV8PP9juOJHmroVBLqN3//lfra+urbFEIdB7zLQCjZs7SiSEZNlKKWRJfA0nOcZ9hughuC2k3wd1qdFRl23W3cJs/Ql2jcRGMOFgAm0cLwIWsMrd9xJDr/7uYOtglbluj9mKfuEdg1Gtw+pE1wW/0rYkmaXBzvlhxHI4xJNN7CtsWIkGhlePUNXydCSbe5RZhES6djaIkAabe0pX5F+tONAHtrWJx++QhnUuI6IwHI8nDO1EKVCGfGJQzalXI7wLqpqtcJQEzqympMINK81IvExHXCdGngsF/br5cSnxiMX2udVNCHSnI+VJjQgSokia7EhKsNwZk2HDeR1hoSzXPRNJ7AwD2V3PGVOsbmY50FJXor1Oi11or6fSOOdrE3sZCBnq3b6vFeKDLVJyLR5ZiTNdKRBUGwEl0cMHg3NBihpQVx1aRnYjirnpTcViJGKDnq4ufan7vxc783drjjwdjMxSuiDreI7fV3JHeOi4Sxh5h55KT/SrYkSVsJ3wt1ZrWPZR2xVlPnHwUyAs3H+hE4yog4KiKRkX2I1YNjia7uD9JaBT75hHb1BKEpQP3137nMbz/+8cN6j8VmwPblRNE+EgZ2cQR3gAioMn3RpzBPUpbfws79fTThj4Rm6OsJjlWDz+Ac2HtLqRtK3djAbgsg0uO///Rq7otfz6HUOppkHFvrWMmXoJdbkLgWZ1bH+fSB9ujC0Xl4zirfoHB13HjaFNyzgVunu0XOuDAebZRqay87kIfrCXkInalP/PJPpvr9g14uRsC3a6eKR/lI76ExajNqE83pAV0ncviU4xLP4hEtJxE1SmQGJ+i3Vf1cTwp+tsGZ17Y3CLaIeEjJkUR7XZscZX1WyMncQsBpfeO2sPhBtqo6dVcVoEkkEC62cZOIguasEqjkFqh9yEUb9xRWlhchn8qRTZ0o9WaiwVE/y+k0DDKxaEA36UPMYCjQxCGwwJJLX8B7amVZHzQ8Ny40KoEXJMp2o6hsbnBt2vD7j1gLiy9BUvAjaMSRD5M87mees7w9l5jiq13tvkqdJkb/W05ZvvJczUgDM59oV7HY4Yw2jiXKdyPuhdXiSmxL13i4VqmVigXzoFqslE1ztVA5KJiPCp9XAetaiwv6AhKTgLaciLZRrpT2ytu1GN72GhhJrF20Joao2sDSm+3GT8DjGexJXiGqjupIolvdYHcYhd1a+aCyVi3trUGE5kGxbO5ubaswM1CscF8WGONHxIqKnlGQRVgGklRAjgupbiOjUijanQDVDUKbLWiL1N17STH6i+2s+EaBR3DY/BJd8PtrKVgrQedlgq7zJY3g45TknNWoU9MyVxJkDAndhsaJrVyxVFagc2J3lNyiQV14o4eUWLnkSfN33JtGMhVEotZeGMiluJP+t3gcc4MiJ8MonBVG9s6dbKIIrD96Wph6QQ8xl9N1LmDqdjC1ZX/DjHEHP/Ni3ALrJMY3SWYvaIkapACmbAjmTTP/LvZ2kCefEfxsuUkG+i4YQ0SXWEN16QhrOB8v0IkLSbyY77xGVlU1yd/4FedNXc70D9ASD655ges3E2ak71500vuF14ufFsDAfWuIqo4xfMzh1ohmPragZ7J1aluwKD8ZwB9Rz8kzEdXxK/X4ORkh978R8oDwHyWrCG1XDwAA";
private static final Log log = LogFactory.getLog(ConfigCategoryUI.class);
private static final long serialVersionUID = 1L;
/*-----------------------------------------------------------------------*/
/*--------------------------- Internal states ---------------------------*/
/*-----------------------------------------------------------------------*/
protected List $activeBindings = new ArrayList();
protected Map $bindingSources = new HashMap();
protected final Map $bindings = new TreeMap();
protected Map $objectMap = new HashMap();
protected Map, ?> $previousValues = new HashMap();
private boolean allComponentsCreated;
protected final JAXXContext delegateContext = new DefaultJAXXContext();
/*-----------------------------------------------------------------------*/
/*------------------------ Protected components ------------------------*/
/*-----------------------------------------------------------------------*/
protected JLabel categoryLabel;
protected JPanel categoryLabelPanel;
protected CategoryModel categoryModel;
protected JMenuItem copyCellValue;
protected JTextArea description;
protected JScrollPane descriptionPane;
protected ConfigCategoryUIHandler handler;
protected ConfigUIModel model;
protected JButton reset;
protected JMenuItem resetOptionValue;
protected JButton save;
protected ListSelectionModel selectionModel;
protected JXTable table;
protected ConfigTableModel tableModel;
protected JScrollPane tablePane;
protected JPopupMenu tablePopup;
/*-----------------------------------------------------------------------*/
/*------------------------- Private components -------------------------*/
/*-----------------------------------------------------------------------*/
private ConfigCategoryUI $JPanel0 = this;
private JPanel $JPanel1;
private JPanel $JPanel2;
/*-----------------------------------------------------------------------*/
/*---------------------- Raw body code from script ----------------------*/
/*-----------------------------------------------------------------------*/
void $afterCompleteSetup() {
getHandler().init();
}
/*-----------------------------------------------------------------------*/
/*---------------------------- Constructors ----------------------------*/
/*-----------------------------------------------------------------------*/
public ConfigCategoryUI(LayoutManager param0, boolean param1) {
super(param0 ,param1);
$initialize();
}
public ConfigCategoryUI(JAXXContext parentContext, LayoutManager param1, boolean param2) {
super(param1 ,param2);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public ConfigCategoryUI(LayoutManager param0) {
super(param0);
$initialize();
}
public ConfigCategoryUI(JAXXContext parentContext, LayoutManager param1) {
super(param1);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public ConfigCategoryUI() {
$initialize();
}
public ConfigCategoryUI(JAXXContext parentContext) {
JAXXUtil.initContext(this, parentContext);
$initialize();
}
public ConfigCategoryUI(boolean param0) {
super(param0);
$initialize();
}
public ConfigCategoryUI(JAXXContext parentContext, boolean param1) {
super(param1);
JAXXUtil.initContext(this, parentContext);
$initialize();
}
/*-----------------------------------------------------------------------*/
/*--------------------------- Statics methods ---------------------------*/
/*-----------------------------------------------------------------------*/
public static JAXXObjectDescriptor $getJAXXObjectDescriptor() {
return JAXXUtil.decodeCompressedJAXXObjectDescriptor($jaxxObjectDescriptor);
}
/*-----------------------------------------------------------------------*/
/*---------------------- JAXXObject implementation ----------------------*/
/*-----------------------------------------------------------------------*/
@Override
public void applyDataBinding(String $binding) {
if (allComponentsCreated && $bindings.containsKey($binding)) {
getDataBinding($binding).applyDataBinding();
}
processDataBinding($binding);
}
@Override
public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
super.firePropertyChange(propertyName, oldValue, newValue);
}
@Override
public Map get$objectMap() {
return $objectMap;
}
@Override
public JAXXBinding getDataBinding(String bindingId) {
return $bindings.get(bindingId);
}
@Override
public JAXXBinding[] getDataBindings() {
return $bindings.values().toArray(new JAXXBinding[$bindings.size()]);
}
@Override
public Object getObjectById(String id) {
return $objectMap.get(id);
}
@Override
public void processDataBinding(String $binding, boolean $force) {
if (!$force && $activeBindings.contains($binding)) {
return;
}
$activeBindings.add($binding);
try {
if (allComponentsCreated && $bindings.containsKey($binding)) {
getDataBinding($binding).processDataBinding();
}
} finally {
$activeBindings.remove($binding);
}
}
@Override
public void processDataBinding(String $binding) {
processDataBinding($binding, false);
}
@Override
public void registerDataBinding(JAXXBinding binding) {
$bindings.put(binding.getId(), binding);
}
@Override
public void removeDataBinding(String $binding) {
if (allComponentsCreated && $bindings.containsKey($binding)) {
getDataBinding($binding).removeDataBinding();
}
}
/*-----------------------------------------------------------------------*/
/*--------------------- JAXXContext implementation ---------------------*/
/*-----------------------------------------------------------------------*/
@Override
public T getContextValue(Class clazz) {
return delegateContext.getContextValue(clazz, null);
}
@Override
public T getContextValue(Class clazz, String name) {
return delegateContext.getContextValue(clazz, name);
}
@Override
public JAXXContext getDelegateContext() {
return delegateContext;
}
@Override
public O getParentContainer(Class clazz) {
return SwingUtil.getParentContainer(this, clazz);
}
@Override
public O getParentContainer(Object source, Class clazz) {
return SwingUtil.getParentContainer(source, clazz);
}
@Override
public void removeContextValue(Class clazz) {
delegateContext.removeContextValue(clazz, null);
}
@Override
public void removeContextValue(Class clazz, String name) {
delegateContext.removeContextValue(clazz, name);
}
@Override
public void setContextValue(T o) {
delegateContext.setContextValue(o, null);
}
@Override
public void setContextValue(T o, String name) {
delegateContext.setContextValue(o, name);
}
/*-----------------------------------------------------------------------*/
/*---------------------------- Event methods ----------------------------*/
/*-----------------------------------------------------------------------*/
public void doActionPerformed__on__copyCellValue(ActionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.copyCellValue();
}
public void doActionPerformed__on__reset(ActionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
model.reset();
}
public void doActionPerformed__on__resetOptionValue(ActionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.resetOptionValue();
}
public void doActionPerformed__on__save(ActionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
model.saveModified();
}
public void doMousePressed__on__table(MouseEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.openTablePopupMenu(event, tablePopup);
}
public void doTableChanged__on__tableModel(TableModelEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
handler.updateDescriptionText();
}
public void doValueChanged__on__selectionModel(ListSelectionEvent event) {
if (log.isDebugEnabled()) {
log.debug(event);
}
if (!event.getValueIsAdjusting()) {handler.updateDescriptionText(); }
}
/*-----------------------------------------------------------------------*/
/*----------------------- Public acessor methods -----------------------*/
/*-----------------------------------------------------------------------*/
public JLabel getCategoryLabel() {
return categoryLabel;
}
public JPanel getCategoryLabelPanel() {
return categoryLabelPanel;
}
public CategoryModel getCategoryModel() {
return categoryModel;
}
public JMenuItem getCopyCellValue() {
return copyCellValue;
}
public JTextArea getDescription() {
return description;
}
public JScrollPane getDescriptionPane() {
return descriptionPane;
}
public ConfigCategoryUIHandler getHandler() {
return handler;
}
public ConfigUIModel getModel() {
return model;
}
public JButton getReset() {
return reset;
}
public JMenuItem getResetOptionValue() {
return resetOptionValue;
}
public JButton getSave() {
return save;
}
public ListSelectionModel getSelectionModel() {
return selectionModel;
}
public JXTable getTable() {
return table;
}
public ConfigTableModel getTableModel() {
return tableModel;
}
public JScrollPane getTablePane() {
return tablePane;
}
public JPopupMenu getTablePopup() {
return tablePopup;
}
/*-----------------------------------------------------------------------*/
/*----------------------- Public mutator methods -----------------------*/
/*-----------------------------------------------------------------------*/
public void setCategoryModel(CategoryModel categoryModel) {
CategoryModel oldValue = this.categoryModel;
this.categoryModel = categoryModel;
firePropertyChange(PROPERTY_CATEGORY_MODEL, oldValue, categoryModel);
}
public void setSelectionModel(ListSelectionModel selectionModel) {
ListSelectionModel oldValue = this.selectionModel;
this.selectionModel = selectionModel;
firePropertyChange(PROPERTY_SELECTION_MODEL, oldValue, selectionModel);
}
/*-----------------------------------------------------------------------*/
/*--------------------- Protected acessors methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected JPanel get$JPanel1() {
return $JPanel1;
}
protected JPanel get$JPanel2() {
return $JPanel2;
}
/*-----------------------------------------------------------------------*/
/*--------------------- Components creation methods ---------------------*/
/*-----------------------------------------------------------------------*/
protected void addChildrenToCategoryLabelPanel() {
if (!allComponentsCreated) {
return;
}
categoryLabelPanel.add(categoryLabel);
}
protected void addChildrenToDescriptionPane() {
if (!allComponentsCreated) {
return;
}
descriptionPane.getViewport().add(description);
}
protected void addChildrenToTablePane() {
if (!allComponentsCreated) {
return;
}
tablePane.getViewport().add(table);
}
protected void addChildrenToTablePopup() {
if (!allComponentsCreated) {
return;
}
tablePopup.add(copyCellValue);
tablePopup.add(resetOptionValue);
}
protected void createCategoryLabel() {
$objectMap.put("categoryLabel", categoryLabel = new JLabel());
categoryLabel.setName("categoryLabel");
}
protected void createCategoryLabelPanel() {
$objectMap.put("categoryLabelPanel", categoryLabelPanel = new JPanel());
categoryLabelPanel.setName("categoryLabelPanel");
}
protected void createCategoryModel() {
$objectMap.put("categoryModel", categoryModel = getContextValue(CategoryModel.class));
}
protected void createCopyCellValue() {
$objectMap.put("copyCellValue", copyCellValue = new JMenuItem());
copyCellValue.setName("copyCellValue");
copyCellValue.setText(t("config.action.copyCellValue"));
copyCellValue.setToolTipText(t("config.action.copyCellValue.tip"));
copyCellValue.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__copyCellValue"));
}
protected void createDescription() {
$objectMap.put("description", description = new JTextArea());
description.setName("description");
description.setColumns(15);
description.setLineWrap(true);
description.setWrapStyleWord(true);
description.setEditable(false);
if (description.getFont() != null) {
description.setFont(description.getFont().deriveFont((float) 10));
}
description.setFocusable(false);
description.setRows(3);
}
protected void createDescriptionPane() {
$objectMap.put("descriptionPane", descriptionPane = new JScrollPane());
descriptionPane.setName("descriptionPane");
}
protected void createHandler() {
$objectMap.put("handler", handler = new ConfigCategoryUIHandler(this));
}
protected void createModel() {
$objectMap.put("model", model = getContextValue(ConfigUIModel.class));
}
protected void createReset() {
$objectMap.put("reset", reset = new JButton());
reset.setName("reset");
reset.setText(t("config.action.reset"));
reset.setToolTipText(t("config.action.reset.tip"));
reset.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__reset"));
}
protected void createResetOptionValue() {
$objectMap.put("resetOptionValue", resetOptionValue = new JMenuItem());
resetOptionValue.setName("resetOptionValue");
resetOptionValue.setText(t("config.action.resetOptionValue"));
resetOptionValue.setToolTipText(t("config.action.resetOptionValue.tip"));
resetOptionValue.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__resetOptionValue"));
}
protected void createSave() {
$objectMap.put("save", save = new JButton());
save.setName("save");
save.setText(t("config.action.save"));
save.setToolTipText(t("config.action.save.tip"));
save.addActionListener(JAXXUtil.getEventListener(ActionListener.class, "actionPerformed", this, "doActionPerformed__on__save"));
}
protected void createSelectionModel() {
$objectMap.put("selectionModel", selectionModel = new DefaultListSelectionModel());
selectionModel.addListSelectionListener(JAXXUtil.getEventListener(ListSelectionListener.class, "valueChanged", this, "doValueChanged__on__selectionModel"));
}
protected void createTable() {
$objectMap.put("table", table = new JXTable(tableModel));
table.setName("table");
table.setRowSelectionAllowed(false);
table.setAutoCreateRowSorter(true);
table.setRowHeight(25);
table.addMouseListener(JAXXUtil.getEventListener(MouseListener.class, "mousePressed", this, "doMousePressed__on__table"));
}
protected void createTableModel() {
$objectMap.put("tableModel", tableModel = new ConfigTableModel(categoryModel));
tableModel.addTableModelListener(JAXXUtil.getEventListener(TableModelListener.class, "tableChanged", this, "doTableChanged__on__tableModel"));
}
protected void createTablePane() {
$objectMap.put("tablePane", tablePane = new JScrollPane());
tablePane.setName("tablePane");
}
protected void createTablePopup() {
$objectMap.put("tablePopup", tablePopup = new JPopupMenu());
tablePopup.setName("tablePopup");
tablePopup.setLabel("config.table.actions");
}
/*-----------------------------------------------------------------------*/
/*------------------------ Internal jaxx methods ------------------------*/
/*-----------------------------------------------------------------------*/
private void $completeSetup() {
allComponentsCreated = true;
if (log.isDebugEnabled()) {
log.debug(this);
}
// inline complete setup of $JPanel0
add(categoryLabelPanel, BorderLayout.NORTH);
add(tablePane, BorderLayout.CENTER);
add($JPanel1, BorderLayout.SOUTH);
addChildrenToCategoryLabelPanel();
addChildrenToTablePane();
// inline complete setup of $JPanel1
$JPanel1.add(descriptionPane, BorderLayout.CENTER);
$JPanel1.add($JPanel2, BorderLayout.SOUTH);
addChildrenToDescriptionPane();
// inline complete setup of $JPanel2
$JPanel2.add(reset);
$JPanel2.add(save);
addChildrenToTablePopup();
// apply 3 data bindings
JAXXUtil.applyDataBinding(this, $bindings.keySet());
// apply 14 property setters
categoryLabelPanel.setBackground(Color.WHITE);
tablePane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
tablePane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
table.setSelectionModel(selectionModel);
table.setAutoResizeMode(JXTable.AUTO_RESIZE_ALL_COLUMNS);
descriptionPane.setColumnHeaderView(new JLabel(t("config.description"), SwingUtil.getUIManagerActionIcon("information"), 10));
SwingUtil.setText(description, t("config.no.option.selected"));
reset.setIcon(SwingUtil.createActionIcon("config-reset"));
save.setIcon(SwingUtil.createActionIcon("config-save"));
copyCellValue.setIcon(SwingUtil.createActionIcon("config-copy"));
resetOptionValue.setIcon(SwingUtil.createActionIcon("config-reset-option"));
$afterCompleteSetup();
}
private void $initialize() {
if (allComponentsCreated) {
return;
}
if (log.isDebugEnabled()) {
log.debug(this);
}
$objectMap.put("$JPanel0", $JPanel0);
createHandler();
createModel();
createCategoryModel();
createTableModel();
createSelectionModel();
createCategoryLabelPanel();
createCategoryLabel();
createTablePane();
createTable();
// inline creation of $JPanel1
$objectMap.put("$JPanel1", $JPanel1 = new JPanel());
$JPanel1.setName("$JPanel1");
$JPanel1.setLayout(new BorderLayout());
createDescriptionPane();
createDescription();
// inline creation of $JPanel2
$objectMap.put("$JPanel2", $JPanel2 = new JPanel());
$JPanel2.setName("$JPanel2");
$JPanel2.setLayout(new GridLayout(1,0));
createReset();
createSave();
createTablePopup();
createCopyCellValue();
createResetOptionValue();
// inline creation of $JPanel0
setName("$JPanel0");
setLayout(new BorderLayout());
// registers 3 data bindings
$registerDefaultBindings();
$completeSetup();
}
private void $registerDefaultBindings() {
// register 3 data bindings
registerDataBinding(new DefaultJAXXBinding(this, BINDING_TABLE_PANE_COLUMN_HEADER_VIEW, true) {
@Override
public void applyDataBinding() {
if (table != null) {
table.addPropertyChangeListener("tableHeader", this);
}
}
@Override
public void processDataBinding() {
if (table != null) {
tablePane.setColumnHeaderView(table.getTableHeader());
}
}
@Override
public void removeDataBinding() {
if (table != null) {
table.removePropertyChangeListener("tableHeader", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_RESET_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("categoryModel", this);
if (getCategoryModel() != null) {
getCategoryModel().addPropertyChangeListener("modified", this);
}
}
@Override
public void processDataBinding() {
if (getCategoryModel() != null) {
reset.setEnabled(getCategoryModel().isModified());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("categoryModel", this);
if (getCategoryModel() != null) {
getCategoryModel().removePropertyChangeListener("modified", this);
}
}
});
registerDataBinding(new DefaultJAXXBinding(this, BINDING_SAVE_ENABLED, true, true) {
@Override
public void applyDataBinding() {
addPropertyChangeListener("categoryModel", this);
if (getCategoryModel() != null) {
getCategoryModel().addPropertyChangeListener("modified", this);
}
if (getCategoryModel() != null) {
getCategoryModel().addPropertyChangeListener("valid", this);
}
}
@Override
public void processDataBinding() {
if (getCategoryModel() != null) {
save.setEnabled(getCategoryModel().isModified() && getCategoryModel().isValid());
}
}
@Override
public void removeDataBinding() {
removePropertyChangeListener("categoryModel", this);
if (getCategoryModel() != null) {
getCategoryModel().removePropertyChangeListener("modified", this);
}
if (getCategoryModel() != null) {
getCategoryModel().removePropertyChangeListener("valid", this);
}
}
});
}
}