예제 #1
0
 /**
  * The ActionListener implementation
  *
  * @param event the event.
  */
 public void actionPerformed(ActionEvent event) {
   String searchText = textField.getText().trim();
   if (searchText.equals("") && !saveAs.isSelected() && (fileLength > 10000000)) {
     textPane.setText("Blank search text is not allowed for large IdTables.");
   } else {
     File outputFile = null;
     if (saveAs.isSelected()) {
       outputFile = chooser.getSelectedFile();
       if (outputFile != null) {
         String name = outputFile.getName();
         int k = name.lastIndexOf(".");
         if (k != -1) name = name.substring(0, k);
         name += ".txt";
         File parent = outputFile.getAbsoluteFile().getParentFile();
         outputFile = new File(parent, name);
         chooser.setSelectedFile(outputFile);
       }
       if (chooser.showSaveDialog(this) != JFileChooser.APPROVE_OPTION) System.exit(0);
       outputFile = chooser.getSelectedFile();
     }
     textPane.setText("");
     Searcher searcher = new Searcher(searchText, event.getSource().equals(searchPHI), outputFile);
     searcher.start();
   }
 }
예제 #2
0
  void applyDirectives() {
    findRemoveDirectives(true);

    StringBuffer buffer = new StringBuffer();
    String head = "", toe = "; \n";

    if (crispBox.isSelected()) buffer.append(head + "crisp=true" + toe);
    if (!fontField.getText().trim().equals(""))
      buffer.append(head + "font=\"" + fontField.getText().trim() + "\"" + toe);
    if (globalKeyEventsBox.isSelected()) buffer.append(head + "globalKeyEvents=true" + toe);
    if (pauseOnBlurBox.isSelected()) buffer.append(head + "pauseOnBlur=true" + toe);
    if (!preloadField.getText().trim().equals(""))
      buffer.append(head + "preload=\"" + preloadField.getText().trim() + "\"" + toe);
    /*if ( transparentBox.isSelected() )
    buffer.append( head + "transparent=true" + toe );*/

    Sketch sketch = editor.getSketch();
    SketchCode code = sketch.getCode(0); // first tab
    if (buffer.length() > 0) {
      code.setProgram("/* @pjs " + buffer.toString() + " */\n\n" + code.getProgram());
      if (sketch.getCurrentCode() == code) // update textarea if on first tab
      {
        editor.setText(sketch.getCurrentCode().getProgram());
        editor.setSelection(0, 0);
      }

      sketch.setModified(false);
      sketch.setModified(true);
    }
  }
예제 #3
0
  /**
   * Constructor for FindDialog
   *
   * @param type
   * @param ta Description of the Parameter
   */
  public FindDialog(JFrame parent, JTextComponent ta) {
    super(parent, "Find in Output", true);
    this.textarea = ta;
    textarea.requestFocus();

    JPanel panel = new JPanel();
    KappaLayout layout = new KappaLayout();
    panel.setLayout(layout);
    panel.setBorder(new javax.swing.border.EmptyBorder(11, 11, 11, 11));
    setContentPane(panel);

    JLabel find_label = new JLabel("Find:");
    final JTextField to_find = new JTextField(20);
    JButton find_btn = new JButton("Find");
    JButton find_next_btn = new JButton("Find Next");
    JButton cancel_btn = new JButton("Close");
    final JCheckBox wrap_cb = new JCheckBox("Wrap search");
    wrap_cb.setSelected(true);

    panel.add(find_label, "0, 0, 1, 1, W, w, 3");
    panel.add(to_find, "0, 1, 1, 1, 0, w, 3");
    panel.add(wrap_cb, "0, 2, 1, 1, 0, w, 3");

    JPanel btn_panel = new JPanel(new KappaLayout());
    btn_panel.add(find_btn, "0, 0, 1, 1, 0, w, 3");
    btn_panel.add(find_next_btn, "0, 1, 1, 1, 0, w, 3");
    btn_panel.add(cancel_btn, "0, 2, 1, 1, 0, w, 3");
    panel.add(btn_panel, "1, 0, 1, 3, 0, h, 5");

    find_btn.addActionListener(new Finder(to_find, textarea, false, wrap_cb.isSelected()));
    find_next_btn.addActionListener(new Finder(to_find, textarea, true, wrap_cb.isSelected()));
    cancel_btn.addActionListener(
        new ActionListener() {
          public void actionPerformed(ActionEvent ae) {
            setVisible(false);
            dispose();
          }
        });
    pack();
    to_find.requestFocus();
  }