use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor in project azure-tools-for-java by Microsoft.
the class SparkLibraryDescription method getSparkSDKConfigurationFromLocalFile.
private NewLibraryConfiguration getSparkSDKConfigurationFromLocalFile() {
FileChooserDescriptor chooserDescriptor = new FileChooserDescriptor(false, false, true, false, true, false);
chooserDescriptor.setTitle("Select Spark SDK");
String pluginPath = PluginUtil.getPluginRootDirectory();
VirtualFile pluginVfs = LocalFileSystem.getInstance().findFileByPath(pluginPath);
VirtualFile chooseFile = FileChooser.chooseFile(chooserDescriptor, null, pluginVfs);
if (chooseFile == null) {
return null;
}
this.localPath = chooseFile.getPath();
final List<OrderRoot> roots = RootDetectionUtil.detectRoots(Arrays.asList(chooseFile), null, null, new DefaultLibraryRootsComponentDescriptor());
if (roots.isEmpty()) {
return null;
}
return new NewLibraryConfiguration(LibraryTypeServiceImpl.suggestLibraryName(roots), SparkLibraryType.getInstance(), new SparkLibraryProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor libraryEditor) {
libraryEditor.addRoots(roots);
}
};
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor in project intellij-community by JetBrains.
the class CustomLibraryDescriptionBase method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, false, true, false, false, true);
descriptor.setTitle(IdeBundle.message("new.library.file.chooser.title"));
descriptor.setDescription(IdeBundle.message("new.library.file.chooser.description"));
final VirtualFile[] files = FileChooser.chooseFiles(descriptor, parentComponent, null, contextDirectory);
if (files.length == 0) {
return null;
}
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
for (VirtualFile file : files) {
editor.addRoot(file, OrderRootType.CLASSES);
}
}
};
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor in project intellij-community by JetBrains.
the class LibraryOptionsPanel method doConfigure.
private void doConfigure() {
switch(myButtonEnumModel.getSelected()) {
case DOWNLOAD:
final LibraryDownloadSettings oldDownloadSettings = mySettings.getDownloadSettings();
LOG.assertTrue(oldDownloadSettings != null);
final LibraryDownloadSettings newDownloadSettings = DownloadingOptionsDialog.showDialog(myPanel, oldDownloadSettings, mySettings.getCompatibleVersions(), true);
if (newDownloadSettings != null) {
mySettings.setDownloadSettings(newDownloadSettings);
}
break;
case USE_LIBRARY:
final Object item = myExistingLibraryComboBox.getSelectedItem();
if (item instanceof LibraryEditor) {
EditLibraryDialog dialog = new EditLibraryDialog(myPanel, mySettings, (LibraryEditor) item);
dialog.show();
if (item instanceof ExistingLibraryEditor) {
new WriteAction() {
protected void run(@NotNull final Result result) {
((ExistingLibraryEditor) item).commit();
}
}.execute();
}
}
break;
case USE_FROM_PROVIDER:
case SETUP_LIBRARY_LATER:
break;
}
updateState();
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor in project android by JetBrains.
the class LibraryPropertiesDialog method createCenterPanel.
@Nullable
@Override
protected JComponent createCenterPanel() {
myIconLabel.setIcon(AllIcons.Modules.Library);
myNameLabel.setText(myLibrary.getName());
LibraryEditor editor = new SourcesAndDocsOnlyEditor(myLibrary);
myLibraryEditorComponent = new LibraryRootsComponent(myProject, editor) {
@Override
public void updatePropertiesLabel() {
JComponent c = getComponent();
if (c != null) {
MultiLineLabel propertiesLabel = findComponentOfType(c, MultiLineLabel.class);
if (propertiesLabel != null) {
propertiesLabel.setText("Add or remove source/Javadoc attachments");
}
}
}
};
myLibraryEditorComponent.updatePropertiesLabel();
JComponent c = myLibraryEditorComponent.getComponent();
// Remove "Exclude" button. We don't support this in libraries.
List<ActionButton> actionButtons = findComponentsOfType(c, ActionButton.class);
for (ActionButton actionButton : actionButtons) {
String text = actionButton.getAction().getTemplatePresentation().getText();
if (text != null && text.startsWith("Exclude")) {
actionButton.setVisible(false);
break;
}
}
MultiLineLabel propertiesLabel = findComponentOfType(c, MultiLineLabel.class);
if (propertiesLabel != null) {
propertiesLabel.setBorder(BorderFactory.createEmptyBorder(1, 1, 0, 1));
}
myTreePanel.add(c, BorderLayout.CENTER);
myTreePanel.setBorder(customLine(OnePixelDivider.BACKGROUND, 1, 1, 1, 1));
return myMainPanel;
}
use of com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor in project intellij-community by JetBrains.
the class GroovyLibraryDescription method createNewLibrary.
@Override
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, VirtualFile contextDirectory) {
VirtualFile initial = findFile(System.getenv(myEnvVariable));
if (initial == null && GROOVY_FRAMEWORK_NAME.equals(myFrameworkName) && SystemInfo.isLinux) {
initial = findFile("/usr/share/groovy");
}
final FileChooserDescriptor descriptor = new FileChooserDescriptor(false, true, false, false, false, false) {
@Override
public boolean isFileSelectable(VirtualFile file) {
if (!super.isFileSelectable(file)) {
return false;
}
return findManager(file) != null;
}
};
descriptor.setTitle(myFrameworkName + " SDK");
descriptor.setDescription("Choose a directory containing " + myFrameworkName + " distribution");
final VirtualFile dir = FileChooser.chooseFile(descriptor, parentComponent, null, initial);
if (dir == null)
return null;
final GroovyLibraryPresentationProviderBase provider = findManager(dir);
if (provider == null) {
return null;
}
final String path = dir.getPath();
final String sdkVersion = provider.getSDKVersion(path);
if (AbstractConfigUtils.UNDEFINED_VERSION.equals(sdkVersion)) {
Messages.showErrorDialog(parentComponent, "Looks like " + myFrameworkName + " distribution in specified path is broken. Cannot determine version.", "Failed to Create Library");
return null;
}
return new NewLibraryConfiguration(provider.getLibraryPrefix() + "-" + sdkVersion) {
@Override
public void addRoots(@NotNull LibraryEditor editor) {
provider.fillLibrary(path, editor);
}
};
}
Aggregations