From d34a2e6593d572e152d08039d0f2d446dd5964df Mon Sep 17 00:00:00 2001 From: Bas Leijdekkers Date: Sun, 11 Dec 2011 20:58:06 +0100 Subject: [PATCH] EA-32512 (CRE: CvsRootParser.valueOf) --- .../config/ui/Cvs2SettingsEditPanel.java | 31 ++++++++++++++----- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java index dfd6cb0043a4..7a2d6d0666a3 100644 --- a/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java +++ b/plugins/cvs/cvs-plugin/src/com/intellij/cvsSupport2/config/ui/Cvs2SettingsEditPanel.java @@ -109,7 +109,7 @@ public class Cvs2SettingsEditPanel { addCvsRootChangeListener(new CvsRootChangeListener() { @Override public void onCvsRootChanged() { - setExtPanelEnabling(); + conditionallyEnableComponents(); } }); @@ -123,6 +123,23 @@ public class Cvs2SettingsEditPanel { } } + public boolean isValidRootConfigured() { + final CvsRootConfiguration rootConfiguration = createConfigurationWithCurrentSettings(); + if (rootConfiguration == null) { + return false; + } + final String rootString = rootConfiguration.getCvsRootAsString(); + if (rootString.trim().isEmpty()) { + return false; + } + try { + CvsRootParser.valueOf(rootString, true); + return true; + } catch (CvsRootException ignore) { + return false; + } + } + public void addCvsRootChangeListener(CvsRootChangeListener cvsRootChangeListener) { myCvsRootConfigurationPanelView.addCvsRootChangeListener(cvsRootChangeListener); } @@ -141,7 +158,7 @@ public class Cvs2SettingsEditPanel { finally { myIsUpdating.set(null); } - setExtPanelEnabling(); + conditionallyEnableComponents(); } public boolean saveTo(CvsRootConfiguration configuration) { @@ -252,10 +269,11 @@ public class Cvs2SettingsEditPanel { private void setEnabled(boolean enabled) { setEnabled(myPanel, enabled); - setExtPanelEnabling(); + conditionallyEnableComponents(); } - private void setExtPanelEnabling() { + private void conditionallyEnableComponents() { + myTestButton.setEnabled(isValidRootConfigured()); try { final CvsRootData currentRootData = CvsRootDataBuilder.createSettingsOn(myCvsRootConfigurationPanelView.getCvsRoot(), true); final String settingsPanelName = getSettingsPanelName(currentRootData); @@ -288,14 +306,11 @@ public class Cvs2SettingsEditPanel { if (method == null) { return EMPTY; } - else { - return method.getDisplayName(); - } + return method.getDisplayName(); } private static void setEnabled(Component component, boolean enabled) { component.setEnabled(enabled); - if (component instanceof Container) { final Container container = (Container)component; for (int i = 0; i < container.getComponentCount(); i++) {