public void commandAction(Command c, Displayable d) {
    if (c == startCmd) {
      form.deleteAll();
      form.removeCommand(startCmd);
      form.addCommand(byeCmd);

      Thread t =
          new Thread() {

            public void run() {
              startSession();
            }
          };
      t.start();

      //	    startSession();
      return;
    } else if (c == exitCmd) {
      destroyApp(true);
      return;
    } else if (c == byeCmd) {
      form.removeCommand(byeCmd);
      form.addCommand(restartCmd);
      sendBYE();
      return;
    } else if (c == restartCmd) {
      stopListener();
      form.removeCommand(restartCmd);
      form.addCommand(startCmd);
      form.deleteAll();
      form.append(address);
      return;
    }
  }
Example #2
0
 public void startApp() {
   this.gameCanvas = new MobileBoard();
   this.t = new Thread(gameCanvas);
   t.start();
   d = Display.getDisplay(this);
   d.setCurrent(gameCanvas);
 }
Example #3
0
  /**
   * Called by a system to indicated that a command has been invoked on a particular displayable.
   *
   * @param command the Command that was invoked
   * @param displayable the Displayable where the command was invoked
   */
  public void commandAction(
      Command command, Displayable displayable) { // GEN-END:|7-commandAction|0|7-preCommandAction
    // write pre-action user code here
    if (displayable == LoginForm) { // GEN-BEGIN:|7-commandAction|1|65-preAction
      if (command == CreateAgentandJoin) { // GEN-END:|7-commandAction|1|65-preAction
        // write pre-action user code here
        String name = UserAgentNameTF.getString();
        String strAgentClassName = "au.edu.latrobe.placecomm.agents.MobileUserAgent";
        try {
          MicroRuntime.startAgent(name, strAgentClassName, null);
          // write post-action user code here
        } catch (Exception ex) {
          ex.printStackTrace();
        }
        // GEN-LINE:|7-commandAction|2|65-postAction
        // write post-action user code here
      } else if (command == CreateContainer) { // GEN-LINE:|7-commandAction|3|63-preAction
        // write pre-action user code here

        Thread t =
            new Thread() {
              public void run() {
                myStartGoOnline();
              }
            };
        t.start();

        // GEN-LINE:|7-commandAction|4|63-postAction
        // write post-action user code here
      } else if (command == OfflineMode) { // GEN-LINE:|7-commandAction|5|28-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|6|28-postAction
        // write post-action user code here
      } else if (command == exitCommand) { // GEN-LINE:|7-commandAction|7|17-preAction
        // write pre-action user code here
        exitMIDlet(); // GEN-LINE:|7-commandAction|8|17-postAction
        // write post-action user code here
      } else if (command == okCommand) { // GEN-LINE:|7-commandAction|9|20-preAction
        // write pre-action user code here
        // GEN-LINE:|7-commandAction|10|20-postAction
        // write post-action user code here
      } // GEN-BEGIN:|7-commandAction|11|7-postCommandAction
    } // GEN-END:|7-commandAction|11|7-postCommandAction
    // write post-action user code here
  } // GEN-BEGIN:|7-commandAction|12|
 /*
  * 1.) Shows Splash Screen in full screen
  * 2.) Sleeps for 3 seconds
  * 3.) Checks the edit previous report message
  * 4.) Displays the first screen in the PAGE Flow
  */
 private void showSplashScreen() {
   SplashScreen splash = new SplashScreen();
   splash.setFullScreenMode(true);
   getDisplay().setCurrent(splash);
   try {
     Thread.sleep(3000);
   } catch (InterruptedException ex) {
     ex.printStackTrace();
   }
   if (savedMsg) {
     // will return true if the user clicks "YES"
     if (!Dialog.show(
         "Question", "Do you want to edit your last submitted report?", "YES", "NO")) {
       editingLastReport = true;
     }
   }
   PAGES[pageFlowIndex].run(new Command[] {exitCommand, settingsCommand}, this);
 }
Example #5
0
  /**
   * Install a suite.
   *
   * @param selectedSuite index into the installList
   */
  private void installSuite(int selectedSuite) {
    MIDletStateHandler midletStateHandler = MIDletStateHandler.getMidletStateHandler();
    MIDletSuite midletSuite = midletStateHandler.getMIDletSuite();
    SuiteDownloadInfo suite;
    String displayName;

    suite = (SuiteDownloadInfo) installList.elementAt(selectedSuite);

    midletSuite.setTempProperty(null, "arg-0", "I");
    midletSuite.setTempProperty(null, "arg-1", suite.url);
    midletSuite.setTempProperty(null, "arg-2", suite.label);

    displayName = Resource.getString(ResourceConstants.INSTALL_APPLICATION);
    try {
      midletStateHandler.startMIDlet("com.sun.midp.installer.GraphicalInstaller", displayName);
      /*
       * Give the create MIDlet notification 1 second to get to
       * AMS.
       */
      Thread.sleep(1000);
      notifyDestroyed();
    } catch (Exception ex) {
      StringBuffer sb = new StringBuffer();

      sb.append(displayName);
      sb.append("\n");
      sb.append(Resource.getString(ResourceConstants.ERROR));
      sb.append(": ");
      sb.append(ex.toString());

      Alert a =
          new Alert(
              Resource.getString(ResourceConstants.AMS_CANNOT_START),
              sb.toString(),
              null,
              AlertType.ERROR);
      a.setTimeout(Alert.FOREVER);
      display.setCurrent(a, urlTextBox);
    }
  }
Example #6
0
 private void startReceive() {
   mEndNow = false;
   // start receive thread
   mReceiver = new Thread(this);
   mReceiver.start();
 }
  public void startApp() {
    if (svgCanvas == null) {
      // If there is a splash screen defined, show it immediately.
      boolean hasSplash = ((splashImageName != null) && !"".equals(splashImageName));

      if (hasSplash) {
        InputStream splashStream = getClass().getResourceAsStream(splashImageName);

        try {
          Image splashImage = Image.createImage(splashStream);
          splashCanvas = new SplashCanvas(splashImage);
        } catch (IOException ioe) {
          ioe.printStackTrace();
          hasSplash = false;
        }

        if (splashCanvas != null) {
          Display.getDisplay(this).setCurrent(splashCanvas);
        }
      }

      long start = System.currentTimeMillis();

      // Get input stream to the SVG image stored in the MIDlet's jar.
      InputStream svgDemoStream = getClass().getResourceAsStream(svgImageName);

      // Build an SVGImage instance from the stream
      svgImage = null;

      if (svgDemoStream != null) {
        try {
          svgImage = (SVGImage) SVGImage.createImage(svgDemoStream, null);
        } catch (IOException io) {
          io.printStackTrace();
        }
      }

      if (svgImage == null) {
        throw new Error(ERROR_COULD_NOT_LOAD_SVG + svgImageName);
      }

      // Build an SVGAnimator from the SVGImage. The SVGAnimator will handle
      // all the animation details and run the SVG animation in a
      // Canvas instance.
      svgAnimator = SVGAnimator.createAnimator(svgImage);

      // Set to 10 fps (frames per second)
      svgAnimator.setTimeIncrement(0.01f);

      // Get the Canvas managed by the SVGAnimator and set the
      // svgImage's size to the canvas display area.
      svgCanvas = (Canvas) svgAnimator.getTargetComponent();
      svgImage.setViewportWidth(svgCanvas.getWidth());
      svgImage.setViewportHeight(svgCanvas.getHeight());

      // Hook the exit command so that we can exit the animation demo.
      svgCanvas.addCommand(exitCommand);
      svgCanvas.setCommandListener(this);

      // The SVG root element is used to reset the time on a stop operation.
      doc = svgImage.getDocument();
      svg = (SVGSVGElement) doc.getDocumentElement();

      // Hook-in key listeners to play, pause and stop the animation.
      svgAnimator.setSVGEventListener(this);

      long end = System.currentTimeMillis();

      if (hasSplash) {
        long waitMore = SPLASH_MIN_LENGTH - (end - start);

        if (waitMore > 0) {
          try {
            Thread.currentThread().sleep(waitMore);
          } catch (InterruptedException ie) {
            // Do nothing.
          }
        }
      }

      if (autoStart) {
        svgAnimator.play();
        state = STATE_PLAYING;
        System.err.println("PLAYING...");
      }
    }

    Display.getDisplay(this).setCurrent(svgCanvas);
    resumeAnimation();
  }