use of org.eclipse.swt.SWTException in project dbeaver by serge-rider.
the class ImageEditor method loadImage.
@Override
public boolean loadImage(InputStream inputStream) {
super.loadImage(inputStream);
try {
SWTException lastError = getLastError();
if (lastError != null) {
messageLabel.setText(lastError.getMessage());
messageLabel.setForeground(redColor);
return false;
} else {
messageLabel.setText(getImageDescription());
messageLabel.setForeground(blackColor);
return true;
}
} finally {
updateActions();
}
}
use of org.eclipse.swt.SWTException in project dbeaver by serge-rider.
the class ImageViewCanvas method loadImage.
/**
* Reload image from a file
* @return swt image created from image file
*/
public Image loadImage(InputStream inputStream) {
if (sourceImage != null && !sourceImage.isDisposed()) {
sourceImage.dispose();
sourceImage = null;
imageData = null;
}
this.error = null;
if (inputStream != null) {
try {
imageData = new ImageData(inputStream);
sourceImage = new Image(getDisplay(), imageData);
} catch (SWTException e) {
this.error = e;
}
}
showOriginal();
return sourceImage;
}
use of org.eclipse.swt.SWTException in project ACS by ACS-Community.
the class PopulateEventList method getThreadForEventList.
Thread getThreadForEventList() {
Runnable eventListRunnable = new Runnable() {
public Runnable r = new Runnable() {
private long totalNumberDrained;
public void run() {
//final Display display = viewer.getControl().getDisplay();
if (!display.isDisposed()) {
ArrayList c = new ArrayList(QUEUE_DRAIN_LIMIT);
int numberDrained = queue.drainTo(c, QUEUE_DRAIN_LIMIT);
if (numberDrained == 0)
return;
totalNumberDrained += numberDrained;
synchronized (this) {
// TODO -- figure out why this doesn't work; need same lock on display everywhere?
if (!display.isDisposed())
viewer.add(c.toArray());
}
if (cycles++ % CHECK_MEMORY_FREQUENCY == 0) {
StopWatch sw = new StopWatch(logger);
freeMemoryIfNecessary();
sw.logLapTime("Check free memory");
logger.fine("Total rows processed so far: " + totalNumberDrained);
String rateStr;
if (threadName.equals("NC Events"))
rateStr = String.format("Average event rate from all subscribed channels: %.2f events/s", EventData.getAverageRate());
else
rateStr = String.format("Average archiving rate: %.2f monitor points/s", ArchiveEventData.getAverageRate());
statusLineWriter.setMessage(rateStr);
}
}
}
};
public void run() {
while (!Thread.currentThread().isInterrupted()) {
if (display.isDisposed())
return;
try {
display.syncExec(r);
//display.asyncExec(r);
Thread.sleep(1000);
// System.out.println("Event list iteration " + ++i);
// System.out.println("Queue has "
// + Application.equeue.remainingCapacity()
// + " slots left.");
} catch (InterruptedException e) {
// TODO: Change thread model, as this happens at shutdown
System.out.println("Event monitoring was interrupted!");
break;
// Application.setMonitoring(false);
// startMonitoringAction.setEnabled(true);
} catch (SWTException e) {
// eat it
break;
}
}
// Application.setMonitoring(false);
// startMonitoringAction.setEnabled(true);
}
};
final Thread th = new Thread(eventListRunnable, threadName);
return th;
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_addLorg_eclipse_swt_graphics_Rectangle.
@Test
public void test_addLorg_eclipse_swt_graphics_Rectangle() {
Region reg = new Region(display);
// add a rectangle
reg.add(new Rectangle(0, 0, 100, 50));
// add a second rectangle
reg.add(new Rectangle(200, 200, 10, 10));
try {
reg.add((Rectangle) null);
fail("no exception thrown for adding a null rectangle");
} catch (IllegalArgumentException e) {
}
reg.dispose();
try {
reg.add(new Rectangle(20, 30, 10, 5));
fail("no exception thrown for adding a rectangle after Region got disposed");
} catch (SWTException e) {
}
}
use of org.eclipse.swt.SWTException in project eclipse.platform.swt by eclipse.
the class Test_org_eclipse_swt_graphics_Region method test_addLorg_eclipse_swt_graphics_Region.
@Test
public void test_addLorg_eclipse_swt_graphics_Region() {
Region reg1 = new Region(display);
// make a second region and add it to the first one
Region reg2 = new Region(display);
reg2.add(new Rectangle(40, 50, 10, 20));
reg1.add(reg2);
reg2.dispose();
try {
reg1.add((Region) null);
fail("no exception thrown for adding a null region");
} catch (IllegalArgumentException e) {
}
try {
reg2 = new Region(display);
reg2.add(new Rectangle(1, 1, 100, 200));
reg2.dispose();
reg1.add(reg2);
fail("no exception thrown for adding to a Region a Region which got disposed");
} catch (IllegalArgumentException e) {
}
reg1.dispose();
try {
reg2 = new Region(display);
reg2.add(new Rectangle(1, 1, 100, 200));
reg1.add(reg2);
fail("no exception thrown for adding a Region to a Region which got disposed");
} catch (SWTException e) {
} finally {
if (reg2 != null)
reg2.dispose();
}
}
Aggregations