本文整理匯總了Java中org.eclipse.swt.SWTException類的典型用法代碼示例。如果您正苦於以下問題:Java SWTException類的具體用法?Java SWTException怎麽用?Java SWTException使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
SWTException類屬於org.eclipse.swt包,在下文中一共展示了SWTException類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: close
import org.eclipse.swt.SWTException; //導入依賴的package包/類
@Override
public boolean close(boolean forceClose) {
// triggerCloseListener
if (!super.close(forceClose)) {
return false;
}
Utils.execSWTThread(new SWTRunnable() {
@Override
public void runWithDisplay(Display display) {
if (swtItem != null && !swtItem.isDisposed()) {
// this will triggerCloseListeners
try {
swtItem.dispose();
}catch( SWTException e ){
// getting internal 'Widget it disposed' here, ignore
}
swtItem = null;
}
}
});
return true;
}
示例2: isThisThreadSWT
import org.eclipse.swt.SWTException; //導入依賴的package包/類
public static boolean isThisThreadSWT() {
SWTThread swt = SWTThread.getInstance();
if (swt == null) {
//System.err.println("WARNING: SWT Thread not started yet");
}
Display display = (swt == null) ? Display.getCurrent() : swt.getDisplay();
if (display == null) {
return false;
}
// This will throw if we are disposed or on the wrong thread
// Much better that display.getThread() as that one locks Device.class
// and may end up causing sync lock when disposing
try {
display.getWarnings();
} catch (SWTException e) {
return false;
}
return (display.getThread() == Thread.currentThread());
}
示例3: resourceChanged
import org.eclipse.swt.SWTException; //導入依賴的package包/類
public void resourceChanged(IResourceChangeEvent event){
if(event.getType()==IResourceChangeEvent.PRE_CLOSE){
try{
if(event.getResource().getProject().isNatureEnabled(CommonNames.DERBY_NATURE)){
if(getRunning(event.getResource().getProject())){
stopDerbyServer(event.getResource().getProject());
}
}
}catch(SWTException swe){
//The SWTException is thrown during the Shell creation
//Logger.log("Exception shutting down "+swe,IStatus.ERROR);
//e.printStackTrace();
}catch(Exception e){
Logger.log("Exception shutting down "+e,IStatus.ERROR);
}
}
}
示例4: populate
import org.eclipse.swt.SWTException; //導入依賴的package包/類
public void populate(){
CoreContext ctx = CoreContext.getContext();
ProxyItem item = (ProxyItem) ctx.getObject(CoreObjects.PROXY_ITEM);
try {
if (item != null) {
this.proxyItem = item;
hostBox.setText(BaseUtils.noNull(item.getHost()));
portBox.setText("" + item.getPort());
enabledCheck.setSelection(item.isProxy());
} else {
this.proxyItem = new ProxyItem();
}
} catch (SWTException e) {
// dispose exception
ExceptionHandler.handle(e);
}
}
示例5: loadImageData
import org.eclipse.swt.SWTException; //導入依賴的package包/類
private ImageData loadImageData() {
ImageData[] imageDatas;
try {
imageDatas = new ImageLoader().load(new ByteArrayInputStream(favIconBytes));
} catch (SWTException e) {
return null;
}
Optional<ImageData> optionalImageData = Arrays.stream(imageDatas).sorted((imageData1,
imageData2) -> distanceFrom16x16ImageData(imageData1) - distanceFrom16x16ImageData(imageData2))
.findFirst();
if (!optionalImageData.isPresent()) {
return null;
}
ImageData imageData = optionalImageData.get();
if (imageData.width <= 16 && imageData.height <= 16) {
return imageData;
}
return imageData.scaledTo(16, 16);
}
示例6: initializeWorkbench
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Performs some weird initialization steps needed to run the tests.
*
* @param bot
* to work with, must not be {@code null}
*/
public static void initializeWorkbench(final SwtWorkbenchBot bot) {
Assert.isNotNull(bot, ARGUMENT_BOT);
// Move mouse outside client area (to prevent problems with context menus)
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
try {
final Robot robot = new Robot();
robot.mouseMove(MOUSE_POSITION_X, MOUSE_POSITION_Y);
} catch (SWTException | AWTException wte) {
throw new WrappedException("Error during initialisation SWT mouse", wte);
}
}
});
// The welcome page must be closed before resetting the workbench to avoid trashing the UI:
bot.closeWelcomePage();
bot.resetActivePerspective();
}
示例7: modifyModel
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Performs modifications to the Plugin Model.
*
* @param modification
* a modification
* @param monitor
* progress monitor
*/
public void modifyModel(final ModelModification modification, final IProgressMonitor monitor) {
if (monitor.isCanceled()) {
throw new OperationCanceledException();
}
try {
PlatformUI.getWorkbench().getDisplay().syncExec(new Runnable() {
@Override
public void run() {
PDEModelUtility.modifyModel(modification, monitor);
}
});
} catch (SWTException e) {
// If the build was cancelled while in syncExec() it will throw an SWTException
if (monitor.isCanceled()) {
throw new OperationCanceledException();
} else {
throw e;
}
}
}
示例8: catchSWTException
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* This can be used to verify an exception that is thrown on the UI thread.
*
* @param runnable
* The runnable that would normally be sent to
* {@link Display#syncExec(Runnable)}.
* @return The first {@link SWTException} that was thrown, or {@code null}
* if one was not thrown.
*/
protected SWTException catchSWTException(final Runnable runnable) {
// Use an AtomicReference to catch the exception.
final AtomicReference<SWTException> exceptionRef;
exceptionRef = new AtomicReference<SWTException>();
// Run the runnable synchronously, but try to catch the SWTException.
getDisplay().syncExec(new Runnable() {
@Override
public void run() {
try {
runnable.run();
} catch (SWTException e) {
exceptionRef.set(e);
}
}
});
// Return any SWTException that was thrown from the specified runnable.
return exceptionRef.get();
}
示例9: enable
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Enable or disable the ui. Can be called from non ui threads.
* @param enabled
*/
private void enable(final boolean enabled) {
try {
Display d = mParent.getDisplay();
d.asyncExec(new Runnable() {
@Override
public void run() {
if (mParent.isDisposed() == false) {
doEnable(enabled);
}
}
});
} catch (SWTException e) {
// disposed. do nothing
}
}
示例10: processCommandResult
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Processes the result of a command sent to the console.
* @param result the result of the command.
*/
private boolean processCommandResult(final String result) {
if (result != EmulatorConsole.RESULT_OK) {
try {
mParent.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
if (mParent.isDisposed() == false) {
MessageDialog.openError(mParent.getShell(), "Emulator Console",
result);
}
}
});
} catch (SWTException e) {
// we're quitting, just ignore
}
return false;
}
return true;
}
示例11: clientChanged
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Sent when an existing client information changed.
* <p/>
* This is sent from a non UI thread.
* @param client the updated client.
* @param changeMask the bit mask describing the changed properties. It can contain
* any of the following values: {@link Client#CHANGE_INFO}, {@link Client#CHANGE_NAME}
* {@link Client#CHANGE_DEBUGGER_STATUS}, {@link Client#CHANGE_THREAD_MODE},
* {@link Client#CHANGE_THREAD_DATA}, {@link Client#CHANGE_HEAP_MODE},
* {@link Client#CHANGE_HEAP_DATA}, {@link Client#CHANGE_NATIVE_HEAP_DATA}
*
* @see IClientChangeListener#clientChanged(Client, int)
*/
@Override
public void clientChanged(final Client client, int changeMask) {
if (client == getCurrentClient()) {
if ((changeMask & Client.CHANGE_HEAP_MODE) == Client.CHANGE_HEAP_MODE ||
(changeMask & Client.CHANGE_HEAP_DATA) == Client.CHANGE_HEAP_DATA) {
try {
mTop.getDisplay().asyncExec(new Runnable() {
@Override
public void run() {
clientSelected();
}
});
} catch (SWTException e) {
// display is disposed (app is quitting most likely), we do nothing.
}
}
}
}
示例12: openOptionPanel
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Opens the option panel.
* </p>
* <b>This must be called from the UI thread</b>
*/
@UiThread
public void openOptionPanel() {
try {
EventDisplayOptions dialog = new EventDisplayOptions(mParent.getShell());
if (dialog.open(mCurrentEventLogParser, mEventDisplays, mEvents)) {
synchronized (mLock) {
// get the new EventDisplay list
mEventDisplays.clear();
mEventDisplays.addAll(dialog.getEventDisplays());
// since the list of EventDisplay changed, we store it.
saveEventDisplays();
rebuildUi();
}
}
} catch (SWTException e) {
Log.e("EventLog", e); //$NON-NLS-1$
}
}
示例13: resetUI
import org.eclipse.swt.SWTException; //導入依賴的package包/類
private void resetUI(boolean inUiThread) {
mEvents.clear();
// the ui is static we just empty it.
if (inUiThread) {
resetUiFromUiThread();
} else {
try {
Display d = mBottomParentPanel.getDisplay();
// run sync as we need to update right now.
d.syncExec(new Runnable() {
@Override
public void run() {
if (mBottomParentPanel.isDisposed() == false) {
resetUiFromUiThread();
}
}
});
} catch (SWTException e) {
// display is disposed, we're quitting. Do nothing.
}
}
}
示例14: scheduleUIEventHandler
import org.eclipse.swt.SWTException; //導入依賴的package包/類
/**
* Schedules the UI thread to execute a {@link Runnable} calling {@link #displayNewEvents()}.
*/
private void scheduleUIEventHandler() {
try {
Display d = mBottomParentPanel.getDisplay();
d.asyncExec(new Runnable() {
@Override
public void run() {
if (mBottomParentPanel.isDisposed() == false) {
if (mCurrentEventLogParser != null) {
displayNewEvents();
}
}
}
});
} catch (SWTException e) {
// if the ui is disposed, do nothing
}
}
示例15: run
import org.eclipse.swt.SWTException; //導入依賴的package包/類
public void run() {
setBlockOnOpen(true);
try {
open();
} catch (SWTException e) {
// Ignore "widget disposed" errors after we closed.
if (!getShell().isDisposed()) {
throw e;
}
}
TreeViewModel.getModel().removeTreeChangeListener(mTreeChangeListener);
PixelPerfectModel.getModel().removeImageChangeListener(mImageChangeListener);
ImageLoader.dispose();
mDirector.stopListenForDevices();
mDirector.stopDebugBridge();
mDirector.terminate();
}