Java Code Examples for java.beans.PropertyVetoException

The following examples show how to use java.beans.PropertyVetoException. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: SIMVA-SoS   Source File: TimeSeriesCollection.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Receives notification that the key for one of the series in the 
 * collection has changed, and vetos it if the key is already present in 
 * the collection.
 * 
 * @param e  the event.
 * 
 * @since 1.0.17
 */
@Override
public void vetoableChange(PropertyChangeEvent e)
        throws PropertyVetoException {
    // if it is not the series name, then we have no interest
    if (!"Key".equals(e.getPropertyName())) {
        return;
    }
    
    // to be defensive, let's check that the source series does in fact
    // belong to this collection
    Series s = (Series) e.getSource();
    if (getSeriesIndex(s.getKey()) == -1) {
        throw new IllegalStateException("Receiving events from a series " +
                "that does not belong to this collection.");
    }
    // check if the new series name already exists for another series
    Comparable key = (Comparable) e.getNewValue();
    if (getSeriesIndex(key) >= 0) {
        throw new PropertyVetoException("Duplicate key2", e);
    }
}
 
Example 2
Source Project: bigtable-sql   Source File: ShowDriverWebsiteAction.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Perform this action. Execute the create driver command.
 *
 * @param	evt	 The current event.
 */
public void actionPerformed(ActionEvent evt)
{
	IApplication app = getApplication();
	DriversListInternalFrame tw = app.getWindowManager().getDriversListInternalFrame();
	tw.moveToFront();
	try
	{
		tw.setSelected(true);
	}
	catch (PropertyVetoException ex)
	{
           //i18n[CreateDriverAction.error.selectingwindow=Error selecting window]
		s_log.error(s_stringMgr.getString("CreateDriverAction.error.selectingwindow"), ex);
	}
           
       ISQLDriver driver = _drivers.getSelectedDriver();
       if (driver != null)
       {
           new ShowDriverWebsiteCommand(app, driver).execute();
       }
}
 
Example 3
public void mouseReleased(final MouseEvent e) {// only when it's actually in the image
    if (fFrame.isIconifiable() && fFrame.isIcon()) {
        if (fTrackingIcon) {
            fTrackingIcon = false;
            if (fIconPane.mouseInIcon(e)) {
                if (fDockLabel != null) fDockLabel.hide();
                try {
                    fFrame.setIcon(false);
                } catch(final PropertyVetoException e2) {}
            } else {
                fIconPane.repaint();
            }
        }
    }

    // if the mouse was completely outside fIconPane, hide the label
    if (fDockLabel != null && !fIconPane.getBounds().contains(e.getX(), e.getY())) fDockLabel.hide();
}
 
Example 4
Source Project: netbeans   Source File: WindowBuilders.java    License: Apache License 2.0 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 5
Source Project: netbeans   Source File: DomPanel.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Updates the set of selected nodes.
 */
private void updateSelection() {
    if (EventQueue.isDispatchThread()) {
        List<? extends Node> nodes = pageModel.getSelectedNodes();
        Node[] selection = nodes.toArray(new Node[nodes.size()]);
        updatingView = true;
        try {
            manager.setSelectedNodes(selection);
        } catch (PropertyVetoException pvex) {
            Logger.getLogger(DomPanel.class.getName()).log(Level.INFO, null, pvex);
        } finally {
            updatingView = false;
        }
    } else {
        EventQueue.invokeLater(new Runnable() {
            @Override
            public void run() {
                updateSelection();
            }
        });
    }
}
 
Example 6
Source Project: JDKSourceCode1.8   Source File: JInternalFrame.java    License: MIT 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 7
Source Project: hottub   Source File: JDesktopPane.java    License: GNU General Public License v2.0 6 votes vote down vote up
/**
 * Selects the next <code>JInternalFrame</code> in this desktop pane.
 *
 * @param forward a boolean indicating which direction to select in;
 *        <code>true</code> for forward, <code>false</code> for
 *        backward
 * @return the JInternalFrame that was selected or <code>null</code>
 *         if nothing was selected
 * @since 1.6
 */
public JInternalFrame selectFrame(boolean forward) {
    JInternalFrame selectedFrame = getSelectedFrame();
    JInternalFrame frameToSelect = getNextFrame(selectedFrame, forward);
    if (frameToSelect == null) {
        return null;
    }
    // Maintain navigation traversal order until an
    // external stack change, such as a click on a frame.
    setComponentOrderCheckingEnabled(false);
    if (forward && selectedFrame != null) {
        selectedFrame.moveToBack();  // For Windows MDI fidelity.
    }
    try { frameToSelect.setSelected(true);
    } catch (PropertyVetoException pve) {}
    setComponentOrderCheckingEnabled(true);
    return frameToSelect;
}
 
Example 8
Source Project: maven-framework-project   Source File: C3P0DataSource.java    License: MIT License 6 votes vote down vote up
private C3P0DataSource() throws IOException, SQLException,
		PropertyVetoException {
	cpds = new ComboPooledDataSource();
	cpds.setDriverClass("org.h2.Driver"); // loads the jdbc driver
	cpds.setJdbcUrl("jdbc:h2:./target/test;AUTO_SERVER=TRUE");
	cpds.setUser("sa");
	cpds.setPassword("");

	// the settings below are optional -- c3p0 can work with defaults
	cpds.setMinPoolSize(5);
	cpds.setAcquireIncrement(5);
	cpds.setMaxPoolSize(20);
	cpds.setMaxStatements(180);

	this.setDataSource(cpds);

}
 
Example 9
public void mouseReleased(final MouseEvent e) {// only when it's actually in the image
    if (fFrame.isIconifiable() && fFrame.isIcon()) {
        if (fTrackingIcon) {
            fTrackingIcon = false;
            if (fIconPane.mouseInIcon(e)) {
                if (fDockLabel != null) fDockLabel.hide();
                try {
                    fFrame.setIcon(false);
                } catch(final PropertyVetoException e2) {}
            } else {
                fIconPane.repaint();
            }
        }
    }

    // if the mouse was completely outside fIconPane, hide the label
    if (fDockLabel != null && !fIconPane.getBounds().contains(e.getX(), e.getY())) fDockLabel.hide();
}
 
Example 10
Source Project: Java8CN   Source File: JInternalFrame.java    License: Apache License 2.0 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
Source Project: netbeans   Source File: LayerCacheManager.java    License: Apache License 2.0 6 votes vote down vote up
@Override
public FileSystem load(FileSystem previous, ByteBuffer bb) throws IOException {
    byte[] arr = new byte[bb.limit()];
    bb.get(arr);
    DataInputStream is = new DataInputStream(new ByteArrayInputStream(arr));
    List<URL> urls = new ArrayList<URL>();
    while (is.available() > 0) {
        String u = is.readUTF();
        urls.add(new URL(u));
    }
    try {
        XMLFileSystem fs = (XMLFileSystem)previous;
        fs.setXmlUrls(urls.toArray(new URL[urls.size()]));
        return fs;
    } catch (PropertyVetoException pve) {
        throw (IOException) new IOException(pve.toString()).initCause(pve);
    }
}
 
Example 12
public void activateFrame(final JInternalFrame f) {
    try {
        if (f != null) super.activateFrame(f);

        // If this is the first activation, add to child list.
        if (fChildFrames.indexOf(f) == -1) {
            fChildFrames.addElement(f);
        }

        if (fCurrentFrame != null && f != fCurrentFrame) {
            if (fCurrentFrame.isSelected()) {
                fCurrentFrame.setSelected(false);
            }
        }

        if (f != null && !f.isSelected()) {
            f.setSelected(true);
        }

        fCurrentFrame = f;
    } catch(final PropertyVetoException e) {}
}
 
Example 13
/**
 * 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 14
public void writeToObject(Object object) {
  try {
    Method method = descriptor.getWriteMethod();
    if (method != null) {
      method.invoke(object, new Object[]{getValue()});
    }
  } catch (Exception e) {
    // let PropertyVetoException go to the upper level without logging
    if (e instanceof InvocationTargetException &&
      ((InvocationTargetException)e).getTargetException() instanceof PropertyVetoException) {
      throw new RuntimeException(((InvocationTargetException)e).getTargetException());
    }

    String message = "Got exception when writing property " + getName();
    if (object == null) {
      message += ", object was 'null'";
    } else {
      message += ", object was " + String.valueOf(object);
    }
    throw new RuntimeException(message, e);
  }
}
 
Example 15
Source Project: JDKSourceCode1.8   Source File: KeyboardFocusManager.java    License: MIT 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()</code>. Use
 * <code>Component.requestFocus()</code> or
 * <code>Component.requestFocusInWindow()</code> 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
 * @beaninfo
 *       bound: true
 */
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 16
public void mousePressed(final MouseEvent e) {
    JInternalFrame selectedFrame = desktop.getSelectedFrame();
    if (selectedFrame != null) {
        try {
            selectedFrame.setSelected(false);
        } catch (PropertyVetoException ex) {}
        desktop.getDesktopManager().deactivateFrame(selectedFrame);
    }
}
 
Example 17
public void deiconifyFrame(final JInternalFrame f) {
    final JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon();
    final Container dock = desktopIcon.getParent();
    if (dock == null) return;

    if (dock.getParent() != null) dock.getParent().add(f);
    removeIconFor(f);
    // <rdar://problem/3712485> removed f.show(). show() is now deprecated and
    // it wasn't sending our frame to front nor selecting it. Now, we move it
    // to front and select it manualy. (vm)
    f.moveToFront();
    try {
        f.setSelected(true);
    } catch(final PropertyVetoException pve) { /* do nothing */ }
}
 
Example 18
/**
 * 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()</code>. Use
 * <code>Component.requestFocus()</code> or
 * <code>Component.requestFocusInWindow()</code> 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
 * @beaninfo
 *       bound: true
 */
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 19
Source Project: netbeans   Source File: DiffTreeTable.java    License: Apache License 2.0 5 votes vote down vote up
void setSelection(RepositoryRevision container) {
    RevisionNode node = (RevisionNode) getNode(rootNode, container);
    if (node == null) return;
    ExplorerManager em = ExplorerManager.find(this);
    try {
        em.setSelectedNodes(new Node [] { node });
    } catch (PropertyVetoException e) {
        Subversion.LOG.log(Level.SEVERE, null, e);
    }
}
 
Example 20
public static void main(String[] args) throws PropertyVetoException {
    for (int i = 1; i <= 3; i++) {
        test(i, 1, 10000000);
        test(i, 10, 1000000);
        test(i, 100, 100000);
        test(i, 1000, 10000);
        test(i, 10000, 1000);
        test(i, 20000, 1000);
    }
}
 
Example 21
/**
 * 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;

            throw pve; // re-throw
        }
    }

    if (beanContext != null) releaseBeanContextResources();

    beanContext       = newValue;
    rejectedSetBCOnce = false;

    firePropertyChange("beanContext",
                       oldValue,
                       newValue
    );

    if (beanContext != null) initializeBeanContextResources();
}
 
Example 22
/**
 * 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;

            throw pve; // re-throw
        }
    }

    if (beanContext != null) releaseBeanContextResources();

    beanContext       = newValue;
    rejectedSetBCOnce = false;

    firePropertyChange("beanContext",
                       oldValue,
                       newValue
    );

    if (beanContext != null) initializeBeanContextResources();
}
 
Example 23
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 24
Source Project: netbeans   Source File: ProjectTab.java    License: Apache License 2.0 5 votes vote down vote up
void selectNode(final Node node) {
    Mutex.EVENT.writeAccess(new Runnable() {
        public @Override void run() {
            try {
                manager.setSelectedNodes(new Node[] {node});
                btv.scrollToNode(node);
            } catch (PropertyVetoException e) {
                // Bad day node found but can't be selected
            }
        }
    });
}
 
Example 25
Source Project: dragonwell8_jdk   Source File: TestMethods.java    License: GNU General Public License v2.0 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 26
Source Project: opensim-gui   Source File: ExplorerTopComponent.java    License: Apache License 2.0 5 votes vote down vote up
public void selectNodeForObject(OpenSimObject oObject) {
        Children children = getExplorerManager().getRootContext().getChildren();
        Node[] nodes = children.getNodes();
        for (int i = 0; i < nodes.length; i++) {
            if (nodes[i] instanceof OneModelNode) {
                OneModelNode modelNode = ((OneModelNode) (nodes[i]));
                Node objectNode = findObjectNode(modelNode, oObject);
                // Hack to select Muscle based on selected PathPoint
                if (oObject instanceof AbstractPathPoint){
                    AbstractPathPoint ppt = (AbstractPathPoint)oObject;
                    GeometryPath ppath = GeometryPath.safeDownCast(ppt.getOwner());
                    OpenSimObject pathOwner = ppath.getOwner();
                    objectNode = findObjectNode(modelNode,pathOwner);
                    
                }
                if (objectNode != null) {
                    try {
//                        Node[] previouslySelectedNodes = findInstance().getExplorerManager().getSelectedNodes();
//                        Node[] newSelectedNodes = new Node[previouslySelectedNodes.length+1];
//                        System.arraycopy(previouslySelectedNodes, 0, newSelectedNodes, 0, previouslySelectedNodes.length);
//                        newSelectedNodes[previouslySelectedNodes.length] = objectNode;
                        findInstance().getExplorerManager().setSelectedNodes(new Node[]{objectNode});
                        this.setActivatedNodes(new Node[]{objectNode});
                        ((OpenSimNode)objectNode).refreshNode();
                        requestActive();
                    } catch (PropertyVetoException ex) {
                        Exceptions.printStackTrace(ex);
                    }
                    break;
                }
            }
        }
        //return ret;
    }
 
Example 27
Source Project: JDKSourceCode1.8   Source File: DefaultDesktopManager.java    License: MIT License 5 votes vote down vote up
/**
 * Restores the frame back to its size and position prior
 * to a <code>maximizeFrame</code> call.
 * @param f the <code>JInternalFrame</code> to be restored
 */
public void minimizeFrame(JInternalFrame f) {
    // If the frame was an icon restore it back to an icon.
    if (f.isIcon()) {
        iconifyFrame(f);
        return;
    }

    if ((f.getNormalBounds()) != null) {
        Rectangle r = f.getNormalBounds();
        f.setNormalBounds(null);
        try { f.setSelected(true); } catch (PropertyVetoException e2) { }
        setBoundsForFrame(f, r.x, r.y, r.width, r.height);
    }
}
 
Example 28
@Test
public void testSerialization() throws IOException, ClassNotFoundException, PropertyVetoException {
    EventListenerSupport<VetoableChangeListener> listenerSupport = EventListenerSupport.create(VetoableChangeListener.class);
    listenerSupport.addListener(new VetoableChangeListener() {
        
        @Override
        public void vetoableChange(PropertyChangeEvent e) {
        }
    });
    listenerSupport.addListener(EasyMock.createNiceMock(VetoableChangeListener.class));

    //serialize:
    ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
    ObjectOutputStream objectOutputStream = new ObjectOutputStream(outputStream);

    objectOutputStream.writeObject(listenerSupport);
    objectOutputStream.close();

    //deserialize:
    @SuppressWarnings("unchecked")
    EventListenerSupport<VetoableChangeListener> deserializedListenerSupport = (EventListenerSupport<VetoableChangeListener>) new ObjectInputStream(
            new ByteArrayInputStream(outputStream.toByteArray())).readObject();

    //make sure we get a listener array back, of the correct component type, and that it contains only the serializable mock
    VetoableChangeListener[] listeners = deserializedListenerSupport.getListeners();
    assertEquals(VetoableChangeListener.class, listeners.getClass().getComponentType());
    assertEquals(1, listeners.length);

    //now verify that the mock still receives events; we can infer that the proxy was correctly reconstituted
    VetoableChangeListener listener = listeners[0];
    PropertyChangeEvent evt = new PropertyChangeEvent(new Date(), "Day", 7, 9);
    listener.vetoableChange(evt);
    EasyMock.replay(listener);
    deserializedListenerSupport.fire().vetoableChange(evt);
    EasyMock.verify(listener);

    //remove listener and verify we get an empty array of listeners
    deserializedListenerSupport.removeListener(listener);
    assertEquals(0, deserializedListenerSupport.getListeners().length);
}
 
Example 29
Source Project: openjdk-jdk9   Source File: bug8075314.java    License: GNU General Public License v2.0 5 votes vote down vote up
public static void main(String[] args) throws Exception {
    for (UIManager.LookAndFeelInfo lookAndFeelInfo : UIManager
            .getInstalledLookAndFeels()) {
        UIManager.setLookAndFeel(lookAndFeelInfo.getClassName());
        try {
            SwingUtilities.invokeAndWait(new Runnable() {
                public void run() {
                    frame = new JFrame();
                    frame.setUndecorated(true);
                    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    setup(frame);
                }
            });

            SwingUtilities.invokeAndWait(new Runnable() {
                @Override
                public void run() {
                    try {
                        frame1.setMaximum(true);
                        frame1.setClosed(true);
                        if (frame2.isMaximum()) {
                            throw new RuntimeException(
                                    "Frame2 is maximized!");
                        }
                    } catch (PropertyVetoException e) {
                        throw new RuntimeException(e);
                    }

                }
            });
        } finally {
            frame.dispose();
        }
    }
    System.out.println("ok");
}
 
Example 30
Source Project: code   Source File: MainConfigofProfile.java    License: Apache License 2.0 5 votes vote down vote up
@Profile("dev")
@Bean("devDataSource")
public DataSource dataSourceDev(@Value("${db.password}") String pwd) throws PropertyVetoException {
    ComboPooledDataSource dataSource = new ComboPooledDataSource();
    dataSource.setUser(user);
    dataSource.setPassword(pwd);
    dataSource.setDriverClass(driverClass);
    dataSource.setJdbcUrl("jdbc:mysql://localhost:3306/dev");
    return dataSource;
}