Java 类com.intellij.openapi.projectRoots.impl.SdkImpl 实例源码

项目:consulo-ikvm    文件:MonoIkvmModuleExtension.java   
@Override
protected Sdk createSdk(VirtualFile virtualFile)
{
    SdkImpl sdk = new SdkImpl("Mono IKVM.NET", IkvmBundleType.getInstance());
    VirtualFile mainMonoPath = virtualFile.getParent().getParent().getParent();
    sdk.setHomePath(mainMonoPath.getPath());
    sdk.setPredefined(true);
    sdk.setVersionString(IkvmBundleType.getInstance().getVersionString(sdk));

    SdkModificator sdkModificator = sdk.getSdkModificator();
    for(String library : IkvmBundleType.ourLibraries)
    {
        VirtualFile libraryFile = mainMonoPath.findFileByRelativePath("lib/mono/ikvm/" + library);
        if(libraryFile != null)
        {
            VirtualFile archiveLibraryFile = ArchiveVfsUtil.getArchiveRootForLocalFile(libraryFile);
            if(archiveLibraryFile != null)
            {
                sdkModificator.addRoot(archiveLibraryFile, BinariesOrderRootType.getInstance());
            }
        }
    }

    sdkModificator.commitChanges();
    return sdk;
}
项目:consulo-lua    文件:LuaPredefinedBundlesProvider.java   
@Override
public void createBundles(@NotNull Consumer<SdkImpl> consumer)
{
    Map<String, LuaSdkType> map = new HashMap<String, LuaSdkType>();
    map.put("Kahlua", KahluaSdkType.getInstance());
    map.put("LuaJ", LuaJSdkType.getInstance());

    for(Map.Entry<String, LuaSdkType> entry : map.entrySet())
    {
        LuaSdkType luaSdkType = entry.getValue();
        SdkImpl sdkWithName = createSdkWithName(luaSdkType, entry.getKey());

        sdkWithName.setHomePath(luaSdkType.getStdLibraryFile().getPath());

        luaSdkType.setupSdkPaths(sdkWithName);

        consumer.consume(sdkWithName);
    }
}
项目:consulo    文件:PredefinedBundlesLoader.java   
@Override
public void initComponent() {
  if (SystemProperties.is("consulo.disable.predefined.bundles")) {
    return;
  }

  Consumer<SdkImpl> consumer = new Consumer<SdkImpl>() {
    @Override
    @RequiredDispatchThread
    public void consume(final SdkImpl sdk) {
      ApplicationManager.getApplication().runWriteAction(() -> {
        sdk.setPredefined(true);
        SdkTable.getInstance().addSdk(sdk);
      });
    }
  };

  for (PredefinedBundlesProvider predefinedBundlesProvider : PredefinedBundlesProvider.EP_NAME.getExtensions()) {
    try {
      predefinedBundlesProvider.createBundles(consumer);
    }
    catch (Throwable e) {
      LOGGER.error(e);
    }
  }
}
项目:consulo    文件:ProjectSdksModel.java   
public void doAdd(JComponent parent, final SdkType type, final Consumer<Sdk> callback) {
  myModified = true;
  if (type.supportsCustomCreateUI()) {
    type.showCustomCreateUI(this, parent, new Consumer<Sdk>() {
      @Override
      public void consume(Sdk sdk) {
        setupSdk(sdk, callback);
      }
    });
  }
  else {
    SdkConfigurationUtil.selectSdkHome(type, new Consumer<String>() {
      @Override
      public void consume(final String home) {
        String newSdkName = SdkConfigurationUtil.createUniqueSdkName(type, home, getSdks());
        final SdkImpl newSdk = new SdkImpl(newSdkName, type);
        newSdk.setHomePath(home);
        setupSdk(newSdk, callback);
      }
    });
  }
}
项目:consulo    文件:SdkListConfigurable.java   
public boolean addSdkNode(final Sdk sdk, final boolean selectInTree) {
  if (!myUiDisposed) {
    myContext.getDaemonAnalyzer().queueUpdate(new SdkProjectStructureElement(myContext, sdk));

    MyNode newSdkNode = new MyNode(new SdkConfigurable((SdkImpl)sdk, mySdksTreeModel, TREE_UPDATER, myHistory, myProject));

    final MyNode groupNode = MasterDetailsComponent.findNodeByObject(myRoot, sdk.getSdkType());
    if (groupNode != null) {
      addNode(newSdkNode, groupNode);
    }
    else {
      final MyNode sdkGroupNode = createSdkGroupNode((SdkType)sdk.getSdkType());

      addNode(sdkGroupNode, myRoot);
      addNode(newSdkNode, sdkGroupNode);
    }

    if (selectInTree) {
      selectNodeInTree(newSdkNode);
    }
    return true;
  }
  return false;
}
项目:consulo    文件:SdksConfigurable.java   
@Override
public void reset() {
  super.reset();

  myProjectSdksModel.reset(myProject);

  myRoot.removeAllChildren();
  final Map<Sdk, Sdk> sdks = myProjectSdksModel.getProjectSdks();
  for (Sdk sdk : sdks.keySet()) {
    final SdkConfigurable configurable = new SdkConfigurable((SdkImpl)sdks.get(sdk), myProjectSdksModel, TREE_UPDATER, myHistory, myProject);
    addNode(new MyNode(configurable), myRoot);
  }

  final String value = PropertiesComponent.getInstance().getValue(SPLITTER_PROPORTION);
  if (value != null) {
    try {
      final Splitter splitter = extractSplitter();
      if (splitter != null) {
        (splitter).setProportion(Float.parseFloat(value));
      }
    }
    catch (NumberFormatException e) {
      //do not set proportion
    }
  }
}
项目:consulo    文件:SdksConfigurable.java   
@Override
@Nullable
protected ArrayList<AnAction> createActions(final boolean fromPopup) {
  final ArrayList<AnAction> actions = new ArrayList<AnAction>();
  DefaultActionGroup group = new DefaultActionGroup(ProjectBundle.message("add.action.name"), true);
  group.getTemplatePresentation().setIcon(IconUtil.getAddIcon());
  myProjectSdksModel.createAddActions(group, myTree, new Consumer<Sdk>() {
    @Override
    public void consume(final Sdk projectJdk) {
      addNode(new MyNode(new SdkConfigurable(((SdkImpl)projectJdk), myProjectSdksModel, TREE_UPDATER, myHistory, myProject), false), myRoot);
      selectNodeInTree(findNodeByObject(myRoot, projectJdk));
    }
  }, SdkListConfigurable.ADD_SDK_FILTER);
  actions.add(new MyActionGroupWrapper(group));
  actions.add(new MyDeleteAction(forAll(Conditions.alwaysTrue())));
  return actions;
}
项目:consulo-dotnet    文件:MicrosoftDotNetPredefinedBundlesProvider.java   
@Override
public void createBundles(@NotNull Consumer<SdkImpl> consumer)
{
    MicrosoftDotNetSdkType sdkType = MicrosoftDotNetSdkType.getInstance();

    Collection<MicrosoftDotNetFramework> microsoftDotNetFrameworks = buildPaths(sdkType);
    for(MicrosoftDotNetFramework netFramework : microsoftDotNetFrameworks)
    {
        SdkImpl sdk = createSdkWithName(sdkType, sdkType.getPresentableName() + " " + netFramework.toString());
        sdk.setHomePath(netFramework.getPath());
        sdk.setVersionString(netFramework.getVersion().getPresentableName());

        consumer.consume(sdk);
    }
}
项目:consulo    文件:DefaultPredefinedBundlesProvider.java   
@Override
public void createBundles(@Nonnull Consumer<SdkImpl> consumer) {
  for (SdkType sdkType : SdkType.EP_NAME.getExtensions()) {
    if(sdkType.canCreatePredefinedSdks()) {
      Collection<String> paths = sdkType.suggestHomePaths();

      for (String path : paths) {
        path = sdkType.adjustSelectedSdkHome(path);

        if(sdkType.isValidSdkHome(path)) {
          VirtualFile dirPath = LocalFileSystem.getInstance().findFileByPath(path);
          if(dirPath == null) {
            continue;
          }

          String sdkPath = sdkType.sdkPath(dirPath);

          SdkImpl sdk = createSdk(sdkType, sdkPath);
          sdk.setHomePath(sdkPath);
          sdk.setVersionString(sdkType.getVersionString(sdk));
          sdkType.setupSdkPaths(sdk);

          consumer.consume(sdk);
        }
      }
    }
  }
}
项目:consulo    文件:BaseSdkEditor.java   
private void doSetHomePath(final String homePath, final SdkType sdkType) {
  if (homePath == null) {
    return;
  }
  setHomePathValue(homePath.replace('/', File.separatorChar));

  final String newSdkName = suggestSdkName(homePath);
  ((SdkImpl)mySdk).setName(newSdkName);

  try {
    final Sdk dummySdk = (Sdk)mySdk.clone();
    SdkModificator sdkModificator = dummySdk.getSdkModificator();
    sdkModificator.setHomePath(homePath);
    sdkModificator.removeAllRoots();
    sdkModificator.commitChanges();

    sdkType.setupSdkPaths(dummySdk);

    clearAllPaths();
    myVersionString = dummySdk.getVersionString();
    if (myVersionString == null) {
      Messages
        .showMessageDialog(ProjectBundle.message("sdk.java.corrupt.error", homePath), ProjectBundle.message("sdk.java.corrupt.title"),
                           Messages.getErrorIcon());
    }
    sdkModificator = dummySdk.getSdkModificator();
    for (OrderRootType type : myPathEditors.keySet()) {
      myPathEditors.get(type).addPaths(sdkModificator.getRoots(type));
    }
    mySdkModel.getMulticaster().sdkHomeSelected(dummySdk, homePath);
  }
  catch (CloneNotSupportedException e) {
    BaseSdkEditor.LOGGER.error(e); // should not happen in normal program
  }
}
项目:consulo    文件:SdkConfigurable.java   
public SdkConfigurable(@Nonnull final SdkImpl sdk,
                       final ProjectSdksModel sdksModel,
                       final Runnable updateTree,
                       @Nonnull History history,
                       Project project) {
  super(!sdk.isPredefined(), updateTree);
  mySdk = sdk;
  mySdkEditor = createSdkEditor(sdksModel, history, mySdk);
  final StructureConfigurableContext context = ModuleStructureConfigurable.getInstance(project).getContext();
  myProjectStructureElement = new SdkProjectStructureElement(context, mySdk);
}
项目:consulo    文件:SdkListConfigurable.java   
@Override
public void update(final AnActionEvent e) {
  if (myTree.getSelectionPaths() == null || myTree.getSelectionPaths().length != 1) {
    e.getPresentation().setEnabled(false);
  }
  else {
    Object selectedObject = getSelectedObject();
    e.getPresentation().setEnabled(selectedObject instanceof SdkImpl && !(((SdkImpl)selectedObject).getSdkType() instanceof UnknownSdkType));
  }
}
项目:consulo    文件:PredefinedBundlesProvider.java   
@Nonnull
public SdkImpl createSdkWithName(@Nonnull SdkType sdkType, @Nonnull String suggestName) {
  String uniqueSdkName = SdkConfigurationUtil.createUniqueSdkName(suggestName + SdkConfigurationUtil.PREDEFINED_PREFIX, SdkTable.getInstance().getAllSdks());

  return new SdkImpl(uniqueSdkName, sdkType);
}
项目:consulo    文件:PredefinedBundlesProvider.java   
@Nonnull
public SdkImpl createSdk(@Nonnull SdkType sdkType, @Nonnull String sdkHome) {
  return createSdkWithName(sdkType, sdkType.suggestSdkName(null, sdkHome));
}
项目:consulo    文件:SdkEditor.java   
public SdkEditor(@Nonnull SdkModel sdkModel, @Nonnull History history, @Nonnull SdkImpl sdk) {
  super(sdkModel, sdk);
  myHistory = history;
}
项目:consulo    文件:BaseSdkEditor.java   
public BaseSdkEditor(@Nonnull SdkModel sdkModel, @Nonnull SdkImpl sdk) {
  mySdkModel = sdkModel;
  mySdk = sdk;
  createMainPanel();
  initSdk(sdk);
}
项目:consulo    文件:BaseSdkEditor.java   
@Override
public void setName(String name) {
  ((SdkImpl)mySdk).setName(name);
}
项目:consulo    文件:SdkConfigurable.java   
protected BaseSdkEditor createSdkEditor(ProjectSdksModel sdksModel, History history, SdkImpl projectJdk) {
  return new SdkEditor(sdksModel, history, projectJdk);
}
项目:consulo-javascript    文件:ClientJavaScriptPredefinedBundlesProvider.java   
@Override
public void createBundles(@NotNull Consumer<SdkImpl> consumer)
{
    PluginClassLoader classLoader = (PluginClassLoader) getClass().getClassLoader();
    IdeaPluginDescriptor plugin = PluginManager.getPlugin(classLoader.getPluginId());
    assert plugin != null;
    File path = plugin.getPath();

    File sdkDir = new File(path, "sdk");
    if(!sdkDir.exists())
    {
        return;
    }

    for(File file : sdkDir.listFiles())
    {
        String name = ourMapping.get(file.getName());
        if(name == null)
        {
            continue;
        }

        VirtualFile fileByIoFile = LocalFileSystem.getInstance().findFileByIoFile(file);
        if(fileByIoFile == null)
        {
            continue;
        }
        SdkImpl sdk = createSdkWithName(ClientJavaScriptSdkType.getInstance(), name);
        sdk.setHomePath(fileByIoFile.getPath());
        sdk.setVersionString("1");

        SdkModificator sdkModificator = sdk.getSdkModificator();
        for(VirtualFile child : fileByIoFile.getChildren())
        {
            sdkModificator.addRoot(child, BinariesOrderRootType.getInstance());
            sdkModificator.addRoot(child, SourcesOrderRootType.getInstance());
        }
        sdkModificator.commitChanges();
        consumer.consume(sdk);
    }
}
项目:consulo    文件:PredefinedBundlesProvider.java   
public abstract void createBundles(@Nonnull Consumer<SdkImpl> consumer);