[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
[
List Home]
[cdt-patch] CDT UI leak fix
|
Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/ChangeLog,v
retrieving revision 1.35
diff -u -r1.35 ChangeLog
--- ChangeLog 27 Nov 2002 04:51:17 -0000 1.35
+++ ChangeLog 27 Nov 2002 18:56:23 -0000
@@ -1,3 +1,7 @@
+2002-11-27 David Inglis
+ * utils.ui/.../controls/ControlFactory.java:
+ removed unsed hyperlink stuff since it was leaking Cursors.
+
2002-11-27 Alain Magloire
* src/.../internal/ui/preferences/CProjectPropertyPage.java:
Index: org/eclipse/cdt/utils/ui/controls/ControlFactory.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.ui/utils.ui/org/eclipse/cdt/utils/ui/controls/ControlFactory.java,v
retrieving revision 1.3
diff -u -r1.3 ControlFactory.java
--- org/eclipse/cdt/utils/ui/controls/ControlFactory.java 17 Oct 2002 19:58:22 -0000 1.3
+++ org/eclipse/cdt/utils/ui/controls/ControlFactory.java 27 Nov 2002 18:37:04 -0000
@@ -5,32 +5,39 @@
* All Rights Reserved.
*/
+import java.util.StringTokenizer;
+
+import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.jface.viewers.CheckboxTableViewer;
+import org.eclipse.jface.viewers.ColumnWeightData;
+import org.eclipse.jface.viewers.TableLayout;
+import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
-import org.eclipse.swt.events.*;
+import org.eclipse.swt.events.SelectionListener;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Font;
import org.eclipse.swt.graphics.FontData;
-import org.eclipse.swt.widgets.*;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.List;
+import org.eclipse.swt.widgets.MessageBox;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Table;
import org.eclipse.swt.widgets.TableColumn;
-import org.eclipse.swt.layout.*;
-import org.eclipse.jface.viewers.CellEditor;
-import org.eclipse.jface.viewers.CheckboxTableViewer;
-import org.eclipse.jface.viewers.ColumnWeightData;
-import org.eclipse.jface.viewers.TableLayout;
-import org.eclipse.jface.viewers.TableViewer;
+import org.eclipse.swt.widgets.TableItem;
+import org.eclipse.swt.widgets.Text;
import org.eclipse.ui.PlatformUI;
-import org.eclipse.swt.SWT;
-import java.util.StringTokenizer;
public class ControlFactory {
- private static HyperlinkHandler defaultHyperlinkHandler = new HyperlinkHandler();
-
- public static void dispose() {
- defaultHyperlinkHandler.dispose();
- }
-
public static Control setParentColors(Control control) {
Composite parent = control.getParent();
control.setBackground(parent.getBackground());
@@ -164,28 +171,7 @@
return createLabel(parent, text, widthHint, heightHint, SWT.LEFT | SWT.WRAP);
}
- /**
- * Utility method that creates a HyperLinkLabel instance
- * and sets the default layout data.
- *
- * @param parent the parent for the new label
- * @param text the text for the new label
- * @param TypedListener click event listener
- * @return the new label
- */
- public static Label createHyperlinkLabel(Composite parent, String text, IHyperlinkListener listener,
- HyperlinkHandler hyperlinkHandler) {
- Label label = createLabel(parent, text);
- turnIntoHyperlink(label, listener,
- (null == hyperlinkHandler) ? defaultHyperlinkHandler : hyperlinkHandler);
- return label;
- }
- public static void turnIntoHyperlink(Control control, IHyperlinkListener listener,
- HyperlinkHandler hyperlinkHandler) {
- hyperlinkHandler.registerHyperlink(control, listener);
- }
-
/**
* Creates an new checkbox instance and sets the default
* layout data.
Index: org/eclipse/cdt/utils/ui/controls/HyperlinkHandler.java
===================================================================
RCS file: org/eclipse/cdt/utils/ui/controls/HyperlinkHandler.java
diff -N org/eclipse/cdt/utils/ui/controls/HyperlinkHandler.java
--- org/eclipse/cdt/utils/ui/controls/HyperlinkHandler.java 26 Jun 2002 21:17:46 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,176 +0,0 @@
-package org.eclipse.cdt.utils.ui.controls;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.widgets.*;
-import org.eclipse.swt.events.*;
-import org.eclipse.swt.graphics.*;
-import java.util.*;
-import org.eclipse.swt.*;
-
-public class HyperlinkHandler implements MouseListener, MouseTrackListener, PaintListener {
- public static final int UNDERLINE_NEVER = 1;
- public static final int UNDERLINE_ROLLOVER = 2;
- public static final int UNDERLINE_ALWAYS = 3;
-
- private Cursor hyperlinkCursor;
- private Cursor busyCursor;
- private boolean hyperlinkCursorUsed=true;
- private int hyperlinkUnderlineMode=UNDERLINE_ALWAYS;
- private Color background;
- private Color foreground;
- private Color activeBackground;
- private Color activeForeground;
- private Hashtable hyperlinkListeners;
- private Control lastLink;
-
-public HyperlinkHandler() {
- hyperlinkListeners = new Hashtable();
- hyperlinkCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
- busyCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_WAIT);
-}
-public void dispose() {
- hyperlinkCursor.dispose();
- busyCursor.dispose();
-}
-public org.eclipse.swt.graphics.Color getActiveBackground() {
- return activeBackground;
-}
-public org.eclipse.swt.graphics.Color getActiveForeground() {
- return activeForeground;
-}
-public org.eclipse.swt.graphics.Color getBackground() {
- return background;
-}
-public org.eclipse.swt.graphics.Cursor getBusyCursor() {
- return busyCursor;
-}
-public org.eclipse.swt.graphics.Color getForeground() {
- return foreground;
-}
-public org.eclipse.swt.graphics.Cursor getHyperlinkCursor() {
- return hyperlinkCursor;
-}
-public int getHyperlinkUnderlineMode() {
- return hyperlinkUnderlineMode;
-}
-public org.eclipse.swt.widgets.Control getLastLink() {
- return lastLink;
-}
-public boolean isHyperlinkCursorUsed() {
- return hyperlinkCursorUsed;
-}
- public void mouseDoubleClick(MouseEvent e) {
- }
-public void mouseDown(MouseEvent e) {
- if (e.button == 1)
- return;
- lastLink = (Control)e.widget;
-}
-public void mouseEnter(MouseEvent e) {
- Control control = (Control) e.widget;
- if (isHyperlinkCursorUsed())
- control.setCursor(hyperlinkCursor);
- if (activeBackground != null)
- control.setBackground(activeBackground);
- if (activeForeground != null)
- control.setForeground(activeForeground);
- if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER) underline(control, true);
-
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(control);
- if (action != null)
- action.linkEntered(control);
-}
-public void mouseExit(MouseEvent e) {
- Control control = (Control) e.widget;
- if (isHyperlinkCursorUsed())
- control.setCursor(null);
- if (hyperlinkUnderlineMode==UNDERLINE_ROLLOVER)
- underline(control, false);
- if (background != null)
- control.setBackground(background);
- if (foreground != null)
- control.setForeground(foreground);
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(control);
- if (action != null)
- action.linkExited(control);
-}
- public void mouseHover(MouseEvent e) {
- }
-public void mouseUp(MouseEvent e) {
- if (e.button != 1)
- return;
- IHyperlinkListener action =
- (IHyperlinkListener) hyperlinkListeners.get(e.widget);
- if (action != null) {
- Control c = (Control) e.widget;
- c.setCursor(busyCursor);
- action.linkActivated(c);
- if (!c.isDisposed())
- c.setCursor(isHyperlinkCursorUsed()?hyperlinkCursor:null);
- }
-}
-public void paintControl(PaintEvent e) {
- Control label = (Control) e.widget;
- if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
- HyperlinkHandler.underline(label, true);
-}
-public void registerHyperlink(Control control, IHyperlinkListener listener) {
- if (background != null)
- control.setBackground(background);
- if (foreground != null)
- control.setForeground(foreground);
- control.addMouseListener(this);
- control.addMouseTrackListener(this);
- if (hyperlinkUnderlineMode == UNDERLINE_ALWAYS)
- control.addPaintListener(this);
- hyperlinkListeners.put(control, listener);
- removeDisposedLinks();
-}
-private void removeDisposedLinks() {
- for (Enumeration keys = hyperlinkListeners.keys(); keys.hasMoreElements();) {
- Control control = (Control)keys.nextElement();
- if (control.isDisposed()) {
- hyperlinkListeners.remove(control);
- }
- }
-}
-public void reset() {
- hyperlinkListeners.clear();
-}
-public void setActiveBackground(org.eclipse.swt.graphics.Color newActiveBackground) {
- activeBackground = newActiveBackground;
-}
-public void setActiveForeground(org.eclipse.swt.graphics.Color newActiveForeground) {
- activeForeground = newActiveForeground;
-}
-public void setBackground(org.eclipse.swt.graphics.Color newBackground) {
- background = newBackground;
-}
-public void setForeground(org.eclipse.swt.graphics.Color newForeground) {
- foreground = newForeground;
-}
-public void setHyperlinkCursorUsed(boolean newHyperlinkCursorUsed) {
- hyperlinkCursorUsed = newHyperlinkCursorUsed;
-}
-public void setHyperlinkUnderlineMode(int newHyperlinkUnderlineMode) {
- hyperlinkUnderlineMode = newHyperlinkUnderlineMode;
-}
-public static void underline(Control control, boolean inside) {
- if (!(control instanceof Label))
- return;
- Composite parent = control.getParent();
- Rectangle bounds = control.getBounds();
- GC gc = new GC(parent);
- Color color = inside? control.getForeground() : control.getBackground();
- gc.setForeground(color);
- int y = bounds.y + bounds.height;
- gc.drawLine(bounds.x, y, bounds.x+bounds.width, y);
- gc.dispose();
-}
-}
Index: org/eclipse/cdt/utils/ui/controls/IHyperlinkListener.java
===================================================================
RCS file: org/eclipse/cdt/utils/ui/controls/IHyperlinkListener.java
diff -N org/eclipse/cdt/utils/ui/controls/IHyperlinkListener.java
--- org/eclipse/cdt/utils/ui/controls/IHyperlinkListener.java 26 Jun 2002 21:17:46 -0000 1.1
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -1,15 +0,0 @@
-package org.eclipse.cdt.utils.ui.controls;
-
-/*
- * (c) Copyright IBM Corp. 2000, 2001.
- * All Rights Reserved.
- */
-
-import org.eclipse.swt.widgets.*;
-
-public interface IHyperlinkListener {
-
-public void linkActivated(Control linkLabel);
-public void linkEntered(Control linkLabel);
-public void linkExited(Control linkLabel);
-}