void changed() {
    if (!changed) {
      changed = true;

      try {
        pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
      } catch (Exception e) {
        logger.log(
            Level.SEVERE,
            "KeywordSearchOptionsPanelController listener threw exception",
            e); // NON-NLS
        MessageNotifyUtil.Notify.show(
            NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr"),
            NbBundle.getMessage(
                this.getClass(), "KeywordSearchOptionsPanelController.moduleErr.msg1"),
            MessageNotifyUtil.MessageType.ERROR);
      }
    }
    try {
      pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
    } catch (Exception e) {
      logger.log(
          Level.SEVERE,
          "KeywordSearchOptionsPanelController listener threw exception",
          e); // NON-NLS
      MessageNotifyUtil.Notify.show(
          NbBundle.getMessage(this.getClass(), "KeywordSearchOptionsPanelController.moduleErr"),
          NbBundle.getMessage(
              this.getClass(), "KeywordSearchOptionsPanelController.moduleErr.msg2"),
          MessageNotifyUtil.MessageType.ERROR);
    }
  }
示例#2
0
文件: Case.java 项目: halbbob/autopsy
  /**
   * Updates the current case to the given case and fires off the appropriate property-change
   *
   * @param newCase the new current case
   */
  private static void changeCase(Case newCase) {

    Case oldCase = Case.currentCase;
    Case.currentCase = null;

    String oldCaseName = oldCase != null ? oldCase.name : "";

    doCaseChange(null); // closes windows, etc
    pcs.firePropertyChange(CASE_CURRENT_CASE, oldCase, null);

    doCaseNameChange("");
    pcs.firePropertyChange(CASE_NAME, oldCaseName, "");

    if (newCase != null) {
      currentCase = newCase;

      pcs.firePropertyChange(CASE_CURRENT_CASE, null, currentCase);
      doCaseChange(currentCase);

      pcs.firePropertyChange(CASE_NAME, "", currentCase.name);
      doCaseNameChange(currentCase.name);

      RecentCases.getInstance()
          .addRecentCase(currentCase.name, currentCase.configFilePath); // update the recent cases
    }
  }
 /**
  * Call this method when an option has dataChanged it's value. This will cause a property change
  * event to be fired and starts data validation.
  */
 public void dataChanged() {
   if (!changed) {
     changed = true;
     pcs.firePropertyChange(OptionsPanelController.PROP_CHANGED, false, true);
   }
   pcs.firePropertyChange(OptionsPanelController.PROP_VALID, null, null);
 }
示例#4
0
 public void addPropertyChangeListener(PropertyChangeListener listener) {
   List<PropertyChangeListener> listeners =
       Arrays.asList(propertyChangeSupport.getPropertyChangeListeners());
   if (!listeners.contains(listener)) {
     propertyChangeSupport.addPropertyChangeListener(listener);
   }
 }
示例#5
0
 @Override
 public void dispose() {
   final PropertyChangeListener[] changeListeners = changeSupport.getPropertyChangeListeners();
   for (PropertyChangeListener changeListener : changeListeners) {
     changeSupport.removePropertyChangeListener(changeListener);
   }
 }
 @Override
 public void addPropertyChangeListener(PropertyChangeListener listener) {
   // Ignore duplicate method calls.
   for (PropertyChangeListener l : pcs.getPropertyChangeListeners()) {
     if (l == listener) return;
   }
   pcs.addPropertyChangeListener(listener);
 }
 private void fireAllFunction(boolean oldHas1, boolean oldHas2) {
   property.firePropertyChange(
       "firstFunctionOnly", (!oldHas2) && oldHas1, (!plotFunction2) && plotFunction1);
   property.firePropertyChange(
       "secondFunctionOnly", (!oldHas1) && oldHas2, (!plotFunction1) && plotFunction2);
   property.firePropertyChange("bothFunction", oldHas1 && oldHas2, plotFunction1 && plotFunction2);
   autoScale();
 }
示例#8
0
 public void setFastaFile(GridFile inputFile) {
   GridFile old = this.fastaFile;
   inputFiles.remove(inputFile.getUrl());
   this.fastaFile = inputFile;
   inputFiles.put(inputFile.getUrl(), null);
   pcs.firePropertyChange("fastaFile", old, this.fastaFile);
   pcs.firePropertyChange("inputFiles", null, inputFiles);
 }
  public void testOldAndNewAreBothNull() {
    Object bean = new Object();
    PropertyChangeSupport support = new PropertyChangeSupport(bean);
    EventLog listener = new EventLog();
    support.addPropertyChangeListener(listener);

    PropertyChangeEvent nullToNull = new PropertyChangeEvent(bean, "a", null, null);
    support.firePropertyChange(nullToNull);
    assertEquals(Arrays.<PropertyChangeEvent>asList(nullToNull), listener.log);
  }
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   _path = (String) evt.getNewValue();
   _image = (PlanarImage) evt.getOldValue();
   updateImage();
   if (_support.hasListeners("_low")) {
     System.out.println("TH _support true");
     _support.firePropertyChange("TRESHHOLD.update", _image, _path);
   }
 }
  public void testOldAndNewAreTheSame() {
    Object bean = new Object();
    PropertyChangeSupport support = new PropertyChangeSupport(bean);
    EventLog listener = new EventLog();
    support.addPropertyChangeListener(listener);

    PropertyChangeEvent xToX = new PropertyChangeEvent(bean, "a", "x", new String("x"));
    support.firePropertyChange(xToX);
    assertEquals(Arrays.<PropertyChangeEvent>asList(), listener.log);
  }
示例#12
0
 /**
  * Support for reporting bound property changes. If oldValue and newValue are not equal and the
  * PropertyChangeEvent listener list is not empty, then fire a PropertyChange event to each
  * listener. In general, this is for use by the Accessible objects themselves and should not be
  * called by an application program.
  *
  * @param propertyName The programmatic name of the property that was changed.
  * @param oldValue The old value of the property.
  * @param newValue The new value of the property.
  * @see java.beans.PropertyChangeSupport
  * @see #addPropertyChangeListener
  * @see #removePropertyChangeListener
  * @see #ACCESSIBLE_NAME_PROPERTY
  * @see #ACCESSIBLE_DESCRIPTION_PROPERTY
  * @see #ACCESSIBLE_STATE_PROPERTY
  * @see #ACCESSIBLE_VALUE_PROPERTY
  * @see #ACCESSIBLE_SELECTION_PROPERTY
  * @see #ACCESSIBLE_TEXT_PROPERTY
  * @see #ACCESSIBLE_VISIBLE_DATA_PROPERTY
  */
 public void firePropertyChange(String propertyName, Object oldValue, Object newValue) {
   if (accessibleChangeSupport != null) {
     if (newValue instanceof PropertyChangeEvent) {
       PropertyChangeEvent pce = (PropertyChangeEvent) newValue;
       accessibleChangeSupport.firePropertyChange(pce);
     } else {
       accessibleChangeSupport.firePropertyChange(propertyName, oldValue, newValue);
     }
   }
 }
  public void setPlotFunction12(boolean p1, boolean p2) {
    boolean o1 = this.plotFunction1;
    boolean o2 = this.plotFunction2;

    this.plotFunction1 = hasFunction1 && p1;
    property.firePropertyChange("plotFunction1", o1, p1);

    this.plotFunction2 = hasFunction2 && p2;
    property.firePropertyChange("plotFunction1", o2, p2);
    fireAllFunction(o1, o2);
  }
  /**
   * Returns an array of all the listeners which have been associated with the named property.
   *
   * @param propertyName The name of the property being listened to
   * @return all of the <code>PropertyChangeListeners</code> associated with the named property. If
   *     no such listeners have been added, or if <code>propertyName</code> is null, an empty array
   *     is returned.
   */
  public synchronized PropertyChangeListener[] getPropertyChangeListeners(String propertyName) {
    ArrayList returnList = new ArrayList();

    if (children != null && propertyName != null) {
      PropertyChangeSupport support = (PropertyChangeSupport) children.get(propertyName);
      if (support != null) {
        returnList.addAll(Arrays.asList(support.getPropertyChangeListeners()));
      }
    }
    return (PropertyChangeListener[]) (returnList.toArray(new PropertyChangeListener[0]));
  }
  /**
   * Sets the predefinedIdState
   *
   * @param predefinedIdState the predefinedIdState to set
   */
  public void setPredefinedIdState(String predefinedIdState) {
    String oldPredefinedIdState = this.predefinedIdState;
    this.predefinedIdState = predefinedIdState;

    // change also the controller descriptor as a consequence
    this.descriptor =
        PropertyEditorControllerService.getInstance()
            .createPredefinedControllerDescriptor(predefinedIdState);

    changeSupport.firePropertyChange("predefinedId", oldPredefinedIdState, this.predefinedIdState);
    changeSupport.firePropertyChange("descriptor", null, descriptor);
  }
示例#16
0
 /**
  * Sets the default value for the given input field.
  *
  * @param field the input field
  * @param value the default value, or <code>null</code> if the given input field should have no
  *     default value
  */
 public void setDefault(InputField field, Object value) {
   final Object oldValue = defaults.get(field);
   if (oldValue == null && value != null) {
     defaults.put(field, value);
     changeSupport.firePropertyChange(DEFAULTS_PROPERTY, oldValue, value);
   } else if (oldValue != null && value == null) {
     defaults.remove(field);
     changeSupport.firePropertyChange(DEFAULTS_PROPERTY, oldValue, value);
   } else if (oldValue != null && value != null && !oldValue.equals(value)) {
     defaults.put(field, value);
     changeSupport.firePropertyChange(DEFAULTS_PROPERTY, oldValue, value);
   }
 }
 /**
  * Remove a PropertyChangeListener for a specific property. If <code>listener</code> was added
  * more than once to the same event source for the specified property, it will be notified one
  * less time after being removed. If <code>propertyName</code> is null, no exception is thrown and
  * no action is taken. If <code>listener</code> is null, or was never added for the specified
  * property, no exception is thrown and no action is taken.
  *
  * @param propertyName The name of the property that was listened on.
  * @param listener The PropertyChangeListener to be removed
  */
 public synchronized void removePropertyChangeListener(
     String propertyName, PropertyChangeListener listener) {
   if (listener == null || propertyName == null) {
     return;
   }
   if (children == null) {
     return;
   }
   PropertyChangeSupport child = (PropertyChangeSupport) children.get(propertyName);
   if (child == null) {
     return;
   }
   child.removePropertyChangeListener(listener);
 }
示例#18
0
 public synchronized void addChild(AbstractNode child, boolean expandTo) {
   if (children == null) {
     children = new ArrayList<AbstractNode>();
   }
   children.add(child);
   child.setParent(this);
   if (!(child instanceof WaitingNode)) {
     if (expandTo) {
       propertyChangeSupport.firePropertyChange(EXPAND_TO, null, this);
     } else {
       propertyChangeSupport.firePropertyChange(NODE_CHILDREN_MODIFIED, null, this);
     }
   }
 }
 /**
  * Add a PropertyChangeListener for a specific property. The listener will be invoked only when a
  * call on firePropertyChange names that specific property. The same listener object may be added
  * more than once. For each property, the listener will be invoked the number of times it was
  * added for that property. If <code>propertyName</code> or <code>listener</code> is null, no
  * exception is thrown and no action is taken.
  *
  * @param propertyName The name of the property to listen on.
  * @param listener The PropertyChangeListener to be added
  */
 public synchronized void addPropertyChangeListener(
     String propertyName, PropertyChangeListener listener) {
   if (listener == null || propertyName == null) {
     return;
   }
   if (children == null) {
     children = new java.util.Hashtable();
   }
   PropertyChangeSupport child = (PropertyChangeSupport) children.get(propertyName);
   if (child == null) {
     child = new PropertyChangeSupport(source);
     children.put(propertyName, child);
   }
   child.addPropertyChangeListener(listener);
 }
示例#20
0
  @Test
  public void setFireGet() throws Exception {

    LastChange lc = new LastChange(new RenderingControlLastChangeParser());

    lc.setEventedValue(0, new RenderingControlVariable.PresetNameList("foo"));
    lc.setEventedValue(0, new RenderingControlVariable.PresetNameList("foobar")); // Double set!

    lc.setEventedValue(
        0, new RenderingControlVariable.Volume(new ChannelVolume(Channel.Master, 123)));

    lc.setEventedValue(
        1, new RenderingControlVariable.Brightness(new UnsignedIntegerTwoBytes(456)));

    final String[] lcValue = new String[1];
    PropertyChangeSupport pcs = new PropertyChangeSupport(this);
    pcs.addPropertyChangeListener(
        new PropertyChangeListener() {
          public void propertyChange(PropertyChangeEvent ev) {
            if (ev.getPropertyName().equals("LastChange")) lcValue[0] = (String) ev.getNewValue();
          }
        });
    lc.fire(pcs);

    // Check it's clear
    assertEquals(lc.getEventedValue(0, RenderingControlVariable.PresetNameList.class), null);
    assertEquals(lc.toString(), "");

    // Set something again, it's not fired, so it has no consequence on further assertions
    lc.setEventedValue(0, new RenderingControlVariable.PresetNameList("foo"));

    // Read the XML string instead
    lc = new LastChange(new RenderingControlLastChangeParser(), lcValue[0]);

    assertEquals(
        lc.getEventedValue(0, RenderingControlVariable.PresetNameList.class).getValue(), "foobar");

    assertEquals(
        lc.getEventedValue(0, RenderingControlVariable.Volume.class).getValue().getChannel(),
        Channel.Master);
    assertEquals(
        lc.getEventedValue(0, RenderingControlVariable.Volume.class).getValue().getVolume(),
        new Integer(123));

    assertEquals(
        lc.getEventedValue(1, RenderingControlVariable.Brightness.class).getValue(),
        new UnsignedIntegerTwoBytes(456));
  }
 /**
  * Removes a PropertyChangeListener from the listener list for a specific property. This method
  * should be used to remove PropertyChangeListeners that were registered for a specific bound
  * property.
  *
  * <p>If listener is null, no exception is thrown and no action is performed.
  *
  * @param propertyName a valid property name
  * @param listener the PropertyChangeListener to be removed
  * @see #addPropertyChangeListener(java.lang.String, java.beans.PropertyChangeListener)
  * @see #getPropertyChangeListeners(java.lang.String)
  * @see #removePropertyChangeListener(java.beans.PropertyChangeListener)
  */
 public synchronized void removePropertyChangeListener(
     String propertyName, PropertyChangeListener listener) {
   if (listener == null || changeSupport == null) {
     return;
   }
   changeSupport.removePropertyChangeListener(propertyName, listener);
 }
示例#22
0
 /**
  * Set batching for changes to <code>PanelModel</code>. Fires property "batch" when <code>
  * PanelModel</code> has changed and batch is set to false.
  *
  * @param batch batch value
  */
 public void setBatch(boolean batch) {
   this.batch = batch;
   if (!this.batch && modified) {
     modified = false;
     support_.firePropertyChange("batch", null, null);
   }
 }
 /**
  * Adds a property change listener.Static for simplicity of use.
  *
  * @param key The specific key to listen for.
  * @param p The class which will listen for property changes.
  */
 public final void addListener(ConfigurationKey key, PropertyChangeListener p) {
   if (pcl == null) {
     pcl = new PropertyChangeSupport(this);
   }
   LOG.debug("addPropertyChangeListener(" + key.getKey() + ")");
   pcl.addPropertyChangeListener(key.getKey(), p);
 }
示例#24
0
  /**
   * Set the distributable flag for the sessions supported by this Manager. If this flag is set, all
   * user data objects added to sessions associated with this manager must implement Serializable.
   *
   * @param distributable The new distributable flag
   */
  public void setDistributable(boolean distributable) {

    boolean oldDistributable = this.distributable;
    this.distributable = distributable;
    support.firePropertyChange(
        "distributable", new Boolean(oldDistributable), new Boolean(this.distributable));
  }
示例#25
0
  /**
   * Sets the session id length (in bytes) for Sessions created by this Manager.
   *
   * @param idLength The session id length
   */
  public void setSessionIdLength(int idLength) {

    int oldSessionIdLength = this.sessionIdLength;
    this.sessionIdLength = idLength;
    support.firePropertyChange(
        "sessionIdLength", new Integer(oldSessionIdLength), new Integer(this.sessionIdLength));
  }
示例#26
0
  public void setCurrentSelectedOntology(ITerminology newTermino) {
    ITerminology oldSelectedTermino = currentSelectedTerminology;
    currentSelectedTerminology = newTermino;

    propertyChangeSupport.firePropertyChange(
        SELECT_TERMINOLOGY_EVENT, oldSelectedTermino, currentSelectedTerminology);
  }
示例#27
0
 /** @since 3.0 */
 public void setYArray(GeoDateArray tArray) {
   tArray_ = tArray;
   yTime_ = true;
   yArray_ = null;
   yRange_ = computeSoTRange(tArray);
   changes_.firePropertyChange("dataModified", new Integer(0), new Integer(tArray.getLength()));
 }
示例#28
0
 /**
  * Sets the color used by the factory to generate shadows.
  *
  * <p>Consecutive calls to {@link #createShadow} will all use this color until it is set again.
  *
  * <p>If the color provided is null, the previous color will be retained.
  *
  * @param shadowColor the generated shadows color
  */
 public void setColor(final Color shadowColor) {
   if (shadowColor != null) {
     Color oldColor = this.color;
     this.color = shadowColor;
     changeSupport.firePropertyChange(COLOR_CHANGED_PROPERTY, oldColor, this.color);
   }
 }
示例#29
0
        @Override
        public void valueChanged(ListSelectionEvent e) {
          if (!fireSelectionEvent || e.getValueIsAdjusting()) return;

          int id = getSelectedId();
          listeners.firePropertyChange(PROPERTY_SelectedId, null, id);
        }
示例#30
0
 private void firePropertyChange(String name, int oldValue, int newValue) {
   if (batch) {
     modified = true;
   } else {
     support_.firePropertyChange(name, oldValue, newValue);
   }
 }