From 1a914cf8cd35ee8e419ddc4c063ed83333a4efea Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Thu, 20 May 2010 17:31:12 +0400 Subject: [PATCH] Minor: Removed errorLabel, use DialogWrapper.setErrorText instead. Fixed code style. --- .../hg4idea/ui/HgSetExecutableDialog.form | 18 ++++------------ .../hg4idea/ui/HgSetExecutableDialog.java | 21 +++++++++---------- .../hg4idea/ui/HgSetExecutablePathPanel.java | 10 +++++---- 3 files changed, 20 insertions(+), 29 deletions(-) diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.form b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.form index 5a5ecc9f5bb2..9ba2bbb7a460 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.form +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.form @@ -1,6 +1,6 @@
- + @@ -8,7 +8,7 @@ - + @@ -16,7 +16,7 @@ - + @@ -24,19 +24,9 @@ - - - - - - - - - - - + diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.java index 127b91943ca3..915ed8000f75 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutableDialog.java @@ -21,10 +21,9 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; public class HgSetExecutableDialog extends DialogWrapper { - private JPanel centerPanel; - private HgSetExecutablePathPanel hgExecutablePath; - private JLabel infoLabel; - private JLabel errorLabel; + private JPanel myCenterPanel; + private HgSetExecutablePathPanel myHgExecutablePath; + private JLabel myInfoLabel; public HgSetExecutableDialog(Project project) { super(project, false); @@ -33,23 +32,23 @@ public class HgSetExecutableDialog extends DialogWrapper { @Override protected JComponent createCenterPanel() { - return centerPanel; + return myCenterPanel; } public void setBadHgPath(String hgPath) { - hgExecutablePath.setText(hgPath); - errorLabel.setText(HgVcsMessages.message("hg4idea.configuration.executable.error", hgPath)); + myHgExecutablePath.setText(hgPath); + setErrorText(HgVcsMessages.message("hg4idea.configuration.executable.error", hgPath)); } public String getNewHgPath() { - return hgExecutablePath.getText(); + return myHgExecutablePath.getText(); } private void createUIComponents() { - hgExecutablePath = new HgSetExecutablePathPanel(); - hgExecutablePath.addOKListener(new ActionListener() { + myHgExecutablePath = new HgSetExecutablePathPanel(); + myHgExecutablePath.addOKListener(new ActionListener() { public void actionPerformed(ActionEvent event) { - errorLabel.setText(""); + setErrorText(""); } }); } diff --git a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutablePathPanel.java b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutablePathPanel.java index bbf397d7a4ef..7594a7c86244 100644 --- a/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutablePathPanel.java +++ b/plugins/hg4idea/src/org/zmlx/hg4idea/ui/HgSetExecutablePathPanel.java @@ -7,7 +7,6 @@ import com.intellij.openapi.vfs.VirtualFile; import org.zmlx.hg4idea.HgVcsMessages; import org.zmlx.hg4idea.command.HgVersionCommand; -import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.HashSet; import java.util.Set; @@ -18,7 +17,7 @@ import java.util.Set; */ class HgSetExecutablePathPanel extends TextFieldWithBrowseButton { - private Set okListeners = new HashSet(); + private final Set myOkListeners = new HashSet(); HgSetExecutablePathPanel() { FileChooserDescriptor descriptor = new FileChooserDescriptor(true, false, false, false, false, false) { @@ -28,7 +27,7 @@ class HgSetExecutablePathPanel extends TextFieldWithBrowseButton { if (!command.isValid(path)) { throw new ConfigurationException(HgVcsMessages.message("hg4idea.configuration.executable.error", path)); } - for (ActionListener okListener : okListeners) { + for (ActionListener okListener : myOkListeners) { okListener.actionPerformed(null); } } @@ -36,8 +35,11 @@ class HgSetExecutablePathPanel extends TextFieldWithBrowseButton { addBrowseFolderListener(HgVcsMessages.message("hg4idea.configuration.title"), HgVcsMessages.message("hg4idea.configuration.description"), null, descriptor); } + /** + * Adds a listener which will be called when file chooser dialog is closed successfully. + */ void addOKListener(ActionListener listener) { - okListeners.add(listener); + myOkListeners.add(listener); } }