예제 #1
0
  /** Initialize and update the items. */
  @Override
  public void initItems() {
    if (!initialized) {
      return;
    }

    removeAll();
    JMenuItem mit = add(newWindowAction);
    setMenuShortCutAccelerator(mit, 'N');

    ArrayList<GeoGebraFrame> ggbInstances = GeoGebraFrame.getInstances();
    int size = ggbInstances.size();
    if (size == 1) return;

    addSeparator();
    StringBuilder sb = new StringBuilder();
    ButtonGroup bg = new ButtonGroup();
    JRadioButtonMenuItem mi;

    int current = -1;

    for (int i = 0; i < size; i++) {
      GeoGebraFrame ggb = ggbInstances.get(i);
      AppD application = ggb.getApplication();
      if (app == application) current = i;
    }

    for (int i = 0; i < size; i++) {
      GeoGebraFrame ggb = ggbInstances.get(i);
      AppD application = ggb.getApplication();

      sb.setLength(0);
      sb.append(i + 1);
      if (application != null) // Michael Borcherds 2008-03-03 bugfix
      if (application.getCurrentFile() != null) {
          sb.append(" ");
          sb.append(application.getCurrentFile().getName());
        }

      mi = new JRadioButtonMenuItem(sb.toString());
      if (application == this.app) mi.setSelected(true);
      ActionListener al = new RequestFocusListener(ggb);
      mi.addActionListener(al);
      if (i == ((current + 1) % size)) setMenuShortCutShiftAccelerator(mi, 'N');
      else if (i == ((current - 1 + size) % size)) setMenuShortCutShiftAltAccelerator(mi, 'N');
      bg.add(mi);
      add(mi);
    }

    // support for right-to-left languages
    app.setComponentOrientation(this);
  }
예제 #2
0
  /** Initialize all items. */
  private void updateItems() {
    removeAll();

    JMenuItem mi;

    if (!app.isApplet()) {
      // "New" in application: new window
      mi = new JMenuItem(newWindowAction);
      setMenuShortCutAccelerator(mi, 'N');
      add(mi);
    }

    // "New": reset
    mi = add(deleteAll);

    mi = add(loadAction);
    setMenuShortCutAccelerator(mi, 'O'); // open
    mi = add(loadURLAction);
    addSeparator();
    mi = add(saveAction);
    setMenuShortCutAccelerator(mi, 'S');
    mi = add(saveAsAction);
    addSeparator();

    mi = add(printEuclidianViewAction);
    mi.setText(app.getMenu("PrintPreview"));
    mi.setIcon(app.getImageIcon("document-print-preview.png"));
    setMenuShortCutAccelerator(mi, 'P');

    addSeparator();

    mi = add(exportLMSAction);

    addSeparator();

    // export
    JMenu submenu = new JMenu(app.getMenu("Export"));
    submenu.setIcon(app.getEmptyIcon());
    add(submenu);

    mi = submenu.add(exportWorksheet);
    setMenuShortCutShiftAccelerator(mi, 'W');

    mi = submenu.add(exportGraphicAction);
    setMenuShortCutShiftAccelerator(mi, 'P');

    mi = submenu.add(drawingPadToClipboardAction);
    setMenuShortCutShiftAccelerator(mi, 'C');

    submenu.addSeparator();
    mi = submenu.add(exportPSTricksAction);
    setMenuShortCutShiftAccelerator(mi, 'T');

    mi = submenu.add(exportPgfAction);
    mi = submenu.add(exportAsymptoteAction);
    // End Export SubMenu

    // mi = submenu.add(exportGeoGebraTubeAction);

    // DONE HERE WHEN APPLET
    if (app.isApplet()) return;

    // recent SubMenu
    addSeparator();
    JMenu submenuRecent = new JMenu(app.getMenu("Recent"));
    submenu.setIcon(app.getEmptyIcon());
    add(submenuRecent);

    // Recent files list
    int size = Application.getFileListSize();
    if (size > 0) {
      for (int i = 0; i < Application.MAX_RECENT_FILES; i++) {
        File file = Application.getFromFileList(i);
        if (file != null) {
          mi = new JMenuItem(file.getName());
          mi.setIcon(app.getImageIcon("geogebra.gif"));
          ActionListener al = new LoadFileListener(app, file);
          mi.addActionListener(al);
          submenuRecent.add(mi);
        }
      }
    }

    // close
    addSeparator();
    mi = add(exitAction);
    if (Application.MAC_OS) {
      setMenuShortCutAccelerator(mi, 'W');
    } else {
      // Alt + F4
      KeyStroke ks = KeyStroke.getKeyStroke(KeyEvent.VK_F4, InputEvent.ALT_MASK);
      mi.setAccelerator(ks);
    }

    // close all
    if (GeoGebraFrame.getInstanceCount() > 1) {
      add(exitAllAction);
    }
  }