Ejemplo n.º 1
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);
    }
  }
Ejemplo n.º 2
0
 @Override
 public void actionPerformed(ActionEvent e) {
   if (td.getTabCount() > 0) {
     TextDocument ta = (TextDocument) td.getComponentAt(td.getSelectedIndex());
     Pattern pn = Pattern.compile(tf1.getText());
     Matcher mt = pn.matcher(ta.getText());
     if (e.getSource() == jb2) { // 取代
       ta.setText(mt.replaceAll(tf2.getText()));
     } else if (e.getSource() == jb1) { // 尋找
       Highlighter hl = ta.getHighlighter();
       hl.removeAllHighlights();
       while (mt.find()) {
         try {
           hl.addHighlight(
               mt.start(), mt.end(), new DefaultHighlighter.DefaultHighlightPainter(null));
         } catch (Exception ex) {
         }
       } // 開啟及關閉介面
     } else if (e.getSource() == replace_searchMenuItem) {
       System.out.println("Replace/Search is show:" + !show);
       if (show) {
         getContentPane().remove(jp);
         show = false;
       } else {
         getContentPane().add(jp, BorderLayout.SOUTH);
         show = true;
       }
       validate(); // 刷新容器
     }
   } else if (e.getSource() == replace_searchMenuItem) {
     JOptionPane.showMessageDialog(
         null, "尚無檔案,無法使用!", "Repace/Search error", JOptionPane.ERROR_MESSAGE);
   }
 }
Ejemplo n.º 3
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();
   }
 }
Ejemplo n.º 4
0
  void handleScanFiles(JTextField field, String[] extensions) {
    String[] dataFiles = scanDataFolderForFilesByType(extensions);
    if (dataFiles == null || dataFiles.length == 0) return;

    String[] oldFileList = field.getText().trim().split(",");
    ArrayList<String> newFileList = new ArrayList<String>();
    for (String c : oldFileList) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) // TODO check exists() here?
      {
        newFileList.add(c);
      }
    }
    for (String c : dataFiles) {
      c = c.trim();
      if (!c.equals("") && newFileList.indexOf(c) == -1) {
        newFileList.add(c);
      }
    }
    Collections.sort(newFileList);
    String finalFileList = "";
    int i = 0;
    for (String s : newFileList) {
      finalFileList += (i > 0 ? ", " : "") + s;
      i++;
    }
    field.setText(finalFileList);
  }
Ejemplo n.º 5
0
  void openButton_actionPerformed(ActionEvent e) {
    String name = nameTextField.getText().trim();
    if (mode == ProfileChooser.MODE_OPEN) { // open
      if (name.equals("")) {
        JOptionPane.showMessageDialog(
            this, SanBootView.res.getString("ProfileChooser.errMsg.notSelect"));
        return;
      }

      UniProfile prof = isSameProfile(name);
      if (prof == null) {
        JOptionPane.showMessageDialog(
            this, SanBootView.res.getString("ProfileChooser.errMsg.notExist") + ": " + name);
        return;
      }

      values = new Object[1];
      values[0] = prof;
    } else { // save as 或 save
      if (name.equals("")) {
        JOptionPane.showMessageDialog(
            this, SanBootView.res.getString("ProfileChooser.errMsg.notName"));
        return;
      }

      String tmpName = name;
      Pattern pattern = Pattern.compile(".+\\.prf");
      Matcher matcher = pattern.matcher(tmpName);
      if (!matcher.find()) {
        tmpName += ".prf";
      }

      UniProfile pf = isSameProfile(tmpName);
      if (pf != null) { // 存 在 相 同 的 名 字 的profile ( pf )
        if (view.initor.mdb.getSchNumOnProfName(pf.getProfileName()) > 0) {
          JOptionPane.showMessageDialog(
              this, SanBootView.res.getString("EditProfileDialog.error.hasSch"));
          return;
        }

        if (JOptionPane.showConfirmDialog( // 提示信息更换
                (Dialog) bakable,
                SanBootView.res.getString("ProfileChooser.confirmmsg1"),
                SanBootView.res.getString("common.confirm"),
                JOptionPane.OK_CANCEL_OPTION)
            == JOptionPane.CANCEL_OPTION) {
          return;
        } else {
          values = new Object[2];
          values[0] = pf;
          values[1] = saveAsProfile;
        }
      } else { // 不 存 在 相 同 的 名 字
        String pname = ResourceCenter.PROFILE_DIR + name + ".prf";

        if (pname.indexOf("\"") >= 0
            || pname.indexOf("'") >= 0
            || pname.indexOf(' ') >= 0
            || pname.indexOf('\t') >= 0) {
          JOptionPane.showMessageDialog(
              this, SanBootView.res.getString("ProfileChooser.errmsg.badname"));
          return;
        }

        if (pname.getBytes().length >= 1000) {
          JOptionPane.showMessageDialog(
              this, SanBootView.res.getString("ProfileChooser.errmsg.tooLargePname"));
          return;
        }

        values = new Object[1];
        saveAsProfile.setProfileName(pname);
        values[0] = saveAsProfile;
      }
    }

    dispose();
  }