本文整理汇总了Java中com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel类的典型用法代码示例。如果您正苦于以下问题:Java ProjectSdksModel类的具体用法?Java ProjectSdksModel怎么用?Java ProjectSdksModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ProjectSdksModel类属于com.intellij.openapi.roots.ui.configuration.projectRoot包,在下文中一共展示了ProjectSdksModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDetectedSdk
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
private static Sdk addDetectedSdk(@NotNull Sdk sdk, @NotNull Project project) {
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
final String name = sdk.getName();
VirtualFile sdkHome = WriteAction.compute(() -> LocalFileSystem.getInstance().refreshAndFindFileByPath(name));
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkUpdater.updateOrShowError(sdk, null, project, null);
}
model.addSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
return sdk;
}
示例2: reloadModel
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public void reloadModel(JdkComboBoxItem firstItem, @Nullable Project project) {
final DefaultComboBoxModel model = ((DefaultComboBoxModel)getModel());
if (project == null) {
model.addElement(firstItem);
return;
}
model.removeAllElements();
model.addElement(firstItem);
final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(project).getProjectJdksModel();
List<Sdk> projectJdks = new ArrayList<Sdk>(projectJdksModel.getProjectSdks().values());
if (myFilter != null) {
projectJdks = ContainerUtil.filter(projectJdks, getSdkFilter(myFilter));
}
Collections.sort(projectJdks, new Comparator<Sdk>() {
@Override
public int compare(final Sdk o1, final Sdk o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
for (Sdk projectJdk : projectJdks) {
model.addElement(new JdkComboBox.JdkComboBoxItem(projectJdk));
}
}
示例3: JdkComboBoxModel
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public JdkComboBoxModel(final ProjectSdksModel jdksModel, Condition<Sdk> sdkFilter) {
Sdk[] jdks = jdksModel.getSdks();
if (sdkFilter != null) {
final List<Sdk> filtered = ContainerUtil.filter(jdks, sdkFilter);
jdks = filtered.toArray(new Sdk[filtered.size()]);
}
Arrays.sort(jdks, new Comparator<Sdk>() {
@Override
public int compare(final Sdk s1, final Sdk s2) {
return s1.getName().compareToIgnoreCase(s2.getName());
}
});
for (Sdk jdk : jdks) {
addElement(new JdkComboBoxItem(jdk));
}
}
示例4: ProjectConfigurable
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public ProjectConfigurable(Project project,
final StructureConfigurableContext context,
ModulesConfigurator configurator,
ProjectSdksModel model) {
myProject = project;
myContext = context;
myModulesConfigurator = configurator;
mySettingsElement = new GeneralProjectSettingsElement(context);
final ProjectStructureDaemonAnalyzer daemonAnalyzer = context.getDaemonAnalyzer();
myModulesConfigurator.addAllModuleChangeListener(new ModuleEditor.ChangeListener() {
@Override
public void moduleStateChanged(ModifiableRootModel moduleRootModel) {
daemonAnalyzer.queueUpdate(mySettingsElement);
}
});
init(model);
}
示例5: fillList
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的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);
}
}
示例6: showOptions
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
private void showOptions(final Project project) {
final PyConfigurableInterpreterList interpreterList = PyConfigurableInterpreterList.getInstance(project);
final Sdk[] sdks = interpreterList.getModel().getSdks();
PythonSdkDetailsStep.show(project, sdks, null, this, getButton().getLocationOnScreen(), new NullableConsumer<Sdk>() {
@Override
public void consume(@Nullable Sdk sdk) {
if (sdk == null) return;
final PySdkService sdkService = PySdkService.getInstance();
sdkService.restoreSdk(sdk);
final ProjectSdksModel projectSdksModel = interpreterList.getModel();
if (projectSdksModel.findSdk(sdk) == null) {
projectSdksModel.addSdk(sdk);
try {
projectSdksModel.apply();
}
catch (ConfigurationException e) {
LOG.error("Error adding new python interpreter " + e.getMessage());
}
}
//noinspection unchecked
getComboBox().setModel(new CollectionComboBoxModel(interpreterList.getAllPythonSdks(), sdk));
}
}, true);
}
示例7: testSatisfied
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public void testSatisfied() throws Exception {
ProjectSdksModel model = new ProjectSdksModel();
model.addSdk(IdeaTestUtil.getMockJdk17());
ProjectJdkTable jdkTable = ProjectJdkTable.getInstance();
Sdk sdk = jdkTable.createSdk("a", AndroidSdkType.getInstance());
mySdks.add(sdk);
jdkTable.addJdk(sdk);
AnAction action = getAddAction(model);
try {
action.actionPerformed(new TestActionEvent(action));
fail("Exception should be thrown");
}
catch (Exception e) {
assertEquals(AndroidBundle.message("cannot.parse.sdk.error"), e.getMessage());
}
}
示例8: BlazeIntellijPluginConfigurationSettingsEditor
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public BlazeIntellijPluginConfigurationSettingsEditor(
Iterable<Label> javaLabels,
RunConfigurationStateEditor blazeFlagsEditor,
RunConfigurationStateEditor exeFlagsEditor) {
targetCombo =
new ComboBox<>(
new DefaultComboBoxModel<>(
Ordering.usingToString().sortedCopy(javaLabels).toArray(new Label[0])));
targetCombo.setRenderer(
new ListCellRendererWrapper<Label>() {
@Override
public void customize(
JList list, @Nullable Label value, int index, boolean selected, boolean hasFocus) {
setText(value == null ? null : value.toString());
}
});
this.blazeFlagsEditor = blazeFlagsEditor;
this.exeFlagsEditor = exeFlagsEditor;
ProjectSdksModel sdksModel = new ProjectSdksModel();
sdksModel.reset(null);
sdkCombo = new JdkComboBox(sdksModel, IdeaJdkHelper::isIdeaJdkType);
keepInSyncCheckBox = new JBCheckBox("Keep in sync with source XML");
keepInSyncCheckBox.addItemListener(e -> updateEnabledStatus());
}
示例9: initComponents
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
@Override
protected void initComponents()
{
myModuleBox = new ComboBox();
myModuleBox.setRenderer(new ModuleListCellRenderer());
myVmParametersComponent = LabeledComponent.create(new RawCommandLineEditor(), "VM arguments");
myVmParametersComponent.setLabelLocation(BorderLayout.WEST);
copyDialogCaption(myVmParametersComponent);
myUseAlternativeBundleCheckBox = new JCheckBox("Use alternative bundle: ");
ProjectSdksModel projectSdksModel = new ProjectSdksModel();
projectSdksModel.reset();
myAlternativeBundleComboBox = new SdkComboBox(projectSdksModel, Conditions.<SdkTypeId>is(NodeJSBundleType.getInstance()), true);
myAlternativeBundleComboBox.setEnabled(false);
myUseAlternativeBundleCheckBox.addItemListener(new ItemListener()
{
@Override
public void itemStateChanged(ItemEvent e)
{
myAlternativeBundleComboBox.setEnabled(myUseAlternativeBundleCheckBox.isSelected());
}
});
super.initComponents();
}
示例10: createEditor
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
@NotNull
@Override
protected JComponent createEditor()
{
JPanel verticalLayout = new JPanel(new VerticalFlowLayout(0, 0));
ProjectSdksModel model = new ProjectSdksModel();
model.reset();
myBundleBox = new SdkComboBox(model, Conditions.equalTo(myBundleType), true);
verticalLayout.add(LabeledComponent.left(myBundleBox, J2EEBundle.message("label.run.configuration.properties.application.server")));
JPanel openBrowserPanel = new JPanel();
openBrowserPanel.setBorder(IdeBorderFactory.createTitledBorder("Open browser"));
verticalLayout.add(openBrowserPanel);
if(myBundleType.isJreCustomizable())
{
AlternativeJREPanel panel = new AlternativeJREPanel();
verticalLayout.add(panel);
}
verticalLayout.add(mySettingsWrapper);
return verticalLayout;
}
示例11: reloadModel
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public void reloadModel(SdkComboBoxItem firstItem, @Nullable Project project) {
final DefaultComboBoxModel model = ((DefaultComboBoxModel)getModel());
if (project == null) {
model.addElement(firstItem);
return;
}
model.removeAllElements();
model.addElement(firstItem);
final ProjectSdksModel projectSdksModel = ProjectStructureConfigurable.getInstance(project).getProjectSdksModel();
List<Sdk> sdks = new ArrayList<Sdk>(projectSdksModel.getProjectSdks().values());
if (myFilter != null) {
sdks = ContainerUtil.filter(sdks, getSdkFilter(myFilter));
}
Collections.sort(sdks, new Comparator<Sdk>() {
@Override
public int compare(final Sdk o1, final Sdk o2) {
return o1.getName().compareToIgnoreCase(o2.getName());
}
});
for (Sdk sdk : sdks) {
model.addElement(new SdkComboBoxItem(sdk));
}
}
示例12: createAndAddVirtualEnv
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public void createAndAddVirtualEnv(Project project, PyNewProjectSettings settings) {
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
Course course = StudyTaskManager.getInstance(project).getCourse();
if (course == null) {
return;
}
final String baseSdk = getBaseSdk(course);
if (baseSdk != null) {
final PyPackageManager packageManager = PyPackageManager.getInstance(new PyDetectedSdk(baseSdk));
try {
final String path = packageManager.createVirtualEnv(project.getBasePath() + "/.idea/VirtualEnvironment", false);
AbstractCreateVirtualEnvDialog.setupVirtualEnvSdk(path, true, new AbstractCreateVirtualEnvDialog.VirtualEnvCallback() {
@Override
public void virtualEnvCreated(Sdk createdSdk, boolean associateWithProject) {
settings.setSdk(createdSdk);
model.addSdk(createdSdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding created virtual env " + exception.getMessage());
}
if (associateWithProject) {
SdkAdditionalData additionalData = createdSdk.getSdkAdditionalData();
if (additionalData == null) {
additionalData = new PythonSdkAdditionalData(PythonSdkFlavor.getFlavor(createdSdk.getHomePath()));
((ProjectJdkImpl)createdSdk).setSdkAdditionalData(additionalData);
}
((PythonSdkAdditionalData)additionalData).associateWithNewProject();
}
}
});
}
catch (ExecutionException e) {
LOG.warn("Failed to create virtual env " + e.getMessage());
}
}
}
示例13: setSetupButton
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public void setSetupButton(final JButton setUpButton,
@Nullable final Project project,
final ProjectSdksModel jdksModel,
final JdkComboBoxItem firstItem,
@Nullable final Condition<Sdk> additionalSetup,
final boolean moduleJdkSetup) {
setSetupButton(setUpButton, project, jdksModel, firstItem, additionalSetup,
ProjectBundle.message("project.roots.set.up.jdk.title", moduleJdkSetup ? 1 : 2));
}
示例14: getProjectSdkName
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
@Override
@Nullable
public String getProjectSdkName(final Project project) {
final String projectJdkName = ProjectRootManager.getInstance(project).getProjectSdkName();
final Sdk projectJdk = getProjectSdk(project);
if (projectJdk != null) {
return projectJdk.getName();
}
else {
final ProjectSdksModel projectJdksModel = ProjectStructureConfigurable.getInstance(project).getProjectJdksModel();
return projectJdksModel.findSdk(projectJdkName) == null ? projectJdkName : null;
}
}
示例15: ProjectJdksConfigurable
import com.intellij.openapi.roots.ui.configuration.projectRoot.ProjectSdksModel; //导入依赖的package包/类
public ProjectJdksConfigurable(Project project, ProjectSdksModel sdksModel) {
myProject = project;
myProjectJdksModel = sdksModel;
initTree();
myToReInitWholePanel = true;
reInitWholePanelIfNeeded();
}