繁体   English   中英

Eclipse RCP - 在调整窗口大小之前,工具项不使用 Edge 浏览器呈现

[英]Eclipse RCP - ToolItems not rendering with Edge browser until window resized

希望你能帮助解决我遇到的一个奇怪问题。

以一个非常简单的 RCP 应用程序为例,顶部有一个工具栏,用户可以在其中切换视角。 一个透视图包含一个Browser组件。

通常,当用户切换到HelpDocumentsView时,会显示一个浏览器,并且顶部会出现一堆红色图标(突出显示)。

在此处输入图像描述

但是当使用 Edge webview2 作为浏览器组件时,使用以下虚拟机增强:

-Dorg.eclipse.swt.browser.DefaultType=edge -Dorg.eclipse.swt.browser.EdgeDir=path\to\Microsoft.WebView2.FixedVersionRuntime.103.0.1264.37.x64

红色图标不显示: 在此处输入图像描述

但是当应用程序调整大小时,它们会出现: 在此处输入图像描述

不知何故,浏览器渲染引擎的选择正在改变ToolItem的渲染方式,我不明白为什么。

我正在尝试使用 Edge,因为在 Windows 上它将使用 IE,而 IE 无法呈现我想在浏览器中呈现的页面上包含的 Javascript。

PerspectiveSwitcherToolbar.java

package com.me.rcp.perspective;

import javax.annotation.PostConstruct;
import javax.inject.Inject;

import org.eclipse.e4.ui.model.application.MApplication;
import org.eclipse.e4.ui.model.application.ui.advanced.MPerspective;
import org.eclipse.e4.ui.workbench.modeling.EModelService;
import org.eclipse.e4.ui.workbench.modeling.EPartService;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Menu;
import org.eclipse.swt.widgets.MenuItem;
import org.eclipse.swt.widgets.ToolBar;
import org.eclipse.swt.widgets.ToolItem;
import org.osgi.service.event.Event;
import org.osgi.service.event.EventHandler;

import com.me.images.ImageProvider;

public class PerspectiveSwitcherToolbar implements EventHandler {
    private static final String HELP_ID = "Help"; //$NON-NLS-1$

    @Inject
    private static MApplication app;

    @Inject
    private static EPartService partService;

    @Inject
    private static EModelService modelService;

    private static ToolBar toolBar;

    @PostConstruct
    private static void postConstruct(final Composite parent) {
    final Composite composite = new Composite(parent, SWT.NONE);

    composite.setLayout(new RowLayout(SWT.HORIZONTAL));

    toolBar = new ToolBar(composite, SWT.FLAT | SWT.WRAP | SWT.RIGHT);

    parent.pack();

    perspectiveSwitch("DataDashboard"); //$NON-NLS-1$
    }

    private static void perspectiveSwitch(final String id) {
    final Menu switcherMenu = new Menu(toolBar);

    final ToolItem choosePerspective = new ToolItem(toolBar, SWT.DROP_DOWN);
    choosePerspective.setImage(ImageProvider.DATA_DASHBOARD);
    choosePerspective.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
        final Rectangle rect = choosePerspective.getBounds();
        final Point pt = switcherMenu.getParent().toDisplay(new Point(rect.x, rect.y));
        switcherMenu.setLocation(pt.x, pt.y + rect.height);
        switcherMenu.setVisible(true);
        }
    });

    final MenuItem helpMenu = new MenuItem(switcherMenu, SWT.PUSH);
    helpMenu.setImage(ImageProvider.HELP);
    helpMenu.addSelectionListener(new SelectionAdapter() {
        @Override
        public void widgetSelected(final SelectionEvent e) {
        perspectiveSwitch(HELP_ID);
        }
    });

    partService.switchPerspective((MPerspective) modelService.find(id, app));

    if (id.equals(HELP_ID)) {
        for (int i = 0; i < 10; i++) {
        new ToolItem(toolBar, SWT.PUSH).setImage(ImageProvider.USER_GUIDE);
        }
    }
    }

    @Override
    public void handleEvent(final Event event) {
    }
}

HelpDocumentsView.java

package com.me.rcp.viewpart;

import javax.annotation.PostConstruct;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.widgets.Composite;

public class HelpDocumentsView {
    @PostConstruct
    public void createPartControl(final Composite parent) {
    new Browser(parent, SWT.NONE);
    }
}
["

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM