Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlexander Kurtakov2018-03-29 02:50:57 -0400
committerAlexander Kurtakov2018-03-29 02:50:57 -0400
commit534d3cc4229625961a0eed78a5e7fb467f2c549e (patch)
tree1b45f09cf1aaf4f3110b7f0aef8c4e56dce62e0e
parent22cba0022bfd7ceca30273236c6cde4244a6b26e (diff)
downloadeclipse.platform.team-534d3cc4229625961a0eed78a5e7fb467f2c549e.tar.gz
eclipse.platform.team-534d3cc4229625961a0eed78a5e7fb467f2c549e.tar.xz
eclipse.platform.team-534d3cc4229625961a0eed78a5e7fb467f2c549e.zip
Bug 533040 - Use system cursors
To prevent needlessly creating and disposing cursors. Change-Id: Ieb88dc236954a136dae8e515790c458d78ea6563 Signed-off-by: Alexander Kurtakov <akurtako@redhat.com>
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java31
-rw-r--r--bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java18
-rw-r--r--bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java99
3 files changed, 45 insertions, 103 deletions
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
index 065620b11..87af3c009 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/ContentMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* 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
@@ -339,7 +339,7 @@ public abstract class ContentMergeViewer extends ContentViewer
private Image fRightArrow;
private Image fLeftArrow;
private Image fBothArrow;
- Cursor fNormalCursor;
+ private Cursor fNormalCursor;
private Cursor fHSashCursor;
private Cursor fVSashCursor;
private Cursor fHVSashCursor;
@@ -591,27 +591,27 @@ public abstract class ContentMergeViewer extends ContentViewer
case VERTICAL:
if (fAncestorVisible) {
if (fVSashCursor == null)
- fVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZENS);
+ fVSashCursor=c.getDisplay().getSystemCursor(SWT.CURSOR_SIZENS);
cursor= fVSashCursor;
} else {
if (fNormalCursor == null)
- fNormalCursor= new Cursor(c.getDisplay(), SWT.CURSOR_ARROW);
+ fNormalCursor= c.getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
cursor= fNormalCursor;
}
break;
case HORIZONTAL:
if (fHSashCursor == null)
- fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
+ fHSashCursor= c.getDisplay().getSystemCursor(SWT.CURSOR_SIZEWE);
cursor= fHSashCursor;
break;
case VERTICAL + HORIZONTAL:
if (fAncestorVisible) {
if (fHVSashCursor == null)
- fHVSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEALL);
+ fHVSashCursor= c.getDisplay().getSystemCursor(SWT.CURSOR_SIZEALL);
cursor= fHVSashCursor;
} else {
if (fHSashCursor == null)
- fHSashCursor= new Cursor(c.getDisplay(), SWT.CURSOR_SIZEWE);
+ fHSashCursor= c.getDisplay().getSystemCursor(SWT.CURSOR_SIZEWE);
cursor= fHSashCursor;
}
break;
@@ -1054,23 +1054,6 @@ public abstract class ContentMergeViewer extends ContentViewer
fBothArrow= null;
}
- if (fNormalCursor != null) {
- fNormalCursor.dispose();
- fNormalCursor= null;
- }
- if (fHSashCursor != null) {
- fHSashCursor.dispose();
- fHSashCursor= null;
- }
- if (fVSashCursor != null) {
- fVSashCursor.dispose();
- fVSashCursor= null;
- }
- if (fHVSashCursor != null) {
- fHVSashCursor.dispose();
- fHVSashCursor= null;
- }
-
super.handleDispose(event);
}
diff --git a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
index 5b07e4ba9..04d3d4828 100644
--- a/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
+++ b/bundles/org.eclipse.compare/compare/org/eclipse/compare/contentmergeviewer/TextMergeViewer.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2017 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* 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
@@ -363,7 +363,6 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
// SWT resources to be disposed
private Map<RGB, Color> fColors;
- private Cursor fBirdsEyeCursor;
// points for center curves
private double[] fBasicCenterCurve;
@@ -1578,8 +1577,6 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
};
fComposite.setData(INavigatable.NAVIGATOR_PROPERTY, nav);
- fBirdsEyeCursor= new Cursor(parent.getDisplay(), SWT.CURSOR_HAND);
-
JFaceResources.getFontRegistry().addListener(fPreferenceChangeListener);
JFaceResources.getColorRegistry().addListener(fPreferenceChangeListener);
updateFont();
@@ -1917,11 +1914,6 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
disconnect(fRightContributor);
disconnect(fAncestorContributor);
- if (fBirdsEyeCursor != null) {
- fBirdsEyeCursor.dispose();
- fBirdsEyeCursor= null;
- }
-
if (showWhitespaceAction != null)
showWhitespaceAction.dispose();
@@ -2124,7 +2116,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
Cursor cursor= null;
Diff diff= handlemouseInBirdsEyeView(fBirdsEyeCanvas, e.y);
if (diff != null && diff.getKind() != RangeDifference.NOCHANGE)
- cursor= fBirdsEyeCursor;
+ cursor= e.widget.getDisplay().getSystemCursor(SWT.CURSOR_HAND);
if (fLastCursor != cursor) {
fBirdsEyeCanvas.setCursor(cursor);
fLastCursor= cursor;
@@ -2389,11 +2381,11 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
};
new HoverResizer(canvas, HORIZONTAL);
- if (fNormalCursor == null) fNormalCursor= new Cursor(canvas.getDisplay(), SWT.CURSOR_ARROW);
+ Cursor normalCursor= canvas.getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
int style= fIsMac ? SWT.FLAT : SWT.PUSH;
fLeftToRightButton= new Button(canvas, style);
- fLeftToRightButton.setCursor(fNormalCursor);
+ fLeftToRightButton.setCursor(normalCursor);
fLeftToRightButton.setText(COPY_LEFT_TO_RIGHT_INDICATOR);
fLeftToRightButton.setToolTipText(
Utilities.getString(getResourceBundle(), "action.CopyDiffLeftToRight.tooltip")); //$NON-NLS-1$
@@ -2409,7 +2401,7 @@ public class TextMergeViewer extends ContentMergeViewer implements IAdaptable {
);
fRightToLeftButton= new Button(canvas, style);
- fRightToLeftButton.setCursor(fNormalCursor);
+ fRightToLeftButton.setCursor(normalCursor);
fRightToLeftButton.setText(COPY_RIGHT_TO_LEFT_INDICATOR);
fRightToLeftButton.setToolTipText(
Utilities.getString(getResourceBundle(), "action.CopyDiffRightToLeft.tooltip")); //$NON-NLS-1$
diff --git a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java
index c7ae412b8..a003ec5fb 100644
--- a/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java
+++ b/bundles/org.eclipse.team.cvs.ui/src/org/eclipse/team/internal/ccvs/ui/tags/TagSelectionDialog.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2000, 2006 IBM Corporation and others.
+ * Copyright (c) 2000, 2018 IBM Corporation and others.
* 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
@@ -17,13 +17,10 @@ import org.eclipse.core.runtime.jobs.Job;
import org.eclipse.jface.dialogs.IDialogConstants;
import org.eclipse.jface.dialogs.TrayDialog;
import org.eclipse.jface.operation.IRunnableContext;
-import org.eclipse.jface.operation.IRunnableWithProgress;
import org.eclipse.jface.util.IPropertyChangeListener;
import org.eclipse.jface.util.PropertyChangeEvent;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
-import org.eclipse.swt.events.DisposeEvent;
-import org.eclipse.swt.events.DisposeListener;
import org.eclipse.swt.graphics.Cursor;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
@@ -38,7 +35,6 @@ import org.eclipse.team.internal.ccvs.ui.*;
public class TagSelectionDialog extends TrayDialog implements IPropertyChangeListener {
private TagSelectionArea tagSelectionArea;
- private Cursor appBusyCursor;
public static final int INCLUDE_HEAD_TAG = TagSourceWorkbenchAdapter.INCLUDE_HEAD_TAG;
public static final int INCLUDE_BASE_TAG = TagSourceWorkbenchAdapter.INCLUDE_BASE_TAG;
@@ -103,17 +99,11 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis
setShellStyle(SWT.DIALOG_TRIM | SWT.RESIZE | SWT.APPLICATION_MODAL);
}
- /* (non-Javadoc)
- * Method declared on Window.
- */
protected void configureShell(Shell newShell) {
super.configureShell(newShell);
newShell.setText(title);
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.window.Window#getInitialSize()
- */
protected Point getInitialSize() {
final Point size= super.getInitialSize();
size.x= convertWidthInCharsToPixels(SIZING_DIALOG_WIDTH);
@@ -176,11 +166,7 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis
if(showRecurse) {
final Button recurseCheck = new Button(parent, SWT.CHECK);
recurseCheck.setText(CVSUIMessages.TagSelectionDialog_recurseOption);
- recurseCheck.addListener(SWT.Selection, new Listener() {
- public void handleEvent(Event event) {
- recurse = recurseCheck.getSelection();
- }
- });
+ recurseCheck.addListener(SWT.Selection, event -> recurse = recurseCheck.getSelection());
recurseCheck.setSelection(true);
}
}
@@ -252,9 +238,6 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis
}
}
- /* (non-Javadoc)
- * @see org.eclipse.jface.util.IPropertyChangeListener#propertyChange(org.eclipse.jface.util.PropertyChangeEvent)
- */
public void propertyChange(PropertyChangeEvent event) {
String property = event.getProperty();
if (property.equals(TagSelectionArea.SELECTED_TAG)) {
@@ -271,62 +254,46 @@ public class TagSelectionDialog extends TrayDialog implements IPropertyChangeLis
* @since 3.1
*/
private IRunnableContext getRunnableContext() {
- return new IRunnableContext() {
- public void run(boolean fork, boolean cancelable, final IRunnableWithProgress runnable) throws InvocationTargetException, InterruptedException {
- final Job refreshJob = new Job(CVSUIMessages.TagSelectionDialog_7) {
- protected IStatus run(IProgressMonitor monitor) {
- if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- try {
- setBusy(true);
- runnable.run(monitor);
- } catch (InvocationTargetException e) {
- return new CVSStatus(IStatus.ERROR, CVSUIMessages.TagSelectionDialog_8, e);
- } catch (InterruptedException e) {
- return new CVSStatus(IStatus.ERROR, CVSUIMessages.TagSelectionDialog_8, e);
- } finally {
- setBusy(false);
- }
+ return (fork, cancelable, runnable) -> {
+ final Job refreshJob = new Job(CVSUIMessages.TagSelectionDialog_7) {
+ protected IStatus run(IProgressMonitor monitor) {
if (monitor.isCanceled())
- return Status.CANCEL_STATUS;
- else
- return Status.OK_STATUS;
+ return Status.CANCEL_STATUS;
+ try {
+ setBusy(true);
+ runnable.run(monitor);
+ } catch (InvocationTargetException e) {
+ return new CVSStatus(IStatus.ERROR, CVSUIMessages.TagSelectionDialog_8, e);
+ } catch (InterruptedException e) {
+ return new CVSStatus(IStatus.ERROR, CVSUIMessages.TagSelectionDialog_8, e);
+ } finally {
+ setBusy(false);
}
- };
- refreshJob.setUser(false);
- refreshJob.setPriority(Job.DECORATE);
- getShell().addDisposeListener(new DisposeListener() {
- public void widgetDisposed(DisposeEvent e) {
- refreshJob.cancel();
- }
- });
- refreshJob.schedule();
- }
+ if (monitor.isCanceled())
+ return Status.CANCEL_STATUS;
+ else
+ return Status.OK_STATUS;
+ }
+ };
+ refreshJob.setUser(false);
+ refreshJob.setPriority(Job.DECORATE);
+ getShell().addDisposeListener(e -> refreshJob.cancel());
+ refreshJob.schedule();
};
}
private void setBusy(final boolean busy) {
final Shell shell = getShell();
if (shell != null && !shell.isDisposed()) {
- shell.getDisplay().asyncExec(new Runnable() {
- public void run() {
- if (!shell.isDisposed()) {
- Cursor cursor = null;
- if (busy) {
- if (appBusyCursor == null)
- appBusyCursor = new Cursor(shell.getDisplay(), SWT.CURSOR_APPSTARTING);
- cursor = appBusyCursor;
- }
- shell.setCursor(cursor);
- }
- }
+ shell.getDisplay().asyncExec(() -> {
+ if (!shell.isDisposed()) {
+ Cursor cursor = null;
+ if (busy) {
+ cursor = shell.getDisplay().getSystemCursor(SWT.CURSOR_APPSTARTING);
+ }
+ shell.setCursor(cursor);
+ }
});
}
}
-
- public boolean close() {
- if(appBusyCursor != null)
- appBusyCursor.dispose();
- return super.close();
- }
}

Back to the top