Пример #1
0
  public static void main(String args[]) {

    // make sure that this is running on java 1.5 or better.
    if (Base.javaVersion < 1.5f) {
      Base.quitWithError(
          "Need to install Java 1.5",
          "This version of ReplicatorG requires\n"
              + "Java 1.5 or later to run properly.\n"
              + "Please visit java.com to upgrade.",
          null);
    }

    if (Base.isMacOS()) {
      // Default to sun's XML parser, PLEASE.  Some apps are installing some janky-ass xerces.
      System.setProperty(
          "javax.xml.parsers.DocumentBuilderFactory",
          "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl");
      System.setProperty("com.apple.mrj.application.apple.menu.about.name", "ReplicatorG");
    }

    // parse command line input
    for (int i = 0; i < args.length; i++) {
      // grab any opened file from the command line
      if (supportedExtension(args[i])) {
        Base.openedAtStartup = args[i];
      }

      // Allow for [--debug] [DEBUGLEVEL]
      if (args[i].equals("--debug")) {
        int debugLevelArg = 2;
        if ((i + 1) < args.length) {
          try {
            debugLevelArg = Integer.parseInt(args[i + 1]);
          } catch (NumberFormatException e) {
          }
          ;
        }
        if (debugLevelArg == 0) {
          logger.setLevel(Level.INFO);
          logger.info("Debug level is 'INFO'");
        } else if (debugLevelArg == 1) {
          logger.setLevel(Level.FINE);
          logger.info("Debug level is 'FINE'");
        } else if (debugLevelArg == 2) {
          logger.setLevel(Level.FINER);
          logger.info("Debug level is 'FINER'");
        } else if (debugLevelArg == 3) {
          logger.setLevel(Level.FINEST);
          logger.info("Debug level is 'FINEST'");
        } else if (debugLevelArg >= 4) {
          logger.setLevel(Level.ALL);
          logger.info("Debug level is 'ALL'");
        }
      } else if (args[i].startsWith("-")) {
        System.out.println("Usage: ./replicatorg [[--debug] [DEBUGLEVEL]] [filename.stl]");
        System.exit(1);
      }
    }

    // Warn about read-only directories
    {
      File userDir = getUserDirectory();
      String header = null;
      if (!userDir.exists()) header = new String("Unable to create user directory");
      else if (!userDir.canWrite()) header = new String("Unable to write to user directory");
      else if (!userDir.isDirectory()) header = new String("User directory must be a directory");
      if (header != null) {
        Base.showMessage(
            header,
            "<html><body>ReplicatorG can not write to the directory "
                + userDir.getAbsolutePath()
                + ".<br>"
                + "Some functions of ReplicatorG, like toolpath generation and firmware updates,<br>"
                + "require ReplicatorG to write data to this directory.  You should end this<br>"
                + "session, change the permissions on this directory, and start again.");
      }
    }

    // Use the default system proxy settings
    System.setProperty("java.net.useSystemProxies", "true");
    // Use antialiasing implicitly
    System.setProperty("j3d.implicitAntialiasing", "true");

    // Start the firmware check thread.
    FirmwareUploader.checkFirmware();

    // MAC OS X ONLY:
    // register a temporary/early version of the mrj open document handler,
    // because the event may be lost (sometimes, not always) by the time
    // that MainWindow is properly constructed.
    MRJOpenDocumentHandler startupOpen =
        new MRJOpenDocumentHandler() {
          public void handleOpenFile(File file) {
            // this will only get set once.. later will be handled
            // by the MainWindow version of this fella
            if (Base.openedAtStartup == null) {
              Base.openedAtStartup = file.getAbsolutePath();
            }
          }
        };
    MRJApplicationUtils.registerOpenDocumentHandler(startupOpen);

    // Create the new application "Base" class.
    new Base();
  }
Пример #2
0
 protected void setupFrame() {
   super.setupFrame();
   MRJApplicationUtils.registerAboutHandler(this);
   MRJApplicationUtils.registerQuitHandler(this);
 }