【问题标题】:Eclipse RCP detached views: How to control the z-index?Eclipse RCP 分离视图:如何控制 z-index?
【发布时间】:2011-10-22 03:51:12
【问题描述】:

假设我有 2 个视图(A,B)分离。工作台外壳顶部的视图 B 上方的视图 A。

问题 1: 如何让用户点击视图使其位于顶部?

问题 2: 现在我使用其他应用程序的窗口,比如记事本,来覆盖视图 A。 是否可以让用户只单击视图 A 将其翻转到记事本顶部,同时保持视图 B 和记事本后面的主视图?

感谢大家的回答

【问题讨论】:

    标签: view focus eclipse-rcp rcp detach


    【解决方案1】:

    我终于做了一些肮脏的工作:

       <extension
             point="org.eclipse.ui.internalTweaklets">
          <tweaklet
    
    definition="org.eclipse.ui.internal.tweaklets.WorkbenchImplementation"
                description="Customized Detached View"
                id="id1"
                implementation="tweaklets.WorkbenchImplementation"
                name="Customized Detached View">
          </tweaklet>
       </extension> 
    

    我的 WorkbenchImplementation.java

    public class WorkbenchImplementation extends Workbench3xImplementation {
    
        private static final Logger logger = LoggerFactory.getLogger(WorkbenchImplementation.class);
    
        @Override
        public WorkbenchWindow createWorkbenchWindow(int newWindowNumber) {
            // return super.createWorkbenchWindow(newWindowNumber);
            return new WorkbenchWindow(newWindowNumber) {
    
                @Override
                protected void configureShell(Shell shell) {
                    super.configureShell(shell);
    
                    try {
                        Field field = WorkbenchWindow.class.getDeclaredField("detachedWindowShells");
                        field.setAccessible(true);
                        field.set(this, createShellPool(shell));
                    } catch (Exception e) {
                        logger.error("Error tweaking WorkbenchWindow", e);
                    }
                }
    
            };
        }
    
        protected ShellPool createShellPool(Shell shell) {
            // return new ShellPool(null, SWT.TOOL | SWT.TITLE | SWT.MAX | SWT.RESIZE | Window.getDefaultOrientation());
            return new ShellPool(null, SWT.NO_TRIM | Window.getDefaultOrientation());
        }
    
    }
    

    【讨论】:

      【解决方案2】:

      这个问题没有一般的答案。窗口管理器的行为很大程度上取决于本机窗口管理器。例如。 Windows 7 和 OSX 的行为不同。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-12-20
        • 2012-12-17
        • 2016-11-18
        • 2012-12-24
        • 2012-03-22
        相关资源
        最近更新 更多