如何更改 ContentProposalAdapter 的外观

发布于 2024-12-02 20:22:49 字数 152 浏览 2 评论 0原文

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

I'm using a ContentProposalAdapter to auto completion of a textbox, it work's OK, but I want change its appearance like font or background color of popup, and more, I searched but I can't find any ContentProposalAdapter's method for doing these stuff. how can i change the appearance of a ContentProposalAdapter?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

简美 2024-12-09 20:22:49

我对这个 jface 部分没有任何经验,但是当您检查文档时,您可以找到方法 openProposalPopup (参见文档)

此类提供一些可重写的方法允许客户端手动控制弹出窗口。但是,大多数实现仍然是私有的。

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

如果您检查此方法的代码,您会发现

/**
 * 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 实例,该实例管理弹出窗口小部件的外观和其他一些东西(查看源代码整个 ContentProposalAdapeter 类)。

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

I don't have any experiences with this jface part, but when you check the documentation, you can find method openProposalPopup (see docs)

This class provides some overridable methods to allow clients to manually control the popup. However, most of the implementation remains private.

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.

If you check code of this method, you'll find

/**
 * 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);
}

The code creates ContentProposalPopup instance, which manage the appearance of popup widget and few other things (see source code of whole ContentProposalAdapeter class).

So if you'll create new class which will override openProposalPopup() and will use your own ContentProposalPopup, you could manage the appearance as you want..

烟花肆意 2024-12-09 20:22:49

我们也遇到了 ContentProposalAdapter 的问题,最终复制粘贴它,然后根据我们的需要进行修改。

We had issues with the ContentProposalAdapter, too, and ended up copy-pasting it, then modified according to our needs.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文