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; }
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(); }