public void find(boolean forward) {
    SearchContext context = new SearchContext();
    String text = findTextField.getText();
    if (text.length() == 0) {
      return;
    }
    context.setSearchFor(text);

    context.setMatchCase(this.matchCaseCheckBox.isSelected());
    context.setRegularExpression(this.regExCheckBox.isSelected());
    context.setSearchForward(forward);

    context.setWholeWord(this.wholeWordsOnlyCheckBox.isSelected());

    SearchResult found = SearchEngine.find(selectedArea, context);
    if (this.markAllComboBox.isSelected()) {
      selectedArea.setMarkOccurrences(true);
    } else {
      selectedArea.setMarkOccurrences(false);
    }
    if (!found.wasFound()) {
      JOptionPane.showMessageDialog(
          this, "Text not found", "DomainMath IDE", JOptionPane.INFORMATION_MESSAGE);
    }
  }
Esempio n. 2
0
 /** Construit un panneau d'édition. */
 public TextEditor() {
   setLayout(new BorderLayout());
   // Creation de la barre de commande
   {
     toolBar = new ToolBar();
     add(toolBar, BorderLayout.NORTH);
   }
   // Creation de la zone d'édition
   {
     textArea = new RSyntaxTextArea(25, 70);
     textArea.setCaretPosition(0);
     textArea.requestFocusInWindow();
     textArea.setMarkOccurrences(true);
     textArea.setText("");
     scrollPane = new RTextScrollPane(textArea, true);
     Gutter gutter = scrollPane.getGutter();
     gutter.setBorderColor(Color.BLUE);
     add(scrollPane, BorderLayout.CENTER);
   }
   // Définition du mécanisme de complétion
   {
     completionsProvider = new DefaultCompletionProvider();
     LanguageAwareCompletionProvider lacp =
         new LanguageAwareCompletionProvider(completionsProvider);
     AutoCompletion ac =
         new AutoCompletion(lacp) {
           @Override
           public void doCompletion() {
             if (isAutoCompleteEnabled()) {
               super.doCompletion();
             }
           }
         };
     ac.install(textArea);
     ac.setAutoCompleteSingleChoices(false);
     ac.setAutoActivationEnabled(true);
     ac.setAutoActivationDelay(1500);
     ac.setShowDescWindow(true);
   }
   // Ajout de l'aide à l'édition
   {
     JPopupMenu j = toolBar.addRightTool("Aide");
     j.add(new JLabel("<html>\n<b>Commandes d'édition</b><br><table>\n" + helpText + "</table>"));
   }
 }