replace constructor with factory method

This commit is contained in:
Nikolay Matveev
2011-07-11 13:44:12 +04:00
parent 0a8820a6b3
commit b1ec5d1ffa
5 changed files with 14 additions and 8 deletions
@@ -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);
@@ -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));
@@ -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);
@@ -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);
@@ -221,7 +221,7 @@ class XsltRunSettingsEditor extends SettingsEditor<XsltRunConfiguration> {
});
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) {