IMemento[] actions = memento
.getChildren(IWorkbenchConstants.TAG_ALWAYS_ON_ACTION_SET);
for (int x = 0; x < actions.length; x++) {
String actionSetID = actions[x]
.getString(IWorkbenchConstants.TAG_ID);
final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
.getActionSetRegistry().findActionSet(actionSetID);
if (d != null) {
StartupThreading
.runWithoutExceptions(new StartupRunnable() {
public void runWithException() throws Throwable {
addAlwaysOn(d);
}
});
knownActionSetIds.add(actionSetID);
}
}
// Load the always off action sets.
actions = memento
.getChildren(IWorkbenchConstants.TAG_ALWAYS_OFF_ACTION_SET);
for (int x = 0; x < actions.length; x++) {
String actionSetID = actions[x]
.getString(IWorkbenchConstants.TAG_ID);
final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
.getActionSetRegistry().findActionSet(actionSetID);
if (d != null) {
StartupThreading
.runWithoutExceptions(new StartupRunnable() {
public void runWithException() throws Throwable {
addAlwaysOff(d);
}
});
knownActionSetIds.add(actionSetID);
}
}
// Load "show view actions".
actions = memento
.getChildren(IWorkbenchConstants.TAG_SHOW_VIEW_ACTION);
showViewShortcuts = new ArrayList(actions.length);
for (int x = 0; x < actions.length; x++) {
String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
showViewShortcuts.add(id);
}
// Load "show in times".
actions = memento.getChildren(IWorkbenchConstants.TAG_SHOW_IN_TIME);
for (int x = 0; x < actions.length; x++) {
String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
String timeStr = actions[x]
.getString(IWorkbenchConstants.TAG_TIME);
if (id != null && timeStr != null) {
try {
long time = Long.parseLong(timeStr);
showInTimes.put(id, new Long(time));
} catch (NumberFormatException e) {
// skip this one
}
}
}
// Load "show in parts" from registry, not memento
showInPartIds = getShowInIdsFromRegistry();
// Load "new wizard actions".
actions = memento
.getChildren(IWorkbenchConstants.TAG_NEW_WIZARD_ACTION);
newWizardShortcuts = new ArrayList(actions.length);
for (int x = 0; x < actions.length; x++) {
String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
newWizardShortcuts.add(id);
}
// Load "perspective actions".
actions = memento
.getChildren(IWorkbenchConstants.TAG_PERSPECTIVE_ACTION);
perspectiveShortcuts = new ArrayList(actions.length);
for (int x = 0; x < actions.length; x++) {
String id = actions[x].getString(IWorkbenchConstants.TAG_ID);
perspectiveShortcuts.add(id);
}
ArrayList extActionSets = getPerspectiveExtensionActionSets();
for (int i = 0; i < extActionSets.size(); i++) {
String actionSetID = (String) extActionSets.get(i);
if (knownActionSetIds.contains(actionSetID)) {
continue;
}
final IActionSetDescriptor d = WorkbenchPlugin.getDefault()
.getActionSetRegistry().findActionSet(actionSetID);
if (d != null) {
StartupThreading
.runWithoutExceptions(new StartupRunnable() {
public void runWithException() throws Throwable {
addAlwaysOn(d);
}
});
knownActionSetIds.add(d.getId());
}
}
// Add the visible set of action sets to our knownActionSetIds
// Now go through the registry to ensure we pick up any new action
// sets
// that have been added but not yet considered by this perspective.
ActionSetRegistry reg = WorkbenchPlugin.getDefault()
.getActionSetRegistry();
IActionSetDescriptor[] array = reg.getActionSets();
int count = array.length;
for (int i = 0; i < count; i++) {
IActionSetDescriptor desc = array[i];
if ((!knownActionSetIds.contains(desc.getId()))
&& (desc.isInitiallyVisible())) {
addActionSet(desc);
}
}
} finally {
// restart context changes