コード例 #1
0
  public boolean isEnabled(List<IServicePolicy> selectedPolicies) {
    boolean result = true;

    // If we don't allow multi select and multiple policies have been selected
    // then this operation is not enabled.
    if (!multiSelect && selectedPolicies.size() > 1) {
      result = false;
    }

    if (result && enabledElement != null) {
      // We have an extension for this enablement code so we will call this
      // code.
      if (enableOperationObject == null) {
        try {
          String enabledClassName =
              RegistryUtils.getAttributeName(enabledElement, "enabledclass"); // $NON-NLS-1$
          enableOperationObject =
              (IEnableOperation) enabledElement.createExecutableExtension(enabledClassName);
        } catch (Exception exc) {
          ServicePolicyActivatorUI.logError(
              "Error loading service policy ui \"enabled\" class.", exc); // $NON-NLS-1$
        }

        if (enableOperationObject != null) {
          result = enableOperationObject.isEnabled(selectedPolicies);
        }
      }
    }

    return result;
  }
コード例 #2
0
  public void launchOperation(IServicePolicy thisPolicy, List<IServicePolicy> selectedPolicies) {
    if (launchOperationObject == null) {
      try {
        String launchClassName =
            RegistryUtils.getAttributeName(complexElement, "launchclass"); // $NON-NLS-1$
        launchOperationObject =
            (ILaunchOperation) complexElement.createExecutableExtension(launchClassName);
      } catch (Exception exc) {
        ServicePolicyActivatorUI.logError(
            "Error loading service policy ui launch class.", exc); // $NON-NLS-1$
      }
    }

    if (launchOperationObject != null) {
      launchOperationObject.launch(selectedPolicies);
    }
  }