Temporary copy js kotlin runtime to the folder with the library. Need special gui.

This commit is contained in:
Nikolay Krasko
2013-02-25 20:26:14 +04:00
parent 52d8b0d616
commit 9b9f9a50d3
2 changed files with 21 additions and 2 deletions
@@ -24,6 +24,8 @@ import com.intellij.openapi.roots.libraries.NewLibraryConfiguration;
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription;
import com.intellij.openapi.roots.ui.configuration.libraryEditor.LibraryEditor;
import com.intellij.openapi.ui.Messages;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.vfs.LocalFileSystem;
import com.intellij.openapi.vfs.VfsUtil;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
@@ -74,6 +76,7 @@ public class JSLibraryDescription extends CustomLibraryDescription {
final File targetFile;
try {
targetFile = FileUIUtils.copyWithOverwriteDialog(directoryPath, runtimePath);
copyJsRuntimeFile(directoryPath);
}
catch (IOException e) {
Messages.showErrorDialog("Error during file copy", JAVA_SCRIPT_LIBRARY_CREATION);
@@ -87,4 +90,19 @@ public class JSLibraryDescription extends CustomLibraryDescription {
}
};
}
private static void copyJsRuntimeFile(@NotNull String directoryPath) {
File file = PathUtil.getKotlinPathsForIdeaPlugin().getJsLibJsPath();
File folder = new File(directoryPath);
File targetFile = new File(folder, file.getName());
try {
FileUtil.copy(file, targetFile);
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(targetFile);
}
catch (IOException e) {
// Don't do nothing. This is temp code and should be removed.
}
}
}
@@ -38,8 +38,9 @@ public class FileUIUtils {
File folder = new File(destinationFolder);
File targetFile = new File(folder, file.getName());
// TODO: create folder if it is not present yet
assert folder.exists();
if (!folder.exists()) {
throw new IllegalArgumentException(String.format("Destination folder '%s' should exist", folder));
}
if (!targetFile.exists()) {
FileUtil.copy(file, targetFile);