锘??xml version="1.0" encoding="utf-8" standalone="yes"?>
]]>
* Adds a view with the given compound id to this page layout.
* See the {@link IPageLayout} type documentation for more details about compound ids.
* The primary id must name a view contributed to the workbench's view extension point
* (named <code>"org.eclipse.ui.views"</code>).
*
* @param viewId the compound view id
* @param relationship the position relative to the reference part;
* one of <code>TOP</code>, <code>BOTTOM</code>, <code>LEFT</code>,
* or <code>RIGHT</code>
* @param ratio a ratio specifying how to divide the space currently occupied by the reference part,
* in the range <code>0.05f</code> to <code>0.95f</code>.
* Values outside this range will be clipped to facilitate direct manipulation.
* For a vertical split, the part on top gets the specified ratio of the current space
* and the part on bottom gets the rest.
* Likewise, for a horizontal split, the part at left gets the specified ratio of the current space
* and the part at right gets the rest.
* @param refId the id of the reference part; either a view id, a folder id,
* or the special editor area id returned by <code>getEditorArea</code>
*/
public void addView(String viewId, int relationship, float ratio,
String refId);
]]>
闇瑕佷嬌鐢?div style="display: inline-block; ">ActionFactory.SAVE,ActionFactory.SAVE_ALL鍙樹負鍙敤鐘舵侊紝鍙渶瑕佽緗紪杈戝櫒EditorPart鐨刬sDirty()鏂規硶榪斿洖涓簍rue鍗沖彲銆?br /> ActionFactory.SAVE_AS璁劇疆緙栬緫鍣‥ditorPart鐨刬isSaveAsAllowed()涓簍rue鍗沖彲銆?br /> 浣嗘槸ActionFactory.DELETE闇瑕佸叾浠栬鍥炬垨緙栬緫鍣ㄤ腑娉ㄥ唽鍏ㄥ眬鐨勫彞鏌勶紝鍙互閫氳繃濡備笅鏂規硶浣跨敤editorSite.getActionBars().setGlobalActionHandler(
]]>
]]>
@Override
public User unmarshal(TO to) throws Exception {
return (User)to;
}
@Override
public TO marshal(User user) throws Exception {
return (TO)user;
}
}
public interface TypeConvert {
@WebMethod
@XmlJavaTypeAdapter(UserTOAdapter.class)
User addUser(User user);
}
]]> private void loadExtensionRegistry(){
//鑾峰彇鎵╁睍鐐規敞鍐岀鐞嗗璞?/span>
IExtensionRegistry extReg = Platform.getExtensionRegistry();
//鑾峰彇鏌愮娉ㄥ唽鎵╁睍鐐?/span>
IExtensionPoint ExtPoint = extReg.getExtensionPoint(PLUGIN_ID ,"ExtensionPointId");
//鑾峰彇鎵╁睍鐐瑰寘鐨勬湁鎵╁睍淇℃伅
IExtension[] exts = ExtPoint.getExtensions();
for(IExtension ext : exts){
//璇誨彇鎵╁睍鐐逛腑鐨勫厓鏁頒俊鎭?/span>
IConfigurationElement[] configElements = ext.getConfigurationElements();
for (IConfigurationElement element : configElements) {
//璇誨彇鍏冪礌涓殑姣忎竴涓睘鎬т俊鎭?br />
//璇誨彇鍙墽琛岀被
UBPAction action = (UBPAction)element.createExecutableExtension("ClassTag");
//璇誨彇灞炴?/span>
String iconPath = element.getAttribute(BusinessDefine.TAG_ICON);
if (iconPath != null) {
//杞負鍖栧浘鏍囧璞?/span>
ImageDescriptor icon = imageDescriptorFromPlugin(pluginId, iconPath);
}
//璇誨彇瀛愬厓绱犱俊鎭?/span>
IConfigurationElement[] children = element.getChildren("child");
for (IConfigurationElement child : children){
//璇誨彇瀛愬厓绱犵殑灞炴?/span>
child.getAttribute("AttributeId");
}
}
}
}
]]>
]]>
鐐瑰嚮Validate Plug-ins鎸夐挳錛屼細寮瑰嚭涓涓獥浣擄紝鏄劇ず鎻掍歡閿欒鐨勫師鍥?
]]>
娣誨姞鑿滃崟
娣誨姞鑿滃崟宸ュ叿鏍忕涓縐嶆柟娉?br />
makeActions鍒涘緩action,娉ㄥ唽action;regsiter(action)鏄敤鏉ユ妸瀹炰緥娉ㄥ唽鍒板伐浣滃彴涓紝褰撳伐浣滃彴閿姣佺殑鏃跺欙紝action涔熷彲浠ヨ閿姣?br />
action闇瑕佸疄鐜癐WorkbenchAction鎺ュ彛
fillMenuBar寤鴻彍鍗?宸ュ叿鏉?璁劇疆鐩稿搴旂殑action;
娣誨姞鑿滃崟宸ュ叿鏍忕浜岀鏂規硶
鍦╬lugin.xml涓坊鍔犻厤緗?br />
<extension
id ="cn.blogjava.youxia.actionset"
name ="鎴戠殑鑿滃崟鎵╁睍"
point ="org.eclipse.ui.actionSets">
<actionSet
description ="絎竴涓墿灞?
id ="RCP_Start.actionSet1"
label ="RCP_Start.actionSet1"
visible ="true" >
<action class ="cn.blogjava.youxia.actions.Action2"
icon ="icons/alt_window_16.gif"
id ="RCP_Start.action2"
label ="絎簩涓彍鍗曢」"
menubarPath ="cn.blogjava.youxia.firstmenu/additions"
style ="push"
toolbarPath ="additions"
tooltip ="絎簩涓彍鍗曢」鐨勬寜閽? />
</actionSet>
</extension>
Action2蹇呴』瑕佸疄鐜板疄鐜皁rg.eclipse.ui.IWorkbenchWindowActionDelegate鎺ュ彛錛屽瀹氫箟浜嗕竴涓柟娉昿ublic void selectionChanged(IAction action, ISelection selection)錛岃繖涓柟娉曟槸蹇呴』鐨勶紝浠ヤ究宸ヤ綔鍙扮獥鍙e湪鐢ㄦ埛閫夊畾鍝竴欏硅祫婧愮殑鏃跺欓氱煡鎴戜滑鐨凙ction綾葷殑瀹炰緥銆傝繖涓柟娉曟槸蹇呴』鐨勶紝浠ヤ究宸ヤ綔鍙扮獥鍙e湪鐢ㄦ埛閫夊畾鍝竴欏硅祫婧愭椂閫氱煡鎴戜滑鐨刟ction綾葷殑瀹炰緥
娣誨姞瑙嗗浘
鍦‵ile->New->Other->Designer->RCP->ViewPart->Next
Perspective綾伙細榪欐槸RCP搴旂敤鐨勯粯璁よ鍥撅紝瀹炵幇浜咺PerspectiveFactory鎺ュ彛錛屽茍涓旈氳繃org.eclipse.ui.perspectives鎵╁睍ClassName灞炴ф寚瀹?br />
鍦≒erspective綾諱腑createInitialLayout鏂規硶涓坊鍔犲涓嬩唬鐮?br />
layout.addView( BrowserView.ID,
IPageLayout.TOP,
IPageLayout.RATIO_MAX,
IPageLayout.ID_EDITOR_AREA );
鍦╬lugin.xml涓坊鍔犲涓嬭妭鐐?br />
<extension point="org.eclipse.ui.views">
<view
class="helloworld_rcp.BrowView"
id="BrowView"
name="New ViewPart">
</view>
</extension>
璁劇疆闅愯棌緙栬緫闈㈡澘
layout.setEditorAreaVisible(false);
Selection Service鐨勬暣浣撴灦鏋?/strong>
娉ㄥ唽
this.getSite().setSelectionProvider(viewer);
viewer闇瑕佸疄鐜癐SelectProvider鎺ュ彛
鐩戝惉
this.getSite().getPage().addSelectionListener(this);
this.瀹炵幇ISelectionListener鎺ュ彛