/*
 * Copyright 2000-2009 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.
 *  You may obtain a copy of the License at
 *
 *  http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */

package org.jetbrains.plugins.groovy.griffon;

import com.intellij.execution.configurations.ConfigurationFactory;
import com.intellij.execution.configurations.ConfigurationType;
import com.intellij.execution.configurations.ConfigurationTypeUtil;
import com.intellij.execution.configurations.RunConfiguration;
import com.intellij.openapi.project.Project;
import icons.JetgroovyIcons;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

public class GriffonRunConfigurationType implements ConfigurationType {
  private final ConfigurationFactory myConfigurationFactory;
  @NonNls private static final String GRIFFON_APPLICATION = "Griffon";

  public GriffonRunConfigurationType() {
    myConfigurationFactory = new ConfigurationFactory(this) {
      @Override
      public RunConfiguration createTemplateConfiguration(Project project) {
        return new GriffonRunConfiguration(this, project, GRIFFON_APPLICATION, "run-app");
      }
    };
  }

  public String getDisplayName() {
    return GRIFFON_APPLICATION;
  }

  public String getConfigurationTypeDescription() {
    return GRIFFON_APPLICATION;
  }

  public Icon getIcon() {
    return JetgroovyIcons.Griffon.Griffon;
  }

  @NonNls
  @NotNull
  public String getId() {
    return "GriffonRunConfigurationType";
  }

  public ConfigurationFactory[] getConfigurationFactories() {
    return new ConfigurationFactory[]{myConfigurationFactory};
  }

  public static GriffonRunConfigurationType getInstance() {
    return ConfigurationTypeUtil.findConfigurationType(GriffonRunConfigurationType.class);
  }

}

@@ -651,16 +651,120 @@
 iffon;%0A%0A
+import com.intellij.compiler.options.CompileStepBeforeRun;%0Aimport com.intellij.execution.BeforeRunTask;%0A
 import c
@@ -822,16 +822,16 @@
 actory;%0A
-
 import c
@@ -1062,16 +1062,54 @@
 roject;%0A
+import com.intellij.openapi.util.Key;%0A
 import i
@@ -1633,24 +1633,24 @@
  project) %7B%0A
-
         retu
@@ -1735,16 +1735,250 @@
 %0A      %7D
+%0A%0A      @Override%0A      public void configureBeforeRunTaskDefaults(Key%3C? extends BeforeRunTask%3E providerID, BeforeRunTask task) %7B%0A        if (providerID == CompileStepBeforeRun.ID) %7B%0A          task.setEnabled(false);%0A        %7D%0A      %7D
 %0A    %7D;%0A

Disable CompileBeforeRun for GrailsRunConfiguration and GriffonRunConfiguration.