if (csmart != null) { experiment = csmart.getRunningExperiment(); setHostToMonitor(experiment); listener = new MyExperimentListener(this); experiment.addExperimentListener(listener); }
refreshAgents();
  public CSMARTUL(CSMART csmart) {    this.csmart = csmart;    if (csmart != null) {      experiment = csmart.getRunningExperiment();      setHostToMonitor(experiment);      listener = new MyExperimentListener(this);      experiment.addExperimentListener(listener);    }    // create one version of properties for all objects    // and set them in CSMARTGraph because it can't address CSMARTUL    // TODO: better handling of properties    CSMARTGraph.setProperties(properties);    JMenuBar menuBar = new JMenuBar();    getRootPane().setJMenuBar(menuBar);     JMenu fileMenu = new JMenu(FILE_MENU);    fileMenu.setToolTipText("Create new views, open saved views, or exit.");    JMenu newMenu = new JMenu(NEW_MENU_ITEM);    newMenu.setToolTipText("Create new views.");    fileMenu.add(newMenu);    JMenu openMenu = new JMenu(OPEN_MENU_ITEM);    openMenu.setToolTipText("Open a saved view.");    JMenuItem openGraphMenuItem = new JMenuItem(OPEN_GRAPH_MENU_ITEM);    openGraphMenuItem.setToolTipText("Open a saved graph view.");    openGraphMenuItem.addActionListener(this);    openMenu.add(openGraphMenuItem);    JMenuItem openMetricMenuItem = new JMenuItem(OPEN_METRIC_MENU_ITEM);    openMetricMenuItem.setToolTipText("Open a saved metrics view.");    openMetricMenuItem.addActionListener(this);    //openMetricMenuItem.setEnabled(false);    openMenu.add(openMetricMenuItem);    fileMenu.add(openMenu);    JMenuItem exitMenuItem = new JMenuItem(EXIT_MENU_ITEM);    exitMenuItem.setToolTipText("Exit this tool.");    exitMenuItem.addActionListener(this);    fileMenu.add(exitMenuItem);    windowMenu = new JMenu(WINDOW_MENU);    windowMenu.setToolTipText("Display selected window.");    menuBar.add(fileMenu);        // if running stand alone, then add a windows menu    // to keep track of windows created by this tool    // TODO: replicated NamedWindow capability at this level, but under csmart    if (csmart == null) {      menuBar.add(windowMenu);      setTitle("Society Monitor");    }    // Add a Help menu item    JMenu helpmenu = new JMenu(HELP_MENU);    for (int i = 0; i < helpMenuItems.length; i++) {      JMenuItem mItem = new JMenuItem(helpMenuItems[i]);      mItem.addActionListener(this);      helpmenu.add(mItem);    }    menuBar.add(helpmenu);    JToolBar toolBar = new JToolBar();    toolBar.setLayout(new GridLayout(1, 5, 2, 2));    getContentPane().add("North", toolBar);    for (int i = 0; i < views.length; i++) {      JButton button = makeButton(views[i], iconFilenames[i]);      button.setToolTipText(tooltips[i]);      button.setHorizontalTextPosition(JButton.CENTER);      button.setVerticalTextPosition(JButton.BOTTOM);      button.addActionListener(this);      toolBar.add(button);      JMenuItem menuItem = new JMenuItem(views[i]);      menuItem.addActionListener(this);      newMenu.add(menuItem);    }    if (csmart == null) {      addWindowListener(new WindowAdapter() {	public void windowClosing(WindowEvent e) {	  System.exit(0);	}      });      // if running standalone, then manage the windows created by this tool      NamedFrame.getNamedFrame().addObserver(this);    } else {      // if running under csmart, close windows we created when we're closed      addWindowListener(new WindowAdapter() {	public void windowClosing(WindowEvent e) {	  closeSubWindows();	  experiment.removeExperimentListener(listener);	}      });    }    pack();    setVisible(true);  }