ComponentWithBrowseButton - optional remove listener on hide
[fedora-idea.git] / java / java-impl / src / com / intellij / refactoring / ui / PackageNameReferenceEditorCombo.java
blobd9d45b4a547ee4d2b8fa4a7c5738b320b6cd8808
1 /*
2 * Copyright 2000-2009 JetBrains s.r.o.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
16 package com.intellij.refactoring.ui;
18 import com.intellij.ide.util.PackageChooserDialog;
19 import com.intellij.openapi.project.Project;
20 import com.intellij.psi.PsiManager;
21 import com.intellij.psi.PsiPackage;
22 import com.intellij.ui.ReferenceEditorComboWithBrowseButton;
23 import org.jetbrains.annotations.NotNull;
25 import java.awt.event.ActionEvent;
26 import java.awt.event.ActionListener;
28 /**
29 * @author yole
31 public class PackageNameReferenceEditorCombo extends ReferenceEditorComboWithBrowseButton {
32 public PackageNameReferenceEditorCombo(final String text, @NotNull final Project project,
33 final String recentsKey, final String chooserTitle) {
34 super(null, text, PsiManager.getInstance(project), false, recentsKey);
35 addActionListener(new ActionListener() {
36 public void actionPerformed(ActionEvent e) {
37 PackageChooserDialog chooser = new PackageChooserDialog(chooserTitle, project);
38 chooser.selectPackage(getText());
39 chooser.show();
40 PsiPackage aPackage = chooser.getSelectedPackage();
41 if (aPackage != null) {
42 setText(aPackage.getQualifiedName());
45 });