Package de.hpi.eworld.observer

Examples of de.hpi.eworld.observer.ObserverNotification


    final ModelManager modelManager = ModelManager.getInstance();
    modelManager.clearModel();

    for (final PersistenceProviderInterface plugin : plugins.values()) {
      setChanged();
      notifyObservers(new ObserverNotification(NotificationType.clearModel, plugin));
      clearChanged();
    }

    System.gc();
View Full Code Here


    // the first container in each file should belong to the ModelManager
    if (ppcModel.getPluginName().equals("de.hpi.eworld.core")) {
      final Collection<Object> items = ppcModel.getItems();

      modelManager.setChanged();
      modelManager.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
      modelManager.clearChanged();

      for (final Object obj : items) {
        final ModelElement me = (ModelElement) obj;
        modelManager.addModelElement(me);
      }

      modelManager.setSimulationStartTime(ppcModel.getSimulationStartTime());
      modelManager.setSimulationEndTime(ppcModel.getSimulationEndTime());

      // first values prevents the network view from filter duplicate
      // edges
      modelManager.setChanged();
      modelManager.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, false, false));
      modelManager.clearChanged();
    } else {
      // do panic
      in.close();
      throw new Exception("First Container does not belong to the ModelManager");
    }

    // clean up as much as possible
    ppcModel = null;
    System.gc();

    while (true) {
      PluginPersistenceContainer ppc = null;

      try {

        ppc = (PluginPersistenceContainer) in.readObject();

      } catch (final EOFException xcp) {

        // everything's fine
        // this exception is thrown if the end of the stream is reached
        // its escalation is stopped here
        // just close the stream and return

        in.close();
        return;
      }

      if (plugins.keySet().contains(ppc.getPluginName())) {
        final PersistenceProviderInterface accordingPlugin = plugins.get(ppc.getPluginName());
        setChanged();
        notifyObservers(new ObserverNotification(NotificationType.loadFromFile, accordingPlugin, ppc.getItems()));
        clearChanged();
      }
    }

  }
View Full Code Here

   */
  @Override
  public void run() {
    ModelManager manager = ModelManager.getInstance();
    manager.setChanged();
    manager.notifyObservers(new ObserverNotification(NotificationType.startBatchProcess));
    manager.clearChanged();
   
    Collection<ModelElement> allElements = ModelManager.getInstance().getAllModelElements();
    int totalNumber = allElements.size();
    if(totalNumber == 0) totalNumber = 1;
    int i = 0;
   
    for(ModelElement m : allElements)
    { 
      if(progressDialog.wasCanceled()) break;

      m.setChanged();
      m.notifyObservers(new ObserverNotification(NotificationType.elementChanged, m));
      m.clearChanged();
      i++;

      int progress = (int)i * 100 / totalNumber;
      this.setChanged();
      this.notifyObservers(new ObserverNotification(NotificationType.progress,
                              progress));
      this.clearChanged();
    }
   
    manager.setChanged();
    manager.notifyObservers(new ObserverNotification(NotificationType.endBatchProcess, true, false));
    manager.clearChanged();
   
    this.setChanged();
    if(progressDialog.wasCanceled()) {
      this.notifyObservers(new ObserverNotification(NotificationType.failed));
    }
    else {
      this.notifyObservers(new ObserverNotification(NotificationType.done));
    }
    this.clearChanged();
  }
View Full Code Here

  public void update(Observable o, Object arg) {
    if (!(arg instanceof ObserverNotification)) {
      return;
    }
    // cast notification and type.
    final ObserverNotification notification = (ObserverNotification) arg;
    final NotificationType type = notification.getType();
    if (!(type == NotificationType.itemButtonClicked
      ||type == NotificationType.itemDoubleClicked)) {
      return;
    }
    if (!(notification.getObj1() instanceof TrafficLightView)) {
      return;
    }
     
    final TrafficLightView item = (TrafficLightView) notification.getObj1();
    newTLSDialogEditing(item);
  }
View Full Code Here

    return canceled;
  }

  @Override
  public void update(Observable o, Object arg) {
    final ObserverNotification notification = (ObserverNotification) arg;
    final NotificationType type = notification.getType();
   
    if (type.equals(NotificationType.updateSignal)) {
      if(arg instanceof Integer) {
        setProgressValue((Integer) arg);
      }
View Full Code Here

  @Override
  public void update(final Observable o, final Object arg) {
    if (arg instanceof ObserverNotification) {
      // cast notification and type.
      final ObserverNotification notification = (ObserverNotification) arg;
      final NotificationType type = notification.getType();

      // we're going to make some assumptions about the class of some
      // objects returned from the notification. those might be wrong,
      // hence the try/catch with ClassCastException.
      try {
View Full Code Here

    if (dataset.belongsToCurrentMap()) {
      retrieveAdditionalInfos(dataset);
    }
    datasets.put(dataset.getId(), dataset);
    lastDataset.push(dataset.getId());
      this.notifyObservers(new ObserverNotification(NotificationType.datasetsChanged));
  }
View Full Code Here

   * Deletes all datasets and resets the manager
   */
  public void clear() {
    datasets.clear();
    lastDataset.clear();
      this.notifyObservers(new ObserverNotification(NotificationType.datasetsCleared));
  }
View Full Code Here

    if (datasets.remove(id) == null) {
      // dataset didn't exist
      // do nothing
    } else {
      lastDataset.remove(id);
        this.notifyObservers(new ObserverNotification(NotificationType.datasetsChanged));
    }
  }
View Full Code Here

   */
  public void setDatasets(Map<String, StatDataset> datasets) {
    this.datasets = datasets;
    logger.debug("Loaded " + datasets.size() + " datasets");
    // logger.debug("Num datasets: " + numDatasets());
      this.notifyObservers(new ObserverNotification(NotificationType.datasetsChanged));
  }
View Full Code Here

TOP

Related Classes of de.hpi.eworld.observer.ObserverNotification

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.