Subclasses of Widget now perform their cleanup in a DisposeListener.
Disposing any child Control of a Composite is handled by the platform
and is therefore removed from the cleanup handling.
Subclasses of TmfComponent that are associated with a Control now
dispose their Control when TmfComponent.dispose() is called, and perform
their cleanup in a DisposeListener, including calling super.dispose().
The DisposeListener is attached to the Control.
Change-Id: Ie6bf7b18b8fad6a0fc0a683209a92fa39bbc8907
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/70057
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Hudson CI
fDragProvider.register();
fTooltipProvider = new SimpleTooltipProvider(this);
fTooltipProvider.register();
+
+ fChart.addDisposeListener((e) -> {
+ internalDispose();
+ });
}
/**
@Override
public void dispose() {
+ fChart.dispose();
+ }
+
+ private void internalDispose() {
if (fSegmentStoreProvider != null && fListener != null) {
fSegmentStoreProvider.removeListener(fListener);
}
/*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
setCurrentState(new PieChartViewerStateNoContentSelected(this));
}
- @Override
- public void dispose() {
- if (fGlobalPC != null) {
- fGlobalPC.dispose();
- }
- if (fTimeRangePC != null) {
- fTimeRangePC.dispose();
- }
- super.dispose();
- }
-
/**
* Updates the data contained in the Global PieChart by using a Map.
* Normally, this method is only called by the state machine.
/*******************************************************************************
- * Copyright (c) 2012, 2015 Ericsson
+ * Copyright (c) 2012, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
initContent(parent);
initInput();
+
+ fSash.addDisposeListener((e) -> {
+ internalDispose();
+ });
}
@Override
public void dispose() {
+ fSash.dispose();
+ }
+
+ private void internalDispose() {
super.dispose();
if (fWaitCursor != null) {
fWaitCursor.dispose();
/*******************************************************************************
- * Copyright (c) 2010, 2015 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2010, 2016 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
TmfTraceColumnManager.saveColumnOrder(fTrace.getTraceTypeId(), fEventsTable.getColumnOrder());
}
}
- if (fEventsTable != null) {
- fEventsTable.dispose();
- }
super.dispose();
}
fRawViewer.setVisible(false);
createPopupMenu();
+
+ fComposite.addDisposeListener((e) -> {
+ internalDispose();
+ });
}
/**
@Override
public void dispose() {
+ fComposite.dispose();
+ }
+
+ private void internalDispose() {
stopSearchThread();
stopFilterThread();
PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(this);
ColorSettingsManager.removeColorSettingsListener(this);
- fComposite.dispose();
+ fCache.clear();
if ((fTrace != null) && fDisposeOnClose) {
fTrace.dispose();
}
fResourceManager.dispose();
- fRawViewer.dispose();
if (fRawViewerPopupMenuManager != null) {
fRawViewerPopupMenuManager.dispose();
}
toggle();
}
});
- }
-
- @Override
- public void dispose() {
- super.dispose();
- fLabelBackground.dispose();
+ addDisposeListener((e) -> {
+ fLabelBackground.dispose();
+ });
}
@Override
/*******************************************************************************
- * Copyright (c) 2015 Ericsson
+ * Copyright (c) 2015, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
Menu tablePopup = fTablePopupMenuManager.createContextMenu(getTableViewer().getTable());
getTableViewer().getTable().setMenu(tablePopup);
+
+ tableControl.addDisposeListener((e) -> {
+ internalDispose();
+ });
}
@Override
if (fTableViewer != null) {
fTableViewer.getControl().dispose();
}
+ }
+
+ private void internalDispose() {
if (fTablePopupMenuManager != null) {
fTablePopupMenuManager.dispose();
}
/**********************************************************************
- * Copyright (c) 2013, 2015 Ericsson, École Polytechnique de Montréal
+ * Copyright (c) 2013, 2016 Ericsson, École Polytechnique de Montréal
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
fMouseWheelZoomProvider = new TmfMouseWheelZoomProvider(this);
fToolTipProvider = new TmfSimpleTooltipProvider(this);
fMouseDragProvider = new TmfMouseDragProvider(this);
+
+ fSwtChart.addDisposeListener((e) -> {
+ internalDispose();
+ });
}
// ------------------------------------------------------------------------
// ------------------------------------------------------------------------
// TmfComponent
// ------------------------------------------------------------------------
+
@Override
public void dispose() {
- super.dispose();
fSwtChart.dispose();
+ }
+
+ private void internalDispose() {
+ super.dispose();
if (fMouseSelectionProvider != null) {
fMouseSelectionProvider.dispose();
/**********************************************************************
- * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
+ * Copyright (c) 2005, 2016 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
fToolTipShell.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_INFO_BACKGROUND));
fToolTipShell.addPaintListener(this);
fToolTipShell.setSize(SHELL_WIDTH, SHELL_HEIGHT);
+ fToolTipShell.addDisposeListener((e) -> {
+ for (int i = 0; i < fColors.length; i++) {
+ fColors[i].dispose();
+ }
+ });
fColors = new Color[NUMBER_STEPS];
int greenBlue = BASE_GREEN_BLUE_VALUE;
}
/**
- * Disposes the system resource used by this kind of toolTips (a colors array essentially)
+ * Dispose this tool tip
*/
public void dispose() {
- for (int i = 0; i < fColors.length; i++) {
- fColors[i].dispose();
- }
+ fToolTipShell.dispose();
}
@Override
/**********************************************************************
- * Copyright (c) 2005, 2014 IBM Corporation, Ericsson
+ * Copyright (c) 2005, 2016 IBM Corporation, Ericsson
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
}
});
}
+
+ addDisposeListener((e) -> {
+ if (fAutoScroll != null) {
+ fAutoScroll.cancel();
+ fAutoScroll = null;
+ }
+ fViewControl = null;
+ fVertScrollBar = null;
+ fHorScrollBar = null;
+ if (fCornerControl != null) {
+ Object data = fCornerControl.getData();
+ if (data instanceof Overview) {
+ ((Overview) data).dispose();
+ }
+ }
+ fCornerControl = null;
+ });
}
// ------------------------------------------------------------------------
fViewControl.setCursor(cursor);
}
- @Override
- public void dispose() {
- if (fAutoScroll != null) {
- fAutoScroll.cancel();
- fAutoScroll = null;
- }
- if (fViewControl != null) {
- fViewControl.dispose();
- }
- fViewControl = null;
- if (fVertScrollBar != null) {
- fVertScrollBar.dispose();
- }
- fVertScrollBar = null;
- if (fHorScrollBar != null) {
- fHorScrollBar.dispose();
- }
- fHorScrollBar = null;
- if (fCornerControl != null) {
- Object data = fCornerControl.getData();
- if (data instanceof Overview) {
- ((Overview) data).dispose();
- }
- fCornerControl.dispose();
- fCornerControl = null;
- }
- super.dispose();
- }
-
@Override
public Rectangle getClientArea() {
Rectangle area = fViewControl.getClientArea();
/*******************************************************************************
- * Copyright (c) 2010, 2015 Ericsson
+ * Copyright (c) 2010, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
// Prevent the slider from being traversed
setTabList(new Control[] { fScrolledComposite });
- }
- @Override
- public void dispose() {
- if (fBottomContext != null) {
- fBottomContext.dispose();
- }
- PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(this);
- super.dispose();
+ addDisposeListener((e) -> {
+ if (fBottomContext != null) {
+ fBottomContext.dispose();
+ }
+ PlatformUI.getWorkbench().getThemeManager().removePropertyChangeListener(TmfRawEventViewer.this);
+ });
}
// ------------------------------------------------------------------------
/*******************************************************************************
- * Copyright (c) 2012, 2014 Ericsson
+ * Copyright (c) 2012, 2016 Ericsson
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
initFolder();
}
- @Override
- public void dispose() {
- super.dispose();
- for (ITmfViewer viewer : fViewers.values()) {
- viewer.dispose();
- }
- if (fFolder != null) {
- fFolder.dispose();
- }
- }
-
/**
* Disposes of all the viewers contained in the folder and restart to a
* clean state.
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.ControlAdapter;
import org.eclipse.swt.events.ControlEvent;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.events.MenuDetectListener;
super.redraw();
}
};
- fDataViewer.addDisposeListener(new DisposeListener() {
- @Override
- public void widgetDisposed(DisposeEvent e) {
- if (fMarkersMenu != null) {
- fMarkersMenu.dispose();
- }
+ fDataViewer.addDisposeListener((e) -> {
+ if (fMarkersMenu != null) {
+ fMarkersMenu.dispose();
}
});
GridLayout gl = new GridLayout(2, false);
fDataViewer.update();
adjustHorizontalScrollBar();
adjustVerticalScrollBar();
+
+ fDataViewer.addDisposeListener((e) -> {
+ saveOptions();
+ fColorScheme.dispose();
+ });
+
return fDataViewer;
}
/**
- * Dispose the view.
+ * Dispose the time graph viewer.
*/
public void dispose() {
- saveOptions();
- fTimeGraphCtrl.dispose();
fDataViewer.dispose();
- fColorScheme.dispose();
}
/**
/*******************************************************************************
- * Copyright (c) 2009, 2014 Ericsson.
+ * Copyright (c) 2009, 2016 Ericsson.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v1.0 which
setDialogHelpAvailable(false);
setHelpAvailable(false);
+ composite.addDisposeListener((e) -> {
+ fResourceManager.dispose();
+ });
return composite;
}
gc.setForeground(Display.getDefault().getSystemColor(SWT.COLOR_BLACK));
gc.drawRectangle(0, 0, r.width - 1, r.height - 1);
}
-
- @Override
- public void dispose() {
- super.dispose();
- color.dispose();
- }
-
}
}
addKeyListener(this);
addMenuDetectListener(this);
addListener(SWT.MouseWheel, this);
- }
-
- @Override
- public void dispose() {
- super.dispose();
- fResourceManager.dispose();
- for (Font font : fFonts.values()) {
- font.dispose();
- }
+ addDisposeListener((e) -> {
+ fResourceManager.dispose();
+ for (Font font : fFonts.values()) {
+ font.dispose();
+ }
+ });
}
/**
addMouseListener(this);
addMouseMoveListener(this);
TimeDraw.updateTimeZone();
- }
-
- @Override
- public void dispose() {
- TmfSignalManager.deregister(this);
- super.dispose();
+ addDisposeListener((e) -> {
+ TmfSignalManager.deregister(TimeGraphScale.this);
+ });
}
/**