diff options
| author | Lars Vogel | 2020-07-14 13:29:42 +0000 |
|---|---|---|
| committer | Roland Grunberg | 2020-08-05 17:54:47 +0000 |
| commit | ba67eabbf1207ad025db6d9e4dbd74e95cbad904 (patch) | |
| tree | dd73faedea05d9722da419bb7eb1978d41b6c7e5 | |
| parent | e0b8c4a05fdb3ca1ade9a97ea71394fb3f477ddd (diff) | |
| download | eclipse.jdt.ui-ba67eabbf1207ad025db6d9e4dbd74e95cbad904.tar.gz eclipse.jdt.ui-ba67eabbf1207ad025db6d9e4dbd74e95cbad904.tar.xz eclipse.jdt.ui-ba67eabbf1207ad025db6d9e4dbd74e95cbad904.zip | |
Bug 565208: Remove calls to Color.dispose
As these calls are no longer needed, remove the calls
and related code around such dispose that is also
now redundant.
Also removes the Colors fields in AbstractInfoView, JavaSourceViewer and
SourceViewerInformationControl which were only used for dispose calls.
Change-Id: Ic35eb74a501e358aa79987b16b4240e429847f13
8 files changed, 5 insertions, 96 deletions
diff --git a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java index 03f18a833b..47ef1f5380 100644 --- a/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java +++ b/org.eclipse.jdt.astview/src/org/eclipse/jdt/astview/views/ASTViewLabelProvider.java @@ -240,8 +240,6 @@ public class ASTViewLabelProvider extends LabelProvider implements IColorProvide @Override public void dispose() { super.dispose(); - fSelectedElemBGColor.dispose(); - fLightRed.dispose(); fAllocatedBoldItalic.dispose(); } diff --git a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java index 72478c9ed3..cb2a2ea6ff 100644 --- a/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java +++ b/org.eclipse.jdt.junit/src/org/eclipse/jdt/internal/junit/ui/JUnitProgressBar.java @@ -53,11 +53,6 @@ public class JUnitProgressBar extends Canvas { } }); addPaintListener(this::paint); - addDisposeListener(event -> { - fFailureColor.dispose(); - fOKColor.dispose(); - fStoppedColor.dispose(); - }); Display display= parent.getDisplay(); fFailureColor= new Color(display, 159, 63, 63); fOKColor= new Color(display, 95, 191, 95); diff --git a/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeInfoViewer.java b/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeInfoViewer.java index 86b5986310..eef9a7968b 100644 --- a/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeInfoViewer.java +++ b/org.eclipse.jdt.ui/internal compatibility/org/eclipse/jdt/internal/ui/dialogs/TypeInfoViewer.java @@ -935,7 +935,6 @@ public class TypeInfoViewer { }); fTable.addDisposeListener(event -> { stop(true, true); - fDashLineColor.dispose(); fSeparatorIcon.dispose(); fImageManager.dispose(); if (fProgressUpdateJob != null) { diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/AbstractInfoView.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/AbstractInfoView.java index 18b67f486e..969b25967d 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/AbstractInfoView.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/infoviews/AbstractInfoView.java @@ -158,14 +158,8 @@ public abstract class AbstractInfoView extends ViewPart implements ISelectionLis */ private IProgressMonitor fComputeProgressMonitor; - /** - * Background color. - * @since 3.2 - */ - private Color fBackgroundColor; private RGB fBackgroundColorRGB; - private Color fForegroundColor; private RGB fForegroundColorRGB; /** @@ -393,8 +387,7 @@ public abstract class AbstractInfoView extends ViewPart implements ISelectionLis fgColor = display.getSystemColor(SWT.COLOR_INFO_FOREGROUND); fForegroundColorRGB= fgColor.getRGB(); } else { - fgColor = new Color(display, fForegroundColorRGB); - fForegroundColor= fgColor; + fgColor = new Color(fForegroundColorRGB); } setForeground(fgColor); @@ -404,8 +397,7 @@ public abstract class AbstractInfoView extends ViewPart implements ISelectionLis bgColor= display.getSystemColor(SWT.COLOR_INFO_BACKGROUND); fBackgroundColorRGB= bgColor.getRGB(); } else { - bgColor= new Color(display, fBackgroundColorRGB); - fBackgroundColor= bgColor; + bgColor= new Color(fBackgroundColorRGB); } setBackground(bgColor); } @@ -669,16 +661,8 @@ public abstract class AbstractInfoView extends ViewPart implements ISelectionLis JFaceResources.getColorRegistry().removeListener(this); fBackgroundColorRGB= null; - if (fBackgroundColor != null) { - fBackgroundColor.dispose(); - fBackgroundColor= null; - } fForegroundColorRGB= null; - if (fForegroundColor != null) { - fForegroundColor.dispose(); - fForegroundColor= null; - } internalDispose(); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java index 218fda3cf2..44fd1855dd 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/ClassFileEditor.java @@ -169,7 +169,6 @@ public class ClassFileEditor extends JavaEditor implements ClassFileDocumentProv fComposite.addDisposeListener(e -> { JFaceResources.getFontRegistry().removeListener(SourceAttachmentForm.this); fComposite= null; - fSeparatorColor.dispose(); fSeparatorColor= null; fBannerLabels.clear(); fHeaderLabels.clear(); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java index 9e6507b8ab..f810fff43b 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/javaeditor/JavaSourceViewer.java @@ -94,26 +94,6 @@ public class JavaSourceViewer extends ProjectionViewer implements IPropertyChang private IInformationPresenter fHierarchyPresenter; /** - * This viewer's foreground color. - * @since 3.0 - */ - private Color fForegroundColor; - /** - * The viewer's background color. - * @since 3.0 - */ - private Color fBackgroundColor; - /** - * This viewer's selection foreground color. - * @since 3.0 - */ - private Color fSelectionForegroundColor; - /** - * The viewer's selection background color. - * @since 3.0 - */ - private Color fSelectionBackgroundColor; - /** * The preference store. * * @since 3.0 @@ -272,43 +252,24 @@ public class JavaSourceViewer extends ProjectionViewer implements IPropertyChang : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_FOREGROUND, styledText.getDisplay()); styledText.setForeground(color); - if (fForegroundColor != null) - fForegroundColor.dispose(); - - fForegroundColor= color; - // ---------- background color ---------------------- color= fPreferenceStore.getBoolean(AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND_SYSTEM_DEFAULT) ? null : createColor(fPreferenceStore, AbstractTextEditor.PREFERENCE_COLOR_BACKGROUND, styledText.getDisplay()); styledText.setBackground(color); - if (fBackgroundColor != null) - fBackgroundColor.dispose(); - - fBackgroundColor= color; - // ----------- selection foreground color -------------------- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_DEFAULT_COLOR) ? null : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_FOREGROUND_COLOR, styledText.getDisplay()); styledText.setSelectionForeground(color); - if (fSelectionForegroundColor != null) - fSelectionForegroundColor.dispose(); - - fSelectionForegroundColor= color; - // ---------- selection background color ---------------------- color= fPreferenceStore.getBoolean(AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_DEFAULT_COLOR) ? null : createColor(fPreferenceStore, AbstractDecoratedTextEditorPreferenceConstants.EDITOR_SELECTION_BACKGROUND_COLOR, styledText.getDisplay()); styledText.setSelectionBackground(color); - if (fSelectionBackgroundColor != null) - fSelectionBackgroundColor.dispose(); - - fSelectionBackgroundColor= color; } } @@ -360,10 +321,6 @@ public class JavaSourceViewer extends ProjectionViewer implements IPropertyChang if (Math.abs(defaultBgHSB[2] - javaDefaultHSB[2]) >= 0.5f) { getTextWidget().setBackground(defaultColor); - if (fBackgroundColor != null) { - fBackgroundColor.dispose(); - fBackgroundColor= null; - } } } @@ -386,14 +343,6 @@ public class JavaSourceViewer extends ProjectionViewer implements IPropertyChang fHierarchyPresenter.uninstall(); fHierarchyPresenter= null; } - if (fForegroundColor != null) { - fForegroundColor.dispose(); - fForegroundColor= null; - } - if (fBackgroundColor != null) { - fBackgroundColor.dispose(); - fBackgroundColor= null; - } if (fPreferenceStore != null) fPreferenceStore.removePropertyChangeListener(this); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchLabelProvider.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchLabelProvider.java index 63b0abed83..6da9db9688 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchLabelProvider.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/search/SearchLabelProvider.java @@ -173,7 +173,6 @@ public abstract class SearchLabelProvider extends AppearanceAwareLabelProvider { @Override public void dispose() { if (fPotentialMatchFgColor != null) { - fPotentialMatchFgColor.dispose(); fPotentialMatchFgColor= null; } fSearchPreferences.removePropertyChangeListener(fSearchPropertyListener); diff --git a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/SourceViewerInformationControl.java b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/SourceViewerInformationControl.java index 13b392986c..69e5383346 100644 --- a/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/SourceViewerInformationControl.java +++ b/org.eclipse.jdt.ui/ui/org/eclipse/jdt/internal/ui/text/java/hover/SourceViewerInformationControl.java @@ -108,12 +108,7 @@ public class SourceViewerInformationControl * @since 3.0 */ private Font fStatusTextFont; - /** - * The color of the optional status text label or <code>null</code> if none. - * - * @since 3.6 - */ - private Color fStatusTextForegroundColor; + /** * The width size constraint. * @since 3.2 @@ -131,7 +126,6 @@ public class SourceViewerInformationControl private final int fOrientation; private Color fBackgroundColor; - private boolean fIsSystemBackgroundColor= true; private JavaSourceViewerConfiguration fViewerConfiguration; private Map<String, JavaSourceViewerConfiguration> fKindToViewerConfiguration= new HashMap<>(); @@ -232,8 +226,8 @@ public class SourceViewerInformationControl fStatusField.setLayoutData(gd2); RGB javaDefaultColor= JavaUI.getColorManager().getColor(IJavaColorConstants.JAVA_DEFAULT).getRGB(); - fStatusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), javaDefaultColor, 0.56f)); - fStatusField.setForeground(fStatusTextForegroundColor); + Color statusTextForegroundColor= new Color(fStatusField.getDisplay(), blend(fBackgroundColor.getRGB(), javaDefaultColor, 0.56f)); + fStatusField.setForeground(statusTextForegroundColor); fStatusField.setBackground(fBackgroundColor); } @@ -276,10 +270,8 @@ public class SourceViewerInformationControl } if (bgRGB != null) { fBackgroundColor= new Color(fShell.getDisplay(), bgRGB); - fIsSystemBackgroundColor= false; } else { fBackgroundColor= fShell.getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND); - fIsSystemBackgroundColor= true; } } @@ -394,10 +386,6 @@ public class SourceViewerInformationControl fStatusTextFont.dispose(); fStatusTextFont= null; - if (fStatusTextForegroundColor != null && !fStatusTextForegroundColor.isDisposed()) - fStatusTextForegroundColor.dispose(); - fStatusTextForegroundColor= null; - fTextFont= null; fShell= null; fText= null; @@ -405,8 +393,6 @@ public class SourceViewerInformationControl @Override public final void dispose() { - if (!fIsSystemBackgroundColor) - fBackgroundColor.dispose(); if (fShell != null && !fShell.isDisposed()) fShell.dispose(); else |
