mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
IDEA-79353 No completion in the Type field of Custom Renderer preference page
This commit is contained in:
+24
-11
@@ -27,19 +27,16 @@ import com.intellij.debugger.ui.JavaDebuggerSupport;
|
||||
import com.intellij.debugger.ui.tree.render.*;
|
||||
import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.application.ModalityState;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.options.ConfigurationException;
|
||||
import com.intellij.openapi.options.UnnamedConfigurable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.TextFieldWithBrowseButton;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiType;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.ui.AnActionButton;
|
||||
import com.intellij.ui.AnActionButtonRunnable;
|
||||
import com.intellij.ui.TableUtil;
|
||||
import com.intellij.ui.ToolbarDecorator;
|
||||
import com.intellij.ui.*;
|
||||
import com.intellij.ui.table.JBTable;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.ui.AbstractTableCellEditor;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -61,7 +58,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
private CompoundReferenceRenderer myRenderer;
|
||||
private CompoundReferenceRenderer myOriginalRenderer;
|
||||
private Project myProject;
|
||||
private TextFieldWithBrowseButton myClassNameField;
|
||||
private ClassNameEditorWithBrowseButton myClassNameField;
|
||||
private JRadioButton myRbDefaultLabel;
|
||||
private JRadioButton myRbExpressionLabel;
|
||||
private JRadioButton myRbDefaultChildrenRenderer;
|
||||
@@ -133,7 +130,7 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
myRbListChildrenRenderer.addItemListener(updateListener);
|
||||
myRbExpressionChildrenRenderer.addItemListener(updateListener);
|
||||
|
||||
myClassNameField = new TextFieldWithBrowseButton(new ActionListener() {
|
||||
myClassNameField = new ClassNameEditorWithBrowseButton(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
PsiClass psiClass = DebuggerUtils.getInstance()
|
||||
.chooseClassDialog(DebuggerBundle.message("title.compound.renderer.configurable.choose.renderer.reference.type"), myProject);
|
||||
@@ -143,8 +140,8 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
updateContext(qName);
|
||||
}
|
||||
}
|
||||
});
|
||||
myClassNameField.getTextField().addFocusListener(new FocusAdapter() {
|
||||
}, myProject);
|
||||
myClassNameField.getEditorTextField().addFocusListener(new FocusAdapter() {
|
||||
public void focusLost(FocusEvent e) {
|
||||
final String qName = myClassNameField.getText();
|
||||
updateContext(qName);
|
||||
@@ -515,4 +512,20 @@ public class CompoundRendererConfigurable implements UnnamedConfigurable {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static class ClassNameEditorWithBrowseButton extends ReferenceEditorWithBrowseButton {
|
||||
private ClassNameEditorWithBrowseButton(ActionListener browseActionListener, final Project project) {
|
||||
super(browseActionListener, project,
|
||||
new Function<String, Document>() {
|
||||
@Override
|
||||
public Document fun(String s) {
|
||||
PsiPackage defaultPackage = JavaPsiFacade.getInstance(project).findPackage("");
|
||||
final JavaCodeFragment fragment =
|
||||
JavaCodeFragmentFactory.getInstance(project).createReferenceCodeFragment(s, defaultPackage, true, true);
|
||||
fragment.setVisibilityChecker(JavaCodeFragment.VisibilityChecker.EVERYTHING_VISIBLE);
|
||||
return PsiDocumentManager.getInstance(project).getDocument(fragment);
|
||||
}
|
||||
}, "");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -62,7 +62,7 @@ import java.util.List;
|
||||
* @author max
|
||||
*/
|
||||
public class EditorTextField extends NonOpaquePanel implements DocumentListener, TextComponent, DataProvider,
|
||||
DocumentBasedComponent {
|
||||
DocumentBasedComponent, FocusListener {
|
||||
private static final Logger LOG = Logger.getInstance("#com.intellij.ui.EditorTextField");
|
||||
public static final Key<Boolean> SUPPLEMENTARY_KEY = Key.create("Supplementary");
|
||||
|
||||
@@ -73,6 +73,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
private Component myNextFocusable = null;
|
||||
private boolean myWholeTextSelected = false;
|
||||
private final List<DocumentListener> myDocumentListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private final List<FocusListener> myFocusListeners = ContainerUtil.createLockFreeCopyOnWriteList();
|
||||
private boolean myIsListenerInstalled = false;
|
||||
private boolean myIsViewer;
|
||||
private boolean myIsSupplementary;
|
||||
@@ -119,7 +120,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
// todo[dsl,max]
|
||||
setFocusable(true);
|
||||
// dsl: this is a weird way of doing things....
|
||||
addFocusListener(new FocusListener() {
|
||||
super.addFocusListener(new FocusListener() {
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
requestFocus();
|
||||
@@ -321,6 +322,9 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
}
|
||||
|
||||
remove(editor.getComponent());
|
||||
|
||||
editor.getContentComponent().removeFocusListener(this);
|
||||
|
||||
final Application application = ApplicationManager.getApplication();
|
||||
final Runnable runnable = new Runnable() {
|
||||
@Override
|
||||
@@ -522,6 +526,7 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
|
||||
editor.putUserData(SUPPLEMENTARY_KEY, myIsSupplementary);
|
||||
editor.getContentComponent().setFocusCycleRoot(false);
|
||||
editor.getContentComponent().addFocusListener(this);
|
||||
|
||||
editor.setPlaceholder(myHintText);
|
||||
|
||||
@@ -746,6 +751,30 @@ public class EditorTextField extends NonOpaquePanel implements DocumentListener,
|
||||
return myEditor == null ? this : myEditor.getContentComponent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void addFocusListener(FocusListener l) {
|
||||
myFocusListeners.add(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void removeFocusListener(FocusListener l) {
|
||||
myFocusListeners.remove(l);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusGained(FocusEvent e) {
|
||||
for (FocusListener listener : myFocusListeners) {
|
||||
listener.focusGained(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void focusLost(FocusEvent e) {
|
||||
for (FocusListener listener : myFocusListeners) {
|
||||
listener.focusLost(e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
if (myEditor != null && myEditor.isRendererMode()) return null;
|
||||
|
||||
Reference in New Issue
Block a user