Search in sources :

Example 6 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project pentaho-kettle by pentaho.

the class Sleak method main.

public static void main(String[] args) {
    DeviceData data = new DeviceData();
    data.tracking = true;
    Display display = new Display(data);
    Sleak sleak = new Sleak();
    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();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) DeviceData(org.eclipse.swt.graphics.DeviceData) Point(org.eclipse.swt.graphics.Point) Display(org.eclipse.swt.widgets.Display)

Example 7 with DeviceData

use of org.eclipse.swt.graphics.DeviceData in project netxms by netxms.

the class Sleak method refreshDifference.

void refreshDifference() {
    final DeviceData info = display.getDeviceData();
    if (!info.tracking) {
        final MessageBox dialog = new MessageBox(shell, SWT.ICON_WARNING | SWT.OK);
        dialog.setText(shell.getText());
        // $NON-NLS-1$
        dialog.setMessage("Warning: Device is not tracking resource allocation");
        dialog.open();
    }
    final Object[] newObjects = info.objects;
    final Error[] newErrors = info.errors;
    final Object[] diffObjects = new Object[newObjects.length];
    final Error[] diffErrors = new Error[newErrors.length];
    int count = 0;
    for (int i = 0; i < newObjects.length; i++) {
        int index = 0;
        while (index < oldObjects.length) {
            if (newObjects[i] == oldObjects[index]) {
                break;
            }
            index++;
        }
        if (index == oldObjects.length) {
            diffObjects[count] = newObjects[i];
            diffErrors[count] = newErrors[i];
            count++;
        }
    }
    objects = new Object[count];
    errors = new Error[count];
    System.arraycopy(diffObjects, 0, objects, 0, count);
    System.arraycopy(diffErrors, 0, errors, 0, count);
    list.removeAll();
    // $NON-NLS-1$
    text.setText("");
    canvas.redraw();
    if (traceFileName != null) {
        writeTraceFile(count);
    }
    for (final Object object : objects) {
        list.add(objectName(object));
    }
    refreshLabel();
    layout();
}
Also used : DeviceData(org.eclipse.swt.graphics.DeviceData) Point(org.eclipse.swt.graphics.Point) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

DeviceData (org.eclipse.swt.graphics.DeviceData)7 Display (org.eclipse.swt.widgets.Display)5 Point (org.eclipse.swt.graphics.Point)3 Shell (org.eclipse.swt.widgets.Shell)3 MessageBox (org.eclipse.swt.widgets.MessageBox)2 Test (org.junit.Test)2 FileOutputStream (java.io.FileOutputStream)1 PrintStream (java.io.PrintStream)1 MalformedURLException (java.net.MalformedURLException)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 ExecutorService (java.util.concurrent.ExecutorService)1 MetalLookAndFeel (javax.swing.plaf.metal.MetalLookAndFeel)1 TeeOutputStream (org.apache.commons.io.output.TeeOutputStream)1 FileSystemException (org.apache.commons.vfs2.FileSystemException)1 SWTException (org.eclipse.swt.SWTException)1 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleFileException (org.pentaho.di.core.exception.KettleFileException)1 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)1