Update of /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv7890/src/org/rubypeople/rdt/internal/ui/rubyeditor Modified Files: RubyEditorMessages.java RubyEditorActionContributor.java RubyEditorMessages.properties RubyEditor.java Log Message: Add a folding action menu to context ruler on left side of editor, and add command shortcuts for actions to manipulatae folding. Now users can collapse/expand all, comments, members, reset structure, etc. Index: RubyEditorMessages.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorMessages.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** RubyEditorMessages.java 24 Feb 2006 20:03:58 -0000 1.5 --- RubyEditorMessages.java 9 Jun 2006 01:19:18 -0000 1.6 *************** *** 38,41 **** --- 38,43 ---- private static ResourceBundle fgBundleForConstructedKeys= ResourceBundle.getBundle(BUNDLE_FOR_CONSTRUCTED_KEYS); + public static String Editor_FoldingMenu_name; + /** * Returns the message bundle which contains constructed keys. Index: RubyEditorMessages.properties =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorMessages.properties,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** RubyEditorMessages.properties 24 Feb 2006 20:03:43 -0000 1.6 --- RubyEditorMessages.properties 9 Jun 2006 01:19:18 -0000 1.7 *************** *** 55,58 **** --- 55,60 ---- RubyOutlinePage_error_NoTopLevelType=Top level type not defined + Editor_FoldingMenu_name=F&olding + OpenOnSelection.description=Open an editor on the selected element OpenOnSelection.dialog.message=&Select or enter the element to open: Index: RubyEditor.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditor.java,v retrieving revision 1.46 retrieving revision 1.47 diff -C2 -d -r1.46 -r1.47 *** RubyEditor.java 5 May 2006 01:13:27 -0000 1.46 --- RubyEditor.java 9 Jun 2006 01:19:18 -0000 1.47 *************** *** 18,21 **** --- 18,22 ---- import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IMenuManager; + import org.eclipse.jface.action.MenuManager; import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.jface.text.BadLocationException; *************** *** 90,93 **** --- 91,95 ---- import org.rubypeople.rdt.internal.ui.RubyPlugin; import org.rubypeople.rdt.internal.ui.RubyUIMessages; + import org.rubypeople.rdt.internal.ui.actions.FoldingActionGroup; import org.rubypeople.rdt.internal.ui.text.IRubyPartitions; import org.rubypeople.rdt.internal.ui.text.RubyHeuristicScanner; *************** *** 100,103 **** --- 102,106 ---- import org.rubypeople.rdt.ui.actions.SurroundWithBeginRescueAction; import org.rubypeople.rdt.ui.text.folding.IRubyFoldingStructureProvider; + import org.rubypeople.rdt.ui.text.folding.IRubyFoldingStructureProviderExtension; public class RubyEditor extends RubyAbstractEditor { *************** *** 148,151 **** --- 151,161 ---- */ private ToggleFoldingRunner fFoldingRunner; + + /** + * The action group for folding. + * + * @since 0.9.0 + */ + private FoldingActionGroup fFoldingGroup; private BracketInserter fBracketInserter = new BracketInserter(); *************** *** 160,163 **** --- 170,182 ---- setOutlinerContextMenuId("#RubyScriptOutlinerContext"); //$NON-NLS-1$ } + + /** + * Returns the standard action group of this editor. + * + * @return returns this editor's standard action group + */ + protected ActionGroup getActionGroup() { + return actionGroup; + } protected void createActions() { *************** *** 195,198 **** --- 214,220 ---- setAction("Format", action); + + fFoldingGroup= new FoldingActionGroup(this, getViewer()); + ISelectionProvider provider= getSite().getSelectionProvider(); ISelection selection= provider.getSelection(); *************** *** 207,210 **** --- 229,236 ---- } + public final ISourceViewer getViewer() { + return getSourceViewer(); + } + /** * Configures the toggle comment action *************** *** 266,270 **** --- 292,330 ---- } } + + /** + * Resets the foldings structure according to the folding + * preferences. + * + * @since 0.9.0 + */ + public void resetProjection() { + if (fProjectionModelUpdater != null) { + fProjectionModelUpdater.initialize(); + } + } + + /* + * @see org.eclipse.ui.texteditor.AbstractTextEditor#rulerContextMenuAboutToShow(org.eclipse.jface.action.IMenuManager) + */ + protected void rulerContextMenuAboutToShow(IMenuManager menu) { + super.rulerContextMenuAboutToShow(menu); + IMenuManager foldingMenu= new MenuManager(RubyEditorMessages.Editor_FoldingMenu_name, "projection"); //$NON-NLS-1$ + menu.appendToGroup(ITextEditorActionConstants.GROUP_RULERS, foldingMenu); + IAction action= getAction("FoldingToggle"); //$NON-NLS-1$ + foldingMenu.add(action); + action= getAction("FoldingExpandAll"); //$NON-NLS-1$ + foldingMenu.add(action); + action= getAction("FoldingCollapseAll"); //$NON-NLS-1$ + foldingMenu.add(action); + action= getAction("FoldingRestore"); //$NON-NLS-1$ + foldingMenu.add(action); + action= getAction("FoldingCollapseMembers"); //$NON-NLS-1$ + foldingMenu.add(action); + action= getAction("FoldingCollapseComments"); //$NON-NLS-1$ + foldingMenu.add(action); + } + /** * Returns the annotation overlapping with the given range or *************** *** 1469,1471 **** --- 1529,1561 ---- } } + + /** + * Collapses all foldable members if supported by the folding + * structure provider. + * + * @since 0.9.0 + */ + public void collapseMembers() { + if (fProjectionModelUpdater instanceof IRubyFoldingStructureProviderExtension) { + IRubyFoldingStructureProviderExtension extension= (IRubyFoldingStructureProviderExtension) fProjectionModelUpdater; + extension.collapseMembers(); + } + } + + /** + * Collapses all foldable comments if supported by the folding + * structure provider. + * + * @since 0.9.0 + */ + public void collapseComments() { + if (fProjectionModelUpdater instanceof IRubyFoldingStructureProviderExtension) { + IRubyFoldingStructureProviderExtension extension= (IRubyFoldingStructureProviderExtension) fProjectionModelUpdater; + extension.collapseComments(); + } + } + + public FoldingActionGroup getFoldingActionGroup() { + return fFoldingGroup; + } } \ No newline at end of file Index: RubyEditorActionContributor.java =================================================================== RCS file: /cvsroot/rubyeclipse/org.rubypeople.rdt.ui/src/org/rubypeople/rdt/internal/ui/rubyeditor/RubyEditorActionContributor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** RubyEditorActionContributor.java 24 Feb 2006 20:04:22 -0000 1.11 --- RubyEditorActionContributor.java 9 Jun 2006 01:19:18 -0000 1.12 *************** *** 15,18 **** --- 15,19 ---- import org.eclipse.ui.texteditor.RetargetTextEditorAction; import org.rubypeople.rdt.internal.ui.RubyUIMessages; + import org.rubypeople.rdt.internal.ui.actions.FoldingActionGroup; import org.rubypeople.rdt.ui.actions.IRubyEditorActionDefinitionIds; import org.rubypeople.rdt.ui.actions.RubyActionIds; *************** *** 59,62 **** --- 60,72 ---- GotoMatchingBracketAction.GOTO_MATCHING_BRACKET)); + + if (part instanceof RubyEditor) { + RubyEditor javaEditor= (RubyEditor) part; + javaEditor.getActionGroup().fillActionBars(getActionBars()); + FoldingActionGroup foldingActions= javaEditor.getFoldingActionGroup(); + if (foldingActions != null) + foldingActions.updateActionBars(); + } + IActionBars actionBars = getActionBars(); actionBars.setGlobalActionHandler(RubyActionIds.COMMENT, getAction(textEditor, "Comment")); |