Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--bundles/org.eclipse.swt.tools/Sleak/org/eclipse/swt/tools/internal/Sleak.java41
-rw-r--r--bundles/org.eclipse.swt.tools/plugin.properties1
-rw-r--r--bundles/org.eclipse.swt.tools/plugin.xml7
-rw-r--r--bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/views/SleakView.java64
4 files changed, 93 insertions, 20 deletions
diff --git a/bundles/org.eclipse.swt.tools/Sleak/org/eclipse/swt/tools/internal/Sleak.java b/bundles/org.eclipse.swt.tools/Sleak/org/eclipse/swt/tools/internal/Sleak.java
index cefe5f59a9..ac1ee2d86a 100644
--- a/bundles/org.eclipse.swt.tools/Sleak/org/eclipse/swt/tools/internal/Sleak.java
+++ b/bundles/org.eclipse.swt.tools/Sleak/org/eclipse/swt/tools/internal/Sleak.java
@@ -23,8 +23,6 @@ import java.io.*;
*
*/
public class Sleak {
- Display display;
- Shell shell;
List list;
Canvas canvas;
Button start, stop, check;
@@ -41,7 +39,12 @@ public static void main (String [] args) {
data.tracking = true;
Display display = new Display (data);
Sleak sleak = new Sleak ();
- sleak.open ();
+ Shell shell = new Shell(display);
+ shell.setText ("S-Leak");
+ Point size = shell.getSize ();
+ shell.setSize (size.x / 2, size.y / 2);
+ sleak.create (shell);
+ shell.open();
// Launch your application here
// e.g.
@@ -55,62 +58,57 @@ public static void main (String [] args) {
// button2.setImage(image);
// shell.open();
- while (!sleak.shell.isDisposed ()) {
+ while (!shell.isDisposed ()) {
if (!display.readAndDispatch ()) display.sleep ();
}
display.dispose ();
}
-public void open () {
- display = Display.getCurrent ();
- shell = new Shell (display);
- shell.setText ("S-Leak");
- list = new List (shell, SWT.BORDER | SWT.V_SCROLL);
+public void create (Composite parent) {
+ list = new List (parent, SWT.BORDER | SWT.V_SCROLL);
list.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
refreshObject ();
}
});
- text = new Text (shell, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
- canvas = new Canvas (shell, SWT.BORDER);
+ text = new Text (parent, SWT.BORDER | SWT.H_SCROLL | SWT.V_SCROLL);
+ canvas = new Canvas (parent, SWT.BORDER);
canvas.addListener (SWT.Paint, new Listener () {
public void handleEvent (Event event) {
paintCanvas (event);
}
});
- check = new Button (shell, SWT.CHECK);
+ check = new Button (parent, SWT.CHECK);
check.setText ("Stack");
check.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event e) {
toggleStackTrace ();
}
});
- start = new Button (shell, SWT.PUSH);
+ start = new Button (parent, SWT.PUSH);
start.setText ("Snap");
start.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
refreshAll ();
}
});
- stop = new Button (shell, SWT.PUSH);
+ stop = new Button (parent, SWT.PUSH);
stop.setText ("Diff");
stop.addListener (SWT.Selection, new Listener () {
public void handleEvent (Event event) {
refreshDifference ();
}
});
- label = new Label (shell, SWT.BORDER);
+ label = new Label (parent, SWT.BORDER);
label.setText ("0 object(s)");
- shell.addListener (SWT.Resize, new Listener () {
+ parent.addListener (SWT.Resize, new Listener () {
public void handleEvent (Event e) {
layout ();
}
});
check.setSelection (false);
text.setVisible (false);
- Point size = shell.getSize ();
- shell.setSize (size.x / 2, size.y / 2);
- shell.open ();
+ layout();
}
void refreshLabel () {
@@ -147,8 +145,10 @@ void refreshLabel () {
}
void refreshDifference () {
+ Display display = canvas.getDisplay();
DeviceData info = display.getDeviceData ();
if (!info.tracking) {
+ Shell shell = canvas.getShell();
MessageBox dialog = new MessageBox (shell, SWT.ICON_WARNING | SWT.OK);
dialog.setText (shell.getText ());
dialog.setMessage ("Warning: Device is not tracking resource allocation");
@@ -292,7 +292,8 @@ void refreshAll () {
}
void layout () {
- Rectangle rect = shell.getClientArea ();
+ Composite parent = canvas.getParent();
+ Rectangle rect = parent.getClientArea ();
int width = 0;
String [] items = list.getItems ();
GC gc = new GC (list);
diff --git a/bundles/org.eclipse.swt.tools/plugin.properties b/bundles/org.eclipse.swt.tools/plugin.properties
index db89eade77..3065bf1b0c 100644
--- a/bundles/org.eclipse.swt.tools/plugin.properties
+++ b/bundles/org.eclipse.swt.tools/plugin.properties
@@ -12,5 +12,6 @@ pluginName = SWT Tools
providerName = Eclipse.org
macViewName = Mac Generator
spyViewName = SWT Spy
+sleakViewName = Sleak
jniBuilderName = JNI Builder
enableCheck64Name = Report 64-bit Problems
diff --git a/bundles/org.eclipse.swt.tools/plugin.xml b/bundles/org.eclipse.swt.tools/plugin.xml
index 05e310ad03..ef0072b5e4 100644
--- a/bundles/org.eclipse.swt.tools/plugin.xml
+++ b/bundles/org.eclipse.swt.tools/plugin.xml
@@ -23,6 +23,13 @@
id="org.eclipse.swt.tools.views.SpyView"
name="%spyViewName">
</view>
+ <view
+ category="org.eclipse.swt.swt.tools"
+ class="org.eclipse.swt.tools.views.SleakView"
+ icon="icons/sleak.gif"
+ id="org.eclipse.swt.tools.views.SleakView"
+ name="%sleakViewName">
+ </view>
</extension>
<extension point="org.eclipse.ui.editors.templates">
diff --git a/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/views/SleakView.java b/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/views/SleakView.java
new file mode 100644
index 0000000000..100c4e43e6
--- /dev/null
+++ b/bundles/org.eclipse.swt.tools/src/org/eclipse/swt/tools/views/SleakView.java
@@ -0,0 +1,64 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2009 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
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.swt.tools.views;
+
+import org.eclipse.swt.*;
+import org.eclipse.swt.tools.internal.*;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.ui.part.*;
+
+/**
+ * This sample class demonstrates how to plug-in a new
+ * workbench view. The view shows data obtained from the
+ * model. The sample creates a dummy model on the fly,
+ * but a real implementation would connect to the model
+ * available either in this or another plug-in (e.g. the workspace).
+ * The view is connected to the model using a content provider.
+ * <p>
+ * The view uses a label provider to define how model
+ * objects should be presented in the view. Each
+ * view can present the same model objects using
+ * different labels and icons, if needed. Alternatively,
+ * a single label provider can be shared between views
+ * in order to ensure that objects of the same type are
+ * presented in the same way everywhere.
+ * <p>
+ */
+
+public class SleakView extends ViewPart {
+
+ Composite parent = null;
+ Sleak sleak = null;
+
+ /**
+ * The constructor.
+ */
+ public SleakView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ this.parent = new Composite(parent, SWT.NONE);
+ sleak = new Sleak ();
+ sleak.create(this.parent);
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ parent.setFocus();
+ }
+
+} \ No newline at end of file

Back to the top