Java Code Examples for com.intellij.openapi.projectRoots.Sdk#getSdkAdditionalData()

The following examples show how to use com.intellij.openapi.projectRoots.Sdk#getSdkAdditionalData() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: HaxelibCommandUtils.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
/**
 * Find the path to the 'haxelib' executable, using a specific SDK.
 *
 * @param sdk - SDK to look up haxelib for.
 * @return the configured haxelib for the SDK; "haxelib" if not specified.
 */
@NotNull
public static String getHaxelibPath(@NotNull Sdk sdk) {

  String haxelibPath = "haxelib";
  if (sdk != null) {
    SdkAdditionalData data = sdk.getSdkAdditionalData();

    if (data instanceof HaxeSdkData) {
      HaxeSdkData sdkData = (HaxeSdkData)data;
      String path = sdkData.getHaxelibPath();
      if (!path.isEmpty()) {
        haxelibPath = path;
      }
    }
  }

  return haxelibPath;
}
 
Example 2
Source File: OCamlAdditionalDataConfigurable.java    From reasonml-idea-plugin with MIT License 5 votes vote down vote up
@Override
public void setSdk(Sdk sdk) {
    m_sdk = sdk;
    SdkAdditionalData data = sdk.getSdkAdditionalData();
    if (data == null) {
        String versionString = sdk.getVersionString();
        if (versionString != null) {
            OCamlSdkAdditionalData oData = new OCamlSdkAdditionalData();
            oData.setVersionFromHome(versionString);
            ((ProjectJdkImpl) sdk).setSdkAdditionalData(oData);
        }
    }
}
 
Example 3
Source File: AndroidSdkFromProjectView.java    From intellij with Apache License 2.0 5 votes vote down vote up
private static int getAndroidSdkApiLevel(Sdk sdk) {
  int androidSdkApiLevel = 1;
  AndroidSdkAdditionalData additionalData = (AndroidSdkAdditionalData) sdk.getSdkAdditionalData();
  if (additionalData != null) {
    AndroidPlatform androidPlatform = additionalData.getAndroidPlatform();
    if (androidPlatform != null) {
      androidSdkApiLevel = androidPlatform.getApiLevel();
    }
  }
  return androidSdkApiLevel;
}
 
Example 4
Source File: NMERunningState.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
private HaxeCommandLine getCommandForNeko(Sdk sdk, HaxeModuleSettings settings) throws ExecutionException {
  final HaxeSdkData sdkData = sdk.getSdkAdditionalData() instanceof HaxeSdkData ? (HaxeSdkData)sdk.getSdkAdditionalData() : null;
  if (sdkData == null) {
    throw new ExecutionException(HaxeCommonBundle.message("invalid.haxe.sdk"));
  }
  final HaxeCommandLine commandLine = new HaxeCommandLine(module);

  commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath()));
  final String haxelibPath = sdkData.getHaxelibPath();
  if (haxelibPath == null || haxelibPath.isEmpty()) {
    throw new ExecutionException(HaxeCommonBundle.message("no.haxelib.for.sdk", sdk.getName()));
  }
  commandLine.setExePath(haxelibPath);
  commandLine.addParameter("run");
  commandLine.addParameter("nme");
  commandLine.addParameter(myRunInTest ? "test" : "run");
  commandLine.addParameter(settings.getNmmlPath());
  for (String flag : settings.getNmeTarget().getFlags()) {
    commandLine.addParameter(flag);
  }
  if (myDebug) {
    commandLine.addParameter("-debug");
    commandLine.addParameter("-Ddebug");
    commandLine.addParameter("-args");
    commandLine.addParameter("-start_debugger");
    commandLine.addParameter("-debugger_host=localhost:" + myDebugPort);
  }

  final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getNmeFlags());
  while (flagsTokenizer.hasMoreTokens()) {
    commandLine.addParameter(flagsTokenizer.nextToken());
  }

  final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject());
  setConsoleBuilder(consoleBuilder);
  return commandLine;
}
 
Example 5
Source File: HaxeSdkUtilBase.java    From intellij-haxe with Apache License 2.0 5 votes vote down vote up
@Nullable
public static HaxeSdkAdditionalDataBase getSdkData(@Nullable Sdk sdk) {
  if(sdk != null) {
    SdkAdditionalData sdkData = sdk.getSdkAdditionalData();
    if(sdkData != null && sdkData instanceof HaxeSdkAdditionalDataBase) {
      return (HaxeSdkAdditionalDataBase)sdkData;
    }
  }
  return null;
}
 
Example 6
Source File: OCamlSdkForm.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
public void createUIComponents(@NotNull Sdk sdk) {
    SdkTypeId sdkType = sdk.getSdkType();
    if (sdkType instanceof OCamlSdkType) {
        m_sdkVersion = sdk.getVersionString();
        m_data = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData();
        if (m_data != null) {
            c_version.setText("Current version is: " + m_data);

            c_forceVersion.setSelected(m_data.isForced());
            c_forceVersion.addItemListener(itemEvent -> c_forceValue.setEnabled(itemEvent.getStateChange() == ItemEvent.SELECTED));

            c_forceValue.setText(m_data.toString());
            c_forceValue.setEnabled(m_data.isForced());

            c_sdkHome.addBrowseFolderListener("Choose Sdk Home Directory: ", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor());

            c_download.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent mouseEvent) {
                    OCamlSdkAdditionalData odkData = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData();
                    if (odkData != null) {
                        // Download SDK from distribution site
                        LOG.debug("Download SDK", m_data.toString());
                        VirtualFileSystem fileSystem = LocalFileSystem.getInstance();
                        VirtualFile sdkHome = fileSystem.findFileByPath(c_sdkHome.getText().trim());
                        if (sdkHome != null) {
                            Task.WithResult<String, RuntimeException> download = new Task.WithResult<String, RuntimeException>(null, "Download SDK", false) {
                                @Override
                                protected String compute(@NotNull ProgressIndicator indicator) throws RuntimeException {
                                    new SdkDownloader(odkData.getMajor(), odkData.getMinor(), odkData.getPatch(), sdkHome).run(null, indicator);
                                    return sdkHome.getPath();
                                }
                            };
                            String path = ProgressManager.getInstance().run(download);
                            Notifications.Bus.notify(new ORNotification("SDK", "SDK " + odkData + " downloaded to " + path, NotificationType.INFORMATION));
                        }
                    }
                }
            });
        }
    }
}
 
Example 7
Source File: OpenFLRunningState.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
private HaxeCommandLine getCommandForOpenFL(Sdk sdk, HaxeModuleSettings settings) throws ExecutionException {
  final HaxeSdkData sdkData = sdk.getSdkAdditionalData() instanceof HaxeSdkData ? (HaxeSdkData)sdk.getSdkAdditionalData() : null;
  if (sdkData == null) {
    throw new ExecutionException(HaxeCommonBundle.message("invalid.haxe.sdk"));
  }
  final HaxeCommandLine commandLine = new HaxeCommandLine(module);

  commandLine.setWorkDirectory(PathUtil.getParentPath(module.getModuleFilePath()));
  final String haxelibPath = sdkData.getHaxelibPath();
  if (haxelibPath == null || haxelibPath.isEmpty()) {
    throw new ExecutionException(HaxeCommonBundle.message("no.haxelib.for.sdk", sdk.getName()));
  }

  commandLine.setExePath(haxelibPath);
  commandLine.addParameter("run");
  commandLine.addParameter("lime");
  commandLine.addParameter(myRunInTest ? "test" : "run");

  if(!StringUtil.isEmpty(settings.getOpenFLPath())) {
    commandLine.addParameter(settings.getOpenFLPath());
  }

  for (String flag : settings.getOpenFLTarget().getFlags()) {
    commandLine.addParameter(flag);
  }

  commandLine.addParameter("-verbose");

  if (myDebug) {
    commandLine.addParameter("-Ddebug");
    commandLine.addParameter("-debug");

    if (settings.getOpenFLTarget() == OpenFLTarget.FLASH) {
      commandLine.addParameter("-Dfdb");
    }
    else {
      commandLine.addParameter("-args");
      commandLine.addParameter("-start_debugger");
      commandLine.addParameter("-debugger_host=localhost:" + myDebugPort);
    }
  }

  final StringTokenizer flagsTokenizer = new StringTokenizer(settings.getOpenFLFlags());
  while (flagsTokenizer.hasMoreTokens()) {
    commandLine.addParameter(flagsTokenizer.nextToken());
  }

  final TextConsoleBuilder consoleBuilder = TextConsoleBuilderFactory.getInstance().createBuilder(module.getProject());
  setConsoleBuilder(consoleBuilder);
  return commandLine;
}