当前位置: 首页>>代码示例>>Java>>正文


Java SdkType类代码示例

本文整理汇总了Java中com.intellij.openapi.projectRoots.SdkType的典型用法代码示例。如果您正苦于以下问题:Java SdkType类的具体用法?Java SdkType怎么用?Java SdkType使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


SdkType类属于com.intellij.openapi.projectRoots包,在下文中一共展示了SdkType类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setJdk

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
protected void setJdk(@NotNull Project project) {
  JdkComboBox.JdkComboBoxItem selectedItem = myJdkComboBox.getSelectedItem();
  if (selectedItem instanceof JdkComboBox.SuggestedJdkItem) {
    SdkType type = ((JdkComboBox.SuggestedJdkItem)selectedItem).getSdkType();
    String path = ((JdkComboBox.SuggestedJdkItem)selectedItem).getPath();
    myModel.addSdk(type, path, sdk -> {
      myJdkComboBox.reloadModel(new JdkComboBox.ActualJdkComboBoxItem(sdk), project);
      myJdkComboBox.setSelectedJdk(sdk);
    });
  }
  try {
    myModel.apply();
  } catch (ConfigurationException e) {
    LOG.error(e);
  }
  ApplicationManager.getApplication().runWriteAction(() -> {
    ProjectRootManager.getInstance(project).setProjectSdk(myJdkComboBox.getSelectedJdk());
  });
}
 
开发者ID:medvector,项目名称:educational-plugin,代码行数:20,代码来源:EduIntellijCourseProjectGeneratorBase.java

示例2: fillList

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
public void fillList(final @Nullable SdkType type, final @Nullable Sdk[] globalSdks) {
  myListModel.clear();
  final Sdk[] jdks;
  if (myProject == null || myProject.isDefault()) {
    final Sdk[] allJdks = globalSdks != null ? globalSdks : ProjectJdkTable.getInstance().getAllJdks();
    jdks = getCompatibleJdks(type, Arrays.asList(allJdks));
  }
  else {
    final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(myProject).getProjectJdksModel();
    if (!projectJdksModel.isInitialized()){ //should be initialized
      projectJdksModel.reset(myProject);
    }
    final Collection<Sdk> collection = projectJdksModel.getProjectSdks().values();
    jdks = getCompatibleJdks(type, collection);
  }
  Arrays.sort(jdks, new Comparator<Sdk>() {
    public int compare(final Sdk o1, final Sdk o2) {
      return o1.getName().compareToIgnoreCase(o2.getName());
    }
  });
  for (Sdk jdk : jdks) {
    myListModel.addElement(jdk);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:JdkChooserPanel.java

示例3: createSdkOfType

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
protected static Sdk createSdkOfType(final SdkModel sdkModel,
                                final SdkType sdkType,
                                final Consumer<Sdk> sdkCreatedCallback) {
  final Ref<Sdk> result = new Ref<Sdk>(null);
  SdkConfigurationUtil.selectSdkHome(sdkType, new Consumer<String>() {
    @Override
    public void consume(final String home) {
      String newSdkName = SdkConfigurationUtil.createUniqueSdkName(sdkType, home, Arrays.asList(sdkModel.getSdks()));
      final ProjectJdkImpl newJdk = new ProjectJdkImpl(newSdkName, sdkType);
      newJdk.setHomePath(home);

      sdkCreatedCallback.consume(newJdk);
      result.set(newJdk);
    }
  });
  return result.get();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:18,代码来源:DependentSdkType.java

示例4: createCompositeDescriptor

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
  return new FileChooserDescriptor(sdkTypes[0].getHomeChooserDescriptor()) {
    @Override
    public void validateSelectedFiles(final VirtualFile[] files) throws Exception {
      if (files.length > 0) {
        for (SdkType type : sdkTypes) {
          if (type.isValidSdkHome(files[0].getPath())) {
            return;
          }
        }
      }
      String key = files.length > 0 && files[0].isDirectory() ? "sdk.configure.home.invalid.error" : "sdk.configure.home.file.invalid.error";
      throw new Exception(ProjectBundle.message(key, sdkTypes[0].getPresentableName()));
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:17,代码来源:SdkConfigurationUtil.java

示例5: createAndAddSDK

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
/**
 * 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
 * @return newly created SDK, or null.
 */
@Nullable
public static Sdk createAndAddSDK(final String path, SdkType sdkType) {
  VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
    @Override
    public VirtualFile compute() {
      return LocalFileSystem.getInstance().refreshAndFindFileByPath(path);
    }
  });
  if (sdkHome != null) {
    final Sdk newSdk = setupSdk(ProjectJdkTable.getInstance().getAllJdks(), sdkHome, sdkType, true, null, null);
    if (newSdk != null) {
      addSdk(newSdk);
    }
    return newSdk;
  }
  return null;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SdkConfigurationUtil.java

示例6: selectSdkHome

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
public static void selectSdkHome(@NotNull final SdkType sdkType, @NotNull final Consumer<String> consumer) {
  final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType);
    if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found");
    consumer.consume(sdk.getHomePath());
    return;
  }
  FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> chosen) {
      final String path = chosen.get(0).getPath();
      if (sdkType.isValidSdkHome(path)) {
        consumer.consume(path);
        return;
      }

      final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
      if (sdkType.isValidSdkHome(adjustedPath)) {
        consumer.consume(adjustedPath);
      }
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:25,代码来源:SdkConfigurationUtil.java

示例7: createCompositeDescriptor

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
  FileChooserDescriptor descriptor0 = sdkTypes[0].getHomeChooserDescriptor();
  FileChooserDescriptor descriptor = new FileChooserDescriptor(descriptor0.isChooseFiles(), descriptor0.isChooseFolders(),
                                                               descriptor0.isChooseJars(), descriptor0.isChooseJarsAsFiles(),
                                                               descriptor0.isChooseJarContents(), descriptor0.isChooseMultiple()) {

    @Override
    public void validateSelectedFiles(final VirtualFile[] files) throws Exception {
      if (files.length > 0) {
        for (SdkType type : sdkTypes) {
          if (type.isValidSdkHome(files[0].getPath())) {
            return;
          }
        }
      }
      String message = files.length > 0 && files[0].isDirectory()
                       ? ProjectBundle.message("sdk.configure.home.invalid.error", sdkTypes[0].getPresentableName())
                       : ProjectBundle.message("sdk.configure.home.file.invalid.error", sdkTypes[0].getPresentableName());
      throw new Exception(message);
    }
  };
  descriptor.setTitle(descriptor0.getTitle());
  return descriptor;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:SdkConfigurationUtil.java

示例8: selectSdkHome

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
public static void selectSdkHome(final SdkType sdkType, @NotNull final Consumer<String> consumer) {
  final FileChooserDescriptor descriptor = sdkType.getHomeChooserDescriptor();
  if (ApplicationManager.getApplication().isUnitTestMode()) {
    Sdk sdk = ProjectJdkTable.getInstance().findMostRecentSdkOfType(sdkType);
    if (sdk == null) throw new RuntimeException("No SDK of type " + sdkType + " found");
    consumer.consume(sdk.getHomePath());
    return;
  }
  FileChooser.chooseFiles(descriptor, null, getSuggestedSdkRoot(sdkType), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> chosen) {
      final String path = chosen.get(0).getPath();
      if (sdkType.isValidSdkHome(path)) {
        consumer.consume(path);
        return;
      }

      final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
      if (sdkType.isValidSdkHome(adjustedPath)) {
        consumer.consume(adjustedPath);
      }
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:25,代码来源:SdkConfigurationUtil.java

示例9: setUpJdk

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
@Override
protected void setUpJdk() {
  super.setUpJdk();
  new WriteAction() {
    protected void run(final Result result) {
      ProjectJdkTable table = ProjectJdkTable.getInstance();
      myPluginSdk = table.createSdk("IDEA plugin SDK", SdkType.findInstance(IdeaJdk.class));
      SdkModificator modificator = myPluginSdk.getSdkModificator();
      modificator.setSdkAdditionalData(new Sandbox(getSandboxPath(), getTestProjectJdk(), myPluginSdk));
      String rootPath = FileUtil.toSystemIndependentName(PathManager.getJarPathForClass(FileUtilRt.class));
      modificator.addRoot(LocalFileSystem.getInstance().refreshAndFindFileByPath(rootPath), OrderRootType.CLASSES);
      modificator.commitChanges();
      table.addJdk(myPluginSdk);
    }
  }.execute();
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:17,代码来源:PluginModuleCompilationTest.java

示例10: createCompositeDescriptor

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
private static FileChooserDescriptor createCompositeDescriptor(final SdkType... sdkTypes) {
  FileChooserDescriptor descriptor0 = sdkTypes[0].getHomeChooserDescriptor();
  FileChooserDescriptor descriptor =
    new FileChooserDescriptor(descriptor0.isChooseFiles(), descriptor0.isChooseFolders(), descriptor0.isChooseJars(),
                              descriptor0.isChooseJarsAsFiles(), descriptor0.isChooseJarContents(), descriptor0.isChooseMultiple()) {

      @Override
      public void validateSelectedFiles(final VirtualFile[] files) throws Exception {
        if (files.length > 0) {
          for (SdkType type : sdkTypes) {
            if (type.isValidSdkHome(files[0].getPath())) {
              return;
            }
          }
        }
        String message = files.length > 0 && files[0].isDirectory()
                         ? ProjectBundle.message("sdk.configure.home.invalid.error", sdkTypes[0].getPresentableName())
                         : ProjectBundle.message("sdk.configure.home.file.invalid.error", sdkTypes[0].getPresentableName());
        throw new Exception(message);
      }
    };
  descriptor.setTitle(descriptor0.getTitle());
  return descriptor;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:SdkConfigurationUtil.java

示例11: createAndAddSDK

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
/**
 * 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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:26,代码来源:SdkConfigurationUtil.java

示例12: selectSdkHome

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
public static void selectSdkHome(final SdkType sdkType, @Nonnull 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), new Consumer<List<VirtualFile>>() {
    @Override
    public void consume(final List<VirtualFile> chosen) {
      final String path = chosen.get(0).getPath();
      if (sdkType.isValidSdkHome(path)) {
        consumer.consume(path);
        return;
      }

      final String adjustedPath = sdkType.adjustSelectedSdkHome(path);
      if (sdkType.isValidSdkHome(adjustedPath)) {
        consumer.consume(adjustedPath);
      }
    }
  });
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:SdkConfigurationUtil.java

示例13: addSdkNode

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:25,代码来源:SdkListConfigurable.java

示例14: LuaSdkChooserPanel

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
public LuaSdkChooserPanel(final Project project) {
    myJdkChooser = new JdkChooserPanel(project);

    setLayout(new GridBagLayout());
    setBorder(BorderFactory.createEtchedBorder());

    final JLabel label = new JLabel(LuaBundle.message("sdk.chooser.luabinaries.prompt"));
    label.setUI(new MultiLineLabelUI());
    add(label, new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
            GridBagConstraints.HORIZONTAL, new Insets(8, 10, 8, 10), 0, 0));

    final JLabel jdkLabel = new JLabel(LuaBundle.message("sdk.chooser.select.sdk.prompt"));
    jdkLabel.setFont(UIUtil.getLabelFont().deriveFont(Font.BOLD));
    add(jdkLabel,
            new GridBagConstraints(0, GridBagConstraints.RELATIVE, 2, 1, 1.0, 0.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.NONE, new Insets(8, 10, 0, 10), 0, 0));

    add(myJdkChooser,
            new GridBagConstraints(0, GridBagConstraints.RELATIVE, 1, 1, 1.0, 1.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.BOTH, new Insets(2, 10, 10, 5), 0, 0));
    JButton configureButton = new JButton(LuaBundle.message("sdk.chooser.configure.button"));
    add(configureButton,
            new GridBagConstraints(1, GridBagConstraints.RELATIVE, 1, 1, 0.0, 1.0, GridBagConstraints.NORTHWEST,
                    GridBagConstraints.NONE, new Insets(2, 0, 10, 5), 0, 0));

    configureButton.addActionListener(new ActionListener() {
        public void actionPerformed(ActionEvent e) {
            myJdkChooser.editJdkTable();
        }
    });

    myJdkChooser.setAllowedJdkTypes(new SdkType[]{LuaSdkType.getInstance()});

    final Sdk selectedJdk = project == null ? null : ProjectRootManager.getInstance(project).getProjectSdk();

    myJdkChooser.fillList(LuaSdkType.getInstance(), null);
    if (selectedJdk != null) {
        myJdkChooser.selectJdk(selectedJdk);
    }
}
 
开发者ID:internetisalie,项目名称:lua-for-idea,代码行数:41,代码来源:LuaSdkChooserPanel.java

示例15: forJdk

import com.intellij.openapi.projectRoots.SdkType; //导入依赖的package包/类
@NotNull
@Override
public CellAppearanceEx forJdk(@Nullable final Sdk jdk, final boolean isInComboBox, final boolean selected, final boolean showVersion) {
  if (jdk == null) {
    return FileAppearanceService.getInstance().forInvalidUrl(NO_JDK);
  }

  String name = jdk.getName();
  CompositeAppearance appearance = new CompositeAppearance();
  SdkType sdkType = (SdkType)jdk.getSdkType();
  appearance.setIcon(sdkType.getIcon());
  SimpleTextAttributes attributes = getTextAttributes(sdkType.sdkHasValidPath(jdk), selected);
  CompositeAppearance.DequeEnd ending = appearance.getEnding();
  ending.addText(name, attributes);

  if (showVersion) {
    String versionString = jdk.getVersionString();
    if (versionString != null && !versionString.equals(name)) {
      SimpleTextAttributes textAttributes = isInComboBox && !selected ? SimpleTextAttributes.SYNTHETIC_ATTRIBUTES :
                                            SystemInfo.isMac && selected ? new SimpleTextAttributes(SimpleTextAttributes.STYLE_PLAIN, 
                                                                                                    Color.WHITE): SimpleTextAttributes.GRAY_ATTRIBUTES;
      ending.addComment(versionString, textAttributes);
    }
  }

  return ending.getAppearance();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:OrderEntryAppearanceServiceImpl.java


注:本文中的com.intellij.openapi.projectRoots.SdkType类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。