mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
PR 61965
From Thomas Fletcher: 2.0 mainline scalability patch to call dispose methods and remove listeners
This commit is contained in:
parent
40f9982534
commit
4a8eacaa59
10 changed files with 221 additions and 85 deletions
|
@ -1,3 +1,10 @@
|
|||
2004-05-26 Alain Magloire
|
||||
|
||||
PR 61965
|
||||
From Thomas Fletcher:
|
||||
2.0 mainline scalability patch to
|
||||
call dispose methods and remove listeners
|
||||
|
||||
2004-05-21 Andrew Niefer
|
||||
Indexer Problem reporting (bug 43014, 62979)
|
||||
* plugin.xml
|
||||
|
|
|
@ -282,10 +282,18 @@ public class CPluginImages {
|
|||
* Sets all available image descriptors for the given action.
|
||||
*/
|
||||
public static void setImageDescriptors(IAction action, String type, String relPath) {
|
||||
relPath= relPath.substring(NAME_PREFIX_LENGTH);
|
||||
action.setDisabledImageDescriptor(create(T + "d" + type, relPath)); //$NON-NLS-1$
|
||||
action.setHoverImageDescriptor(create(T + "c" + type, relPath)); //$NON-NLS-1$
|
||||
action.setImageDescriptor(create(T + "e" + type, relPath)); //$NON-NLS-1$
|
||||
//Use the managed version so that we ensure that there is no resource handle leaks
|
||||
//Let the widget itself manage the disabled/hover attribution. This was a huge leak
|
||||
// relPath= relPath.substring(NAME_PREFIX_LENGTH);
|
||||
// action.setDisabledImageDescriptor(create(T + "d" + type, relPath)); //$NON-NLS-1$
|
||||
// action.setHoverImageDescriptor(create(T + "c" + type, relPath)); //$NON-NLS-1$
|
||||
// action.setImageDescriptor(create(T + "e" + type, relPath)); //$NON-NLS-1$
|
||||
|
||||
ImageDescriptor desc = getImageRegistry().getDescriptor(relPath);
|
||||
if(desc == null) {
|
||||
desc = createManaged(T + "e" + type, relPath);
|
||||
}
|
||||
action.setImageDescriptor(desc);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -137,9 +137,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
}
|
||||
|
||||
fRefactoringActionGroup.fillContextMenu(menu);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -147,7 +144,6 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
*/
|
||||
public void createControl(Composite parent) {
|
||||
treeViewer = new ProblemTreeViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL);
|
||||
treeViewer.addSelectionChangedListener(this);
|
||||
|
||||
treeViewer.setContentProvider(new CElementContentProvider(true, true));
|
||||
treeViewer.setLabelProvider(new StandardCElementLabelProvider());
|
||||
|
@ -166,30 +162,55 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
Control control= treeViewer.getControl();
|
||||
Menu menu= manager.createContextMenu(control);
|
||||
control.setMenu(menu);
|
||||
|
||||
|
||||
// register global actions
|
||||
IPageSite site= getSite();
|
||||
site.registerContextMenu(fContextMenuId, manager, treeViewer);
|
||||
site.setSelectionProvider(treeViewer);
|
||||
|
||||
IActionBars bars= site.getActionBars();
|
||||
bars.setGlobalActionHandler(ICEditorActionDefinitionIds.TOGGLE_PRESENTATION, fTogglePresentation);
|
||||
|
||||
registerToolbarActions();
|
||||
|
||||
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
||||
fRefactoringActionGroup = new RefactoringActionGroup(this, null);
|
||||
|
||||
treeViewer.setInput(fInput);
|
||||
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
CUIPlugin.getDefault().getProblemMarkerManager().removeListener(treeViewer);
|
||||
|
||||
if (treeViewer != null) {
|
||||
treeViewer.removeSelectionChangedListener(this);
|
||||
}
|
||||
|
||||
if (fTogglePresentation != null) {
|
||||
fTogglePresentation.setEditor(null);
|
||||
fTogglePresentation= null;
|
||||
}
|
||||
|
||||
if (fMemberFilterActionGroup != null) {
|
||||
fMemberFilterActionGroup.dispose();
|
||||
fMemberFilterActionGroup= null;
|
||||
}
|
||||
}
|
||||
|
||||
if (fRefactoringActionGroup != null) {
|
||||
fRefactoringActionGroup.dispose();
|
||||
fRefactoringActionGroup= null;
|
||||
}
|
||||
|
||||
if (fSelectionSearchGroup != null) {
|
||||
fSelectionSearchGroup.dispose();
|
||||
fSelectionSearchGroup= null;
|
||||
}
|
||||
|
||||
if (selectionChangedListeners != null) {
|
||||
selectionChangedListeners.clear();
|
||||
selectionChangedListeners= null;
|
||||
}
|
||||
|
||||
fInput= null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -201,6 +222,9 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
|
||||
LexicalSortingAction action= new LexicalSortingAction(getTreeViewer());
|
||||
toolBarManager.add(action);
|
||||
|
||||
fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$
|
||||
fMemberFilterActionGroup.fillActionBars(actionBars);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
|
@ -276,8 +300,8 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
if (treeViewer != null)
|
||||
treeViewer.setSelection(selection);
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current input to the content provider.
|
||||
* @param unit
|
||||
*/
|
||||
public void setInput(ITranslationUnit unit) {
|
||||
|
@ -288,16 +312,5 @@ public class CContentOutlinePage extends Page implements IContentOutlinePage, IS
|
|||
contentUpdated();
|
||||
}
|
||||
|
||||
private void registerToolbarActions() {
|
||||
|
||||
IToolBarManager toolBarManager= getSite().getActionBars().getToolBarManager();
|
||||
if (toolBarManager != null) {
|
||||
//toolBarManager.add(new ClassOnlyAction());
|
||||
//toolBarManager.add(new LexicalSortingAction());
|
||||
|
||||
fMemberFilterActionGroup= new MemberFilterActionGroup(treeViewer, "COutlineViewer"); //$NON-NLS-1$
|
||||
fMemberFilterActionGroup.contributeToToolBar(toolBarManager);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -76,13 +76,14 @@ import org.eclipse.ui.IWorkbenchWindow;
|
|||
import org.eclipse.ui.actions.ActionGroup;
|
||||
import org.eclipse.ui.editors.text.EditorsUI;
|
||||
import org.eclipse.ui.editors.text.TextEditor;
|
||||
import org.eclipse.ui.ide.IDE;
|
||||
import org.eclipse.ui.part.EditorActionBarContributor;
|
||||
import org.eclipse.ui.part.IShowInSource;
|
||||
import org.eclipse.ui.part.ShowInContext;
|
||||
import org.eclipse.ui.texteditor.AbstractTextEditor;
|
||||
import org.eclipse.ui.texteditor.AnnotationPreference;
|
||||
import org.eclipse.ui.texteditor.ChainedPreferenceStore;
|
||||
import org.eclipse.ui.texteditor.ContentAssistAction;
|
||||
import org.eclipse.ui.texteditor.DefaultRangeIndicator;
|
||||
import org.eclipse.ui.texteditor.IEditorStatusLine;
|
||||
import org.eclipse.ui.texteditor.ITextEditorActionConstants;
|
||||
import org.eclipse.ui.texteditor.MarkerAnnotation;
|
||||
|
@ -103,12 +104,14 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
protected CContentOutlinePage fOutlinePage;
|
||||
|
||||
/** Search actions **/
|
||||
|
||||
private ActionGroup fSelectionSearchGroup;
|
||||
private ActionGroup fRefactoringActionGroup;
|
||||
private ShowInCViewAction fShowInCViewAction;
|
||||
|
||||
/** Activity Listeners **/
|
||||
protected ISelectionChangedListener fStatusLineClearer;
|
||||
|
||||
protected ISelectionChangedListener fSelectionUpdateListener;
|
||||
|
||||
/** The property change listener */
|
||||
private PropertyChangeListener fPropertyChangeListener = new PropertyChangeListener();
|
||||
/** The mouse listener */
|
||||
|
@ -158,29 +161,30 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
*/
|
||||
public CEditor() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
|
||||
*/
|
||||
protected void initializeEditor() {
|
||||
//@@@ We should be able to get this from our parent
|
||||
fAnnotationPreferences = new MarkerAnnotationPreferences();
|
||||
|
||||
CTextTools textTools = CUIPlugin.getDefault().getTextTools();
|
||||
setSourceViewerConfiguration(new CSourceViewerConfiguration(textTools, this));
|
||||
setDocumentProvider(CUIPlugin.getDefault().getDocumentProvider());
|
||||
setRangeIndicator(new DefaultRangeIndicator());
|
||||
//setPreferenceStore(CUIPlugin.getDefault().getPreferenceStore());
|
||||
|
||||
|
||||
setEditorContextMenuId("#CEditorContext"); //$NON-NLS-1$
|
||||
setRulerContextMenuId("#CEditorRulerContext"); //$NON-NLS-1$
|
||||
setOutlinerContextMenuId("#CEditorOutlinerContext"); //$NON-NLS-1$
|
||||
|
||||
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
|
||||
}
|
||||
|
||||
/*
|
||||
* @see org.eclipse.ui.texteditor.AbstractDecoratedTextEditor#initializeEditor()
|
||||
*/
|
||||
protected void initializeEditor() {
|
||||
IPreferenceStore[] stores = new IPreferenceStore[2];
|
||||
stores[0] = CUIPlugin.getDefault().getPreferenceStore();
|
||||
stores[1] = EditorsUI.getPreferenceStore();
|
||||
IPreferenceStore store = new ChainedPreferenceStore(stores);
|
||||
setPreferenceStore(store);
|
||||
|
||||
fCEditorErrorTickUpdater = new CEditorErrorTickUpdater(this);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -188,7 +192,9 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
*/
|
||||
protected void doSetInput(IEditorInput input) throws CoreException {
|
||||
super.doSetInput(input);
|
||||
fCEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input));
|
||||
if (fCEditorErrorTickUpdater != null) {
|
||||
fCEditorErrorTickUpdater.setAnnotationModel(getDocumentProvider().getAnnotationModel(input));
|
||||
}
|
||||
setOutlinePageInput(fOutlinePage, input);
|
||||
}
|
||||
|
||||
|
@ -297,16 +303,6 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private void disableBrowserLikeLinks() {
|
||||
if (fMouseListener != null) {
|
||||
fMouseListener.uninstall();
|
||||
fMouseListener= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ISelectionChangedListener#selectionChanged
|
||||
*/
|
||||
|
@ -437,18 +433,60 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
|
||||
if (fCEditorErrorTickUpdater != null) {
|
||||
fCEditorErrorTickUpdater.setAnnotationModel(null);
|
||||
fCEditorErrorTickUpdater.dispose();
|
||||
fCEditorErrorTickUpdater = null;
|
||||
}
|
||||
if (fBracketMatcher != null) {
|
||||
fBracketMatcher.dispose();
|
||||
fBracketMatcher = null;
|
||||
}
|
||||
|
||||
if (fPropertyChangeListener != null) {
|
||||
Preferences preferences = CCorePlugin.getDefault().getPluginPreferences();
|
||||
preferences.removePropertyChangeListener(fPropertyChangeListener);
|
||||
IPreferenceStore preferenceStore = getPreferenceStore();
|
||||
preferenceStore.removePropertyChangeListener(fPropertyChangeListener);
|
||||
fPropertyChangeListener = null;
|
||||
|
||||
}
|
||||
|
||||
if (fSelectionUpdateListener != null) {
|
||||
getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
|
||||
fSelectionUpdateListener = null;
|
||||
}
|
||||
|
||||
if (fStatusLineClearer != null) {
|
||||
ISelectionProvider provider = getSelectionProvider();
|
||||
provider.removeSelectionChangedListener(fStatusLineClearer);
|
||||
fStatusLineClearer = null;
|
||||
}
|
||||
|
||||
if (fBracketMatcher != null) {
|
||||
fBracketMatcher.dispose();
|
||||
fBracketMatcher = null;
|
||||
}
|
||||
|
||||
if (fOutlinePage != null) {
|
||||
fOutlinePage.dispose();
|
||||
fOutlinePage = null;
|
||||
}
|
||||
|
||||
if (fShowInCViewAction != null) {
|
||||
fShowInCViewAction.dispose();
|
||||
fShowInCViewAction = null;
|
||||
}
|
||||
|
||||
if (fRefactoringActionGroup != null) {
|
||||
fRefactoringActionGroup.dispose();
|
||||
fRefactoringActionGroup = null;
|
||||
}
|
||||
|
||||
if (fSelectionSearchGroup != null) {
|
||||
fSelectionSearchGroup.dispose();
|
||||
fSelectionSearchGroup = null;
|
||||
}
|
||||
|
||||
stopTabConversion();
|
||||
disableBrowserLikeLinks();
|
||||
|
||||
fAnnotationPreferences = null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
@ -517,11 +555,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_DECL);
|
||||
setAction("OpenDeclarations", action); //$NON-NLS-1$
|
||||
|
||||
action = new ShowInCViewAction(this);
|
||||
fShowInCViewAction = new ShowInCViewAction(this);
|
||||
action = fShowInCViewAction;
|
||||
action.setActionDefinitionId(ICEditorActionDefinitionIds.OPEN_CVIEW);
|
||||
setAction("ShowInCView", action); //$NON-NLS-1$
|
||||
|
||||
//Selection Search group
|
||||
//Assorted action groupings
|
||||
fSelectionSearchGroup = new SelectionSearchGroup(this);
|
||||
fRefactoringActionGroup = new RefactoringActionGroup(this, null);
|
||||
|
||||
|
@ -574,7 +613,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
*/
|
||||
public void createPartControl(Composite parent) {
|
||||
super.createPartControl(parent);
|
||||
ISelectionChangedListener sListener = new ISelectionChangedListener() {
|
||||
fSelectionUpdateListener = new ISelectionChangedListener() {
|
||||
private Runnable fRunnable = new Runnable() {
|
||||
public void run() {
|
||||
updateStatusField(CTextEditorActionConstants.STATUS_CURSOR_POS);
|
||||
|
@ -589,7 +628,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
fDisplay.asyncExec(fRunnable);
|
||||
}
|
||||
};
|
||||
getSelectionProvider().addSelectionChangedListener(sListener);
|
||||
getSelectionProvider().addSelectionChangedListener(fSelectionUpdateListener);
|
||||
|
||||
if (isTabConversionEnabled())
|
||||
startTabConversion();
|
||||
|
@ -660,8 +699,7 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
|
||||
if (nextError != null) {
|
||||
|
||||
|
||||
gotoMarker(nextError);
|
||||
IDE.gotoMarker(this, nextError);
|
||||
|
||||
IWorkbenchPage page = getSite().getPage();
|
||||
|
||||
|
@ -875,10 +913,12 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
IWorkingCopyManager mgr = CUIPlugin.getDefault().getWorkingCopyManager();
|
||||
ITranslationUnit unit = mgr.getWorkingCopy(getEditorInput());
|
||||
String fileType = (unit != null && unit.isCXXLanguage()) ? LANGUAGE_CPP : LANGUAGE_C;
|
||||
|
||||
fAnnotationAccess = createAnnotationAccess();
|
||||
ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors();
|
||||
|
||||
fAnnotationAccess = createAnnotationAccess();
|
||||
|
||||
//TODO: TF NOTE: This can be greatly cleaned up using the parent createOverviewRuler method
|
||||
//It will also totally get rid of the need for the fAnnotationPreferences in this object
|
||||
ISharedTextColors sharedColors = CUIPlugin.getDefault().getSharedTextColors();
|
||||
fOverviewRuler = new OverviewRuler(fAnnotationAccess, VERTICAL_RULER_WIDTH, sharedColors);
|
||||
Iterator e = fAnnotationPreferences.getAnnotationPreferences().iterator();
|
||||
while (e.hasNext()) {
|
||||
|
@ -900,6 +940,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
|
||||
configureSourceViewerDecorationSupport(fSourceViewerDecorationSupport);
|
||||
|
||||
//TODO: TF NOTE: Add the bracket matching back in here!
|
||||
|
||||
return sourceViewer;
|
||||
}
|
||||
|
||||
|
@ -956,9 +998,8 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
|
||||
}
|
||||
|
||||
//Links
|
||||
/**
|
||||
* Enables browser like links.
|
||||
* Enables browser like links, requires disable to clean up
|
||||
*/
|
||||
private void enableBrowserLikeLinks() {
|
||||
if (fMouseListener == null) {
|
||||
|
@ -968,20 +1009,31 @@ public class CEditor extends TextEditor implements ISelectionChangedListener, IS
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable browser like links, clean up resources
|
||||
*/
|
||||
private void disableBrowserLikeLinks() {
|
||||
if (fMouseListener != null) {
|
||||
fMouseListener.uninstall();
|
||||
fMouseListener= null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @return
|
||||
* Determine if the hyperlink capability is enabled
|
||||
* @return boolean indicating if hyperlinking is enabled
|
||||
*/
|
||||
private boolean hyperLinkEnabled() {
|
||||
IPreferenceStore store= getPreferenceStore();
|
||||
boolean Value = store.getBoolean(HYPERLINK_ENABLED);
|
||||
return Value;
|
||||
return store.getBoolean(HYPERLINK_ENABLED);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.ui.editor.IReconcilingParticipant#reconciled()
|
||||
*/
|
||||
public void reconciled(boolean somethingHasChanged) {
|
||||
if(somethingHasChanged)
|
||||
if(somethingHasChanged && fOutlinePage != null) {
|
||||
fOutlinePage.contentUpdated();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -210,4 +210,11 @@ public class CEditorActionContributor extends TextEditorActionContributor {
|
|||
super.contributeToStatusLine(statusLineManager);
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.IEditorActionBarContributor#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
setActiveEditor(null);
|
||||
super.dispose();
|
||||
}
|
||||
}
|
|
@ -88,6 +88,13 @@ public class CEditorErrorTickUpdater implements IAnnotationModelListener {
|
|||
}
|
||||
}
|
||||
|
||||
public void dispose() {
|
||||
if (fLabelProvider != null) {
|
||||
fLabelProvider.dispose();
|
||||
fLabelProvider= null;
|
||||
}
|
||||
fAnnotationModel= null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -201,18 +201,18 @@ IPropertyChangeListener{
|
|||
fCursor= null;
|
||||
}
|
||||
|
||||
ISourceViewer sourceViewer= fViewer;
|
||||
if (sourceViewer == null)
|
||||
return;
|
||||
|
||||
IPreferenceStore preferenceStore= fPrefStore;
|
||||
if (preferenceStore != null)
|
||||
preferenceStore.removePropertyChangeListener(this);
|
||||
|
||||
|
||||
ISourceViewer sourceViewer= fViewer;
|
||||
if (sourceViewer == null)
|
||||
return;
|
||||
|
||||
StyledText text= sourceViewer.getTextWidget();
|
||||
if (text == null || text.isDisposed())
|
||||
return;
|
||||
|
||||
|
||||
text.removeKeyListener(this);
|
||||
text.removeMouseListener(this);
|
||||
text.removeMouseMoveListener(this);
|
||||
|
|
|
@ -90,4 +90,23 @@ public class SelectionSearchGroup extends ActionGroup {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.ui.actions.ActionGroup#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
if (fDeclarationsSearchGroup != null) {
|
||||
fDeclarationsSearchGroup.dispose();
|
||||
fDeclarationsSearchGroup= null;
|
||||
}
|
||||
|
||||
if (fRefSearchGroup != null) {
|
||||
fRefSearchGroup.dispose();
|
||||
fRefSearchGroup= null;
|
||||
}
|
||||
|
||||
fEditor= null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -260,6 +260,10 @@ public class MemberFilterActionGroup extends ActionGroup {
|
|||
* @see ActionGroup#dispose()
|
||||
*/
|
||||
public void dispose() {
|
||||
fFilterActions= null;
|
||||
fFilter= null;
|
||||
fViewer= null;
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
|
|
|
@ -102,9 +102,9 @@ public class RefactoringActionGroup extends ActionGroup {
|
|||
private CEditor fEditor;
|
||||
private String fGroupName= IContextMenuConstants.GROUP_REORGANIZE;
|
||||
|
||||
private SelectionDispatchAction fRenameAction;
|
||||
private SelectionDispatchAction fRedoAction;
|
||||
private SelectionDispatchAction fUndoAction;
|
||||
private RenameRefactoringAction fRenameAction;
|
||||
private RedoRefactoringAction fRedoAction;
|
||||
private UndoRefactoringAction fUndoAction;
|
||||
private List fEditorActions;
|
||||
|
||||
private static class NoActionAvailable extends Action {
|
||||
|
@ -148,8 +148,8 @@ public class RefactoringActionGroup extends ActionGroup {
|
|||
|
||||
ISelectionProvider provider= editor.getSelectionProvider();
|
||||
ISelection selection= provider.getSelection();
|
||||
fEditorActions= new ArrayList();
|
||||
|
||||
fEditorActions= new ArrayList(3);
|
||||
|
||||
fRenameAction= new RenameRefactoringAction(editor);
|
||||
fRenameAction.update(selection);
|
||||
editor.setAction("RenameElement", fRenameAction); //$NON-NLS-1$
|
||||
|
@ -164,7 +164,7 @@ public class RefactoringActionGroup extends ActionGroup {
|
|||
fRedoAction.update(selection);
|
||||
editor.setAction("RedoAction", fRedoAction); //$NON-NLS-1$
|
||||
fEditorActions.add(fRedoAction);
|
||||
}
|
||||
}
|
||||
|
||||
public RefactoringActionGroup(IWorkbenchSite site, String groupName) {
|
||||
fSite= site;
|
||||
|
@ -212,15 +212,34 @@ public class RefactoringActionGroup extends ActionGroup {
|
|||
*/
|
||||
public void dispose() {
|
||||
ISelectionProvider provider= fSite.getSelectionProvider();
|
||||
disposeAction(fRenameAction, provider);
|
||||
disposeAction(fUndoAction, provider);
|
||||
disposeAction(fRedoAction, provider);
|
||||
|
||||
if (fRenameAction != null) {
|
||||
disposeAction(fRenameAction, provider);
|
||||
fRenameAction= null;
|
||||
}
|
||||
|
||||
if (fUndoAction != null) {
|
||||
disposeAction(fUndoAction, provider);
|
||||
fUndoAction.dispose();
|
||||
fUndoAction= null;
|
||||
}
|
||||
|
||||
if (fRedoAction != null) {
|
||||
disposeAction(fRedoAction, provider);
|
||||
fRedoAction.dispose();
|
||||
fRedoAction= null;
|
||||
}
|
||||
|
||||
if (fEditorActions != null) {
|
||||
fEditorActions.clear();
|
||||
fEditorActions= null;
|
||||
}
|
||||
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
private void disposeAction(ISelectionChangedListener action, ISelectionProvider provider) {
|
||||
if (action != null)
|
||||
provider.removeSelectionChangedListener(action);
|
||||
provider.removeSelectionChangedListener(action);
|
||||
}
|
||||
|
||||
private void addRefactorSubmenu(IMenuManager menu) {
|
||||
|
|
Loading…
Add table
Reference in a new issue