blob: 23aa6c43b60d7b3f97d9e4ce942246be5821d05d [file] [log] [blame]
/*
* 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.SearchableConfigurable;
import com.intellij.openapi.options.newEditor.OptionsEditor;
import com.intellij.ui.ClickListener;
import com.intellij.ui.components.JBLabel;
import org.jetbrains.annotations.NotNull;
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(@NotNull MouseEvent e, int clickCount) {
if (clickCount == 1) {
final OptionsEditor optionsEditor = OptionsEditor.KEY.getData(DataManager.getInstance().getDataContext(parentPanel));
if (optionsEditor != null) {
SearchableConfigurable configurable = optionsEditor.findConfigurableById(PyActiveSdkModuleConfigurable.class.getName());
if (configurable != null) {
optionsEditor.clearSearchAndSelect(configurable);
}
return true;
}
}
return false;
}
}.installOn(myConfigureLabel);
add(myConfigureLabel, BorderLayout.CENTER);
}
}