what kind of TextFieldWithAutoCompletion can select method ?

Answered

hello ,I need a TextFieldWithAutoCompletion to select method, By the way how to create "ctrl o" dialog in my plug

16 comments
Comment actions Permalink

You can collect the method items to display (and e.g. filter out specific methods) and then pass these items to TextFieldWithAutoCompletion.

1
Comment actions Permalink

I'm just doing what you said,But I found a bug,When I create a TextFieldwithAutoCompletion in DomFileEditor, my ClassNameReferenceEditor will not work, and the java editor and XML editor will always be in the analysis state

 

0
Comment actions Permalink

Please check idea.log for errors.

0
Comment actions Permalink

I didn't find some useful information. I'm such a rookie,Press Ctrl + enter can restore,I do not know why,Something may not have been initialized ,oh my god,It has taken me several days.

 

some warnings, on errors

2021-09-16 17:28:18,187 [   1966]   WARN - tellij.ide.SystemHealthMonitor - issue detected: bundled.jre.version.message 
2021-09-16 17:28:18,834 [ 2613] WARN - ion.impl.NotificationCollector - Notification group 'Heap Dump Analysis' is already registered in whitelist
2021-09-16 17:28:18,834 [ 2613] WARN - ion.impl.NotificationCollector - Notification group 'Low Memory' is already registered in whitelist
2021-09-16 17:28:19,257 [ 3036] WARN - Container.ComponentManagerImpl - Do not use constructor injection (requestorClass=org.jetbrains.android.compose.AndroidComposeAutoDocumentation)
2021-09-16 17:28:20,056 [ 3835] WARN - tartup.impl.StartupManagerImpl - Activities registered via registerPostStartupActivity must be dumb-aware: org.jetbrains.kotlin.idea.configuration.ui.KotlinConfigurationCheckerComponent$projectOpened$1@424411fa
2021-09-16 17:28:32,353 [ 16132] WARN - .diagnostic.PerformanceWatcher - UI was frozen for 11125ms, details saved to E:\workspace\sandbox2\system\log\threadDumps-freeze-20210916-172826-IC-202.8194.7-Database.open-11sec
2021-09-16 17:34:03,031 [ 346810] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.core.script.configuration.utils.ScriptClassRootsStorage
2021-09-16 17:39:14,499 [ 658278] WARN - com.intellij.util.xmlb.Binding - no accessors for org.jetbrains.kotlin.idea.scripting.gradle.GradleScriptInputsWatcher$Storage
0
Comment actions Permalink

Please share full plugin sources

0
Comment actions Permalink

sdk: IntelliJ IDEA Community Edition IC-202.8194.7

plugs.xml

<idea-plugin>

<name>demoPlugs111</name>
<version>1.0</version>
<vendor email="support@demoPlugs.com" url="http://www.demoPlugs.com">YourCompany</vendor>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html for description -->
<idea-version since-build="173.0"/>

<!-- please see https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/plugin_compatibility.html
on how to target different products -->
<depends>com.intellij.modules.platform</depends>

<depends>com.intellij.modules.platform</depends>
<depends>com.intellij.modules.lang</depends>
<depends>com.intellij.modules.java</depends>

<actions>
<!-- Add your actions here -->
</actions>

<extensions defaultExtensionNs="com.intellij">
<!-- Add your extensions here -->
<dom.fileMetaData implementation="com.xxx.MyDomFileDescription" rootTagName="debugs" domVersion="1">

</dom.fileMetaData>
<fileType name="gapsxx" patterns="*.debugcase" implementationClass="com.xxx.DebugCaseFileType" language="XML"/>

<fileEditorProvider implementation="com.xxx.GapsDebugCaseFileEditorProvider" />
</extensions>

</idea-plugin>
package com.xxx;

import com.intellij.ide.highlighter.XmlLikeFileType;
import com.intellij.lang.xml.XMLLanguage;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;

public class DebugCaseFileType extends XmlLikeFileType {
public static final String EXTENSION = "debugcase";
public static final String FLOW_EXTENSION = "gapsflow";

protected DebugCaseFileType() {
super(XMLLanguage.INSTANCE);
}

@NotNull
@Override
public String getName() {
return "gapsxx";
}

@NotNull
@Override
public String getDescription() {
return "xxxxxxxx";
}

@NotNull
@Override
public String getDefaultExtension() {
return "debugcase";
}

@Nullable
@Override
public Icon getIcon() {
return null;
}

@Override
public boolean isReadOnly() {
return false;
}

@Nullable
@Override
public String getCharset(@NotNull VirtualFile virtualFile, @NotNull byte[] bytes) {
return null;
}
}
package com.xxx;



import com.intellij.ui.TextFieldWithAutoCompletion;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.ui.BasicDomElementComponent;
import org.apache.commons.compress.utils.Lists;

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


public class GapsDebugCaseDomElementComponent extends BasicDomElementComponent<DomElement> {

private final JComponent component;

public GapsDebugCaseDomElementComponent(final DomElement domElement) {
super(domElement);
JPanel jPanel = new JPanel(new GridLayout(1, 1));
TextFieldWithAutoCompletion<String> autoCompletion = TextFieldWithAutoCompletion.create(domElement.getManager().getProject(), Lists.newArrayList(), true, "");
autoCompletion.setText("xxxxxxxxx");

jPanel.add(autoCompletion);
component = jPanel;
}


@Override
public JComponent getComponent() {

return component;
}


}
package com.xxx;


import com.intellij.openapi.fileEditor.FileEditor;
import com.intellij.openapi.fileEditor.FileEditorPolicy;
import com.intellij.openapi.fileEditor.FileEditorProvider;
import com.intellij.openapi.project.DumbAware;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.PsiManager;
import com.intellij.psi.xml.XmlFile;
import com.intellij.util.xml.DomFileElement;
import com.intellij.util.xml.DomManager;
import com.intellij.util.xml.ui.BasicDomElementComponent;
import com.intellij.util.xml.ui.DomFileEditor;
import org.jetbrains.annotations.NotNull;

public class GapsDebugCaseFileEditorProvider implements FileEditorProvider, DumbAware {

public static final String FILE_EDITOR_NAME = "测试用例编辑器";

@Override
public boolean accept(@NotNull Project project, @NotNull VirtualFile virtualFile) {
return DebugCaseFileType.EXTENSION.equalsIgnoreCase(virtualFile.getExtension());
}

@NotNull
@Override
public FileEditor createEditor(@NotNull Project project, @NotNull VirtualFile virtualFile) {
XmlFile file = (XmlFile) PsiManager.getInstance(project).findFile(virtualFile);
DomFileElement<GapsDebugsRootTag> element = DomManager.getDomManager(file.getProject()).getFileElement(file, GapsDebugsRootTag.class);
return new DomFileEditor<BasicDomElementComponent>(
project, virtualFile,
FILE_EDITOR_NAME,
new GapsDebugCaseDomElementComponent(element));

}


@NotNull
@Override
public String getEditorTypeId() {
return this.getClass().getName();
}

@NotNull
@Override
public FileEditorPolicy getPolicy() {
return FileEditorPolicy.PLACE_BEFORE_DEFAULT_EDITOR;
}


}

 

package com.xxx;


import com.intellij.util.xml.Attribute;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.GenericAttributeValue;


public interface GapsDebugsRootTag extends DomElement {
@Attribute("fileDes")
GenericAttributeValue<String> getFileDesAttribute();

}

try to open file :default.debugcase

<debugs fileDes="xxx">

</debugs>

 

package com.xxx;

import com.intellij.util.xml.DomFileDescription;

public class MyDomFileDescription extends DomFileDescription {
public MyDomFileDescription() {
super(GapsDebugsRootTag.class, "debugs");
}
}
0
Comment actions Permalink

Sorry, I don't know your email address,so I make a demo to show this problem . if "default.debugcase" open first,other editor will always be in the analysis state

0
Comment actions Permalink

Please upload sources to https://uploads.services.jetbrains.com/ and specify filename here

0
Comment actions Permalink

Upload id: 2021_09_16_MHkBBfebEW2jcm2d (file: demo form1795944309.zip)

0
Comment actions Permalink

sdk: IntelliJ IDEA Community Edition IC-202.8194.7

0
Comment actions Permalink

GapsDebugCaseDomElementComponent doesn't seem to be in sync of how it should be used.

https://plugins.jetbrains.com/docs/intellij/xml-dom-api.html#ui-organization

Implement custom com.intellij.util.xml.ui.EditorTextFieldControl using TextFieldWithAutoCompletion as underlying component. You can use com.intellij.util.xml.ui.PsiClassControl as reference

 

Please note that DOM UI is no longer maintained.

0
Comment actions Permalink

Thanks a lot,we use StartUpManager to solve,I have a new problem. How do I set the callback for “Enter select” 

0
Comment actions Permalink

register com.intellij.codeInsight.lookup.LookupListener via LookupManagerListener.TOPIC project level bus, handle itemSelected() make sure to filter handling only for your custom UI/items

0
Comment actions Permalink

hi Yann, I have a new problem. There was a problem with the EditorTextField when the theme changed

 

0
Comment actions Permalink

Use com.intellij.ide.ui.LafManagerListener to subscribe to Look&Feel Changes and redraw/update UI if necessary

0

Please sign in to leave a comment.