public void selectEntityFrame(DustEntity entity, boolean createIfMissing) {
    EntityFrame iFrm = mapEntityFrames.get(entity);

    if (null == iFrm) {
      if (createIfMissing) {
        iFrm = new EntityFrame(entity);

        mapEntityFrames.put(entity, iFrm);
        desktop.add(iFrm);
      }
    }

    if (null != iFrm) {
      iFrm.show();
      iFrm.toFront();
      try {
        iFrm.setSelected(true);
      } catch (PropertyVetoException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
      }
    }
  }
Exemple #2
0
  public MainWindow() {
    JMenuItem showTextItem, showContentItem, showStatsItem;
    JMenuItem consoleWinItem, treeWinItem, traceWinItem;

    // our libgist execution thread
    opThread = new OpThread(this);
    Libgist.setBreakHandler(opThread);
    opThread.start();
    cmd = new LibgistCommand();

    menuBar = new JMenuBar();
    setJMenuBar(menuBar);

    // create toolbar and console window with text area

    getContentPane().removeAll();
    getContentPane().setLayout(new BorderLayout());
    JPanel panel = new JPanel();
    panel.setLayout(new BorderLayout());

    // desktop pane + console frame
    desktop = new JDesktopPane();
    desktop.setOpaque(true);
    desktop.setBackground(Color.lightGray);
    consoleFrame = new ConsoleWindow(200, desktop);
    desktop.add(consoleFrame, JLayeredPane.PALETTE_LAYER);

    // debugging actions for toolbar:
    // notify opThread of what to do when it hits a breakpoint
    stepAction =
        new AbstractAction("Step") {
          public void actionPerformed(ActionEvent e) {
            opThread.step();
          }
        };
    cancelAction =
        new AbstractAction("Cancel") {
          public void actionPerformed(ActionEvent e) {
            scriptWasCancelled = true; // don't call it after next line!
            opThread.cancel();
          }
        };
    nextAction =
        new AbstractAction("Next") {
          public void actionPerformed(ActionEvent e) {
            opThread.next();
          }
        };
    contAction =
        new AbstractAction("Continue") {
          public void actionPerformed(ActionEvent e) {
            opThread.cont();
          }
        };

    // opThread is currently executing a script and we want it to stop:
    // tell libgist directly to suspend execution once opThread is done
    // with the current operation
    stopAction =
        new AbstractAction("Stop") {
          public void actionPerformed(ActionEvent e) {
            Libgist.singleStep();
          }
        };

    // toolbar
    JToolBar toolbar = new JToolBar();
    toolbar.add(stepAction).setText("Step");
    toolbar.add(nextAction).setText("Next");
    toolbar.add(contAction).setText("Continue");
    toolbar.add(stopAction).setText("Stop");
    toolbar.add(cancelAction).setText("Cancel");

    panel.add(toolbar, BorderLayout.NORTH);
    panel.add(desktop, BorderLayout.CENTER);
    getContentPane().add(panel);

    createFileMenu();
    createOpsMenu();
    createDebugMenu();
    createTreeStatsMenu();
    createAnalysisMenu();
    createWindowsMenu();

    setGuiState(INITSTATE); // nothing opened yet

    // addWindowListener(this); // So we do the right thing on window closing.
  }
Exemple #3
0
  public void updateGuiState(int priorState, LibgistCommand cmd, boolean success) {
    switch (cmd.cmdType) {
      case LibgistCommand.CREATE:
      case LibgistCommand.OPEN:
        resetState();
        if (!success) return; // done
        setGuiState(IDXOPENSTATE);
        isOpen = true;
        idxName = cmd.indexName.toString();
        if (cmd.cmdType == LibgistCommand.CREATE) {
          resetConfig();
        } else {
          restoreConfig();
        }
        // setTitle("amdb: " + filename);
        setTree(idxName);
        try {
          treeView = new TreeView(desktop); // creates a display of the opened index
          desktop.add(treeView, JLayeredPane.PALETTE_LAYER);
        } catch (LibgistException e) {
          // what to do now?
          consoleFrame.echoInfo("new TreeView() failed");
        }
        break;

      case LibgistCommand.CLOSE:
        saveConfig();
        resetState();
        break;

      case LibgistCommand.OPENANL:
        resetState();
        if (!success) return; // done
        // enable menu items and open tree view
        setGuiState(ANLOPENSTATE);
        // setTitle("amdb: " + filename);
        setTree(idxName);
        try {
          treeView = new TreeView(desktop); // creates a display of the opened index
          desktop.add(treeView, JLayeredPane.PALETTE_LAYER);
        } catch (LibgistException e) {
          // what to do now?
          consoleFrame.echoInfo("new TreeView() failed");
        }

        // get ready to display dialogs
        if (analysisInfo.actualHasWkldStats) {
          wkldStatsDlg.init(treeView);
        }
        if (analysisInfo.actualHasSplitStats) {
          splitStatsDlg.init(treeView);
        }
        if (analysisInfo.actualHasPenaltyStats) {
          penaltyStatsDlg.init(treeView);
        }
        break;

      case LibgistCommand.CLOSEANL:
        treeView.dispose();
        treeView = null;
        setGuiState(INITSTATE);
        setTree("");
        break;

        // if these didn't work, we don't care
      case LibgistCommand.INSERT:
      case LibgistCommand.REMOVE:
      case LibgistCommand.FETCH:
      case LibgistCommand.FLUSH:
      case LibgistCommand.CREATEANL:
      case LibgistCommand.SCRIPT:
        setGuiState(priorState);
        break;
    }
  }
Exemple #4
0
  /**
   * Method to handle hyper link events.
   *
   * @param event hyper link event
   */
  public void hyperlinkUpdate(HyperlinkEvent event) {
    if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) {
      setCursor(cbusy);
      try {
        URL url = event.getURL();

        int ind1 = event.getDescription().indexOf("[");
        int ind2 = event.getDescription().lastIndexOf("]");

        String search = "";
        if (ind1 > -1 && ind2 > -1) search = event.getDescription().substring(ind1 + 1, ind2);
        else {
          ind1 = event.getDescription().indexOf("=") + 1; // genedb
          if (ind1 > -1) search = event.getDescription().substring(ind1);
        }

        if (desktop != null) {
          if (BigPane.srsTabPane.isSelected()) setUpSRSFrame(url, search);

          if (BigPane.srsWin.isSelected()) {
            int hgt = (2 * desktop.getHeight()) / 3;
            Annotation edPane = new Annotation(url);
            JScrollPane jsp = new JScrollPane(edPane);
            JInternalFrame jif =
                new JInternalFrame(
                    "SRS " + search,
                    true, // resizable
                    true, // closable
                    true, // maximizable
                    true); // iconifiable);
            JMenuBar menuBar = new JMenuBar();
            menuBar.add(new CommonMenu(jif));
            jif.setJMenuBar(menuBar);
            jif.getContentPane().add(jsp);
            jif.setLocation(0, 0);
            jif.setSize(800, hgt);
            jif.setVisible(true);
            desktop.add(jif);
          }

          if (BigPane.srsBrowser.isSelected()) BrowserControl.displayURL(event.getDescription());
        } else {
          setPage(url);
          back.add(url);
        }
      } catch (IOException ioe) {
        String msg = event.getDescription();
        if (msg.length() > 50) msg = msg.substring(0, 50) + "....";

        JOptionPane.showMessageDialog(
            this, "Cannot reach URL:\n" + msg, "Cannot Connect", JOptionPane.INFORMATION_MESSAGE);
        //      ioe.printStackTrace();
        //      ("Can't follow link to " +
        //                event.getURL().toExternalForm() );
      }

      setCursor(cdone);
    } else if (event.getEventType() == HyperlinkEvent.EventType.ENTERED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText(event.getDescription());
      } catch (Exception exp) {
      }

    } else if (event.getEventType() == HyperlinkEvent.EventType.EXITED) {
      try {
        JTextField statusField = (JTextField) BigPane.srsFrame.getContentPane().getComponent(1);
        statusField.setText("");
      } catch (Exception exp) {
      }
    }
  }