From b1ec5d1ffa9e84beecafbf0fc9f7888e037429ef Mon Sep 17 00:00:00 2001 From: Nikolay Matveev Date: Sat, 9 Jul 2011 16:24:57 +0400 Subject: [PATCH] replace constructor with factory method --- .../intellij/diagnostic/logging/EditLogPatternDialog.java | 6 +++--- .../openapi/fileChooser/FileChooserDescriptorFactory.java | 6 +++++- .../plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java | 3 ++- .../idea/svn/dialogs/browser/DiffOptionsDialog.java | 5 +++-- .../intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java b/platform/lang-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java index f1756e4159b7..ea083b0719b2 100644 --- a/platform/lang-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java +++ b/platform/lang-impl/src/com/intellij/diagnostic/logging/EditLogPatternDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -17,7 +17,7 @@ package com.intellij.diagnostic.logging; import com.intellij.diagnostic.DiagnosticBundle; -import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextComponentAccessor; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -52,7 +52,7 @@ public class EditLogPatternDialog extends DialogWrapper { } protected JComponent createCenterPanel() { - myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, new FileChooserDescriptor(true, true, false, false, false, false), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); + myFilePattern.addBrowseFolderListener(UIBundle.message("file.chooser.default.title"), null, null, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(), TextComponentAccessor.TEXT_FIELD_WHOLE_TEXT); myFilePattern.getTextField().getDocument().addDocumentListener(new DocumentAdapter() { protected void textChanged(DocumentEvent e) { setOKActionEnabled(myFilePattern.getText() != null && myFilePattern.getText().length() > 0); diff --git a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java index 91500c2713b2..2696d8904ceb 100644 --- a/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java +++ b/platform/platform-api/src/com/intellij/openapi/fileChooser/FileChooserDescriptorFactory.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -51,6 +51,10 @@ public class FileChooserDescriptorFactory { return new FileChooserDescriptor(false, true, true, false, true, true); } + public static FileChooserDescriptor createSingleFileOrFolderDescriptor() { + return new FileChooserDescriptor(true, true, false, false, false, false); + } + public static FileChooserDescriptor getDirectoryChooserDescriptor(String aSearchedObjectName) { final FileChooserDescriptor singleFolderDescriptor = createSingleFolderDescriptor(); singleFolderDescriptor.setTitle(UIBundle.message("file.chooser.select.object.title", aSearchedObjectName)); diff --git a/plugins/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java b/plugins/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java index ed0533583ff6..893c1ad0baf6 100644 --- a/plugins/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java +++ b/plugins/relaxng/src/org/intellij/plugins/relaxNG/convert/ConvertSchemaSettingsImpl.java @@ -18,6 +18,7 @@ package org.intellij.plugins.relaxNG.convert; import com.intellij.openapi.actionSystem.LangDataKeys; import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.fileTypes.FileType; import com.intellij.openapi.fileTypes.StdFileTypes; import com.intellij.openapi.module.Module; @@ -134,7 +135,7 @@ public class ConvertSchemaSettingsImpl implements ConvertSchemaSettings { final SchemaType outputType = getOutputType(); myLineLength.setEnabled(outputType == SchemaType.DTD || outputType == SchemaType.RNC); - final FileChooserDescriptor descriptor = new FileChooserDescriptor(true, true, false, false, false, false); + final FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); final Module module = ProjectRootManager.getInstance(project).getFileIndex().getModuleForFile(firstFile); descriptor.putUserData(LangDataKeys.MODULE_CONTEXT, module); diff --git a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java index 60e58e4f5da7..e332bf53c10e 100644 --- a/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java +++ b/plugins/svn4idea/src/org/jetbrains/idea/svn/dialogs/browser/DiffOptionsDialog.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2009 JetBrains s.r.o. + * Copyright 2000-2011 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. @@ -24,6 +24,7 @@ package org.jetbrains.idea.svn.dialogs.browser; import com.intellij.openapi.fileChooser.FileChooser; import com.intellij.openapi.fileChooser.FileChooserDescriptor; +import com.intellij.openapi.fileChooser.FileChooserDescriptorFactory; import com.intellij.openapi.project.Project; import com.intellij.openapi.ui.DialogWrapper; import com.intellij.openapi.ui.TextFieldWithBrowseButton; @@ -168,7 +169,7 @@ public class DiffOptionsDialog extends DialogWrapper implements ActionListener { @Nullable private File selectFile(String title, String description) { - FileChooserDescriptor fcd = new FileChooserDescriptor(true, true, false, false, false, false); + FileChooserDescriptor fcd = FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor(); fcd.setShowFileSystemRoots(true); fcd.setTitle(title); fcd.setDescription(description); diff --git a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java index 4b02edbf74fb..a90e2a5cb26d 100644 --- a/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java +++ b/plugins/xpath/xpath-lang/src/org/intellij/lang/xpath/xslt/run/XsltRunSettingsEditor.java @@ -221,7 +221,7 @@ class XsltRunSettingsEditor extends SettingsEditor { }); myOutputFile.addBrowseFolderListener("Choose Output File", "The selected file will be overwritten during execution.", - project, new FileChooserDescriptor(true, true, false, false, false, false)); + project, FileChooserDescriptorFactory.createSingleFileOrFolderDescriptor()); final ItemListener outputStateListener = new ItemListener() { public void itemStateChanged(ItemEvent e) {