home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2003 March / DPPCPRO0303.ISO / Components / Microsoft ASP / _SETUP.1 / ASPWizard.jar / asp / wizard / GenProgressDisplay.class (.txt) < prev    next >
Encoding:
Java Class File  |  1998-11-20  |  3.6 KB  |  100 lines

  1. package asp.wizard;
  2.  
  3. import asp.util.ResourceUtil;
  4. import asp.wizard.def.DefAbstract;
  5. import asp.wizard.def.DefCollection;
  6. import asp.wizard.def.DefPage;
  7. import asp.wizard.def.LayoutGeneratorEvent;
  8. import asp.wizard.def.LayoutGeneratorListener;
  9. import java.awt.Component;
  10. import java.awt.Dialog;
  11.  
  12. class GenProgressDisplay implements LayoutGeneratorListener {
  13.    private int _pageCount;
  14.    private int _currPageIndex;
  15.    private int _pageIncrement;
  16.    private int _objectCount;
  17.    private int _currObjectIndex;
  18.    private int _objectIncrement;
  19.    // $FF: synthetic field
  20.    static Class class$asp$wizard$WizardManager;
  21.  
  22.    public void genStarted(LayoutGeneratorEvent e) {
  23.       ProgressStatus ps = ProgressStatus.getInstance();
  24.       DefPage firstDefPage = (DefPage)e.getCurrDefAbstract();
  25.       this._pageCount = firstDefPage.getDescendantCount() + 1;
  26.       this._pageIncrement = 100 / this._pageCount;
  27.       this._currPageIndex = 0;
  28.       ps.reset();
  29.       ((Dialog)ps).setTitle(ResourceUtil.getResourceString("asp.wizard.res", class$asp$wizard$WizardManager != null ? class$asp$wizard$WizardManager : (class$asp$wizard$WizardManager = class$("asp.wizard.WizardManager")), "window.title.generate"));
  30.       ((Component)ps).setVisible(true);
  31.    }
  32.  
  33.    public void genEnded(LayoutGeneratorEvent evt) {
  34.       ProgressStatus ps = ProgressStatus.getInstance();
  35.       ps.setValue(100);
  36.       Thread.yield();
  37.       ((Component)ps).setVisible(false);
  38.    }
  39.  
  40.    public void genObjectStarted(LayoutGeneratorEvent e) {
  41.       if (e.getCurrDefAbstract() instanceof DefPage) {
  42.          DefPage currPage = (DefPage)e.getCurrDefAbstract();
  43.          StringBuffer sb = new StringBuffer();
  44.          sb.append(((DefAbstract)currPage).getName());
  45.          sb.append(" (");
  46.          sb.append(this._currPageIndex + 1);
  47.          sb.append("/");
  48.          sb.append(this._pageCount);
  49.          sb.append(")");
  50.          ProgressStatus.getInstance().setText(((DefAbstract)currPage).getName());
  51.          this._objectCount = ((DefCollection)currPage).getElementCount();
  52.          this._currObjectIndex = 0;
  53.       } else if (!(e.getCurrDefAbstract() instanceof DefCollection)) {
  54.          DefAbstract singleObj = e.getCurrDefAbstract();
  55.          DefCollection currPage = singleObj.getParent();
  56.          StringBuffer sb = new StringBuffer();
  57.          if (currPage != null) {
  58.             sb.append(((DefAbstract)currPage).getName());
  59.             sb.append(" (");
  60.             sb.append(this._currPageIndex + 1);
  61.             sb.append("/");
  62.             sb.append(this._pageCount);
  63.             sb.append(")");
  64.             sb.append(" - ");
  65.          }
  66.  
  67.          sb.append(singleObj.getName());
  68.          sb.append(" (");
  69.          sb.append(this._currObjectIndex + 1);
  70.          sb.append("/");
  71.          sb.append(this._objectCount);
  72.          sb.append(")");
  73.          ProgressStatus.getInstance().setText(sb.toString());
  74.       }
  75.  
  76.    }
  77.  
  78.    public void genObjectEnded(LayoutGeneratorEvent e) {
  79.       if (e.getCurrDefAbstract() instanceof DefPage) {
  80.          if (this._pageCount > 0) {
  81.             ProgressStatus.getInstance().setValue(++this._currPageIndex * 100 / this._pageCount);
  82.          }
  83.       } else if (!(e.getCurrDefAbstract() instanceof DefCollection) && this._objectCount > 0 && this._pageCount > 0) {
  84.          ++this._currObjectIndex;
  85.          int value = (this._currPageIndex * this._objectCount * this._pageCount + this._currObjectIndex * this._pageCount) * 100 / (this._pageCount * this._pageCount * this._objectCount);
  86.          ProgressStatus.getInstance().setValue(value);
  87.       }
  88.  
  89.    }
  90.  
  91.    // $FF: synthetic method
  92.    static Class class$(String class$) {
  93.       try {
  94.          return Class.forName(class$);
  95.       } catch (ClassNotFoundException forName) {
  96.          throw new NoClassDefFoundError(((Throwable)forName).getMessage());
  97.       }
  98.    }
  99. }
  100.