Esempio n. 1
0
    public void actionPerformed(ActionEvent event) {

      JMenuItem mi;
      String label = "";

      if (warningPopup == null) {
        warningPopup = new WarningDialog(textViewerFrame);
      }
      if ((editor1 == null) || (editor1.getDocument() == null)) {
        String errstr = "TextViewer:editor1 or document is null";
        warningPopup.display(errstr);
        return;
      }
      String actionStr = event.getActionCommand(); // is not makeing anysense
      // when keystrokes typed
      if ((event.getSource() instanceof JMenuItem)) {
        mi = (JMenuItem) event.getSource();
        label = mi.getText();
      } else if ((event.getSource() instanceof JTextArea)) { // keystroke
        label = "FindAgain"; // just set it to findagain
      } else {
        System.err.println("Debug:TextViewer:" + actionStr);
        System.err.println("Debug:TextViewer:" + event.getSource().toString());
        String errstr =
            "TextViewer:FindAction: "
                + event.getSource().toString()
                + " not an instance of JMenuItem or JTextArea";
        warningPopup.display(errstr);
        return;
      }

      if (label.equals("FindAgain")) {
        isFindAgain = true;
        lastFindStr = lastFindStr;
      } else {
        isFindAgain = false;
        lastFindStr = "";
      }
      StringBoolean content = new StringBoolean(lastFindStr, forwardFindDirection);

      boolean okPressed = mySearchDialog.display(content);
      if (!okPressed) {
        return;
      }
      lastFindStr = content.mystring;
      forwardFindDirection = content.myboolean;

      if (forwardFindDirection) {
        lastFindIndex = searchForward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);

      } else {
        lastFindIndex = searchBackward(lastFindStr);
        //		System.out.println("Debug:TextViewer: lastFindIndex:"+lastFindIndex);
      }
    }
  /**
   * Handles toolbar action event for this toolbar.
   *
   * @param evt the genereated action event to be handled.
   */
  public void actionPerformed(ActionEvent evt) {

    oParent.setWaitCursor();

    Object source = evt.getSource();

    if (source.equals(pbOpen)) {
      oParent.onFileOpen();
    } else if (source.equals(pbClose)) {
      oParent.onFileClose();
    } else if (source.equals(pbDelete)) {
      oParent.onEditDelete();
    } else if (source.equals(pbCut)) {
      oParent.onEditCut();
    } else if (source.equals(pbCopy)) {
      oParent.onEditCopy();
    } else if (source.equals(pbPaste)) {
      oParent.onEditPaste();
    } else if (source.equals(pbUndo)) {
      oParent.onEditUndo();
    } else if (source.equals(pbRedo)) {
      oParent.onEditRedo();
    } else if (source.equals(pbBack)) {
      onBack();
    } else if (source.equals(pbShowBackHistory)) {
      onShowBackHistory();
    } else if (source.equals(pbShowForwardHistory)) {
      onShowForwardHistory();
    } else if (source.equals(pbForward)) {
      onForward();
    } else if (source.equals(pbSearch)) {
      oParent.onSearch();
    } else if (source.equals(pbImageRollover)) {
      oParent.onImageRollover(!FormatProperties.imageRollover);
    }

    oParent.setDefaultCursor();
  }