Search in sources :

Example 11 with PropertyVetoException

use of java.beans.PropertyVetoException in project JMRI by JMRI.

the class TableFrames method openBlockPathFrame.

protected void openBlockPathFrame(String sysName) {
    JInternalFrame frame = _blockPathMap.get(sysName);
    if (frame == null) {
        OBlock block = InstanceManager.getDefault(jmri.jmrit.logix.OBlockManager.class).getBySystemName(sysName);
        if (block == null) {
            return;
        }
        frame = makeBlockPathFrame(block);
        _blockPathMap.put(sysName, frame);
        frame.setVisible(true);
        _desktop.add(frame);
        frame.moveToFront();
    } else {
        frame.setVisible(true);
        try {
            frame.setIcon(false);
        } catch (PropertyVetoException pve) {
            log.warn("BlockPath Table Frame for \"" + sysName + "\" vetoed setIcon " + pve.toString());
        }
        frame.moveToFront();
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) OBlockManager(jmri.jmrit.logix.OBlockManager) JInternalFrame(javax.swing.JInternalFrame) OBlock(jmri.jmrit.logix.OBlock)

Example 12 with PropertyVetoException

use of java.beans.PropertyVetoException in project JMRI by JMRI.

the class TableFrames method updateOpenMenu.

protected void updateOpenMenu() {
    _openMenu.removeAll();
    JMenuItem openBlock = new JMenuItem(Bundle.getMessage("OpenBlockMenu"));
    _openMenu.add(openBlock);
    openBlock.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            _blockTableFrame.setVisible(true);
            try {
                _blockTableFrame.setIcon(false);
            } catch (PropertyVetoException pve) {
                log.warn("Block Table Frame vetoed setIcon " + pve.toString());
            }
            _blockTableFrame.moveToFront();
        }
    });
    JMenuItem openPortal = new JMenuItem(Bundle.getMessage("OpenPortalMenu"));
    _openMenu.add(openPortal);
    openPortal.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            _portalTableFrame.setVisible(true);
            try {
                _portalTableFrame.setIcon(false);
            } catch (PropertyVetoException pve) {
                log.warn("Portal Table Frame vetoed setIcon " + pve.toString());
            }
            _portalTableFrame.moveToFront();
        }
    });
    JMenuItem openXRef = new JMenuItem(Bundle.getMessage("OpenXRefMenu"));
    _openMenu.add(openXRef);
    openXRef.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            _blockPortalXRefFrame.setVisible(true);
            try {
                _blockPortalXRefFrame.setIcon(false);
            } catch (PropertyVetoException pve) {
                log.warn("XRef Table Frame vetoed setIcon " + pve.toString());
            }
            _blockPortalXRefFrame.moveToFront();
        }
    });
    JMenuItem openSignal = new JMenuItem(Bundle.getMessage("OpenSignalMenu"));
    _openMenu.add(openSignal);
    openSignal.addActionListener(new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent event) {
            _signalTableFrame.setVisible(true);
            try {
                _signalTableFrame.setIcon(false);
            } catch (PropertyVetoException pve) {
                log.warn("Signal Table Frame vetoed setIcon " + pve.toString());
            }
            _signalTableFrame.moveToFront();
        }
    });
    JMenu openBlockPath = new JMenu(Bundle.getMessage("OpenBlockPathMenu"));
    ActionListener openFrameAction = new ActionListener() {

        @Override
        public void actionPerformed(ActionEvent e) {
            String sysName = e.getActionCommand();
            openBlockPathFrame(sysName);
        }
    };
    OBlockManager manager = InstanceManager.getDefault(jmri.jmrit.logix.OBlockManager.class);
    String[] sysNames = manager.getSystemNameArray();
    for (int i = 0; i < sysNames.length; i++) {
        OBlock block = manager.getBySystemName(sysNames[i]);
        JMenuItem mi = new JMenuItem(Bundle.getMessage("OpenPathMenu", block.getDisplayName()));
        mi.setActionCommand(sysNames[i]);
        mi.addActionListener(openFrameAction);
        openBlockPath.add(mi);
    }
    _openMenu.add(openBlockPath);
    JMenu openTurnoutPath = new JMenu(Bundle.getMessage("OpenBlockPathTurnoutMenu"));
    sysNames = manager.getSystemNameArray();
    for (int i = 0; i < sysNames.length; i++) {
        OBlock block = manager.getBySystemName(sysNames[i]);
        JMenu openTurnoutMenu = new JMenu(Bundle.getMessage("OpenTurnoutMenu", block.getDisplayName()));
        openTurnoutPath.add(openTurnoutMenu);
        openFrameAction = new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                String pathTurnoutName = e.getActionCommand();
                openPathTurnoutFrame(pathTurnoutName);
            }
        };
        Iterator<Path> iter = block.getPaths().iterator();
        while (iter.hasNext()) {
            OPath path = (OPath) iter.next();
            JMenuItem mi = new JMenuItem(Bundle.getMessage("OpenPathTurnoutMenu", path.getName()));
            mi.setActionCommand(makePathTurnoutName(sysNames[i], path.getName()));
            mi.addActionListener(openFrameAction);
            openTurnoutMenu.add(mi);
        }
    }
    _openMenu.add(openTurnoutPath);
}
Also used : OPath(jmri.jmrit.logix.OPath) Path(jmri.Path) ActionEvent(java.awt.event.ActionEvent) OBlockManager(jmri.jmrit.logix.OBlockManager) OPath(jmri.jmrit.logix.OPath) Point(java.awt.Point) PropertyVetoException(java.beans.PropertyVetoException) ActionListener(java.awt.event.ActionListener) TransferActionListener(jmri.util.com.sun.TransferActionListener) JMenuItem(javax.swing.JMenuItem) OBlock(jmri.jmrit.logix.OBlock) JMenu(javax.swing.JMenu)

Example 13 with PropertyVetoException

use of java.beans.PropertyVetoException in project jdk8u_jdk by JetBrains.

the class BeanContextChildSupport method setBeanContext.

/**
     * Sets the <code>BeanContext</code> for
     * this <code>BeanContextChildSupport</code>.
     * @param bc the new value to be assigned to the <code>BeanContext</code>
     * property
     * @throws PropertyVetoException if the change is rejected
     */
public synchronized void setBeanContext(BeanContext bc) throws PropertyVetoException {
    if (bc == beanContext)
        return;
    BeanContext oldValue = beanContext;
    BeanContext newValue = bc;
    if (!rejectedSetBCOnce) {
        if (rejectedSetBCOnce = !validatePendingSetBeanContext(bc)) {
            throw new PropertyVetoException("setBeanContext() change rejected:", new PropertyChangeEvent(beanContextChildPeer, "beanContext", oldValue, newValue));
        }
        try {
            fireVetoableChange("beanContext", oldValue, newValue);
        } catch (PropertyVetoException pve) {
            rejectedSetBCOnce = true;
            // re-throw
            throw pve;
        }
    }
    if (beanContext != null)
        releaseBeanContextResources();
    beanContext = newValue;
    rejectedSetBCOnce = false;
    firePropertyChange("beanContext", oldValue, newValue);
    if (beanContext != null)
        initializeBeanContextResources();
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) PropertyChangeEvent(java.beans.PropertyChangeEvent)

Example 14 with PropertyVetoException

use of java.beans.PropertyVetoException in project JMRI by JMRI.

the class AbstractManager method vetoableChange.

@Override
@OverridingMethodsMustInvokeSuper
public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
    if ("CanDelete".equals(evt.getPropertyName())) {
        //IN18N
        StringBuilder message = new StringBuilder();
        message.append(Bundle.getMessage("VetoFoundIn", getBeanTypeHandled())).append("<ul>");
        boolean found = false;
        for (NamedBean nb : _tsys.values()) {
            try {
                nb.vetoableChange(evt);
            } catch (PropertyVetoException e) {
                if (e.getPropertyChangeEvent().getPropertyName().equals("DoNotDelete")) {
                    //IN18N
                    throw e;
                }
                found = true;
                message.append("<li>").append(e.getMessage()).append("</li>");
            }
        }
        message.append("</ul>").append(Bundle.getMessage("VetoWillBeRemovedFrom", getBeanTypeHandled()));
        if (found) {
            throw new PropertyVetoException(message.toString(), evt);
        }
    } else {
        for (NamedBean nb : _tsys.values()) {
            try {
                nb.vetoableChange(evt);
            } catch (PropertyVetoException e) {
                throw e;
            }
        }
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) NamedBean(jmri.NamedBean) OverridingMethodsMustInvokeSuper(javax.annotation.OverridingMethodsMustInvokeSuper)

Example 15 with PropertyVetoException

use of java.beans.PropertyVetoException in project sic by belluccifranco.

the class PedidosGUI method formInternalFrameOpened.

//GEN-LAST:event_tbl_PedidosMouseClicked
private void formInternalFrameOpened(javax.swing.event.InternalFrameEvent evt) {
    //GEN-FIRST:event_formInternalFrameOpened
    this.setSize(sizeInternalFrame);
    this.limpiarJTables();
    txt_NumeroPedido.setEnabled(false);
    dc_FechaDesde.setEnabled(false);
    dc_FechaHasta.setEnabled(false);
    cmb_Cliente.setEnabled(false);
    cmb_Vendedor.setEnabled(false);
    dc_FechaDesde.setDate(new Date());
    dc_FechaHasta.setDate(new Date());
    try {
        this.setMaximum(true);
    } catch (PropertyVetoException ex) {
        String mensaje = "Se produjo un error al intentar maximizar la ventana.";
        LOGGER.error(mensaje + " - " + ex.getMessage());
        JOptionPane.showInternalMessageDialog(this, mensaje, "Error", JOptionPane.ERROR_MESSAGE);
        this.dispose();
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) Date(java.util.Date)

Aggregations

PropertyVetoException (java.beans.PropertyVetoException)49 JInternalFrame (javax.swing.JInternalFrame)12 Date (java.util.Date)7 ComboPooledDataSource (com.mchange.v2.c3p0.ComboPooledDataSource)4 PropertyChangeEvent (java.beans.PropertyChangeEvent)4 Point (java.awt.Point)3 VetoableChangeListener (java.beans.VetoableChangeListener)3 SQLException (java.sql.SQLException)3 OBlock (jmri.jmrit.logix.OBlock)3 OBlockManager (jmri.jmrit.logix.OBlockManager)3 ActionEvent (java.awt.event.ActionEvent)2 IndexedPropertyChangeEvent (java.beans.IndexedPropertyChangeEvent)2 VetoableChangeSupport (java.beans.VetoableChangeSupport)2 File (java.io.File)2 IOException (java.io.IOException)2 BigDecimal (java.math.BigDecimal)2 PreparedStatement (java.sql.PreparedStatement)2 ResultSet (java.sql.ResultSet)2 Timestamp (java.sql.Timestamp)2 ArrayList (java.util.ArrayList)2