首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 开源软件 >

Eclpse_plugin 开发札记_Action_Enable

2012-06-27 
Eclpse_plugin 开发笔记_Action_Enable1.Action ID 获取??????? IViewPart homeworkView ??????????? Pla

Eclpse_plugin 开发笔记_Action_Enable

1.Action ID 获取
??????? IViewPart homeworkView =??????????? PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.xcc.zzu_wmp.views.HomeWorkView");
?????? ? IActionBars bars = homeworkView.getViewSite().getActionBars();
???????? IToolBarManager actios = bars.getToolBarManager();
???????? ActionContributionItem contribut = (ActionContributionItem)

???????? actios.find(PreferenceConstants.P_ZZU_REFRESH);
???????? contribut.getAction().setEnabled(true);

?

?

??????? refresh = new Action( {});

??????? refresh.setEnabled(false);
??? ??? refresh.setId(PreferenceConstants.P_ZZU_REFRESH);

2. ActionSet ID 获取
??? ??? ??? ??? ??? ??? ?
??? ??? ??? ??? ??? IWorkbench wb=PlatformUI.getWorkbench();
??? ??? ??? ??? ??? List<String> actionIDs= new ArrayList<String>();
??? ??? ??? ??? ??? actionIDs.add(PreferenceConstants.P_ZZU_SAVE);
??? ??? ??? ??? ??? actionIDs.add(PreferenceConstants.P_ZZU_DOWNLOAD);
??? ??? ??? ??? ??? actionIDs.add(PreferenceConstants.P_ZZU_UPLOAD);
??? ??? ??? ??? ???
??? ??? ??? ??? ??? ActionPresentation ap = ((WorkbenchWindow) wb.getActiveWorkbenchWindow()) .getActionPresentation();
??? ??? ??? ??? ??? IActionSet[] sets = ap.getActionSets();
??? ??? ??? ??? ??? if (sets != null) {
??? ??? ??? ??????????? for (IActionSet set : sets) {
??? ??? ??? ??????????????? PluginActionSet pas = (PluginActionSet) set;
??? ??? ??? ??????????????? IAction[] actions = pas.getPluginActions();
??? ??? ??? ??????????????? if (actions != null&& pas.getDesc().getId().endsWith(PreferenceConstants.P_ZZU_ACTIONSET)) {//ActionSetID
??? ??? ??? ??????????????????? for (IAction action : actions) {
??? ??? ??? ??????????????????????? if (actionIDs.contains(action.getId())) {
??? ??? ??? ??????????????????????????? action.setEnabled(store.getBoolean(PreferenceConstants.P_ZZU_ISLOGIN));
??? ??? ??? ??????????????????????? }
??? ??? ??? ??????????????????? }
??? ??? ??? ??????????????? }
??? ??? ??? ??? ??? ?}
??? ??? ??? ??????????? }

热点排行