org.eclipse.swt.graphics.DeviceData Java Examples

The following examples show how to use org.eclipse.swt.graphics.DeviceData. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Sleak.java    From AppleCommander with GNU General Public License v2.0 6 votes vote down vote up
public static void main (String [] args) {
	DeviceData data = new DeviceData();
	data.tracking = true;
	Display display = new Display (data);
	Sleak sleak = new Sleak ();
	sleak.open ();

	// Launch your application here
	SwtAppleCommander ac = new SwtAppleCommander();
	ac.launch(display);
	// End of AC code...	
	
	while (!sleak.shell.isDisposed ()) {
		if (!display.readAndDispatch ()) display.sleep ();
	}
	display.dispose ();
}
 
Example #2
Source File: Sleak.java    From hop with Apache License 2.0 5 votes vote down vote up
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();

  // Launch your application here
  // e.g.
  // Shell shell = new Shell(display);
  // Button button1 = new Button(shell, SWT.PUSH);
  // button1.setBounds(10, 10, 100, 50);
  // button1.setText("Hello World");
  // Image image = new Image(display, 20, 20);
  // Button button2 = new Button(shell, SWT.PUSH);
  // button2.setBounds(10, 70, 100, 50);
  // button2.setImage(image);
  // shell.open();

  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
  display.dispose();
}
 
Example #3
Source File: Sleak.java    From AppleCommander with GNU General Public License v2.0 5 votes vote down vote up
void refreshDifference () {
	DeviceData info = display.getDeviceData ();
	if (!info.tracking) {
		MessageBox dialog = new MessageBox (shell, SWT.ICON_WARNING | SWT.OK);
		dialog.setText (shell.getText ());
		dialog.setMessage ("Warning: Device is not tracking resource allocation"); //$NON-NLS-1$
		dialog.open ();
	}
	Object [] newObjects = info.objects;
	Error [] newErrors = info.errors;
	Object [] diffObjects = new Object [newObjects.length];
	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 ();
	text.setText (""); //$NON-NLS-1$
	canvas.redraw ();
	for (int i=0; i<objects.length; i++) {
		list.add (objectName (objects [i]));
	}
	refreshLabel ();
	layout ();
}
 
Example #4
Source File: Sleak.java    From pentaho-kettle with Apache License 2.0 5 votes vote down vote up
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();

  // Launch your application here
  // e.g.
  // Shell shell = new Shell(display);
  // Button button1 = new Button(shell, SWT.PUSH);
  // button1.setBounds(10, 10, 100, 50);
  // button1.setText("Hello World");
  // Image image = new Image(display, 20, 20);
  // Button button2 = new Button(shell, SWT.PUSH);
  // button2.setBounds(10, 70, 100, 50);
  // button2.setImage(image);
  // shell.open();

  while ( !shell.isDisposed() ) {
    if ( !display.readAndDispatch() ) {
      display.sleep();
    }
  }
  display.dispose();
}
 
Example #5
Source File: FontFactoryTest.java    From swt-bling with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
  if (Display.getCurrent() != null) Display.getCurrent().dispose();
  DeviceData data = new DeviceData();
  data.tracking = true;
  display = new Display(data);
  shell = new Shell(display);
}
 
Example #6
Source File: ColorFactoryTest.java    From swt-bling with MIT License 5 votes vote down vote up
@Before
public void setup() throws Exception {
  if (Display.getCurrent() != null) Display.getCurrent().dispose();
  DeviceData data = new DeviceData();
  data.tracking = true;
  display = new Display(data);
  shell = new Shell(display);
}
 
Example #7
Source File: Sleak.java    From swt-bling with MIT License 5 votes vote down vote up
void refreshDifference () {
  DeviceData info = display.getDeviceData ();
  if (!info.tracking) {
    MessageBox dialog = new MessageBox (shell, SWT.ICON_WARNING | SWT.OK);
    dialog.setText (shell.getText ());
    dialog.setMessage ("Warning: Device is not tracking resource allocation");
    dialog.open ();
  }
  Object [] newObjects = info.objects;
  Error [] newErrors = info.errors;
  Object [] diffObjects = new Object [newObjects.length];
  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 ();
  text.setText ("");
  canvas.redraw ();
  for (int i=0; i<objects.length; i++) {
    list.add (objectName (objects [i]));
  }
  refreshLabel ();
  layout ();
}
 
Example #8
Source File: ResourceQuery.java    From swt-bling with MIT License 5 votes vote down vote up
public static Map<String, Integer> getAllocatedResourceCounts(final Display display) {
  HashMap<String, Integer> results = new HashMap<String, Integer>();
  DeviceData data = display.getDeviceData();
  for (Object object : data.objects) {
    String name = object.getClass().getCanonicalName();
    Integer count = results.get(name);
    if (count == null) {
      count = 0;
    }
    int c = count.intValue();
    c++;
    results.put(name, c);
  }
  return results;
}
 
Example #9
Source File: Sleak.java    From hop with Apache License 2.0 4 votes vote down vote up
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" );
    dialog.open();
  }
  Object[] newObjects = info.objects;
  Error[] newErrors = info.errors;
  Object[] diffObjects = new Object[ newObjects.length ];
  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();
  text.setText( "" );
  canvas.redraw();
  for ( int i = 0; i < objects.length; i++ ) {
    list.add( objects[ i ].toString() );
  }
  refreshLabel();
  layout();
}
 
Example #10
Source File: Sleak.java    From pentaho-kettle with Apache License 2.0 4 votes vote down vote up
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" );
    dialog.open();
  }
  Object[] newObjects = info.objects;
  Error[] newErrors = info.errors;
  Object[] diffObjects = new Object[newObjects.length];
  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();
  text.setText( "" );
  canvas.redraw();
  for ( int i = 0; i < objects.length; i++ ) {
    list.add( objects[i].toString() );
  }
  refreshLabel();
  layout();
}
 
Example #11
Source File: ResourceQueryTest.java    From swt-bling with MIT License 4 votes vote down vote up
@Before
public void setUp() throws Exception {
  DeviceData data = new DeviceData();
  data.tracking = true;
  display = new Display(data);
}