com.intellij.openapi.projectRoots.SdkTypeId Java Examples

The following examples show how to use com.intellij.openapi.projectRoots.SdkTypeId. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SdkComboBox.java    From consulo with Apache License 2.0 5 votes vote down vote up
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());
    }
  };
}
 
Example #2
Source File: SdkComboBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SdkComboBox(@Nonnull BundleHolder sdksModel,
                   @Nullable Condition<SdkTypeId> filter,
                   @Nullable String nullItemName) {
  this(sdksModel, filter, filter, nullItemName, null);
}
 
Example #3
Source File: MockSdkWrapper.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
@Nonnull
public SdkTypeId getSdkType() {
  return myDelegate.getSdkType();
}
 
Example #4
Source File: BundleBoxBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public BundleBoxBuilder withSdkTypeFilter(@Nonnull Predicate<SdkTypeId> sdkFilter) {
  mySdkFilter = sdkFilter;
  return this;
}
 
Example #5
Source File: BundleBoxBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
public BundleBoxBuilder withSdkTypeFilterByClass(@Nonnull final Class<? extends SdkTypeId> clazz) {
  mySdkFilter = sdkTypeId -> clazz.isAssignableFrom(sdkTypeId.getClass());
  return this;
}
 
Example #6
Source File: BundleBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@RequiredUIAccess
private static ListModel<BundleBoxItem> model(@Nonnull BundleHolder holder, @Nullable Predicate<SdkTypeId> filter, String nullItemName) {
  return MutableListModel.create(buildItems(holder, filter, nullItemName != null));
}
 
Example #7
Source File: BundleBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public BundleBox(@Nonnull BundleHolder bundleHolder, @Nullable Predicate<SdkTypeId> filter, @Nullable final String nullItemName, @Nullable final Image nullIcon) {
  myOriginalComboBox = ComboBox.create(model(bundleHolder, filter, nullItemName));

  myOriginalComboBox.setRender((render, index, value) -> {
    if (value instanceof InvalidBundleBoxItem) {
      render.setIcon(AllIcons.Toolbar.Unknown);
      render.append(value.getBundleName(), TextAttribute.ERROR);
    }
    else if (value instanceof CustomBundleBoxItem) {
      render.setIcon(((CustomBundleBoxItem)value).getIcon());
      render.append(((CustomBundleBoxItem)value).getPresentableName());
    }
    else if (value instanceof ModuleExtensionBundleBoxItem) {
      ModuleExtensionBundleBoxItem extensionSdkComboBoxItem = (ModuleExtensionBundleBoxItem)value;
      render.setIcon(AllIcons.Nodes.Module);
      render.append(extensionSdkComboBoxItem.getModule().getName(), TextAttribute.REGULAR_BOLD);

      final String sdkName = extensionSdkComboBoxItem.getBundleName();
      if (sdkName != null) {
        render.append(" (" + extensionSdkComboBoxItem.getBundleName() + ")", TextAttribute.GRAYED);
      }
    }
    else if (value instanceof InvalidModuleBundleBoxItem) {
      render.setIcon(AllIcons.Nodes.Module);
      render.append(((InvalidModuleBundleBoxItem)value).getModuleName(), TextAttribute.ERROR_BOLD);
    }
    else if (value == null || value instanceof NullBundleBoxItem) {
      render.setIcon(ObjectUtil.notNull(nullIcon, AllIcons.Ide.EmptyFatalError));
      String name = ObjectUtil.notNull(nullItemName, ProjectBundle.message("sdk.combo.box.item"));
      render.append(name, TextAttribute.REGULAR);
    }
    else {
      Sdk sdk = value.getBundle();
      String sdkName = value.getBundleName();
      assert sdkName != null;
      render.setIcon(sdk == null ? AllIcons.Toolbar.Unknown : SdkUtil.getIcon(sdk));
      render.append(sdkName, sdk == null ? TextAttribute.ERROR : TextAttribute.REGULAR);
      String version = sdk == null ? null : sdk.getVersionString();
      if (version != null) {
        render.append(" (", TextAttribute.GRAY);
        render.append(version, TextAttribute.GRAY);
        render.append(")", TextAttribute.GRAY);
      }
    }
  });
}
 
Example #8
Source File: BundleBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public BundleBox(@Nonnull BundleHolder bundleHolder, @Nullable Predicate<SdkTypeId> filter, @Nullable String nullItemName) {
  this(bundleHolder, filter, nullItemName, null);
}
 
Example #9
Source File: BundleBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public BundleBox(@Nonnull BundleHolder bundleHolder, @Nullable Predicate<SdkTypeId> filter, boolean withNoneItem) {
  this(bundleHolder, filter, withNoneItem ? ProjectBundle.message("sdk.combo.box.item") : null, null);
}
 
Example #10
Source File: SdkComboBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SdkComboBox(@Nonnull BundleHolder sdksModel,
                   @Nullable Condition<SdkTypeId> filter,
                   @Nullable Condition<SdkTypeId> creationFilter,
                   @Nullable final String nullItemName,
                   @Nullable final Image nullIcon) {
  super(new SdkComboBoxModel(sdksModel, getSdkFilter(filter), nullItemName));
  myFilter = filter;
  myCreationFilter = creationFilter;
  setRenderer(new ColoredListCellRendererWrapper<SdkComboBoxItem>() {
    @Override
    public void doCustomize(JList list, SdkComboBoxItem value, int index, boolean selected, boolean hasFocus) {
      setIcon(Image.empty(16));    // to fix vertical size
      if (value instanceof InvalidSdkComboBoxItem) {
        setIcon(AllIcons.Toolbar.Unknown);
        append(value.getSdkName(), SimpleTextAttributes.ERROR_ATTRIBUTES);
      }
      else if (value instanceof CustomSdkComboBoxItem) {
        setIcon(((CustomSdkComboBoxItem)value).getIcon());
        append(((CustomSdkComboBoxItem)value).getPresentableName());
      }
      else if (value instanceof ModuleExtensionSdkComboBoxItem) {
        ModuleExtensionSdkComboBoxItem extensionSdkComboBoxItem = (ModuleExtensionSdkComboBoxItem)value;
        setIcon(AllIcons.Nodes.Module);
        append(extensionSdkComboBoxItem.getModule().getName(), SimpleTextAttributes.REGULAR_BOLD_ATTRIBUTES);

        final String sdkName = extensionSdkComboBoxItem.getSdkName();
        if (sdkName != null) {
          append(" (" + extensionSdkComboBoxItem.getSdkName() + ")", SimpleTextAttributes.GRAYED_ATTRIBUTES);
        }
      }
      else if (value instanceof InvalidModuleComboBoxItem) {
        setIcon(AllIcons.Nodes.Module);
        append(((InvalidModuleComboBoxItem)value).getModuleName(), SimpleTextAttributes.ERROR_BOLD_ATTRIBUTES);
      }
      else if (value == null || value instanceof NullSdkComboBoxItem) {
        setIcon(ObjectUtil.notNull(nullIcon, AllIcons.Ide.EmptyFatalError));
        String name = ObjectUtil.notNull(nullItemName, ProjectBundle.message("sdk.combo.box.item"));
        append(name, SimpleTextAttributes.REGULAR_ATTRIBUTES);
      }
      else {
        Sdk sdk = value.getSdk();
        String sdkName = value.getSdkName();
        assert sdkName != null;
        setIcon(sdk == null ? AllIcons.Toolbar.Unknown : SdkUtil.getIcon(sdk));
        append(sdkName, sdk == null ? SimpleTextAttributes.ERROR_ATTRIBUTES : SimpleTextAttributes.REGULAR_ATTRIBUTES);
        String version = sdk == null ? null : sdk.getVersionString();
        if (version != null) {
          append(" (", SimpleTextAttributes.GRAY_ATTRIBUTES);
          append(version, SimpleTextAttributes.GRAY_ATTRIBUTES);
          append(")", SimpleTextAttributes.GRAY_ATTRIBUTES);
        }
      }
    }
  });
}
 
Example #11
Source File: SdkComboBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SdkComboBox(@Nonnull BundleHolder sdksModel,
                   @Nullable Condition<SdkTypeId> filter,
                   @Nullable Condition<SdkTypeId> creationFilter,
                   @Nullable String nullItemName) {
  this(sdksModel, filter, creationFilter, nullItemName, null);
}
 
Example #12
Source File: SdkComboBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SdkComboBox(@Nonnull BundleHolder sdksModel,
                   @Nullable Condition<SdkTypeId> filter,
                   @Nullable Condition<SdkTypeId> creationFilter,
                   boolean withNoneItem) {
  this(sdksModel, filter, creationFilter, withNoneItem ? ProjectBundle.message("sdk.combo.box.item") : null, null);
}
 
Example #13
Source File: DubboPluginModuleBuilder.java    From intellij-idea-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
    return sdkType == JavaSdk.getInstance();
}
 
Example #14
Source File: SdkComboBox.java    From consulo with Apache License 2.0 4 votes vote down vote up
public SdkComboBox(@Nonnull BundleHolder sdksModel,
                   @Nullable Condition<SdkTypeId> filter,
                   boolean withNoneItem) {
  this(sdksModel, filter, filter, withNoneItem);
}
 
Example #15
Source File: ModuleExtensionBundleBoxBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@UsedInPlugin
public ModuleExtensionBundleBoxBuilder<T> sdkTypeClass(@Nonnull final Class<? extends SdkTypeId> clazz) {
  mySdkFilter = sdkTypeId -> clazz.isAssignableFrom(sdkTypeId.getClass());
  return this;
}
 
Example #16
Source File: ModuleExtensionSdkBoxBuilder.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
@UsedInPlugin
public ModuleExtensionSdkBoxBuilder<T> sdkTypeClass(@Nonnull final Class<? extends SdkTypeId> clazz) {
  mySdkFilter = sdkTypeId -> clazz.isAssignableFrom(sdkTypeId.getClass());
  return this;
}
 
Example #17
Source File: ModuleExtensionWithSdk.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Nonnull
Class<? extends SdkTypeId> getSdkTypeClass();
 
Example #18
Source File: AsposeMavenModuleBuilder.java    From Aspose.OCR-for-Java with MIT License 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
    return sdkType instanceof JavaSdkType;
}
 
Example #19
Source File: HaxeModuleBuilder.java    From intellij-haxe with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdk) {
  return sdk == HaxeSdkType.getInstance();
}
 
Example #20
Source File: SlingMavenModuleBuilder.java    From aem-ide-tooling-4-intellij with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdk) {
    return sdk == JavaSdk.getInstance();
}
 
Example #21
Source File: IdeaJdkHelper.java    From intellij with Apache License 2.0 4 votes vote down vote up
public static boolean isIdeaJdkType(SdkTypeId type) {
  return IdeaJdk.getInstance().equals(type);
}
 
Example #22
Source File: NutzBootModuleBuilder.java    From NutzCodeInsight with Apache License 2.0 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
    return sdkType == JavaSdk.getInstance();
}
 
Example #23
Source File: DuneProjectImportBuilder.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
@Override
public boolean isSuitableSdkType(SdkTypeId sdkType) {
    return sdkType == OCamlSdkType.getInstance();
}
 
Example #24
Source File: OCamlSdkForm.java    From reasonml-idea-plugin with MIT License 4 votes vote down vote up
public void createUIComponents(@NotNull Sdk sdk) {
    SdkTypeId sdkType = sdk.getSdkType();
    if (sdkType instanceof OCamlSdkType) {
        m_sdkVersion = sdk.getVersionString();
        m_data = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData();
        if (m_data != null) {
            c_version.setText("Current version is: " + m_data);

            c_forceVersion.setSelected(m_data.isForced());
            c_forceVersion.addItemListener(itemEvent -> c_forceValue.setEnabled(itemEvent.getStateChange() == ItemEvent.SELECTED));

            c_forceValue.setText(m_data.toString());
            c_forceValue.setEnabled(m_data.isForced());

            c_sdkHome.addBrowseFolderListener("Choose Sdk Home Directory: ", null, null, FileChooserDescriptorFactory.createSingleFolderDescriptor());

            c_download.addMouseListener(new MouseAdapter() {
                @Override
                public void mouseClicked(MouseEvent mouseEvent) {
                    OCamlSdkAdditionalData odkData = (OCamlSdkAdditionalData) sdk.getSdkAdditionalData();
                    if (odkData != null) {
                        // Download SDK from distribution site
                        LOG.debug("Download SDK", m_data.toString());
                        VirtualFileSystem fileSystem = LocalFileSystem.getInstance();
                        VirtualFile sdkHome = fileSystem.findFileByPath(c_sdkHome.getText().trim());
                        if (sdkHome != null) {
                            Task.WithResult<String, RuntimeException> download = new Task.WithResult<String, RuntimeException>(null, "Download SDK", false) {
                                @Override
                                protected String compute(@NotNull ProgressIndicator indicator) throws RuntimeException {
                                    new SdkDownloader(odkData.getMajor(), odkData.getMinor(), odkData.getPatch(), sdkHome).run(null, indicator);
                                    return sdkHome.getPath();
                                }
                            };
                            String path = ProgressManager.getInstance().run(download);
                            Notifications.Bus.notify(new ORNotification("SDK", "SDK " + odkData + " downloaded to " + path, NotificationType.INFORMATION));
                        }
                    }
                }
            });
        }
    }
}
 
Example #25
Source File: SettingsSdksModel.java    From consulo with Apache License 2.0 votes vote down vote up
void createAddActions(DefaultActionGroup group, final JComponent parent, final Consumer<Sdk> updateTree, @Nullable Condition<SdkTypeId> filter);