gpt4 book ai didi

java - 如何更改 ContentProposalAdapter 的外观

转载 作者:行者123 更新时间:2023-11-30 07:31:33 25 4
gpt4 key购买 nike

我正在使用 ContentProposalAdapter 来自动完成文本框,它工作正常,但我想更改它的外观,例如弹出窗口的字体或背景颜色等等,我搜索了但找不到任何 ContentProposalAdapter 的方法这些东西。如何更改 ContentProposalAdapter 的外观?

最佳答案

我对这个 jface 部分没有任何经验,但是当你查看文档时,你可以找到方法 openProposalPopup ( see docs )

此类提供了一些可覆盖的方法以允许客户端手动控制弹出窗口。但是,大部分实现仍然是私有(private)的。

打开提案弹出窗口并显示提案提供者提供的提案。此方法立即返回。也就是说,它不会等待提案被选中。子类使用此方法显式调用弹出窗口的打开。如果没有要显示的提案,弹出窗口将不会打开,并且会发出哔声。

如果你检查这个方法的代码,你会发现

/**
* Open the proposal popup and display the proposals provided by the
* proposal provider. If there are no proposals to be shown, do not show the
* popup. This method returns immediately. That is, it does not wait for the
* popup to open or a proposal to be selected.
*
* @param autoActivated
* a boolean indicating whether the popup was autoactivated. If
* false, a beep will sound when no proposals can be shown.
*/
private void openProposalPopup(boolean autoActivated) {
if (isValid()) {
if (popup == null) {
// Check whether there are any proposals to be shown.
recordCursorPosition(); // must be done before getting proposals
IContentProposal[] proposals = getProposals();
if (proposals.length > 0) {
if (DEBUG) {
System.out.println("POPUP OPENED BY PRECEDING EVENT"); //$NON-NLS-1$
}
recordCursorPosition();
popup = new ContentProposalPopup(null, proposals);
popup.open();
popup.getShell().addDisposeListener(new DisposeListener() {
public void widgetDisposed(DisposeEvent event) {
popup = null;
}
});
internalPopupOpened();
notifyPopupOpened();
} else if (!autoActivated) {
getControl().getDisplay().beep();
}
}
}
}

/**
* Open the proposal popup and display the proposals provided by the
* proposal provider. This method returns immediately. That is, it does not
* wait for a proposal to be selected. This method is used by subclasses to
* explicitly invoke the opening of the popup. If there are no proposals to
* show, the popup will not open and a beep will be sounded.
*/
protected void openProposalPopup() {
openProposalPopup(false);
}

代码创建了 ContentProposalPopup 实例,它管理弹出窗口小部件的外观和其他一些东西 ( see source code of whole ContentProposalAdapeter class )。

因此,如果您要创建新类来覆盖 openProposalPopup() 并使用您自己的 ContentProposalPopup,您可以根据需要管理外观..

关于java - 如何更改 ContentProposalAdapter 的外观,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7279002/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com