void onOpenFileClicked() {
    if (!maybeSave()) {
      return;
    }

    try {
      JFileChooser fc = new JFileChooser();
      FileNameExtensionFilter filter1 =
          new FileNameExtensionFilter(strings.getString("filetype." + EXTENSION), EXTENSION);
      fc.setFileFilter(filter1);

      int rv = fc.showOpenDialog(this);
      if (rv == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();

        Tournament t = new Tournament();
        t.loadFile(file);

        setTournament(file, t);
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
  }
  /** Install Add and Remove Buttons into the toolbar */
  private void installAddRemovePointButtons() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/plus.gif");
    ImageIcon plus = new ImageIcon(imgURL);
    imgURL = ClassLoader.getSystemResource("ch/tbe/pics/minus.gif");
    ImageIcon minus = new ImageIcon(imgURL);
    add = new JButton(plus);
    rem = new JButton(minus);
    add.setToolTipText(workingViewLabels.getString("plus"));
    rem.setToolTipText(workingViewLabels.getString("minus"));
    add.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WorkingView.this.addRemovePoint(true);
          }
        });
    rem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            WorkingView.this.addRemovePoint(false);
          }
        });

    add.setContentAreaFilled(false);
    add.setBorderPainted(false);
    rem.setContentAreaFilled(false);
    rem.setBorderPainted(false);
    toolbar.add(add);
    toolbar.add(rem);
  }
Exemple #3
0
 public ExitAction(MainFrame main) {
   super();
   Locale locale = Locale.getDefault();
   bundle = ResourceBundle.getBundle(getClass().getName(), locale);
   this.main = main;
   putValue(NAME, bundle.getString("Exit"));
   putValue(MNEMONIC_KEY, new Integer(bundle.getString("Exit.mnemonic").charAt(0)));
 }
 void refresh() {
   if (currentFile != null) {
     String fileName = currentFile.getName();
     if (fileName.endsWith("." + EXTENSION)) {
       fileName = fileName.substring(0, fileName.length() - 1 - EXTENSION.length());
     }
     setTitle(MessageFormat.format(strings.getString("main.caption_named_file"), fileName));
   } else {
     setTitle(strings.getString("main.caption_unnamed_file"));
   }
 }
Exemple #5
0
 public String getLevelString(String code) {
   try {
     return mResource.getString(LEVEL_PROPERTY + code);
   } catch (MissingResourceException e) {
     return code;
   }
 }
Exemple #6
0
 public String getSourceString(String code) {
   try {
     return mResource.getString(SOURCE_PROPERTY + code);
   } catch (MissingResourceException e) {
     return code;
   }
 }
  /** Second part of debugger start procedure. */
  private void startDebugger() {
    threadManager = new ThreadManager(this);

    setBreakpoints();
    updateWatches();
    println(bundle.getString("CTL_Debugger_running"), STL_OUT);
    setDebuggerState(DEBUGGER_RUNNING);

    virtualMachine.resume();

    // start refresh thread .................................................
    if (debuggerThread != null) debuggerThread.stop();
    debuggerThread =
        new Thread(
            new Runnable() {
              public void run() {
                for (; ; ) {
                  try {
                    Thread.sleep(5000);
                  } catch (InterruptedException ex) {
                  }
                  if (getState() == DEBUGGER_RUNNING) threadGroup.refresh();
                }
              }
            },
            "Debugger refresh thread"); // NOI18N
    debuggerThread.setPriority(Thread.MIN_PRIORITY);
    debuggerThread.start();
  }
 /** Returns version of this debugger. */
 public String getVersion() {
   return bundle.getString("CTL_Debugger_version");
   /*    if (virtualMachine != null)
     return virtualMachine.versionDescription () + " (" +
            virtualMachine.majorVersion () + "/" +
            virtualMachine.minorVersion () + ")";
   else
     return bundle.getString ("CTL_Debugger_version");*/
 }
 static {
   try {
     resources = ResourceBundle.getBundle("resources.TextViewer", Locale.getDefault());
   } catch (MissingResourceException mre) {
     String errstr = "TextViewer:resources/TextViewer.properties not found";
     // System.exit(1);
     System.err.println(errstr);
   }
 }
Exemple #10
0
 protected String getResourceString(String nm) {
   String str;
   try {
     str = resources.getString(nm);
   } catch (MissingResourceException mre) {
     str = null;
   }
   return str;
 }
Exemple #11
0
 static {
   try {
     properties = new Properties();
     properties.load(Notepad.class.getResourceAsStream("resources/NotepadSystem.properties"));
     resources = ResourceBundle.getBundle("resources.Notepad", Locale.getDefault());
   } catch (MissingResourceException | IOException e) {
     System.err.println(
         "resources/Notepad.properties " + "or resources/NotepadSystem.properties not found");
     System.exit(1);
   }
 }
Exemple #12
0
  public void actionPerformed(ActionEvent e) {
    // Ask user to confirm exit.
    int reply =
        JOptionPane.showConfirmDialog(
            main,
            bundle.getString("Exit_application_?"),
            bundle.getString("Exit"),
            JOptionPane.YES_NO_OPTION);
    if (reply != JOptionPane.YES_OPTION) return;

    // Save MainFrame's bounds
    Rectangle r = main.getBounds();
    Main.setProperty("window.bounds.width", Integer.toString(r.width));
    Main.setProperty("window.bounds.height", Integer.toString(r.height));
    Main.setProperty("window.bounds.x", Integer.toString(r.x));
    Main.setProperty("window.bounds.y", Integer.toString(r.y));

    // System Exit
    Main.saveProperties();
    Main.exit(0);
  }
  private VirtualMachine connect(String bndlPrefix, AttachingConnector connector, Map args)
      throws DebuggerException {
    if (bndlPrefix != null) {
      if (connector.transport().name().equals("dt_shmem")) {
        Argument a = (Argument) args.get("name");
        if (a == null) println(bundle.getString(bndlPrefix + "_shmem_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_shmem"))
                  .format(new Object[] {a.value()}),
              ERR_OUT);
      } else if (connector.transport().name().equals("dt_socket")) {
        Argument name = (Argument) args.get("hostname");
        Argument port = (Argument) args.get("port");
        if ((name == null) || (port == null))
          println(bundle.getString(bndlPrefix + "_socket_noargs"), ERR_OUT);
        else
          println(
              new MessageFormat(bundle.getString(bndlPrefix + "_socket"))
                  .format(new Object[] {name.value(), port.value()}),
              ERR_OUT);
      } else println(bundle.getString(bndlPrefix), ERR_OUT);
    }

    // launch VM
    try { // S ystem.out.println ("attach to:" + ac + " : " + password); // NOI18N
      return connector.attach(args);
    } catch (Exception e) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_connecting_to_debuggee"))
              .format(new Object[] {e.toString()}),
          e);
    }
  }
Exemple #14
0
  /** @return true if file was saved, false if user canceled */
  boolean onSaveFileClicked() {
    if (currentFile == null) {
      return onSaveAsFileClicked();
    }

    try {
      tournament.saveFile(currentFile);
      return true;
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
    return false;
  }
  /**
   * Create this dialog with the given parent and title.
   *
   * @param parent window from which this dialog is launched
   * @param title the title for the dialog box window
   * @since ostermillerutils 1.00.00
   */
  public PasswordDialog(Frame parent, String title) {

    super(parent, title, true);

    setLocale(Locale.getDefault());

    if (title == null) {
      setTitle(labels.getString("dialog.title"));
    }
    if (parent != null) {
      setLocationRelativeTo(parent);
    }
    // super calls dialogInit, so we don't need to do it again.
  }
Exemple #16
0
  /** @return true if file was saved, false if user canceled */
  boolean onSaveAsFileClicked() {
    try {

      JFileChooser fc = new JFileChooser();
      FileNameExtensionFilter filter1 =
          new FileNameExtensionFilter(strings.getString("filetype." + EXTENSION), EXTENSION);
      fc.setFileFilter(filter1);
      int rv = fc.showSaveDialog(this);

      if (rv == JFileChooser.APPROVE_OPTION) {
        currentFile = fc.getSelectedFile();
        if (!currentFile.getName().endsWith("." + EXTENSION)) {
          currentFile = new File(currentFile.getPath() + "." + EXTENSION);
        }
        doSave(currentFile);
        refresh();
        return true;
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
    return false;
  }
Exemple #17
0
  void makeMenu() {
    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu(strings.getString("menu.file"));
    menuBar.add(fileMenu);

    JMenuItem menuItem;
    menuItem = new JMenuItem(strings.getString("menu.file.new"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onNewFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.open"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onOpenFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.save"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onSaveFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.save_as"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onSaveAsFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.exit"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            closeWindow();
          }
        });
    fileMenu.add(menuItem);

    setJMenuBar(menuBar);
  }
Exemple #18
0
  boolean maybeSave() {
    if (tournament.isDirty()) {

      int rv =
          JOptionPane.showConfirmDialog(
              this,
              strings.getString("main.save_query"),
              PRODUCT_NAME,
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.WARNING_MESSAGE);
      if (rv == JOptionPane.CANCEL_OPTION) return false;

      if (rv == JOptionPane.YES_OPTION) {
        return onSaveFileClicked();
      }
    }
    return true;
  }
Exemple #19
0
 /*==========================================================
  * constructors
  *==========================================================*/
 public DefaultLogParser() {
   mResource = ResourceBundle.getBundle(CMSAdminResources.class.getName());
 }
  public void init() {
    symbolData =
        new Icon[] {
          new ImageIcon(getClass().getResource("images/sym_square.gif")),
          new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_circle.gif")),
          new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamond.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_triangle.gif")),
          new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross1.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross2.gif"))
        };

    mSymbolPopup = new JOAJComboBox();
    for (int i = 0; i < symbolData.length; i++) {
      mSymbolPopup.addItem(symbolData[i]);
    }
    mSymbolPopup.setSelectedIndex(mCurrSymbol - 1);

    JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5));

    // create the two parameter chooser lists
    Container contents = this.getContentPane();
    this.getContentPane().setLayout(new BorderLayout(5, 5));
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout(5, 5));
    JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JPanel upperPanel = new JPanel(new BorderLayout(5, 5));
    mYParamList =
        new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT");
    OffsetPanel ofp = new OffsetPanel(this);
    mYParamList.init();
    paramPanel.add(mYParamList);
    paramPanel.add(ofp);
    upperPanel.add("Center", paramPanel);
    everyThingPanel.add(BorderLayout.NORTH, upperPanel);

    // Options
    JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3));
    TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    middlePanel.setBorder(tb);

    // containers for the non-advanced options
    JPanel nonAdvOptions = new JPanel();
    nonAdvOptions.setLayout(new BorderLayout(5, 0));

    JPanel ctrNonAdvOptions = new JPanel();
    ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2));

    // plot axes goes in ctrNonAdvOptions
    JPanel axesOptions = new JPanel();
    axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kAxes"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    axesOptions.setBorder(tb);
    JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true);
    mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false);
    mReverseY.addItemListener(this);
    mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid"));
    mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid"));
    line0.add(mConnectObs);
    line1.add(mReverseY);
    line3.add(mPlotYGrid);
    line33.add(mPlotXGrid);
    axesOptions.add(line1);
    axesOptions.add(line3);
    axesOptions.add(line33);

    // other options
    JPanel otherOptions = new JPanel();
    otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kOther"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    otherOptions.setBorder(tb);

    // plot symbols
    JPanel line4 = new JPanel();
    line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    mEnableSymbols = new JOAJLabel(b.getString("kSymbol"));
    line4.add(mEnableSymbols);
    line4.add(mSymbolPopup);
    mSymbolPopup.addItemListener(this);
    mSizeLabel = new JOAJLabel(b.getString("kSize"));
    line4.add(mSizeLabel);

    SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1);
    mSizeField = new JSpinner(model);

    line4.add(mSizeField);
    otherOptions.add(line0);
    otherOptions.add(line4);

    // add the axes and other panels to the gridlayout
    ctrNonAdvOptions.add(axesOptions);
    ctrNonAdvOptions.add(otherOptions);

    // add this panel to the north of the borderlayout
    nonAdvOptions.add("Center", ctrNonAdvOptions);

    JPanel colorNameContPanel = new JPanel();
    colorNameContPanel.setLayout(new BorderLayout(0, 0));

    JPanel colorNamePanel = new JPanel();
    colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));

    // swatches
    JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineLCS.add(new JOAJLabel(b.getString("kLineColor")));
    mLineColorSwatch = new Swatch(Color.black, 12, 12);
    lineLCS.add(new JOAJLabel(" "));
    lineLCS.add(mLineColorSwatch);

    JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineSCS.add(new JOAJLabel(b.getString("kSymbolColor")));
    mSymbolColorSwatch = new Swatch(Color.black, 12, 12);
    lineSCS.add(new JOAJLabel(" "));
    lineSCS.add(mSymbolColorSwatch);

    JPanel line7 = new JPanel();
    line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line7.add(new JOAJLabel(b.getString("kBackgroundColor")));
    plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12);
    line7.add(new JOAJLabel(" "));
    line7.add(plotBg);
    JPanel line8 = new JPanel();
    line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line8.add(new JOAJLabel(b.getString("kGridColor")));
    axesColor = new Swatch(Color.black, 12, 12);
    line8.add(new JOAJLabel(" "));
    line8.add(axesColor);
    JPanel line9 = new JPanel();
    line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    line9.add(new JOAJLabel(b.getString("kColorSchemes")));
    Vector<String> presetSchemes = new Vector<String>();
    presetSchemes.addElement(b.getString("kDefault"));
    presetSchemes.addElement(b.getString("kWhiteBackground"));
    presetSchemes.addElement(b.getString("kBlackBackground"));
    presetColorSchemes = new JOAJComboBox(presetSchemes);
    presetColorSchemes.setSelectedItem(b.getString("kDefault"));
    presetColorSchemes.addItemListener(this);
    line9.add(presetColorSchemes);

    JPanel swatchCont = new JPanel();
    swatchCont.setLayout(new GridLayout(4, 1, 0, 5));
    swatchCont.add(lineLCS);
    swatchCont.add(lineSCS);
    swatchCont.add(line7);
    swatchCont.add(line8);
    JPanel swatchContCont = new JPanel();
    swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    swatchContCont.add(swatchCont);
    swatchContCont.add(line9);
    tb = BorderFactory.createTitledBorder(b.getString("kColors"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    swatchContCont.setBorder(tb);

    // window name
    JPanel namePanel = new JPanel();
    namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5));
    namePanel.add(new JOAJLabel(b.getString("kWindowName")));
    mNameField = new JOAJTextField(30);
    mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    namePanel.add(mNameField);

    // add the color panel
    colorNameContPanel.add("North", swatchContCont);
    colorNamePanel.add(colorNameContPanel);

    // add the name panel
    colorNamePanel.add(namePanel);

    // add these to the south of the borderlayout
    nonAdvOptions.add("South", colorNamePanel);

    // add all of this to the middle panel
    middlePanel.add(nonAdvOptions);

    // advanced options panel
    // axis container
    // y axis detail
    // container for the axes stuff
    plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5));

    // y axis container
    JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kYAxis"));
    yAxis.setBorder(tb);
    StnPlotSpecification mPlotSpec = new StnPlotSpecification();

    JPanel line5y = new JPanel();
    line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5y.add(new JOAJLabel(b.getString("kMinimum")));
    yMin = new JOAJTextField(6);
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false));
    yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5y.add(yMin);

    JPanel line6y = new JPanel();
    line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6y.add(new JOAJLabel(b.getString("kMaximum")));
    yMax = new JOAJTextField(6);
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false));
    yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6y.add(yMax);

    JPanel line7y = new JPanel();
    line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7y.add(new JOAJLabel(b.getString("kIncrement")));
    yInc = new JOAJTextField(6);
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false));
    yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7y.add(yInc);

    JPanel line8y = new JPanel();
    line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8y.add(new JOAJLabel(b.getString("kNoMinorTicks")));

    SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1);
    yTics = new JSpinner(model3);
    line8y.add(yTics);

    yAxis.add(line5y);
    yAxis.add(line6y);
    yAxis.add(line7y);
    yAxis.add(line8y);
    yAxis.add(new JLabel("   "));
    yAxis.add(new JLabel("    "));
    yAxis.add(new JLabel("    "));
    plotScaleCont.add(yAxis);

    // x axis container
    JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kXAxis"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    xAxis.setBorder(tb);

    JPanel line5x = new JPanel();
    line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5x.add(mMinXLabel);
    xMin = new JOAJTextField(6);
    xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false));
    xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5x.add(xMin);

    JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    minTime.add(mMinXTLabel);
    JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    maxTime.add(mMaxXTLabel);

    GeoDate minDate = new GeoDate(mFileViewer.getMinDate());
    minDate.decrement(1.0, GeoDate.YEARS);
    GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate());
    maxDate.increment(1.0, GeoDate.YEARS);
    // value, start,end
    SpinnerDateModel mStartDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR);
    mStartSpinner = new JSpinner(mStartDateModel);
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm");
    mStartSpinner.setEditor(dateEditor);

    SpinnerDateModel mEndDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR);
    mEndSpinner = new JSpinner(mEndDateModel);
    JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm");
    minTime.add(mStartSpinner);
    maxTime.add(mEndSpinner);
    mEndSpinner.setEditor(dateEditor2);

    JPanel line6x = new JPanel();
    line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6x.add(mMaxXLabel);
    xMax = new JOAJTextField(6);
    xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false));
    xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6x.add(xMax);

    JPanel line7x = new JPanel();
    line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7x.add(mIncLabel);
    xInc = new JOAJTextField(6);
    xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false));
    xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7x.add(xInc);

    JPanel line8x = new JPanel();
    line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8x.add(mXIncLabel);

    SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1);
    xTics = new JSpinner(model2);
    line8x.add(xTics);

    xAxis.add(minTime);
    xAxis.add(maxTime);
    xAxis.add(line5x);
    xAxis.add(line6x);
    xAxis.add(line7x);
    xAxis.add(line8x);
    plotScaleCont.add(xAxis);

    everyThingPanel.add(BorderLayout.CENTER, plotScaleCont);
    everyThingPanel.add(BorderLayout.SOUTH, middlePanel);

    mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10));

    // lower panel
    mOKBtn = new JOAJButton(b.getString("kPlot"));
    mOKBtn.setActionCommand("ok");
    this.getRootPane().setDefaultButton(mOKBtn);
    mCancelButton = new JOAJButton(b.getString("kCancel"));
    mCancelButton.setActionCommand("cancel");
    JPanel dlgBtnsInset = new JPanel();
    JPanel dlgBtnsPanel = new JPanel();
    dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1));
    dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1));
    if (JOAConstants.ISMAC) {
      dlgBtnsPanel.add(mCancelButton);
      dlgBtnsPanel.add(mOKBtn);
    } else {
      dlgBtnsPanel.add(mOKBtn);
      dlgBtnsPanel.add(mCancelButton);
    }
    dlgBtnsInset.add(dlgBtnsPanel);

    mOKBtn.addActionListener(this);
    mCancelButton.addActionListener(this);

    mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South");
    contents.add("Center", mainPanel);
    this.pack();

    runTimer();
    setXRangeToDistance();

    // show dialog at center of screen
    Rectangle dBounds = this.getBounds();
    Dimension sd = Toolkit.getDefaultToolkit().getScreenSize();
    int x = sd.width / 2 - dBounds.width / 2;
    int y = sd.height / 2 - dBounds.height / 2;
    this.setLocation(x, y);
  }
Exemple #21
0
  /** Install the Rotate-Button into the toolbar */
  private void installRotateButton() {
    URL imgURL = ClassLoader.getSystemResource("ch/tbe/pics/rotate.gif");
    ImageIcon rotateIcon = new ImageIcon(imgURL);
    rotate = new JButton(rotateIcon);
    rotate.setEnabled(false);
    rotatePanel = new JToolBar();
    rotatePanel.setOrientation(1);
    rotatePanel.setLayout(new BorderLayout(0, 1));
    rotateSlider = new JSlider();
    rotateSlider.setMaximum(359);
    rotateSlider.setMinimum(0);
    rotateSlider.setMaximumSize(new Dimension(100, 100));
    rotateSlider.setOrientation(1);
    Box box = Box.createVerticalBox();

    sliderValue.setPreferredSize(new Dimension(30, 20));

    rotateSlider.setAlignmentY(Component.TOP_ALIGNMENT);
    box.add(sliderValue);
    box.add(rotateSlider);
    sliderValue.setAlignmentY(Component.TOP_ALIGNMENT);
    rotatePanel.add(box, BorderLayout.NORTH);

    sliderValue.addFocusListener(
        new FocusListener() {

          private int oldValue = 0;

          public void focusGained(FocusEvent arg0) {
            oldValue = Integer.parseInt(sliderValue.getText());
          }

          public void focusLost(FocusEvent arg0) {
            int newValue = 0;
            try {
              newValue = Integer.parseInt(sliderValue.getText());
            } catch (Exception ex) {
              sliderValue.setText(Integer.toString(oldValue));
            }
            if (newValue >= 0 && newValue <= 359) {

              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rotateSlider.setValue(newValue);
            } else {
              sliderValue.setText(Integer.toString(oldValue));
            }
          }
        });

    rotateSlider.addChangeListener(
        new ChangeListener() {

          public void stateChanged(ChangeEvent arg0) {

            if (board.getSelectionCount() == 1
                && board.getSelectionCells()[0] instanceof ShapeItem) {
              sliderValue.setText(Integer.toString(rotateSlider.getValue()));
              ShapeItem s = (ShapeItem) board.getSelectionCells()[0];
              board.removeItem(new ItemComponent[] {s});
              s.setRotation(rotateSlider.getValue());
              board.addItem(s);
            }
          }
        });
    rotateSlider.addMouseListener(
        new MouseAdapter() {

          private int value;

          public void mousePressed(MouseEvent e) {
            value = rotateSlider.getValue();
          }

          public void mouseReleased(MouseEvent e) {
            if (value != rotateSlider.getValue()) {
              RotateCommand rc = new RotateCommand(board.getSelectedItems());
              ArrayList<Command> actCommands = new ArrayList<Command>();
              actCommands.add(rc);
              TBE.getInstance().addCommands(actCommands);
              rc.setRotation(value);
            }
          }
        });

    rotate.setToolTipText(workingViewLabels.getString("rotate"));

    rotate.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            if (board.getSelectionCount() == 1
                && board.getSelectedItems()[0] instanceof ShapeItem) {
              rotateSlider.setValue(((ShapeItem) board.getSelectedItems()[0]).getRotation());
            }
            rotatePanel.setVisible(!rotatePanel.isVisible());
            showRotate = !showRotate;
          }
        });

    rotate.setContentAreaFilled(false);
    rotate.setBorderPainted(false);
    toolbar.add(rotate);
    rotatePanel.setVisible(false);
    this.add(rotatePanel, BorderLayout.EAST);
  }
  private void initComponents() {
    // JFormDesigner - Component initialization - DO NOT MODIFY
    // //GEN-BEGIN:initComponents
    ResourceBundle bundle = ResourceBundle.getBundle("org.darkstorm.darkbot.darkbotmc.enUS");
    dialogPane = new JPanel();
    contentPanel = new JPanel();
    JLabel typeLabel = new JLabel();
    typeComboBox = new JComboBox();
    separator1 = new JSeparator();
    optionsPanel = new JPanel();
    buttonBar = new JPanel();
    okButton = new JButton();
    cancelButton = new JButton();

    // ======== this ========
    setTitle(bundle.getString("newbotdialog.this.title"));
    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    // ======== dialogPane ========
    {
      dialogPane.setBorder(new EmptyBorder(12, 12, 12, 12));
      dialogPane.setLayout(new BorderLayout());

      // ======== contentPanel ========
      {
        contentPanel.setLayout(new GridBagLayout());
        ((GridBagLayout) contentPanel.getLayout()).columnWidths = new int[] {0, 0, 0};
        ((GridBagLayout) contentPanel.getLayout()).rowHeights = new int[] {0, 0, 0, 0};
        ((GridBagLayout) contentPanel.getLayout()).columnWeights = new double[] {0.0, 1.0, 1.0E-4};
        ((GridBagLayout) contentPanel.getLayout()).rowWeights =
            new double[] {0.0, 0.0, 1.0, 1.0E-4};

        // ---- typeLabel ----
        typeLabel.setText(bundle.getString("newbotdialog.typeLabel.text"));
        contentPanel.add(
            typeLabel,
            new GridBagConstraints(
                0,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 5),
                0,
                0));

        // ---- typeComboBox ----
        typeComboBox.setModel(new DefaultComboBoxModel(new String[] {"Regular", "Spambot"}));
        typeComboBox.addItemListener(
            new ItemListener() {
              public void itemStateChanged(ItemEvent e) {
                typeComboBoxItemStateChanged(e);
              }
            });
        contentPanel.add(
            typeComboBox,
            new GridBagConstraints(
                1,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0),
                0,
                0));
        contentPanel.add(
            separator1,
            new GridBagConstraints(
                0,
                1,
                2,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 5, 0),
                0,
                0));

        // ======== optionsPanel ========
        {
          optionsPanel.setLayout(new BorderLayout());
        }
        contentPanel.add(
            optionsPanel,
            new GridBagConstraints(
                0,
                2,
                2,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 0, 0),
                0,
                0));
      }
      dialogPane.add(contentPanel, BorderLayout.CENTER);

      // ======== buttonBar ========
      {
        buttonBar.setBorder(new EmptyBorder(12, 0, 0, 0));
        buttonBar.setLayout(new GridBagLayout());
        ((GridBagLayout) buttonBar.getLayout()).columnWidths = new int[] {0, 85, 80};
        ((GridBagLayout) buttonBar.getLayout()).columnWeights = new double[] {1.0, 0.0, 0.0};

        // ---- okButton ----
        okButton.setText("OK");
        okButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                okButtonActionPerformed(e);
              }
            });
        buttonBar.add(
            okButton,
            new GridBagConstraints(
                1,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 0, 5),
                0,
                0));

        // ---- cancelButton ----
        cancelButton.setText("Cancel");
        cancelButton.addActionListener(
            new ActionListener() {
              public void actionPerformed(ActionEvent e) {
                cancelButtonActionPerformed(e);
              }
            });
        buttonBar.add(
            cancelButton,
            new GridBagConstraints(
                2,
                0,
                1,
                1,
                0.0,
                0.0,
                GridBagConstraints.CENTER,
                GridBagConstraints.BOTH,
                new Insets(0, 0, 0, 0),
                0,
                0));
      }
      dialogPane.add(buttonBar, BorderLayout.SOUTH);
    }
    contentPane.add(dialogPane, BorderLayout.CENTER);
    setSize(400, 550);
    setLocationRelativeTo(getOwner());
    // //GEN-END:initComponents
  }
@SuppressWarnings("serial")
public class ConfigureStationValuePlot extends JOAJDialog
    implements ListSelectionListener, ActionListener, ButtonMaintainer, ItemListener {
  ResourceBundle b = ResourceBundle.getBundle("javaoceanatlas.resources.JOAResources");
  protected FileViewer mFileViewer;
  protected String mTitle;
  protected Component mComp;
  protected StnParameterChooser mYParamList;
  protected int mSelYParam = -1;
  protected JOAJButton mOKBtn = null;
  protected JOAJButton mCancelButton = null;
  protected JOAJTextField mNameField = null;
  protected JOAJRadioButton b1 = null;
  protected JOAJRadioButton b2 = null;
  protected JOAJRadioButton b3 = null;
  protected int mOffset = JOAConstants.PROFDISTANCE;
  protected Swatch plotBg = null;
  protected Swatch axesColor = null;
  protected Swatch mLineColorSwatch = null;
  protected Swatch mSymbolColorSwatch = null;
  protected JOAJComboBox presetColorSchemes = null;
  protected JOAJCheckBox mReverseY = null;
  protected JOAJCheckBox mPlotYGrid = null;
  protected JOAJCheckBox mPlotXGrid = null;
  protected JOAJComboBox mSymbolPopup = null;
  protected int mCurrSymbol = JOAConstants.SYMBOL_CROSS1;
  protected Icon[] symbolData = null;
  protected JSpinner mSizeField = null;
  protected JOAJLabel mEnableSymbols = null;
  protected JOAJLabel mSizeLabel = null;
  private Timer timer = new Timer();
  protected JOAJTextField yMin, yMax, yInc;
  protected JSpinner yTics, xTics;
  protected JOAJTextField xMin, xMax, xInc;
  protected JPanel plotScaleCont = null;
  protected int pPos = -1;
  protected int yTicsVal = 1;
  protected int xTicsVal = 1;
  private JOAJLabel mMinXLabel = new JOAJLabel(b.getString("kMinimum"));
  private JOAJLabel mMaxXLabel = new JOAJLabel(b.getString("kMaximum"));
  private JOAJLabel mIncLabel = new JOAJLabel(b.getString("kIncrement"));
  private JOAJLabel mMinXTLabel = new JOAJLabel(b.getString("kMinimum"));
  private JOAJLabel mMaxXTLabel = new JOAJLabel(b.getString("kMaximum"));
  private JOAJLabel mXIncLabel = new JOAJLabel(b.getString("kNoMinorTicks"));
  private JSpinner mStartSpinner;
  private JSpinner mEndSpinner;
  private JCheckBox mConnectObs;

  public ConfigureStationValuePlot(JFrame par, FileViewer fv) {
    super(par, "Station Value Plot", false);
    mFileViewer = fv;
    this.init();
  }

  public void init() {
    symbolData =
        new Icon[] {
          new ImageIcon(getClass().getResource("images/sym_square.gif")),
          new ImageIcon(getClass().getResource("images/sym_squarefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_circle.gif")),
          new ImageIcon(getClass().getResource("images/sym_circlefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamond.gif")),
          new ImageIcon(getClass().getResource("images/sym_diamondfilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_triangle.gif")),
          new ImageIcon(getClass().getResource("images/sym_trianglefilled.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross1.gif")),
          new ImageIcon(getClass().getResource("images/sym_cross2.gif"))
        };

    mSymbolPopup = new JOAJComboBox();
    for (int i = 0; i < symbolData.length; i++) {
      mSymbolPopup.addItem(symbolData[i]);
    }
    mSymbolPopup.setSelectedIndex(mCurrSymbol - 1);

    JPanel everyThingPanel = new JPanel(new BorderLayout(5, 5));

    // create the two parameter chooser lists
    Container contents = this.getContentPane();
    this.getContentPane().setLayout(new BorderLayout(5, 5));
    JPanel mainPanel = new JPanel();
    mainPanel.setLayout(new BorderLayout(5, 5));
    JPanel paramPanel = new JPanel(new GridLayout(1, 2, 5, 5));
    JPanel upperPanel = new JPanel(new BorderLayout(5, 5));
    mYParamList =
        new StnParameterChooser(mFileViewer, new String("Stations Parameters:"), this, 5, "SALT");
    OffsetPanel ofp = new OffsetPanel(this);
    mYParamList.init();
    paramPanel.add(mYParamList);
    paramPanel.add(ofp);
    upperPanel.add("Center", paramPanel);
    everyThingPanel.add(BorderLayout.NORTH, upperPanel);

    // Options
    JPanel middlePanel = new JPanel();
    middlePanel.setLayout(new ColumnLayout(Orientation.CENTER, Orientation.TOP, 3));
    TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOptions"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    middlePanel.setBorder(tb);

    // containers for the non-advanced options
    JPanel nonAdvOptions = new JPanel();
    nonAdvOptions.setLayout(new BorderLayout(5, 0));

    JPanel ctrNonAdvOptions = new JPanel();
    ctrNonAdvOptions.setLayout(new GridLayout(1, 2, 2, 2));

    // plot axes goes in ctrNonAdvOptions
    JPanel axesOptions = new JPanel();
    axesOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kAxes"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    axesOptions.setBorder(tb);
    JPanel line0 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line3 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    JPanel line33 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
    mConnectObs = new JOAJCheckBox(b.getString("kConnectObservations"), true);
    mReverseY = new JOAJCheckBox(b.getString("kReverseYAxis"), false);
    mReverseY.addItemListener(this);
    mPlotYGrid = new JOAJCheckBox(b.getString("kYGrid"));
    mPlotXGrid = new JOAJCheckBox(b.getString("kXGrid"));
    line0.add(mConnectObs);
    line1.add(mReverseY);
    line3.add(mPlotYGrid);
    line33.add(mPlotXGrid);
    axesOptions.add(line1);
    axesOptions.add(line3);
    axesOptions.add(line33);

    // other options
    JPanel otherOptions = new JPanel();
    otherOptions.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));
    tb = BorderFactory.createTitledBorder(b.getString("kOther"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    otherOptions.setBorder(tb);

    // plot symbols
    JPanel line4 = new JPanel();
    line4.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    mEnableSymbols = new JOAJLabel(b.getString("kSymbol"));
    line4.add(mEnableSymbols);
    line4.add(mSymbolPopup);
    mSymbolPopup.addItemListener(this);
    mSizeLabel = new JOAJLabel(b.getString("kSize"));
    line4.add(mSizeLabel);

    SpinnerNumberModel model = new SpinnerNumberModel(4, 1, 100, 1);
    mSizeField = new JSpinner(model);

    line4.add(mSizeField);
    otherOptions.add(line0);
    otherOptions.add(line4);

    // add the axes and other panels to the gridlayout
    ctrNonAdvOptions.add(axesOptions);
    ctrNonAdvOptions.add(otherOptions);

    // add this panel to the north of the borderlayout
    nonAdvOptions.add("Center", ctrNonAdvOptions);

    JPanel colorNameContPanel = new JPanel();
    colorNameContPanel.setLayout(new BorderLayout(0, 0));

    JPanel colorNamePanel = new JPanel();
    colorNamePanel.setLayout(new ColumnLayout(Orientation.LEFT, Orientation.CENTER, 0));

    // swatches
    JPanel lineLCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineLCS.add(new JOAJLabel(b.getString("kLineColor")));
    mLineColorSwatch = new Swatch(Color.black, 12, 12);
    lineLCS.add(new JOAJLabel(" "));
    lineLCS.add(mLineColorSwatch);

    JPanel lineSCS = new JPanel(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    lineSCS.add(new JOAJLabel(b.getString("kSymbolColor")));
    mSymbolColorSwatch = new Swatch(Color.black, 12, 12);
    lineSCS.add(new JOAJLabel(" "));
    lineSCS.add(mSymbolColorSwatch);

    JPanel line7 = new JPanel();
    line7.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line7.add(new JOAJLabel(b.getString("kBackgroundColor")));
    plotBg = new Swatch(JOAConstants.DEFAULT_CONTENTS_COLOR, 12, 12);
    line7.add(new JOAJLabel(" "));
    line7.add(plotBg);
    JPanel line8 = new JPanel();
    line8.setLayout(new FlowLayout(FlowLayout.RIGHT, 3, 0));
    line8.add(new JOAJLabel(b.getString("kGridColor")));
    axesColor = new Swatch(Color.black, 12, 12);
    line8.add(new JOAJLabel(" "));
    line8.add(axesColor);
    JPanel line9 = new JPanel();
    line9.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    line9.add(new JOAJLabel(b.getString("kColorSchemes")));
    Vector<String> presetSchemes = new Vector<String>();
    presetSchemes.addElement(b.getString("kDefault"));
    presetSchemes.addElement(b.getString("kWhiteBackground"));
    presetSchemes.addElement(b.getString("kBlackBackground"));
    presetColorSchemes = new JOAJComboBox(presetSchemes);
    presetColorSchemes.setSelectedItem(b.getString("kDefault"));
    presetColorSchemes.addItemListener(this);
    line9.add(presetColorSchemes);

    JPanel swatchCont = new JPanel();
    swatchCont.setLayout(new GridLayout(4, 1, 0, 5));
    swatchCont.add(lineLCS);
    swatchCont.add(lineSCS);
    swatchCont.add(line7);
    swatchCont.add(line8);
    JPanel swatchContCont = new JPanel();
    swatchContCont.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 0));
    swatchContCont.add(swatchCont);
    swatchContCont.add(line9);
    tb = BorderFactory.createTitledBorder(b.getString("kColors"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    swatchContCont.setBorder(tb);

    // window name
    JPanel namePanel = new JPanel();
    namePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 5));
    namePanel.add(new JOAJLabel(b.getString("kWindowName")));
    mNameField = new JOAJTextField(30);
    mNameField.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    namePanel.add(mNameField);

    // add the color panel
    colorNameContPanel.add("North", swatchContCont);
    colorNamePanel.add(colorNameContPanel);

    // add the name panel
    colorNamePanel.add(namePanel);

    // add these to the south of the borderlayout
    nonAdvOptions.add("South", colorNamePanel);

    // add all of this to the middle panel
    middlePanel.add(nonAdvOptions);

    // advanced options panel
    // axis container
    // y axis detail
    // container for the axes stuff
    plotScaleCont = new JPanel(new GridLayout(1, 2, 5, 5));

    // y axis container
    JPanel yAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kYAxis"));
    yAxis.setBorder(tb);
    StnPlotSpecification mPlotSpec = new StnPlotSpecification();

    JPanel line5y = new JPanel();
    line5y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5y.add(new JOAJLabel(b.getString("kMinimum")));
    yMin = new JOAJTextField(6);
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMin()), 3, false));
    yMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5y.add(yMin);

    JPanel line6y = new JPanel();
    line6y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6y.add(new JOAJLabel(b.getString("kMaximum")));
    yMax = new JOAJTextField(6);
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinYPlotMax()), 3, false));
    yMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6y.add(yMax);

    JPanel line7y = new JPanel();
    line7y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7y.add(new JOAJLabel(b.getString("kIncrement")));
    yInc = new JOAJTextField(6);
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getYInc()), 3, false));
    yInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7y.add(yInc);

    JPanel line8y = new JPanel();
    line8y.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8y.add(new JOAJLabel(b.getString("kNoMinorTicks")));

    SpinnerNumberModel model3 = new SpinnerNumberModel(mPlotSpec.getYTics(), 0, 100, 1);
    yTics = new JSpinner(model3);
    line8y.add(yTics);

    yAxis.add(line5y);
    yAxis.add(line6y);
    yAxis.add(line7y);
    yAxis.add(line8y);
    yAxis.add(new JLabel("   "));
    yAxis.add(new JLabel("    "));
    yAxis.add(new JLabel("    "));
    plotScaleCont.add(yAxis);

    // x axis container
    JPanel xAxis = new JPanel(new ColumnLayout(Orientation.RIGHT, Orientation.CENTER, 2));
    tb = BorderFactory.createTitledBorder(b.getString("kXAxis"));
    if (JOAConstants.ISMAC) {
      // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
    }
    xAxis.setBorder(tb);

    JPanel line5x = new JPanel();
    line5x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line5x.add(mMinXLabel);
    xMin = new JOAJTextField(6);
    xMin.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMin()), 3, false));
    xMin.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line5x.add(xMin);

    JPanel minTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    minTime.add(mMinXTLabel);
    JPanel maxTime = new JPanel(new FlowLayout(FlowLayout.LEFT, 3, 1));
    maxTime.add(mMaxXTLabel);

    GeoDate minDate = new GeoDate(mFileViewer.getMinDate());
    minDate.decrement(1.0, GeoDate.YEARS);
    GeoDate maxDate = new GeoDate(mFileViewer.getMaxDate());
    maxDate.increment(1.0, GeoDate.YEARS);
    // value, start,end
    SpinnerDateModel mStartDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMinDate()), minDate, maxDate, Calendar.HOUR);
    mStartSpinner = new JSpinner(mStartDateModel);
    JSpinner.DateEditor dateEditor = new JSpinner.DateEditor(mStartSpinner, "yyyy-MM-dd HH:mm");
    mStartSpinner.setEditor(dateEditor);

    SpinnerDateModel mEndDateModel =
        new SpinnerDateModel(
            new GeoDate(mFileViewer.getMaxDate()), minDate, maxDate, Calendar.HOUR);
    mEndSpinner = new JSpinner(mEndDateModel);
    JSpinner.DateEditor dateEditor2 = new JSpinner.DateEditor(mEndSpinner, "yyyy-MM-dd HH:mm");
    minTime.add(mStartSpinner);
    maxTime.add(mEndSpinner);
    mEndSpinner.setEditor(dateEditor2);

    JPanel line6x = new JPanel();
    line6x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line6x.add(mMaxXLabel);
    xMax = new JOAJTextField(6);
    xMax.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getWinXPlotMax()), 3, false));
    xMax.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line6x.add(xMax);

    JPanel line7x = new JPanel();
    line7x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line7x.add(mIncLabel);
    xInc = new JOAJTextField(6);
    xInc.setText(JOAFormulas.formatDouble(String.valueOf(mPlotSpec.getXInc()), 3, false));
    xInc.setCursor(Cursor.getPredefinedCursor(Cursor.TEXT_CURSOR));
    line7x.add(xInc);

    JPanel line8x = new JPanel();
    line8x.setLayout(new FlowLayout(FlowLayout.LEFT, 3, 1));
    line8x.add(mXIncLabel);

    SpinnerNumberModel model2 = new SpinnerNumberModel(mPlotSpec.getXTics(), 0, 100, 1);
    xTics = new JSpinner(model2);
    line8x.add(xTics);

    xAxis.add(minTime);
    xAxis.add(maxTime);
    xAxis.add(line5x);
    xAxis.add(line6x);
    xAxis.add(line7x);
    xAxis.add(line8x);
    plotScaleCont.add(xAxis);

    everyThingPanel.add(BorderLayout.CENTER, plotScaleCont);
    everyThingPanel.add(BorderLayout.SOUTH, middlePanel);

    mainPanel.add(BorderLayout.CENTER, new TenPixelBorder(everyThingPanel, 10, 10, 10, 10));

    // lower panel
    mOKBtn = new JOAJButton(b.getString("kPlot"));
    mOKBtn.setActionCommand("ok");
    this.getRootPane().setDefaultButton(mOKBtn);
    mCancelButton = new JOAJButton(b.getString("kCancel"));
    mCancelButton.setActionCommand("cancel");
    JPanel dlgBtnsInset = new JPanel();
    JPanel dlgBtnsPanel = new JPanel();
    dlgBtnsInset.setLayout(new FlowLayout(FlowLayout.CENTER, 20, 1));
    dlgBtnsPanel.setLayout(new GridLayout(1, 4, 15, 1));
    if (JOAConstants.ISMAC) {
      dlgBtnsPanel.add(mCancelButton);
      dlgBtnsPanel.add(mOKBtn);
    } else {
      dlgBtnsPanel.add(mOKBtn);
      dlgBtnsPanel.add(mCancelButton);
    }
    dlgBtnsInset.add(dlgBtnsPanel);

    mOKBtn.addActionListener(this);
    mCancelButton.addActionListener(this);

    mainPanel.add(new TenPixelBorder(dlgBtnsInset, 5, 5, 5, 5), "South");
    contents.add("Center", mainPanel);
    this.pack();

    runTimer();
    setXRangeToDistance();

    // show dialog at center of screen
    Rectangle dBounds = this.getBounds();
    Dimension sd = Toolkit.getDefaultToolkit().getScreenSize();
    int x = sd.width / 2 - dBounds.width / 2;
    int y = sd.height / 2 - dBounds.height / 2;
    this.setLocation(x, y);
  }

  public void runTimer() {
    TimerTask task =
        new TimerTask() {
          public void run() {
            maintainButtons();
          }
        };
    timer.schedule(task, 0, 1000);
  }

  private class OffsetPanel extends JPanel {
    private OffsetPanel(Component comp) {
      this.setLayout(new BorderLayout(0, 0));
      TitledBorder tb = BorderFactory.createTitledBorder(b.getString("kOffsetBy"));
      if (JOAConstants.ISMAC) {
        // tb.setTitleFont(new Font("Helvetica", Font.PLAIN, 11));
      }
      this.setBorder(tb);
      JPanel controls = new JPanel();
      controls.setLayout(new GridLayout(3, 1, 5, 0));
      b1 = new JOAJRadioButton(b.getString("kSequence"));
      b2 = new JOAJRadioButton(b.getString("kDistance"), true);
      b3 = new JOAJRadioButton(b.getString("kTime"));
      controls.add(b2);
      controls.add(b1);
      controls.add(b3);
      controls.add(new JOAJLabel("       "));
      ButtonGroup bg = new ButtonGroup();
      bg.add(b1);
      bg.add(b2);
      bg.add(b3);
      this.add("Center", controls);
      b1.addItemListener((ItemListener) comp);
      b2.addItemListener((ItemListener) comp);
      b3.addItemListener((ItemListener) comp);
    }
  }

  public void valueChanged(ListSelectionEvent evt) {
    if (evt.getSource() == mYParamList.getJList()) {
      mSelYParam = mYParamList.getJList().getSelectedIndex();
      setAdvancedValues();
    }

    generatePlotName();
  }

  public void actionPerformed(ActionEvent e) {
    String cmd = e.getActionCommand();

    if (cmd.equals("cancel")) {
      this.dispose();
      timer.cancel();
    } else if (cmd.equals("ok")) {
      StnPlotSpecification spec = createPlotSpec();
      try {
        spec.writeToLog("New Station Value Plot (" + mFileViewer.getTitle() + "):");
      } catch (Exception ex) {
      }

      JOAStnValPlotWindow plotWind = new JOAStnValPlotWindow(spec, mFileViewer);
      plotWind.pack();
      plotWind.setVisible(true);
      mFileViewer.addOpenWindow(plotWind);
      timer.cancel();
      this.dispose();
    }
  }

  public void itemStateChanged(ItemEvent evt) {
    if (evt.getSource() instanceof JOAJRadioButton) {
      JOAJRadioButton rb = (JOAJRadioButton) evt.getSource();
      if (rb == b1 && evt.getStateChange() == ItemEvent.SELECTED) {
        mOffset = JOAConstants.PROFSEQUENCE;
        setXRangeToSequence();
      } else if (rb == b2 && evt.getStateChange() == ItemEvent.SELECTED) {
        mOffset = JOAConstants.PROFDISTANCE;
        setXRangeToDistance();
      } else if (rb == b3 && evt.getStateChange() == ItemEvent.SELECTED) {
        mOffset = JOAConstants.PROFTIME;
        setXRangeToTime();
      }
    } else if (evt.getSource() instanceof JOAJCheckBox) {
    } else if (evt.getSource() instanceof JOAJComboBox) {
      JOAJComboBox cb = (JOAJComboBox) evt.getSource();
      if (cb == presetColorSchemes) {
        int colorScheme = cb.getSelectedIndex();
        if (colorScheme == 0) {
          // default bg
          plotBg.setColor(JOAConstants.DEFAULT_CONTENTS_COLOR);
          axesColor.setColor(Color.black);
        } else if (colorScheme == 1) {
          // white bg
          plotBg.setColor(Color.white);
          axesColor.setColor(Color.black);
        } else {
          // color bg
          plotBg.setColor(Color.black);
          axesColor.setColor(Color.white);
        }
      } else if (cb == mSymbolPopup) {
        mCurrSymbol = cb.getSelectedIndex() + 1;
      }
    }
    generatePlotName();
  }

  public void maintainButtons() {
    if (mSelYParam >= 0) {
      mOKBtn.setEnabled(true);
    } else {
      mOKBtn.setEnabled(false);
    }
  }

  public StnPlotSpecification createPlotSpec() {
    StnPlotSpecification ps = new StnPlotSpecification();
    // get the colors
    ps.setFGColor(axesColor.getColor());
    ps.setBGColor(plotBg.getColor());

    ps.setSectionType(mOffset);
    ps.setFileViewer(mFileViewer);
    ps.setXStnVarCode(mSelYParam);
    ps.setYStnVarName(new String((String) mYParamList.getJList().getSelectedValue()));
    ps.setWinTitle(mNameField.getText());
    ps.setYGrid(mPlotYGrid.isSelected());
    ps.setXGrid(mPlotXGrid.isSelected());
    ps.setReverseY(mReverseY.isSelected());
    ps.setSymbol(mCurrSymbol);
    ps.setSymbolSize(((Integer) mSizeField.getValue()).intValue());
    ps.setConnectObs(mConnectObs.isSelected());
    ps.setLineColor(mLineColorSwatch.getColor());
    ps.setSymbolColor(mSymbolColorSwatch.getColor());

    boolean error = false;
    try {
      ps.setWinYPlotMin(Double.valueOf(yMin.getText()).doubleValue());
    } catch (NumberFormatException ex) {
      error = true;
    }

    try {
      ps.setWinYPlotMax(Double.valueOf(yMax.getText()).doubleValue());
    } catch (NumberFormatException ex) {
      error = true;
    }

    try {
      ps.setYInc(Double.valueOf(yInc.getText()).doubleValue());
    } catch (NumberFormatException ex) {
      error = true;
    }

    ps.setYTics(((Integer) yTics.getValue()).intValue());

    if (mOffset == JOAConstants.PROFSEQUENCE || mOffset == JOAConstants.PROFDISTANCE) {
      try {
        ps.setWinXPlotMin(Double.valueOf(xMin.getText()).doubleValue());
      } catch (NumberFormatException ex) {
        error = true;
      }

      try {
        ps.setWinXPlotMax(Double.valueOf(xMax.getText()).doubleValue());
      } catch (NumberFormatException ex) {
        error = true;
      }

      try {
        ps.setXInc(Double.valueOf(xInc.getText()).doubleValue());
      } catch (NumberFormatException ex) {
        error = true;
      }
    } else {

      long startTime = ((Date) mStartSpinner.getValue()).getTime();
      long endTime = ((Date) mEndSpinner.getValue()).getTime();

      ps.setWinXPlotMin(startTime);
      ps.setWinXPlotMax(endTime);
    }

    ps.setXTics(((Integer) xTics.getValue()).intValue());

    if (error) {
      // post alert
    }
    return ps;
  }

  public void setAdvancedValues() {
    // get pretty ranges for the current parameters
    // get the range for the station value
    double min = 10000;
    double max = 0;
    for (int fc = 0; fc < mFileViewer.mNumOpenFiles; fc++) {
      OpenDataFile of = (OpenDataFile) mFileViewer.mOpenFiles.elementAt(fc);

      for (int sec = 0; sec < of.mNumSections; sec++) {
        Section sech = (Section) of.mSections.elementAt(sec);

        if (sech.mNumCasts == 0) {
          continue;
        }

        for (int stc = 0; stc < sech.mStations.size(); stc++) {
          Station sh = (Station) sech.mStations.elementAt(stc);
          if (!sh.mUseStn) {
            continue;
          }

          // get the station value
          double y = sh.getStnValue(mSelYParam);
          if (y == JOAConstants.MISSINGVALUE || y >= JOAConstants.EPICMISSINGVALUE) {
            continue;
          } else {
            min = y < min ? y : min;
            max = y > max ? y : max;
          }
        }
      }
    }

    Triplet newRange = JOAFormulas.GetPrettyRange(min, max);
    double yMinv = newRange.getVal1();
    double yMaxv = newRange.getVal2();
    double yIncv = newRange.getVal3();
    yMin.setText(JOAFormulas.formatDouble(String.valueOf(yMinv), 3, false));
    yMax.setText(JOAFormulas.formatDouble(String.valueOf(yMaxv), 3, false));
    yInc.setText(JOAFormulas.formatDouble(String.valueOf(yIncv), 3, false));
    yTics.setValue(new Integer(yTicsVal));
    if (b1.isSelected()) {
      mOffset = JOAConstants.PROFSEQUENCE;
      setXRangeToSequence();
    } else if (b2.isSelected()) {
      mOffset = JOAConstants.PROFDISTANCE;
      setXRangeToDistance();
    } else if (b3.isSelected()) {
      mOffset = JOAConstants.PROFTIME;
      setXRangeToTime();
    }
  }

  public void setXRangeToDistance() {
    hideTime();
    // set the x axis from the total mercator distance
    double tempXMin = 0;
    double tempXMax = mFileViewer.mTotMercDist * 1.852;
    Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
    double xMinv = newRange.getVal1();
    double xMaxv = newRange.getVal2();
    double xIncv = newRange.getVal3();
    xMin.setText(JOAFormulas.formatDouble(String.valueOf(xMinv), 3, false));
    xMax.setText(JOAFormulas.formatDouble(String.valueOf(xMaxv), 3, false));
    xInc.setText(JOAFormulas.formatDouble(String.valueOf(xIncv), 3, false));
    xTics.setValue(new Integer(xTicsVal));
  }

  public void setXRangeToTime() {
    showTime();
    // set the x axis from the time range of the data
    GeoDate minDate = mFileViewer.getMinDate();
    GeoDate maxDate = mFileViewer.getMaxDate();

    xTics.setValue(new Integer(xTicsVal));
  }

  public void setXRangeToSequence() {
    hideTime();
    // set the x axis from the total mercator distance
    double tempXMin = 0;
    double tempXMax = mFileViewer.mTotalStations;
    Triplet newRange = JOAFormulas.GetPrettyRange(tempXMin, tempXMax);
    double xMinv = newRange.getVal1();
    double xMaxv = newRange.getVal2();
    double xIncv = newRange.getVal3();
    xMin.setText(String.valueOf((int) xMinv));
    xMax.setText(String.valueOf((int) xMaxv));
    xInc.setText(String.valueOf((int) xIncv));
    xTics.setValue(new Integer(xTicsVal));
  }

  public void hideTime() {
    mMaxXTLabel.setEnabled(false);
    mMinXTLabel.setEnabled(false);
    mMaxXLabel.setEnabled(true);
    mMinXLabel.setEnabled(true);
    mIncLabel.setEnabled(true);
    xMin.setEnabled(true);
    xMax.setEnabled(true);
    xInc.setEnabled(true);
    mStartSpinner.setEnabled(false);
    mEndSpinner.setEnabled(false);
    xTics.setEnabled(true);
    mPlotXGrid.setEnabled(true);
    mXIncLabel.setEnabled(true);
  }

  public void showTime() {
    mMaxXTLabel.setEnabled(true);
    mMinXTLabel.setEnabled(true);
    mMaxXLabel.setEnabled(false);
    mMinXLabel.setEnabled(false);
    mIncLabel.setEnabled(false);
    xMin.setText("");
    xMax.setText("");
    xInc.setText("");
    xMin.setEnabled(false);
    xMax.setEnabled(false);
    xInc.setEnabled(false);
    mStartSpinner.setEnabled(true);
    mEndSpinner.setEnabled(true);
    xTics.setEnabled(false);
    mPlotXGrid.setEnabled(false);
    mXIncLabel.setEnabled(false);
  }

  public void generatePlotName() {
    String yVarText = (String) mYParamList.getJList().getSelectedValue();
    if (yVarText == null || yVarText.length() == 0) {
      yVarText = "?";
    }

    String offsetStr = null;
    if (b1.isSelected()) {
      offsetStr = "Seq";
    } else if (b2.isSelected()) {
      offsetStr = "Dist";
    } else {
      offsetStr = "Time";
    }

    String nameString =
        new String(yVarText + "-" + offsetStr + " (" + mFileViewer.mFileViewerName + ")");
    mNameField.setText(nameString);
  }
}
  private VirtualMachine launch(DebuggerInfo info) throws DebuggerException {
    // create process & read password for local debugging

    // create main class & arguments ...............................................
    StringBuffer sb = new StringBuffer();
    sb.append(mainClassName);
    String[] infoArgs = info.getArguments();
    int i, k = infoArgs.length;
    for (i = 0; i < k; i++) sb.append(" \"").append(infoArgs[i]).append('"'); // NOI18N
    String main = new String(sb);

    // create connector ..............................................................
    VirtualMachineManager vmm = Bootstrap.virtualMachineManager();
    java.util.List lcs = vmm.launchingConnectors();
    k = lcs.size();
    for (i = 0; i < k; i++)
      if (((LaunchingConnector) lcs.get(i)).name().indexOf("RawCommandLineLaunch") >= 0) // NOI18N
      break;
    if (i == k) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_Cannot_find_launcher"))
              .format(
                  new Object[] {
                    "RawCommandLineLaunch" // NOI18N
                  }));
    }
    LaunchingConnector lc = (LaunchingConnector) lcs.get(i);
    String transport = lc.transport().name();

    // create commandLine & NbProcessDescriptor ..............................
    NbProcessDescriptor debugerProcess;
    if (info instanceof ProcessDebuggerInfo)
      debugerProcess = ((ProcessDebuggerInfo) info).getDebuggerProcess();
    else debugerProcess = ProcessDebuggerType.DEFAULT_DEBUGGER_PROCESS;

    // generate password
    String password;
    if (transport.equals("dt_shmem")) { // NOI18N
      connector = getAttachingConnectorFor("dt_shmem");
      password = generatePassword();
      args = connector.defaultArguments();
      ((Argument) args.get("name")).setValue(password);
    } else {
      try {
        java.net.ServerSocket ss = new java.net.ServerSocket(0);
        password = "" + ss.getLocalPort(); // NOI18N
        ss.close();
      } catch (java.io.IOException e) {
        finishDebugger();
        throw new DebuggerException(
            new MessageFormat(bundle.getString("EXC_Cannot_find_empty_local_port"))
                .format(new Object[] {e.toString()}));
      }
      connector = getAttachingConnectorFor("dt_socket");
      args = connector.defaultArguments();
      ((Argument) args.get("port")).setValue(password);
    }
    HashMap map =
        Utils.processDebuggerInfo(
            info,
            "-Xdebug -Xnoagent -Xrunjdwp:transport="
                + // NOI18N
                transport
                + ",address="
                + // NOI18N
                password
                + ",suspend=y ", // NOI18N
            main);
    MapFormat format = new MapFormat(map);
    String commandLine =
        format.format(
            debugerProcess.getProcessName()
                + " "
                + // NOI18N
                debugerProcess.getArguments());
    println(commandLine, ERR_OUT);
    /*
    We mus wait on process start to connect...
    try {
      process = debugerProcess.exec (format);
    } catch (java.io.IOException exc) {
      finishDebugger ();
      throw new DebuggerException (
        new MessageFormat (bundle.getString ("EXC_While_create_debuggee")).
          format (new Object[] {
            debugerProcess.getProcessName (),
            exc.toString ()
          }),
        exc
      );
    }
    return connect (
      null,
      connector,
      args
    );*/

    /*      S ystem.out.println ("attaching: ");
    Utils.showConnectors (vmm.attachingConnectors ());

    S ystem.out.println ("launching: ");
    Utils.showConnectors (vmm.launchingConnectors ());

    S ystem.out.println ("listening: ");
    Utils.showConnectors (vmm.listeningConnectors ());*/

    // set debugger-start arguments
    Map params = lc.defaultArguments();
    ((Argument) params.get("command"))
        .setValue( // NOI18N
            commandLine);
    ((Argument) params.get("address"))
        .setValue( // NOI18N
            password);

    // launch VM
    try {
      return lc.launch(params);
    } catch (VMStartException exc) {
      showOutput(process = exc.process(), ERR_OUT, ERR_OUT);
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    } catch (Exception exc) {
      finishDebugger();
      throw new DebuggerException(
          new MessageFormat(bundle.getString("EXC_While_create_debuggee"))
              .format(
                  new Object[] {format.format(debugerProcess.getProcessName()), exc.toString()}),
          exc);
    }
  }
  // ------------------------------------------------------------------------
  TextViewer(JFrame inParentFrame) {
    // super(true); //is double buffered - only for panels

    textViewerFrame = this;
    parentFrame = inParentFrame;
    lastViewedDirStr = "";
    lastViewedFileStr = "";

    setTitle(resources.getString("Title"));
    addWindowListener(new AppCloser());
    pack();
    setSize(500, 600);

    warningPopup = new WarningDialog(this);
    okCancelPopup = new WarningDialogOkCancel(this);
    messagePopup = new MessageDialog(this);
    okCancelMessagePopup = new MessageDialogOkCancel(this);

    // Force SwingSet to come up in the Cross Platform L&F
    try {
      UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
      // If you want the System L&F instead, comment out the above line and
      // uncomment the following:
      // UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
    } catch (Exception exc) {
      String errstr = "TextViewer:Error loading L&F: " + exc;
      warningPopup.display(errstr);
    }

    Container cf = getContentPane();
    cf.setBackground(Color.lightGray);
    // Border etched=BorderFactory.createEtchedBorder();
    // Border title=BorderFactory.createTitledBorder(etched,"TextViewer");
    // cf.setBorder(title);
    cf.setLayout(new BorderLayout());

    // create the embedded JTextComponent
    editor1 = createEditor();
    editor1.setFont(new Font("monospaced", Font.PLAIN, 12));
    // aa -added next line
    setPlainDocument((PlainDocument) editor1.getDocument()); // sets doc1

    // install the command table
    commands = new Hashtable();
    Action[] actions = getActions();
    for (int i = 0; i < actions.length; i++) {
      Action a = actions[i];
      commands.put(a.getValue(Action.NAME), a);
      // System.out.println("Debug:TextViewer: actionName:"+a.getValue(Action.NAME));
    }
    // editor1.setPreferredSize(new Dimension(,));
    // get setting from user preferences
    if (UserPref.keymapType.equals("Word")) {
      editor1 = updateKeymapForWord(editor1);
    } else {
      editor1 = updateKeymapForEmacs(editor1);
    }

    scroller1 = new JScrollPane();
    viewport1 = scroller1.getViewport();
    viewport1.add(editor1);
    scroller1.setVerticalScrollBarPolicy(JScrollPane.VERTICAL_SCROLLBAR_ALWAYS);
    scroller1.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);

    try {
      String vpFlag = resources.getString("ViewportBackingStore");
      Boolean bs = new Boolean(vpFlag);
      viewport1.setBackingStoreEnabled(bs.booleanValue());
    } catch (MissingResourceException mre) {
      System.err.println("TextViewer:missing resource:" + mre.getMessage());
      // just use the viewport1 default
    }

    menuItems = new Hashtable();

    menubar = createMenubar();

    lowerPanel = new JPanel(true); // moved double buffering to here
    lowerPanel.setLayout(new BorderLayout());
    lowerPanel.add("North", createToolbar());
    lowerPanel.add("Center", scroller1);

    cf.add("North", menubar);
    cf.add("Center", lowerPanel);
    cf.add("South", createStatusbar());

    // for the find/search utilities
    mySearchDialog = new SearchDialog(this);

    // System.out.println("Debug:TextViewer: end of TextViewer constructor");

  }
  /**
   * Starts the debugger. The method stops the current debugging (if any) and takes information from
   * the provided info (containing the class to start and arguments to pass it and name of class to
   * stop debugging in) and starts new debugging session.
   *
   * @param info debugger info about class to start
   * @exception DebuggerException if an error occures during the start of the debugger
   */
  public void startDebugger(DebuggerInfo info) throws DebuggerException {
    debuggerInfo = info;
    if (virtualMachine != null) finishDebugger();

    stopOnMain = info.getStopClassName() != null;
    mainClassName =
        info
            .getClassName(); // S ystem.out.println ("JPDADebugger stop on " + info.getStopClassName
                             // ()); // NOI18N

    // open output window ...
    super.startDebugger(info);

    // stop on main
    if (stopOnMain) {
      try {
        String stopClassName = debuggerInfo.getStopClassName();
        AbstractDebugger d = (AbstractDebugger) TopManager.getDefault().getDebugger();
        breakpointMain = new CoreBreakpoint[stopMethodNames.length];
        for (int x = 0; x < breakpointMain.length; x++) {
          breakpointMain[x] = (CoreBreakpoint) d.createBreakpoint(true);
          breakpointMain[x].setClassName(""); // NOI18N
          breakpointMain[x].setMethodName(stopMethodNames[x]); // NOI18N
          CoreBreakpoint.Action[] a = breakpointMain[x].getActions();
          int i, ii = a.length;
          for (i = 0; i < ii; i++)
            if (a[i] instanceof PrintAction) {
              ((PrintAction) a[i]).setPrintText(bundle.getString("CTL_Stop_On_Main_print_text"));
            }
          breakpointMain[x].setClassName(stopClassName);
        }

        addPropertyChangeListener(
            new PropertyChangeListener() {
              public void propertyChange(PropertyChangeEvent ev) {
                if (ev.getPropertyName().equals(PROP_STATE)) {
                  if ((((Integer) ev.getNewValue()).intValue() == DEBUGGER_STOPPED)
                      || (((Integer) ev.getNewValue()).intValue() == DEBUGGER_NOT_RUNNING)) {
                    if (breakpointMain != null) {
                      for (int x = 0; x < breakpointMain.length; x++) breakpointMain[x].remove();
                      breakpointMain = null;
                    }
                    removePropertyChangeListener(this);
                  }
                }
              }
            });

      } catch (DebuggerException e) {
        e.printStackTrace();
      }
    }

    // start & init remote debugger ............................................
    boolean launch = false;
    if (info instanceof ReconnectDebuggerInfo) {
      virtualMachine = reconnect((ReconnectDebuggerInfo) info);
    } else if (info instanceof RemoteDebuggerInfo) {
      virtualMachine = connect((RemoteDebuggerInfo) info);
    } else {
      virtualMachine = launch(info);
      process = virtualMachine.process();
      showOutput(process, STD_OUT, STD_OUT);
      connectInput(process);
      launch = true;
    }
    requestManager = virtualMachine.eventRequestManager();
    operator =
        new Operator(
            virtualMachine,
            launch
                ? new Runnable() {
                  public void run() {
                    startDebugger();
                  }
                }
                : null,
            new Runnable() {
              public void run() {
                try {
                  finishDebugger();
                } catch (DebuggerException e) {
                }
              }
            });
    operator.start();
    if (!launch) startDebugger();
  }
  /**
   * Called by constructors to initialize the dialog.
   *
   * @since ostermillerutils 1.00.00
   */
  @Override
  protected void dialogInit() {

    if (labels == null) {
      setLocale(Locale.getDefault());
    }

    name = new JTextField("", 20);
    pass = new JPasswordField("", 20);
    okButton = new JButton(labels.getString("dialog.ok"));
    cancelButton = new JButton(labels.getString("dialog.cancel"));
    nameLabel = new JLabel(labels.getString("dialog.name") + " ");
    passLabel = new JLabel(labels.getString("dialog.pass") + " ");

    super.dialogInit();

    KeyListener keyListener =
        (new KeyAdapter() {
          @Override
          public void keyPressed(KeyEvent e) {
            if (e.getKeyCode() == KeyEvent.VK_ESCAPE
                || (e.getSource() == cancelButton && e.getKeyCode() == KeyEvent.VK_ENTER)) {
              pressed_OK = false;
              PasswordDialog.this.setVisible(false);
            }
            if (e.getSource() == okButton && e.getKeyCode() == KeyEvent.VK_ENTER) {
              pressed_OK = true;
              PasswordDialog.this.setVisible(false);
            }
          }
        });
    addKeyListener(keyListener);

    ActionListener actionListener =
        new ActionListener() {
          public void actionPerformed(ActionEvent e) {
            Object source = e.getSource();
            if (source == name) {
              // the user pressed enter in the name field.
              name.transferFocus();
            } else {
              // other actions close the dialog.
              pressed_OK = (source == pass || source == okButton);
              PasswordDialog.this.setVisible(false);
            }
          }
        };

    GridBagLayout gridbag = new GridBagLayout();
    GridBagConstraints c = new GridBagConstraints();
    c.insets.top = 5;
    c.insets.bottom = 5;
    JPanel pane = new JPanel(gridbag);
    pane.setBorder(BorderFactory.createEmptyBorder(10, 20, 5, 20));
    c.anchor = GridBagConstraints.EAST;
    gridbag.setConstraints(nameLabel, c);
    pane.add(nameLabel);

    gridbag.setConstraints(name, c);
    name.addActionListener(actionListener);
    name.addKeyListener(keyListener);
    pane.add(name);

    c.gridy = 1;
    gridbag.setConstraints(passLabel, c);
    pane.add(passLabel);

    gridbag.setConstraints(pass, c);
    pass.addActionListener(actionListener);
    pass.addKeyListener(keyListener);
    pane.add(pass);

    c.gridy = 2;
    c.gridwidth = GridBagConstraints.REMAINDER;
    c.anchor = GridBagConstraints.CENTER;
    JPanel panel = new JPanel();
    okButton.addActionListener(actionListener);
    okButton.addKeyListener(keyListener);
    panel.add(okButton);
    cancelButton.addActionListener(actionListener);
    cancelButton.addKeyListener(keyListener);
    panel.add(cancelButton);
    gridbag.setConstraints(panel, c);
    pane.add(panel);

    getContentPane().add(pane);

    pack();
  }
/**
 * Implementaion of Framebuffer for MeTA Studio. Majorly a copy of <code>
 * org.jrman.ui.FramebufferImpl</code>.
 *
 * @author V.Ganesh
 * @version 2.0 (Part of MeTA v2.0)
 */
public class IDEJRManFramebufferImpl extends JInternalFrame implements Framebuffer {

  private JImageViewerPanel imagePanel = new JImageViewerPanel();
  private ImageViewerPanelSaveAction save =
      new ImageViewerPanelSaveAction(imagePanel, BufferedImage.TYPE_INT_ARGB);
  private String name;

  /** Creates a new instance of IDEJRManFramebufferImpl */
  public IDEJRManFramebufferImpl(String name, BufferedImage image) {
    super("JRMan rendered: " + name, true, true, true, true);
    this.name = name;

    save.setEnabled(false);

    imagePanel.setImage(image);
    imagePanel.addToolbarAction(save);
    if (image.getType() == BufferedImage.TYPE_INT_ARGB
        || image.getType() == BufferedImage.TYPE_INT_ARGB_PRE) {
      imagePanel.setShowTransparencyPattern(true);
    }

    getRootPane().setDoubleBuffered(false);
    getContentPane().add(imagePanel);
    pack();

    ImageResource images = ImageResource.getInstance();

    // set the frame icon
    setFrameIcon(images.getJrMan());

    // add this to the IDE desktop
    MainMenuEventHandlers.getInstance(null)
        .getIdeInstance()
        .getWorkspaceDesktop()
        .addInternalFrame(this, true);
  }

  /**
   * Signal that a certain rectangular region has changed
   *
   * @param x top-left x coordinate
   * @param y top-left y coordinate
   * @param w rectangle width
   * @param h rectangle height
   */
  @Override
  public void refresh(int x, int y, int w, int h) {
    imagePanel.repaintImage(x, y, w, h);
  }

  /** Signal image is completed */
  @Override
  public void completed() {
    save.setEnabled(true);
  }

  // the resource bundels
  private static final ResourceBundle messagesBundle =
      ResourceBundle.getBundle(
          net.falappa.imageio.ImageViewerPanelSaveAction.class.getPackage().getName()
              + ".res.ImageViewerPanelActions");

  /** inner class to handle save action */
  public class ImageViewerPanelSaveAction extends AbstractAction {
    private JImageViewerPanel viewerPanel;
    private int imageType;
    private IDEFileChooser fc;

    /**
     * Constructs and initializes this object
     *
     * @param viewerPanel the <code>JImageViewerPanel</code> this action is linked to
     * @param imageType
     */
    public ImageViewerPanelSaveAction(JImageViewerPanel viewerPanel, int imageType) {
      super(messagesBundle.getString("ImageViewerPanelSaveAction.Save_1")); // $NON-NLS-1$
      assert viewerPanel != null;
      this.imageType = imageType;
      this.viewerPanel = viewerPanel;
      putValue(
          SHORT_DESCRIPTION,
          messagesBundle.getString("ImageViewerPanelSaveAction.Save_image_to_file_2"));
      //$NON-NLS-1$
      putValue(SMALL_ICON, UIManager.getIcon("FileView.floppyDriveIcon")); // $NON-NLS-1$
    }

    @Override
    public void actionPerformed(ActionEvent e) {
      if (fc == null) {
        fc = new IDEFileChooser();
        fc.setFileView(new IDEFileView());
        fc.setAcceptAllFileFilterUsed(false);
        fc.setFileSelectionMode(JFileChooser.FILES_ONLY);
        fc.setMultiSelectionEnabled(false);
        fc.setDialogTitle(
            messagesBundle.getString("ImageViewerPanelSaveAction.Choose_filename_to_save_4"));

        //$NON-NLS-1$

        // prepare file filters
        IIORegistry theRegistry = IIORegistry.getDefaultInstance();
        Iterator it = theRegistry.getServiceProviders(ImageWriterSpi.class, false);
        while (it.hasNext()) {
          ImageWriterSpi writer = (ImageWriterSpi) it.next();
          if ((imageType == BufferedImage.TYPE_INT_ARGB
                  || imageType == BufferedImage.TYPE_INT_ARGB_PRE)
              && "JPEG".equals(writer.getFormatNames()[0].toUpperCase())) continue;
          ImageWriterSpiFileFilter ff = new ImageWriterSpiFileFilter(writer);
          fc.addChoosableFileFilter(ff);
        }
      }

      if (fc.showSaveDialog(viewerPanel) == JFileChooser.APPROVE_OPTION) {
        File selectedFile = fc.getSelectedFile();

        if (selectedFile != null) {
          String fileName = selectedFile.getAbsolutePath();
          ImageWriterSpiFileFilter ff = (ImageWriterSpiFileFilter) fc.getFileFilter();
          if (!ff.hasCorrectSuffix(fileName)) fileName = ff.addSuffix(fileName);
          selectedFile = new File(fileName);
          if (selectedFile.exists()) {
            String message =
                MessageFormat.format(
                    messagesBundle.getString("ImageViewerPanelSaveAction.Overwrite_question_5"),
                    //$NON-NLS-1$
                    fileName);
            if (JOptionPane.NO_OPTION
                == JOptionPane.showConfirmDialog(
                    viewerPanel,
                    message,
                    messagesBundle.getString("ImageViewerPanelSaveAction.Warning_6"),
                    //$NON-NLS-1$
                    JOptionPane.YES_NO_OPTION,
                    JOptionPane.WARNING_MESSAGE)) return;
          }
          writeToFile(selectedFile, ff);
        }
      }
    }

    private void writeToFile(File selectedFile, ImageWriterSpiFileFilter ff) {
      try {
        ImageOutputStream ios = ImageIO.createImageOutputStream(selectedFile);
        ImageWriter iw = ff.getImageWriterSpi().createWriterInstance();
        iw.setOutput(ios);
        ImageWriteParam iwp = iw.getDefaultWriteParam();
        if (iwp.canWriteCompressed()) {
          iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
          // set maximum image quality
          iwp.setCompressionQuality(1.f);
        }
        Image image = viewerPanel.getImage();
        BufferedImage bufferedImage;
        if (viewerPanel.getImage() instanceof BufferedImage)
          bufferedImage = (BufferedImage) viewerPanel.getImage();
        else {
          bufferedImage =
              new BufferedImage(
                  image.getWidth(null), image.getHeight(null), BufferedImage.TYPE_INT_RGB);
          bufferedImage.createGraphics().drawImage(image, 0, 0, null);
        }
        iw.write(null, new IIOImage(bufferedImage, null, null), iwp);
        iw.dispose();
        ios.close();
      } catch (IOException ioe) {
        JOptionPane.showMessageDialog(
            viewerPanel,
            messagesBundle.getString(
                "ImageViewerPanelSaveAction." + "Error_during_image_saving_message_7"),
            //$NON-NLS-1$
            messagesBundle.getString("ImageViewerPanelSaveAction." + "Error_dialog_title_8"),
            //$NON-NLS-1$
            JOptionPane.ERROR_MESSAGE);
        ioe.printStackTrace();
      }
    }
  }
} // end of class IDEJRManFramebufferImpl
 /**
  * Set the locale used for getting localized strings.
  *
  * @param locale Locale used to for i18n.
  * @since ostermillerutils 1.00.00
  */
 @Override
 public void setLocale(Locale locale) {
   labels = ResourceBundle.getBundle("com.Ostermiller.util.PasswordDialog", locale);
 }
Exemple #30
0
public class MainWindow extends JFrame {
  static ResourceBundle strings = ResourceBundle.getBundle("dragonfin.tournament.GuiStrings");
  static final String PRODUCT_NAME = strings.getString("PRODUCT");
  static final String EXTENSION = "tourney";

  Tournament tournament;
  File currentFile;

  RosterModel rosterModel;
  JTable rosterTable;
  JScrollPane rosterScrollPane;

  public MainWindow() {
    setTitle(PRODUCT_NAME);

    rosterTable = new JTable();

    rosterScrollPane = new JScrollPane(rosterTable);
    rosterTable.setFillsViewportHeight(true);
    getContentPane().add(rosterScrollPane, BorderLayout.CENTER);

    makeMenu();
    pack();
    setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
    setLocationRelativeTo(null);

    addWindowListener(
        new WindowAdapter() {
          public void windowClosing(WindowEvent ev) {
            closeWindow();
          }
        });

    setTournament(null, new Tournament());
  }

  void makeMenu() {
    JMenuBar menuBar = new JMenuBar();

    JMenu fileMenu = new JMenu(strings.getString("menu.file"));
    menuBar.add(fileMenu);

    JMenuItem menuItem;
    menuItem = new JMenuItem(strings.getString("menu.file.new"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onNewFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.open"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onOpenFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.save"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onSaveFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.save_as"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            onSaveAsFileClicked();
          }
        });
    fileMenu.add(menuItem);

    menuItem = new JMenuItem(strings.getString("menu.file.exit"));
    menuItem.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ev) {
            closeWindow();
          }
        });
    fileMenu.add(menuItem);

    setJMenuBar(menuBar);
  }

  void closeWindow() {
    if (!maybeSave()) {
      return;
    }

    dispose();
  }

  boolean maybeSave() {
    if (tournament.isDirty()) {

      int rv =
          JOptionPane.showConfirmDialog(
              this,
              strings.getString("main.save_query"),
              PRODUCT_NAME,
              JOptionPane.YES_NO_CANCEL_OPTION,
              JOptionPane.WARNING_MESSAGE);
      if (rv == JOptionPane.CANCEL_OPTION) return false;

      if (rv == JOptionPane.YES_OPTION) {
        return onSaveFileClicked();
      }
    }
    return true;
  }

  void onNewFileClicked() {
    if (!maybeSave()) {
      return;
    }

    setTournament(null, new Tournament());
  }

  void doSave(File file) throws IOException {
    currentFile = file;
    tournament.saveFile(file);
  }

  void onOpenFileClicked() {
    if (!maybeSave()) {
      return;
    }

    try {
      JFileChooser fc = new JFileChooser();
      FileNameExtensionFilter filter1 =
          new FileNameExtensionFilter(strings.getString("filetype." + EXTENSION), EXTENSION);
      fc.setFileFilter(filter1);

      int rv = fc.showOpenDialog(this);
      if (rv == JFileChooser.APPROVE_OPTION) {
        File file = fc.getSelectedFile();

        Tournament t = new Tournament();
        t.loadFile(file);

        setTournament(file, t);
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
  }

  /** @return true if file was saved, false if user canceled */
  boolean onSaveFileClicked() {
    if (currentFile == null) {
      return onSaveAsFileClicked();
    }

    try {
      tournament.saveFile(currentFile);
      return true;
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
    return false;
  }

  /** @return true if file was saved, false if user canceled */
  boolean onSaveAsFileClicked() {
    try {

      JFileChooser fc = new JFileChooser();
      FileNameExtensionFilter filter1 =
          new FileNameExtensionFilter(strings.getString("filetype." + EXTENSION), EXTENSION);
      fc.setFileFilter(filter1);
      int rv = fc.showSaveDialog(this);

      if (rv == JFileChooser.APPROVE_OPTION) {
        currentFile = fc.getSelectedFile();
        if (!currentFile.getName().endsWith("." + EXTENSION)) {
          currentFile = new File(currentFile.getPath() + "." + EXTENSION);
        }
        doSave(currentFile);
        refresh();
        return true;
      }
    } catch (Exception e) {
      JOptionPane.showMessageDialog(
          this, e, strings.getString("main.error_caption"), JOptionPane.ERROR_MESSAGE);
    }
    return false;
  }

  void refresh() {
    if (currentFile != null) {
      String fileName = currentFile.getName();
      if (fileName.endsWith("." + EXTENSION)) {
        fileName = fileName.substring(0, fileName.length() - 1 - EXTENSION.length());
      }
      setTitle(MessageFormat.format(strings.getString("main.caption_named_file"), fileName));
    } else {
      setTitle(strings.getString("main.caption_unnamed_file"));
    }
  }

  public static void main(String[] args) {
    SwingUtilities.invokeLater(
        new Runnable() {
          public void run() {
            new MainWindow().setVisible(true);
          }
        });
  }

  public void setTournament(File file, Tournament newTournament) {
    assert newTournament != null;

    this.currentFile = file;
    this.tournament = newTournament;

    rosterModel = new RosterModel(newTournament);
    rosterTable.setModel(rosterModel);

    refresh();
  }
}