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));
}
}
}
}
}