Exemplo n.º 1
0
  public void reload() throws Exception {
    if (saved) {
      long a = file.lastModified();
      if (a > file_lastModified) {
        sem.fireEvent("stop", null, null);

        text.setText(U.slurp(file));
        saved = true;

        sem.pushEvent("updateTitle", this, null);
        file_lastModified = a;
      }
    }
  }
Exemplo n.º 2
0
  public CodePane(SimpleEventManager _sem) throws Exception {
    this.sem = _sem;
    sem.addListener(this);

    Font font = new Font(Font.MONOSPACED, Font.PLAIN, 12);
    text = new JEditorPane();
    text.getDocument()
        .addDocumentListener(
            new DocumentListener() {
              public void changedUpdate(DocumentEvent arg0) {
                onChange();
              }

              public void insertUpdate(DocumentEvent arg0) {
                onChange();
              }

              public void removeUpdate(DocumentEvent arg0) {
                onChange();
              }
            });
    text.addKeyListener(
        new KeyListener() {

          public void keyPressed(KeyEvent ke) {
            // TODO Auto-generated method stub
            if (ke.isControlDown() && (ke.getKeyCode() == KeyEvent.VK_S)) {
              sem.fireEvent("save", null, null);
            }
          }

          public void keyReleased(KeyEvent arg0) {}

          public void keyTyped(KeyEvent arg0) {}
        });
    text.setFont(font);

    setLayout(new BorderLayout());
    add(new JScrollPane(text));
  }
Exemplo n.º 3
0
 public void save() throws Exception {
   U.saveString(file, text.getText());
   file_lastModified = file.lastModified();
   saved = true;
   sem.pushEvent("updateTitle", this, null);
 }
Exemplo n.º 4
0
 public void onChange() {
   saved = false;
   sem.fireEvent("stop", null, null);
   sem.pushEvent("updateTitle", this, null);
 }