示例#1
0
  /**
   * Grab the user's attention in a platform dependent way
   *
   * @param type one of <code>PlatformManager.USER_REQUEST_INFO</code>, <code>
   *     PlatformManager.USER_REQUEST_WARNING</code>, OR <code>PlatformManager.USER_REQUEST_QUESTION
   *     </code>
   * @param data user-defined data object; see the platform-specific <code>PlatformManager</code>
   *     for what may be supported
   */
  public static void requestUserAttention(int type, Object data) {

    PlatformManager pm = PlatformManagerFactory.getPlatformManager();
    if (true == pm.hasCapability(PlatformManagerCapabilities.RequestUserAttention)) {
      try {
        pm.requestUserAttention(type, data);
      } catch (PlatformManagerException e) {
        Debug.printStackTrace(e);
      }
    }
  }
  private void enableTOSRegistrySetting(boolean enable) {
    PlatformManager mgr = PlatformManagerFactory.getPlatformManager();

    if (mgr.hasCapability(PlatformManagerCapabilities.SetTCPTOSEnabled)) {
      // see http://wiki.vuze.com/w/AdvancedNetworkSettings
      try {
        mgr.setTCPTOSEnabled(enable);
      } catch (PlatformManagerException pe) {
        Debug.printStackTrace(pe);
      }
    }
  }
示例#3
0
  public static void checkAssociations() {
    try {

      PlatformManager platform = PlatformManagerFactory.getPlatformManager();

      if (platform.hasCapability(PlatformManagerCapabilities.RegisterFileAssociations)) {

        if (COConfigurationManager.getBooleanParameter("config.interface.checkassoc")) {

          if (!platform.isApplicationRegistered()) {

            new AssociationChecker(platform);
          }
        }
      }
    } catch (Throwable e) {

      // Debug.printStackTrace( e );
    }
  }
示例#4
0
  protected void close(boolean ok, boolean check_on_startup) {
    if (check_on_startup
        != COConfigurationManager.getBooleanParameter("config.interface.checkassoc")) {

      COConfigurationManager.setParameter("config.interface.checkassoc", check_on_startup);

      COConfigurationManager.save();
    }

    if (ok) {

      try {
        platform.registerApplication();

      } catch (PlatformManagerException e) {

        Debug.printStackTrace(e);
      }
    }

    shell.dispose();
  }
示例#5
0
  public static void login(long contentNetworkID, long maxDelayMS) {
    PlatformManager pm = PlatformManagerFactory.getPlatformManager();
    String azComputerID = "";
    try {
      azComputerID = pm.getAzComputerID();
    } catch (PlatformManagerException e) {
    }

    String sourceRef = null;
    if (contentNetworkID != ConstantsVuze.DEFAULT_CONTENT_NETWORK_ID) {
      ContentNetwork cn =
          ContentNetworkManagerFactory.getSingleton().getContentNetwork(contentNetworkID);
      sourceRef = (String) cn.getPersistentProperty(ContentNetwork.PP_SOURCE_REF);
    }
    if (sourceRef == null) {
      sourceRef = "unknown";
    }

    Object[] params =
        new Object[] {
          "version",
          org.gudy.azureus2.core3.util.Constants.AZUREUS_VERSION,
          "locale",
          Locale.getDefault().toString(),
          "azCID",
          azComputerID,
          "vid",
          COConfigurationManager.getStringParameter("ID"),
          "source-ref",
          sourceRef
        };
    PlatformMessage message =
        new PlatformMessage("AZMSG", LISTENER_ID, "login", params, maxDelayMS);
    message.setContentNetworkID(contentNetworkID);

    PlatformMessengerListener listener =
        new PlatformMessengerListener() {

          public void replyReceived(PlatformMessage message, String replyType, Map reply) {
            if (reply == null) {
              return;
            }

            boolean allowMulti =
                MapUtils.getMapBoolean(reply, "allow-multi-rpc", PlatformMessenger.getAllowMulti());
            PlatformMessenger.setAllowMulti(allowMulti);

            try {
              List listURLs =
                  (List) MapUtils.getMapObject(reply, "url-whitelist", null, List.class);
              if (listURLs != null) {
                for (int i = 0; i < listURLs.size(); i++) {
                  String string = (String) listURLs.get(i);
                  UrlFilter.getInstance().addUrlWhitelist(string);
                }
              }
            } catch (Exception e) {
              Debug.out(e);
            }

            try {
              List listURLs =
                  (List) MapUtils.getMapObject(reply, "url-blacklist", null, List.class);
              if (listURLs != null) {
                for (int i = 0; i < listURLs.size(); i++) {
                  String string = (String) listURLs.get(i);
                  UrlFilter.getInstance().addUrlBlacklist(string);
                }
              }
            } catch (Exception e) {
              Debug.out(e);
            }

            try {
              List listDomains =
                  (List) MapUtils.getMapObject(reply, "tracker-domains", null, List.class);
              if (listDomains != null) {
                for (int i = 0; i < listDomains.size(); i++) {
                  String s = (String) listDomains.get(i);
                  PlatformTorrentUtils.addPlatformHost(s);
                  PlatformMessenger.debug("v3.login: got tracker domain of " + s);
                }
              }
            } catch (Exception e) {
              Debug.out(e);
            }

            if (message.getContentNetworkID() != ConstantsVuze.getDefaultContentNetwork().getID()) {
              return;
            }

            try {
              sendStats = MapUtils.getMapBoolean(reply, "send-stats", false);
              doUrlQOS = MapUtils.getMapBoolean(reply, "do-url-qos", false);
              allowSendDeviceList = MapUtils.getMapBoolean(reply, "send-device-list", false);
            } catch (Exception e) {
            }

            try {
              iRPCVersion = MapUtils.getMapInt(reply, "rpc-version", 0);
              playAfterURL = (String) MapUtils.getMapString(reply, "play-after-url", null);
            } catch (Exception e) {
              Debug.out(e);
            }

            platformLoginComplete = true;
            Object[] listeners = platformLoginCompleteListeners.toArray();
            platformLoginCompleteListeners = Collections.EMPTY_LIST;
            for (int i = 0; i < listeners.length; i++) {
              try {
                PlatformLoginCompleteListener l = (PlatformLoginCompleteListener) listeners[i];
                l.platformLoginComplete();
              } catch (Exception e) {
                Debug.out(e);
              }
            }
          }

          public void messageSent(PlatformMessage message) {}
        };

    PlatformMessenger.pushMessageNow(message, listener);
  }
  public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;

    Composite cDisplay = new Composite(parent, SWT.NULL);

    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    cDisplay.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cDisplay.setLayout(layout);

    new BooleanParameter(cDisplay, "Open Details", LBLKEY_PREFIX + "opendetails");

    /** Old-style speed menus. */
    new BooleanParameter(cDisplay, "GUI_SWT_bOldSpeedMenu", LBLKEY_PREFIX + "use_old_speed_menus");

    Composite cBars = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cBars.setLayout(layout);
    cBars.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new BooleanParameter(cBars, "Open Bar Incomplete", LBLKEY_PREFIX + "openbar.incomplete");
    new BooleanParameter(cBars, "Open Bar Complete", LBLKEY_PREFIX + "openbar.complete");
    new BooleanParameter(
        cDisplay,
        "Remember transfer bar location",
        LBLKEY_PREFIX + "transferbar.remember_location");

    if (!Constants.isOSX || SWT.getVersion() >= 3300) {

      BooleanParameter est =
          new BooleanParameter(cDisplay, "Enable System Tray", KEY_PREFIX + "enabletray");

      BooleanParameter ctt =
          new BooleanParameter(cDisplay, "Close To Tray", LBLKEY_PREFIX + "closetotray");
      BooleanParameter mtt =
          new BooleanParameter(cDisplay, "Minimize To Tray", LBLKEY_PREFIX + "minimizetotray");

      est.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(ctt.getControls()));
      est.setAdditionalActionPerformer(new ChangeSelectionActionPerformer(mtt.getControls()));
    }

    /** Default download / upload limits available in the UI. */
    Group limit_group = new Group(cDisplay, SWT.NULL);
    Messages.setLanguageText(limit_group, LBLKEY_PREFIX + "set_ui_transfer_speeds");
    layout = new GridLayout();
    limit_group.setLayout(layout);
    limit_group.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    Label limit_group_label = new Label(limit_group, SWT.WRAP);
    limit_group_label.setLayoutData(Utils.getWrappableLabelGridData(1, GridData.GRAB_HORIZONTAL));
    Messages.setLanguageText(
        limit_group_label, LBLKEY_PREFIX + "set_ui_transfer_speeds.description");

    String[] limit_types = new String[] {"download", "upload"};
    final String limit_type_prefix = "config.ui.speed.partitions.manual.";
    for (int i = 0; i < limit_types.length; i++) {
      final BooleanParameter bp =
          new BooleanParameter(
              limit_group,
              limit_type_prefix + limit_types[i] + ".enabled",
              false,
              LBLKEY_PREFIX + "set_ui_transfer_speeds.description." + limit_types[i]);
      final StringParameter sp =
          new StringParameter(limit_group, limit_type_prefix + limit_types[i] + ".values", "");
      IAdditionalActionPerformer iaap =
          new GenericActionPerformer(new Control[] {}) {
            public void performAction() {
              sp.getControl().setEnabled(bp.isSelected());
            }
          };

      gridData = new GridData();
      gridData.widthHint = 150;
      sp.setLayoutData(gridData);
      iaap.performAction();
      bp.setAdditionalActionPerformer(iaap);
    }

    new BooleanParameter(cDisplay, "Send Version Info", LBLKEY_PREFIX + "allowSendVersion");

    Composite cArea = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    new LinkLabel(
        cArea,
        LBLKEY_PREFIX + "version.info.link",
        "http://www.azureuswiki.com/index.php/Version.azureusplatform.com");

    if (!Constants.isOSX) {

      BooleanParameter confirm =
          new BooleanParameter(
              cArea, "confirmationOnExit", "ConfigView.section.style.confirmationOnExit");
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      confirm.setLayoutData(gridData);
    }

    cArea = new Composite(cDisplay, SWT.NULL);
    layout = new GridLayout();
    layout.marginHeight = 0;
    layout.marginWidth = 0;
    layout.numColumns = 2;
    cArea.setLayout(layout);
    cArea.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

    // config torrent removal

    BooleanParameter confirm_removal =
        new BooleanParameter(
            cArea, "confirm_torrent_removal", KEY_PREFIX + "confirm_torrent_removal");
    gridData = new GridData();
    gridData.horizontalSpan = 2;
    confirm_removal.setLayoutData(gridData);

    // clear remembered decisions

    final Label clear_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_label, KEY_PREFIX + "cleardecisions");

    final Button clear_decisions = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_decisions, KEY_PREFIX + "cleardecisionsbutton");

    clear_decisions.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {

            COConfigurationManager.setParameter("MessageBoxWindow.decisions", new HashMap());
          }
        });

    final Label clear_tracker_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_tracker_label, KEY_PREFIX + "cleartrackers");

    final Button clear_tracker_button = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_tracker_button, KEY_PREFIX + "cleartrackersbutton");

    clear_tracker_button.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            TrackersUtil.getInstance().clearAllTrackers(true);
          }
        });

    final Label clear_save_path_label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(clear_save_path_label, KEY_PREFIX + "clearsavepaths");

    final Button clear_save_path_button = new Button(cArea, SWT.PUSH);
    Messages.setLanguageText(clear_save_path_button, KEY_PREFIX + "clearsavepathsbutton");

    clear_save_path_button.addListener(
        SWT.Selection,
        new Listener() {
          public void handleEvent(Event event) {
            COConfigurationManager.setParameter("saveTo_list", new StringListImpl());
          }
        });

    decisions_parameter_listener =
        new ParameterListener() {
          public void parameterChanged(String parameterName) {
            if (clear_decisions.isDisposed()) {

              // tidy up from previous incarnations

              COConfigurationManager.removeParameterListener("MessageBoxWindow.decisions", this);

            } else {

              boolean enabled =
                  COConfigurationManager.getMapParameter(
                              "MessageBoxWindow.decisions", new HashMap())
                          .size()
                      > 0;

              clear_label.setEnabled(enabled);
              clear_decisions.setEnabled(enabled);
            }
          }
        };

    decisions_parameter_listener.parameterChanged(null);

    COConfigurationManager.addParameterListener(
        "MessageBoxWindow.decisions", decisions_parameter_listener);

    // password

    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, LBLKEY_PREFIX + "password");

    gridData = new GridData();
    gridData.widthHint = 150;
    PasswordParameter pw1 = new PasswordParameter(cArea, "Password");
    pw1.setLayoutData(gridData);
    Text t1 = (Text) pw1.getControl();

    // password confirm

    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, LBLKEY_PREFIX + "passwordconfirm");
    gridData = new GridData();
    gridData.widthHint = 150;
    PasswordParameter pw2 = new PasswordParameter(cArea, "Password Confirm");
    pw2.setLayoutData(gridData);
    Text t2 = (Text) pw2.getControl();

    // password activated

    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, LBLKEY_PREFIX + "passwordmatch");
    passwordMatch = new Label(cArea, SWT.NULL);
    gridData = new GridData();
    gridData.widthHint = 150;
    passwordMatch.setLayoutData(gridData);
    refreshPWLabel();

    t1.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            refreshPWLabel();
          }
        });
    t2.addModifyListener(
        new ModifyListener() {
          public void modifyText(ModifyEvent e) {
            refreshPWLabel();
          }
        });

    // drag-drop

    label = new Label(cArea, SWT.NULL);
    Messages.setLanguageText(label, "ConfigView.section.style.dropdiraction");

    String[] drop_options = {
      "ConfigView.section.style.dropdiraction.opentorrents",
      "ConfigView.section.style.dropdiraction.sharefolder",
      "ConfigView.section.style.dropdiraction.sharefoldercontents",
      "ConfigView.section.style.dropdiraction.sharefoldercontentsrecursive",
    };

    String dropLabels[] = new String[drop_options.length];
    String dropValues[] = new String[drop_options.length];
    for (int i = 0; i < drop_options.length; i++) {

      dropLabels[i] = MessageText.getString(drop_options[i]);
      dropValues[i] = "" + i;
    }
    new StringListParameter(cArea, "config.style.dropdiraction", dropLabels, dropValues);

    // reset associations

    final PlatformManager platform = PlatformManagerFactory.getPlatformManager();

    if (platform.hasCapability(PlatformManagerCapabilities.RegisterFileAssociations)) {

      Composite cResetAssoc = new Composite(cArea, SWT.NULL);
      layout = new GridLayout();
      layout.marginHeight = 0;
      layout.marginWidth = 0;
      layout.numColumns = 2;
      cResetAssoc.setLayout(layout);
      cResetAssoc.setLayoutData(new GridData());

      label = new Label(cResetAssoc, SWT.NULL);
      Messages.setLanguageText(label, KEY_PREFIX + "resetassoc");

      Button reset = new Button(cResetAssoc, SWT.PUSH);
      Messages.setLanguageText(reset, KEY_PREFIX + "resetassocbutton"); // $NON-NLS-1$

      reset.addListener(
          SWT.Selection,
          new Listener() {
            public void handleEvent(Event event) {

              try {
                platform.registerApplication();

              } catch (PlatformManagerException e) {

                Logger.log(
                    new LogAlert(LogAlert.UNREPEATABLE, "Failed to register application", e));
              }
            }
          });

      new BooleanParameter(cArea, "config.interface.checkassoc", KEY_PREFIX + "checkassoc");
    }

    return cDisplay;
  }
  public Composite configSectionCreate(final Composite parent) {
    GridData gridData;
    GridLayout layout;
    Label label;

    final Composite cDisplay = new Composite(parent, SWT.NULL);

    gridData = new GridData(GridData.VERTICAL_ALIGN_FILL | GridData.HORIZONTAL_ALIGN_FILL);
    cDisplay.setLayoutData(gridData);
    layout = new GridLayout();
    layout.numColumns = 1;
    layout.marginWidth = 0;
    layout.marginHeight = 0;
    cDisplay.setLayout(layout);

    final PlatformManager platform = PlatformManagerFactory.getPlatformManager();

    int userMode = COConfigurationManager.getIntParameter("User Mode");

    // ***** start group

    boolean can_ral = platform.hasCapability(PlatformManagerCapabilities.RunAtLogin);

    if (can_ral || userMode > 0) {

      Group gStartStop = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gStartStop, LBLKEY_PREFIX + "start");
      layout = new GridLayout(2, false);
      gStartStop.setLayout(layout);
      gStartStop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      if (can_ral) {

        gridData = new GridData();
        gridData.horizontalSpan = 2;
        BooleanParameter start_on_login =
            new BooleanParameter(gStartStop, "Start On Login", LBLKEY_PREFIX + "start.onlogin");

        try {
          start_on_login.setSelected(platform.getRunAtLogin());

          start_on_login.addChangeListener(
              new ParameterChangeAdapter() {
                public void booleanParameterChanging(Parameter p, boolean toValue) {
                  try {
                    platform.setRunAtLogin(toValue);

                  } catch (Throwable e) {

                    Debug.out(e);
                  }
                }
              });

        } catch (Throwable e) {

          start_on_login.setEnabled(false);

          Debug.out(e);
        }

        start_on_login.setLayoutData(gridData);
      }

      if (userMode > 0) {

        gridData = new GridData();
        gridData.horizontalSpan = 2;

        BooleanParameter start_in_lr_mode =
            new BooleanParameter(
                gStartStop, "Start In Low Resource Mode", LBLKEY_PREFIX + "start.inlrm");

        start_in_lr_mode.setLayoutData(gridData);
      }
    }

    if (platform.hasCapability(PlatformManagerCapabilities.PreventComputerSleep)) {

      Group gSleep = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gSleep, LBLKEY_PREFIX + "sleep");
      layout = new GridLayout(2, false);
      gSleep.setLayout(layout);
      gSleep.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      label = new Label(gSleep, SWT.NULL);
      Messages.setLanguageText(label, "ConfigView.label.sleep.info");
      label.setLayoutData(gridData);

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter no_sleep_dl =
          new BooleanParameter(
              gSleep, "Prevent Sleep Downloading", LBLKEY_PREFIX + "sleep.download");
      no_sleep_dl.setLayoutData(gridData);

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter no_sleep_se =
          new BooleanParameter(gSleep, "Prevent Sleep FP Seeding", LBLKEY_PREFIX + "sleep.fpseed");
      no_sleep_se.setLayoutData(gridData);
    }

    if (userMode > 0) {

      Group gPR = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gPR, LBLKEY_PREFIX + "pauseresume");
      layout = new GridLayout(2, false);
      gPR.setLayout(layout);
      gPR.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter pauseOnExit =
          new BooleanParameter(
              gPR, "Pause Downloads On Exit", "ConfigView.label.pause.downloads.on.exit");
      pauseOnExit.setLayoutData(gridData);

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter resumeOnStart =
          new BooleanParameter(
              gPR, "Resume Downloads On Start", "ConfigView.label.resume.downloads.on.start");
      resumeOnStart.setLayoutData(gridData);
    }

    if (userMode >= 0) {

      Group gStop = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gStop, LBLKEY_PREFIX + "stop");
      layout = new GridLayout(2, false);
      gStop.setLayout(layout);
      gStop.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // done downloading

      gridData = new GridData();
      label = new Label(gStop, SWT.NULL);
      Messages.setLanguageText(label, "ConfigView.label.stop.downcomp");
      label.setLayoutData(gridData);

      int shutdown_types = platform.getShutdownTypes();

      List<String> l_action_values = new ArrayList<String>();
      List<String> l_action_descs = new ArrayList<String>();

      l_action_values.add("Nothing");
      l_action_values.add("QuitVuze");

      if ((shutdown_types & PlatformManager.SD_SLEEP) != 0) {

        l_action_values.add("Sleep");
      }
      if ((shutdown_types & PlatformManager.SD_HIBERNATE) != 0) {

        l_action_values.add("Hibernate");
      }
      if ((shutdown_types & PlatformManager.SD_SHUTDOWN) != 0) {

        l_action_values.add("Shutdown");
      }

      String[] action_values = l_action_values.toArray(new String[l_action_values.size()]);

      for (String s : action_values) {

        l_action_descs.add(MessageText.getString("ConfigView.label.stop." + s));
      }

      String[] action_descs = l_action_descs.toArray(new String[l_action_descs.size()]);

      new StringListParameter(
          gStop, "On Downloading Complete Do", "Nothing", action_descs, action_values);

      // done seeding

      gridData = new GridData();
      label = new Label(gStop, SWT.NULL);
      Messages.setLanguageText(label, "ConfigView.label.stop.seedcomp");
      label.setLayoutData(gridData);

      new StringListParameter(
          gStop, "On Seeding Complete Do", "Nothing", action_descs, action_values);

      gridData = new GridData();
      gridData.horizontalSpan = 2;
      BooleanParameter resetOnTrigger =
          new BooleanParameter(
              gStop,
              "Stop Triggers Auto Reset",
              "!"
                  + MessageText.getString(
                      "ConfigView.label.stop.autoreset",
                      new String[] {MessageText.getString("ConfigView.label.stop.Nothing")})
                  + "!");

      resetOnTrigger.setLayoutData(gridData);
    }

    if (userMode > 0
        && platform.hasCapability(PlatformManagerCapabilities.AccessExplicitVMOptions)) {

      Group gJVM = new Group(cDisplay, SWT.NULL);
      Messages.setLanguageText(gJVM, LBLKEY_PREFIX + "jvm");
      layout = new GridLayout(2, false);
      gJVM.setLayout(layout);
      gJVM.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));

      // wiki link

      gridData = new GridData();
      gridData.horizontalSpan = 2;

      LinkLabel link =
          new LinkLabel(
              gJVM,
              gridData,
              "ConfigView.label.please.visit.here",
              "http://wiki.vuze.com/w/Java_VM_memory_usage");

      // info

      label = new Label(gJVM, SWT.NULL);
      Messages.setLanguageText(label, "jvm.info");
      gridData = new GridData();
      gridData.horizontalSpan = 2;
      label.setLayoutData(gridData);

      try {
        final File option_file = platform.getVMOptionFile();

        final Group gJVMOptions = new Group(gJVM, SWT.NULL);
        layout = new GridLayout(3, false);
        gJVMOptions.setLayout(layout);
        gridData = new GridData(GridData.FILL_HORIZONTAL);
        gridData.horizontalSpan = 2;
        gJVMOptions.setLayoutData(gridData);

        buildOptions(cDisplay, platform, gJVMOptions, false);

        // show option file

        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(
            label, "jvm.show.file", new String[] {option_file.getAbsolutePath()});

        Button show_folder_button = new Button(gJVM, SWT.PUSH);

        Messages.setLanguageText(show_folder_button, "MyTorrentsView.menu.explore");

        show_folder_button.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent e) {
                ManagerUtils.open(option_file);
              }
            });

        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(label, "jvm.reset");

        Button reset_button = new Button(gJVM, SWT.PUSH);

        Messages.setLanguageText(reset_button, "Button.reset");

        reset_button.addSelectionListener(
            new SelectionAdapter() {
              public void widgetSelected(SelectionEvent event) {
                try {
                  platform.setExplicitVMOptions(new String[0]);

                  buildOptions(cDisplay, platform, gJVMOptions, true);

                } catch (Throwable e) {

                  Debug.out(e);
                }
              }
            });

      } catch (Throwable e) {

        Debug.out(e);

        label = new Label(gJVM, SWT.NULL);
        Messages.setLanguageText(
            label, "jvm.error", new String[] {Debug.getNestedExceptionMessage(e)});
        gridData = new GridData();
        gridData.horizontalSpan = 2;
        label.setLayoutData(gridData);
      }
    }

    return cDisplay;
  }
  private void buildOptions(
      final Composite parent, final PlatformManager platform, final Composite area, boolean rebuild)
      throws PlatformManagerException {
    if (rebuild) {

      Control[] kids = area.getChildren();

      for (Control k : kids) {
        k.dispose();
      }
    }

    String[] options = platform.getExplicitVMOptions();

    {
      // max mem

      long max_mem = AEMemoryMonitor.getJVMLongOption(options, "-Xmx");

      final int MIN_MAX_JVM = 32 * 1024 * 1024;

      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "jvm.max.mem", new String[] {encodeDisplayLong(MIN_MAX_JVM)});

      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter max_vm = new StringParameter(area, "jvm.max.mem", "", false);
      max_vm.setLayoutData(gridData);

      max_vm.setValue(max_mem == -1 ? "" : encodeDisplayLong(max_mem));

      max_vm.addChangeListener(
          new ParameterChangeAdapter() {
            private String last_value;

            public void parameterChanged(Parameter p, boolean caused_internally) {
              if (max_vm.isDisposed()) {

                max_vm.removeChangeListener(this);

                return;
              }

              String val = max_vm.getValue();

              if (last_value != null && last_value.equals(val)) {

                return;
              }

              last_value = val;

              try {
                long max_mem = decodeDisplayLong(val);

                if (max_mem < MIN_MAX_JVM) {

                  throw (new Exception("Min=" + encodeDisplayLong(MIN_MAX_JVM)));
                }

                String[] options = platform.getExplicitVMOptions();

                options = AEMemoryMonitor.setJVMLongOption(options, "-Xmx", max_mem);

                long min_mem = AEMemoryMonitor.getJVMLongOption(options, "-Xms");

                if (min_mem == -1 || min_mem > max_mem) {

                  options = AEMemoryMonitor.setJVMLongOption(options, "-Xms", max_mem);
                }

                platform.setExplicitVMOptions(options);

                buildOptions(parent, platform, area, true);

              } catch (Throwable e) {

                String param_name = MessageText.getString("jvm.max.mem");

                int pos = param_name.indexOf('[');

                if (pos != -1) {

                  param_name = param_name.substring(0, pos).trim();
                }

                MessageBoxShell mb =
                    new MessageBoxShell(
                        SWT.ICON_ERROR | SWT.OK,
                        MessageText.getString("ConfigView.section.invalid.value.title"),
                        MessageText.getString(
                            "ConfigView.section.invalid.value",
                            new String[] {val, param_name, Debug.getNestedExceptionMessage(e)}));

                mb.setParent(parent.getShell());
                mb.open(null);
              }
            }
          });

      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);

      Long max_heap_mb = AEMemoryMonitor.getMaxHeapMB();

      if (max_heap_mb > 0) {

        Messages.setLanguageText(
            label,
            "jvm.max.mem.current",
            new String[] {
              DisplayFormatters.formatByteCountToKiBEtc(max_heap_mb * 1024 * 1024, true)
            });
      }
    }

    {
      // min mem

      final int MIN_MIN_JVM = 8 * 1024 * 1024;

      long min_mem = AEMemoryMonitor.getJVMLongOption(options, "-Xms");

      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "jvm.min.mem", new String[] {encodeDisplayLong(MIN_MIN_JVM)});

      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter min_vm = new StringParameter(area, "jvm.min.mem", "", false);
      min_vm.setLayoutData(gridData);

      min_vm.setValue(min_mem == -1 ? "" : encodeDisplayLong(min_mem));

      min_vm.addChangeListener(
          new ParameterChangeAdapter() {
            private String last_value;

            public void parameterChanged(Parameter p, boolean caused_internally) {
              if (min_vm.isDisposed()) {

                min_vm.removeChangeListener(this);

                return;
              }

              String val = min_vm.getValue();

              if (last_value != null && last_value.equals(val)) {

                return;
              }

              last_value = val;

              try {
                long min_mem = decodeDisplayLong(val);

                if (min_mem < MIN_MIN_JVM) {

                  throw (new Exception("Min=" + encodeDisplayLong(MIN_MIN_JVM)));
                }

                String[] options = platform.getExplicitVMOptions();

                options = AEMemoryMonitor.setJVMLongOption(options, "-Xms", min_mem);

                long max_mem = AEMemoryMonitor.getJVMLongOption(options, "-Xmx");

                if (max_mem == -1 || max_mem < min_mem) {

                  options = AEMemoryMonitor.setJVMLongOption(options, "-Xmx", min_mem);
                }

                platform.setExplicitVMOptions(options);

                buildOptions(parent, platform, area, true);

              } catch (Throwable e) {

                String param_name = MessageText.getString("jvm.min.mem");

                int pos = param_name.indexOf('[');

                if (pos != -1) {

                  param_name = param_name.substring(0, pos).trim();
                }

                MessageBoxShell mb =
                    new MessageBoxShell(
                        SWT.ICON_ERROR | SWT.OK,
                        MessageText.getString("ConfigView.section.invalid.value.title"),
                        MessageText.getString(
                            "ConfigView.section.invalid.value",
                            new String[] {val, param_name, Debug.getNestedExceptionMessage(e)}));

                mb.setParent(parent.getShell());
                mb.open(null);
              }
            }
          });

      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);
    }

    {
      // max DIRECT mem

      final int MIN_DIRECT_JVM = 32 * 1024 * 1024;

      final String OPTION_KEY = "-XX:MaxDirectMemorySize=";

      long max_direct = AEMemoryMonitor.getJVMLongOption(options, OPTION_KEY);

      GridData gridData = new GridData();
      Label label = new Label(area, SWT.NULL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(
          label, "jvm.max.direct.mem", new String[] {encodeDisplayLong(MIN_DIRECT_JVM)});

      gridData = new GridData();
      gridData.widthHint = 125;
      final StringParameter max_direct_vm =
          new StringParameter(area, "jvm.max.direct.mem", "", false);
      max_direct_vm.setLayoutData(gridData);

      max_direct_vm.setValue(max_direct == -1 ? "" : encodeDisplayLong(max_direct));

      max_direct_vm.addChangeListener(
          new ParameterChangeAdapter() {
            private String last_value;

            public void parameterChanged(Parameter p, boolean caused_internally) {
              if (max_direct_vm.isDisposed()) {

                max_direct_vm.removeChangeListener(this);

                return;
              }

              String val = max_direct_vm.getValue();

              if (last_value != null && last_value.equals(val)) {

                return;
              }

              last_value = val;

              try {
                long max_direct = decodeDisplayLong(val);

                if (max_direct < MIN_DIRECT_JVM) {

                  throw (new Exception("Min=" + encodeDisplayLong(MIN_DIRECT_JVM)));
                }

                String[] options = platform.getExplicitVMOptions();

                options = AEMemoryMonitor.setJVMLongOption(options, OPTION_KEY, max_direct);

                platform.setExplicitVMOptions(options);

                buildOptions(parent, platform, area, true);

              } catch (Throwable e) {

                String param_name = MessageText.getString("jvm.max.direct.mem");

                int pos = param_name.indexOf('[');

                if (pos != -1) {

                  param_name = param_name.substring(0, pos).trim();
                }

                MessageBoxShell mb =
                    new MessageBoxShell(
                        SWT.ICON_ERROR | SWT.OK,
                        MessageText.getString("ConfigView.section.invalid.value.title"),
                        MessageText.getString(
                            "ConfigView.section.invalid.value",
                            new String[] {val, param_name, Debug.getNestedExceptionMessage(e)}));

                mb.setParent(parent.getShell());
                mb.open(null);
              }
            }
          });

      label = new Label(area, SWT.NULL);
      gridData = new GridData(GridData.FILL_HORIZONTAL);
      label.setLayoutData(gridData);
      Messages.setLanguageText(label, "jvm.max.direct.mem.info");
    }

    // all options

    Label label = new Label(area, SWT.NULL);
    GridData gridData = new GridData(GridData.FILL_HORIZONTAL);
    gridData.horizontalSpan = 3;
    label.setLayoutData(gridData);
    Messages.setLanguageText(label, "jvm.options.summary");

    for (String option : options) {

      label = new Label(area, SWT.NULL);
      label.setText(option);
      gridData = new GridData();
      gridData.horizontalSpan = 3;
      gridData.horizontalIndent = 20;
      label.setLayoutData(gridData);
    }

    if (rebuild) {

      parent.layout(true, true);
    }
  }