From a90a1d652fa2e5f1cef3c0dfd2d4ee9c2c5b69c1 Mon Sep 17 00:00:00 2001 From: Constantine Plotnikov Date: Mon, 27 Oct 2008 17:52:25 +0300 Subject: [PATCH] Added javadoc to TextComponentAccessor and made vcs mapping dialog to use project directory as default directory. --- .../intellij/openapi/ui/TextComponentAccessor.java | 27 +++++++++++++++++++++- .../VcsMappingConfigurationDialog.java | 13 +++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/platform-api/src/com/intellij/openapi/ui/TextComponentAccessor.java b/platform-api/src/com/intellij/openapi/ui/TextComponentAccessor.java index 9d45b69878..fb65d728d3 100644 --- a/platform-api/src/com/intellij/openapi/ui/TextComponentAccessor.java +++ b/platform-api/src/com/intellij/openapi/ui/TextComponentAccessor.java @@ -21,9 +21,16 @@ import javax.swing.*; import java.awt.*; /** + * Text component accessor. It wraps access to the content of text component + * and it might perform some translations between text representation and + * component objects. + * * @author dyoma */ public interface TextComponentAccessor { + /** + * The accessor that gets and changes whole text + */ TextComponentAccessor TEXT_FIELD_WHOLE_TEXT = new TextComponentAccessor() { public String getText(JTextField textField) { return textField.getText(); @@ -34,6 +41,9 @@ public interface TextComponentAccessor { } }; + /** + * The accessor that replaces selection or whole text if there is no selection + */ TextComponentAccessor TEXT_FIELD_SELECTED_TEXT = new TextComponentAccessor() { public String getText(JTextField textField) { String selectedText = textField.getSelectedText(); @@ -46,6 +56,9 @@ public interface TextComponentAccessor { } }; + /** + * The accessor that gets and changes whole text + */ TextComponentAccessor STRING_COMBOBOX_WHOLE_TEXT = new TextComponentAccessor() { public String getText(JComboBox comboBox) { Object item = comboBox.getEditor().getItem(); @@ -56,7 +69,9 @@ public interface TextComponentAccessor { comboBox.getEditor().setItem(text); } }; - + /** + * The accessor that gets and changes whole text + */ TextComponentAccessor TEXT_FIELD_WITH_HISTORY_WHOLE_TEXT = new TextComponentAccessor() { public String getText(TextFieldWithHistory textField) { return textField.getText(); @@ -67,7 +82,17 @@ public interface TextComponentAccessor { } }; + /** + * Get text from component + * @param component a component to examine + * @return the text (possibly adjusted) + */ String getText(T component); + /** + * Set text to the component + * @param component the component + * @param text the text to set + */ void setText(T component, String text); } diff --git a/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsMappingConfigurationDialog.java b/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsMappingConfigurationDialog.java index ca70f0a085..2a1d74bd9b 100644 --- a/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsMappingConfigurationDialog.java +++ b/vcs-impl/src/com/intellij/openapi/vcs/configurable/VcsMappingConfigurationDialog.java @@ -110,6 +110,19 @@ public class VcsMappingConfigurationDialog extends DialogWrapper { FileChooserDescriptor fileChooserDescriptor) { super(title, description, textField, project, fileChooserDescriptor, TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); } + + @Override + protected VirtualFile getInitialFile() { + // suggest project base dir only if nothing is typed in the component. + String text = getComponentText(); + if(text.length() == 0) { + VirtualFile file = myProject.getBaseDir(); + if(file != null) { + return file; + } + } + return super.getInitialFile(); + } @Override protected void onFileChoosen(final VirtualFile chosenFile) { -- 2.11.4.GIT