当前位置: 首页>>代码示例>>Java>>正文


Java VetoableChangeListener类代码示例

本文整理汇总了Java中java.beans.VetoableChangeListener的典型用法代码示例。如果您正苦于以下问题:Java VetoableChangeListener类的具体用法?Java VetoableChangeListener怎么用?Java VetoableChangeListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


VetoableChangeListener类属于java.beans包,在下文中一共展示了VetoableChangeListener类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: commitChanges

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/**
 * Used by PropertyAction to mimic property sheet behavior - trying to invoke
 * PropertyEnv listener of the current property editor (we can't create our
 * own PropertyEnv instance).
 * 
 * @return current value
 * @throws java.beans.PropertyVetoException if someone vetoes this change.
 */
public Object commitChanges() throws PropertyVetoException {
    int currentIndex = editorsCombo.getSelectedIndex();
    PropertyEditor currentEditor = currentIndex > -1 ? allEditors[currentIndex] : null;
    if (currentEditor instanceof ExPropertyEditor) {
        // we can only guess - according to the typical pattern the propetry
        // editor itself or the custom editor usually implement the listener
        // registered in PropertyEnv
        PropertyChangeEvent evt = new PropertyChangeEvent(
                this, PropertyEnv.PROP_STATE, null, PropertyEnv.STATE_VALID);
        if (currentEditor instanceof VetoableChangeListener) {
            ((VetoableChangeListener)currentEditor).vetoableChange(evt);
        }
        Component currentCustEd = currentIndex > -1 ? allCustomEditors[currentIndex] : null;
        if (currentCustEd instanceof VetoableChangeListener) {
            ((VetoableChangeListener)currentCustEd).vetoableChange(evt);
        }
        if (currentEditor instanceof PropertyChangeListener) {
            ((PropertyChangeListener)currentEditor).propertyChange(evt);
        }
        if (currentCustEd instanceof PropertyChangeListener) {
            ((PropertyChangeListener)currentCustEd).propertyChange(evt);
        }
    }
    return commitChanges0();
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:34,代码来源:FormCustomEditor.java

示例2: testSetNodesSurviveChangeOfNodes

import java.beans.VetoableChangeListener; //导入依赖的package包/类
public void testSetNodesSurviveChangeOfNodes() throws Exception {
    final Node a = keys.key("toRemove");
    
    class ChangeTheSelectionInMiddleOfMethod implements VetoableChangeListener {
        public int cnt;
        
        public void vetoableChange(PropertyChangeEvent evt) {
            cnt++;
            keys.keys(new String[0]);
        }
    }
    
    ChangeTheSelectionInMiddleOfMethod list = new ChangeTheSelectionInMiddleOfMethod();
    em.addVetoableChangeListener(list);
    
    em.setSelectedNodes(new Node[] { a });
    
    assertEquals("Vetoable listener called", 1, list.cnt);
    assertEquals("Node is dead", null, a.getParentNode());
    
    // handling of removed nodes is done asynchronously
    em.waitFinished();
    
    Node[] arr = em.getSelectedNodes();
    assertEquals("No nodes can be selected", 0, arr.length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:27,代码来源:ExplorerManagerTest.java

示例3: testCannotVetoSetToEmptySelection

import java.beans.VetoableChangeListener; //导入依赖的package包/类
public void testCannotVetoSetToEmptySelection() throws Exception {
    final Node a = keys.key("toRemove");
    
    em.setSelectedNodes(new Node[] { a });
    
    class NeverCalledVeto implements VetoableChangeListener {
        public int cnt;
        
        public void vetoableChange(PropertyChangeEvent evt) {
            cnt++;
            keys.keys(new String[0]);
        }
    }
    
    NeverCalledVeto list = new NeverCalledVeto();
    em.addVetoableChangeListener(list);
    
    em.setSelectedNodes(new Node[0]);
    
    assertEquals("Veto not called", 0, list.cnt);
    Node[] arr = em.getSelectedNodes();
    assertEquals("No nodes can be selected", 0, arr.length);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:24,代码来源:ExplorerManagerTest.java

示例4: addVetoableChangeListenerIfAbsent

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/**
  * Add a PropertyChangeListener to the listener list if it is 
  * not already present.
  * The listener is registered for all properties.
  * The operation maintains Set semantics: If the listener is already 
  * registered, the operation has no effect.
  *
  * @param listener  The PropertyChangeListener to be added
  * @exception NullPointerException If listener is null
  */
 
 public synchronized void addVetoableChangeListenerIfAbsent(VetoableChangeListener listener) {

   if (listener == null) throw new NullPointerException();

   // Copy while checking if already present.
   int len = listeners.length; 
   VetoableChangeListener[] newArray = new VetoableChangeListener[len + 1];
   for (int i = 0; i < len; ++i) {
     newArray[i] = listeners[i];
     if (listener.equals(listeners[i]))
return; // already present -- throw away copy
   }
   newArray[len] = listener;
   listeners = newArray;
 }
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:27,代码来源:VetoableChangeMulticaster.java

示例5: addListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
private void addListener(PropertiesDataObject dataObj) {
    PropertyChangeListener l =weakEnvPropListeners.get(dataObj);
    VetoableChangeListener v = weakEnvVetoListeners.get(dataObj);
    if (l != null) {
        dataObj.removePropertyChangeListener(l);
    } else {
        l = WeakListeners.propertyChange(this, dataObj);
        weakEnvPropListeners.put(dataObj, l);
    }
    if (v != null) {
        dataObj.removeVetoableChangeListener(v);
    } else {
        v = WeakListeners.vetoableChange(this, dataObj);
        weakEnvVetoListeners.put(dataObj, v);
    }
    dataObj.addPropertyChangeListener(l);
    dataObj.addVetoableChangeListener(v);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PropertiesOpen.java

示例6: addListeners

import java.beans.VetoableChangeListener; //导入依赖的package包/类
private  void addListeners() {
    BundleStructure structure = bundleStructure;
    PropertiesDataObject dataObj;
    weakEnvPropListeners = new HashMap<PropertiesDataObject, PropertyChangeListener>();
    weakEnvVetoListeners = new HashMap<PropertiesDataObject, VetoableChangeListener>();
    PropertyChangeListener l;
    VetoableChangeListener v;
    for(int i=0;i<structure.getEntryCount();i++) {
        dataObj = (PropertiesDataObject) structure.getNthEntry(i).getDataObject();
        l = WeakListeners.propertyChange(this, dataObj);
        weakEnvPropListeners.put(dataObj, l);
        dataObj.addPropertyChangeListener(l);
        v = WeakListeners.vetoableChange(this, dataObj);
        weakEnvVetoListeners.put(dataObj, v);
        dataObj.addVetoableChangeListener(v);
    }

}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:19,代码来源:PropertiesOpen.java

示例7: removeListeners

import java.beans.VetoableChangeListener; //导入依赖的package包/类
private void removeListeners() {
    BundleStructure structure = bundleStructure;
    PropertiesDataObject dataObj;
    PropertyChangeListener l;
    VetoableChangeListener v;
    for(int i=0;i<structure.getEntryCount();i++) {
        dataObj = (PropertiesDataObject) structure.getNthEntry(i).getDataObject();
        l = weakEnvPropListeners.remove(dataObj);
        v = weakEnvVetoListeners.remove(dataObj);
        if (l!=null) {
            dataObj.removePropertyChangeListener(l);
        }
        if (v!=null) {
            dataObj.removeVetoableChangeListener(v);
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:PropertiesOpen.java

示例8: atomicUnlockImpl

import java.beans.VetoableChangeListener; //导入依赖的package包/类
final void atomicUnlockImpl (boolean notifyUnmodifyIfNoMods) {
    boolean noModsAndOuterUnlock = false;
    synchronized (this) {
        if (atomicDepth <= 0) {
            throw new IllegalStateException("atomicUnlock() without atomicLock()"); // NOI18N
        }

        if (--atomicDepth == 0) { // lock really ended
            fireAtomicUnlock(atomicLockEventInstance);

            noModsAndOuterUnlock = !checkAndFireAtomicEdits();
            atomicLockListenerList = null;
            extWriteUnlock();
        }
    }

    if (notifyUnmodifyIfNoMods && noModsAndOuterUnlock) {
        // Notify unmodification if there were no document modifications
        // inside the atomic section.
        // Fire VetoableChangeListener outside Document lock
        VetoableChangeListener l = (VetoableChangeListener) getProperty(MODIFICATION_LISTENER_PROP);
        if (l != null) {
            try {
                // Notify unmodification by Boolean.FALSE
                l.vetoableChange(new PropertyChangeEvent(this, "modified", null, Boolean.FALSE));
            } catch (java.beans.PropertyVetoException ex) {
                // Ignored (should not be thrown)
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:32,代码来源:BaseDocument.java

示例9: notifyModified

import java.beans.VetoableChangeListener; //导入依赖的package包/类
private boolean notifyModified (Object o) {
    boolean canBeModified = true;
    if (o instanceof VetoableChangeListener) {
        VetoableChangeListener l = (VetoableChangeListener)o;
        try {
            l.vetoableChange (new java.beans.PropertyChangeEvent (this, "modified", null, Boolean.TRUE));
        } catch (java.beans.PropertyVetoException ex) {
            canBeModified = false;
        }
    }
    return canBeModified;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:NbLikeEditorKit.java

示例10: removeVetoableChangeListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
protected synchronized void removeVetoableChangeListener(String property, VetoableChangeListener listener)
{
    if (_vcSupport != null)
    {
        _vcSupport.removeVetoableChangeListener(property, listener);
    }
}
 
开发者ID:JetBrains,项目名称:intellij-deps-ini4j,代码行数:8,代码来源:AbstractBeanInvocationHandler.java

示例11: addVetoableChangeListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/**
 * Adds a <code>VetoableChangeListener</code> to the listener list.
 * The listener is registered for all properties.
 *
 * @param listener  the <code>VetoableChangeListener</code> to be added
 */
public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {
    if (vetoableChangeSupport == null) {
        vetoableChangeSupport = new java.beans.VetoableChangeSupport(this);
    }
    vetoableChangeSupport.addVetoableChangeListener(listener);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:13,代码来源:JComponent.java

示例12: getChildVetoableChangeListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/**
 * Gets the VetoableChangeListener
 * (if any) of the specified child
 * @param child the specified child
 * @return the VetoableChangeListener (if any) of the specified child
 */
protected static final VetoableChangeListener getChildVetoableChangeListener(Object child) {
    try {
        return (VetoableChangeListener)child;
    } catch (ClassCastException cce) {
        return null;
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:BeanContextSupport.java

示例13: addVetoableChangeListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/**
 * Add a VetoableChangeListener to the listener list.
 * The listener is registered for all properties.
 * If the listener is added multiple times, it will
 * receive multiple change notifications upon any fireVetoableChange.
 *
 * @param listener  The VetoableChangeListener to be added
 */

public synchronized void addVetoableChangeListener(VetoableChangeListener listener) {

  if (listener == null) throw new NullPointerException();

  int len = listeners.length;
  VetoableChangeListener[] newArray = new VetoableChangeListener[len + 1];
  if (len > 0)
    System.arraycopy(listeners, 0, newArray, 0, len);
  newArray[len] = listener;
  listeners = newArray;
}
 
开发者ID:parabuild-ci,项目名称:parabuild-ci,代码行数:21,代码来源:VetoableChangeMulticaster.java

示例14: openInnerPanel

import java.beans.VetoableChangeListener; //导入依赖的package包/类
protected void openInnerPanel() {
    if (toolBarDesignEditor == null) {
        toolBarDesignEditor = sectionView.getToolBarDesignEditor();
        if (toolBarDesignEditor != null) {
            toolBarDesignEditor.addVetoableChangeListener(new VetoableChangeListener() {
                public void vetoableChange(PropertyChangeEvent evt) throws PropertyVetoException {
                    if (ToolBarDesignEditor.PROPERTY_FLUSH_DATA.equals(evt.getPropertyName()) &&
                            evt.getNewValue() == null) {
                        if (innerPanel != null && !innerPanel.canClose()) {
                            throw new PropertyVetoException("", evt);
                        }
                    }
                }
            });
        }
    }
    if (innerPanel != null) {
        return;
    }
    innerPanel = createInnerpanel();
    java.awt.GridBagConstraints gridBagConstraints = new java.awt.GridBagConstraints();
    gridBagConstraints.gridx = 1;
    gridBagConstraints.gridy = 2;
    gridBagConstraints.gridwidth = 2;
    gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
    gridBagConstraints.weightx = 1.0;
    gridBagConstraints.insets = new java.awt.Insets(2, 0, 0, 0);
    fillerLine.setVisible(true);
    fillerEnd.setVisible(true);
    innerPanel.addFocusListener(sectionFocusListener);
    add(innerPanel, gridBagConstraints);
    Utils.scrollToVisible(this);
    // issue 233048: the background color issues with dark metal L&F
    // innerPanel.setBackground(
    //      active ? SectionVisualTheme.getSectionActiveBackgroundColor() : SectionVisualTheme.getDocumentBackgroundColor());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:37,代码来源:SectionPanel.java

示例15: addVetoableChangeListener

import java.beans.VetoableChangeListener; //导入依赖的package包/类
/** Adds listener for the veto of property change.
* @param listener the listener
*/
public final void addVetoableChangeListener(VetoableChangeListener listener) {
    synchronized (internLock) {
        if (vetoableChangeList == null) {
            vetoableChangeList = new ListenerList<VetoableChangeListener>();
        }

        vetoableChangeList.add(listener);
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:13,代码来源:FileSystem.java


注:本文中的java.beans.VetoableChangeListener类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。