コード例 #1
0
ファイル: MainWindow.java プロジェクト: hkaiser/TRiAS
  // enable/disable all menu items/actions
  private void setAllEnabled(boolean enabled) {
    DbgOutput.println(2, "enabled: " + enabled);
    fileMenu.setEnabled(enabled);
    newItem.setEnabled(enabled);
    openItem.setEnabled(enabled);
    closeItem.setEnabled(enabled);
    // dumpItem.setEnabled(enabled);
    flushItem.setEnabled(enabled);
    optionsItem.setEnabled(enabled);
    settingsItem.setEnabled(enabled);

    debugMenu.setEnabled(enabled);
    stepAction.setEnabled(enabled);
    stopAction.setEnabled(enabled);
    cancelAction.setEnabled(enabled);
    nextAction.setEnabled(enabled);
    contAction.setEnabled(enabled);
    breakpointsItem.setEnabled(enabled);

    opsMenu.setEnabled(enabled);
    insertItem.setEnabled(enabled);
    deleteItem.setEnabled(enabled);
    searchItem.setEnabled(enabled);
    executeItem.setEnabled(enabled);

    treeStatsMenu.setEnabled(enabled);
    utilItem.setEnabled(enabled);
    predSzItem.setEnabled(enabled);
    slotCntItem.setEnabled(enabled);

    analysisMenu.setEnabled(enabled);
    newAnalysisItem.setEnabled(enabled);
    openAnalysisItem.setEnabled(enabled);
    completeAnalysisItem.setEnabled(enabled);
    wkldStatsItem.setEnabled(enabled);
    splitStatsItem.setEnabled(enabled);
    penaltyStatsItem.setEnabled(enabled);

    // these are never disabled
    windowsMenu.setEnabled(true);
    showCmdsItem.setEnabled(true);
    showResultsItem.setEnabled(true);
    showTraceItem.setEnabled(true);
    tileItem.setEnabled(true);
  }
コード例 #2
0
ファイル: MainWindow.java プロジェクト: hkaiser/TRiAS
 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);
 }
コード例 #3
0
  // Method builds menu action listeners.
  private void buildMenuActionListeners() {
    /*
    || Section adds action listeners to window frame menus:
    || ===================================================
    ||  - Menu file:
    ||    ---------
    ||    - menuItemSend
    ||    - menuItemReceive
    ||    - menuItemExit
    ||
    ||  - Menu edit:
    ||    ---------
    ||    - menuItemHelp
    */

    // ---------------------------------/
    // Menu item listeners to file menu.
    // ---------------------------------/

    menuItemNew.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // New file.
            newFile();
          } // End of actionPerformed method.
        }); // End of menuItemNew action listener.

    menuItemOpen.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Open file.
            openFile();
          } // End of actionPerformed method.
        }); // End of menuItemOpen action listener.

    menuItemClose.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Close file.
            closeFile();
          } // End of actionPerformed method.
        }); // End of menuItemClose action listener.

    menuItemSave.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Save current sender JTextAreaPanel String as current file.
            saveFile();
          } // End of actionPerformed method.
        }); // End of menuItemSave action listener.

    menuItemSaveAs.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Save current sender JTextAreaPanel String as new file.
            saveAsFile();
          } // End of actionPerformed method.
        }); // End of menuItemSaveAs action listener.

    menuItemExit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Exit the system on menu exit.
            System.exit(0);
          } // End of actionPerformed() method.
        }); // End of menuItemExit action listener.

    menuItemSend.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Send message.
            setMessage(sender, receiver);
          } // End of actionPerformed() method.
        }); // End of menuItemSend action listener.

    menuItemReceive.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Receive message.
            getMessage(receiver);
          } // End of actionPerformed() method.
        }); // End of menuItemReceive action listener.

    menuItemConnect.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Functionality to be implemented.
            System.out.println("This is future functionality to Connect to DB.");
          } // End of actionPerformed() method.
        }); // End of menuItemConnect action listener.

    menuItemSubmit.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Functionality to be implemented.
            System.out.println("This is future functionality to Submit SQL.");
          } // End of actionPerformed() method.
        }); // End of menuItemSubmit action listener.

    // ---------------------------------/
    // Menu item listeners to help menu.
    // ---------------------------------/

    // Add menu item listeners for debug check box menu item.
    menuCheckBoxItemDebug.addItemListener(
        new ItemListener() {
          public void itemStateChanged(ItemEvent e) {
            // Set stack trace enablement to opposite state.
            setDebugEnabled(!getDebugEnabled());
          } // End of actionPerformed method.
        }); // End of menuCheckBoxItemDebug item listener.

    // Add menu item action listener for help menu.
    menuItemHelp.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            // Call inner class help handler.
            new HelpHandler(JMessagingFrame.this, true);
          } // End of actionPerformed() method.
        }); // End of menuItemHelp action listener.
  } // End of buildMenuActionListeners() method.
コード例 #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
ファイル: MainWindow.java プロジェクト: hkaiser/TRiAS
  // create a new profile: read the script and possibly execute the queries,
  // save the stats (if 'import' == true, we assume the profile already exists
  // and don't run the queries)
  public void createWkld(String name, String scriptFile, boolean runQueries) {
    System.gc();
    Workload wkld = new Workload(name);

    if (showCmdsItem.getState()) {
      consoleFrame.echoCmd((!runQueries ? "importprof " : "newwkld ") + name + " " + scriptFile);
    }

    // construct the Workload object from the script;
    // first, check if the file exists
    try {
      FileReader reader = new FileReader(scriptFile);
      reader.close();
    } catch (FileNotFoundException e) {
      System.out.println("couldn't open " + scriptFile);
      return;
    } catch (IOException e) {
      System.out.println("couldn't close " + scriptFile);
    }

    // now, check if it contains only queries
    int scriptId = 0;
    try {
      scriptId = Libgist.openScript(scriptFile);
    } catch (LibgistException e) {
      System.out.println("couldn't open (C) " + scriptFile);
      return;
    }
    char[] arg1 = new char[64 * 1024];
    StringBuffer arg1Buf = new StringBuffer();
    char[] arg2 = new char[64 * 1024];
    StringBuffer arg2Buf = new StringBuffer();
    // for (;;) {
    // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
    // if (cmd == Libgist.EOF) break;
    // if (cmd != Libgist.FETCH) {
    // there should only be queries
    // System.out.println("Script file contains non-SELECT command");
    // return;
    // }
    // }

    if (runQueries) {
      // turn profiling on and execute queries
      // Libgist.setProfilingEnabled(true);
      Libgist.disableBps(true); // we don't want to stop at breakpoints

      // rescan queries
      try {
        scriptId = Libgist.openScript(scriptFile);
      } catch (LibgistException e) {
        System.out.println("couldn't open (C) " + scriptFile);
        return;
      }
      int cnt = 1;
      // for (;;) {
      // int cmd = Libgist.getCommand(scriptId, arg1, arg2);
      // if (cmd == Libgist.EOF) break;
      // arg1Buf.setLength(0);
      // arg1Buf.append(arg1, 0, strlen(arg1));
      // arg2Buf.setLength(0);
      // arg2Buf.append(arg2, 0, strlen(arg2));
      // OpThread.execCmd(LibgistCommand.FETCH, arg1Buf.toString(),
      // arg2Buf.toString(), false);
      // System.out.print(cnt + " ");
      // System.out.println(cnt + ": execute " + arg2Buf.toString() + " "
      // + arg1Buf.toString());
      // cnt++;
      // }
      System.out.println();

      Libgist.disableBps(false);
      // compute optimal clustering and some more statistics
      // Libgist.computeMetrics(wkld.filename);
    }

    // save profile
    try {
      // we're saving Java and C++ data in separate files (filename and filename.prof)
      // the profile object only contains the filename, the queries will be
      // read in from the file when the profile is opened (faster that way)
      ObjectOutputStream out = new ObjectOutputStream(new FileOutputStream(wkld.filename));
      out.writeObject(wkld);
      out.close();
      System.out.println("copy query file");
      Runtime.getRuntime().exec("cp " + scriptFile + " " + wkld.filename + ".queries");
      System.out.println("saving tree and profile");
      Libgist.saveToFile(wkld.filename + ".idx");
      if (runQueries) {
        // Libgist.saveProfile(wkld.filename + ".prof");
      }
    } catch (Exception e) {
      System.out.println("Error saving profile: " + e);
      return;
    }

    if (runQueries) {
      // turn profiling off (after the metrics were computed and
      // the profile saved)
      // Libgist.setProfilingEnabled(false);
    }
  }
コード例 #6
0
ファイル: MainWindow.java プロジェクト: hkaiser/TRiAS
  public void echoCmd(LibgistCommand cmd) {
    if (!showCmdsItem.getState()) {
      return;
    }

    echoBuffer.setLength(0); // reset
    switch (cmd.cmdType) {
      case LibgistCommand.INSERT:
        echoBuffer.append("insert \"").append(cmd.key);
        echoBuffer.append("\" \"").append(cmd.data).append("\"");
        break;

      case LibgistCommand.REMOVE:
        echoBuffer.append("delete \"").append(cmd.qual);
        echoBuffer.append("\"");
        break;

      case LibgistCommand.FETCH:
        echoBuffer.append("select ");
        if (cmd.fetchLimit > 0) {
          echoBuffer.append(cmd.fetchLimit).append(" ");
        }
        echoBuffer.append("\"").append(cmd.qual).append("\"");
        break;

      case LibgistCommand.CREATE:
        echoBuffer.append("create ").append(cmd.indexName);
        echoBuffer.append(" ").append(cmd.extension);
        break;

      case LibgistCommand.OPEN:
        echoBuffer.append("open ").append(cmd.indexName);
        break;

      case LibgistCommand.CLOSE:
        echoBuffer.append("close");
        break;

      case LibgistCommand.FLUSH:
        echoBuffer.append("flush");
        break;

      case LibgistCommand.OPENANL:
        echoBuffer.append("openanl ").append(cmd.analysisFile.getPath());
        break;

      case LibgistCommand.CLOSEANL:
        echoBuffer.append("closeanl");
        break;

      case LibgistCommand.CREATEANL:
        echoBuffer.append("createanl");
        break;

      case LibgistCommand.SCRIPT:
        echoBuffer.append("executing script...");
        break;

      default:
        // something wrong here
    }
    consoleFrame.echoCmd(echoBuffer.toString());
  }