package com.karateca.jstoolbox.config;

import com.intellij.ide.util.PropertiesComponent;

/**
 * @author Andres Dominguez.
 */
public class JsToolboxSettings {

  private static final String TEST_SUFFIX_PROP = "com.karateca.jstoolbox.testSuffix";
  private static final String FILE_SUFFIX_PROP = "com.karateca.jstoolbox.fileSuffix";
  private static final String VIEW_SUFFIX_PROP = "com.karateca.jstoolbox.viewSuffix";

  public static final String DEFAULT_TEST_SUFFIX = "-spec.js";
  public static final String DEFAULT_FILE_SUFFIX = ".js";
  public static final String DEFAULT_VIEW_SUFFIX = ".html";

  private final PropertiesComponent properties;

  private String fileSuffix;
  private String testSuffix;
  private String viewSuffix;

  public JsToolboxSettings() {
    properties = PropertiesComponent.getInstance();
    load();
  }

  public void load() {
    this.testSuffix = properties.getValue(TEST_SUFFIX_PROP, DEFAULT_TEST_SUFFIX);
    this.fileSuffix = properties.getValue(FILE_SUFFIX_PROP, DEFAULT_FILE_SUFFIX);
    this.viewSuffix = properties.getValue(VIEW_SUFFIX_PROP, DEFAULT_VIEW_SUFFIX);
  }

  public void save() {
    properties.setValue(TEST_SUFFIX_PROP, testSuffix);
    properties.setValue(FILE_SUFFIX_PROP, fileSuffix);
    properties.setValue(VIEW_SUFFIX_PROP, viewSuffix);
  }

  public String getFileSuffix() {
    return fileSuffix;
  }

  public void setFileSuffix(String fileSuffix) {
    this.fileSuffix = fileSuffix;
  }

  public String getTestSuffix() {
    return testSuffix;
  }

  public void setTestSuffix(String testSuffix) {
    this.testSuffix = testSuffix;
  }

  public String getViewSuffix() {
    return viewSuffix;
  }

  public void setViewSuffix(String viewSuffix) {
    this.viewSuffix = viewSuffix;
  }
}

@@ -412,16 +412,100 @@
 Suffix%22;
+%0A  private static final String SEARCH_URL_PROP = %22com.karateca.jstoolbox.searchUrl%22;
 %0A%0A  publ
@@ -678,16 +678,113 @@
 %22.html%22;
+%0A  public static final String DEFAULT_SEARCH_URL = %22https://github.com/search?q=%253CFILE_NAME%253E%22;
 %0A%0A  priv
@@ -912,16 +912,44 @@
 wSuffix;
+%0A  private String searchUrl;
 %0A%0A  publ
@@ -1311,16 +1311,95 @@
 UFFIX);%0A
+    this.searchUrl = properties.getValue(SEARCH_URL_PROP, DEFAULT_SEARCH_URL);%0A
   %7D%0A%0A  p
@@ -1583,16 +1583,69 @@
 uffix);%0A
+    properties.setValue(SEARCH_URL_PROP, searchUrl);%0A
   %7D%0A%0A  p
@@ -2044,32 +2044,32 @@
 g viewSuffix) %7B%0A
-
     this.viewSuf
@@ -2089,11 +2089,155 @@
 fix;%0A  %7D
+%0A%0A  public String getSearchUrl() %7B%0A    return searchUrl;%0A  %7D%0A%0A  public void setSearchUrl(String searchUrl) %7B%0A    this.searchUrl = searchUrl;%0A  %7D
 %0A%7D%0A

Add search url