Package java.util

Examples of java.util.Observer


        throws ContextException
    {
        m_context = context;
        try
        {
            final Observer observer = (Observer)context.get( Observer.class.getName() );
            m_observable.addObserver( observer );
        }
        catch( final ContextException ce )
        {
            final String message = REZ.getString( "embeddor.notice.no-restart" );
View Full Code Here


   
    mainPanel = new JPanel();
   
    this.logger = Logger.getLogger(this.getClass());
    StatisticsDataManager smm = StatisticsDataManager.getInstance();
    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.displayInfoBox)) {
            showInfoBox((String) notification.getObj1(), (String) notification.getObj2());
          }
        }
      }
    });
   
    //setAllowedAreas(Qt.DockWidgetArea.RightDockWidgetArea, Qt.DockWidgetArea.LeftDockWidgetArea);
//    setTitle(title);
    tabWidget = new JPanel();
    tabWidget.setMinimumSize(new Dimension(150, 200));
    tabWidget.setMaximumSize(new Dimension(235,9999));

    // statDataWidget
    // ------------------------------------------------------------
    statDataWidget = new JPanel();
    GridBagLayout dataLayout = new GridBagLayout();

    listModel = new DefaultListModel<ListValue>();
    datasetsList = new JList<Object>();
   
    datasetsListPopup = new JPopupMenu();
    datasetsListPopup.addPopupMenuListener(new PopupMenuListener() {
      @Override
      public void popupMenuWillBecomeVisible(PopupMenuEvent e) {
        displayDatasetItem((ListValue) e.getSource());
      }
     
      @Override
      public void popupMenuWillBecomeInvisible(PopupMenuEvent e) {}
     
      @Override
      public void popupMenuCanceled(PopupMenuEvent e) {}
    });
   
    // context actions
    JMenuItem showPropertiesAction = new JMenuItem("Properties");
    showPropertiesAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showProperties();
      }
    });
    datasetsListPopup.add(showPropertiesAction);
   
    JMenuItem showChartsAction = new JMenuItem("Show charts");
    showChartsAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showCharts();
      }
    });
    datasetsListPopup.add(showChartsAction);
   
    showOnMapAction = new JMenuItem("Show on map");
    showOnMapAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        initShowOnMap();
      }
    });
    datasetsListPopup.add(showOnMapAction);
   
    JMenuItem showRawAction = new JMenuItem("Open data file");
    showRawAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        showRawData();
      }
    });
    datasetsListPopup.add(showRawAction);
   
    JMenuItem renameSetAction = new JMenuItem("Rename");
    renameSetAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onRenameDataset();
      }
    });
    datasetsListPopup.add(renameSetAction);
   
    JMenuItem deleteSetAction = new JMenuItem("Remove");
    deleteSetAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onDeleteDataset();
      }
    });
    datasetsListPopup.add(deleteSetAction);
   
    JMenuItem deleteAllAction = new JMenuItem("Remove all");
    deleteAllAction.addMouseListener(new MouseAdapter() {
      @Override
      public void mouseClicked(MouseEvent e) {
        super.mouseClicked(e);
        onDeleteAllDatasets();
      }
    });
    datasetsListPopup.add(deleteAllAction);

    //datasetsList.setContextMenuPolicy(Qt.ContextMenuPolicy.NoContextMenu);
    datasetsList.addListSelectionListener(new ListSelectionListener() {
      @Override
      public void valueChanged(ListSelectionEvent e) {
        checkBelongingToMap();
      }
    });
   
    statAutoImport = new JCheckBox("Automatically import data");
    statAutoImport.setToolTipText("Import of the SUMO dump data will be triggered automatically when the simulation finishes");
    statAutoImport.setSelected(true);

    final GridBagConstraints datasetsListConstraints = new GridBagConstraints();
    datasetsListConstraints.gridx = 0;
    datasetsListConstraints.gridy = 0;
    datasetsListConstraints.fill = GridBagConstraints.HORIZONTAL;
    dataLayout.setConstraints(datasetsList, datasetsListConstraints);
    mainPanel.add(datasetsList);
   
    final GridBagConstraints statAutoImportConstraints = new GridBagConstraints();
    statAutoImportConstraints.gridx = 1;
    statAutoImportConstraints.gridy = 0;
    statAutoImportConstraints.gridwidth = 1;
    statAutoImportConstraints.fill = GridBagConstraints.HORIZONTAL;
    dataLayout.setConstraints(statAutoImport, statAutoImportConstraints);
    mainPanel.add(statAutoImport);

    statDataWidget.setLayout(dataLayout);


    //simulationDock.set(tabWidget.indexOf(statDataWidget));

    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.datasetsChanged)) {
            onDatasetsChanged();
          }
        }
      }
    });
   
    smm.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

   * @param networkView
   */
  public void setNetworkView(GraphController networkView) {
    visualizeWidget.setNetworkView(networkView);
   
    networkView.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.endBatchProcess)) {
            onBatchEnded();
          }
        }
      }
    });
   
    networkView.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

        getClass().getClassLoader(), "export.png", 16));
    menu.add(exportToSumoAction);
    exportToSumoAction.addActionListener(new ExportItemListener(this));
    exportToSumoAction.setEnabled(false);

    ModelManager.getInstance().addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        ObserverNotification notification = (ObserverNotification) arg;
       
        if( notification.getType() == NotificationType.elementAdded ) {
          onModelElementAdded((ModelElement) notification.getObj1());
        }
      }
    });

    ModelManager.getInstance().addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        ObserverNotification notification = (ObserverNotification) arg;
       
        if( notification.getType() == NotificationType.modelCleared ) {
View Full Code Here

   * is called when the model is cleared. disables export menu actions
   */
  public void onModelCleared() {
      exportToSumoAction.setEnabled(false);
     
      elementAddedObserver = new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        ObserverNotification notification = (ObserverNotification) arg;
       
        if( notification.getType() == NotificationType.elementAdded ) {
View Full Code Here

   * @param file
   */
  public void importDumpFile(String file) {
    SumoDumpThread importThread = new SumoDumpThread(file, true, true);
    // TODO signals don't trigger the slots, don't know why
    importThread.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.sumoDumpThreadDone)) {
            threadDone();
          }
        }
      }
    });
    importThread.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

   *
   * @param mainWindow
   */
  public void showImportDialog(MainWindow mainWindow) {
    dialog = new SumoDumpImportDialog(mainWindow);
    dialog.observable.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

    simulationStatistic = new SimulationStatistic(viewAction);
    simulationStatistic.startUp(this.parentWindow);
    simulationStatistic.setNetworkView(networkView);

    // connect signals and slots
    simulationStatistic.observable.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.simulationStatisticClosed)) {
            onSimulationStatisticClosed();
          }
        }
      }
    });
   
    dump = new SumoDump();
    dump.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
         
          if (type.equals(NotificationType.importSuccessful)) {
            onNewImport();
          }
        }
      }
    });
   
    /*
    StatisticsDataManager.getInstance().sumoSimDone.connect(
        this, "onSimulationFinished(String)");
    */
    TriggerSumo.getInstance().observable.addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

   * @param visualizerPlugin
   */
  public void initializeVisualizerPlugin(VisualizerPlugin visualizerPlugin) {
    this.visualizerPlugin = visualizerPlugin;
   
    this.visualizerPlugin.getSimControlToolbar().addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

   * standard constructor, sets the database parameters using the saved settings
   */
  private DatabaseAccess()
  {
   
    ModelManager.getInstance().addObserver(new Observer() {
      @Override
      public void update(Observable o, Object arg) {
        if (arg instanceof ObserverNotification) {
          final ObserverNotification notification = (ObserverNotification) arg;
          final NotificationType type = notification.getType();
View Full Code Here

TOP

Related Classes of java.util.Observer

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.