/**
  * Adds a Display menu to the menu bar. Overrides OSPFrame method.
  *
  * @return the display menu
  */
 protected JMenu loadDisplayMenu() {
   JMenuBar menuBar = getJMenuBar();
   if (menuBar == null) {
     return null;
   }
   JMenu menu = super.loadDisplayMenu();
   translateItem = new JMenuItem();
   translateItem.setText(ControlsRes.getString("OSPControl.Translate")); // $NON-NLS-1$
   // changed by D Brown 2007-10-17
   if (OSPRuntime.translator != null) {
     translateItem.addActionListener(
         new ActionListener() {
           public void actionPerformed(ActionEvent e) {
             OSPRuntime.translator.showProperties(model.getClass());
             if (OSPRuntime.translator instanceof Hidable)
               ((Hidable) OSPRuntime.translator).setKeepHidden(false);
             OSPRuntime.translator.setVisible(true);
           }
         });
     translateItem.setEnabled(OSPRuntime.isAuthorMode());
     languageMenu.add(translateItem, 0);
   }
   // changed by D Brown 2006-09-10
   if (languageMenu.getItemCount() > 1) languageMenu.insertSeparator(1);
   return menu;
 }
Example #2
0
  /**
   * Gets the autoload manager, creating it the first time called.
   *
   * @return the autoload manageer
   */
  protected AutoloadManager getAutoloadManager() {
    if (autoloadManager == null) {
      autoloadManager = new AutoloadManager(this);

      // center on screen
      Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
      int x = (dim.width - autoloadManager.getBounds().width) / 2;
      int y = (dim.height - autoloadManager.getBounds().height) / 2;
      autoloadManager.setLocation(x, y);

      if (!Tracker.dataFunctionControlStrings.isEmpty()) {
        // convert and save in user platform-dependent default search directory
        ArrayList<String> searchPaths = OSPRuntime.getDefaultSearchPaths();
        final String directory = searchPaths.size() > 0 ? searchPaths.get(0) : null;
        if (directory != null) {
          Runnable runner =
              new Runnable() {
                public void run() {
                  int response =
                      JOptionPane.showConfirmDialog(
                          TrackDataBuilder.this,
                          TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message1") //$NON-NLS-1$
                              + "\n"
                              + TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message2") //$NON-NLS-1$
                                                                                      // //$NON-NLS-2$
                              + "\n\n"
                              + TrackerRes.getString(
                                  "TrackDataBuilder.Dialog.ConvertAutoload.Message3"), //$NON-NLS-1$
                                                                                       // //$NON-NLS-2$
                          TrackerRes.getString(
                              "TrackDataBuilder.Dialog.ConvertAutoload.Title"), //$NON-NLS-1$
                          JOptionPane.YES_NO_OPTION);
                  if (response == JOptionPane.YES_OPTION) {
                    TrackDataBuilder builder = new TrackDataBuilder(new TrackerPanel());
                    int i = 0;
                    for (String next : Tracker.dataFunctionControlStrings) {
                      XMLControl panelControl = new XMLControlElement(next);
                      DataFunctionPanel panel = new DataFunctionPanel(new DatasetManager());
                      panelControl.loadObject(panel);
                      builder.addPanelWithoutAutoloading("panel" + i, panel); // $NON-NLS-1$
                      i++;
                    }
                    File file =
                        new File(directory, "TrackerConvertedAutoloadFunctions.xml"); // $NON-NLS-1$
                    XMLControl control = new XMLControlElement(builder);
                    control.write(file.getAbsolutePath());
                    Tracker.dataFunctionControlStrings.clear();
                    autoloadManager.refreshAutoloadData();
                  }
                }
              };
          SwingUtilities.invokeLater(runner);
        }
      }
    }
    autoloadManager.setFontLevel(FontSizer.getLevel());
    return autoloadManager;
  }