Java 类com.intellij.openapi.projectRoots.SdkTypeId 实例源码

项目:intellij-ce-playground    文件:PyTreeStructureProvider.java   
@Nullable
private static Sdk getPythonSdk(@NotNull AbstractTreeNode node) {
  if (node instanceof NamedLibraryElementNode) {
    final NamedLibraryElement value = ((NamedLibraryElementNode)node).getValue();
    if (value != null) {
      final LibraryOrSdkOrderEntry entry = value.getOrderEntry();
      if (entry instanceof JdkOrderEntry) {
        final Sdk sdk = ((JdkOrderEntry)entry).getJdk();
        final SdkTypeId type = sdk.getSdkType();
        if (type instanceof PythonSdkType) {
          return sdk;
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:PythonSdkUpdater.java   
public static void updateActiveSdks(@NotNull final Project project, final int delay) {
  final Set<Sdk> sdksToUpdate = new HashSet<Sdk>();
  for (Module module : ModuleManager.getInstance(project).getModules()) {
    final Sdk sdk = PythonSdkType.findPythonSdk(module);
    if (sdk != null) {
      final SdkTypeId sdkType = sdk.getSdkType();
      if (sdkType instanceof PythonSdkType) {
        sdksToUpdate.add(sdk);
      }
    }
  }

  // NOTE: everything is run later on the AWT thread
  if (!sdksToUpdate.isEmpty()) {
    updateSdks(project, delay, sdksToUpdate);
  }
}
项目:consulo-nodejs    文件:NodeJSConfigurationPanelBase.java   
@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();
}
项目:HotswapAgentIntelliJ    文件:HotswapAgentIntegration.java   
/**
 * @return cesta k JRE
 */
private String getJrePath()  //TODO: Udělat nějak eleganěnji. Například stahovat vždy cele JRE do alternativního adresáře
{
    SdkTypeId id = ProjectJdkTable.getInstance().getDefaultSdkType()  ;

    if ( id != null )
    {
        List<Sdk> sdk = ProjectJdkTable.getInstance().getSdksOfType(ProjectJdkTable.getInstance().getDefaultSdkType()) ;

        if ( ! sdk.isEmpty() )
        {
            return modifyForAlternativeJvm( sdk.get(0).getHomePath() + File.separatorChar ) ;
        }
    }

    return getPluginDescriptor().getPath().getAbsolutePath() + File.separatorChar + GITHUB_PROJECT + File.separatorChar ;
}
项目:consulo-java    文件:JavaSdkUtil.java   
@Contract("null, _ -> false")
public static boolean isJdkAtLeast(@Nullable Sdk jdk, @NotNull JavaSdkVersion expected)
{
    if(jdk != null)
    {
        SdkTypeId type = jdk.getSdkType();
        if(type instanceof JavaSdk)
        {
            JavaSdkVersion actual = ((JavaSdk) type).getVersion(jdk);
            if(actual != null)
            {
                return actual.isAtLeast(expected);
            }
        }
    }

    return false;
}
项目:consulo-java    文件:OwnJdkUtil.java   
public static GeneralCommandLine setupJVMCommandLine(@NotNull OwnSimpleJavaParameters javaParameters) throws CantRunException
{
    Sdk jdk = javaParameters.getJdk();
    if(jdk == null)
    {
        throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    }
    SdkTypeId type = jdk.getSdkType();
    if(!(type instanceof JavaSdkType))
    {
        throw new CantRunException(ExecutionBundle.message("run.configuration.error.no.jdk.specified"));
    }

    GeneralCommandLine commandLine = new GeneralCommandLine();
    ((JavaSdkType) type).setupCommandLine(commandLine, jdk);
    String exePath = commandLine.getExePath();
    if(exePath == null)
    {
        throw new CantRunException(ExecutionBundle.message("run.configuration.cannot.find.vm.executable"));
    }

    setupCommandLine(commandLine, javaParameters);
    return commandLine;
}
项目:intellij-ce-playground    文件:ProjectWizardTestCase.java   
protected Sdk createSdk(String name, SdkTypeId sdkType) {
  final Sdk sdk = ProjectJdkTable.getInstance().createSdk(name, sdkType);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    @Override
    public void run() {
      ProjectJdkTable.getInstance().addJdk(sdk);
    }
  });
  mySdks.add(sdk);
  return sdk;
}
项目:intellij-ce-playground    文件:JavaModuleType.java   
@Nullable
@Override
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
  return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId sdkType) {
      return moduleBuilder.isSuitableSdkType(sdkType);
    }
  });
}
项目:intellij-ce-playground    文件:JdkComboBox.java   
private static Condition<Sdk> getSdkFilter(@Nullable final Condition<SdkTypeId> filter) {
  return filter == null ? Conditions.<Sdk>alwaysTrue() : new Condition<Sdk>() {
    @Override
    public boolean value(Sdk sdk) {
      return filter.value(sdk.getSdkType());
    }
  };
}
项目:intellij-ce-playground    文件:JavaSettingsStep.java   
public JavaSettingsStep(@NotNull SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder, @NotNull Condition<SdkTypeId> sdkFilter) {
  super(settingsStep, moduleBuilder, sdkFilter);
  mySourcePath.setText(PropertiesComponent.getInstance().getValue(MODULE_SOURCE_ROOT_KEY, DEFAULT_MODULE_SOURCE_ROOT_PATH));
  myModuleBuilder = moduleBuilder;

  if (moduleBuilder instanceof JavaModuleBuilder) {
    addSourcePath(settingsStep);
  }
}
项目:intellij-ce-playground    文件:ProjectFromSourcesBuilderImpl.java   
@Override
public boolean isSuitableSdkType(final SdkTypeId sdkTypeId) {
  for (ProjectDescriptor projectDescriptor : getSelectedDescriptors()) {
    for (ModuleDescriptor moduleDescriptor : projectDescriptor.getModules()) {
      try {
        final ModuleType moduleType = getModuleType(moduleDescriptor);
        if (moduleType != null && !moduleType.createModuleBuilder().isSuitableSdkType(sdkTypeId)) return false;
      }
      catch (Exception ignore) {
      }
    }
  }
  return true;
}
项目:intellij-ce-playground    文件:SdkSettingsStep.java   
public SdkSettingsStep(SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder,
                         @NotNull Condition<SdkTypeId> sdkFilter) {

  this(settingsStep.getContext(), moduleBuilder, sdkFilter);
  if (!isEmpty()) {
    settingsStep.addSettingsField(getSdkFieldLabel(settingsStep.getContext().getProject()), myJdkPanel);
  }
}
项目:intellij-ce-playground    文件:SdkSettingsStep.java   
public SdkSettingsStep(WizardContext context,
                       @NotNull ModuleBuilder moduleBuilder,
                       @NotNull Condition<SdkTypeId> sdkFilter) {
  myModuleBuilder = moduleBuilder;

  myWizardContext = context;
  myModel = new ProjectSdksModel();
  Project project = myWizardContext.getProject();
  myModel.reset(project);

  myJdkComboBox = new JdkComboBox(myModel, sdkFilter);
  myJdkPanel = new JPanel(new BorderLayout(4, 0));

  final PropertiesComponent component = project == null ? PropertiesComponent.getInstance() : PropertiesComponent.getInstance(project);
  ModuleType moduleType = moduleBuilder.getModuleType();
  final String selectedJdkProperty = "jdk.selected." + (moduleType == null ? "" : moduleType.getId());
  myJdkComboBox.addActionListener(new ActionListener() {
    @Override
    public void actionPerformed(ActionEvent e) {
      Sdk jdk = myJdkComboBox.getSelectedJdk();
      if (jdk != null) {
        component.setValue(selectedJdkProperty, jdk.getName());
      }
      onSdkSelected(jdk);
    }
  });

  Sdk sdk = getPreselectedSdk(project, component.getValue(selectedJdkProperty), sdkFilter);
  myJdkComboBox.setSelectedJdk(sdk);

  JButton button = new JButton("Ne\u001Bw...");
  myJdkComboBox.setSetupButton(button, project, myModel,
                               project == null ? new JdkComboBox.NoneJdkComboBoxItem() : new JdkComboBox.ProjectJdkComboBoxItem(),
                               null,
                               false);

  myJdkPanel.add(myJdkComboBox);
  myJdkPanel.add(myJdkComboBox.getSetUpButton(), BorderLayout.EAST);
}
项目:intellij-ce-playground    文件:CoreProjectJdkTable.java   
@Override
public List<Sdk> getSdksOfType(SdkTypeId type) {
  List<Sdk> result = new ArrayList<Sdk>();
  synchronized (mySdks) {
    for (Sdk sdk : mySdks) {
      if (sdk.getSdkType() == type) {
        result.add(sdk);
      }
    }
  }
  return result;
}
项目:intellij-ce-playground    文件:NavBarPresentation.java   
@SuppressWarnings("MethodMayBeStatic")
@Nullable
public Icon getIcon(final Object object) {
  if (!NavBarModel.isValid(object)) return null;
  if (object instanceof Project) return AllIcons.Nodes.Project;
  if (object instanceof Module) return ModuleType.get(((Module)object)).getIcon();
  try {
    if (object instanceof PsiElement) {
      Icon icon = ApplicationManager.getApplication().runReadAction(new Computable<Icon>() {
        @Override
        public Icon compute() {
          return ((PsiElement)object).isValid() ? ((PsiElement)object).getIcon(0) : null;
        }
      });

      if (icon != null && (icon.getIconHeight() > 16 * 2 || icon.getIconWidth() > 16 * 2)) {
        icon = IconUtil.cropIcon(icon, 16 * 2, 16 * 2);
      }
      return icon;
    }
  }
  catch (IndexNotReadyException e) {
    return null;
  }
  if (object instanceof JdkOrderEntry) {
    final SdkTypeId sdkType = ((JdkOrderEntry)object).getJdk().getSdkType();
    return ((SdkType) sdkType).getIcon();
  }
  if (object instanceof LibraryOrderEntry) return AllIcons.Nodes.PpLibFolder;
  if (object instanceof ModuleOrderEntry) return ModuleType.get(((ModuleOrderEntry)object).getModule()).getIcon();
  return null;
}
项目:intellij-ce-playground    文件:PythonModuleBuilder.java   
@Override
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep) {
  return new SdkSettingsStep(settingsStep, this, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId id) {
      return PythonSdkType.getInstance() == id;
    }
  }) {
    @Override
    protected void onSdkSelected(Sdk sdk) {
      setSdk(sdk);
    }
  };
}
项目:intellij-ce-playground    文件:PyBuiltinCache.java   
@Nullable
public static PyFile getSkeletonFile(final @NotNull Project project, @NotNull Sdk sdk, @NotNull String name) {
  SdkTypeId sdkType = sdk.getSdkType();
  if (sdkType instanceof PythonSdkType) {
    // dig out the builtins file, create an instance based on it
    final String[] urls = sdk.getRootProvider().getUrls(PythonSdkType.BUILTIN_ROOT_TYPE);
    for (String url : urls) {
      if (url.contains(PythonSdkType.SKELETON_DIR_NAME)) {
        final String builtins_url = url + "/" + name;
        File builtins = new File(VfsUtilCore.urlToPath(builtins_url));
        if (builtins.isFile() && builtins.canRead()) {
          final VirtualFile builtins_vfile = LocalFileSystem.getInstance().findFileByIoFile(builtins);
          if (builtins_vfile != null) {
            final Ref<PyFile> result = Ref.create();
            ApplicationManager.getApplication().runReadAction(new Runnable() {
              @Override
              public void run() {
                PsiFile file = PsiManager.getInstance(project).findFile(builtins_vfile);
                if (file instanceof PyFile) {
                  result.set((PyFile)file);
                }
              }
            });
            return result.get();

          }
        }
      }
    }
  }
  return null;
}
项目:intellij-ce-playground    文件:AndroidModifiedSettingsStep.java   
AndroidModifiedSettingsStep(@NotNull final AndroidModuleBuilder builder, @NotNull SettingsStep settingsStep) {
  super(settingsStep, builder, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId sdkType) {
      return builder.isSuitableSdkType(sdkType);
    }
  });
  myBuilder = builder;
}
项目:intellij-ce-playground    文件:ChooseAndroidAndJavaSdkStep.java   
private void createUIComponents() {
  mySdksModel = new ProjectSdksModel();
  mySdksModel.reset(null);
  myJavaSdkCombo = new JdkComboBox(mySdksModel, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId id) {
      return JavaSdk.getInstance().equals(id);
    }
  });
}
项目:intellij-ce-playground    文件:AndroidSdkTypeNewProjectWizardTest.java   
private static AnAction getAddAction(ProjectSdksModel model) {
  DefaultActionGroup group = new DefaultActionGroup();
  model.createAddActions(group, new JPanel(), null, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId id) {
      return id == AndroidSdkType.getInstance();
    }
  });
  AnAction[] children = group.getChildren(null);
  assertEquals(1, children.length);
  return children[0];
}
项目:intellij    文件:AndroidSyncTest.java   
private void mockSdk(String targetHash, String sdkName) {
  SdkTypeId sdkType = mock(SdkTypeId.class);
  when(sdkType.getName()).thenReturn("Android SDK");
  Sdk sdk = mock(Sdk.class);
  when(sdk.getName()).thenReturn(sdkName);
  when(sdk.getSdkType()).thenReturn(sdkType);
  MockBlazeSdkProvider sdkProvider = (MockBlazeSdkProvider) BlazeSdkProvider.getInstance();
  sdkProvider.addSdk(targetHash, sdk);
}
项目:intellij-perl-plugin    文件:PerlModuleType.java   
@Nullable
public ModuleWizardStep modifyProjectTypeStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
    return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition() {
        @Override
        public boolean value(Object o) {
            return true;
        }

        public boolean value(SdkTypeId sdkType) {
            return moduleBuilder.isSuitableSdkType(sdkType);
        }
    });
}
项目:defrac-plugin-intellij    文件:DefracModifiedSettingsStep.java   
public DefracModifiedSettingsStep(final SettingsStep settingsStep, final DefracModuleBuilder moduleBuilder) {
  super(settingsStep, moduleBuilder, new Condition<SdkTypeId>() {
    @Override
    public boolean value(final SdkTypeId sdkTypeId) {
      return moduleBuilder.isSuitableSdkType(sdkTypeId);
    }
  });

  this.moduleBuilder = moduleBuilder;

  if(myJdkComboBox.getSelectedJdk() != null) {
    onSdkSelected(myJdkComboBox.getSelectedJdk());
  }
}
项目:tools-idea    文件:ProjectWizardTestCase.java   
protected Sdk createSdk(String name, SdkTypeId sdkType) {
  final Sdk sdk = ProjectJdkTable.getInstance().createSdk(name, sdkType);
  ApplicationManager.getApplication().runWriteAction(new Runnable() {
    public void run() {
      ProjectJdkTable.getInstance().addJdk(sdk);
    }
  });
  mySdks.add(sdk);
  return sdk;
}
项目:tools-idea    文件:JavaModuleType.java   
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep, @NotNull final ModuleBuilder moduleBuilder) {
  return ProjectWizardStepFactory.getInstance().createJavaSettingsStep(settingsStep, moduleBuilder, new Condition<SdkTypeId>() {
    @Override
    public boolean value(SdkTypeId sdkType) {
      return moduleBuilder.isSuitableSdkType(sdkType);
    }
  });
}
项目:tools-idea    文件:JdkComboBox.java   
private static Condition<Sdk> getSdkFilter(@Nullable final Condition<SdkTypeId> filter) {
  return filter == null ? Conditions.<Sdk>alwaysTrue() : new Condition<Sdk>() {
    @Override
    public boolean value(Sdk sdk) {
      return filter.value(sdk.getSdkType());
    }
  };
}
项目:tools-idea    文件:JavaSettingsStep.java   
public JavaSettingsStep(@NotNull SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder, @NotNull Condition<SdkTypeId> sdkFilter) {
  super(settingsStep, moduleBuilder, sdkFilter);
  mySourcePath.setText(PropertiesComponent.getInstance().getValue(MODULE_SOURCE_ROOT_KEY, DEFAULT_MODULE_SOURCE_ROOT_PATH));
  myModuleBuilder = moduleBuilder;

  if (moduleBuilder instanceof JavaModuleBuilder) {
    addSourcePath(settingsStep);
  }
}
项目:tools-idea    文件:ProjectFromSourcesBuilderImpl.java   
@Override
public boolean isSuitableSdkType(final SdkTypeId sdkTypeId) {
  for (ProjectDescriptor projectDescriptor : getSelectedDescriptors()) {
    for (ModuleDescriptor moduleDescriptor : projectDescriptor.getModules()) {
      try {
        final ModuleType moduleType = getModuleType(moduleDescriptor);
        if (moduleType != null && !moduleType.createModuleBuilder().isSuitableSdkType(sdkTypeId)) return false;
      }
      catch (Exception ignore) {
      }
    }
  }
  return true;
}
项目:tools-idea    文件:CoreProjectJdkTable.java   
@Override
public List<Sdk> getSdksOfType(SdkTypeId type) {
  List<Sdk> result = new ArrayList<Sdk>();
  synchronized (mySdks) {
    for (Sdk sdk : mySdks) {
      if (sdk.getSdkType() == type) {
        result.add(sdk);
      }
    }
  }
  return result;
}
项目:tools-idea    文件:NavBarPresentation.java   
@SuppressWarnings("MethodMayBeStatic")
@Nullable
public Icon getIcon(final Object object) {
  if (!NavBarModel.isValid(object)) return null;
  if (object instanceof Project) return AllIcons.Nodes.Project;
  if (object instanceof Module) return ModuleType.get(((Module)object)).getIcon();
  try {
    if (object instanceof PsiElement) {
      Icon icon = ApplicationManager.getApplication().runReadAction(new Computable<Icon>() {
        @Override
        public Icon compute() {
          return ((PsiElement)object).isValid() ? ((PsiElement)object).getIcon(0) : null;
        }
      });

      if (icon != null && (icon.getIconHeight() > 16 || icon.getIconWidth() > 16)) {
        icon = IconUtil.cropIcon(icon, 16, 16);
      }
      return icon;
    }
  }
  catch (IndexNotReadyException e) {
    return null;
  }
  if (object instanceof JdkOrderEntry) {
    final SdkTypeId sdkType = ((JdkOrderEntry)object).getJdk().getSdkType();
    return ((SdkType) sdkType).getIcon();
  }
  if (object instanceof LibraryOrderEntry) return AllIcons.Nodes.PpLibFolder;
  if (object instanceof ModuleOrderEntry) return ModuleType.get(((ModuleOrderEntry)object).getModule()).getIcon();
  return null;
}
项目:tools-idea    文件:MvcModuleBuilder.java   
@Nullable
@Override
public ModuleWizardStep modifySettingsStep(@NotNull SettingsStep settingsStep) {
  return new SdkSettingsStep(settingsStep, this, new Condition<SdkTypeId>() {
        @Override
        public boolean value(SdkTypeId sdkType) {
          return isSuitableSdkType(sdkType);
        }
      });
}
项目:consulo    文件:SdkComboBox.java   
private static Condition<Sdk> getSdkFilter(@Nullable final Condition<SdkTypeId> filter) {
  return filter == null ? Conditions.<Sdk>alwaysTrue() : new Condition<Sdk>() {
    @Override
    public boolean value(Sdk sdk) {
      return filter.value(sdk.getSdkType());
    }
  };
}
项目:consulo    文件:SdkTableImpl.java   
@Override
public List<Sdk> getSdksOfType(final SdkTypeId type) {
  List<Sdk> result = new ArrayList<Sdk>();
  final Sdk[] sdks = getAllSdks();
  for (Sdk sdk : sdks) {
    if (sdk.getSdkType() == type) {
      result.add(sdk);
    }
  }
  return result;
}
项目:consulo    文件:SdkTableImpl.java   
@Override
@Nullable
public Sdk findPredefinedSdkByType(@Nonnull SdkTypeId sdkType) {
  for (Sdk sdk : mySdks) {
    if (sdk.isPredefined() && sdk.getSdkType() == sdkType) {
      return sdk;
    }
  }
  return null;
}
项目:consulo    文件:SdkTableImpl.java   
public static SdkTypeId findSdkTypeByName(String sdkTypeName) {
  final SdkType[] allSdkTypes = SdkType.EP_NAME.getExtensions();
  for (final SdkType type : allSdkTypes) {
    if (type.getName().equals(sdkTypeName)) {
      return type;
    }
  }
  return UnknownSdkType.getInstance(sdkTypeName);
}
项目:lua-for-idea    文件:LuaModuleBuilder.java   
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
    return sdkType instanceof LuaSdkType;
}
项目:intellij-ce-playground    文件:JavaModuleBuilder.java   
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
  return sdkType instanceof JavaSdkType;
}
项目:intellij-ce-playground    文件:JavaAwareProjectJdkTableImpl.java   
@Override
public SdkTypeId getDefaultSdkType() {
  return myJavaSdk;
}
项目:intellij-ce-playground    文件:JdkComboBox.java   
public JdkComboBox(@NotNull final ProjectSdksModel jdkModel,
                   @Nullable Condition<SdkTypeId> filter) {
  this(jdkModel, filter, filter);
}
项目:intellij-ce-playground    文件:ProjectWizardStepFactoryImpl.java   
@Override
public ModuleWizardStep createJavaSettingsStep(@NotNull SettingsStep settingsStep, @NotNull ModuleBuilder moduleBuilder, @NotNull Condition<SdkTypeId> sdkFilter) {
 return new JavaSettingsStep(settingsStep, moduleBuilder, sdkFilter);
}