/** {@inheritDoc} */ @Override public void clear() { if (recentGroup == null) { return; } openRecentFilesPresenter.clearRecentFiles(); recentStorage.clear(); // de-register all previously registered actions for (Pair<File, RecentFileAction> pair : fileToAction) { actionManager.unregisterAction(pair.getSecond().getId()); recentGroup.remove(pair.getSecond()); } fileToAction.clear(); }
/** {@inheritDoc} */ @Override public boolean remove(File item) { if (recentGroup == null) { return false; } recentStorage.remove(item); openRecentFilesPresenter.setRecentFiles(getAll()); // with one cycle de-register action and remove it from recent group Iterator<Pair<File, RecentFileAction>> iterator = fileToAction.iterator(); while (iterator.hasNext()) { Pair<File, RecentFileAction> pair = iterator.next(); if (pair.getFirst().equals(item)) { recentGroup.remove(pair.getSecond()); actionManager.unregisterAction(pair.getSecond().getId()); iterator.remove(); return true; } } return false; }
/** * Removes action for executing the given command and removes the appropriate action group in case * it's empty. */ private void removeAction(CommandImpl command) { Action commandAction = commandActions.remove(command.getName()); if (commandAction != null) { removeAction(commandAction); // remove action from it's action group String goalId = command.getGoal(); if (isNullOrEmpty(goalId)) { goalId = goalRegistry.getDefaultGoal().getId(); } DefaultActionGroup goalPopUpGroup = goalPopUpGroups.get(goalId); if (goalPopUpGroup != null) { goalPopUpGroup.remove(commandAction); } } } }