home *** CD-ROM | disk | FTP | other *** search
/ Cre@te Online 2000 December / Cre@teOnline CD05.iso / MacSoft / XML ConsoleMax.sea / XML ConsoleMax / Required / esc.jar / com / extensibility / app / EditWindow.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  4.6 KB  |  142 lines

  1. package com.extensibility.app;
  2.  
  3. import com.extensibility.rock.RAction;
  4. import java.awt.Window;
  5.  
  6. public abstract class EditWindow extends BaseWindow {
  7.    private String findText;
  8.    private String replaceText;
  9.  
  10.    public EditWindow(BaseDocument var1) {
  11.       super(var1);
  12.    }
  13.  
  14.    public boolean commitPendingEdits(boolean var1) {
  15.       return true;
  16.    }
  17.  
  18.    protected void fillEditMenu() {
  19.       this.createUndoAction().addToMenu(super.muEdit);
  20.       this.createRedoAction().addToMenu(super.muEdit);
  21.       super.muEdit.addSeparator();
  22.       this.createCutAction().addToMenu(super.muEdit);
  23.       this.createCopyAction().addToMenu(super.muEdit);
  24.       this.createPasteAction().addToMenu(super.muEdit);
  25.       this.createClearAction().addToMenu(super.muEdit);
  26.       super.muEdit.addSeparator();
  27.       this.createFindAction().addToMenu(super.muEdit);
  28.       this.createFindAgainAction().addToMenu(super.muEdit);
  29.       this.createReplaceAction().addToMenu(super.muEdit);
  30.       this.createReplaceAgainAction().addToMenu(super.muEdit);
  31.       super.muEdit.addSeparator();
  32.       super.fillEditMenu();
  33.       this.setEditEnable();
  34.    }
  35.  
  36.    public void touch() {
  37.       ((BaseWindow)this).getDocument().touch();
  38.    }
  39.  
  40.    protected BaseAction createSaveToURLAction() {
  41.       return new 1(this, "file.item.save.url");
  42.    }
  43.  
  44.    protected BaseAction createCloseAction() {
  45.       return new 2(this, "file.item.close", 'W');
  46.    }
  47.  
  48.    protected RAction createUndoAction() {
  49.       return ((BaseWindow)this).getDocument().getUndoManager().getUndoAction();
  50.    }
  51.  
  52.    protected RAction createRedoAction() {
  53.       return ((BaseWindow)this).getDocument().getUndoManager().getRedoAction();
  54.    }
  55.  
  56.    protected RAction createCutAction() {
  57.       return new 3((EditWindow)null, "edit.item.cut", 'X');
  58.    }
  59.  
  60.    protected RAction createCopyAction() {
  61.       return new 4((EditWindow)null, "edit.item.copy", 'C');
  62.    }
  63.  
  64.    protected RAction createPasteAction() {
  65.       return new 5((EditWindow)null, "edit.item.paste", 'V');
  66.    }
  67.  
  68.    protected RAction createClearAction() {
  69.       return new 6((EditWindow)null, "edit.item.clear", 'B');
  70.    }
  71.  
  72.    protected RAction createFindAction() {
  73.       return new 7(this, "edit.item.find", 'F');
  74.    }
  75.  
  76.    protected RAction createFindAgainAction() {
  77.       return new 8(this, "edit.item.find.again", 'G');
  78.    }
  79.  
  80.    protected RAction createReplaceAction() {
  81.       return new 9(this, "edit.item.replace", 'R');
  82.    }
  83.  
  84.    protected RAction createReplaceAgainAction() {
  85.       return new 10(this, "edit.item.replace.again", 'T');
  86.    }
  87.  
  88.    protected RAction createSaveAction() {
  89.       return new 11(this, "file.item.save", 'S');
  90.    }
  91.  
  92.    protected RAction createSaveAsAction() {
  93.       return new 12(this, "file.item.save.as");
  94.    }
  95.  
  96.    protected abstract void setEditEnable();
  97.  
  98.    protected abstract boolean canFind();
  99.  
  100.    protected abstract void doFind(String var1, boolean var2);
  101.  
  102.    public abstract String getSelectedText();
  103.  
  104.    public abstract boolean setSelectedText(String var1);
  105.  
  106.    public void find() {
  107.       String var1 = DialogFactory.askFind(this, this.findText);
  108.       if (var1 != null && this.canFind()) {
  109.          this.findText = var1;
  110.          this.findAgain();
  111.       }
  112.  
  113.    }
  114.  
  115.    public void findAgain() {
  116.       if (this.findText == null) {
  117.          this.find();
  118.       } else if (this.canFind()) {
  119.          this.doFind(this.findText, true);
  120.       }
  121.  
  122.    }
  123.  
  124.    public void replace() {
  125.       String[] var1 = DialogFactory.askReplace(this, this.findText, this.replaceText);
  126.       if (var1 != null && this.canFind()) {
  127.          this.findText = var1[0];
  128.          this.replaceText = var1[1];
  129.          this.findAgain();
  130.       }
  131.  
  132.    }
  133.  
  134.    public void replaceAgain() {
  135.       if (this.getSelectedText() != null && this.getSelectedText().equals(this.findText) && !this.setSelectedText(this.replaceText)) {
  136.          ((Window)this).getToolkit().beep();
  137.       }
  138.  
  139.       this.findAgain();
  140.    }
  141. }
  142.