/*
 * 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 com.intellij.execution.configurations;

import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.Nls;
import org.jetbrains.annotations.NonNls;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;

/**
 * @author yole
 */
public abstract class ConfigurationTypeBase implements ConfigurationType {
  private static final ConfigurationFactory[] EMPTY_FACTORIES = new ConfigurationFactory[0];

  private final String myId;
  private final String myDisplayName;
  private final String myDescription;
  private final Icon myIcon;
  private ConfigurationFactory[] myFactories;

  protected ConfigurationTypeBase(@NotNull @NonNls String id, @Nls String displayName, @Nls String description, Icon icon) {
    myId = id;
    myDisplayName = displayName;
    myDescription = description;
    myIcon = icon;
    myFactories = EMPTY_FACTORIES;
  }

  protected void addFactory(ConfigurationFactory factory) {
    myFactories = ArrayUtil.append(myFactories, factory);
  }

  @Override
  @Nls
  public String getDisplayName() {
    return myDisplayName;
  }

  @Override
  @Nls
  public String getConfigurationTypeDescription() {
    return myDescription;
  }

  @Override
  public Icon getIcon() {
    return myIcon;
  }

  @Override
  @NotNull
  @NonNls
  public String getId() {
    return myId;
  }

  @Override
  public ConfigurationFactory[] getConfigurationFactories() {
    return myFactories;
  }
}

@@ -640,17 +640,16 @@
 urations
-;
 %0A%0Aimport
@@ -676,17 +676,16 @@
 rrayUtil
-;
 %0Aimport 
@@ -713,17 +713,16 @@
 ions.Nls
-;
 %0Aimport 
@@ -757,51 +757,8 @@
 nNls
-;%0Aimport org.jetbrains.annotations.NotNull;
 %0A%0Aim
@@ -775,17 +775,16 @@
 .swing.*
-;
 %0A%0A/**%0A *
@@ -801,23 +801,16 @@
 ole%0A */%0A
-public 
 abstract
@@ -842,238 +842,219 @@
 ase 
-implements ConfigurationType %7B%0A  private static final ConfigurationFactory%5B%5D EMPTY_FACTORIES = new ConfigurationFactory%5B0%5D;%0A%0A  private final String myId;%0A  private final String myDisplayName;%0A  private final String myDescription;%0A
+protected constructor(@param:NonNls private val myId: String, @param:Nls private val myDisplayName: String, @param:Nls private val myDescription: String,%0A                                                         
   pr
@@ -1063,36 +1063,27 @@
 ate 
-fin
+v
 al 
+my
 Icon
+:
  
-my
 Icon
-;%0A  private
+) :
  Con
@@ -1096,256 +1096,87 @@
 tion
-Factory%5B%5D myFactories;%0A%0A  protected ConfigurationTypeBase(@NotNull @NonNls String id, @Nls String displayName, @Nls String description, Icon icon) %7B%0A    myId = id;%0A    myDisplayName = displayName;%0A    myDescription = description;%0A    myIcon = icon;
+Type %7B%0A  private var myFactories: Array%3CConfigurationFactory%3E? = null%0A%0A  init %7B
 %0A   
@@ -1205,17 +1205,16 @@
 ACTORIES
-;
 %0A  %7D%0A%0A  
@@ -1227,12 +1227,11 @@
 ted 
-void
+fun
  add
@@ -1238,16 +1238,25 @@
 Factory(
+factory: 
 Configur
@@ -1267,24 +1267,16 @@
 nFactory
- factory
 ) %7B%0A    
@@ -1317,16 +1317,18 @@
 actories
+!!
 , factor
@@ -1329,17 +1329,16 @@
 factory)
-;
 %0A  %7D%0A%0A  
@@ -1342,39 +1342,26 @@
 %0A  @
-Override%0A  @Nls%0A  public String
+Nls%0A  override fun
  get
@@ -1373,16 +1373,24 @@
 ayName()
+: String
  %7B%0A    r
@@ -1408,17 +1408,16 @@
 playName
-;
 %0A  %7D%0A%0A  
@@ -1421,39 +1421,26 @@
 %0A  @
-Override%0A  @Nls%0A  public String
+Nls%0A  override fun
  get
@@ -1465,24 +1465,32 @@
 escription()
+: String
  %7B%0A    retur
@@ -1504,25 +1504,24 @@
 cription
-;
 %0A  %7D%0A%0A  
 @Overrid
@@ -1516,30 +1516,19 @@
 %0A%0A  
-@O
+o
 verride
-%0A  public Ico
+ fu
 n ge
@@ -1534,16 +1534,22 @@
 etIcon()
+: Icon
  %7B%0A    r
@@ -1560,17 +1560,16 @@
 n myIcon
-;
 %0A  %7D%0A%0A  
@@ -1573,61 +1573,45 @@
 %0A  @
-Override%0A  @NotNull%0A  @NonNls%0A  public String getId()
+NonNls%0A  override fun getId(): String
  %7B%0A 
@@ -1628,17 +1628,16 @@
 myId
-;
 %0A  %7D%0A%0A  
 @Ove
@@ -1636,27 +1636,24 @@
 %0A%0A  
-@O
+o
 verride
-%0A  public 
+ fun get
 Conf
@@ -1671,15 +1671,21 @@
 ctor
-y%5B%5D get
+ies(): Array%3C
 Conf
@@ -1699,21 +1699,19 @@
 onFactor
-ies()
+y%3E?
  %7B%0A    r
@@ -1727,16 +1727,113 @@
 actories
-;
+%0A  %7D%0A%0A  companion object %7B%0A    private val EMPTY_FACTORIES = arrayOfNulls%3CConfigurationFactory%3E(0)
 %0A  %7D%0A%7D%0A

convert ConfigurationTypeBase to kotlin