/*
 * Copyright 2000-2013 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.jetbrains.python.configuration;

import com.intellij.ide.DataManager;
import com.intellij.openapi.options.newEditor.OptionsEditor;
import com.intellij.ui.ClickListener;
import com.intellij.ui.components.JBLabel;

import javax.swing.*;
import java.awt.*;
import java.awt.event.MouseEvent;

/**
 * @author traff
 */
public class PyConfigureInterpretersLinkPanel extends JPanel {
  private final JBLabel myConfigureLabel;

  public PyConfigureInterpretersLinkPanel(final JPanel parentPanel) {
    super(new BorderLayout());
    myConfigureLabel = new JBLabel("<html><a href=\"#\">Configure Interpreters");
    myConfigureLabel.setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
    new ClickListener() {
      @Override
      public boolean onClick(MouseEvent e, int clickCount) {
        if (clickCount == 1) {
          final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(DataManager.getInstance().getDataContext(parentPanel));
          if (optionsEditor != null) {
            PythonSdkConfigurable configurable = optionsEditor.findConfigurable(PythonSdkConfigurable.class);
            if (configurable != null) {
              optionsEditor.clearSearchAndSelect(configurable);
            }
            return true;
          }
        }
        return false;
      }
    }.installOn(myConfigureLabel);

    add(myConfigureLabel, BorderLayout.CENTER);
  }
}

@@ -672,24 +672,84 @@
 ataManager;%0A
+import com.intellij.openapi.options.SearchableConfigurable;%0A
 import com.i
@@ -1662,25 +1662,26 @@
         
-PythonSdk
+Searchable
 Configur
@@ -1734,18 +1734,30 @@
 able
-(PythonSdk
+ById(PyActiveSdkModule
 Conf
@@ -1770,16 +1770,26 @@
 le.class
+.getName()
 );%0A     

use proper configurable in configure interpreters link