mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-91559 (CVS: Import into CVS: disable Finish if the NameInRepository field is empty)
This commit is contained in:
+8
-10
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2009 JetBrains s.r.o.
|
||||
* Copyright 2000-2012 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.
|
||||
@@ -31,10 +31,9 @@ import java.awt.event.ActionListener;
|
||||
public class CvsFieldValidator {
|
||||
public static final char[] INVALID_CHARACTERS = new char[]{'`', '$', '.', ',', ':', ';', '@', '\'', ' '};
|
||||
|
||||
private CvsFieldValidator() {
|
||||
}
|
||||
private CvsFieldValidator() {}
|
||||
|
||||
private static void reportError(JLabel errorLabel, String message, TagNameFieldOwner tagNameFieldOwner) {
|
||||
public static void reportError(JLabel errorLabel, String message, TagNameFieldOwner tagNameFieldOwner) {
|
||||
@NonNls final String text = "<html><font color='red'><b>" + message + "</b></font></html>";
|
||||
errorLabel.setText(text);
|
||||
if (tagNameFieldOwner != null) {
|
||||
@@ -45,6 +44,7 @@ public class CvsFieldValidator {
|
||||
public static void installOn(final TagNameFieldOwner dialog, final JTextField field, final JLabel label) {
|
||||
installOn(dialog, field, label, new AbstractButton[0]);
|
||||
field.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void textChanged(DocumentEvent event) {
|
||||
checkTagNameField(dialog, field, label);
|
||||
}
|
||||
@@ -57,6 +57,7 @@ public class CvsFieldValidator {
|
||||
final JLabel label,
|
||||
AbstractButton[] buttons) {
|
||||
field.getDocument().addDocumentListener(new DocumentAdapter() {
|
||||
@Override
|
||||
public void textChanged(DocumentEvent event) {
|
||||
checkTagNameField(dialog, field, label);
|
||||
}
|
||||
@@ -64,6 +65,7 @@ public class CvsFieldValidator {
|
||||
|
||||
for (AbstractButton button : buttons) {
|
||||
button.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
checkTagNameField(dialog, field, label);
|
||||
}
|
||||
@@ -86,13 +88,12 @@ public class CvsFieldValidator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static boolean checkField(JTextField field,
|
||||
JTextField[] shouldDifferFrom,
|
||||
boolean shouldStartFromLetter,
|
||||
JLabel errorMessage, TagNameFieldOwner tagNameFieldOwner) {
|
||||
String text = field.getText().trim();
|
||||
if (text.length() == 0) {
|
||||
final String text = field.getText().trim();
|
||||
if (text.isEmpty()) {
|
||||
reportError(errorMessage, CvsBundle.message("error.message.field.cannot.be.empty"), tagNameFieldOwner);
|
||||
return false;
|
||||
}
|
||||
@@ -112,7 +113,6 @@ public class CvsFieldValidator {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (shouldStartFromLetter && !Character.isLetter(text.charAt(0))) {
|
||||
reportError(errorMessage, CvsBundle.message("error.message.field.value.must.start.with.a.letter"), tagNameFieldOwner);
|
||||
return false;
|
||||
@@ -121,6 +121,4 @@ public class CvsFieldValidator {
|
||||
errorMessage.setText(" ");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,7 +21,7 @@
|
||||
<properties/>
|
||||
<border type="none"/>
|
||||
<children>
|
||||
<component id="4cdd4" class="javax.swing.JLabel" binding="myNameLabel">
|
||||
<component id="4cdd4" class="javax.swing.JLabel" binding="myModuleNameLabel">
|
||||
<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>
|
||||
@@ -69,7 +69,7 @@
|
||||
</constraints>
|
||||
<properties/>
|
||||
</component>
|
||||
<component id="22e23" class="javax.swing.JLabel">
|
||||
<component id="22e23" class="javax.swing.JLabel" binding="myModuleNameErrorMessage">
|
||||
<constraints>
|
||||
<grid row="0" column="2" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false">
|
||||
<minimum-size width="250" height="-1"/>
|
||||
|
||||
+20
-27
@@ -20,10 +20,10 @@ import com.intellij.cvsSupport2.config.ImportConfiguration;
|
||||
import com.intellij.cvsSupport2.ui.experts.CvsWizard;
|
||||
import com.intellij.cvsSupport2.ui.experts.WizardStep;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.ui.DocumentAdapter;
|
||||
|
||||
import javax.swing.*;
|
||||
import javax.swing.event.DocumentEvent;
|
||||
import javax.swing.event.DocumentListener;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.io.File;
|
||||
@@ -33,6 +33,7 @@ import java.util.Collection;
|
||||
* author: lesya
|
||||
*/
|
||||
public class ImportSettingsStep extends WizardStep {
|
||||
|
||||
private JPanel myPanel;
|
||||
private JTextField myModuleName;
|
||||
private JTextField myVendor;
|
||||
@@ -47,9 +48,10 @@ public class ImportSettingsStep extends WizardStep {
|
||||
|
||||
private JCheckBox myCheckoutAfterImport;
|
||||
private JCheckBox myMakeCheckedOutFilesReadOnly;
|
||||
private JLabel myModuleNameErrorMessage;
|
||||
private JLabel myVendorErrorMessage;
|
||||
private JLabel myReleaseTagErrorMessage;
|
||||
private JLabel myNameLabel;
|
||||
private JLabel myModuleNameLabel;
|
||||
private JLabel myVendorLabel;
|
||||
private JLabel myReleaseTagLabel;
|
||||
private JLabel myLogMessageLabel;
|
||||
@@ -70,14 +72,18 @@ public class ImportSettingsStep extends WizardStep {
|
||||
mySelectImportLocationStep = selectImportLocationStep;
|
||||
myImportConfiguration = importConfiguration;
|
||||
|
||||
checkFields();
|
||||
|
||||
final MyDocumentListener listener = new MyDocumentListener();
|
||||
final DocumentAdapter listener = new DocumentAdapter() {
|
||||
@Override
|
||||
protected void textChanged(DocumentEvent e) {
|
||||
checkFields();
|
||||
}
|
||||
};
|
||||
myModuleName.getDocument().addDocumentListener(listener);
|
||||
myVendor.getDocument().addDocumentListener(listener);
|
||||
myReleaseTag.getDocument().addDocumentListener(listener);
|
||||
|
||||
myLogMessageLabel.setLabelFor(myLogMessage);
|
||||
myNameLabel.setLabelFor(myModuleName);
|
||||
myModuleNameLabel.setLabelFor(myModuleName);
|
||||
myReleaseTagLabel.setLabelFor(myReleaseTag);
|
||||
myVendorLabel.setLabelFor(myVendor);
|
||||
|
||||
@@ -115,6 +121,13 @@ public class ImportSettingsStep extends WizardStep {
|
||||
final JTextField[] fields = new JTextField[]{myReleaseTag, myVendor};
|
||||
boolean result = CvsFieldValidator.checkField(myVendor, fields, true, myVendorErrorMessage, null);
|
||||
result &= CvsFieldValidator.checkField(myReleaseTag, fields, true, myReleaseTagErrorMessage, null);
|
||||
final String moduleName = myModuleName.getText().trim();
|
||||
if (moduleName.isEmpty()) {
|
||||
CvsFieldValidator.reportError(myModuleNameErrorMessage, CvsBundle.message("error.message.field.cannot.be.empty"), null);
|
||||
}
|
||||
else {
|
||||
myModuleNameErrorMessage.setText(" ");
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -187,24 +200,4 @@ public class ImportSettingsStep extends WizardStep {
|
||||
public Collection<FileExtension> getFileExtensions() {
|
||||
return myImportConfiguration.getExtensions();
|
||||
}
|
||||
|
||||
private class MyDocumentListener implements DocumentListener {
|
||||
|
||||
public MyDocumentListener() {}
|
||||
|
||||
@Override
|
||||
public void changedUpdate(DocumentEvent e) {
|
||||
checkFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void insertUpdate(DocumentEvent e) {
|
||||
checkFields();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeUpdate(DocumentEvent e) {
|
||||
checkFields();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user