public static void main(String vmargs[]) {
    // start with parameters:
    // args[0]: spider
    // args[1]: distance
    ewe.sys.Vm.startEwe(vmargs);
    /*		Gui.screenIs(Gui.PDA_SCREEN);
    		Rect s = (Rect)Window.getGuiInfo(Window.INFO_SCREEN_RECT,null,new Rect(),0);
    		//Gui.screenIs(Gui.PDA_SCREEN)
    		if (Vm.isMobile() && s.height >= 400) {
    			Font defaultGuiFont = mApp.findFont("gui");
    			int sz = (int)(defaultGuiFont.getSize());
    			Font newGuiFont = new Font(defaultGuiFont.getName(), defaultGuiFont.getStyle(), sz);
    			mApp.addFont(newGuiFont, "gui");
    			mApp.fontsChanged();
    			mApp.mainApp.font = newGuiFont;
    		}
    */
    if (Gui.screenIs(Gui.PDA_SCREEN) && Vm.isMobile()) {
      Vm.setSIP(Vm.SIP_LEAVE_BUTTON);
    }

    // get program command line parameters and switches
    String[] args =
        vmargs; // Vm.getProgramArguments(); <-- only works in eclipse, but mixes the letters in the
                // ewe-vm (tested in ewe-1.49 on win xp)
    String configfile = null;
    boolean debug = false;
    if (args.length > 0) {
      if (args[0].equals("test")) {
        Test t = new Test();
        t.testAll();
      }
      for (int i = 0; i < args.length; i++) {
        Vm.debug("prog: " + args[i]);
        Vm.debug("vm: " + vmargs[i]);
        if (args[i] != null
            && args[i].length() > 1
            && (args[i].startsWith("-") || args[i].startsWith("/"))) {
          String c = args[i].substring(1, args[i].length());
          if (c.equalsIgnoreCase("c")) {
            if (i < args.length - 1) {
              configfile = args[i + 1];
              i++;
            } else {
              (new MessageBox(
                      "Error",
                      MyLocale.getMsg(7200, "Usage: CacheWolf [-c <path to pref.xml>] [-debug]"),
                      MessageBox.OKB))
                  .execute();
              // return usage info
              ewe.sys.Vm.exit(1);
            }
          }
          if (c.equalsIgnoreCase("debug")) {
            // Vm.debug("d");
            debug = true;
          }
        }
      }
    }

    if (debug) {
      Vm.debug("prg-args: " + args.length);
      Vm.debug("vm-args: " + vmargs.length);
    }

    Editor mainF = new MainForm(debug, configfile);
    Device.preventIdleState(true);
    mainF.execute();
    Device.preventIdleState(false);
    ewe.sys.Vm.exit(0);
  }
Beispiel #2
0
  public void doIt() {
    // CellPanel [] p = addToolbar();
    Global.mainForm = this;
    // this.title = "CacheWolf " + Version.getRelease();
    this.exitSystemOnClose = true;
    this.resizable = true;
    this.moveable = true;
    this.windowFlagsToSet = WindowConstants.FLAG_MAXIMIZE_ON_PDA;
    // Rect screen = ((ewe.fx.Rect)
    // (Window.getGuiInfo(WindowConstants.INFO_SCREEN_RECT,null,new
    // ewe.fx.Rect(),0)));
    // if ( screen.height >= 600 && screen.width >= 800)
    // this.setPreferredSize(800, 600);
    this.resizeOnSIP = true;
    InfoBox infB = null;
    try {
      pref.readPrefFile();
      if (MyLocale.initErrors.length() != 0) {
        new MessageBox("Error", MyLocale.initErrors, FormBase.OKB).execute();
      }
      if (Vm.isMobile() == true) {
        // this.windowFlagsToSet |=Window.FLAG_FULL_SCREEN;
        this.resizable = false;
        this.moveable = false;
      } else {
        int h, w;
        h = pref.myAppHeight;
        if (h > MyLocale.getScreenHeight()) h = MyLocale.getScreenHeight();
        w = pref.myAppWidth;
        if (w > MyLocale.getScreenWidth()) w = MyLocale.getScreenWidth();
        this.setPreferredSize(w, h);
      }
      addGuiFont();
      if (!pref.selectProfile(profile, Preferences.PROFILE_SELECTOR_ONOROFF, true))
        ewe.sys.Vm.exit(0); // User MUST select or create a profile
      Vm.showWait(true);

      // Replace buildt-in symbols with customized images
      GuiImageBroker.customizedSymbols();

      // Load CacheList
      infB = new InfoBox("CacheHound", MyLocale.getMsg(5000, "Loading Cache-List"));
      infB.exec();
      infB.waitUntilPainted(100);
      profile.readIndex(infB);
      pref.setCurCenter(new CWPoint(profile.getCenter()));
      profile.updateBearingDistance();
      setTitle("CacheHound " + Version.getRelease() + " - " + profile.name);
    } catch (Exception e) {
      if (pref.debug == true) Vm.debug("MainForm:: Exception:: " + e.toString());
    }

    if (pref.showStatus) statBar = new StatusBar(pref, profile.cacheDB);
    mMenu = new MainMenu(this);
    mTab = new MainTab(mMenu, statBar);
    split = new SplittablePanel(PanelSplitter.HORIZONTAL);
    split.theSplitter.thickness = 0;
    split.theSplitter.modify(Invisible, 0);
    CellPanel pnlCacheList = split.getNextPanel();
    CellPanel pnlMainTab = split.getNextPanel();
    split.setSplitter(
        PanelSplitter.MIN_SIZE | PanelSplitter.BEFORE,
        PanelSplitter.HIDDEN | PanelSplitter.BEFORE,
        PanelSplitter.CLOSED);
    pnlCacheList.addLast(cacheList = new CacheList(), STRETCH, FILL);
    pnlMainTab.addLast(mTab, STRETCH, FILL);

    mTab.dontAutoScroll = true;

    this.addLast(split, STRETCH, FILL);
    /*
     * if (pref.menuAtTop) { this.addLast(mMenu,CellConstants.DONTSTRETCH,
     * CellConstants.FILL); this.addLast(split,STRETCH,FILL); } else {
     * this.addLast(split,STRETCH,FILL);
     * this.addLast(mMenu,CellConstants.DONTSTRETCH, CellConstants.FILL); }
     */
    mMenu.setTablePanel(mTab.getTablePanel());
    if (infB != null) infB.close(0);
    mTab.tbP.refreshTable();
    mTab.tbP.selectFirstRow();
    // mTab.tbP.tc.paintSelection();
    Vm.showWait(false);
  }