List of usage examples for java.awt EventQueue isDispatchThread
public static boolean isDispatchThread()
From source file:org.parosproxy.paros.view.SiteMapPanel.java
public void expandRoot() { TreeNode root = (TreeNode) treeSite.getModel().getRoot(); if (rootTreePath == null || root != rootTreePath.getPathComponent(0)) { rootTreePath = new TreePath(root); }/*from w w w . j a v a 2 s . c o m*/ if (EventQueue.isDispatchThread()) { getTreeSite().expandPath(rootTreePath); return; } try { EventQueue.invokeLater(new Runnable() { public void run() { getTreeSite().expandPath(rootTreePath); } }); } catch (Exception e) { log.warn(e.getMessage(), e); } }
From source file:org.ut.biolab.medsavant.shared.util.MiscUtils.java
/** * Invoke the given runnable on the AWT event thread. * * @param r the action to be invoked/* w w w . j ava 2 s .c o m*/ */ public static void invokeLaterIfNecessary(Runnable r) { if (EventQueue.isDispatchThread()) { r.run(); } else { EventQueue.invokeLater(r); } }
From source file:org.zaproxy.zap.extension.ascan.ExtensionActiveScan.java
@Override public void sessionChanged(final Session session) { if (EventQueue.isDispatchThread()) { sessionChangedEventHandler(session); } else {//www. ja v a2 s .c o m try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { sessionChangedEventHandler(session); } }); } catch (InterruptedException | InvocationTargetException e) { logger.error(e.getMessage(), e); } } }
From source file:org.zaproxy.zap.extension.autoupdate.ExtensionAutoUpdate.java
boolean uninstallAddOnsWithView(final Window caller, final Set<AddOn> addOns, final boolean updates, final Set<AddOn> failedUninstallations) { if (addOns == null || addOns.isEmpty()) { return true; }//from w w w . j a v a 2 s . c o m if (!EventQueue.isDispatchThread()) { try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { uninstallAddOnsWithView(caller, addOns, updates, failedUninstallations); } }); } catch (InvocationTargetException | InterruptedException e) { logger.error("Failed to uninstall add-ons:", e); return false; } return failedUninstallations.isEmpty(); } final Window parent = getWindowParent(caller); final UninstallationProgressDialogue waitDialogue = new UninstallationProgressDialogue(parent, addOns); waitDialogue.addAddOnUninstallListener(new AddOnUninstallListener() { @Override public void uninstallingAddOn(AddOn addOn, boolean updating) { if (updating) { String message = MessageFormat.format( Constant.messages.getString("cfu.output.replacing") + "\n", addOn.getName(), Integer.valueOf(addOn.getFileVersion())); getView().getOutputPanel().append(message); } } @Override public void addOnUninstalled(AddOn addOn, boolean update, boolean uninstalled) { if (uninstalled) { if (!update && addonsDialog != null) { addonsDialog.notifyAddOnUninstalled(addOn); } String message = MessageFormat.format( Constant.messages.getString("cfu.output.uninstalled") + "\n", addOn.getName(), Integer.valueOf(addOn.getFileVersion())); getView().getOutputPanel().append(message); } else { if (addonsDialog != null) { addonsDialog.notifyAddOnFailedUninstallation(addOn); } String message; if (update) { message = MessageFormat.format( Constant.messages.getString("cfu.output.replace.failed") + "\n", addOn.getName(), Integer.valueOf(addOn.getFileVersion())); } else { message = MessageFormat.format( Constant.messages.getString("cfu.output.uninstall.failed") + "\n", addOn.getName(), Integer.valueOf(addOn.getFileVersion())); } getView().getOutputPanel().append(message); } } }); SwingWorker<Void, UninstallationProgressEvent> a = new SwingWorker<Void, UninstallationProgressEvent>() { @Override protected void process(List<UninstallationProgressEvent> events) { waitDialogue.update(events); } @Override protected Void doInBackground() { UninstallationProgressHandler progressHandler = new UninstallationProgressHandler() { @Override protected void publishEvent(UninstallationProgressEvent event) { publish(event); } }; for (AddOn addOn : addOns) { if (!uninstall(addOn, updates, progressHandler)) { failedUninstallations.add(addOn); } } if (!failedUninstallations.isEmpty()) { logger.warn("Not all add-ons were successfully uninstalled: " + failedUninstallations); } return null; } }; waitDialogue.bind(a); a.execute(); waitDialogue.setSynchronous(updates); waitDialogue.setVisible(true); return failedUninstallations.isEmpty(); }
From source file:org.zaproxy.zap.extension.brk.ProxyListenerBreak.java
private void clearAndDisableRequest() { if (EventQueue.isDispatchThread()) { getBreakPanel().clearAndDisableRequest(); } else {//from www . j a v a 2 s. c om try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { getBreakPanel().clearAndDisableRequest(); } }); } catch (Exception e) { log.warn(e.getMessage(), e); } } }
From source file:org.zaproxy.zap.extension.brk.ProxyListenerBreak.java
private void clearAndDisableResponse() { if (EventQueue.isDispatchThread()) { getBreakPanel().clearAndDisableResponse(); } else {//from ww w .j a v a 2 s .c o m try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { getBreakPanel().clearAndDisableResponse(); } }); } catch (Exception e) { log.warn(e.getMessage(), e); } } }
From source file:org.zaproxy.zap.extension.compare.ExtensionCompare.java
@Override public void sessionChanged(final Session session) { if (EventQueue.isDispatchThread()) { sessionChangedEventHandler(session); } else {//w w w . j a va2s . c o m try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { sessionChangedEventHandler(session); } }); } catch (Exception e) { log.warn(e.getMessage(), e); } } }
From source file:org.zaproxy.zap.extension.customFire.ExtensionCustomFire.java
@Override public void sessionChanged(final Session session) { if (EventQueue.isDispatchThread()) { sessionChangedEventHandler(session); } else {/*from ww w. j av a2s. c o m*/ try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { sessionChangedEventHandler(session); } }); } catch (InterruptedException | InvocationTargetException e) { //logger.error(e.getMessage(), e); e.printStackTrace(); } } }
From source file:org.zaproxy.zap.extension.fuzz.httpfuzzer.ui.HttpFuzzResultsContentPanel.java
@Override public void clear() { if (!EventQueue.isDispatchThread()) { try {/* w w w.ja v a 2s .c o m*/ EventQueue.invokeAndWait(new Runnable() { @Override public void run() { clear(); } }); } catch (Exception e) { logger.error(e.getMessage(), e); } return; } currentFuzzer = null; fuzzResultTable.setModel(EMPTY_RESULTS_MODEL); errorsTable.setModel(EMPTY_ERRORS_MODEL); }
From source file:org.zaproxy.zap.extension.multiFuzz.impl.http.HttpFuzzerContentPanel.java
private void addFuzzResult(final String name, final String custom, final HttpFuzzRequestRecord.State state, final ArrayList<String> pay, final HttpMessage msg) { if (EventQueue.isDispatchThread()) { addFuzzResultToView(name, custom, state, pay, msg); return;/*from w w w . j av a 2 s. co m*/ } try { EventQueue.invokeLater(new Runnable() { @Override public void run() { addFuzzResultToView(name, custom, state, pay, msg); } }); } catch (Exception e) { logger.error(e.getMessage(), e); } }