예제 #1
0
  /**
   * Creates the menu at the top of the shell where most of the programs functionality is accessed.
   *
   * @return The <code>Menu</code> widget that was created
   */
  private Menu createMenuBar() {
    Menu menuBar = new Menu(shell, SWT.BAR);
    shell.setMenuBar(menuBar);

    // create each header and subMenu for the menuBar
    createFileMenu(menuBar);
    createEditMenu(menuBar);
    createSearchMenu(menuBar);
    createHelpMenu(menuBar);

    return menuBar;
  }
예제 #2
0
파일: View.java 프로젝트: shader/gdr
  /** Initialize the drop-down menus in the appropriate area of the window */
  public void initMenu() {
    Menu menuBar = new Menu(shell, SWT.BAR);
    MenuItem cascadeFileMenu = new MenuItem(menuBar, SWT.CASCADE);
    cascadeFileMenu.setText("&File");
    MenuItem cascadeAnimMenu = new MenuItem(menuBar, SWT.CASCADE);
    cascadeAnimMenu.setText("&Animation");

    // file menu
    Menu fileMenu = new Menu(shell, SWT.DROP_DOWN);
    cascadeFileMenu.setMenu(fileMenu);

    MenuItem exitItem = new MenuItem(fileMenu, SWT.PUSH);
    exitItem.setText("&Exit");

    MenuItem openGraphItem = new MenuItem(fileMenu, SWT.PUSH);
    openGraphItem.setText("Open &Graph");

    MenuItem openAnimationItem = new MenuItem(fileMenu, SWT.PUSH);
    openAnimationItem.setText("Open &Animation");

    // temporary animation menu
    Menu animMenu = new Menu(shell, SWT.DROP_DOWN);
    cascadeAnimMenu.setMenu(animMenu);

    MenuItem DFSItem = new MenuItem(animMenu, SWT.PUSH);
    DFSItem.setText("Depth First Search");

    // add the menubar to the shell
    shell.setMenuBar(menuBar);

    // actions for the menu items

    exitItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            shell.getDisplay().dispose();
            System.exit(0);
          }
        });

    openGraphItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.NULL);
            String path = dialog.open();
            controller.LoadGraph(path);
          }
        });

    openAnimationItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            FileDialog dialog = new FileDialog(shell, SWT.NULL);
            String path = dialog.open();
            controller.LoadAnimation(path);
          }
        });

    DFSItem.addSelectionListener(
        new SelectionAdapter() {
          @Override
          public void widgetSelected(SelectionEvent e) {
            controller.LoadDFSAnimation();
          }
        });
  }