Java Code Examples for java.beans.PropertyVetoException

The following are top voted examples for showing how to use java.beans.PropertyVetoException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: buffer-slayer   File: AbstractBatchJdbcTemplateBenchmark.java   Source Code and License 7 votes vote down vote up
@Setup
public void setup() throws PropertyVetoException {
  dataSource = new DriverManagerDataSource();
  dataSource.setDriverClassName("com.mysql.jdbc.Driver");
  dataSource.setUrl(propertyOr("jdbcUrl", "jdbc:mysql://127.0.0.1:3306?useSSL=false"));
  dataSource.setUsername(propertyOr("username", "root"));
  dataSource.setPassword(propertyOr("password", "root"));

  JdbcTemplate delegate = new JdbcTemplate(dataSource);
  delegate.setDataSource(dataSource);

  proxy = new SenderProxy(new JdbcTemplateSender(delegate));
  proxy.onMessages(updated -> counter.addAndGet(updated.size()));

  reporter = reporter(proxy);
  batch = new BatchJdbcTemplate(delegate, reporter);
  batch.setDataSource(dataSource);

  unbatch = new JdbcTemplate(dataSource);
  unbatch.setDataSource(dataSource);
  unbatch.update(CREATE_DATABASE);
  unbatch.update(DROP_TABLE);
  unbatch.update(CREATE_TABLE);
}
 
Example 2
Project: NBANDROID-V2   File: SdksCustomizer.java   Source Code and License 7 votes vote down vote up
private static void expandAllNodes(BeanTreeView btv, Node node, ExplorerManager mgr, AndroidSdk platform) {
    btv.expandNode(node);
    Children ch = node.getChildren();
    if (ch == Children.LEAF) {
        if (platform != null && platform.equals(node.getLookup().lookup(AndroidSdk.class))) {
            try {
                mgr.setSelectedNodes(new Node[]{node});
            } catch (PropertyVetoException e) {
                //Ignore it
            }
        }
        return;
    }
    Node nodes[] = ch.getNodes(true);
    for (int i = 0; i < nodes.length; i++) {
        expandAllNodes(btv, nodes[i], mgr, platform);
    }

}
 
Example 3
Project: incubator-netbeans   File: BaseCaretTest.java   Source Code and License 6 votes vote down vote up
public static void prepareTest(String[] additionalLayers, Object[] additionalLookupContent) throws IOException, SAXException, PropertyVetoException {
    Collection<URL> allUrls = new ArrayList<URL>();
    for (String u : additionalLayers) {
        if (u.charAt(0) == '/') {
            u = u.substring(1);
        }
        for (Enumeration<URL> en = Thread.currentThread().getContextClassLoader().getResources(u); en.hasMoreElements(); ) {
            allUrls.add(en.nextElement());
        }
    }
    XMLFileSystem system = new XMLFileSystem();
    system.setXmlUrls(allUrls.toArray(new URL[allUrls.size()]));
    
    Repository repository = new Repository(system);
    Object[] lookupContent = new Object[additionalLookupContent.length + 1];
    
    System.arraycopy(additionalLookupContent, 0, lookupContent, 1, additionalLookupContent.length);
    
    lookupContent[0] = repository;
    
    setLookup(lookupContent, BaseCaretTest.class.getClassLoader());
}
 
Example 4
Project: incubator-netbeans   File: GuardedSectionManagerTest.java   Source Code and License 6 votes vote down vote up
public void testRenameInteriorSection() throws BadLocationException, PropertyVetoException {
    System.out.println("-- testRenameInteriorSection -------------");
    
    editor.doc.insertString(0, "aaa", null);
    InteriorSection is1 = guards.createInteriorSection(editor.doc.createPosition(1), "is1");
    assertEquals("name", "is1", is1.getName());
    is1.setName("isNewName");
    assertTrue("valid", is1.isValid());
    assertEquals("new name", "isNewName", is1.getName());
    // set the same name
    is1.setName("isNewName");
    
    InteriorSection is2 = guards.createInteriorSection(
            editor.doc.createPosition(is1.getEndPosition().getOffset() + 1),
            "is2");
    
    // rename to existing name
    try {
        is1.setName("is2");
        fail("accepted already existing name");
    } catch (PropertyVetoException ex) {
        assertTrue("valid", is1.isValid());
        assertEquals("name", "isNewName", is1.getName());
    }
}
 
Example 5
Project: openjdk-jdk10   File: KeyboardFocusManager.java   Source Code and License 6 votes vote down vote up
/**
 * Sets the active Window. Only a Frame or a Dialog can be the active
 * Window. The native windowing system may denote the active Window or its
 * children with special decorations, such as a highlighted title bar. The
 * active Window is always either the focused Window, or the first Frame or
 * Dialog that is an owner of the focused Window.
 * <p>
 * This method does not actually change the active Window as far as the
 * native windowing system is concerned. It merely stores the value to be
 * subsequently returned by {@code getActiveWindow()}. Use
 * {@code Component.requestFocus()} or
 * {@code Component.requestFocusInWindow()} to change the active
 * Window, subject to platform limitations.
 *
 * @param activeWindow the active Window
 * @see #getActiveWindow
 * @see #getGlobalActiveWindow
 * @see Component#requestFocus()
 * @see Component#requestFocusInWindow()
 * @throws SecurityException if this KeyboardFocusManager is not the
 *         current KeyboardFocusManager for the calling thread's context
 *         and if the calling thread does not have "replaceKeyboardFocusManager"
 *         permission
 */
protected void setGlobalActiveWindow(Window activeWindow)
    throws SecurityException
{
    Window oldActiveWindow;
    synchronized (KeyboardFocusManager.class) {
        checkKFMSecurity();

        oldActiveWindow = getActiveWindow();
        if (focusLog.isLoggable(PlatformLogger.Level.FINER)) {
            focusLog.finer("Setting global active window to " + activeWindow + ", old active " + oldActiveWindow);
        }

        try {
            fireVetoableChange("activeWindow", oldActiveWindow,
                               activeWindow);
        } catch (PropertyVetoException e) {
            // rejected
            return;
        }

        KeyboardFocusManager.activeWindow = activeWindow;
    }

    firePropertyChange("activeWindow", oldActiveWindow, activeWindow);
}
 
Example 6
Project: incubator-netbeans   File: OutlineView.java   Source Code and License 6 votes vote down vote up
/**
 * Called when selection in tree is changed.
 */
private void callSelectionChanged (Node[] nodes) {
    manager.removePropertyChangeListener (wlpc);
    manager.removeVetoableChangeListener (wlvc);
    try {
        manager.setSelectedNodes(nodes);
    } catch (PropertyVetoException e) {
        synchronizeSelectedNodes(false);
    } finally {
        // to be sure not to add them twice!
        manager.removePropertyChangeListener (wlpc);
        manager.removeVetoableChangeListener (wlvc);
        manager.addPropertyChangeListener (wlpc);
        manager.addVetoableChangeListener (wlvc);
    }
}
 
Example 7
Project: incubator-netbeans   File: PhadhailViews.java   Source Code and License 6 votes vote down vote up
private static Component nodeBasedView(Node root) {
    Node root2;
    if (Children.MUTEX == Mutex.EVENT) {
        // #35833 branch.
        root2 = root;
    } else {
        root2 = new EQReplannedNode(root);
    }
    ExpPanel p = new ExpPanel();
    p.setLayout(new BorderLayout());
    JComponent tree = new BeanTreeView();
    p.add(tree, BorderLayout.CENTER);
    p.getExplorerManager().setRootContext(root2);
    try {
        p.getExplorerManager().setSelectedNodes(new Node[] {root2});
    } catch (PropertyVetoException pve) {
        pve.printStackTrace();
    }
    Object key = "org.openide.actions.PopupAction";
    KeyStroke ks = KeyStroke.getKeyStroke("shift F10");
    tree.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT).put(ks, key);
    return p;
}
 
Example 8
Project: incubator-netbeans   File: WindowBuilders.java   Source Code and License 6 votes vote down vote up
protected JInternalFrame createInstanceImpl() {
    JInternalFrame frame = new JInternalFrame(title, resizable, closable, maximizable, iconable) {
        protected JRootPane createRootPane() {
            return _rootPane == null ? null : _rootPane.createInstance();
        }
        public void addNotify() {
            try {
                // Doesn't seem to work correctly
                setClosed(_isClosed);
                setMaximum(_isMaximum);
                setIcon(_isIcon);
                setSelected(_isSelected);
            } catch (PropertyVetoException ex) {}
        }
    };
    return frame;
}
 
Example 9
Project: incubator-netbeans   File: XMLFileSystem.java   Source Code and License 6 votes vote down vote up
/** Initializes the root of FS.
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    //ois.defaultReadObject ();
    ObjectInputStream.GetField fields = ois.readFields();
    URL[] urls = (URL[]) fields.get("urlsToXml", null); // NOI18N

    if (urls == null) {
        urls = new URL[1];
        urls[0] = (URL) fields.get("uriId", null); // NOI18N
        if (urls[0] == null) {
            throw new IOException("missing uriId"); // NOI18N
        }
    }

    try {
        setXmlUrls(urls);
    } catch (PropertyVetoException ex) {
        IOException x = new IOException(ex.getMessage());
        ExternalUtil.copyAnnotation(x, ex);
        throw x;
    }
}
 
Example 10
Project: jdk8u-jdk   File: JInternalFrame.java   Source Code and License 6 votes vote down vote up
/**
 * Iconifies or de-iconifies this internal frame,
 * if the look and feel supports iconification.
 * If the internal frame's state changes to iconified,
 * this method fires an <code>INTERNAL_FRAME_ICONIFIED</code> event.
 * If the state changes to de-iconified,
 * an <code>INTERNAL_FRAME_DEICONIFIED</code> event is fired.
 *
 * @param b a boolean, where <code>true</code> means to iconify this internal frame and
 *          <code>false</code> means to de-iconify it
 * @exception PropertyVetoException when the attempt to set the
 *            property is vetoed by the <code>JInternalFrame</code>
 *
 * @see InternalFrameEvent#INTERNAL_FRAME_ICONIFIED
 * @see InternalFrameEvent#INTERNAL_FRAME_DEICONIFIED
 *
 * @beaninfo
 *           bound: true
 *     constrained: true
 *     description: The image displayed when this internal frame is minimized.
 */
public void setIcon(boolean b) throws PropertyVetoException {
    if (isIcon == b) {
        return;
    }

    /* If an internal frame is being iconified before it has a
       parent, (e.g., client wants it to start iconic), create the
       parent if possible so that we can place the icon in its
       proper place on the desktop. I am not sure the call to
       validate() is necessary, since we are not going to display
       this frame yet */
    firePropertyChange("ancestor", null, getParent());

    Boolean oldValue = isIcon ? Boolean.TRUE : Boolean.FALSE;
    Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
    fireVetoableChange(IS_ICON_PROPERTY, oldValue, newValue);
    isIcon = b;
    firePropertyChange(IS_ICON_PROPERTY, oldValue, newValue);
    if (b)
      fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ICONIFIED);
    else
      fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED);
}
 
Example 11
Project: lembredio   File: TelaInicial.java   Source Code and License 6 votes vote down vote up
/**
 * Creates new form TelaInicial
 */


public TelaInicial() throws PropertyVetoException, IOException {
    initComponents();
    this.setLocationRelativeTo(null);
    jDesktopPane3.add(obj);
    obj.setMaximizable(true);
    obj.setMaximum(true);
    obj.setVisible(true);
    getContentPane().setBackground(Color.WHITE);
   
    File file = new File("CADASTRADOS.txt");
   if(!file.exists()){
    file.createNewFile();// TODO code application logic here
   }
   File dir = new File("CadastroRemedios");
   if(!dir.exists()){
       dir.mkdir();
   }
    //this.setExtendedState(MAXIMIZED_BOTH);
    //jDesktopPane3.setExtendedState(MAXIMIZED_BOTH);
   //obj.setLocation(jDesktopPane3.getSize().width/2 - obj.getSize().width/2,jDesktopPane3.getSize().height/2 - obj.getSize().height/2);

}
 
Example 12
Project: otus_java_2017_06   File: Main.java   Source Code and License 6 votes vote down vote up
public static void main(String[] args) throws PropertyVetoException, SQLException, InterruptedException {
    //DataSourceFactory factory = new C3P0DataSourceFactory();
    //DataSourceFactory factory = new DBCPDataSourceFactory();
    DataSourceFactory factory = new HikariCPDataSourceFactory();

    Connection connection = factory.get().getConnection();
    System.out.println("DatabaseProductName: " + connection.getMetaData().getDatabaseProductName());

    Connection connection2 = factory.get().getConnection();
    System.out.println("DriverName: " + connection2.getMetaData().getDriverName());

    Connection connection3 = factory.get().getConnection();
    System.out.println("URL: " + connection3.getMetaData().getURL());

    hold();
}
 
Example 13
Project: incubator-netbeans   File: JarFileSystem.java   Source Code and License 6 votes vote down vote up
/** Initializes the root of FS.
*/
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException {
    ois.defaultReadObject();
    closeSync = new Object();
    strongCache = null;
    softCache = new SoftReference<Cache>(null);
    aliveCount = 0;

    try {
        setJarFile(root);
    } catch (PropertyVetoException ex) {
        throw new IOException(ex.getMessage());
    } catch (IOException iex) {
        ExternalUtil.log(iex.getLocalizedMessage());
    }
}
 
Example 14
Project: incubator-netbeans   File: URLMapperTest.java   Source Code and License 6 votes vote down vote up
public void testPlusInName() throws IOException, PropertyVetoException {
    clearWorkDir();
    File plus = new File(getWorkDir(), "plus+plus");
    plus.createNewFile();
    LocalFileSystem lfs = new LocalFileSystem();
    lfs.setRootDirectory(getWorkDir());
    Repository.getDefault().addFileSystem(lfs);
    
    URL uPlus = BaseUtilities.toURI(plus).toURL();
    FileObject fo = URLMapper.findFileObject(uPlus);
    assertNotNull("File object found", fo);
    assertEquals("plus+plus", fo.getNameExt());
    
    URL back = URLMapper.findURL(fo, URLMapper.EXTERNAL);
    assertTrue("plus+plus is there", back.getPath().endsWith("plus+plus"));
}
 
Example 15
Project: JavaStudy   File: MineC3P0DataSource.java   Source Code and License 5 votes vote down vote up
public MineC3P0DataSource(boolean autoregister) {
    super(autoregister);
    this.dmds = new DriverManagerDataSource();
    this.wcpds = new WrapperConnectionPoolDataSource();
    this.wcpds.setNestedDataSource(this.dmds);

    try {
        this.setConnectionPoolDataSource(this.wcpds);
    } catch (PropertyVetoException var3) {
        logger.log(MLevel.WARNING, "Hunh??? This can\'t happen. We haven\'t set up any listeners to veto the property change yet!", var3);
        throw new RuntimeException("Hunh??? This can\'t happen. We haven\'t set up any listeners to veto the property change yet! " + var3);
    }

    this.setUpPropertyEvents();
}
 
Example 16
Project: spanner-jdbc   File: CloudSpannerIT.java   Source Code and License 5 votes vote down vote up
private void performJdbcTests() throws Exception
{
	// Get a JDBC connection
	try (Connection connection = createConnection())
	{
		connection.setAutoCommit(false);
		// Test connection pooling
		ConnectionPoolingTester poolingTester = new ConnectionPoolingTester();
		poolingTester.testPooling((CloudSpannerConnection) connection);

		// Test Table DDL statements
		TableDDLTester tableDDLTester = new TableDDLTester(connection);
		tableDDLTester.runCreateTests();
		// Test DML statements
		DMLTester dmlTester = new DMLTester(connection);
		dmlTester.runDMLTests();
		// Test meta data functions
		MetaDataTester metaDataTester = new MetaDataTester(connection);
		metaDataTester.runMetaDataTests();
		// Test transaction functions
		TransactionTester txTester = new TransactionTester(connection);
		txTester.runTransactionTests();
		// Test select statements
		SelectStatementsTester selectTester = new SelectStatementsTester(connection);
		selectTester.runSelectTests();
		// Test XA transactions
		XATester xaTester = new XATester();
		xaTester.testXA(projectId, instanceId, DATABASE_ID, credentialsPath);

		// Test drop statements
		tableDDLTester.runDropTests();
	}
	catch (SQLException | PropertyVetoException e)
	{
		log.log(Level.WARNING, "Error during JDBC tests", e);
		throw e;
	}
}
 
Example 17
Project: jdk8u-jdk   File: KeyboardFocusManager.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the focused Window. The focused Window is the Window that is or
 * contains the focus owner. The operation will be cancelled if the
 * specified Window to focus is not a focusable Window.
 * <p>
 * This method does not actually change the focused Window as far as the
 * native windowing system is concerned. It merely stores the value to be
 * subsequently returned by <code>getFocusedWindow()</code>. Use
 * <code>Component.requestFocus()</code> or
 * <code>Component.requestFocusInWindow()</code> to change the focused
 * Window, subject to platform limitations.
 *
 * @param focusedWindow the focused Window
 * @see #getFocusedWindow
 * @see #getGlobalFocusedWindow
 * @see Component#requestFocus()
 * @see Component#requestFocusInWindow()
 * @see Window#isFocusableWindow
 * @throws SecurityException if this KeyboardFocusManager is not the
 *         current KeyboardFocusManager for the calling thread's context
 *         and if the calling thread does not have "replaceKeyboardFocusManager"
 *         permission
 * @beaninfo
 *       bound: true
 */
protected void setGlobalFocusedWindow(Window focusedWindow)
    throws SecurityException
{
    Window oldFocusedWindow = null;
    boolean shouldFire = false;

    if (focusedWindow == null || focusedWindow.isFocusableWindow()) {
        synchronized (KeyboardFocusManager.class) {
            checkKFMSecurity();

            oldFocusedWindow = getFocusedWindow();

            try {
                fireVetoableChange("focusedWindow", oldFocusedWindow,
                                   focusedWindow);
            } catch (PropertyVetoException e) {
                // rejected
                return;
            }

            KeyboardFocusManager.focusedWindow = focusedWindow;
            shouldFire = true;
        }
    }

    if (shouldFire) {
        firePropertyChange("focusedWindow", oldFocusedWindow,
                           focusedWindow);
    }
}
 
Example 18
Project: adept   File: C3p0DataSourceConfig.java   Source Code and License 5 votes vote down vote up
/**
 * 通过基础配置信息构建DBCP数据源信息.
 * @param driver 数据库连接的JDBC驱动
 * @param url 数据库连接的url
 * @param user 数据库连接的用户名
 * @param password 数据库连接的密码
 */
public ComboPooledDataSource buildDataSource(String driver, String url, String user, String password) {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    try {
        dataSource.setDriverClass(driver);
    } catch (PropertyVetoException e) {
        log.error("设置C3P0数据源的DriverClass出错!", e);
    }
    dataSource.setJdbcUrl(url);
    dataSource.setUser(user);
    dataSource.setPassword(password);
    return dataSource;
}
 
Example 19
Project: incubator-netbeans   File: AbstractSearchResultsPanel.java   Source Code and License 5 votes vote down vote up
private void shift(int direction) {

        Node next = findShiftNode(direction, getOutlineView(), true);
        if (next != null) {
            try {
                getExplorerManager().setSelectedNodes(new Node[]{next});
                onDetailShift(next);
            } catch (PropertyVetoException pve) {
                Exceptions.printStackTrace(pve);
            }
        }
    }
 
Example 20
Project: jdk8u-jdk   File: WindowsDesktopManager.java   Source Code and License 5 votes vote down vote up
public void activateFrame(JInternalFrame f) {
    JInternalFrame currentFrame = currentFrameRef != null ?
        currentFrameRef.get() : null;
    try {
        super.activateFrame(f);
        if (currentFrame != null && f != currentFrame) {
            // If the current frame is maximized, transfer that
            // attribute to the frame being activated.
            if (currentFrame.isMaximum() &&
                (f.getClientProperty("JInternalFrame.frameType") !=
                "optionDialog") ) {
                //Special case.  If key binding was used to select next
                //frame instead of minimizing the icon via the minimize
                //icon.
                if (!currentFrame.isIcon()) {
                    currentFrame.setMaximum(false);
                    if (f.isMaximizable()) {
                        if (!f.isMaximum()) {
                            f.setMaximum(true);
                        } else if (f.isMaximum() && f.isIcon()) {
                            f.setIcon(false);
                        } else {
                            f.setMaximum(false);
                        }
                    }
                }
            }
            if (currentFrame.isSelected()) {
                currentFrame.setSelected(false);
            }
        }

        if (!f.isSelected()) {
            f.setSelected(true);
        }
    } catch (PropertyVetoException e) {}
    if (f != currentFrame) {
        currentFrameRef = new WeakReference<JInternalFrame>(f);
    }
}
 
Example 21
Project: openjdk-jdk10   File: WindowsDesktopManager.java   Source Code and License 5 votes vote down vote up
public void activateFrame(JInternalFrame f) {
    JInternalFrame currentFrame = currentFrameRef != null ?
        currentFrameRef.get() : null;
    try {
        super.activateFrame(f);
        if (currentFrame != null && f != currentFrame) {
            // If the current frame is maximized, transfer that
            // attribute to the frame being activated.
            if (!currentFrame.isClosed() && currentFrame.isMaximum() &&
                (f.getClientProperty("JInternalFrame.frameType") !=
                "optionDialog") ) {
                //Special case.  If key binding was used to select next
                //frame instead of minimizing the icon via the minimize
                //icon.
                if (!currentFrame.isIcon()) {
                    currentFrame.setMaximum(false);
                    if (f.isMaximizable()) {
                        if (!f.isMaximum()) {
                            f.setMaximum(true);
                        } else if (f.isMaximum() && f.isIcon()) {
                            f.setIcon(false);
                        } else {
                            f.setMaximum(false);
                        }
                    }
                }
            }
            if (currentFrame.isSelected()) {
                currentFrame.setSelected(false);
            }
        }

        if (!f.isSelected()) {
            f.setSelected(true);
        }
    } catch (PropertyVetoException e) {}
    if (f != currentFrame) {
        currentFrameRef = new WeakReference<JInternalFrame>(f);
    }
}
 
Example 22
Project: incubator-netbeans   File: HistoryFileView.java   Source Code and License 5 votes vote down vote up
private void setSelection(final Node[] nodes) {
SwingUtilities.invokeLater(new Runnable() {
@Override
    public void run() {
        try {
            tablePanel.getExplorerManager().setSelectedNodes(nodes);
        } catch (PropertyVetoException ex) {
            // ignore
        }
    }
});                                             
}
 
Example 23
Project: incubator-netbeans   File: IDEInitializer.java   Source Code and License 5 votes vote down vote up
public MyFileSystem (FileSystem[] fileSystems) {
    super (fileSystems);
    try {
        setSystemName ("TestFS");
    } catch (PropertyVetoException ex) {
        ex.printStackTrace();
    }
}
 
Example 24
Project: incubator-netbeans   File: StringEditor.java   Source Code and License 5 votes vote down vote up
@Override
public void vetoableChange(PropertyChangeEvent ev) throws PropertyVetoException {
    super.vetoableChange(ev);
    if (PropertyEnv.PROP_STATE.equals(ev.getPropertyName())
        && resourcePanel == null && noI18nCheckbox  != null)
    {   // no resourcing, just internationalizing
        // mark the property excluded if the NOI18N checkbox is checked
        ResourceSupport.setExcludedProperty(property, noI18nCheckbox.isSelected());
    }
}
 
Example 25
Project: openjdk-jdk10   File: KeyboardFocusManager.java   Source Code and License 5 votes vote down vote up
/**
 * Sets the permanent focus owner. The operation will be cancelled if the
 * Component is not focusable. The permanent focus owner is defined as the
 * last Component in an application to receive a permanent FOCUS_GAINED
 * event. The focus owner and permanent focus owner are equivalent unless
 * a temporary focus change is currently in effect. In such a situation,
 * the permanent focus owner will again be the focus owner when the
 * temporary focus change ends.
 * <p>
 * This method does not actually set the focus to the specified Component.
 * It merely stores the value to be subsequently returned by
 * {@code getPermanentFocusOwner()}. Use
 * {@code Component.requestFocus()} or
 * {@code Component.requestFocusInWindow()} to change the focus owner,
 * subject to platform limitations.
 *
 * @param permanentFocusOwner the permanent focus owner
 * @see #getPermanentFocusOwner
 * @see #getGlobalPermanentFocusOwner
 * @see Component#requestFocus()
 * @see Component#requestFocusInWindow()
 * @see Component#isFocusable
 * @throws SecurityException if this KeyboardFocusManager is not the
 *         current KeyboardFocusManager for the calling thread's context
 *         and if the calling thread does not have "replaceKeyboardFocusManager"
 *         permission
 */
protected void setGlobalPermanentFocusOwner(Component permanentFocusOwner)
    throws SecurityException
{
    Component oldPermanentFocusOwner = null;
    boolean shouldFire = false;

    if (permanentFocusOwner == null || permanentFocusOwner.isFocusable()) {
        synchronized (KeyboardFocusManager.class) {
            checkKFMSecurity();

            oldPermanentFocusOwner = getPermanentFocusOwner();

            try {
                fireVetoableChange("permanentFocusOwner",
                                   oldPermanentFocusOwner,
                                   permanentFocusOwner);
            } catch (PropertyVetoException e) {
                // rejected
                return;
            }

            KeyboardFocusManager.permanentFocusOwner = permanentFocusOwner;

            KeyboardFocusManager.
                setMostRecentFocusOwner(permanentFocusOwner);

            shouldFire = true;
        }
    }

    if (shouldFire) {
        firePropertyChange("permanentFocusOwner", oldPermanentFocusOwner,
                           permanentFocusOwner);
    }
}
 
Example 26
Project: intellij-deps-ini4j   File: AbstractBeanInvocationHandler.java   Source Code and License 5 votes vote down vote up
protected synchronized void fireVetoableChange(String property, Object oldValue, Object newValue) throws PropertyVetoException
{
    if (_vcSupport != null)
    {
        _vcSupport.fireVetoableChange(property, oldValue, newValue);
    }
}
 
Example 27
Project: incubator-netbeans   File: UnitUtilities.java   Source Code and License 5 votes vote down vote up
public static void prepareTest(String[] additionalLayers, Object[] additionalLookupContent) throws IOException, SAXException, PropertyVetoException {
    URL[] layers = new URL[additionalLayers.length + 1];
    
    layers[0] = Utilities.class.getResource("/org/netbeans/modules/editor/errorstripe/resources/layer.xml");
    
    for (int cntr = 0; cntr < additionalLayers.length; cntr++) {
        layers[cntr + 1] = Utilities.class.getResource(additionalLayers[cntr]);
    }
    
    for (int cntr = 0; cntr < layers.length; cntr++) {
        if (layers[cntr] == null) {
            throw new IllegalStateException("layers[" + cntr + "]=null");
        }
    }
    
    XMLFileSystem system = new XMLFileSystem();
    system.setXmlUrls(layers);
    
    Repository repository = new Repository(system);
    Object[] lookupContent = new Object[additionalLookupContent.length + 1];
    
    System.arraycopy(additionalLookupContent, 0, lookupContent, 1, additionalLookupContent.length);
    
    lookupContent[0] = repository;
    
    DEFAULT_LOOKUP.setLookup(lookupContent, UnitUtilities.class.getClassLoader());
}
 
Example 28
Project: JDigitalSimulator   File: Guitilities.java   Source Code and License 5 votes vote down vote up
public static void selectFrame(final JInternalFrame frame) {
	SwingUtilities.invokeLater(new Runnable(){
		@Override public void run() {
			frame.requestFocusInWindow();
			try { frame.setSelected(true); }	catch (PropertyVetoException e) {}
			frame.toFront();
		}
	});
}
 
Example 29
Project: incubator-netbeans   File: JavaComponentInfo.java   Source Code and License 5 votes vote down vote up
@Override
public Object getValue() throws IllegalAccessException, InvocationTargetException {
    synchronized (valueLock) {
        if (value == null) {
            value = valueCalculating;
            debugger.getRequestProcessor().post(new Runnable() {
                @Override
                public void run() {
                    try {
                        RemoteServices.runOnStoppedThread(t, new Runnable() {
                            @Override
                            public void run() {
                                boolean[] isEditablePtr = new boolean[] { false };
                                Type[] typePtr = new Type[] { null };
                                String v = getValueLazy(isEditablePtr, typePtr);
                                synchronized (valueLock) {
                                    value = v;
                                    valueIsEditable = isEditablePtr[0];
                                    valueType = typePtr[0];
                                }
                                ci.firePropertyChange(propertyName, null, v);
                            }
                        }, sType);
                    } catch (PropertyVetoException ex) {
                        value = ex.getLocalizedMessage();
                    }
                }
            });
        }
        return value;
    }
}
 
Example 30
Project: incubator-netbeans   File: DocumentViewPanel.java   Source Code and License 5 votes vote down vote up
/**
 * Select corresponding node in the document view tree upon change of the
 * rule editor's content.
 *
 * A. The RuleNode holds instances of Rule-s from the model instance which
 * was created as setContext(file) was called on the view panel. B. The
 * 'rule' argument here is from an up-to-date model.
 *
 */
private void setSelectedRule(RuleHandle handle) {
    try {
        Node foundRuleNode = findLocation(manager.getRootContext(), handle);
        Node[] toSelect = foundRuleNode != null ? new Node[]{foundRuleNode} : new Node[0];
        manager.setSelectedNodes(toSelect);
    } catch (PropertyVetoException ex) {
        //no-op
    }
}
 
Example 31
Project: jdk8u-jdk   File: TestMethods.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) throws PropertyVetoException {
    Object source = new Object();
    new TestMethods(source).fireVetoableChange(new PropertyChangeEvent(source, NAME, null, null));
    new TestMethods(source).fireVetoableChange(NAME, null, null);
    new TestMethods(source).fireVetoableChange(NAME, 0, 1);
    new TestMethods(source).fireVetoableChange(NAME, true, false);
}
 
Example 32
Project: openjdk-jdk10   File: TestPopupMenu.java   Source Code and License 5 votes vote down vote up
private void createAndShowUI() throws Exception {
    frame = new JFrame();
    frame.setTitle("Test Frame");
    frame.setSize(800, 600);

    JDesktopPane pane = new JDesktopPane();
    TestInternalFrameWPopup testInternalFrame1 = new TestInternalFrameWPopup();
    pane.add(testInternalFrame1);

    testInternalFrame1.setVisible(true);
    JScrollPane scrollPane = new JScrollPane(pane);
    frame.getContentPane().add(scrollPane);
    testInternalFrame1.setMaximum(true);
    frame.getRootPane().registerKeyboardAction(e -> {
        TestInternalFrame testInternalFrame2 = new TestInternalFrame();
        pane.add(testInternalFrame2);
        try {
            testInternalFrame2.setMaximum(true);
        } catch (PropertyVetoException ex) {
            throw new RuntimeException(ex);
        }
        testInternalFrame2.setVisible(true);
    }, KeyStroke.getKeyStroke(KeyEvent.VK_U, KeyEvent.CTRL_MASK),
                             JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);

    frame.setVisible(true);
}
 
Example 33
Project: incubator-netbeans   File: MergeDialogComponent.java   Source Code and License 5 votes vote down vote up
private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
    // Add your handling code here:
    synchronized (this) {
        try {
            fireVetoableChange(PROP_ALL_CANCELLED, null, null);
        } catch (PropertyVetoException pvex) {}
        try {
            internallyClosing = true;
            close();
        } finally {
            internallyClosing = false;
        }
    }
}
 
Example 34
Project: incubator-netbeans   File: PropertiesEditorSupport.java   Source Code and License 5 votes vote down vote up
/** Called from the <code>EnvironmentListener</code>.
 * The components are going to be closed anyway and in case of
 * modified document its asked before if to save the change. */
private void fileRemoved() {
    LOG.finer("Environment.fileRemoved() ... ");                //NOI18N
    try {
        fireVetoableChange(PROP_VALID, Boolean.TRUE, Boolean.FALSE);
    } catch(PropertyVetoException pve) {
        // Ignore it and close anyway. File doesn't exist anymore.
    }
    
    firePropertyChange(PROP_VALID, Boolean.TRUE, Boolean.FALSE);
}
 
Example 35
Project: incubator-netbeans   File: OpenSupport.java   Source Code and License 5 votes vote down vote up
/** Accepts vetoable changes and fires them to own listeners.
*/
public void vetoableChange(PropertyChangeEvent ev) throws PropertyVetoException {
    fireVetoableChange (
        ev.getPropertyName (),
        ev.getOldValue (),
        ev.getNewValue ()
    );
}
 
Example 36
Project: openjdk-jdk10   File: bug6647340.java   Source Code and License 5 votes vote down vote up
private void setIcon(boolean b) {
    try {
        jif.setIcon(b);
    } catch (PropertyVetoException e) {
        e.printStackTrace();
    }
}
 
Example 37
Project: incubator-netbeans   File: MultiFileSystem3Test.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @param testName name of test 
 * @return  array of FileSystems that should be tested in test named: "testName" */
protected FileSystem[] createFileSystem (String testName, String[] resources) throws IOException {        
        FileSystem lfs = TestUtilHid.createLocalFileSystem("mfs3"+testName, resources);
        FileSystem xfs = TestUtilHid.createXMLFileSystem(testName, resources);
        FileSystem mfs = new MultiFileSystem(lfs, xfs);
        try {
            mfs.setSystemName("mfs3test");
        } catch (PropertyVetoException e) {
            e.printStackTrace();  //To change body of catch statement use Options | File Templates.
        }
    return new FileSystem[] {mfs,lfs,xfs};
}
 
Example 38
Project: incubator-netbeans   File: AttrTest.java   Source Code and License 5 votes vote down vote up
/** it mounts LocalFileSystem in temorary directory
     */
    private void preprocess() throws IOException,PropertyVetoException {
//        fileSystemFile.mkdir();
        clearWorkDir();
        fileSystemDir = new File(getWorkDir(), "testAtt123rDir");
        if(fileSystemDir.mkdir() == false || fileSystemDir.isDirectory() == false) {
            throw new IOException (fileSystemDir.toString() + " is not directory");
        }
        fileSystem = new LocalFileSystem();
        fileSystem.setRootDirectory(fileSystemDir);
    }
 
Example 39
Project: incubator-netbeans   File: DocumentsDlg.java   Source Code and License 5 votes vote down vote up
private void updateNodes() {
    //Create nodes for TopComponents, sort them using their own comparator
    List<TopComponent> tcList = getOpenedDocuments();
    TopComponent activeTC = TopComponent.getRegistry().getActivated();
    TopComponentNode[] tcNodes = new TopComponentNode[tcList.size()];
    TopComponentNode toSelect = null;
    for (int i = 0; i < tcNodes.length; i++) {
        TopComponent tc = tcList.get(i);
        tcNodes[i] = new TopComponentNode(tc);
        if( tc == activeTC ) {
            toSelect = tcNodes[i];
        }
    }
    if( radioOrderByName.isSelected() ) {
        Arrays.sort(tcNodes);
    }
    
    Children.Array nodeArray = new Children.Array();
    nodeArray.add(tcNodes);
    Node root = new AbstractNode(nodeArray);
    explorer.setRootContext(root);
    // set focus to documents list
    listView.requestFocus();
    // select the active editor tab or the first item if possible
    if (tcNodes.length > 0) {
        try {
            if( null == toSelect ) 
                toSelect = tcNodes[0];
            explorer.setSelectedNodes(new Node[] {toSelect} );
        } catch (PropertyVetoException exc) {
            // do nothing, what should I do?
        }
    }
}
 
Example 40
Project: OpenJSharp   File: SynthInternalFrameTitlePane.java   Source Code and License 5 votes vote down vote up
protected void assembleSystemMenu() {
    systemPopupMenu = new JPopupMenuUIResource();
    addSystemMenuItems(systemPopupMenu);
    enableActions();
    menuButton = createNoFocusButton();
    updateMenuIcon();
    menuButton.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent e) {
            try {
                frame.setSelected(true);
            } catch(PropertyVetoException pve) {
            }
            showSystemMenu();
        }
    });
    JPopupMenu p = frame.getComponentPopupMenu();
    if (p == null || p instanceof UIResource) {
        frame.setComponentPopupMenu(systemPopupMenu);
    }
    if (frame.getDesktopIcon() != null) {
        p = frame.getDesktopIcon().getComponentPopupMenu();
        if (p == null || p instanceof UIResource) {
            frame.getDesktopIcon().setComponentPopupMenu(systemPopupMenu);
        }
    }
    setInheritsPopupMenu(true);
}