2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 package org
.jetbrains
.plugins
.groovy
.config
;
19 import com
.intellij
.conversion
.*;
20 import org
.jdom
.Element
;
21 import org
.jetbrains
.annotations
.NonNls
;
26 public class GroovyProjectConverter
extends ProjectConverter
{
27 @NonNls private static final String GRAILS_TESTS_RUN_CONFIGURATION_TYPE
= "GrailsTestsRunConfigurationType";
28 @NonNls private static final String GANT_SCRIPT_RUN_CONFIGURATION
= "GantScriptRunConfiguration";
29 @NonNls private static final String GRAILS_RUN_CONFIGURATION_TYPE
= "GrailsRunConfigurationType";
32 public ConversionProcessor
<ModuleSettings
> createModuleFileConverter() {
33 return new GroovyModuleConverter();
37 public ConversionProcessor
<RunManagerSettings
> createRunConfigurationsConverter() {
38 return new ConversionProcessor
<RunManagerSettings
>() {
40 public boolean isConversionNeeded(RunManagerSettings settings
) {
41 for (Element element
: settings
.getRunConfigurations()) {
42 final String confType
= element
.getAttributeValue("type");
43 if (GRAILS_TESTS_RUN_CONFIGURATION_TYPE
.equals(confType
) || GANT_SCRIPT_RUN_CONFIGURATION
.equals(confType
)) {
46 if (GRAILS_RUN_CONFIGURATION_TYPE
.equals(confType
) && "Grails Application".equals(element
.getAttributeValue("factoryName"))) {
54 public void process(RunManagerSettings settings
) throws CannotConvertException
{
55 for (Element element
: settings
.getRunConfigurations()) {
56 final String confType
= element
.getAttributeValue("type");
57 final boolean wasGrails
= GRAILS_TESTS_RUN_CONFIGURATION_TYPE
.equals(confType
);
58 if (wasGrails
|| GANT_SCRIPT_RUN_CONFIGURATION
.equals(confType
)) {
59 if ("true".equals(element
.getAttributeValue("default"))) {
63 element
.setAttribute("type", wasGrails ? GRAILS_RUN_CONFIGURATION_TYPE
: "GroovyScriptRunConfiguration");
64 element
.setAttribute("factoryName", wasGrails ?
"Grails" : "Groovy Script");
67 else if (GRAILS_RUN_CONFIGURATION_TYPE
.equals(confType
) &&
68 "Grails Application".equals(element
.getAttributeValue("factoryName"))) {
69 element
.setAttribute("factoryName", "Grails");