/*
 * Copyright 2005, Sixth and Red River Software
 *
 *  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.sixrr.metrics.plugin;

import com.intellij.openapi.application.PathManager;
import com.intellij.openapi.components.ExportableApplicationComponent;
import com.sixrr.metrics.utils.MetricsReloadedBundle;
import org.jetbrains.annotations.NonNls;

import java.io.File;

/**
 * Allows for exporting metrics profiles.
 * <p/>
 * <pre>
 * File / Export settings...
 * </pre>
 * <p/>
 * The metrics configuration files are located within <code>.IntellijIDEA50/config/metrics/...</code>
 */
public class MetricsPluginApplicationImpl
        implements ExportableApplicationComponent, MetricsPluginApplication {

    public File[] getExportFiles() {
        @NonNls final String dirName =
                PathManager.getConfigPath() + File.separator + "metrics";
        final File metricsDirectory = new File(dirName);
        final File[] files = metricsDirectory.listFiles();
        final File[] out = new File[files.length + 1];
        out[0] = metricsDirectory;
        System.arraycopy(files, 0, out, 1, files.length);
        return out;
    }

    public String getPresentableName() {
        return MetricsReloadedBundle.message("metrics.profiles.configuration.presentable.name");
    }

    public String getComponentName() {
        return "MetricsReloaded";
    }

    public void initComponent() {
    }

    public void disposeComponent() {
    }
}

@@ -13,17 +13,21 @@
 ght 2005
-,
+-2013
  Sixth a
@@ -47,16 +47,33 @@
 Software
+, Bas Leijdekkers
 %0A *%0A *  
@@ -792,16 +792,52 @@
 ponent;%0A
+import com.intellij.util.ArrayUtil;%0A
 import c
@@ -927,28 +927,95 @@
 ls;%0A
-%0Aimport java.io.File
+import org.jetbrains.annotations.NotNull;%0A%0Aimport java.io.File;%0Aimport java.util.Arrays
 ;%0A%0A/
@@ -1350,16 +1350,43 @@
 tion %7B%0A%0A
+    @NotNull%0A    @Override%0A
     publ
@@ -1456,24 +1456,8 @@
 me =
-%0A               
  Pat
@@ -1655,158 +1655,293 @@
  out
- = new File%5Bfiles.length + 1%5D;%0A        out%5B0%5D = metricsDirectory;%0A        System.arraycopy(files, 0, out, 1, files.length);%0A        return out;%0A    %7D%0A
+;%0A        if (files == null) %7B%0A            out = new File%5B1%5D;%0A        %7D else %7B%0A            out = new File%5Bfiles.length + 1%5D;%0A            System.arraycopy(files, 0, out, 1, files.length);%0A        %7D%0A        out%5B0%5D = metricsDirectory;%0A        return out;%0A    %7D%0A%0A    @NotNull%0A    @Override
 %0A   
@@ -2074,32 +2074,59 @@
 .name%22);%0A    %7D%0A%0A
+    @NotNull%0A    @Override%0A
     public Strin
@@ -2181,32 +2181,46 @@
 loaded%22;%0A    %7D%0A%0A
+    @Override%0A
     public void 
@@ -2240,24 +2240,38 @@
 () %7B%0A    %7D%0A%0A
+    @Override%0A
     public v

fix #21 (Exception when exporting settings in IntelliJ IDEA 12.1.5)