示例#1
0
 private void createTreeStatsMenu() {
   treeStatsMenu = new JMenu("Tree Stats");
   menuBar.add(treeStatsMenu);
   utilItem = new JMenuItem("Utilization");
   treeStatsMenu.add(utilItem);
   utilItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.NODEUTIL, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, utilItem.getText());
         }
       });
   slotCntItem = new JMenuItem("Slot Count");
   treeStatsMenu.add(slotCntItem);
   slotCntItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.SLOTCNT, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, slotCntItem.getText());
         }
       });
   predSzItem = new JMenuItem("Predicate Size");
   treeStatsMenu.add(predSzItem);
   predSzItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent e) {
           Libgist.getWkldNodeStats(Libgist.PREDSIZE, 0, false);
           treeView.showStats(Libgist.nodeCnt, Libgist.displayStats, predSzItem.getText());
         }
       });
 }
示例#2
0
 private void createDebugMenu() {
   debugMenu = new JMenu("Debug");
   menuBar.add(debugMenu);
   debugMenu.add(stepAction);
   debugMenu.add(nextAction);
   debugMenu.add(contAction);
   debugMenu.add(stopAction);
   traceAllItem = new JCheckBoxMenuItem("Trace All");
   debugMenu.add(traceAllItem);
   debugMenu.addSeparator();
   breakpointsItem = new JMenuItem("Breakpoints...");
   debugMenu.add(breakpointsItem);
   breakpointsItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           Breakpoints.edit();
         }
       });
   Breakpoints.setParent(this);
 }
示例#3
0
 private void createWindowsMenu() {
   windowsMenu = new JMenu("Windows");
   menuBar.add(windowsMenu);
   showCmdsItem = new JCheckBoxMenuItem("Show Commands");
   showCmdsItem.setState(true);
   windowsMenu.add(showCmdsItem);
   showResultsItem = new JCheckBoxMenuItem("Show Results");
   showResultsItem.setState(true);
   windowsMenu.add(showResultsItem);
   showTraceItem = new JCheckBoxMenuItem("Show Trace Output");
   showTraceItem.setState(true);
   windowsMenu.add(showTraceItem);
   tileItem = new JMenuItem("Tile");
   tileItem.addActionListener(
       new ActionListener() {
         public void actionPerformed(ActionEvent event) {
           MainWindow.this.tile();
         }
       });
   windowsMenu.add(tileItem);
 }
示例#4
0
  // Method builds menu components.
  private JMenuBar buildMenu() {
    // Add menus to the menu bar.
    menuBar.add(file);
    menuBar.add(comm);
    menuBar.add(data);
    menuBar.add(help);

    // Set mnemonics for menu selections.
    file.setMnemonic('F');
    comm.setMnemonic('C');
    data.setMnemonic('D');
    help.setMnemonic('H');

    // Menu items for file menu.
    file.add(menuItemNew);
    file.addSeparator();
    file.add(menuItemOpen);
    file.add(menuItemClose);
    file.addSeparator();
    file.add(menuItemSave);
    file.add(menuItemSaveAs);
    file.addSeparator();
    file.add(menuItemExit);

    // Menu items for comm menu.
    comm.add(menuItemSend);
    comm.add(menuItemReceive);

    // Menu items for comm menu.
    data.add(menuItemConnect);
    data.add(menuItemSubmit);

    // Set mnemonics for menu item selections for file menu.
    menuItemNew.setMnemonic('N');
    menuItemOpen.setMnemonic('O');
    menuItemClose.setMnemonic('C');
    menuItemSave.setMnemonic('S');
    menuItemSaveAs.setMnemonic('A');
    menuItemExit.setMnemonic('X');

    // Set mnemonics for comm item selections for file menu.
    menuItemSend.setMnemonic('S');
    menuItemReceive.setMnemonic('R');

    // Set mnemonics for data item selections for file menu.
    menuItemConnect.setMnemonic('C');
    menuItemSubmit.setMnemonic('R');

    // Menu items to help menu.
    help.add(menuCheckBoxItemDebug);
    help.addSeparator();
    help.add(menuItemHelp);

    // Set mnemonics for menu item selections for edit menu.
    menuCheckBoxItemDebug.setMnemonic('D');
    menuItemHelp.setMnemonic('A');

    // Build menu action listeners.
    buildMenuActionListeners();

    // Set the menu bar in the frame and return menu bar.
    setJMenuBar(menuBar);

    // Return JMenuBar
    return menuBar;
  } // End of buildMenu() method.
示例#5
0
  private void createOpsMenu() {
    opsMenu = new JMenu("Ops");
    menuBar.add(opsMenu);

    insertItem = new JMenuItem("Insert...");
    opsMenu.add(insertItem);
    final Object[] insertMsg = new Object[4];
    insertMsg[0] = "Key:";
    final JTextField insertKey = new JTextField("");
    insertMsg[1] = insertKey;
    insertMsg[2] = "Data:";
    final JTextField insertData = new JTextField("");
    insertMsg[3] = insertData;
    insertItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            int response =
                JOptionPane.showOptionDialog(
                    MainWindow.this,
                    insertMsg,
                    "Insert",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    null);
            if (response != JOptionPane.OK_OPTION) {
              return;
            }

            // insert new item
            cmd.reset();
            cmd.cmdType = LibgistCommand.INSERT;
            cmd.key.append(insertKey.getText());
            cmd.data.append(insertData.getText());
            opThread.dispatchCmd(cmd);
          }
        });

    deleteItem = new JMenuItem("Delete...");
    opsMenu.add(deleteItem);
    final Object[] deleteMsg = new Object[2];
    deleteMsg[0] = "Query:";
    final JTextField deleteQuery = new JTextField("");
    deleteMsg[1] = deleteQuery;
    deleteItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            int response =
                JOptionPane.showOptionDialog(
                    MainWindow.this,
                    deleteMsg,
                    "Delete",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    null);
            if (response != JOptionPane.OK_OPTION) {
              return;
            }

            // delete item(s)
            cmd.reset();
            cmd.cmdType = LibgistCommand.REMOVE;
            cmd.qual.append(deleteQuery.getText());
            opThread.dispatchCmd(cmd);
          }
        });

    searchItem = new JMenuItem("Search...");
    opsMenu.add(searchItem);
    final Object[] searchMsg = new Object[4];
    searchMsg[0] = "Query:";
    final JTextField searchQuery = new JTextField("");
    searchMsg[1] = searchQuery;
    searchMsg[2] = "Retrieval Limit:";
    final JTextField retrLimit = new JTextField("");
    searchMsg[3] = retrLimit;
    searchItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            int response =
                JOptionPane.showOptionDialog(
                    MainWindow.this,
                    searchMsg,
                    "Search",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    null);
            if (response != JOptionPane.OK_OPTION) {
              return;
            }
            int limit = 0; // 0 means "get them all"
            // if no limit is specified: we leave it at 0
            if (retrLimit.getText() != null) {
              try {
                limit = Integer.parseInt(retrLimit.getText());
              } catch (NumberFormatException e) {
                // user typed junk
                limit = 0;
                retrLimit.setText("");
              }
            }

            // execute query
            cmd.reset();
            cmd.cmdType = LibgistCommand.FETCH;
            cmd.qual.append(searchQuery.getText());
            cmd.fetchLimit = limit;
            opThread.dispatchCmd(cmd);
          }
        });

    executeItem = new JMenuItem("Execute...");
    final JFileChooser executeChooser = new JFileChooser(".");
    executeChooser.setDialogTitle("Execute Script");
    executeChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    opsMenu.add(executeItem);
    executeItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // let user choose script file
            int retval = executeChooser.showDialog(MainWindow.this, "Execute");
            if (retval != 0) {
              return;
            }

            // execute script
            cmd.reset();
            cmd.cmdType = LibgistCommand.SCRIPT;
            cmd.scriptFile.append(executeChooser.getSelectedFile().getPath());
            opThread.dispatchCmd(cmd);
          }
        });
  }
示例#6
0
  private void createFileMenu() {
    fileMenu = new JMenu("File");
    menuBar.add(fileMenu);

    newItem = new JMenuItem("New...");
    fileMenu.add(newItem);
    // construct components of option pane to input name and type of new AM
    final Object[] newMsg = new Object[3];
    newMsg[0] = "Name for new AM:";
    final JTextField newName = new JTextField("new-am");
    newMsg[1] = newName;
    final JComboBox cb = new JComboBox();
    for (int i = 0; i < Libgist.extInfo.length; i++) {
      cb.addItem(Libgist.extInfo[i].name);
    }
    newMsg[2] = cb;
    newItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // first close the currently opened index
            int response =
                JOptionPane.showOptionDialog(
                    MainWindow.this,
                    newMsg,
                    "New",
                    JOptionPane.OK_CANCEL_OPTION,
                    JOptionPane.PLAIN_MESSAGE,
                    null,
                    null,
                    null);
            if (response != JOptionPane.OK_OPTION) {
              return;
            }

            // create new AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.CREATE;
            cmd.indexName.append(newName.getText());
            cmd.extension.append(Libgist.extInfo[cb.getSelectedIndex()]);
            opThread.dispatchCmd(cmd);
          }
        });

    openItem = new JMenuItem("Open...");
    final JFileChooser openChooser = new JFileChooser(".");
    openChooser.setDialogTitle("Open Index");
    openChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    fileMenu.add(openItem);
    openItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // first close currently opened index
            // let user choose index file
            int retval = openChooser.showOpenDialog(MainWindow.this);
            if (retval != 0) {
              return;
            }
            String fileName = openChooser.getSelectedFile().getPath();

            // open AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.OPEN;
            cmd.indexName.append(fileName);
            opThread.dispatchCmd(cmd);

            enableIndexOpened();
          }
        });

    closeItem = new JMenuItem("Close");
    fileMenu.add(closeItem);
    closeItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // close AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.CLOSE;
            opThread.dispatchCmd(cmd);
            // MainWindow.this.setTitle("amdb");
          }
        });

    flushItem = new JMenuItem("Flush");
    fileMenu.add(flushItem);
    flushItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            // open AM
            cmd.reset();
            cmd.cmdType = LibgistCommand.FLUSH;
            opThread.dispatchCmd(cmd);
          }
        });

    fileMenu.addSeparator();

    optionsItem = new JMenuItem("Properties...");
    fileMenu.add(optionsItem);
    optionsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Properties.edit();
          }
        });

    settingsItem = new JMenuItem("Save Settings");
    fileMenu.add(settingsItem);
    settingsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            saveConfig();
          }
        });
    fileMenu.addSeparator();
    exitItem = new JMenuItem("Exit");
    fileMenu.add(exitItem);
    exitItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // close AM
            opThread.stopNow();
            Libgist.cleanup();
            System.exit(0);
          }
        });
  }
示例#7
0
  private void createAnalysisMenu() {
    analysisMenu = new JMenu("Analysis");
    menuBar.add(analysisMenu);

    // analysis-related variables
    analysisInfo = new AnalysisInfo();
    wkldStatsDlg = new WkldStatsDlg(this);
    splitStatsDlg = new SplitStatsDlg(this);
    penaltyStatsDlg = new PenaltyStatsDlg(this);

    newAnalysisItem = new JMenuItem("Create Analysis ...");
    analysisMenu.add(newAnalysisItem);
    newAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                MainWindow.this,
                "Not implemented yet.\nUse command createanl in gistcmdline instead.");
          }
        });

    openAnalysisItem = new JMenuItem("Open Analysis ...");
    final JFileChooser openAnalysisChooser = new JFileChooser(".");
    openAnalysisChooser.setDialogTitle("Open Analysis");
    openAnalysisChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
    analysisMenu.add(openAnalysisItem);
    openAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            int retval = openAnalysisChooser.showOpenDialog(MainWindow.this);
            if (retval != 0) {
              return;
            }
            File f = openAnalysisChooser.getSelectedFile();

            cmd.reset();
            cmd.cmdType = LibgistCommand.OPENANL;
            cmd.analysisFile = f;
            opThread.dispatchCmd(cmd);
          }
        });

    completeAnalysisItem = new JMenuItem("Complete Analysis ...");
    analysisMenu.add(completeAnalysisItem);
    completeAnalysisItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            JOptionPane.showMessageDialog(
                MainWindow.this,
                "Not implemented yet.\nUse commands wkldstats, splitstats and penaltystats\nin gistcmdline instead.");
          }
        });

    analysisMenu.addSeparator();

    wkldStatsItem = new JMenuItem("Workload Stats ...");
    analysisMenu.add(wkldStatsItem);
    wkldStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            wkldStatsDlg.setVisible(true);
          }
        });

    splitStatsItem = new JMenuItem("Split Stats ...");
    analysisMenu.add(splitStatsItem);
    wkldStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            splitStatsDlg.setVisible(true);
          }
        });

    penaltyStatsItem = new JMenuItem("Penalty Stats ...");
    analysisMenu.add(penaltyStatsItem);
    penaltyStatsItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent event) {
            penaltyStatsDlg.setVisible(true);
          }
        });
  }