Search in sources :

Example 1 with PropertyVetoException

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

the class Test6630275 method main.

public static void main(String[] args) {
    CheckListener first = new CheckListener(false);
    CheckListener second = new CheckListener(true);
    CheckListener third = new CheckListener(false);
    VetoableChangeSupport vcs = new VetoableChangeSupport(Test6630275.class);
    vcs.addVetoableChangeListener(first);
    vcs.addVetoableChangeListener(PROPERTY, first);
    vcs.addVetoableChangeListener(PROPERTY, second);
    vcs.addVetoableChangeListener(PROPERTY, third);
    try {
        vcs.fireVetoableChange(PROPERTY, true, false);
    } catch (PropertyVetoException exception) {
        first.validate();
        second.validate();
        third.validate();
        // expected exception
        return;
    }
    throw new Error("exception should be thrown");
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) VetoableChangeSupport(java.beans.VetoableChangeSupport)

Example 2 with PropertyVetoException

use of java.beans.PropertyVetoException in project opennms by OpenNMS.

the class C3P0ConnectionFactory method initializePool.

@Override
protected void initializePool(final JdbcDataSource dataSource) throws SQLException {
    m_pool = new ComboPooledDataSource();
    m_pool.setPassword(dataSource.getPassword());
    m_pool.setUser(dataSource.getUserName());
    m_pool.setJdbcUrl(dataSource.getUrl());
    try {
        m_pool.setDriverClass(dataSource.getClassName());
    } catch (final PropertyVetoException e) {
        throw new SQLException("Unable to set driver class.", e);
    }
    final Properties properties = new Properties();
    for (final Param parameter : dataSource.getParamCollection()) {
        properties.put(parameter.getName(), parameter.getValue());
    }
    if (!properties.isEmpty()) {
        m_pool.setProperties(properties);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ComboPooledDataSource(com.mchange.v2.c3p0.ComboPooledDataSource) SQLException(java.sql.SQLException) Param(org.opennms.netmgt.config.opennmsDataSources.Param) Properties(java.util.Properties)

Example 3 with PropertyVetoException

use of java.beans.PropertyVetoException in project ACS by ACS-Community.

the class CommandCenterGui method prepare.

public void prepare() {
    boolean setLookAndFeel = false;
    if (setLookAndFeel) {
        String lafName = UIManager.getSystemLookAndFeelClassName();
        try {
            UIManager.setLookAndFeel(lafName);
        } catch (Exception exc) {
            log.fine("Couldn't set look and feel " + lafName + " due to " + exc);
        }
    }
    // title added later in doFrameTitle()
    frame = new JFrame("");
    frame.addWindowListener(new WindowAdapter() {

        @Override
        public void windowClosing(WindowEvent evt) {
            controller.stop();
        }
    });
    dlgContainerSettings = new EditContainerSettingsDialog(this);
    frontPanel = new TabPanel(this);
    writeModelToFrontPanel();
    // Splitter between tree and the rest
    splitLeftRight = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT);
    splitLeftRight.setOneTouchExpandable(true);
    JPanel p2 = new JPanel(new BorderLayout());
    p2.setBorder(new EmptyBorder(10, 10, 10, 10));
    p2.add(frontPanel, BorderLayout.NORTH);
    splitLeftRight.setLeftComponent(p2);
    // Deployment Tree
    deploymentInfoPanel = new JPanel(new BorderLayout());
    deploymentInfoPanel.setBorder(new CompoundBorder(new EmptyBorder(5, 7, 5, 7), new TitledBorder(LineBorder.createBlackLineBorder(), " Deployment Info ")));
    deployTree = new DeploymentTree(controller.deploymentTreeControllerImpl);
    JPanel addToDeployTree = new AddToDeployTree(this, deployTree);
    deploymentInfoPanel.add(addToDeployTree, BorderLayout.NORTH);
    deploymentInfoPanel.add(new JScrollPane(deployTree), BorderLayout.CENTER);
    splitLeftRight.setRightComponent(deploymentInfoPanel);
    // Feedback Area
    feedbackTabs = new FeedbackTabs(this, FeedbackTabs.BOTTOM);
    // Logo Panel
    JPanel logoPanel = new LogoPanel(COLOR_LogoBackground_A, COLOR_LogoBackground_B);
    logoPanel.setLayout(new BorderLayout());
    JLabel alma = new JLabel(new ImageIcon(controller.findResource("alma.jpg")));
    logoPanel.add(alma, BorderLayout.WEST);
    JLabel text = new JLabel("Acs Command Center");
    text.setForeground(COLOR_LogoForeground);
    text.setHorizontalTextPosition(SwingConstants.CENTER);
    text.setFont(text.getFont().deriveFont((float) (text.getFont().getSize() * 2.5)));
    text.setBorder(new EmptyBorder(5, 30, 5, 30));
    logoPanel.add(text, BorderLayout.CENTER);
    //		JLabel version = new JLabel(controller.version());
    //		version.setForeground(COLOR_LogoForeground);
    //		version.setBorder(new EmptyBorder(0, 0, 0, 4));
    //		JPanel pnl2 = new JPanel(new BorderLayout());
    //		pnl2.setOpaque(false);
    //		pnl2.add(version, BorderLayout.SOUTH);
    //		logoPanel.add(pnl2, BorderLayout.EAST);
    menuBar = new JMenuBar();
    JMenu fileMenu = new JMenu("Project");
    fileMenu.setMnemonic(KeyEvent.VK_P);
    {
        JMenu newMenu = new JMenu("New");
        newMenu.add(new ActionNewProject("Project"));
        fileMenu.add(newMenu);
    }
    fileMenu.add(new ActionOpenProject("Open..."));
    fileMenu.add(new ActionSaveProject("Save"));
    fileMenu.add(new ActionSaveAsProject("Save As..."));
    fileMenu.addSeparator();
    fileMenu.add(new ActionExit("Exit"));
    menuBar.add(fileMenu);
    toolsMenu = new JMenu("Tools");
    toolsMenu.setMnemonic(KeyEvent.VK_T);
    toolsMenu.add(new ActionConfigureTools("Configure Tools..."));
    toolsMenu.addSeparator();
    menuBar.add(toolsMenu);
    // ---
    JMenu extrasMenu = new JMenu("Expert");
    extrasMenu.setMnemonic(KeyEvent.VK_E);
    {
        //				JMenu sshMode = new JMenu("SSH Library");
        //				sshMode.add(new ActionSetSshMode("Platform-independent", false, false));
        //				sshMode.add(new ActionSetSshMode("Natively installed ssh", true, true));
        //				extrasMenu.add(sshMode);
        //				extrasMenu.add(new JSeparator());
        JMenu extraTools = new JMenu("Tools Menu");
        extraTools.add(new ActionShowExtraTools("View..."));
        extraTools.add(new ActionInstallExtraTools("Replace..."));
        extrasMenu.add(extraTools);
        JMenu builtinTools = new JMenu("Acs Scripts");
        builtinTools.add(new ActionShowBuiltinTools("View..."));
        builtinTools.add(new ActionLoadBuiltinTools("Replace..."));
        extrasMenu.add(builtinTools);
    }
    extrasMenu.add(new JSeparator());
    extrasMenu.add(new ActionShowVariables("Variables..."));
    menuBar.add(extrasMenu);
    // ---
    JMenuItem item;
    JMenu helpMenu = new JMenu("Help");
    helpMenu.setMnemonic(KeyEvent.VK_H);
    item = helpMenu.add(new ActionShowHelp("Online Help"));
    item.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F1, 0));
    item = helpMenu.add(new ActionShowAbout("About"));
    menuBar.add(Box.createHorizontalGlue());
    menuBar.add(helpMenu);
    // ---
    JPanel h = new JPanel(new SpringLayout());
    h.add(logoPanel);
    h.add(menuBar);
    SpringUtilities.makeCompactGrid(h, 0, 1);
    frame.getContentPane().add(h, BorderLayout.NORTH);
    // ---
    pnlManagerLocationForTools = new ManagerLocationPanel.ForTools();
    managerLocationDialog1 = new BasicDialog(this, "Specify Manager and Services for Tools", "Set", pnlManagerLocationForTools);
    // ---
    pnlManagerLocationForContainers = new ManagerLocationPanel.ForContainers();
    managerLocationDialog2 = new BasicDialog(this, "Specify Manager and Services for Containers", "Set", pnlManagerLocationForContainers);
    // ---
    splitTopBottom = new JSplitPane(JSplitPane.VERTICAL_SPLIT, splitLeftRight, feedbackTabs);
    splitTopBottom.setOneTouchExpandable(true);
    // --- 
    // 2009-04: Introducing a desktop layout so i can make the
    // progress dialog a lightweight window on top the front panel
    AccInternalFrame bigInternalFrame = new AccInternalFrame();
    bigInternalFrame.add(splitTopBottom);
    desktop = new JDesktopPane();
    bigInternalFrame.setVisible(true);
    desktop.add(bigInternalFrame);
    frame.getContentPane().add(desktop, BorderLayout.CENTER);
    try {
        bigInternalFrame.setSelected(true);
        bigInternalFrame.setMaximum(true);
    } catch (PropertyVetoException exc) {
    }
    // for mysterious swing reasons, the desktop has a preferred size
    // of (1,1) instead of picking up the preferred size of its child
    // component, so i'm doing this manually here.
    desktop.setPreferredSize(bigInternalFrame.getPreferredSize());
    doFrameTitle();
}
Also used : JPanel(javax.swing.JPanel) ImageIcon(javax.swing.ImageIcon) JDesktopPane(javax.swing.JDesktopPane) WindowAdapter(java.awt.event.WindowAdapter) TitledBorder(javax.swing.border.TitledBorder) JSeparator(javax.swing.JSeparator) BorderLayout(java.awt.BorderLayout) JFrame(javax.swing.JFrame) CompoundBorder(javax.swing.border.CompoundBorder) EmptyBorder(javax.swing.border.EmptyBorder) JMenuItem(javax.swing.JMenuItem) JScrollPane(javax.swing.JScrollPane) JLabel(javax.swing.JLabel) PropertyVetoException(java.beans.PropertyVetoException) UnresolvableException(alma.acs.commandcenter.util.VariableString.UnresolvableException) PropertyVetoException(java.beans.PropertyVetoException) WindowEvent(java.awt.event.WindowEvent) SpringLayout(javax.swing.SpringLayout) JSplitPane(javax.swing.JSplitPane) JMenuBar(javax.swing.JMenuBar) JMenu(javax.swing.JMenu)

Example 4 with PropertyVetoException

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

the class VPAttribute method actionPerformed.

//  addActionListener
/**
	 * 	Action Listener - start dialog
	 * 	@param e Event
	 */
public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals(RecordInfo.CHANGE_LOG_COMMAND)) {
        RecordInfo.start(m_GridField);
        return;
    }
    if (!m_button.isEnabled())
        return;
    m_button.setEnabled(false);
    //
    Integer oldValue = 0;
    try {
        oldValue = (Integer) getValue();
    } catch (ClassCastException cce) {
    // Possible Invalid Cast exception if getValue() return new instance of Object.
    }
    int oldValueInt = oldValue == null ? 0 : oldValue.intValue();
    int M_AttributeSetInstance_ID = oldValueInt;
    int M_Product_ID = 0;
    int M_ProductBOM_ID = 0;
    if (m_GridTab != null) {
        M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_Product_ID");
        M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, m_GridTab.getTabNo(), "M_ProductBOM_ID");
    } else {
        M_Product_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_Product_ID");
        M_ProductBOM_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "M_ProductBOM_ID");
    }
    int M_Locator_ID = -1;
    log.config("M_Product_ID=" + M_Product_ID + "/" + M_ProductBOM_ID + ",M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID + ", AD_Column_ID=" + m_AD_Column_ID);
    //	M_Product.M_AttributeSetInstance_ID = 8418
    //	HARDCODED
    boolean productWindow = m_AD_Column_ID == 8418;
    //	Exclude ability to enter ASI
    boolean exclude = false;
    if (M_Product_ID != 0) {
        MProduct product = MProduct.get(Env.getCtx(), M_Product_ID);
        int M_AttributeSet_ID = product.getM_AttributeSet_ID();
        if (M_AttributeSet_ID != 0) {
            MAttributeSet mas = MAttributeSet.get(Env.getCtx(), M_AttributeSet_ID);
            exclude = mas.excludeEntry(m_AD_Column_ID, Env.isSOTrx(Env.getCtx(), m_WindowNo));
        }
    }
    boolean changed = false;
    if (//	Use BOM Component
    M_ProductBOM_ID != 0)
        M_Product_ID = M_ProductBOM_ID;
    // If the VPAttribute component is in a dialog, use the search
    if (m_searchOnly) {
        // The component is an element in a CPanel, which is part of a JPanel
        // which is in a JLayeredPane which is in ...  the InfoProduct window
        Container me = ((Container) this).getParent();
        while (me != null) {
            if (me instanceof InfoProduct)
                break;
            me = me.getParent();
        }
        InfoPAttribute ia = new InfoPAttribute((CDialog) me);
        m_pAttributeWhere = ia.getWhereClause();
        String oldText = m_text.getText();
        m_text.setText(ia.getDisplay());
        // The text can be long.  Use the tooltip to help display the info.
        m_text.setToolTipText(m_text.getText());
        ActionEvent ae = new ActionEvent(m_text, 1001, "updated");
        //  TODO not the generally correct way to fire an event
        ((InfoProduct) me).actionPerformed(ae);
    } else if (!productWindow && (M_Product_ID == 0 || exclude)) {
        changed = true;
        m_text.setText(null);
        M_AttributeSetInstance_ID = 0;
    } else {
        VPAttributeDialog vad = new VPAttributeDialog(Env.getFrame(this), M_AttributeSetInstance_ID, M_Product_ID, m_C_BPartner_ID, productWindow, m_AD_Column_ID, m_WindowNo, isReadWrite());
        if (vad.isChanged()) {
            m_text.setText(vad.getM_AttributeSetInstanceName());
            // The text can be long.  Use the tooltip to help display the info.
            m_text.setToolTipText(vad.getM_AttributeSetInstanceName());
            M_AttributeSetInstance_ID = vad.getM_AttributeSetInstance_ID();
            if (!productWindow && vad.getM_Locator_ID() > 0) {
                M_Locator_ID = vad.getM_Locator_ID();
            }
            changed = true;
        }
    }
    //	Set Value
    if (changed) {
        log.finest("Changed M_AttributeSetInstance_ID=" + M_AttributeSetInstance_ID);
        //	force re-query display
        m_value = new Object();
        if (M_AttributeSetInstance_ID == 0)
            setValue(null);
        else
            setValue(new Integer(M_AttributeSetInstance_ID));
        // Change Locator
        if (m_GridTab != null && M_Locator_ID > 0) {
            log.finest("Change M_Locator_ID=" + M_Locator_ID);
            m_GridTab.setValue("M_Locator_ID", M_Locator_ID);
        }
        //
        try {
            String columnName = "M_AttributeSetInstance_ID";
            if (m_GridField != null) {
                columnName = m_GridField.getColumnName();
            }
            fireVetoableChange(columnName, new Object(), getValue());
        } catch (PropertyVetoException pve) {
            log.log(Level.SEVERE, "", pve);
        }
        if (M_AttributeSetInstance_ID == oldValueInt && m_GridTab != null && m_GridField != null) {
            //  force Change - user does not realize that embedded object is already saved.
            m_GridTab.processFieldChange(m_GridField);
        }
    }
    //	change
    m_button.setEnabled(true);
    requestFocus();
}
Also used : MProduct(org.compiere.model.MProduct) ActionEvent(java.awt.event.ActionEvent) MAttributeSet(org.compiere.model.MAttributeSet) PropertyVetoException(java.beans.PropertyVetoException) Container(java.awt.Container) InfoProduct(org.compiere.apps.search.InfoProduct) InfoPAttribute(org.compiere.apps.search.InfoPAttribute)

Example 5 with PropertyVetoException

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

the class VAccount method cmd_text.

/**
	 *	Text - try to find Alias or start Dialog
	 */
public void cmd_text() {
    if (m_cmdTextRunning)
        return;
    m_cmdTextRunning = true;
    String text = m_text.getText();
    log.info("Text=" + text);
    if (text == null || text.length() == 0 || text.equals("%")) {
        cmd_button();
        m_cmdTextRunning = false;
        return;
    }
    if (!text.endsWith("%"))
        text += "%";
    //
    String sql = "SELECT C_ValidCombination_ID FROM C_ValidCombination " + "WHERE C_AcctSchema_ID=?" + " AND (UPPER(Alias) LIKE ? OR UPPER(Combination) LIKE ?)";
    sql = MRole.getDefault().addAccessSQL(sql, "C_ValidCombination", MRole.SQL_NOTQUALIFIED, MRole.SQL_RO);
    int C_AcctSchema_ID = Env.getContextAsInt(Env.getCtx(), m_WindowNo, "C_AcctSchema_ID");
    //
    int C_ValidCombination_ID = 0;
    PreparedStatement pstmt = null;
    try {
        pstmt = DB.prepareStatement(sql, null);
        pstmt.setInt(1, C_AcctSchema_ID);
        pstmt.setString(2, text.toUpperCase());
        pstmt.setString(3, text.toUpperCase());
        ResultSet rs = pstmt.executeQuery();
        if (rs.next()) {
            C_ValidCombination_ID = rs.getInt(1);
            if (//	only one
            rs.next())
                C_ValidCombination_ID = 0;
        }
        rs.close();
        pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        log.log(Level.SEVERE, sql, e);
    }
    try {
        if (pstmt != null)
            pstmt.close();
        pstmt = null;
    } catch (Exception e) {
        pstmt = null;
    }
    //	We have a Value
    if (C_ValidCombination_ID > 0) {
        Integer newValue = new Integer(C_ValidCombination_ID);
        //	set & redisplay
        setValue(newValue);
        //	Data Binding
        try {
            fireVetoableChange(m_columnName, null, newValue);
        } catch (PropertyVetoException pve) {
        }
    } else
        cmd_button();
    m_cmdTextRunning = false;
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) ResultSet(java.sql.ResultSet) PreparedStatement(java.sql.PreparedStatement) PropertyVetoException(java.beans.PropertyVetoException)

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