com.intellij.openapi.projectRoots.SdkTable Java Examples
The following examples show how to use
com.intellij.openapi.projectRoots.SdkTable.
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: LightPlatformTestCase.java From consulo with Apache License 2.0 | 6 votes |
@RequiredWriteAction public static synchronized void closeAndDeleteProject() { if (ourProject != null) { ApplicationManager.getApplication().assertWriteAccessAllowed(); for (Sdk registeredSdk : ourRegisteredSdks) { SdkTable.getInstance().removeSdk(registeredSdk); } ((ProjectImpl)ourProject).setTemporarilyDisposed(false); final VirtualFile projFile = ((ProjectEx)ourProject).getStateStore().getProjectFile(); final File projectFile = projFile == null ? null : VfsUtilCore.virtualToIoFile(projFile); if (!ourProject.isDisposed()) Disposer.dispose(ourProject); if (projectFile != null) { FileUtil.delete(projectFile); } ourProject = null; } }
Example #2
Source File: SdkConfigurationUtil.java From consulo with Apache License 2.0 | 6 votes |
/** * Tries to create an SDK identified by path; if successful, add the SDK to the global SDK table. * * @param path identifies the SDK * @param sdkType * @param predefined * @return newly created SDK, or null. */ @Nullable public static Sdk createAndAddSDK(final String path, SdkType sdkType, boolean predefined) { VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() { @Override public VirtualFile compute() { return LocalFileSystem.getInstance().refreshAndFindFileByPath(path); } }); if (sdkHome != null) { final Sdk newSdk = setupSdk(SdkTable.getInstance().getAllSdks(), sdkHome, sdkType, true, predefined, null, null); if (newSdk != null) { addSdk(newSdk); } return newSdk; } return null; }
Example #3
Source File: SdkConfigurationUtil.java From consulo with Apache License 2.0 | 6 votes |
@RequiredUIAccess public static void selectSdkHome(final SdkType sdkType, @Nonnull @RequiredUIAccess final Consumer<String> consumer) { final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor(); if (ApplicationManager.getApplication().isUnitTestMode()) { Sdk sdk = SdkTable.getInstance().findMostRecentSdkOfType(sdkType); if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found"); consumer.consume(sdk.getHomePath()); return; } FileChooser.chooseFiles(descriptor, null, getSuggestedSdkPath(sdkType)).doWhenDone(virtualFiles -> { final String path = virtualFiles[0].getPath(); if (sdkType.isValidSdkHome(path)) { consumer.consume(path); return; } final String adjustedPath = sdkType.adjustSelectedSdkHome(path); if (sdkType.isValidSdkHome(adjustedPath)) { consumer.consume(adjustedPath); } }); }
Example #4
Source File: PredefinedBundlesLoader.java From consulo with Apache License 2.0 | 5 votes |
@Override public void preload(@Nonnull ProgressIndicator indicator) { if (SystemProperties.is("consulo.disable.predefined.bundles")) { return; } SdkTable sdkTable = mySdkTable.get(); ContextImpl context = new ContextImpl(sdkTable); for (PredefinedBundlesProvider provider : PredefinedBundlesProvider.EP_NAME.getExtensionList()) { try { provider.createBundles(context); } catch (Error e) { LOG.error(e); } } List<Sdk> bundles = context.myBundles; if (!bundles.isEmpty()) { for (Sdk bundle : bundles) { ((SdkImpl)bundle).setPredefined(true); } ((SdkTableImpl)sdkTable).addSdksUnsafe(bundles); } }
Example #5
Source File: SdkConfigurationUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void addSdk(@Nonnull final Sdk sdk) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { SdkTable.getInstance().addSdk(sdk); } }); }
Example #6
Source File: SdkConfigurationUtil.java From consulo with Apache License 2.0 | 5 votes |
public static void removeSdk(final Sdk sdk) { ApplicationManager.getApplication().runWriteAction(new Runnable() { @Override public void run() { SdkTable.getInstance().removeSdk(sdk); } }); }
Example #7
Source File: CSharpSetupStep.java From consulo-csharp with Apache License 2.0 | 4 votes |
public CSharpSetupStep(CSharpNewModuleContext context) { super(context); JPanel panel = new JPanel(new VerticalFlowLayout()); myTargetComboBox = new ComboBox<>(DotNetTarget.values()); myTargetComboBox.setRenderer(new ColoredListCellRenderer<DotNetTarget>() { @Override protected void customizeCellRenderer(@Nonnull JList<? extends DotNetTarget> jList, DotNetTarget target, int i, boolean b, boolean b1) { append(target.getDescription()); } }); myTargetComboBox.addItemListener(e -> { if(e.getStateChange() == ItemEvent.SELECTED) { context.setTarget((DotNetTarget) myTargetComboBox.getSelectedItem()); } }); panel.add(myTargetComponent = LabeledComponent.create(myTargetComboBox, "Target")); List<String> validSdkTypes = new SmartList<>(); for(Map.Entry<String, String[]> entry : CSharpNewModuleBuilder.ourExtensionMapping.entrySet()) { // need check C# extension ModuleExtensionProviderEP providerEP = ModuleExtensionProviders.findProvider(entry.getValue()[1]); if(providerEP == null) { continue; } validSdkTypes.add(entry.getKey()); } myComboBox = new SdkComboBox(SdkTable.getInstance(), sdkTypeId -> validSdkTypes.contains(sdkTypeId.getName()), false); myComboBox.addItemListener(e -> { if(e.getStateChange() == ItemEvent.SELECTED) { context.setSdk(myComboBox.getSelectedSdk()); } }); context.setSdk(myComboBox.getSelectedSdk()); panel.add(LabeledComponent.create(myComboBox, ".NET SDK")); myAdditionalContentPanel.add(panel, BorderLayout.NORTH); }
Example #8
Source File: SdkPointerManagerImpl.java From consulo with Apache License 2.0 | 4 votes |
@Nullable @Override protected Sdk findByName(@Nonnull String name) { return SdkTable.getInstance().findSdk(name); }
Example #9
Source File: BundleTypeUsagesCollector.java From consulo with Apache License 2.0 | 4 votes |
@Inject public BundleTypeUsagesCollector(SdkTable sdkTable) { mySdkTable = sdkTable; }
Example #10
Source File: PredefinedBundlesLoader.java From consulo with Apache License 2.0 | 4 votes |
@Inject public PredefinedBundlesLoader(Provider<SdkTable> sdkTable) { mySdkTable = sdkTable; }
Example #11
Source File: PredefinedBundlesLoader.java From consulo with Apache License 2.0 | 4 votes |
public ContextImpl(SdkTable sdkTable) { mySdkTable = sdkTable; }
Example #12
Source File: SdkConfigurationUtil.java From consulo with Apache License 2.0 | 4 votes |
@Nullable public static Sdk setupSdk(final Sdk[] allSdks, final VirtualFile homeDir, final SdkType sdkType, final boolean silent, boolean predefined, @Nullable final SdkAdditionalData additionalData, @Nullable final String customSdkSuggestedName) { final SdkImpl sdk; try { String sdkPath = sdkType.sdkPath(homeDir); String sdkName = null; if (predefined) { sdkName = sdkType.getName() + PREDEFINED_PREFIX; } else { sdkName = customSdkSuggestedName == null ? createUniqueSdkName(sdkType, sdkPath, allSdks) : createUniqueSdkName(customSdkSuggestedName, allSdks); } sdk = new SdkImpl(SdkTable.getInstance(), sdkName, sdkType); sdk.setPredefined(predefined); if (additionalData != null) { // additional initialization. // E.g. some ruby sdks must be initialized before // setupSdkPaths() method invocation sdk.setSdkAdditionalData(additionalData); } sdk.setHomePath(sdkPath); sdkType.setupSdkPaths((Sdk)sdk); } catch (Exception e) { if (!silent) { Messages.showErrorDialog("Error configuring SDK: " + e.getMessage() + ".\nPlease make sure that " + FileUtil.toSystemDependentName(homeDir.getPath()) + " is a valid home path for this SDK type.", "Error Configuring SDK"); } return null; } return sdk; }
Example #13
Source File: DesktopShowSettingsUtilImpl.java From consulo with Apache License 2.0 | 4 votes |
@Inject DesktopShowSettingsUtilImpl(DefaultProjectFactory defaultProjectFactory, Provider<SdkTable> sdkTableProvider) { myDefaultProjectFactory = defaultProjectFactory; mySdksModel = new DefaultSdksModel(sdkTableProvider); }