CreateLibraryDialog*: caption -> LibraryCaption, refactoring CustomLibraryDescriptorWithDefferConfig with subclasses
This commit is contained in:
@@ -98,7 +98,7 @@ public class KotlinJavaModuleConfigurator extends KotlinWithLibraryConfigurator
|
|||||||
CreateLibraryDialogWithModules dialog = new CreateLibraryDialogWithModules(
|
CreateLibraryDialogWithModules dialog = new CreateLibraryDialogWithModules(
|
||||||
project, nonConfiguredModules, defaultPath, showPathPanelForJava,
|
project, nonConfiguredModules, defaultPath, showPathPanelForJava,
|
||||||
JavaRuntimeLibraryDescription.DIALOG_TITLE,
|
JavaRuntimeLibraryDescription.DIALOG_TITLE,
|
||||||
JavaRuntimeLibraryDescription.DIALOG_CAPTION);
|
JavaRuntimeLibraryDescription.LIBRARY_CAPTION);
|
||||||
|
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ public class KotlinJsModuleConfigurator extends KotlinWithLibraryConfigurator {
|
|||||||
CreateLibraryDialogWithModules dialog = new CreateLibraryDialogWithModules(
|
CreateLibraryDialogWithModules dialog = new CreateLibraryDialogWithModules(
|
||||||
project, nonConfiguredModules, defaultPathToJar, showPathToJarPanel,
|
project, nonConfiguredModules, defaultPathToJar, showPathToJarPanel,
|
||||||
JSLibraryStdDescription.DIALOG_TITLE,
|
JSLibraryStdDescription.DIALOG_TITLE,
|
||||||
JSLibraryStdDescription.DIALOG_CAPTION);
|
JSLibraryStdDescription.LIBRARY_CAPTION);
|
||||||
|
|
||||||
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
if (!ApplicationManager.getApplication().isUnitTestMode()) {
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|||||||
+35
-25
@@ -45,6 +45,7 @@ import javax.swing.*;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
import static org.jetbrains.jet.plugin.configuration.KotlinWithLibraryConfigurator.getFileInDir;
|
import static org.jetbrains.jet.plugin.configuration.KotlinWithLibraryConfigurator.getFileInDir;
|
||||||
|
|
||||||
@@ -52,30 +53,43 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
|
|||||||
|
|
||||||
private static final String DEFAULT_LIB_DIR_NAME = "lib";
|
private static final String DEFAULT_LIB_DIR_NAME = "lib";
|
||||||
|
|
||||||
@NotNull
|
private final String libraryName;
|
||||||
public abstract LibraryKind getLibraryKind();
|
private final String dialogTitle;
|
||||||
|
private final String modulesSeparatorCaption;
|
||||||
|
private final LibraryKind libraryKind;
|
||||||
|
private final Set<? extends LibraryKind> suitableLibraryKinds;
|
||||||
|
private final boolean useRelativePaths;
|
||||||
|
|
||||||
@Nullable
|
private DeferredCopyFileRequests deferredCopyFileRequests;
|
||||||
public abstract DeferredCopyFileRequests getCopyFileRequests();
|
|
||||||
|
|
||||||
protected final boolean useRelativePaths;
|
|
||||||
|
|
||||||
protected DeferredCopyFileRequests deferredCopyFileRequests;
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected abstract String getLibraryName();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected abstract String getDialogTitle();
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
protected abstract String getDialogCaption();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project null when project doesn't exist yet (called from project wizard)
|
* @param project null when project doesn't exist yet (called from project wizard)
|
||||||
*/
|
*/
|
||||||
public CustomLibraryDescriptorWithDefferConfig(@Nullable Project project) {
|
public CustomLibraryDescriptorWithDefferConfig(
|
||||||
|
@Nullable Project project,
|
||||||
|
@NotNull String libraryName,
|
||||||
|
@NotNull String dialogTitle,
|
||||||
|
@NotNull String modulesSeparatorCaption,
|
||||||
|
@NotNull LibraryKind libraryKind,
|
||||||
|
@NotNull Set<? extends LibraryKind> suitableLibraryKinds
|
||||||
|
) {
|
||||||
useRelativePaths = project == null;
|
useRelativePaths = project == null;
|
||||||
|
this.libraryName = libraryName;
|
||||||
|
this.dialogTitle = dialogTitle;
|
||||||
|
this.modulesSeparatorCaption = modulesSeparatorCaption;
|
||||||
|
this.libraryKind = libraryKind;
|
||||||
|
this.suitableLibraryKinds = suitableLibraryKinds;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
public DeferredCopyFileRequests getCopyFileRequests() {
|
||||||
|
return deferredCopyFileRequests;
|
||||||
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
|
||||||
|
return suitableLibraryKinds;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void finishLibConfiguration(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
|
public void finishLibConfiguration(@NotNull Module module, @NotNull ModifiableRootModel rootModel) {
|
||||||
@@ -88,7 +102,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
|
|||||||
LibraryPresentationManager libraryPresentationManager = LibraryPresentationManager.getInstance();
|
LibraryPresentationManager libraryPresentationManager = LibraryPresentationManager.getInstance();
|
||||||
List<VirtualFile> classFiles = Arrays.asList(library.getFiles(OrderRootType.CLASSES));
|
List<VirtualFile> classFiles = Arrays.asList(library.getFiles(OrderRootType.CLASSES));
|
||||||
|
|
||||||
return libraryPresentationManager.isLibraryOfKind(classFiles, getLibraryKind());
|
return libraryPresentationManager.isLibraryOfKind(classFiles, libraryKind);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -127,10 +141,6 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addCopyRequest(@NotNull File file, @NotNull String copyIntoPath) {
|
|
||||||
copyFilesRequests.add(new CopyFileRequest(copyIntoPath, file, false));
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addCopyWithReplaceRequest(@NotNull File file, @NotNull String copyIntoPath) {
|
public void addCopyWithReplaceRequest(@NotNull File file, @NotNull String copyIntoPath) {
|
||||||
copyFilesRequests.add(new CopyFileRequest(copyIntoPath, file, true));
|
copyFilesRequests.add(new CopyFileRequest(copyIntoPath, file, true));
|
||||||
}
|
}
|
||||||
@@ -180,7 +190,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
CreateLibraryDialog dialog =new CreateLibraryDialog(defaultPathToJarFile, getDialogTitle(), getDialogCaption());
|
CreateLibraryDialog dialog =new CreateLibraryDialog(defaultPathToJarFile, dialogTitle, modulesSeparatorCaption);
|
||||||
dialog.show();
|
dialog.show();
|
||||||
|
|
||||||
if (!dialog.isOK()) return null;
|
if (!dialog.isOK()) return null;
|
||||||
@@ -202,7 +212,7 @@ public abstract class CustomLibraryDescriptorWithDefferConfig extends CustomLibr
|
|||||||
final String libraryFileUrl = VfsUtil.getUrlForLibraryRoot(libraryFile);
|
final String libraryFileUrl = VfsUtil.getUrlForLibraryRoot(libraryFile);
|
||||||
final String libraryFileSrcUrl = VfsUtil.getUrlForLibraryRoot(librarySrcFile);
|
final String libraryFileSrcUrl = VfsUtil.getUrlForLibraryRoot(librarySrcFile);
|
||||||
|
|
||||||
return new NewLibraryConfiguration(getLibraryName(), null, new LibraryVersionProperties()) {
|
return new NewLibraryConfiguration(libraryName, null, new LibraryVersionProperties()) {
|
||||||
@Override
|
@Override
|
||||||
public void addRoots(@NotNull LibraryEditor editor) {
|
public void addRoots(@NotNull LibraryEditor editor) {
|
||||||
editor.addRoot(libraryFileUrl, OrderRootType.CLASSES);
|
editor.addRoot(libraryFileUrl, OrderRootType.CLASSES);
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ import com.google.common.collect.Sets;
|
|||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.libraries.LibraryKind;
|
import com.intellij.openapi.roots.libraries.LibraryKind;
|
||||||
import com.intellij.openapi.roots.libraries.NewLibraryConfiguration;
|
import com.intellij.openapi.roots.libraries.NewLibraryConfiguration;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.annotations.TestOnly;
|
import org.jetbrains.annotations.TestOnly;
|
||||||
import org.jetbrains.jet.plugin.configuration.KotlinJsModuleConfigurator;
|
import org.jetbrains.jet.plugin.configuration.KotlinJsModuleConfigurator;
|
||||||
@@ -36,50 +35,14 @@ public class JSLibraryStdDescription extends CustomLibraryDescriptorWithDefferCo
|
|||||||
|
|
||||||
public static final String JAVA_SCRIPT_LIBRARY_CREATION = "JavaScript Library Creation";
|
public static final String JAVA_SCRIPT_LIBRARY_CREATION = "JavaScript Library Creation";
|
||||||
public static final String DIALOG_TITLE = "Create Kotlin JavaScript Library";
|
public static final String DIALOG_TITLE = "Create Kotlin JavaScript Library";
|
||||||
public static final String DIALOG_CAPTION = "Kotlin JavaScript Library";
|
public static final String LIBRARY_CAPTION = "Kotlin JavaScript Library";
|
||||||
public static final Set<LibraryKind> SUITABLE_LIBRARY_KINDS = Sets.newHashSet(KOTLIN_JAVASCRIPT_KIND);
|
public static final Set<LibraryKind> SUITABLE_LIBRARY_KINDS = Sets.newHashSet(KOTLIN_JAVASCRIPT_KIND);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project null when project doesn't exist yet (called from project wizard)
|
* @param project null when project doesn't exist yet (called from project wizard)
|
||||||
*/
|
*/
|
||||||
public JSLibraryStdDescription(@Nullable Project project) {
|
public JSLibraryStdDescription(@Nullable Project project) {
|
||||||
super(project);
|
super(project, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVASCRIPT_KIND, SUITABLE_LIBRARY_KINDS);
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getLibraryName() {
|
|
||||||
return LIBRARY_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getDialogTitle() {
|
|
||||||
return DIALOG_TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getDialogCaption() {
|
|
||||||
return DIALOG_CAPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
|
|
||||||
return SUITABLE_LIBRARY_KINDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public LibraryKind getLibraryKind() {
|
|
||||||
return KOTLIN_JAVASCRIPT_KIND;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public DeferredCopyFileRequests getCopyFileRequests() {
|
|
||||||
return deferredCopyFileRequests;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestOnly
|
@TestOnly
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ package org.jetbrains.jet.plugin.framework;
|
|||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
import com.intellij.openapi.project.Project;
|
import com.intellij.openapi.project.Project;
|
||||||
import com.intellij.openapi.roots.libraries.LibraryKind;
|
import com.intellij.openapi.roots.libraries.LibraryKind;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -30,49 +29,13 @@ public class JavaRuntimeLibraryDescription extends CustomLibraryDescriptorWithDe
|
|||||||
|
|
||||||
public static final String JAVA_RUNTIME_LIBRARY_CREATION = "Java Runtime Library Creation";
|
public static final String JAVA_RUNTIME_LIBRARY_CREATION = "Java Runtime Library Creation";
|
||||||
public static final String DIALOG_TITLE = "Create Kotlin Java Runtime Library";
|
public static final String DIALOG_TITLE = "Create Kotlin Java Runtime Library";
|
||||||
public static final String DIALOG_CAPTION = "Kotlin Java Runtime Library";
|
public static final String LIBRARY_CAPTION = "Kotlin Java Runtime Library";
|
||||||
public static final Set<LibraryKind> SUITABLE_LIBRARY_KINDS = Sets.newHashSet(KOTLIN_JAVA_RUNTIME_KIND);
|
public static final Set<LibraryKind> SUITABLE_LIBRARY_KINDS = Sets.newHashSet(KOTLIN_JAVA_RUNTIME_KIND);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param project null when project doesn't exist yet (called from project wizard)
|
* @param project null when project doesn't exist yet (called from project wizard)
|
||||||
*/
|
*/
|
||||||
public JavaRuntimeLibraryDescription(@Nullable Project project) {
|
public JavaRuntimeLibraryDescription(@Nullable Project project) {
|
||||||
super(project);
|
super(project, LIBRARY_NAME, DIALOG_TITLE, LIBRARY_CAPTION, KOTLIN_JAVA_RUNTIME_KIND, SUITABLE_LIBRARY_KINDS);
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getLibraryName() {
|
|
||||||
return LIBRARY_NAME;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getDialogTitle() {
|
|
||||||
return DIALOG_TITLE;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
protected String getDialogCaption() {
|
|
||||||
return DIALOG_CAPTION;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public Set<? extends LibraryKind> getSuitableLibraryKinds() {
|
|
||||||
return SUITABLE_LIBRARY_KINDS;
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull
|
|
||||||
@Override
|
|
||||||
public LibraryKind getLibraryKind() {
|
|
||||||
return KOTLIN_JAVA_RUNTIME_KIND;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nullable
|
|
||||||
@Override
|
|
||||||
public DeferredCopyFileRequests getCopyFileRequests() {
|
|
||||||
return deferredCopyFileRequests;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,8 +20,8 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
|
|
||||||
public class CreateLibraryDialog extends CreateLibraryDialogBase {
|
public class CreateLibraryDialog extends CreateLibraryDialogBase {
|
||||||
|
|
||||||
public CreateLibraryDialog(@NotNull String defaultPath, @NotNull String title, @NotNull String caption) {
|
public CreateLibraryDialog(@NotNull String defaultPath, @NotNull String title, @NotNull String libraryCaption) {
|
||||||
super(null, defaultPath, title, caption);
|
super(null, defaultPath, title, libraryCaption);
|
||||||
updateComponents();
|
updateComponents();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ public abstract class CreateLibraryDialogBase extends DialogWrapper {
|
|||||||
@Nullable Project project,
|
@Nullable Project project,
|
||||||
@NotNull String defaultPath,
|
@NotNull String defaultPath,
|
||||||
@NotNull String title,
|
@NotNull String title,
|
||||||
@NotNull String caption
|
@NotNull String libraryCaption
|
||||||
) {
|
) {
|
||||||
super(project);
|
super(project);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public abstract class CreateLibraryDialogBase extends DialogWrapper {
|
|||||||
});
|
});
|
||||||
chooseLibraryPathPlace.add(pathPanel.getContentPane(), BorderLayout.CENTER);
|
chooseLibraryPathPlace.add(pathPanel.getContentPane(), BorderLayout.CENTER);
|
||||||
|
|
||||||
modulesSeparator.setCaption(caption);
|
modulesSeparator.setCaption(libraryCaption);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void updateComponents() {
|
protected void updateComponents() {
|
||||||
|
|||||||
@@ -33,9 +33,9 @@ public class CreateLibraryDialogWithModules extends CreateLibraryDialogBase {
|
|||||||
@NotNull String defaultPath,
|
@NotNull String defaultPath,
|
||||||
boolean showPathPanel,
|
boolean showPathPanel,
|
||||||
@NotNull String title,
|
@NotNull String title,
|
||||||
@NotNull String caption
|
@NotNull String libraryCaption
|
||||||
) {
|
) {
|
||||||
super(project, defaultPath, title, caption);
|
super(project, defaultPath, title, libraryCaption);
|
||||||
|
|
||||||
chooseModulePanel = new ChooseModulePanel(project, modules);
|
chooseModulePanel = new ChooseModulePanel(project, modules);
|
||||||
chooseModulesPanelPlace.add(chooseModulePanel.getContentPane(), BorderLayout.CENTER);
|
chooseModulesPanelPlace.add(chooseModulePanel.getContentPane(), BorderLayout.CENTER);
|
||||||
|
|||||||
Reference in New Issue
Block a user