Search in sources :

Example 1 with LibraryEditor

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);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) DefaultLibraryRootsComponentDescriptor(com.intellij.openapi.roots.ui.configuration.libraryEditor.DefaultLibraryRootsComponentDescriptor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) OrderRoot(com.intellij.openapi.roots.libraries.ui.OrderRoot) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration)

Example 2 with LibraryEditor

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);
            }
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration) LibraryVersionProperties(com.intellij.framework.library.LibraryVersionProperties)

Example 3 with LibraryEditor

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();
}
Also used : ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) NewLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) WriteAction(com.intellij.openapi.application.WriteAction) Result(com.intellij.openapi.application.Result)

Example 4 with LibraryEditor

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;
}
Also used : ExistingLibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) ActionButton(com.intellij.openapi.actionSystem.impl.ActionButton) LibraryRootsComponent(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryRootsComponent) MultiLineLabel(com.intellij.openapi.ui.ex.MultiLineLabel) Nullable(org.jetbrains.annotations.Nullable)

Example 5 with LibraryEditor

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);
        }
    };
}
Also used : VirtualFile(com.intellij.openapi.vfs.VirtualFile) LibraryEditor(com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor) FileChooserDescriptor(com.intellij.openapi.fileChooser.FileChooserDescriptor) NotNull(org.jetbrains.annotations.NotNull) NewLibraryConfiguration(com.intellij.openapi.roots.libraries.NewLibraryConfiguration)

Aggregations

LibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor)7 NotNull (org.jetbrains.annotations.NotNull)5 NewLibraryConfiguration (com.intellij.openapi.roots.libraries.NewLibraryConfiguration)4 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)3 ExistingLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.ExistingLibraryEditor)3 Result (com.intellij.openapi.application.Result)2 WriteAction (com.intellij.openapi.application.WriteAction)2 OrderRoot (com.intellij.openapi.roots.libraries.ui.OrderRoot)2 NewLibraryEditor (com.intellij.openapi.roots.ui.configuration.libraryEditor.NewLibraryEditor)2 List (java.util.List)2 Nullable (org.jetbrains.annotations.Nullable)2 DownloadableLibraryDescription (com.intellij.framework.library.DownloadableLibraryDescription)1 DownloadableLibraryType (com.intellij.framework.library.DownloadableLibraryType)1 FrameworkLibraryVersion (com.intellij.framework.library.FrameworkLibraryVersion)1 FrameworkLibraryVersionFilter (com.intellij.framework.library.FrameworkLibraryVersionFilter)1 LibraryVersionProperties (com.intellij.framework.library.LibraryVersionProperties)1 AllIcons (com.intellij.icons.AllIcons)1 IdeBundle (com.intellij.ide.IdeBundle)1 OldCustomLibraryDescription (com.intellij.ide.util.frameworkSupport.OldCustomLibraryDescription)1