mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
downloadable libraries: set library type for library created from files
This commit is contained in:
@@ -252,7 +252,7 @@ public class LibraryOptionsPanel implements Disposable {
|
||||
private void doCreate() {
|
||||
final NewLibraryConfiguration libraryConfiguration = mySettings.getLibraryDescription().createNewLibrary(myPanel, getBaseDirectory());
|
||||
if (libraryConfiguration != null) {
|
||||
final NewLibraryEditor libraryEditor = new NewLibraryEditor();
|
||||
final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties());
|
||||
libraryEditor.setName(myLibrariesContainer.suggestUniqueLibraryName(libraryConfiguration.getDefaultLibraryName()));
|
||||
libraryConfiguration.addRoots(libraryEditor);
|
||||
if (myLibraryComboBoxModel.get(0) == null) {
|
||||
|
||||
@@ -57,6 +57,7 @@ public class DownloadableLibraryEditor extends LibraryPropertiesEditor {
|
||||
myLibraryType = libraryType;
|
||||
updateDescription();
|
||||
myCurrentVersionString = myEditorComponent.getProperties().getVersionString();
|
||||
myChangeVersionButton.setVisible(!myEditorComponent.isNewLibrary());
|
||||
myChangeVersionButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
|
||||
+2
-1
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.intellij.ide.util.frameworkSupport;
|
||||
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.ide.IdeBundle;
|
||||
import com.intellij.openapi.fileChooser.FileChooser;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
@@ -46,7 +47,7 @@ public abstract class CustomLibraryDescriptionBase extends CustomLibraryDescript
|
||||
if (files.length == 0) {
|
||||
return null;
|
||||
}
|
||||
return new NewLibraryConfiguration(myDefaultLibraryName) {
|
||||
return new NewLibraryConfiguration(myDefaultLibraryName, getDownloadableLibraryType(), new LibraryVersionProperties()) {
|
||||
@Override
|
||||
public void addRoots(@NotNull LibraryEditor editor) {
|
||||
for (VirtualFile file : files) {
|
||||
|
||||
+1
@@ -17,6 +17,7 @@ package com.intellij.ide.util.frameworkSupport;
|
||||
|
||||
import com.intellij.framework.library.DownloadableLibraryDescription;
|
||||
import com.intellij.framework.library.DownloadableLibraryType;
|
||||
import com.intellij.framework.library.LibraryVersionProperties;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.LibraryFilter;
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ public class CreateCustomLibraryAction extends CustomLibraryActionBase {
|
||||
return;
|
||||
}
|
||||
|
||||
final NewLibraryEditor libraryEditor = new NewLibraryEditor();
|
||||
final NewLibraryEditor libraryEditor = new NewLibraryEditor(libraryConfiguration.getLibraryType(), libraryConfiguration.getProperties());
|
||||
libraryEditor.setName(libraryConfiguration.getDefaultLibraryName());
|
||||
libraryConfiguration.addRoots(libraryEditor);
|
||||
LibraryTablesRegistrar registrar = LibraryTablesRegistrar.getInstance();
|
||||
|
||||
+21
-2
@@ -15,17 +15,36 @@
|
||||
*/
|
||||
package com.intellij.openapi.roots.ui.configuration.libraries;
|
||||
|
||||
import com.intellij.openapi.roots.libraries.LibraryProperties;
|
||||
import com.intellij.openapi.roots.libraries.LibraryType;
|
||||
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public abstract class NewLibraryConfiguration {
|
||||
private String myDefaultLibraryName;
|
||||
private final String myDefaultLibraryName;
|
||||
private final LibraryType<?> myLibraryType;
|
||||
private final LibraryProperties myProperties;
|
||||
|
||||
protected NewLibraryConfiguration(String defaultLibraryName) {
|
||||
protected NewLibraryConfiguration(@NotNull String defaultLibraryName) {
|
||||
this(defaultLibraryName, null, null);
|
||||
}
|
||||
|
||||
protected <P extends LibraryProperties> NewLibraryConfiguration(@NotNull String defaultLibraryName, @Nullable LibraryType<P> libraryType, @Nullable P properties) {
|
||||
myDefaultLibraryName = defaultLibraryName;
|
||||
myLibraryType = libraryType;
|
||||
myProperties = properties;
|
||||
}
|
||||
|
||||
public LibraryType<?> getLibraryType() {
|
||||
return myLibraryType;
|
||||
}
|
||||
|
||||
public LibraryProperties getProperties() {
|
||||
return myProperties;
|
||||
}
|
||||
|
||||
public String getDefaultLibraryName() {
|
||||
|
||||
+5
@@ -125,6 +125,11 @@ public class LibraryRootsComponent implements Disposable, LibraryEditorComponent
|
||||
return getLibraryEditor().getProperties();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNewLibrary() {
|
||||
return getLibraryEditor() instanceof NewLibraryEditor;
|
||||
}
|
||||
|
||||
public void updatePropertiesLabel() {
|
||||
StringBuilder text = new StringBuilder();
|
||||
for (String description : LibraryPresentationManager.getInstance().getDescriptions(getLibraryEditor().getFiles(OrderRootType.CLASSES))) {
|
||||
|
||||
+1
-1
@@ -47,7 +47,7 @@ public class NewLibraryEditor extends LibraryEditorBase {
|
||||
this(null, null);
|
||||
}
|
||||
|
||||
public NewLibraryEditor(LibraryType type, LibraryProperties properties) {
|
||||
public NewLibraryEditor(@Nullable LibraryType type, @Nullable LibraryProperties properties) {
|
||||
myType = type;
|
||||
myProperties = properties;
|
||||
myRoots = new MultiMap<OrderRootType, LightFilePointer>();
|
||||
|
||||
Reference in New Issue
Block a user