org.eclipse.core.expressions.propertyTesters

本文介绍如何在Eclipse RCP应用中添加快速视图(Fast View)及自定义用户界面元素,包括使用JavaElementPropertyTester进行条件判断、定义快捷命令以及通过WorkbenchWindowAdvisor激活快速视图栏。

   <extension point="org.eclipse.core.expressions.propertyTesters">
      <propertyTester
        id="org.eclipse.jdt.core.javaElementPropertyTester"
        class="org.eclipse.jdt.internal.core.manipulation.JavaElementPropertyTester"
        namespace="org.eclipse.jdt.core"
        properties="name,isInJavaProject,isInJavaProjectWithNature,isOnClasspath,hasTypeOnClasspath,inSourceFolder,inArchive,inExternalArchive,projectOption"
        type="org.eclipse.jdt.core.IJavaElement"/>
   </extension>

 

用法:

                  <adapt type="org.eclipse.jdt.core.IJavaElement">
                   <test property="org.eclipse.jdt.core.isInJavaProject"/>
                  </adapt>

 

 

         <enabledWhen>
            <and>
        <instanceof value="org.eclipse.jdt.core.IPackageFragmentRoot"/>
        <not>
          <test property="org.eclipse.jdt.core.inSourceFolder"/>
        </not>
      </and>
         </enabledWhen>

JavaElementPropertyTester继承PropertyTester,实现test方法,被test的对象是第一个参数,property如isInJavaProject,inSourceFolder是第二个参数,第三个参数是参数,第四个参数是期望值,如:

         <enabledWhen>
       <adapt type="org.eclipse.core.resources.IProject">
            <test property="org.eclipse.core.resources.projectNature" value="org.eclipse.jdt.core.javanature"/>
       </adapt>        
         </enabledWhen>

 

里面的value是第四个参数

 

 

 

点右键出现的properties是通过org.eclipse.ui.propertyPages来扩展的

 

 

 

 

 

 

   <extension point="org.eclipse.ui.commands">

      <command
            name="%ActionDefinition.stepIntoSelection.name"
            description="%ActionDefinition.stepIntoSelection.description"
            categoryId="org.eclipse.debug.ui.category.run"
            id="org.eclipse.jdt.debug.ui.commands.StepIntoSelection">
      </command>

   </extension>

 

   <extension point="org.eclipse.ui.bindings">
      <key
            sequence="M1+F5"
            contextId="org.eclipse.debug.ui.debugging"
            commandId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
            schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"/>

   </extension>

 

 

         <action
               class="org.eclipse.jdt.internal.debug.ui.actions.StepIntoSelectionActionDelegate"
               definitionId="org.eclipse.jdt.debug.ui.commands.StepIntoSelection"
               enablesFor="*"
               helpContextId="step_into_selection_action_context"
               id="org.eclipse.jdt.debug.ui.cuPopup.StepIntoSelection"
               label="%stepIntoSelectionAction.label"
               menubarPath="additions">
         </action>

 

definitionId是commandId

 

 

 

codeassist与ContentAssistAction,ContentAssistant,CompletionProposalPopup,显示的是CompletionProposalPopup#fProposalShell

 

 

 

Using Fast Views in Eclipse RCP

In Adding the error view to RCP application one commenter asked how he could add a view as a fast view to an Eclipse RCP application.

To add views as fast view to your RCP application you have to do two things:

1.) Add your view as “fast” via the perspective extension point

 

 

2.) Activate the FastViewBar via the ApplicationWorkbenchWindow Advisor (configurer.setShowFastViewBars(true);)

package de.vogella.test;

import org.eclipse.swt.graphics.Point;
import org.eclipse.ui.application.ActionBarAdvisor;
import org.eclipse.ui.application.IActionBarConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchWindowAdvisor extends WorkbenchWindowAdvisor {

    public ApplicationWorkbenchWindowAdvisor(IWorkbenchWindowConfigurer configurer) {
        super(configurer);
    }

    @Override
	public ActionBarAdvisor createActionBarAdvisor(IActionBarConfigurer configurer) {
        return new ApplicationActionBarAdvisor(configurer);
    }

    @Override
	public void preWindowOpen() {
    	IWorkbenchWindowConfigurer configurer = getWindowConfigurer();

    	configurer.setInitialSize(new Point(1024, 800));
		configurer.setShowStatusLine(true);
		configurer.setTitle("Network Analyser");
		configurer.setShowFastViewBars(true);
    }

}

This should be sufficient to show your view in your RCP application in the fast view pane.

 

 

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值