Search in sources :

Example 1 with BindingGroup

use of org.jdesktop.beansbinding.BindingGroup in project JMRI by JMRI.

the class LnTcpPreferencesPanel method initComponents.

private void initComponents() {
    bindingGroup = new BindingGroup();
    port = new JSpinner();
    portLabel = new JLabel();
    startup = new JCheckBox();
    port.setModel(new SpinnerNumberModel(1234, 1, 65535, 1));
    port.setEditor(new JSpinner.NumberEditor(port, "#"));
    // NOI18N
    port.setToolTipText(Bundle.getMessage("ToolTipPort"));
    Binding binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${port}"), port, BeanProperty.create("value"));
    bindingGroup.addBinding(binding);
    // NOI18N
    portLabel.setText(Bundle.getMessage("LabelPort"));
    // NOI18N
    portLabel.setToolTipText(Bundle.getMessage("ToolTipPort"));
    startup.setSelected(this.isStartupAction());
    // NOI18N
    startup.setText(Bundle.getMessage("LabelStartup"));
    this.startupItemListener = (ItemEvent e) -> {
        this.startup.removeItemListener(this.startupItemListener);
        StartupActionsManager manager = InstanceManager.getDefault(StartupActionsManager.class);
        if (this.startup.isSelected()) {
            PerformActionModel model = new PerformActionModel();
            model.setClassName(LnTcpServerAction.class.getName());
            if (this.startupActionPosition == -1 || this.startupActionPosition >= manager.getActions().length) {
                manager.addAction(model);
            } else {
                manager.setActions(this.startupActionPosition, model);
            }
        } else {
            manager.getActions(PerformActionModel.class).stream().filter((model) -> (LnTcpServerAction.class.getName().equals(model.getClassName()))).forEach((model) -> {
                this.startupActionPosition = Arrays.asList(manager.getActions()).indexOf(model);
                manager.removeAction(model);
            });
        }
        this.startup.addItemListener(this.startupItemListener);
    };
    this.startup.addItemListener(this.startupItemListener);
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(port, GroupLayout.PREFERRED_SIZE, 75, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(portLabel, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addComponent(startup, GroupLayout.DEFAULT_SIZE, 388, Short.MAX_VALUE)).addContainerGap()));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addContainerGap().addGroup(layout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(port, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(portLabel)).addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED).addComponent(startup).addContainerGap(198, Short.MAX_VALUE)));
    bindingGroup.bind();
}
Also used : AutoBinding(org.jdesktop.beansbinding.AutoBinding) Binding(org.jdesktop.beansbinding.Binding) PerformActionModel(apps.PerformActionModel) JComponent(javax.swing.JComponent) ItemEvent(java.awt.event.ItemEvent) InstanceManager(jmri.InstanceManager) BeanProperty(org.jdesktop.beansbinding.BeanProperty) Arrays(java.util.Arrays) JSpinner(javax.swing.JSpinner) SpinnerNumberModel(javax.swing.SpinnerNumberModel) Bindings(org.jdesktop.beansbinding.Bindings) ItemListener(java.awt.event.ItemListener) StartupActionsManager(apps.StartupActionsManager) AutoBinding(org.jdesktop.beansbinding.AutoBinding) LayoutStyle(javax.swing.LayoutStyle) PerformActionModel(apps.PerformActionModel) BindingGroup(org.jdesktop.beansbinding.BindingGroup) JLabel(javax.swing.JLabel) GroupLayout(javax.swing.GroupLayout) JCheckBox(javax.swing.JCheckBox) ELProperty(org.jdesktop.beansbinding.ELProperty) Binding(org.jdesktop.beansbinding.Binding) JPanel(javax.swing.JPanel) PreferencesPanel(jmri.swing.PreferencesPanel) ItemEvent(java.awt.event.ItemEvent) JLabel(javax.swing.JLabel) StartupActionsManager(apps.StartupActionsManager) JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) BindingGroup(org.jdesktop.beansbinding.BindingGroup) GroupLayout(javax.swing.GroupLayout) JSpinner(javax.swing.JSpinner)

Example 2 with BindingGroup

use of org.jdesktop.beansbinding.BindingGroup in project JMRI by JMRI.

the class FrameServletPreferencesPanel method 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")
private // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
void initComponents() {
    bindingGroup = new BindingGroup();
    framesEnabled = new ButtonGroup();
    preferences = InstanceManager.getDefault(WebServerPreferences.class);
    enableFramesPnl = new JPanel();
    enableFrames = new JRadioButton();
    clickDelay = new JSpinner();
    refreshDelay = new JSpinner();
    useAjax = new JCheckBox();
    refreshDelayLbl = new JLabel();
    clickDelayLbl = new JLabel();
    disallowedFramesLbl = new JLabel();
    jScrollPane1 = new JScrollPane();
    disallowedFrames = new EditableList<String>();
    disableFramesPnl = new JPanel();
    disableFrames = new JRadioButton();
    redirectToPanels = new JCheckBox();
    framesEnabled.add(enableFrames);
    framesEnabled.add(disableFrames);
    preferences.addPropertyChangeListener(new PropertyChangeListener() {

        public void propertyChange(PropertyChangeEvent evt) {
            preferencesPropertyChange(evt);
        }
    });
    // NOI18N
    enableFrames.setText(Bundle.getMessage("LabelEnableFrames"));
    Binding binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, preferences, ELProperty.create("${!disableFrames}"), enableFrames, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    clickDelay.setModel(new SpinnerNumberModel(1, 0, 999, 1));
    // NOI18N
    clickDelay.setToolTipText(Bundle.getMessage("ToolTipClickDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${clickDelay}"), clickDelay, BeanProperty.create("value"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), clickDelay, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    refreshDelay.setModel(new SpinnerNumberModel(5, 0, 999, 1));
    // NOI18N
    refreshDelay.setToolTipText(Bundle.getMessage("ToolTipRefreshDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${refreshDelay}"), refreshDelay, BeanProperty.create("value"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), refreshDelay, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    useAjax.setText(Bundle.getMessage("LabelUseAjax"));
    // NOI18N
    useAjax.setToolTipText(Bundle.getMessage("ToolTipUseAjax"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${useAjax}"), useAjax, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), useAjax, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    refreshDelayLbl.setText(Bundle.getMessage("LabelRefreshDelay"));
    // NOI18N
    refreshDelayLbl.setToolTipText(Bundle.getMessage("ToolTipRefreshDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), refreshDelayLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    clickDelayLbl.setText(Bundle.getMessage("LabelClickDelay"));
    // NOI18N
    clickDelayLbl.setToolTipText(Bundle.getMessage("ToolTipClickDelay"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), clickDelayLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    // NOI18N
    disallowedFramesLbl.setText(Bundle.getMessage("LabelDisallowedFrames"));
    // NOI18N
    disallowedFramesLbl.setToolTipText(Bundle.getMessage("ToolTipDisallowedFrames"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), disallowedFramesLbl, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    disallowedFrames.setModel(new DefaultEditableListModel<String>());
    disallowedFrames.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
    // NOI18N
    disallowedFrames.setToolTipText(Bundle.getMessage("ToolTipDisallowedFrames"));
    disallowedFrames.setListCellEditor(new DefaultListCellEditor<>(new JTextField()));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, enableFrames, ELProperty.create("${selected}"), disallowedFrames, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    DefaultEditableListModel<String> model = (DefaultEditableListModel<String>) this.disallowedFrames.getModel();
    model.addListDataListener(this);
    for (String frame : this.preferences.getDisallowedFrames()) {
        model.addElement(frame);
    }
    model.addElement(" ");
    jScrollPane1.setViewportView(disallowedFrames);
    GroupLayout enableFramesPnlLayout = new GroupLayout(enableFramesPnl);
    enableFramesPnl.setLayout(enableFramesPnlLayout);
    enableFramesPnlLayout.setHorizontalGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addContainerGap().addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addGap(29, 29, 29).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addComponent(clickDelay, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(clickDelayLbl, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)).addGroup(enableFramesPnlLayout.createSequentialGroup().addComponent(refreshDelay, GroupLayout.PREFERRED_SIZE, 50, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(refreshDelayLbl, GroupLayout.PREFERRED_SIZE, 104, GroupLayout.PREFERRED_SIZE)).addComponent(useAjax, GroupLayout.PREFERRED_SIZE, 160, GroupLayout.PREFERRED_SIZE)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(jScrollPane1, GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE).addComponent(disallowedFramesLbl, GroupLayout.DEFAULT_SIZE, 148, Short.MAX_VALUE))).addComponent(enableFrames, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addContainerGap()));
    enableFramesPnlLayout.setVerticalGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(enableFrames).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(clickDelay, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(clickDelayLbl).addComponent(disallowedFramesLbl)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(enableFramesPnlLayout.createSequentialGroup().addGroup(enableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.BASELINE).addComponent(refreshDelay, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE).addComponent(refreshDelayLbl)).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(useAjax).addContainerGap(108, Short.MAX_VALUE)).addComponent(jScrollPane1))));
    // NOI18N
    disableFrames.setText(Bundle.getMessage("LabelDisableFrames"));
    // NOI18N
    disableFrames.setToolTipText(Bundle.getMessage("ToolTipDisableFrames"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${disableFrames}"), disableFrames, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    // NOI18N
    redirectToPanels.setText(Bundle.getMessage("LabelRedirectFramesToPanels"));
    // NOI18N
    redirectToPanels.setToolTipText(Bundle.getMessage("ToolTipRedirectFramesToPanels"));
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ_WRITE, preferences, ELProperty.create("${redirectFramesToPanels}"), redirectToPanels, BeanProperty.create("selected"));
    bindingGroup.addBinding(binding);
    binding = Bindings.createAutoBinding(AutoBinding.UpdateStrategy.READ, disableFrames, ELProperty.create("${selected}"), redirectToPanels, BeanProperty.create("enabled"));
    bindingGroup.addBinding(binding);
    GroupLayout disableFramesPnlLayout = new GroupLayout(disableFramesPnl);
    disableFramesPnl.setLayout(disableFramesPnlLayout);
    disableFramesPnlLayout.setHorizontalGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(disableFrames, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)).addGroup(disableFramesPnlLayout.createSequentialGroup().addGap(35, 35, 35).addComponent(redirectToPanels, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))).addContainerGap()));
    disableFramesPnlLayout.setVerticalGroup(disableFramesPnlLayout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(disableFramesPnlLayout.createSequentialGroup().addContainerGap().addComponent(disableFrames, GroupLayout.PREFERRED_SIZE, 23, GroupLayout.PREFERRED_SIZE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(redirectToPanels).addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)));
    GroupLayout layout = new GroupLayout(this);
    this.setLayout(layout);
    layout.setHorizontalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addComponent(enableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addComponent(disableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE));
    layout.setVerticalGroup(layout.createParallelGroup(GroupLayout.Alignment.LEADING).addGroup(layout.createSequentialGroup().addComponent(enableFramesPnl, GroupLayout.DEFAULT_SIZE, GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE).addPreferredGap(LayoutStyle.ComponentPlacement.RELATED).addComponent(disableFramesPnl, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)));
    bindingGroup.bind();
}
Also used : JScrollPane(javax.swing.JScrollPane) AutoBinding(org.jdesktop.beansbinding.AutoBinding) Binding(org.jdesktop.beansbinding.Binding) JPanel(javax.swing.JPanel) PropertyChangeEvent(java.beans.PropertyChangeEvent) DefaultEditableListModel(jmri.swing.DefaultEditableListModel) JRadioButton(javax.swing.JRadioButton) PropertyChangeListener(java.beans.PropertyChangeListener) JLabel(javax.swing.JLabel) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) SpinnerNumberModel(javax.swing.SpinnerNumberModel) ButtonGroup(javax.swing.ButtonGroup) BindingGroup(org.jdesktop.beansbinding.BindingGroup) GroupLayout(javax.swing.GroupLayout) JSpinner(javax.swing.JSpinner)

Example 3 with BindingGroup

use of org.jdesktop.beansbinding.BindingGroup in project MtgDesktopCompanion by nicho92.

the class MagicCardDetailPanel method initDataBindings.

protected BindingGroup initDataBindings() {
    BeanProperty<MagicCard, Integer> cmcProperty = BeanProperty.create("cmc");
    BeanProperty<JTextField, String> textProperty = BeanProperty.create("text");
    AutoBinding<MagicCard, Integer, JTextField, String> autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, cmcProperty, cmcJTextField, textProperty);
    autoBinding.bind();
    // 
    BeanProperty<MagicCard, String> costProperty = BeanProperty.create("cost");
    BeanProperty<ManaPanel, String> textProperty1 = BeanProperty.create("manaCost");
    AutoBinding<MagicCard, String, ManaPanel, String> autoBinding1 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, costProperty, manaPanel, textProperty1);
    autoBinding1.bind();
    // 
    BeanProperty<MagicCard, String> fullTypeProperty = BeanProperty.create("fullType");
    BeanProperty<JTextField, String> textProperty2 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding2 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, fullTypeProperty, fullTypeJTextField, textProperty2);
    autoBinding2.bind();
    // 
    BeanProperty<MagicCard, Integer> loyaltyProperty = BeanProperty.create("loyalty");
    BeanProperty<JTextField, String> textProperty4 = BeanProperty.create("text");
    AutoBinding<MagicCard, Integer, JTextField, String> autoBinding4 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, loyaltyProperty, loyaltyJTextField, textProperty4);
    autoBinding4.bind();
    // 
    BeanProperty<MagicCard, String> nameProperty = BeanProperty.create("name");
    BeanProperty<JTextField, String> textProperty5 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding5 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, nameProperty, nameJTextField, textProperty5);
    autoBinding5.bind();
    // 
    BeanProperty<MagicCard, String> powerProperty = BeanProperty.create("power");
    BeanProperty<JTextField, String> textProperty6 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding6 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, powerProperty, powerJTextField, textProperty6);
    autoBinding6.bind();
    // 
    BeanProperty<MagicCard, String> textProperty8 = BeanProperty.create("text");
    BeanProperty<MagicTextPane, String> textProperty9 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, MagicTextPane, String> autoBinding8 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, textProperty8, txtTextPane, textProperty9);
    autoBinding8.bind();
    // 
    BeanProperty<MagicCard, String> toughnessProperty = BeanProperty.create("toughness");
    BeanProperty<JTextField, String> textProperty10 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding9 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, toughnessProperty, toughnessJTextField, textProperty10);
    autoBinding9.bind();
    BeanProperty<MagicCard, String> flavorProperty = BeanProperty.create("flavor");
    BeanProperty<JTextPane, String> textProperty11 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextPane, String> autoBinding10 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, flavorProperty, txtFlavorArea, textProperty11);
    autoBinding10.bind();
    BeanProperty<MagicCard, String> artistProperty = BeanProperty.create("artist");
    BeanProperty<JTextField, String> textProperty12 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding11 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, artistProperty, txtArtist, textProperty12);
    autoBinding11.bind();
    BeanProperty<MagicCard, String> layoutProperty = BeanProperty.create("layout");
    BeanProperty<JTextField, String> textProperty13 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding12 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, layoutProperty, txtLayoutField, textProperty13);
    autoBinding12.bind();
    BeanProperty<MagicCard, String> waterProperty = BeanProperty.create("watermarks");
    BeanProperty<JTextField, String> textProperty14 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding13 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, waterProperty, txtWatermark, textProperty14);
    autoBinding13.bind();
    BeanProperty<MagicCard, Boolean> reservedProperty = BeanProperty.create("reserved");
    BeanProperty<JCheckBox, Boolean> chkProperty15 = BeanProperty.create("selected");
    AutoBinding<MagicCard, Boolean, JCheckBox, Boolean> autoBinding15 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, reservedProperty, chckbxReserved, chkProperty15);
    autoBinding15.bind();
    try {
        if (magicCard != null)
            rarityJTextField.setText(magicCard.getEditions().get(0).getRarity());
    } catch (Exception e) {
        rarityJTextField.setText("");
    }
    txtTextPane.updateTextWithIcons();
    if (thumbnail && magicCard != null)
        ThreadManager.getInstance().execute(() -> loadPics(), "load pic");
    if (magicCard != null && !magicCard.getEditions().isEmpty()) {
        ThreadManager.getInstance().execute(() -> {
            setMagicLogo(magicCard.getEditions().get(0).getId(), magicCard.getEditions().get(0).getRarity());
            lblnumberInSet.setText(magicCard.getEditions().get(0).getNumber() + "/" + magicCard.getEditions().get(0).getCardCount());
        }, "loadLogo");
    }
    if (magicCard != null && enableCollectionLookup)
        ThreadManager.getInstance().execute(() -> {
            try {
                ((DefaultListModel) listCollection.getModel()).removeAllElements();
                for (MagicCollection col : MTGControler.getInstance().getEnabledDAO().listCollectionFromCards(magicCard)) ((DefaultListModel) listCollection.getModel()).addElement(col);
            } catch (Exception e) {
                logger.error(e);
            }
        }, "loadCollections");
    if (magicCard != null && enableCollectionLookup)
        ThreadManager.getInstance().execute(() -> {
            if (MTGControler.getInstance().getEnabledDAO().hasAlert(magicCard)) {
                btnAlert.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("HAD_ALERT"));
                btnAlert.setEnabled(false);
            } else {
                btnAlert.setToolTipText(MTGControler.getInstance().getLangService().getCapitalize("ADD_ALERT_FOR", magicCard.getName()));
                btnAlert.setEnabled(true);
            }
        }, "Get alerts for " + magicCard);
    ((DefaultListModel) lstFormats.getModel()).removeAllElements();
    if (magicCard != null)
        for (MagicFormat mf : magicCard.getLegalities()) ((DefaultListModel) lstFormats.getModel()).addElement(mf);
    // 
    BindingGroup bindingGroup = new BindingGroup();
    // 
    bindingGroup.addBinding(autoBinding);
    bindingGroup.addBinding(autoBinding1);
    bindingGroup.addBinding(autoBinding2);
    bindingGroup.addBinding(autoBinding4);
    bindingGroup.addBinding(autoBinding5);
    bindingGroup.addBinding(autoBinding6);
    bindingGroup.addBinding(autoBinding8);
    bindingGroup.addBinding(autoBinding9);
    bindingGroup.addBinding(autoBinding10);
    bindingGroup.addBinding(autoBinding11);
    bindingGroup.addBinding(autoBinding12);
    bindingGroup.addBinding(autoBinding13);
    bindingGroup.addBinding(autoBinding15);
    return bindingGroup;
}
Also used : DefaultListModel(javax.swing.DefaultListModel) JTextField(javax.swing.JTextField) JTextPane(javax.swing.JTextPane) BindingGroup(org.jdesktop.beansbinding.BindingGroup) MagicCollection(org.magic.api.beans.MagicCollection) MagicFormat(org.magic.api.beans.MagicFormat) JCheckBox(javax.swing.JCheckBox) MagicCard(org.magic.api.beans.MagicCard)

Example 4 with BindingGroup

use of org.jdesktop.beansbinding.BindingGroup in project MtgDesktopCompanion by nicho92.

the class MagicEditionDetailPanel method initDataBindings.

protected BindingGroup initDataBindings() {
    BeanProperty<MagicEdition, String> borderProperty = BeanProperty.create("border");
    BeanProperty<JTextField, String> textProperty2 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding2 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, borderProperty, borderJTextField, textProperty2);
    autoBinding2.bind();
    // 
    BeanProperty<MagicEdition, Integer> cardCountProperty = BeanProperty.create("cardCount");
    BeanProperty<JTextField, String> valueProperty = BeanProperty.create("text");
    AutoBinding<MagicEdition, Integer, JTextField, String> autoBinding3 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, cardCountProperty, cardCountTextField, valueProperty);
    autoBinding3.bind();
    // 
    BeanProperty<MagicEdition, String> releaseDateProperty = BeanProperty.create("releaseDate");
    BeanProperty<JTextField, String> textProperty6 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding7 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, releaseDateProperty, releaseDateJTextField, textProperty6);
    autoBinding7.bind();
    // 
    BeanProperty<MagicEdition, String> setProperty = BeanProperty.create("set");
    BeanProperty<JTextField, String> textProperty7 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding8 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, setProperty, setJTextField, textProperty7);
    autoBinding8.bind();
    // 
    BeanProperty<MagicEdition, String> typeProperty = BeanProperty.create("type");
    BeanProperty<JTextField, String> textProperty10 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding11 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, typeProperty, typeJTextField, textProperty10);
    autoBinding11.bind();
    BeanProperty<MagicEdition, String> blockProperty = BeanProperty.create("block");
    BeanProperty<JTextField, String> textProperty11 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding12 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, blockProperty, blockJTextField, textProperty11);
    autoBinding12.bind();
    BeanProperty<MagicEdition, String> idProperty = BeanProperty.create("id");
    BeanProperty<JTextField, String> textProperty12 = BeanProperty.create("text");
    AutoBinding<MagicEdition, String, JTextField, String> autoBinding13 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, idProperty, idJtextField, textProperty12);
    autoBinding13.bind();
    BeanProperty<MagicEdition, Boolean> onlineProperty = BeanProperty.create("onlineOnly");
    BeanProperty<JCheckBox, Boolean> chkProperty13 = BeanProperty.create("selected");
    AutoBinding<MagicEdition, Boolean, JCheckBox, Boolean> autoBinding14 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicEdition, onlineProperty, chkOnline, chkProperty13);
    autoBinding14.bind();
    // 
    BindingGroup bindingGroup = new BindingGroup();
    // 
    bindingGroup.addBinding(autoBinding2);
    bindingGroup.addBinding(autoBinding3);
    bindingGroup.addBinding(autoBinding7);
    bindingGroup.addBinding(autoBinding8);
    bindingGroup.addBinding(autoBinding11);
    bindingGroup.addBinding(autoBinding12);
    bindingGroup.addBinding(autoBinding13);
    bindingGroup.addBinding(autoBinding14);
    return bindingGroup;
}
Also used : MagicEdition(org.magic.api.beans.MagicEdition) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) BindingGroup(org.jdesktop.beansbinding.BindingGroup)

Example 5 with BindingGroup

use of org.jdesktop.beansbinding.BindingGroup in project MtgDesktopCompanion by nicho92.

the class MagicCardEditorPanel method initDataBindings.

protected BindingGroup initDataBindings() {
    BeanProperty<MagicCard, String> artistProperty = BeanProperty.create("artist");
    BeanProperty<JTextField, String> textProperty = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, artistProperty, artistJTextField, textProperty);
    autoBinding.bind();
    // 
    BeanProperty<MagicCard, String> costProperty = BeanProperty.create("cost");
    BeanProperty<JTextField, String> textProperty1 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding2 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, costProperty, costJTextField, textProperty1);
    autoBinding2.bind();
    // 
    BeanProperty<MagicCard, String> flavorProperty = BeanProperty.create("flavor");
    BeanProperty<JTextField, String> textProperty2 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding3 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, flavorProperty, flavorJTextField, textProperty2);
    autoBinding3.bind();
    // 
    BeanProperty<MagicCard, Boolean> flippableProperty = BeanProperty.create("flippable");
    BeanProperty<JCheckBox, Boolean> selectedProperty = BeanProperty.create("selected");
    AutoBinding<MagicCard, Boolean, JCheckBox, Boolean> autoBinding4 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, flippableProperty, flippableJCheckBox, selectedProperty);
    autoBinding4.bind();
    // 
    BeanProperty<MagicCard, String> gathererCodeProperty = BeanProperty.create("gathererCode");
    BeanProperty<JTextField, String> textProperty3 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding5 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, gathererCodeProperty, gathererCodeJTextField, textProperty3);
    autoBinding5.bind();
    // 
    BeanProperty<MagicCard, Object> layoutProperty = BeanProperty.create("layout");
    BeanProperty<JComboBox, Object> selectedIndexProperty = BeanProperty.create("selectedItem");
    AutoBinding<MagicCard, Object, JComboBox, Object> autoBinding6 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, layoutProperty, layoutJComboBox, selectedIndexProperty);
    autoBinding6.bind();
    // 
    BeanProperty<MagicCard, Object> loyaltyProperty = BeanProperty.create("loyalty");
    BeanProperty<JTextField, Object> valueProperty1 = BeanProperty.create("value");
    AutoBinding<MagicCard, Object, JTextField, Object> autoBinding7 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, loyaltyProperty, loyaltyJTextField, valueProperty1);
    autoBinding7.bind();
    // 
    BeanProperty<MagicCard, String> mciNumberProperty = BeanProperty.create("mciNumber");
    BeanProperty<JTextField, String> textProperty4 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding8 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, mciNumberProperty, mciNumberJTextField, textProperty4);
    autoBinding8.bind();
    // 
    BeanProperty<MagicCard, String> nameProperty = BeanProperty.create("name");
    BeanProperty<JTextField, String> textProperty5 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding10 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, nameProperty, nameJTextField, textProperty5);
    autoBinding10.bind();
    // 
    BeanProperty<MagicCard, String> numberProperty = BeanProperty.create("number");
    BeanProperty<JTextField, Object> valueProperty3 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, Object> autoBinding11 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, numberProperty, numberJTextField, valueProperty3);
    autoBinding11.bind();
    // 
    BeanProperty<MagicCard, String> powerProperty = BeanProperty.create("power");
    BeanProperty<JTextField, Object> valueProperty4 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, Object> autoBinding13 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, powerProperty, powerJTextField, valueProperty4);
    autoBinding13.bind();
    // 
    BeanProperty<MagicCard, Object> rarityProperty = BeanProperty.create("rarity");
    BeanProperty<JComboBox, Object> selectedIndexProperty1 = BeanProperty.create("selectedItem");
    AutoBinding<MagicCard, Object, JComboBox, Object> autoBinding14 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, rarityProperty, rarityJComboBox, selectedIndexProperty1);
    autoBinding14.bind();
    // 
    BeanProperty<MagicCard, String> rotatedCardNameProperty = BeanProperty.create("rotatedCardName");
    BeanProperty<JTextField, String> textProperty7 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding15 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, rotatedCardNameProperty, rotatedCardNameJTextField, textProperty7);
    autoBinding15.bind();
    // 
    BeanProperty<MagicCard, String> textProperty8 = BeanProperty.create("text");
    BeanProperty<JEditorPane, String> textProperty9 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JEditorPane, String> autoBinding16 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, textProperty8, textJEditorPane, textProperty9);
    autoBinding16.bind();
    // 
    BeanProperty<MagicCard, String> toughnessProperty = BeanProperty.create("toughness");
    BeanProperty<JTextField, Object> valueProperty5 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, Object> autoBinding17 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, toughnessProperty, toughnessJTextField, valueProperty5);
    autoBinding17.bind();
    // 
    BeanProperty<MagicCard, Boolean> tranformableProperty = BeanProperty.create("tranformable");
    BeanProperty<JCheckBox, Boolean> selectedProperty1 = BeanProperty.create("selected");
    AutoBinding<MagicCard, Boolean, JCheckBox, Boolean> autoBinding18 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, tranformableProperty, tranformableJCheckBox, selectedProperty1);
    autoBinding18.bind();
    // 
    BeanProperty<MagicCard, String> watermarksProperty = BeanProperty.create("watermarks");
    BeanProperty<JTextField, String> textProperty10 = BeanProperty.create("text");
    AutoBinding<MagicCard, String, JTextField, String> autoBinding19 = Bindings.createAutoBinding(UpdateStrategy.READ_WRITE, magicCard, watermarksProperty, watermarksJTextField, textProperty10);
    autoBinding19.bind();
    BindingGroup bindingGroup = new BindingGroup();
    // 
    bindingGroup.addBinding(autoBinding);
    bindingGroup.addBinding(autoBinding2);
    bindingGroup.addBinding(autoBinding3);
    bindingGroup.addBinding(autoBinding4);
    bindingGroup.addBinding(autoBinding5);
    bindingGroup.addBinding(autoBinding6);
    bindingGroup.addBinding(autoBinding7);
    bindingGroup.addBinding(autoBinding8);
    bindingGroup.addBinding(autoBinding10);
    bindingGroup.addBinding(autoBinding11);
    bindingGroup.addBinding(autoBinding13);
    bindingGroup.addBinding(autoBinding14);
    bindingGroup.addBinding(autoBinding15);
    bindingGroup.addBinding(autoBinding16);
    bindingGroup.addBinding(autoBinding17);
    bindingGroup.addBinding(autoBinding18);
    bindingGroup.addBinding(autoBinding19);
    return bindingGroup;
}
Also used : JComboBox(javax.swing.JComboBox) JTextField(javax.swing.JTextField) JCheckBox(javax.swing.JCheckBox) MagicCard(org.magic.api.beans.MagicCard) BindingGroup(org.jdesktop.beansbinding.BindingGroup) JEditorPane(javax.swing.JEditorPane)

Aggregations

BindingGroup (org.jdesktop.beansbinding.BindingGroup)8 JCheckBox (javax.swing.JCheckBox)6 JTextField (javax.swing.JTextField)6 GroupLayout (javax.swing.GroupLayout)3 JLabel (javax.swing.JLabel)3 JPanel (javax.swing.JPanel)3 JSpinner (javax.swing.JSpinner)3 SpinnerNumberModel (javax.swing.SpinnerNumberModel)3 AutoBinding (org.jdesktop.beansbinding.AutoBinding)3 Binding (org.jdesktop.beansbinding.Binding)3 MagicCard (org.magic.api.beans.MagicCard)3 PerformActionModel (apps.PerformActionModel)2 StartupActionsManager (apps.StartupActionsManager)2 ItemEvent (java.awt.event.ItemEvent)2 ItemListener (java.awt.event.ItemListener)2 Arrays (java.util.Arrays)2 JComponent (javax.swing.JComponent)2 LayoutStyle (javax.swing.LayoutStyle)2 InstanceManager (jmri.InstanceManager)2 PreferencesPanel (jmri.swing.PreferencesPanel)2