Author: scabanovich
Date: 2011-11-23 17:59:16 -0500 (Wed, 23 Nov 2011)
New Revision: 36588
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ErrorMode.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/DefaultFormContainer.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/SplitFormContainer.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XModelObjectEditor.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/DefaultSettings.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/IWidgetSettings.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/WhiteSettings.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/DefaultSpecialWizardDialog.java
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/ProgressPart.java
Log:
JBIDE-10225
https://issues.jboss.org/browse/JBIDE-10225
Cursor & Color leak prevented.
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ErrorMode.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ErrorMode.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/ErrorMode.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -214,14 +214,16 @@
}
class L extends Canvas implements PaintListener, MouseMoveListener {
- Cursor DEF_CURSOR = new Cursor(null, SWT.CURSOR_ARROW);
- Cursor HAND_CURSOR = new Cursor(null, SWT.CURSOR_HAND);
+ Cursor DEF_CURSOR;
+ Cursor HAND_CURSOR;
private String[] messages = new String[]{"", "", ""};
//$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
public L(Composite parent, int style) {
super (parent, style);
addPaintListener(this);
addMouseMoveListener(this);
+ DEF_CURSOR = getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW);
+ HAND_CURSOR = getShell().getDisplay().getSystemCursor(SWT.CURSOR_HAND);
}
public void setData(String[] messages) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/editor/form/SampleErrorForm.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -251,14 +251,14 @@
}
class ML extends MouseAdapter implements MouseMoveListener {
- Cursor hand = new Cursor(null, SWT.CURSOR_HAND);
- Cursor arrow = new Cursor(null, SWT.CURSOR_ARROW);
+ Cursor hand = null;
+ Cursor arrow = null;
public void mouseMove(MouseEvent e) {
StyleRange range = getRange(e);
if(range != null && range.foreground == BLUE) {
- styledText.setCursor(hand);
+ styledText.setCursor(styledText.getShell().getDisplay().getSystemCursor(SWT.CURSOR_HAND));
} else {
- styledText.setCursor(arrow);
+ styledText.setCursor(styledText.getShell().getDisplay().getSystemCursor(SWT.CURSOR_ARROW));
}
}
public void mouseUp(MouseEvent e) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/attribute/editor/ExtendedFieldEditor.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -139,7 +139,16 @@
}
return labelComposite;
}
-
+
+ Color foreground = null;
+
+ Color getForeground() {
+ if(foreground == null || foreground.isDisposed()) {
+ foreground = new Color(null, 10, 36, 106);
+ }
+ return foreground;
+ }
+
protected Label createLabelControl(Composite parent) {
if (getLabelControl() == null) { // cannot comment this! for details see
label.addDisposeListener
int style = getSettings().getStyle("Label.Style"); //$NON-NLS-1$
@@ -154,7 +163,7 @@
/// label.setBackground(bg);
label.setForeground(fg);
if(settings instanceof WhiteSettings) {
- label.setForeground(new Color(null, 10, 36, 106));
+ label.setForeground(getForeground());
label.setBackground(Display.getDefault().getSystemColor(SWT.COLOR_WHITE));
}
@@ -183,6 +192,10 @@
label = null;
setPropertyChangeListener(null);
setPage(null);
+ if(foreground != null && !foreground.isDisposed()) {
+ foreground.dispose();
+ foreground = null;
+ }
}
public void load() {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/DefaultFormContainer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/DefaultFormContainer.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/DefaultFormContainer.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -39,7 +39,6 @@
composite = new Composite(parent, SWT.NONE);
settings.setupControl(composite);
- //composite.setBackground(new Color(null, 255, 0 ,0));
composite.setLayout(getLayout());
composite.setLayoutData(getLayoutData());
// create client area
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/SplitFormContainer.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/SplitFormContainer.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/forms/SplitFormContainer.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -116,8 +116,6 @@
gd = new GridData(GridData.FILL_BOTH);
secondFormControl.setLayoutData(gd);
-
- //composite.setBackground(new Color(null, 255,255,255));
composite.setWeights(new int[]{30, 70});
composite.setLayoutData(new GridData(GridData.FILL_BOTH));
control = main;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/ExtendedPropertiesEditor.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -14,16 +14,19 @@
import org.eclipse.jface.viewers.CellEditor;
import org.eclipse.jface.viewers.ICellModifier;
import org.eclipse.jface.viewers.TextCellEditor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.TableItem;
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class ExtendedPropertiesEditor {
- static Color DEFAULT_COLOR = new Color(null, 0, 0, 0);
- static Color DISABLED_COLOR = new Color(null, 127, 127, 127);
+ static Color DEFAULT_COLOR = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
+ static Color DISABLED_COLOR = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
+
static Image EMPTY = EclipseResourceUtil.getImage("images/actions/empty.gif");
//$NON-NLS-1$
protected XTable xtable = new XTable();
protected ExtendedProperties attributes;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XChildrenEditor.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -25,6 +25,7 @@
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Widget;
import org.jboss.tools.common.editor.AbstractSelectionProvider;
import org.jboss.tools.common.meta.action.XActionInvoker;
@@ -38,8 +39,8 @@
import org.jboss.tools.common.model.util.AbstractTableHelper;
public class XChildrenEditor implements CommandBarListener {
- protected static Color DEFAULT_COLOR = new Color(null, 0, 0, 0);
- protected static Color GREYED_COLOR = new Color(null, 127, 127, 127);
+ protected static Color DEFAULT_COLOR =
Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
+ protected static Color GREYED_COLOR =
Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
public static String ADD = Messages.XChildrenEditor_Add;
public static String DELETE = Messages.XChildrenEditor_Delete;
public static String EDIT = Messages.XChildrenEditor_Edit;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XModelObjectEditor.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XModelObjectEditor.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/objecteditor/XModelObjectEditor.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -12,10 +12,12 @@
import java.util.ArrayList;
import org.eclipse.jface.viewers.CellEditor;
+import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.jboss.tools.common.meta.XAttribute;
import org.jboss.tools.common.meta.constraint.impl.XAttributeConstraintAList;
import org.jboss.tools.common.meta.key.WizardKeys;
@@ -23,8 +25,8 @@
import org.jboss.tools.common.model.util.EclipseResourceUtil;
public class XModelObjectEditor {
- static Color DEFAULT_COLOR = new Color(null, 0, 0, 0);
- static Color DISABLED_COLOR = new Color(null, 127, 127, 127);
+ static Color DEFAULT_COLOR = Display.getDefault().getSystemColor(SWT.COLOR_BLACK);
+ static Color DISABLED_COLOR = Display.getDefault().getSystemColor(SWT.COLOR_GRAY);
static Image EMPTY = EclipseResourceUtil.getImage("images/actions/empty.gif");
//$NON-NLS-1$
protected XTable xtable = new XTable();
protected XModelObject object = null;
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/DefaultSettings.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/DefaultSettings.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/DefaultSettings.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -287,4 +287,6 @@
return null;
}
+ public void dispose() {}
+
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/IWidgetSettings.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/IWidgetSettings.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/IWidgetSettings.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -31,4 +31,6 @@
public void setupControl(Control control);
public FormToolkit getToolkit(Display display);
+
+ public void dispose();
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/TextAndReferenceComponent.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -52,7 +52,7 @@
public void mouseMove(MouseEvent e) {
int c = (overReference(e.x, e.y)) ? SWT.CURSOR_HAND : SWT.CURSOR_ARROW;
- setCursor(new Cursor(Display.getCurrent(), c));
+ setCursor(getShell().getDisplay().getSystemCursor(c));
}
private boolean overReference(int x, int y) {
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/WhiteSettings.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/WhiteSettings.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/widgets/WhiteSettings.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -51,7 +51,11 @@
protected void initCursors() {
super.initCursors();
- handCursor = new Cursor(Display.getCurrent(), SWT.CURSOR_HAND);
+ Display display = Display.getCurrent();
+ if(display == null) {
+ display = Display.getDefault();
+ }
+ handCursor = display.getSystemCursor(SWT.CURSOR_HAND);
}
protected void initFonts() {
@@ -103,7 +107,12 @@
}
return toolkit;
}
+
+ public void dispose() {
+ defaultBackground.dispose();
+ listBorderColor.dispose();
+ separatorColor.dispose();
+ }
-
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/DefaultSpecialWizardDialog.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/DefaultSpecialWizardDialog.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/DefaultSpecialWizardDialog.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -59,7 +59,6 @@
public void updateDialogArea() {
stepPage = createPage((Composite)pageArea);
- //stepPage.setBackground(new Color(null,128,255,255));
Point size = stepPage.computeSize(SWT.DEFAULT, SWT.DEFAULT);
size.x = Math.max(size.x,pageWidth);
size.y = Math.max(size.y,pageHeight);
@@ -92,7 +91,6 @@
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
dialogArea.setLayout(gridLayout);
- //composite.setBackground(new Color(null, 255,0,255));
// Build the separator line
Label dialogAreaSeparator = new Label(dialogArea, SWT.HORIZONTAL | SWT.SEPARATOR);
@@ -120,7 +118,6 @@
gridLayout.horizontalSpacing = 0;
gridLayout.verticalSpacing = 0;
composite.setLayout(gridLayout);
- //composite.setBackground(new Color(null, 0,255,255));
GridData gd = new GridData(GridData.FILL_HORIZONTAL);
//gd.heightHint = commandBarHeight;
composite.setLayoutData(gd);
@@ -146,7 +143,6 @@
gd = new GridData(GridData.FILL_BOTH);
gd.heightHint = commandBar.getControl().computeSize(SWT.DEFAULT, SWT.DEFAULT).y;
control.setLayoutData(gd);
- //control.setBackground(new Color(null, 0,0,255));
return composite;
}
Modified:
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/ProgressPart.java
===================================================================
---
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/ProgressPart.java 2011-11-23
22:34:15 UTC (rev 36587)
+++
trunk/common/plugins/org.jboss.tools.common.model.ui/src/org/jboss/tools/common/model/ui/wizards/special/ProgressPart.java 2011-11-23
22:59:16 UTC (rev 36588)
@@ -65,9 +65,9 @@
}
private void setWaitCursor() {
Display d = getShell().getDisplay();
- waitCursor = new Cursor(d, SWT.CURSOR_WAIT);
+ waitCursor = d.getSystemCursor(SWT.CURSOR_WAIT);
setDisplayCursor(waitCursor);
- arrowCursor = new Cursor(d, SWT.CURSOR_ARROW);
+ arrowCursor = d.getSystemCursor(SWT.CURSOR_ARROW);
}
private void saveFocus(Map<Object,Object> state, Control focusControl) {
if (focusControl != null) {