From d73123f771abb1e4c2af36e5e0090d2dc8c3dada Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 27 Feb 2013 16:45:45 +0400 Subject: [PATCH] Don't allow copy into empty folders --- .../ui/CreateLibrarySourceDialog.java | 28 ++++++++++++++----- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateLibrarySourceDialog.java b/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateLibrarySourceDialog.java index e32803f4a58..f6dce7ce1f8 100644 --- a/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateLibrarySourceDialog.java +++ b/idea/src/org/jetbrains/jet/plugin/framework/ui/CreateLibrarySourceDialog.java @@ -73,6 +73,13 @@ public class CreateLibrarySourceDialog extends DialogWrapper { 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() { @@ -142,23 +149,30 @@ public class CreateLibrarySourceDialog extends DialogWrapper { } private void updateComponentVersion() { + boolean isError = false; + + useStandaloneKotlinRadioButton.setForeground(Color.BLACK); + useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText); if (useStandaloneKotlinRadioButton.isSelected()) { if (version != null) { - useStandaloneKotlinRadioButton.setForeground(Color.BLACK); useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + version); - setOKActionEnabled(true); } else { useStandaloneKotlinRadioButton.setForeground(Color.RED); useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText + " - " + "Invalid Version"); - setOKActionEnabled(false); + isError = true; } } - else { - useStandaloneKotlinRadioButton.setForeground(Color.BLACK); - useStandaloneKotlinRadioButton.setText(initialStandaloneLabelText); - setOKActionEnabled(true); + + copyLibraryCheckbox.setForeground(Color.BLACK); + if (copyLibraryCheckbox.isSelected()) { + if (copyIntoDirectoryField.getText().trim().isEmpty()) { + copyLibraryCheckbox.setForeground(Color.RED); + isError = true; + } } + + setOKActionEnabled(!isError); } private void updateComponents() {