Java 类java.beans.PropertyChangeListener 实例源码

项目:incubator-netbeans    文件:FormCustomEditor.java   
/**
 * 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();
}
项目:incubator-netbeans    文件:EditorMimeTypes.java   
private EditorMimeTypes() {
    impl = Lookup.getDefault().lookup(EditorMimeTypesImplementation.class);
    if (impl == null) {
        throw new IllegalStateException(String.format(
            "No %s instance in the default Lookup.",    //NOI18N
            EditorMimeTypesImplementation.class));
    }
    listeners = new PropertyChangeSupport(this);
    listener = new PropertyChangeListener() {
        @Override
        public void propertyChange(PropertyChangeEvent evt) {
            if (EditorMimeTypesImplementation.PROP_SUPPORTED_MIME_TYPES.equals(evt.getPropertyName())) {
                listeners.firePropertyChange(PROP_SUPPORTED_MIME_TYPES, null, null);
            }
        }
    };
    impl.addPropertyChangeListener(WeakListeners.propertyChange(listener, impl));
}
项目:OpenJSharp    文件:WToolkit.java   
@Override
public synchronized void addPropertyChangeListener(String name, PropertyChangeListener pcl) {
    if (name == null) {
        // See JavaDoc for the Toolkit.addPropertyChangeListener() method
        return;
    }
    if ( WDesktopProperties.isWindowsProperty(name)
         || name.startsWith(awtPrefix)
         || name.startsWith(dndPrefix))
    {
        // someone is interested in Windows-specific desktop properties
        // we should initialize wprops
        lazilyInitWProps();
    }
    super.addPropertyChangeListener(name, pcl);
}
项目:incubator-netbeans    文件:MenuFakeSupport.java   
@Override
public void addComponentsToContainer(Container container,
                                     Container containerDelegate,
                                     Component[] components,
                                     int index)
{
    for (int i=0; i < components.length; i++) {
        containerDelegate.add(components[i], i + index);
        // Issue 110587 - the default background of menu depends (on some l&f)
        // on the location of the menu (if it is top-level menu or not).
        // The background is changed when "ancestor" property change event
        // is fired. This usually happens when addNotify() is called.
        // Unfortunately, addNotify() is not called if the parent doesn't
        // have peer - this happens for model instances. The following
        // code fires the property change event explicitly to force
        // update of the background.
        PropertyChangeEvent event = new PropertyChangeEvent(components[i], "ancestor", null, container); // NOI18N
        for (PropertyChangeListener listener : components[i].getPropertyChangeListeners()) {
            listener.propertyChange(event);
        }
    }
}
项目:incubator-netbeans    文件:CompletionLayout.java   
public CompletionLayout(PropertyChangeListener listener) {
    this.listener = listener;
    completionPopup = new CompletionPopup();
    completionPopup.setLayout(this);
    completionPopup.setPreferDisplayAboveCaret(false);
    docPopup = new DocPopup();
    docPopup.setLayout(this);
    docPopup.setPreferDisplayAboveCaret(false);
    visiblePopups = new LinkedList<CompletionLayoutPopup>();
}
项目:incubator-netbeans    文件:ProjectUtilsTest.java   
@Override
public ProjectInformation getProjectInformation(final Project project) {
    ProjectInformation info =  project.getLookup().lookup(ProjectInformation.class);
    if (info == null) {
        info = new ProjectInformation() {
            @Override
            public String getName() {
                return project.getProjectDirectory().getName();
            }

            @Override
            public String getDisplayName() {
                return getName();
            }

            @Override
            public Icon getIcon() {
                return null;
            }

            @Override
            public Project getProject() {
                return project;
            }

            @Override
            public void addPropertyChangeListener(PropertyChangeListener listener) {
            }

            @Override
            public void removePropertyChangeListener(PropertyChangeListener listener) {
            }
        };
    }
    return info;
}
项目:incubator-netbeans    文件:NbModuleProject.java   
private void registerListener(Object qimpl, ExtraSJQEvaluator eJSQEval) {
    try {
        // XXX #66275: ugly hack until proper API change;
        // we need ESJQI to work when project is loaded - not opened - to resolve deps on lib wrapper modules correctly
        Field listenerF = qimpl.getClass().getDeclaredField("listener"); // NOI18N
        listenerF.setAccessible(true);
        eJSQEval.addPropertyChangeListener((PropertyChangeListener) listenerF.get(qimpl));
    } catch (Exception ex) {
        Logger.getLogger(NbModuleProject.class.getName()).log(Level.FINE, "Turning off source query support for loaded project '" + ProjectUtils.getInformation(this).getDisplayName() + "'", ex);
    }
}
项目:incubator-netbeans    文件:VersioningSystem.java   
/**
 * Backdoor for DelegatingVCS
 * 
 * @return 
 */
void moveChangeListeners(VersioningSystem system) {
    synchronized(support) {
        PropertyChangeListener[] listeners = support.getPropertyChangeListeners();
        for (PropertyChangeListener l : listeners) {
            system.addPropertyChangeListener(l);
            this.removePropertyChangeListener(l);
        }
    }
}
项目:incubator-netbeans    文件:CodeEvaluatorUI.java   
public static void addResultListener(final PropertyChangeListener listener) {
    rp.post(new Runnable() {
        @Override
        public void run() {
            CodeEvaluatorUI defaultInstance = getDefaultInstance();
            if (defaultInstance != null) {
                synchronized(defaultInstance.pcs) {
                    defaultInstance.pcs.addPropertyChangeListener(listener);
                }
            }
        }
    });
}
项目:incubator-netbeans    文件:MavenOptionController.java   
void firePropChange(String property, Object oldVal, Object newVal) {
    ArrayList<PropertyChangeListener> lst;
    synchronized (listeners) {
        lst = new ArrayList<PropertyChangeListener>(listeners);
    }
    PropertyChangeEvent evnt = new PropertyChangeEvent(this, property, oldVal, newVal);
    for (PropertyChangeListener prop : lst) {
        if (prop == null) {
            //#180218
            continue;
        }
        prop.propertyChange(evnt);
    }
}
项目:jdk8u-jdk    文件:ProxyClient.java   
public void removePropertyChangeListener(PropertyChangeListener listener) {
    if (!(listener instanceof WeakPCL)) {
        // Search for the WeakPCL holding this listener (if any)
        for (PropertyChangeListener pcl : propertyChangeSupport.getPropertyChangeListeners()) {
            if (pcl instanceof WeakPCL && ((WeakPCL)pcl).get() == listener) {
                listener = pcl;
                break;
            }
        }
    }
    propertyChangeSupport.removePropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:DelegatingVCS.java   
@Override
public final void addPropertyCL(PropertyChangeListener listener) {
    synchronized(DELEGATE_LOCK) {
        if(delegate == null) {
            support.addPropertyChangeListener(listener);
        } else {
            delegate.addPropertyChangeListener(listener);
        }
    }
}
项目:jtk    文件:ModeToggleButton.java   
/**
 * Constructs a mode toggle button for the specified mode.
 * @param mode the mode.
 */
public ModeToggleButton(Mode mode) {
  super(mode);
  setText(null); // ignore mode text (is for menus)
  setMnemonic(0); // ignore mnemonic (is for menus)
  mode.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      if (e.getPropertyName().equals("active"))
        setSelected((Boolean)e.getNewValue());
    }
  });
}
项目:incubator-netbeans    文件:PaletteUtils.java   
public static synchronized void removePaletteListener(PropertyChangeListener listener,
                                                      FileObject context)
{
    Project project = FileOwnerQuery.getOwner(context);
    ProjectPaletteInfo pInfo = palettes.get(project);
    if (pInfo != null && pInfo.paletteListeners != null) {
        pInfo.paletteListeners.remove(listener);
        pInfo.getPalette().removePropertyChangeListener(listener);
    }
}
项目:incubator-netbeans    文件:FilterNode.java   
/** Getter for property change listener.
*/
PropertyChangeListener getPropertyChangeListener() {
    synchronized (LISTENER_LOCK) {
        if (propL == null) {
            propL = createPropertyChangeListener();
        }

        return propL;
    }
}
项目:OpenJSharp    文件:Container.java   
/**
 * Adds a PropertyChangeListener to the listener list.
 *
 * @param listener  the PropertyChangeListener to be added
 */
public void addPropertyChangeListener(PropertyChangeListener listener) {
    if (accessibleContainerHandler == null) {
        accessibleContainerHandler = new AccessibleContainerHandler();
    }
    if (propertyListenersCount++ == 0) {
        Container.this.addContainerListener(accessibleContainerHandler);
    }
    super.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:LocalePropertyEditor.java   
/** Gets custom editor. Overrides superclass method. */
public Component getCustomEditor() {
    final LocalePanel localePanel = new LocalePanel(locale);

    localePanel.addPropertyChangeListener(new PropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent evt) {
            if(LocalePanel.PROP_CUSTOMIZED_LOCALE.equals(evt.getPropertyName()))
                setValue(localePanel.getLocale());
        }
    });

    return localePanel;
}
项目:incubator-netbeans    文件:VersioningSystem.java   
/**
 * Adds a listener for change events.
 * 
 * @param listener a PropertyChangeListener 
 */ 
public final void addPropertyChangeListener(PropertyChangeListener listener) {
    synchronized(support) {
        support.addPropertyChangeListener(listener);
    }
}
项目:incubator-netbeans    文件:MuxClassPathImplementationTest.java   
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
    cs.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:SourcePathImplementation.java   
public void addPropertyChangeListener(PropertyChangeListener listener) {
    support.addPropertyChangeListener (listener);
}
项目:openjdk-jdk10    文件:Test4353056.java   
public void addPropertyChangeListener(PropertyChangeListener listener) {
    this.pcs.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:JavaTypeProviderTest.java   
public void removePropertyChangeListener(final PropertyChangeListener listener) {
    assert listener != null;
    this.support.removePropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:ScanningScopeList.java   
public void removePropertyChangeListener( PropertyChangeListener pcl ) {
    propertySupport.removePropertyChangeListener( pcl );
}
项目:incubator-netbeans    文件:SpellcheckerOptionsPanelController.java   
public void removePropertyChangeListener(PropertyChangeListener l) {
    pcs.removePropertyChangeListener(l);
}
项目:jdk8u-jdk    文件:Test7192955.java   
public void removePropertyChangeListener(PropertyChangeListener listener) {
}
项目:NBANDROID-V2    文件:LogReader.java   
public void addPropertyChangeListener(PropertyChangeListener listener) {
    this.changeSupport.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:SourceGroupsTest.java   
public void removePropertyChangeListener(PropertyChangeListener listener) {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:VASSAL-src    文件:SetGlobalProperty.java   
public Ed(final SetGlobalProperty m) {
  keyCommandListConfig = new ListConfigurer(null, "Key Commands") {
    protected Configurer buildChildConfigurer() {
      return new DynamicKeyCommandConfigurer(m);
    }
  };
  keyCommandListConfig.setValue(
    new ArrayList<DynamicKeyCommand>(Arrays.asList(m.keyCommands)));
  PropertyChangeListener l = new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent evt) {
      boolean isNumeric = numericConfig.booleanValue().booleanValue();
      minConfig.getControls().setVisible(isNumeric);
      maxConfig.getControls().setVisible(isNumeric);
      wrapConfig.getControls().setVisible(isNumeric);
      keyCommandListConfig.repack();
    }
  };
  controls = Box.createVerticalBox();
  descConfig = new StringConfigurer(null, "Description:  ", m.description);
  controls.add(descConfig.getControls());
  nameConfig = new PropertyNameExpressionConfigurer(null, "Global Property Name:  ", m.getKey(), (EditablePiece) m);
  controls.add(nameConfig.getControls());
  levelConfig = new StringEnumConfigurer(null, "", new String[]{CURRENT_ZONE, NAMED_ZONE, NAMED_MAP});
  levelConfig.setValue(m.propertyLevel);
  levelConfig.addPropertyChangeListener(new PropertyChangeListener() {
    public void propertyChange(PropertyChangeEvent e) {
      updateVisibility();
    }
  });
  Box box = Box.createHorizontalBox();
  box.add(new JLabel("Locate Property starting in the:   "));
  box.add(levelConfig.getControls());
  controls.add(box);
  nameBox = Box.createHorizontalBox();
  nameBox.add(new JLabel("Name of "));
  nameBox.add(mapLabel);
  nameBox.add(zoneLabel);
  nameBox.add(new JLabel(" containing property:  "));
  searchNameConfig = new FormattedExpressionConfigurer(null, "", m.searchName, (EditablePiece) m);
  nameBox.add(searchNameConfig.getControls());
  controls.add(nameBox);
  numericConfig = new BooleanConfigurer(null, "Is numeric?", m.isNumeric());
  controls.add(numericConfig.getControls());
  minConfig =
    new IntConfigurer(null, "Minimum value:  ", m.getMinimumValue());
  controls.add(minConfig.getControls());
  maxConfig =
    new IntConfigurer(null, "Maximum value:  ", m.getMaximumValue());
  controls.add(maxConfig.getControls());
  wrapConfig = new BooleanConfigurer(null, "Wrap?", m.isWrap());
  controls.add(wrapConfig.getControls());
  controls.add(keyCommandListConfig.getControls());
  numericConfig.addPropertyChangeListener(l);
  numericConfig.fireUpdate();
  updateVisibility();
}
项目:incubator-netbeans    文件:WellKnownSchemaCatalog.java   
@Override
public void addPropertyChangeListener(PropertyChangeListener l) {}
项目:incubator-netbeans    文件:LibrariesCustomizer.java   
@Override public void addPropertyChangeListener(PropertyChangeListener l) {
    getLibraryImplementation().addPropertyChangeListener(l);
}
项目:incubator-netbeans    文件:ClassPathProviderImpl.java   
@Override
public void addPropertyChangeListener(PropertyChangeListener listener) {
    support.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:Network.java   
public void addPropertyChangeListener(PropertyChangeListener l) {
    support.addPropertyChangeListener(l);
}
项目:Logisim    文件:PropertyChangeWeakSupport.java   
ListenerData(String property, PropertyChangeListener listener) {
    this.property = property;
    this.listener = new WeakReference<PropertyChangeListener>(listener);
}
项目:incubator-netbeans    文件:ForeignClassBundlerImpl.java   
@Override
public void removePropertyChangeListener(PropertyChangeListener listener) {
    pchs.removePropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:OpenProjectList.java   
/** As this class is singletnon, which is not GCed it is good idea to 
 *add WeakListeners or remove the listeners properly.
 */

public void addPropertyChangeListener( PropertyChangeListener l ) {
    pchSupport.addPropertyChangeListener( l );        
}
项目:incubator-netbeans    文件:PathRegistryTest.java   
public void addPropertyChangeListener(PropertyChangeListener listener) {
    this.support.addPropertyChangeListener(listener);
}
项目:incubator-netbeans    文件:WinSysOptionsPanelController.java   
@Override
public void removePropertyChangeListener(PropertyChangeListener l) {
    pcs.removePropertyChangeListener(l);
}
项目:incubator-netbeans    文件:DiffResultsView.java   
@Override
public void perform () {
    showDiffError(NbBundle.getMessage(DiffResultsView.class, "MSG_DiffPanel_LoadingDiff")); //NOI18N
    if (revision1 == null) {
        try {
            revision1 = event2.getLogInfoHeader().getAncestorCommit(event2.getOriginalFile(), getClient(), GitUtils.NULL_PROGRESS_MONITOR);
            file1 = event2.getOriginalFile();
            baseFile1 = event2.getFile();
        } catch (GitException ex) {
            LOG.log(Level.INFO, null, ex);
            showDiffError(NbBundle.getMessage(DiffResultsView.class, "MSG_DiffPanel_LoadingDiff")); //NOI18N
            return;
        }
    }
    if (isCanceled()) {
        return;
    }
    String title1, title2;
    title1 = revision1 == null ? null : revision1.substring(0, 7);
    title2 = event2.getLogInfoHeader().getLog().getRevision() == null ? null : event2.getLogInfoHeader().getLog().getRevision().substring(0, 7);
    s1 = new DiffStreamSource(file1, baseFile1, revision1, file1.getName() + (title1 == null ? "" : (" (" + title1 + ")"))); //NOI18N
    s2 = new DiffStreamSource(event2.getFile(), event2.getFile(), event2.getLogInfoHeader().getLog().getRevision(), 
            event2.getFile().getName() + (title2 == null ? "" : (" (" + title2 + ")"))); //NOI18N

    // it's enqueued at ClientRuntime queue and does not return until previous request handled
    s1.getMIMEType();  // triggers s1.init()
    if (isCanceled()) {
        showDiffError(NbBundle.getMessage(DiffResultsView.class, "MSG_DiffPanel_NoRevisions")); // NOI18N
        return;
    }

    s2.getMIMEType();  // triggers s2.init()
    if (isCanceled()) {
        showDiffError(NbBundle.getMessage(DiffResultsView.class, "MSG_DiffPanel_NoRevisions")); // NOI18N
        return;
    }

    if (currentTask != this) return;

    EventQueue.invokeLater(new Runnable() {
        @Override
        public void run() {
            try {
                if (isCanceled()) {
                    showDiffError(NbBundle.getMessage(DiffResultsView.class, "MSG_DiffPanel_NoRevisions")); // NOI18N
                    return;
                }
                final DiffController view = DiffController.createEnhanced(s1, s2);
                if (currentTask == ShowDiffTask.this) {
                    currentDiff = view;
                    setBottomComponent(currentDiff.getJComponent());
                    final int dl = diffView.getDividerLocation();
                    if (!setLocation(view)) {
                        view.addPropertyChangeListener(new PropertyChangeListener() {
                            @Override
                            public void propertyChange(PropertyChangeEvent evt) {
                                view.removePropertyChangeListener(this);
                                setLocation(view);
                                parent.updateActions();
                            }
                        });
                    }
                    parent.refreshComponents(false);
                    EventQueue.invokeLater(new Runnable () {
                        @Override
                        public void run() {
                            diffView.setDividerLocation(dl);
                        }
                    });
                }
            } catch (IOException e) {
                ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, e);
            }
        }
    });
}
项目:incubator-netbeans    文件:ConnectionCustomEditor.java   
private void methodDetailsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_methodDetailsButtonActionPerformed
    MethodPicker picker = new MethodPicker(formModel, null, valueType);
    picker.setSelectedComponent(selectedComponent);
    picker.setSelectedMethod(selectedMethod);

    String title = FormUtils.getFormattedBundleString(
        "CTL_FMT_CW_SelectMethod", // NOI18N
        new Object[] { valueType.getSimpleName() });

    final DialogDescriptor dd = new DialogDescriptor(picker, title);
    dd.setValid(picker.isPickerValid());
    picker.addPropertyChangeListener("pickerValid", new PropertyChangeListener() { // NOI18N
        @Override
        public void propertyChange(PropertyChangeEvent evt2) {
            dd.setValid(((Boolean)evt2.getNewValue()).booleanValue());
        }
    });
    Dialog dialog = DialogDisplayer.getDefault().createDialog(dd);
    dialog.setVisible(true);

    if (dd.getValue() == DialogDescriptor.OK_OPTION) {
        selectedComponent = picker.getSelectedComponent();

 MethodPicker.MethodPickerItem selectedItem = picker.getSelectedMethod();       
 selectedMethod = selectedItem.getMethodDescriptor();

        methodField.setEnabled(true);
        if (selectedComponent == formModel.getTopRADComponent()) {
            methodField.setText(selectedItem.getMethodName());
        } else {
            methodField.setText(selectedComponent.getName() + "." + selectedMethod.getName()); // NOI18N
        }

        if (selectedComponent != null && selectedMethod != null) {
            propertyEditor.setValue(new RADConnectionPropertyEditor.RADConnectionDesignValue(selectedComponent, selectedMethod));
        } else if (selectedItem.getMethodName() != null) {
            propertyEditor.setValue(new RADConnectionPropertyEditor.RADConnectionDesignValue(selectedItem.getMethodName()));
        } else {
            propertyEditor.setValue(BeanSupport.NO_VALUE);
        }
    }
}
项目:incubator-netbeans    文件:SearchHistory.java   
/** Removes a property change listener.
 * @param pcl the listener to remove
 */
public void removePropertyChangeListener(PropertyChangeListener pcl){
    if (pcs != null){
        pcs.removePropertyChangeListener(pcl);
    }
}