コード例 #1
0
ファイル: Runner.java プロジェクト: hsiaotaiyeh/processing
  protected Connector findConnector(String connectorName) {
    //    List connectors =
    //      com.sun.jdi.Bootstrap.virtualMachineManager().allConnectors();
    List connectors = org.eclipse.jdi.Bootstrap.virtualMachineManager().allConnectors();

    //    // debug: code to list available connectors
    //    Iterator iter2 = connectors.iterator();
    //    while (iter2.hasNext()) {
    //      Connector connector = (Connector)iter2.next();
    //      System.out.println("connector name is " + connector.name());
    //    }

    for (Object c : connectors) {
      Connector connector = (Connector) c;
      //      System.out.println(connector.name());
      //    }
      //    Iterator iter = connectors.iterator();
      //    while (iter.hasNext()) {
      //      Connector connector = (Connector)iter.next();
      if (connector.name().equals(connectorName)) {
        return connector;
      }
    }
    Base.showError(
        "Compiler Error",
        "findConnector() failed to find " + connectorName + " inside Runner",
        null);
    return null; // Not reachable
  }
コード例 #2
0
ファイル: Preferences.java プロジェクト: amaxilat/Arduino
  static protected void init(String commandLinePrefs) {

    // start by loading the defaults, in case something
    // important was deleted from the user prefs
    try {
      load(Base.getLibStream("preferences.txt"));
    } catch (Exception e) {
      Base.showError(null, _("Could not read default settings.\n" +
                             "You'll need to reinstall Arduino."), e);
    }

    // check for platform-specific properties in the defaults
    String platformExt = "." + PConstants.platformNames[PApplet.platform];
    int platformExtLength = platformExt.length();
    Enumeration e = table.keys();
    while (e.hasMoreElements()) {
      String key = (String) e.nextElement();
      if (key.endsWith(platformExt)) {
        // this is a key specific to a particular platform
        String actualKey = key.substring(0, key.length() - platformExtLength);
        String value = get(key);
        table.put(actualKey, value);
      }
    }

    // clone the hash table
    defaults = (Hashtable) table.clone();

    // other things that have to be set explicitly for the defaults
    setColor("run.window.bgcolor", SystemColor.control);

    // Load a prefs file if specified on the command line
    if (commandLinePrefs != null) {
      try {
        load(new FileInputStream(commandLinePrefs));

      } catch (Exception poe) {
        Base.showError(_("Error"),
                       I18n.format(
			 _("Could not read preferences from {0}"),
			 commandLinePrefs
		       ), poe);
      }
    } else if (!Base.isCommandLine()) {
      // next load user preferences file
      preferencesFile = Base.getSettingsFile(PREFS_FILE);
      if (!preferencesFile.exists()) {
        // create a new preferences file if none exists
        // saves the defaults out to the file
        save();

      } else {
        // load the previous preferences file

        try {
          load(new FileInputStream(preferencesFile));

        } catch (Exception ex) {
          Base.showError(_("Error reading preferences"),
			 I18n.format(
			   _("Error reading the preferences file. " +
			     "Please delete (or move)\n" +
			     "{0} and restart Arduino."),
			   preferencesFile.getAbsolutePath()
			 ), ex);
        }
      }
    }
  }