Exemplo n.º 1
0
  @Override
  public void referenceModified(RefObject target, PropertyChangeEvent evt) {
    if (((RefObject) evt.getNewValue()).refMetaObject().refGetValue("name").equals("Model")) return;
    if (!(makeKuaba(evt.getPropertyName()))) return;

    RefObject source = (RefObject) evt.getSource();
    if (!KuabaSubsystem.facade.existsDomainIdea(target)) {
      PropertyChangeEvent nameEvt =
          new PropertyChangeEvent(target, "name", "", target.refGetValue("name"));
      PropertyChangeListener listener = KuabaSubsystem.eventPump.getObserver(target);
      if (listener == null) {
        listener = this.createListener(target);
        if (listener == null) return;
        KuabaSubsystem.eventPump.addModelElementObserver(listener, target);
      }
      listener.propertyChange(nameEvt);
      Reference ref =
          MofHelper.getReference(evt.getPropertyName(), (MofClass) source.refMetaObject());
      if (!(ref == null)) {
        String otherSide = MofHelper.getExposedEndName(ref);
        try {
          PropertyChangeEvent referenceEvt =
              new PropertyChangeEvent(target, otherSide, null, target.refGetValue(otherSide));
          listener.propertyChange(referenceEvt);
        } catch (Exception e) {
          // TODO: handle exception
        }
      }
    }
    // para evitar a criação do feature
    if (evt.getPropertyName().equals("feature")) return;

    // aqui que cria as outras questões do tipo participant e owner
    Decision d =
        KuabaSubsystem.facade.referenceChanged(
            (RefObject) evt.getSource(), target, evt.getPropertyName());
    Idea sourceDomainIdea =
        KuabaHelper.getDomainIdea(
            modelRepository(),
            KuabaSubsystem.resolver.resolveXmiId((RefObject) evt.getSource()),
            this.getNamePropertyValue((RefObject) evt.getSource()));
    Idea sourceDesignIdea =
        KuabaHelper.getAcceptedDesignIdea(
            sourceDomainIdea,
            (String) ((RefObject) evt.getSource()).refMetaObject().refGetValue("name"));

    askReferenceChangeArguments(
        d.getConcludes(),
        (Question)
            KuabaHelper.getReasoningElementInTree(sourceDesignIdea, evt.getPropertyName() + "?"),
        evt);

    // tirando as ideias de dominio extras
    if (sourceDesignIdea.getHasText().equals("AssociationEnd")) {
      sourceDomainIdea.listSuggests().next().remove();
      sourceDomainIdea.remove();
    }
  }
Exemplo n.º 2
0
 public void propertyChange(String propertyName, Object oldValue, Object newValue) {
   if (listener != null) {
     if (oldValue != newValue) {
       listener.propertyChange(new PropertyChangeEvent(this, propertyName, oldValue, newValue));
     }
   }
 }
  private void okButtonActionPerformed(
      java.awt.event.ActionEvent evt) { // GEN-FIRST:event_okButtonActionPerformed
    // Validation
    boolean ok = true;
    String name = nameTextField.getText();
    if (name == null || name.trim().length() == 0) {
      JOptionPane.showMessageDialog(this, "Name is required", "Error", JOptionPane.ERROR_MESSAGE);
      ok = false;
    }
    if (commandComboBox.isVisible()) {
      String command = (String) commandComboBox.getSelectedItem();
      if (command == null || command.trim().length() == 0) {
        JOptionPane.showMessageDialog(
            this, "Command is required", "Error", JOptionPane.ERROR_MESSAGE);
        ok = false;
      }
    }
    if (ok) {
      this.setVisible(false);

      AbstractMenuItemType newValue = getValue();
      PropertyChangeEvent event = new PropertyChangeEvent(this, "value", oldValue, newValue);
      for (PropertyChangeListener listener : getPropertyChangeListeners()) {
        listener.propertyChange(event);
      }
    }
  } // GEN-LAST:event_okButtonActionPerformed
Exemplo n.º 4
0
 @Override
 public void propertyChange(PropertyChangeEvent evt) {
   String n = evt.getPropertyName();
   if (propertyName.equals(n)) {
     listener.propertyChange(evt);
   }
 }
Exemplo n.º 5
0
 public void setAnnotations(List<String> annotations) {
   if (listener != null) {
     listener.propertyChange(
         new PropertyChangeEvent(this, "annotations", this.annotations, annotations));
   }
   this.annotations = annotations;
 }
Exemplo n.º 6
0
 public void setNamespace(String namespace) {
   if (listener != null) {
     listener.propertyChange(
         new PropertyChangeEvent(this, "namespace", this.namespace, namespace));
   }
   this.namespace = namespace;
 }
Exemplo n.º 7
0
 public void setEqualsBehavior(AssertBehaviorOption equalsBehaviour) {
   if (listener != null) {
     listener.propertyChange(
         new PropertyChangeEvent(this, "equalsBehavior", this.equalsBehavior, equalsBehavior));
   }
   this.equalsBehavior = equalsBehaviour;
 }
Exemplo n.º 8
0
 public void collectionChange(
     String propertyName, Object oldValue, Object newValue, int changeType) {
   if (listener != null) {
     listener.propertyChange(
         new CollectionChangeEvent(this, propertyName, oldValue, newValue, changeType));
   }
 }
Exemplo n.º 9
0
 public void setEventProcessingMode(EventProcessingOption eventProcessingMode) {
   if (listener != null) {
     listener.propertyChange(
         new PropertyChangeEvent(
             this, "eventProcessingMode", this.eventProcessingMode, eventProcessingMode));
   }
   this.eventProcessingMode = eventProcessingMode;
 }
Exemplo n.º 10
0
  protected void fireCollectionEvent() {

    final PropertyChangeListener[] listeners =
        listenerList.getListeners(PropertyChangeListener.class);

    for (PropertyChangeListener l : listeners) {
      l.propertyChange(null);
    }
  }
Exemplo n.º 11
0
 protected void notifyListeners(String property, String before, String after) {
   synchronized (listeners) {
     for (Iterator<PropertyChangeListener> it = listeners.iterator(); it.hasNext(); ) {
       PropertyChangeListener propertyChangeListener = it.next();
       propertyChangeListener.propertyChange(
           new PropertyChangeEvent(this, property, before, after));
     }
   }
 }
Exemplo n.º 12
0
 protected void firePropertyChangeEvent(PropertyChangeEvent event) {
   // Me
   for (PropertyChangeListener listener : listenerList) {
     listener.propertyChange(event);
   }
   // Propagate up
   if (parent != null) {
     parent.firePropertyChangeEvent(event);
   }
 }
Exemplo n.º 13
0
    public void propertyChange(PropertyChangeEvent pce) {
      PropertyChangeListener pcl = get();

      if (pcl == null) {
        // The referent listener was GC'ed, we're no longer
        // interested in PropertyChanges, remove the listener.
        dispose();
      } else {
        pcl.propertyChange(pce);
      }
    }
Exemplo n.º 14
0
  /**
   * Fires off a list of property change events to any interested listeners.
   *
   * @param changes The list of property changes to fire off.
   */
  private void notifyChanges(Iterable<PropertyChangeEvent> changes) {
    List<PropertyChangeListener> activeListeners = listeners.getActiveListeners();

    if (activeListeners != null) {
      for (PropertyChangeListener listener : activeListeners) {
        for (PropertyChangeEvent event : changes) {
          listener.propertyChange(event);
        }
      }
    }
  }
Exemplo n.º 15
0
  /**
   * Fire a property change event to each listener.
   *
   * @param bean Bean being edited.
   * @param propName Name of the property.
   * @param oldValue Old value.
   * @param newValue New value.
   */
  protected void firePropertyChange(
      Object bean, String propName, Object oldValue, Object newValue) {

    PropertyChangeEvent e = new PropertyChangeEvent(bean, propName, oldValue, newValue);

    Iterator it = _changeListeners.iterator();
    while (it.hasNext()) {
      PropertyChangeListener l = (PropertyChangeListener) it.next();
      l.propertyChange(e);
    }
  }
Exemplo n.º 16
0
 public void setKSessions(Map<String, KSession> kSessions) {
   if (listener != null) {
     listener.propertyChange(
         new PropertyChangeEvent(this, "kSessions", this.kSessions, kSessions));
     for (KSession ksession : kSessions.values()) {
       // make sure the listener is set for each ksession
       ksession.setListener(listener);
     }
   }
   this.kSessions = kSessions;
 }
Exemplo n.º 17
0
 public void collectionChange(
     String propertyName,
     Collection changedCollection,
     Object newObject,
     int changeType,
     boolean isChangeApplied) {
   if (listener != null) {
     listener.propertyChange(
         new CollectionChangeEvent(
             this, propertyName, changedCollection, newObject, changeType, isChangeApplied));
   }
 }
  public void testNotifyListeners() throws Exception {
    PropertyChangeListener listener = EasyMock.createMock(PropertyChangeListener.class);
    listener.propertyChange(EasyMock.isA(PropertyChangeEvent.class));
    EasyMock.replay(listener);

    BarsDataSeriesFunction function = new BarsDataSeriesFunction();
    function.addPropertyChangeListener(BarsDataSeriesFunction.PROP_BARS, listener);

    Bar bar = new Bar(new Date(), TimeSpan.days(1), 10.0, 11.0, 9.0, 10.0, 1000L);
    function.append(bar);

    EasyMock.verify(listener);
  }
Exemplo n.º 19
0
 /*     */ public Object put(Object paramObject1, Object paramObject2) /*     */ {
   /*  72 */ Object localObject = this.theMap.put(paramObject1, paramObject2);
   /*     */ PropertyChangeEvent localPropertyChangeEvent;
   /*  73 */ if ((paramObject2 != localObject) && (!this.listenerList.isEmpty()))
   /*     */ {
     /*  75 */ localPropertyChangeEvent =
         new PropertyChangeEvent(this, (String) paramObject1, localObject, paramObject2);
     /*     */
     /*  78 */ for (PropertyChangeListener localPropertyChangeListener : this.listenerList) {
       /*  79 */ localPropertyChangeListener.propertyChange(localPropertyChangeEvent);
       /*     */ }
     /*     */ }
   /*  82 */ return localObject;
   /*     */ }
Exemplo n.º 20
0
 private static void assertRevisions(
     final DataSetModel model, long r0, long r1, Runnable runnable) {
   PropertyChangeListener listener = EasyMock.createStrictMock(PropertyChangeListener.class);
   for (long r = r0; r < r1; ++r) {
     listener.propertyChange(
         JUnitUtil.eqPropertyChangeEvent(
             new PropertyChangeEvent(model, DataSetModel.PROPERTY_REVISION, r, r + 1)));
   }
   EasyMock.replay(listener);
   model.addPropertyChangeListener(listener);
   runnable.run();
   EasyMock.verify(listener);
   model.removePropertyChangeListener(listener);
 }
  /** Report that we have been modified to any interested listeners. */
  public void firePropertyChange() {
    Vector<PropertyChangeListener> targets;
    synchronized (this) {
      if (listeners == null) {
        return;
      }
      targets = new Vector<PropertyChangeListener>(listeners);
    }
    // Tell our listeners that "everything" has changed.
    PropertyChangeEvent evt = new PropertyChangeEvent(this.editor, "value", null, null);

    for (PropertyChangeListener l : targets) {
      l.propertyChange(evt);
    }
  }
Exemplo n.º 22
0
  private void firePropertyChanged(String name, String oldValue, String newValue) {
    List listeners = (List) this.changeListeners.get(name);
    if (listeners == null || listeners.size() == 0) return;

    // Making a shallow copy of the list prevents a
    // ConcurrentModificationException
    List l2 = new ArrayList(listeners);
    PropertyChangeEvent evt = new PropertyChangeEvent(this, name, oldValue, newValue);

    for (int i = 0; i < l2.size(); i++) {
      PropertyChangeListener l = (PropertyChangeListener) l2.get(i);
      if (l != null) {
        l.propertyChange(evt);
      }
    }
  }
  /**
   * @see ChangeSupport.Notifier#propertyChange(java.beans.PropertyChangeListener,
   *     java.beans.PropertyChangeEvent)
   */
  public void propertyChange(
      final PropertyChangeListener listener, final PropertyChangeEvent event) {
    if (EventQueue.isDispatchThread()) {
      listener.propertyChange(event);
    } else {
      this.invoke(
          new Runnable() {
            public void run() {
              listener.propertyChange(event);
            }

            public String toString() {
              return "propertyChange";
            }
          });
    }
  }
 /**
  * Set the value of the appropriate attribute of target to attributeValue. In this case, place the
  * value inside the target's ValueHolder. if trackChanges is true, set the value in the object as
  * if the user was setting it. Allow change tracking to pick up the change.
  */
 @Override
 public void setRealAttributeValueInObject(
     Object target, Object attributeValue, boolean trackChanges) {
   Object oldValue = null;
   if (trackChanges && (target instanceof ChangeTracker)) {
     oldValue =
         getRealAttributeValueFromObject(target, mapping.getAttributeValueFromObject(target));
   }
   setRealAttributeValueInObject(target, attributeValue);
   if (trackChanges && (target instanceof ChangeTracker)) {
     PropertyChangeListener listener =
         ((ChangeTracker) target)._persistence_getPropertyChangeListener();
     if (listener != null && attributeValue != oldValue) {
       listener.propertyChange(
           new PropertyChangeEvent(target, mapping.getAttributeName(), oldValue, attributeValue));
     }
   }
 }
Exemplo n.º 25
0
  /**
   * Create a horizontal "separator" that can have a title and can be used in a {@link JPopupMenu}.
   *
   * @param bundleName The resource bundle string used to get this separator's text.
   * @return A horizontal "separator" that can have a title and can be used in a {@link JPopupMenu}.
   */
  public JTitledSeparator createToolbarDropdownSeparator(final String bundleName) {
    final JTitledSeparator separator = new JTitledSeparator("");

    PropertyChangeListener listener =
        new PropertyChangeListener() {
          @Override
          public void propertyChange(PropertyChangeEvent evt) {
            try {
              separator.setTitle(messages.getString(bundleName));
            } catch (MissingResourceException e) {
              separator.setTitle("");
            }
          }
        };
    listener.propertyChange(new PropertyChangeEvent(this, "messages", null, messages));
    addPropertyChangeListener("messages", listener);

    return separator;
  }
Exemplo n.º 26
0
  /** add a blue participant */
  void addBlueFile(final String val) {
    // read in this participant
    try {
      final ParticipantType newPart =
          ASSET.Util.XML.ASSETReaderWriter.importParticipant(val, new java.io.FileInputStream(val));

      if (newPart != null) {
        // update the time to match the scenario
        newPart.getStatus().setTime(_myScenario.getTime());

        // and add to the scenario
        _myScenario.addBlueParticipant(0, newPart);
      }
    } catch (java.io.FileNotFoundException fe) {
      fe.printStackTrace();
    }

    // inform the listener
    _listener.propertyChange(new PropertyChangeEvent(this, "blue", null, null));
  }
Exemplo n.º 27
0
 /**
  * @param bundleName The name of the resource bundle this toolbar will fetch the localizations
  *     from.
  */
 public OrigamistToolBar(String bundleName) {
   super();
   this.bundleName = bundleName;
   PropertyChangeListener l =
       new PropertyChangeListener() {
         @Override
         public void propertyChange(PropertyChangeEvent evt) {
           ResourceBundle oldAppMessages = messages;
           messages =
               ResourceBundle.getBundle(
                   OrigamistToolBar.this.bundleName, (Locale) evt.getNewValue());
           if (oldAppMessages == null || !oldAppMessages.equals(messages))
             firePropertyChange("messages", oldAppMessages, messages);
         }
       };
   ServiceLocator.get(ConfigurationManager.class).get().addPropertyChangeListener("locale", l);
   l.propertyChange(
       new PropertyChangeEvent(
           this,
           "locale",
           null,
           ServiceLocator.get(ConfigurationManager.class).get().getLocale()));
 }
Exemplo n.º 28
0
  /**
   * This is a little hacky, I'm not sure how to make this better when it's so late If a better
   * implementation is clear please re-write
   *
   * <p>This method invokes the change listener which will create the view objects on the petri net
   * tab
   *
   * @param propertyChangeListener
   */
  private void initialiseNet(PetriNet net, PropertyChangeListener propertyChangeListener) {
    for (Token token : net.getTokens()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(net, PetriNet.NEW_TOKEN_CHANGE_MESSAGE, null, token);
      propertyChangeListener.propertyChange(changeEvent);
    }

    for (Place place : net.getPlaces()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(net, PetriNet.NEW_PLACE_CHANGE_MESSAGE, null, place);
      propertyChangeListener.propertyChange(changeEvent);
    }

    for (Transition transition : net.getTransitions()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(net, PetriNet.NEW_TRANSITION_CHANGE_MESSAGE, null, transition);
      propertyChangeListener.propertyChange(changeEvent);
    }

    for (Arc<? extends Connectable, ? extends Connectable> arc : net.getArcs()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(net, PetriNet.NEW_ARC_CHANGE_MESSAGE, null, arc);
      propertyChangeListener.propertyChange(changeEvent);
    }

    for (Annotation annotation : net.getAnnotations()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(net, PetriNet.NEW_ANNOTATION_CHANGE_MESSAGE, null, annotation);
      propertyChangeListener.propertyChange(changeEvent);
    }

    for (RateParameter rateParameter : net.getRateParameters()) {
      PropertyChangeEvent changeEvent =
          new PropertyChangeEvent(
              net, PetriNet.NEW_RATE_PARAMETER_CHANGE_MESSAGE, null, rateParameter);
      propertyChangeListener.propertyChange(changeEvent);
    }
  }
Exemplo n.º 29
0
  /** record the control file */
  void setControlFile(final String val) {
    _controlFile = val;

    // inform the listener
    _listener.propertyChange(new PropertyChangeEvent(this, "control", null, null));
  }
Exemplo n.º 30
0
  /** record the template file */
  void setTemplateFile(final String val) {
    _templateFile = val;

    // inform the listener
    _listener.propertyChange(new PropertyChangeEvent(this, "template", null, null));
  }