GUI for copy ecma 3 file
This commit is contained in:
@@ -24,21 +24,20 @@ 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;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
import org.jetbrains.jet.plugin.framework.ui.CreateLibrarySourceDialog;
|
||||
import org.jetbrains.jet.plugin.framework.ui.CreateJavaScriptLibraryDialog;
|
||||
import org.jetbrains.jet.plugin.framework.ui.FileUIUtils;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
public class JSLibraryDescription extends CustomLibraryDescription {
|
||||
@@ -56,7 +55,7 @@ public class JSLibraryDescription extends CustomLibraryDescription {
|
||||
@Nullable
|
||||
@Override
|
||||
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory) {
|
||||
CreateLibrarySourceDialog dialog = new CreateLibrarySourceDialog(null, "Create Kotlin JavaScript Library", contextDirectory);
|
||||
CreateJavaScriptLibraryDialog dialog = new CreateJavaScriptLibraryDialog(null, "Create Kotlin JavaScript Library", contextDirectory);
|
||||
dialog.show();
|
||||
|
||||
if (dialog.isOK()) {
|
||||
@@ -74,12 +73,20 @@ public class JSLibraryDescription extends CustomLibraryDescription {
|
||||
|
||||
String copyIntoPath = dialog.getCopyIntoPath();
|
||||
if (copyIntoPath != null) {
|
||||
libraryFile = FileUIUtils.copyWithOverwriteDialog(parentComponent, copyIntoPath, libraryFile, JAVA_SCRIPT_LIBRARY_CREATION);
|
||||
if (libraryFile == null) {
|
||||
List<File> copyFiles = new ArrayList<File>();
|
||||
|
||||
if (dialog.isCopyLibraryFiles()) copyFiles.add(libraryFile);
|
||||
if (dialog.isCopyECMA3()) copyFiles.add(paths.getJsLibJsPath());
|
||||
|
||||
Map<File,File> copiedFiles =
|
||||
FileUIUtils.copyWithOverwriteDialog(parentComponent, JAVA_SCRIPT_LIBRARY_CREATION, copyIntoPath, copyFiles);
|
||||
if (copiedFiles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
copyJsRuntimeFile(copyIntoPath);
|
||||
if (dialog.isCopyLibraryFiles()) {
|
||||
libraryFile = copiedFiles.get(libraryFile);
|
||||
}
|
||||
}
|
||||
|
||||
final String libraryFileUrl = VfsUtil.getUrlForLibraryRoot(libraryFile);
|
||||
@@ -93,19 +100,4 @@ public class JSLibraryDescription extends CustomLibraryDescription {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
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) {
|
||||
// Do nothing. This is a very temp code and should be removed.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ import com.intellij.openapi.vfs.VfsUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.plugin.framework.ui.CreateLibrarySourceDialog;
|
||||
import org.jetbrains.jet.plugin.framework.ui.CreateJavaLibraryDialog;
|
||||
import org.jetbrains.jet.plugin.framework.ui.FileUIUtils;
|
||||
import org.jetbrains.jet.utils.KotlinPaths;
|
||||
import org.jetbrains.jet.utils.PathUtil;
|
||||
@@ -52,7 +52,7 @@ public class JavaRuntimeLibraryDescription extends CustomLibraryDescription {
|
||||
@Nullable
|
||||
@Override
|
||||
public NewLibraryConfiguration createNewLibrary(@NotNull JComponent parentComponent, @Nullable VirtualFile contextDirectory) {
|
||||
CreateLibrarySourceDialog dialog = new CreateLibrarySourceDialog(null, "Create Kotlin Java Runtime Library", contextDirectory);
|
||||
CreateJavaLibraryDialog dialog = new CreateJavaLibraryDialog(null, "Create Kotlin Java Runtime Library", contextDirectory);
|
||||
dialog.show();
|
||||
|
||||
if (dialog.isOK()) {
|
||||
@@ -72,7 +72,7 @@ public class JavaRuntimeLibraryDescription extends CustomLibraryDescription {
|
||||
|
||||
String copyIntoPath = dialog.getCopyIntoPath();
|
||||
if (copyIntoPath != null) {
|
||||
libraryFile = FileUIUtils.copyWithOverwriteDialog(parentComponent, copyIntoPath, libraryFile, JAVA_RUNTIME_LIBRARY_CREATION);
|
||||
libraryFile = FileUIUtils.copyWithOverwriteDialog(parentComponent, JAVA_RUNTIME_LIBRARY_CREATION, copyIntoPath, libraryFile);
|
||||
if (libraryFile == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.framework.ui.ChooseCompilerSourcePanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="416" height="156"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="e6e7d" class="javax.swing.JRadioButton" binding="useBundledKotlinRadioButton" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="Use compiler &bundled in plugin"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="150a1">
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="7c565" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="kotlinStandalonePathField">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="4b0f" class="javax.swing.JRadioButton" binding="useStandaloneKotlinRadioButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="false"/>
|
||||
<text value="Use standalone Kotlin compiler &installation"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
<group name="sourceGroup">
|
||||
<member id="e6e7d"/>
|
||||
<member id="4b0f"/>
|
||||
</group>
|
||||
</buttonGroups>
|
||||
</form>
|
||||
+62
-86
@@ -1,13 +1,28 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptor;
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.plugin.JetPluginUtil;
|
||||
@@ -21,27 +36,19 @@ import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.IOException;
|
||||
|
||||
public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
private JPanel contentPane;
|
||||
private JRadioButton useStandaloneKotlinRadioButton;
|
||||
public class ChooseCompilerSourcePanel {
|
||||
private JRadioButton useBundledKotlinRadioButton;
|
||||
private JCheckBox copyLibraryCheckbox;
|
||||
private TextFieldWithBrowseButton copyIntoDirectoryField;
|
||||
private JRadioButton useStandaloneKotlinRadioButton;
|
||||
private TextFieldWithBrowseButton kotlinStandalonePathField;
|
||||
private JPanel contentPane;
|
||||
|
||||
private final EventDispatcher<ValidityListener> validityDispatcher = EventDispatcher.create(ValidityListener.class);
|
||||
|
||||
private boolean hasErrorsState = false;
|
||||
private String version = null;
|
||||
|
||||
private final String initialStandaloneLabelText;
|
||||
|
||||
public CreateLibrarySourceDialog(@Nullable Project project, @NotNull String title, VirtualFile contextDirectory) {
|
||||
super(project);
|
||||
|
||||
setTitle(title);
|
||||
|
||||
init();
|
||||
|
||||
contentPane.setMinimumSize(new Dimension(380, 180));
|
||||
|
||||
public ChooseCompilerSourcePanel(@Nullable Project project) {
|
||||
useBundledKotlinRadioButton.setText(useBundledKotlinRadioButton.getText() + " - " + JetPluginUtil.getPluginVersion());
|
||||
|
||||
initialStandaloneLabelText = useStandaloneKotlinRadioButton.getText();
|
||||
@@ -64,30 +71,10 @@ public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
@Override
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
updateStandaloneVersion();
|
||||
updateComponentVersion();
|
||||
}
|
||||
});
|
||||
|
||||
updateStandaloneVersion();
|
||||
|
||||
copyIntoDirectoryField.addBrowseFolderListener(
|
||||
"Copy Into...", "Choose folder where files will be copied", project,
|
||||
FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||
copyIntoDirectoryField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
updateComponentVersion();
|
||||
}
|
||||
});
|
||||
|
||||
copyIntoDirectoryField.getTextField().setText(FileUIUtils.getDefaultLibraryFolder(project, contextDirectory));
|
||||
|
||||
copyLibraryCheckbox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
|
||||
useStandaloneKotlinRadioButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
@@ -101,9 +88,18 @@ public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
}
|
||||
});
|
||||
|
||||
updateStandaloneVersion();
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
public void addValidityListener(ValidityListener listener) {
|
||||
validityDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return hasErrorsState;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStandaloneCompilerPath() {
|
||||
if (useStandaloneKotlinRadioButton.isSelected()) {
|
||||
@@ -113,15 +109,6 @@ public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCopyIntoPath() {
|
||||
if (copyLibraryCheckbox.isSelected()) {
|
||||
return copyIntoDirectoryField.getText().trim();
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
if (useBundledKotlinRadioButton.isSelected()) {
|
||||
@@ -133,6 +120,34 @@ public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
}
|
||||
}
|
||||
|
||||
public JPanel getContentPane() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
boolean isError = false;
|
||||
|
||||
kotlinStandalonePathField.setEnabled(useStandaloneKotlinRadioButton.isSelected());
|
||||
|
||||
useStandaloneKotlinRadioButton.setForeground(Color.BLACK);
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText);
|
||||
if (useStandaloneKotlinRadioButton.isSelected()) {
|
||||
if (version != null) {
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + version);
|
||||
}
|
||||
else {
|
||||
useStandaloneKotlinRadioButton.setForeground(Color.RED);
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + "Invalid Version");
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasErrorsState != isError) {
|
||||
hasErrorsState = isError;
|
||||
validityDispatcher.getMulticaster().validityChanged(isError);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateStandaloneVersion() {
|
||||
if (useStandaloneKotlinRadioButton.isSelected()) {
|
||||
KotlinPaths paths = PathUtil.getKotlinStandaloneCompilerPaths(kotlinStandalonePathField.getTextField().getText().trim());
|
||||
@@ -147,43 +162,4 @@ public class CreateLibrarySourceDialog extends DialogWrapper {
|
||||
|
||||
version = null;
|
||||
}
|
||||
|
||||
private void updateComponentVersion() {
|
||||
boolean isError = false;
|
||||
|
||||
useStandaloneKotlinRadioButton.setForeground(Color.BLACK);
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText);
|
||||
if (useStandaloneKotlinRadioButton.isSelected()) {
|
||||
if (version != null) {
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + version);
|
||||
}
|
||||
else {
|
||||
useStandaloneKotlinRadioButton.setForeground(Color.RED);
|
||||
useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + "Invalid Version");
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
|
||||
copyLibraryCheckbox.setForeground(Color.BLACK);
|
||||
if (copyLibraryCheckbox.isSelected()) {
|
||||
if (copyIntoDirectoryField.getText().trim().isEmpty()) {
|
||||
copyLibraryCheckbox.setForeground(Color.RED);
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
|
||||
setOKActionEnabled(!isError);
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
kotlinStandalonePathField.setEnabled(useStandaloneKotlinRadioButton.isSelected());
|
||||
copyIntoDirectoryField.setEnabled(copyLibraryCheckbox.isSelected());
|
||||
updateComponentVersion();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return contentPane;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.framework.ui.CopyIntoPanel">
|
||||
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="20" y="20" width="465" height="400"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="7591e" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="copyIntoField">
|
||||
<constraints>
|
||||
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<vspacer id="72c0e">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="2" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<component id="9d5d5" class="javax.swing.JLabel" binding="copyIntoLabel">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Copy into:"/>
|
||||
</properties>
|
||||
</component>
|
||||
</children>
|
||||
</grid>
|
||||
</form>
|
||||
@@ -0,0 +1,95 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
import com.intellij.util.EventDispatcher;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import java.awt.*;
|
||||
|
||||
public class CopyIntoPanel {
|
||||
private JPanel contentPane;
|
||||
private TextFieldWithBrowseButton copyIntoField;
|
||||
private JLabel copyIntoLabel;
|
||||
|
||||
private final EventDispatcher<ValidityListener> validityDispatcher = EventDispatcher.create(ValidityListener.class);
|
||||
|
||||
private boolean hasErrorsState;
|
||||
|
||||
public CopyIntoPanel(@Nullable Project project, @NotNull VirtualFile contextDirectory) {
|
||||
copyIntoField.addBrowseFolderListener(
|
||||
"Copy Into...", "Choose folder where files will be copied", project,
|
||||
FileChooserDescriptorFactory.createSingleFolderDescriptor());
|
||||
copyIntoField.getTextField().getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(final DocumentEvent e) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
|
||||
copyIntoLabel.setLabelFor(copyIntoField.getTextField());
|
||||
copyIntoField.getTextField().setText(FileUIUtils.getDefaultLibraryFolder(project, contextDirectory));
|
||||
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
public JComponent getContentPane() {
|
||||
return contentPane;
|
||||
}
|
||||
|
||||
public void addValidityListener(ValidityListener listener) {
|
||||
validityDispatcher.addListener(listener);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getPath() {
|
||||
return copyIntoField.isEnabled() ? copyIntoField.getText().trim() : null;
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
boolean isError = false;
|
||||
|
||||
copyIntoLabel.setForeground(Color.BLACK);
|
||||
if (copyIntoField.isEnabled()) {
|
||||
if (copyIntoField.getText().trim().isEmpty()) {
|
||||
copyIntoLabel.setForeground(Color.RED);
|
||||
isError = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (isError != hasErrorsState) {
|
||||
hasErrorsState = isError;
|
||||
validityDispatcher.getMulticaster().validityChanged(isError);
|
||||
}
|
||||
}
|
||||
|
||||
public void setEnabled(boolean enabled) {
|
||||
copyIntoField.setEnabled(enabled);
|
||||
}
|
||||
|
||||
public boolean hasErrors() {
|
||||
return hasErrorsState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.framework.ui.CreateJavaLibraryDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<vspacer id="bb37c">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="46726" layout-manager="GridLayoutManager" row-count="2" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="15" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="90315" class="javax.swing.JCheckBox" binding="copyLibraryCheckbox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Copy library &files into project"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="e47d8" binding="copyIntoPanelPlace" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="3" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<grid id="fcae8" binding="compilerSourcePanelPlace" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
<group name="sourceGroup">
|
||||
<member id="730af"/>
|
||||
<member id="c709f"/>
|
||||
</group>
|
||||
</buttonGroups>
|
||||
</form>
|
||||
@@ -0,0 +1,101 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class CreateJavaLibraryDialog extends DialogWrapper {
|
||||
private final ChooseCompilerSourcePanel compilerSourcePanel;
|
||||
private final CopyIntoPanel copyIntoPanel;
|
||||
|
||||
private JPanel contentPane;
|
||||
private JCheckBox copyLibraryCheckbox;
|
||||
private JPanel copyIntoPanelPlace;
|
||||
private JPanel compilerSourcePanelPlace;
|
||||
|
||||
public CreateJavaLibraryDialog(@Nullable Project project, @NotNull String title, VirtualFile contextDirectory) {
|
||||
super(project);
|
||||
|
||||
setTitle(title);
|
||||
|
||||
init();
|
||||
|
||||
compilerSourcePanel = new ChooseCompilerSourcePanel(project);
|
||||
compilerSourcePanel.addValidityListener(new ValidityListener() {
|
||||
@Override
|
||||
public void validityChanged(boolean isValid) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
compilerSourcePanelPlace.add(compilerSourcePanel.getContentPane(), BorderLayout.CENTER, 0);
|
||||
|
||||
copyIntoPanel = new CopyIntoPanel(project, contextDirectory);
|
||||
copyIntoPanel.addValidityListener(new ValidityListener() {
|
||||
@Override
|
||||
public void validityChanged(boolean isValid) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
copyIntoPanelPlace.add(copyIntoPanel.getContentPane(), BorderLayout.CENTER);
|
||||
|
||||
contentPane.setMinimumSize(new Dimension(380, 180));
|
||||
|
||||
copyLibraryCheckbox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStandaloneCompilerPath() {
|
||||
return compilerSourcePanel.getStandaloneCompilerPath();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCopyIntoPath() {
|
||||
return copyIntoPanel.getPath();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
return compilerSourcePanel.getVersion();
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
copyIntoPanel.setEnabled(copyLibraryCheckbox.isSelected());
|
||||
setOKActionEnabled(!(compilerSourcePanel.hasErrors() || copyIntoPanel.hasErrors()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return contentPane;
|
||||
}
|
||||
}
|
||||
+31
-36
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.framework.ui.CreateLibrarySourceDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="org.jetbrains.jet.plugin.framework.ui.CreateJavaScriptLibraryDialog">
|
||||
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<xy x="48" y="54" width="436" height="297"/>
|
||||
@@ -8,67 +8,62 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="730af" class="javax.swing.JRadioButton" binding="useStandaloneKotlinRadioButton">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="false"/>
|
||||
<text value="Use &standalone Kotlin compiler installation"/>
|
||||
</properties>
|
||||
</component>
|
||||
<vspacer id="bb37c">
|
||||
<constraints>
|
||||
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
</vspacer>
|
||||
<grid id="46726" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="15" left="0" bottom="0" right="0"/>
|
||||
<grid id="46726" layout-manager="GridLayoutManager" row-count="3" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
|
||||
<margin top="0" left="0" bottom="0" right="0"/>
|
||||
<constraints>
|
||||
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="edb3" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="copyIntoDirectoryField">
|
||||
<constraints>
|
||||
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="90315" class="javax.swing.JCheckBox" binding="copyLibraryCheckbox">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="&Copy library files into project"/>
|
||||
<text value="&Library files"/>
|
||||
</properties>
|
||||
</component>
|
||||
<component id="1f83b" class="javax.swing.JLabel">
|
||||
<component id="dd25b" class="javax.swing.JCheckBox" binding="ECMAScript3JavaScriptRuntimeCheckBox" default-binding="true">
|
||||
<constraints>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="2" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<text value="Folder"/>
|
||||
<selected value="true"/>
|
||||
<text value="EC&MAScript 3 JavaScript runtime file"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="11e35" binding="copyIntoPanelPlace" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="3" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<component id="89e9f" class="com.intellij.openapi.ui.TextFieldWithBrowseButton" binding="kotlinStandalonePathField">
|
||||
<component id="7c0b3" class="com.intellij.ui.TitledSeparator">
|
||||
<constraints>
|
||||
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="3" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="c709f" class="javax.swing.JRadioButton" binding="useBundledKotlinRadioButton">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
|
||||
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties>
|
||||
<selected value="true"/>
|
||||
<text value="Use compiler &bundled in plugin"/>
|
||||
<text value="Copy Into Project"/>
|
||||
</properties>
|
||||
</component>
|
||||
<grid id="d209b" binding="compilerSourcePanelPlace" layout-manager="BorderLayout" hgap="0" vgap="0">
|
||||
<constraints>
|
||||
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
|
||||
</constraints>
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children/>
|
||||
</grid>
|
||||
</children>
|
||||
</grid>
|
||||
<buttonGroups>
|
||||
@@ -0,0 +1,99 @@
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.DialogWrapper;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
|
||||
public class CreateJavaScriptLibraryDialog extends DialogWrapper {
|
||||
private final ChooseCompilerSourcePanel compilerSourcePanel;
|
||||
private final CopyIntoPanel copyIntoPanel;
|
||||
|
||||
private JPanel contentPane;
|
||||
private JCheckBox copyLibraryCheckbox;
|
||||
private JCheckBox ECMAScript3JavaScriptRuntimeCheckBox;
|
||||
private JPanel compilerSourcePanelPlace;
|
||||
private JPanel copyIntoPanelPlace;
|
||||
|
||||
public CreateJavaScriptLibraryDialog(@Nullable Project project, @NotNull String title, VirtualFile contextDirectory) {
|
||||
super(project);
|
||||
|
||||
setTitle(title);
|
||||
|
||||
init();
|
||||
|
||||
compilerSourcePanel = new ChooseCompilerSourcePanel(project);
|
||||
compilerSourcePanel.addValidityListener(new ValidityListener() {
|
||||
@Override
|
||||
public void validityChanged(boolean isValid) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
compilerSourcePanelPlace.add(compilerSourcePanel.getContentPane(), BorderLayout.CENTER);
|
||||
|
||||
copyIntoPanel = new CopyIntoPanel(project, contextDirectory);
|
||||
copyIntoPanel.addValidityListener(new ValidityListener() {
|
||||
@Override
|
||||
public void validityChanged(boolean isValid) {
|
||||
updateComponents();
|
||||
}
|
||||
});
|
||||
copyIntoPanelPlace.add(copyIntoPanel.getContentPane(), BorderLayout.CENTER);
|
||||
|
||||
contentPane.setMinimumSize(new Dimension(380, 180));
|
||||
|
||||
ActionListener updateComponentsListener = new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(@NotNull ActionEvent e) {
|
||||
updateComponents();
|
||||
}
|
||||
};
|
||||
|
||||
copyLibraryCheckbox.addActionListener(updateComponentsListener);
|
||||
ECMAScript3JavaScriptRuntimeCheckBox.addActionListener(updateComponentsListener);
|
||||
|
||||
updateComponents();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getStandaloneCompilerPath() {
|
||||
return compilerSourcePanel.getStandaloneCompilerPath();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String getCopyIntoPath() {
|
||||
return copyIntoPanel.getPath();
|
||||
}
|
||||
|
||||
public boolean isCopyLibraryFiles() {
|
||||
return copyLibraryCheckbox.isSelected();
|
||||
}
|
||||
|
||||
public boolean isCopyECMA3() {
|
||||
return ECMAScript3JavaScriptRuntimeCheckBox.isSelected();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public String getVersion() {
|
||||
return compilerSourcePanel.getVersion();
|
||||
}
|
||||
|
||||
private void updateComponents() {
|
||||
copyIntoPanel.setEnabled(copyLibraryCheckbox.isSelected() ||
|
||||
ECMAScript3JavaScriptRuntimeCheckBox.isSelected());
|
||||
|
||||
setOKActionEnabled(!(compilerSourcePanel.hasErrors() || copyIntoPanel.hasErrors()));
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
protected JComponent createCenterPanel() {
|
||||
return contentPane;
|
||||
}
|
||||
}
|
||||
@@ -16,10 +16,14 @@
|
||||
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import com.google.common.base.Predicate;
|
||||
import com.google.common.collect.Collections2;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.intellij.ide.util.projectWizard.ProjectWizardUtil;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.LocalFileSystem;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.PathUtil;
|
||||
@@ -30,6 +34,8 @@ import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
import java.util.List;
|
||||
|
||||
public class FileUIUtils {
|
||||
private FileUIUtils() {
|
||||
@@ -38,43 +44,84 @@ public class FileUIUtils {
|
||||
@Nullable
|
||||
public static File copyWithOverwriteDialog(
|
||||
@NotNull Component parent,
|
||||
@NotNull String messagesTitle,
|
||||
@NotNull String destinationFolder,
|
||||
@NotNull File file,
|
||||
@NotNull String messagesTitle) {
|
||||
@NotNull File file) {
|
||||
Map<File, File> copiedFiles = copyWithOverwriteDialog(parent, messagesTitle, destinationFolder, ImmutableList.of(file));
|
||||
if (copiedFiles == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
File copy = copiedFiles.get(file);
|
||||
assert copy != null;
|
||||
|
||||
return copy;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static Map<File, File> copyWithOverwriteDialog(
|
||||
@NotNull Component parent,
|
||||
@NotNull String messagesTitle,
|
||||
@NotNull String destinationFolder,
|
||||
@NotNull List<File> files
|
||||
) {
|
||||
if (!ProjectWizardUtil.createDirectoryIfNotExists("Destination folder", destinationFolder, false)) {
|
||||
Messages.showErrorDialog(String.format("Error during folder creating '%s'", destinationFolder), messagesTitle + ". Error");
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
File folder = new File(destinationFolder);
|
||||
File targetFile = new File(folder, file.getName());
|
||||
|
||||
assert folder.exists();
|
||||
Set<String> fileNames = new HashSet<String>();
|
||||
Map<File, File> targetFiles = new LinkedHashMap<File, File>(files.size());
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
|
||||
try {
|
||||
if (!targetFile.exists()) {
|
||||
FileUtil.copy(file, targetFile);
|
||||
}
|
||||
else {
|
||||
int replaceIfExist = Messages.showYesNoDialog(
|
||||
parent,
|
||||
String.format("File \"%s\" is already exist in %s.\nDo you want to rewrite it?", targetFile.getName(), folder.getAbsolutePath()),
|
||||
messagesTitle + ". Replace File",
|
||||
Messages.getWarningIcon());
|
||||
|
||||
if (replaceIfExist == JOptionPane.YES_OPTION) {
|
||||
FileUtil.copy(file, targetFile);
|
||||
}
|
||||
if (!fileNames.add(fileName)) {
|
||||
throw new IllegalArgumentException("There are several files with the same name: " + fileName);
|
||||
}
|
||||
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(targetFile);
|
||||
targetFiles.put(file, new File(folder, fileName));
|
||||
}
|
||||
|
||||
return targetFile;
|
||||
Collection<File> existentFiles = Collections2.filter(targetFiles.values(), new Predicate<File>() {
|
||||
@Override
|
||||
public boolean apply(@Nullable File file) {
|
||||
assert file != null;
|
||||
return file.exists();
|
||||
}
|
||||
});
|
||||
|
||||
if (!existentFiles.isEmpty()) {
|
||||
String message = existentFiles.size() == 1 ?
|
||||
String.format("File \"%s\" is already exist in %s.\nDo you want to overwrite it?", existentFiles.iterator().next().getName(), folder.getAbsolutePath()) :
|
||||
String.format("Several files are already exist in %s:\n%s\nDo you want to overwrite them?", folder.getAbsolutePath(), StringUtil.join(existentFiles, "\n"));
|
||||
|
||||
int replaceIfExist = Messages.showYesNoDialog(
|
||||
null,
|
||||
message,
|
||||
messagesTitle + ". Replace File",
|
||||
"Overwrite",
|
||||
"Cancel",
|
||||
Messages.getWarningIcon());
|
||||
|
||||
if (replaceIfExist != JOptionPane.YES_OPTION) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
catch (IOException e) {
|
||||
Messages.showErrorDialog("Error during file copy", messagesTitle + ". Error");
|
||||
return null;
|
||||
|
||||
for (Map.Entry<File, File> sourceToTarget : targetFiles.entrySet()) {
|
||||
try {
|
||||
FileUtil.copy(sourceToTarget.getKey(), sourceToTarget.getValue());
|
||||
LocalFileSystem.getInstance().refreshAndFindFileByIoFile(sourceToTarget.getValue());
|
||||
}
|
||||
catch (IOException e) {
|
||||
Messages.showErrorDialog(parent, "Error with copy file " + sourceToTarget.getKey().getName(), messagesTitle + ". Error");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return targetFiles;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* Copyright 2010-2013 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.jet.plugin.framework.ui;
|
||||
|
||||
import java.util.EventListener;
|
||||
|
||||
public interface ValidityListener extends EventListener {
|
||||
void validityChanged(boolean isValid);
|
||||
}
|
||||
Reference in New Issue
Block a user