cleanup/generify

This commit is contained in:
Bas Leijdekkers
2011-09-06 12:14:40 +02:00
parent ca2c3bc539
commit 332322d605
2 changed files with 27 additions and 37 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.
@@ -15,6 +15,7 @@
*/
package com.intellij.cvsSupport2.cvsoperations.cvsImport;
import com.intellij.CvsBundle;
import com.intellij.cvsSupport2.connections.CvsEnvironment;
import com.intellij.cvsSupport2.connections.CvsRootProvider;
import com.intellij.cvsSupport2.cvsoperations.common.CvsCommandOperation;
@@ -42,20 +43,21 @@ public class ImportOperation extends CvsCommandOperation {
}
protected Command createCommand(CvsRootProvider root, CvsExecutionEnvironment cvsExecutionEnvironment) {
ImportCommand result = new ImportCommand();
final ImportCommand result = new ImportCommand();
myDetails.prepareCommand(result);
return result;
}
public static ImportOperation createTestInstance(File sourceLocation, CvsEnvironment env) {
ImportDetails details = new ImportDetails(sourceLocation, com.intellij.CvsBundle.message("import.defaults.vendor"),
com.intellij.CvsBundle.message("import.defaults.release_tag"),
com.intellij.CvsBundle.message("import.defaults.log.message"),
sourceLocation.getName(), env, new ArrayList(), new IIgnoreFileFilter(){
public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) {
return false;
}
});
final ImportDetails details = new ImportDetails(sourceLocation, CvsBundle.message("import.defaults.vendor"),
CvsBundle.message("import.defaults.release_tag"),
CvsBundle.message("import.defaults.log.message"),
sourceLocation.getName(), env, new ArrayList(),
new IIgnoreFileFilter(){
public boolean shouldBeIgnored(AbstractFileObject abstractFileObject, ICvsFileSystem cvsFileSystem) {
return false;
}
});
return new ImportOperation(details);
}
@@ -40,13 +40,9 @@ import java.util.*;
*/
public final class ImportCommand extends Command {
// Constants ==============================================================
@NonNls public static final String EXAM_DIR = "server: Importing ";
// Fields =================================================================
private final Map wrapperMap = new HashMap();
private final Map<SimpleStringPattern, KeywordSubstitution> wrapperMap = new HashMap();
private String logMessage;
private String module;
private String releaseTag;
@@ -56,8 +52,7 @@ public final class ImportCommand extends Command {
// Setup ==================================================================
public ImportCommand() {
}
public ImportCommand() {}
// Implemented ============================================================
@@ -110,7 +105,7 @@ public final class ImportCommand extends Command {
}
public String getCvsCommandLine() {
@NonNls final StringBuffer cvsArguments = new StringBuffer("import ");
@NonNls final StringBuilder cvsArguments = new StringBuilder("import ");
cvsArguments.append(getCvsArguments());
cvsArguments.append(' ');
@@ -199,7 +194,7 @@ public final class ImportCommand extends Command {
// Utils ==================================================================
private String getCvsArguments() {
@NonNls final StringBuffer cvsArguments = new StringBuffer();
@NonNls final StringBuilder cvsArguments = new StringBuilder();
cvsArguments.append("-m \"");
cvsArguments.append(CommandUtils.getMessageNotNull(getLogMessage()));
cvsArguments.append("\" ");
@@ -215,10 +210,8 @@ public final class ImportCommand extends Command {
cvsArguments.append(" ");
}
if (wrapperMap.size() > 0) {
final Iterator it = wrapperMap.keySet().iterator();
while (it.hasNext()) {
final SimpleStringPattern pattern = (SimpleStringPattern)it.next();
final KeywordSubstitution keywordSubstitutionOptions = (KeywordSubstitution)wrapperMap.get(pattern);
for (final SimpleStringPattern pattern : wrapperMap.keySet()) {
final KeywordSubstitution keywordSubstitutionOptions = wrapperMap.get(pattern);
cvsArguments.append("-W ");
cvsArguments.append(pattern.toString());
cvsArguments.append(" -k '");
@@ -232,15 +225,14 @@ public final class ImportCommand extends Command {
/**
* Adds requests for specified wrappers to the specified requestList.
*/
private static void addWrapperRequests(Requests requests, Map wrapperMap) {
private static void addWrapperRequests(Requests requests, Map<SimpleStringPattern, KeywordSubstitution> wrapperMap) {
// override the server's ignore list
requests.addArgumentRequest("-I !");
for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) {
final SimpleStringPattern pattern = (SimpleStringPattern)it.next();
final KeywordSubstitution keywordSubstitutionOptions = (KeywordSubstitution)wrapperMap.get(pattern);
for (final SimpleStringPattern pattern : wrapperMap.keySet()) {
final KeywordSubstitution keywordSubstitutionOptions = wrapperMap.get(pattern);
@NonNls final StringBuffer buffer = new StringBuffer();
@NonNls final StringBuilder buffer = new StringBuilder();
buffer.append(pattern.toString());
buffer.append(" -k '");
buffer.append(keywordSubstitutionOptions.toString());
@@ -270,11 +262,9 @@ public final class ImportCommand extends Command {
return;
}
final List subdirectories = new ArrayList();
for (int i = 0; i < files.length; i++) {
final File file = files[i];
final List<File> subdirectories = new ArrayList();
for (final File file : files) {
if (file.isDirectory()) {
final DirectoryObject subDirObject = clientEnvironment.getCvsFileSystem().getLocalFileSystem().getDirectoryObject(file);
@@ -300,8 +290,7 @@ public final class ImportCommand extends Command {
}
}
for (Iterator it = subdirectories.iterator(); it.hasNext();) {
final File subdirectory = (File)it.next();
for (final File subdirectory : subdirectories) {
addFileRequests(subdirectory, requests, requestProcessor, clientEnvironment);
}
}
@@ -324,10 +313,9 @@ public final class ImportCommand extends Command {
private KeywordSubstitution getKeywordSubstMode(String fileName) {
KeywordSubstitution keywordSubstMode = getKeywordSubstitutionOption();
for (Iterator it = wrapperMap.keySet().iterator(); it.hasNext();) {
final SimpleStringPattern pattern = (SimpleStringPattern)it.next();
for (final SimpleStringPattern pattern : wrapperMap.keySet()) {
if (pattern.doesMatch(fileName)) {
keywordSubstMode = (KeywordSubstitution)wrapperMap.get(pattern);
keywordSubstMode = wrapperMap.get(pattern);
break;
}
}