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 / xa / SourcePane.class (.txt) < prev    next >
Encoding:
Java Class File  |  2000-06-30  |  3.8 KB  |  109 lines

  1. package com.extensibility.xa;
  2.  
  3. import com.extensibility.app.BaseAction;
  4. import com.extensibility.app.BaseUndoable;
  5. import com.extensibility.app.DialogFactory;
  6. import com.extensibility.rock.Platform;
  7. import com.extensibility.util.Debug;
  8. import java.io.IOException;
  9. import java.io.StringWriter;
  10.  
  11. public class SourcePane extends BaseSourcePane {
  12.    RefreshUndoAdapter undoAdapter;
  13.  
  14.    public SourcePane(SchemaDoc var1) {
  15.       super(var1);
  16.       this.undoAdapter = new RefreshUndoAdapter((SourcePane)null, var1);
  17.       super.sourceText.getDocument().addUndoableEditListener(this.undoAdapter);
  18.    }
  19.  
  20.    protected void refresh() {
  21.       if (!super.inRefresh) {
  22.          super.inRefresh = true;
  23.          StringWriter var1 = Platform.getTextAreaStringWriter();
  24.  
  25.          try {
  26.             int var2 = ((BaseSourcePane)this).getSourceText().getSelectionStart();
  27.             ((CompositePane)this).getSchemaDoc().write(var1, super.uri);
  28.             this.undoAdapter.beginRefresh();
  29.             ((BaseSourcePane)this).getSourceText().setText(var1.toString());
  30.             var2 = Math.min(var2, ((BaseSourcePane)this).getSourceText().getText().length());
  31.             ((BaseSourcePane)this).getSourceText().select(var2, var2);
  32.             ((BaseSourcePane)this).checkJDKBug();
  33.             ((BaseSourcePane)this).setDirty(false);
  34.             this.undoAdapter.endRefresh();
  35.          } catch (IOException var14) {
  36.             DialogFactory.showException(((CompositePane)this).getSchemaWin(), 1006, var14);
  37.          } catch (Exception var15) {
  38.             Debug.assert(var15);
  39.          } finally {
  40.             super.inRefresh = false;
  41.  
  42.             try {
  43.                var1.close();
  44.             } catch (Exception var13) {
  45.             }
  46.  
  47.             ((BaseSourcePane)this).setInSync(true);
  48.          }
  49.  
  50.       }
  51.    }
  52.  
  53.    public void discard() {
  54.       this.undoAdapter.discard();
  55.       super.discard();
  56.    }
  57.  
  58.    protected String getHeaderPrefix() {
  59.       return new String("Generated Source: ");
  60.    }
  61.  
  62.    public BaseAction createParseAction() {
  63.       if (super.parseAction == null) {
  64.          super.parseAction = new 1(this, "item.parse", 120, 0);
  65.       }
  66.  
  67.       return super.parseAction;
  68.    }
  69.  
  70.    protected BaseAction createRefreshAction() {
  71.       if (super.refreshAction == null) {
  72.          super.refreshAction = new 2(this, "item.refresh", 116, 0);
  73.       }
  74.  
  75.       return super.refreshAction;
  76.    }
  77.  
  78.    public boolean addRequest() {
  79.       if (!((BaseSourcePane)this).isInSync()) {
  80.          this.refresh();
  81.       }
  82.  
  83.       return true;
  84.    }
  85.  
  86.    public void cut() {
  87.       ((CompositePane)this).getSchemaDoc().touch(super.uri);
  88.       super.cut();
  89.    }
  90.  
  91.    public void paste() {
  92.       ((CompositePane)this).getSchemaDoc().touch(super.uri);
  93.       super.paste();
  94.    }
  95.  
  96.    public void clear() {
  97.       ((CompositePane)this).getSchemaDoc().touch(super.uri);
  98.       super.clear();
  99.    }
  100.  
  101.    protected BaseUndoable createSourceReparseUndoable() {
  102.       return new SourceReparseUndoable(this, ((CompositePane)this).getSchemaWin());
  103.    }
  104.  
  105.    protected BaseUndoable createSourceRefreshUndoable() {
  106.       return new SourceRefreshUndoable(this, ((CompositePane)this).getSchemaWin());
  107.    }
  108. }
  109.