本文整理汇总了Java中com.intellij.openapi.projectRoots.Sdk.getName方法的典型用法代码示例。如果您正苦于以下问题:Java Sdk.getName方法的具体用法?Java Sdk.getName怎么用?Java Sdk.getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.openapi.projectRoots.Sdk
的用法示例。
在下文中一共展示了Sdk.getName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addDetectedSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的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.projectRoots.Sdk; //导入方法依赖的package包/类
private void reloadModel() {
myFreeze = true;
final Sdk projectJdk = myJdksModel.getProjectSdk();
myCbProjectJdk.reloadModel(new JdkComboBox.NoneJdkComboBoxItem(), myProject);
final String sdkName = projectJdk == null ? ProjectRootManager.getInstance(myProject).getProjectSdkName() : projectJdk.getName();
if (sdkName != null) {
final Sdk jdk = myJdksModel.findSdk(sdkName);
if (jdk != null) {
myCbProjectJdk.setSelectedJdk(jdk);
} else {
myCbProjectJdk.setInvalidJdk(sdkName);
clearCaches();
}
} else {
myCbProjectJdk.setSelectedJdk(null);
}
myFreeze = false;
}
示例3: jdkNameChanged
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void jdkNameChanged(final Sdk jdk, final String previousName) {
mergeRootsChangesDuring(new Runnable() {
@Override
public void run() {
for (ProjectJdkTable.Listener listener : getListeners()) {
listener.jdkNameChanged(jdk, previousName);
}
}
});
String currentName = getProjectSdkName();
if (previousName != null && previousName.equals(currentName)) {
// if already had jdk name and that name was the name of the jdk just changed
myProjectSdkName = jdk.getName();
myProjectSdkType = jdk.getSdkType().getName();
}
}
示例4: generateBuiltinSkeletons
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public void generateBuiltinSkeletons(@NotNull Sdk sdk) throws InvalidSdkException {
//noinspection ResultOfMethodCallIgnored
new File(mySkeletonsPath).mkdirs();
String binaryPath = sdk.getHomePath();
if (binaryPath == null) throw new InvalidSdkException("Broken home path for " + sdk.getName());
long startTime = System.currentTimeMillis();
final ProcessOutput runResult = getProcessOutput(
new File(binaryPath).getParent(),
new String[]{
binaryPath,
PythonHelpersLocator.getHelperPath(GENERATOR3),
"-d", mySkeletonsPath, // output dir
"-b", // for builtins
},
PythonSdkType.getVirtualEnvExtraEnv(binaryPath), MINUTE * 5
);
runResult.checkSuccess(LOG);
LOG.info("Rebuilding builtin skeletons took " + (System.currentTimeMillis() - startTime) + " ms");
}
示例5: forSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@NotNull
public synchronized PyPackageManager forSdk(Sdk sdk) {
final String name = sdk.getName();
PyPackageManagerImpl manager = myInstances.get(name);
if (manager == null) {
if (PythonSdkType.isRemote(sdk)) {
manager = new PyRemotePackageManagerImpl(sdk);
}
else if (PyCondaPackageManagerImpl.isCondaVEnv(sdk) && PyCondaPackageService.getCondaExecutable() != null) {
manager = new PyCondaPackageManagerImpl(sdk);
}
else {
manager = new PyPackageManagerImpl(sdk);
}
myInstances.put(name, manager);
}
return manager;
}
示例6: isDuplicateSdkName
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private boolean isDuplicateSdkName(String s, Sdk sdk) {
for (Sdk existingSdk : myProjectSdksModel.getSdks()) {
if (existingSdk == sdk) {
continue;
}
String existingName;
if (myModificators.containsKey(existingSdk)) {
existingName = myModificators.get(existingSdk).getName();
}
else {
existingName = existingSdk.getName();
}
if (existingName.equals(s)) {
return true;
}
}
return false;
}
示例7: init
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public void init(@Nullable Sdk jdk, Sdk androidSdk, IAndroidTarget buildTarget) {
updateJdks();
final String jdkName = jdk != null ? jdk.getName() : null;
if (androidSdk != null) {
for (int i = 0; i < myJdksModel.getSize(); i++) {
if (Comparing.strEqual(((Sdk)myJdksModel.getElementAt(i)).getName(), jdkName)) {
myInternalJdkComboBox.setSelectedIndex(i);
break;
}
}
}
mySdkLocation = androidSdk != null ? androidSdk.getHomePath() : null;
AndroidSdkData androidSdkData = mySdkLocation != null ? AndroidSdkData.getSdkData(mySdkLocation) : null;
myFreeze = true;
updateBuildTargets(androidSdkData, buildTarget);
myFreeze = false;
}
示例8: getState
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
public RunProfileState getState(@NotNull final Executor executor, @NotNull final ExecutionEnvironment env) throws ExecutionException {
LuaCommandLineState state = null;
Sdk sdk = getSdk();
final boolean isDebugger = executor.getId().equals(DefaultDebugExecutor.EXECUTOR_ID);
if(sdk != null && sdk.getSdkType() instanceof LuaSdkType) {
if (sdk.getName().equals(KahluaSdk.NAME)) {
state = new KahluaCommandLineState(this, env);
}
else if (sdk.getName().equals(LuaJSdk.NAME)) {
state = new LuaJExternalCommandLineState(this, env);
}
if ((state != null) && isDebugger)
throw new ExecutionException("Debugging not supported for SDK " + sdk.getName() + ". Please configure a real Lua SDK.");
}
if (state == null) {
if (isDebugger)
state = new LuaDebugCommandlineState(this, env);
else
state = new LuaCommandLineState(this, env);
}
TextConsoleBuilder textConsoleBuilder = new LuaTextConsoleBuilder(getProject());
textConsoleBuilder.addFilter(new LuaLineErrorFilter(getProject()));
state.setConsoleBuilder(textConsoleBuilder);
return state;
}
示例9: forJdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的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();
}
示例10: getProjectSdkName
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的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;
}
}
示例11: setProjectSdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void setProjectSdk(Sdk sdk) {
ApplicationManager.getApplication().assertWriteAccessAllowed();
if (sdk == null) {
myProjectSdkName = null;
myProjectSdkType = null;
}
else {
myProjectSdkName = sdk.getName();
myProjectSdkType = sdk.getSdkType().getName();
}
projectJdkChanged();
}
示例12: getJdkName
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
@Nullable
public String getJdkName() {
if (myJdkName != null) return myJdkName;
Sdk jdk = getJdk();
if (jdk != null) {
return jdk.getName();
}
return null;
}
示例13: configureJdk
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
private static void configureJdk(Element cfg, @NotNull Module module) {
String jdkName = cfg.getChildTextTrim("jdkName");
if (StringUtil.isEmptyOrSpaces(jdkName)) return;
ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
String currentSdkName = null;
Sdk sdk = rootManager.getSdk();
if (sdk != null) {
currentSdkName = sdk.getName();
}
if (!jdkName.equals(currentSdkName)) {
ModifiableRootModel model = rootManager.getModifiableModel();
if (jdkName.equals(ProjectRootManager.getInstance(model.getProject()).getProjectSdkName())) {
model.inheritSdk();
}
else {
Sdk jdk = ProjectJdkTable.getInstance().findJdk(jdkName);
if (jdk != null) {
model.setSdk(jdk);
}
else {
model.setInvalidSdk(jdkName, JavaSdk.getInstance().getName());
}
}
model.commit();
}
}
示例14: customize
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void customize(JList list, Object item, int index, boolean selected, boolean hasFocus) {
if (item instanceof Sdk) {
Sdk sdk = (Sdk)item;
final PythonSdkFlavor flavor = PythonSdkFlavor.getPlatformIndependentFlavor(sdk.getHomePath());
final Icon icon = flavor != null ? flavor.getIcon() : ((SdkType)sdk.getSdkType()).getIcon();
String name;
if (mySdkModifiers != null && mySdkModifiers.containsKey(sdk)) {
name = mySdkModifiers.get(sdk).getName();
}
else {
name = sdk.getName();
}
if (name.startsWith("Remote")) {
final String trimmedRemote = StringUtil.trim(name.substring("Remote".length()));
if (!trimmedRemote.isEmpty())
name = trimmedRemote;
}
final String flavorName = flavor == null ? "Python" : flavor.getName();
if (name.startsWith(flavorName)) name = StringUtil.trim(name.substring(flavorName.length()));
if (isShortVersion){
name = shortenName(name);
}
if (PythonSdkType.isInvalid(sdk)) {
setText("[invalid] " + name);
setIcon(wrapIconWithWarningDecorator(icon));
}
else if (PythonSdkType.isIncompleteRemote(sdk)) {
setText("[incomplete] " + name);
setIcon(wrapIconWithWarningDecorator(icon));
}
else if (PythonSdkType.hasInvalidRemoteCredentials(sdk)) {
setText("[invalid] " + name);
setIcon(wrapIconWithWarningDecorator(icon));
}
else if (sdk instanceof PyDetectedSdk) {
setText(name);
setIcon(IconLoader.getTransparentIcon(icon));
}
else {
setText(name);
setIcon(icon);
}
}
else if (SEPARATOR.equals(item))
setSeparator();
else if (item == null)
setText(myNullText);
}
示例15: consume
import com.intellij.openapi.projectRoots.Sdk; //导入方法依赖的package包/类
@Override
public void consume(@Nullable ProjectSettingsStepBase step) {
if (!(step instanceof ProjectSpecificSettingsStep)) return;
final ProjectSpecificSettingsStep settingsStep = (ProjectSpecificSettingsStep)step;
Sdk sdk = settingsStep.getSdk();
final Project project = ProjectManager.getInstance().getDefaultProject();
final ProjectSdksModel model = PyConfigurableInterpreterList.getInstance(project).getModel();
if (sdk instanceof PyDetectedSdk) {
final String name = sdk.getName();
VirtualFile sdkHome = ApplicationManager.getApplication().runWriteAction(new Computable<VirtualFile>() {
@Override
public VirtualFile compute() {
return LocalFileSystem.getInstance().refreshAndFindFileByPath(name);
}
});
PySdkService.getInstance().solidifySdk(sdk);
sdk = SdkConfigurationUtil.createAndAddSDK(sdkHome.getPath(), PythonSdkType.getInstance());
if (sdk != null) {
PythonSdkType.getInstance().setupSdkPathsImmediately(sdk, project);
}
model.addSdk(sdk);
settingsStep.setSdk(sdk);
try {
model.apply();
}
catch (ConfigurationException exception) {
LOG.error("Error adding detected python interpreter " + exception.getMessage());
}
}
Project newProject = generateProject(project, settingsStep);
if (newProject != null) {
SdkConfigurationUtil.setDirectoryProjectSdk(newProject, sdk);
final List<Sdk> sdks = PythonSdkType.getAllSdks();
for (Sdk s : sdks) {
final SdkAdditionalData additionalData = s.getSdkAdditionalData();
if (additionalData instanceof PythonSdkAdditionalData) {
((PythonSdkAdditionalData)additionalData).reassociateWithCreatedProject(newProject);
}
}
}
}