private static SurroundWithTryCatchAction createSurroundWithTryCatchAction( CompilationUnitEditor editor) { SurroundWithTryCatchAction result = new SurroundWithTryCatchAction(editor); result.setText(ActionMessages.SurroundWithTemplateMenuAction_SurroundWithTryCatchActionName); result.setActionDefinitionId(IJavaEditorActionDefinitionIds.SURROUND_WITH_TRY_CATCH); editor.setAction("SurroundWithTryCatch", result); // $NON-NLS-1$ return result; }
public static void fillMenu( IMenuManager menu, CompilationUnitEditor editor, SurroundWithTryCatchAction surroundWithTryCatchAction) { IAction[] actions = getTemplateActions(editor); surroundWithTryCatchAction.update(editor.getSelectionProvider().getSelection()); boolean addSurroundWithAction = surroundWithTryCatchAction.isEnabled() && !isInJavadoc(editor); if ((actions == null || actions.length == 0) && !addSurroundWithAction) { menu.add(NONE_APPLICABLE_ACTION); } else { if (addSurroundWithAction) menu.add(surroundWithTryCatchAction); menu.add(new Separator(TEMPLATE_GROUP)); for (int i = 0; actions != null && i < actions.length; i++) menu.add(actions[i]); } menu.add(new Separator(CONFIG_GROUP)); menu.add(new ConfigureTemplatesAction()); }