List of usage examples for java.awt EventQueue isDispatchThread
public static boolean isDispatchThread()
From source file:net.landora.video.utils.UIUtils.java
public static void invokeInSwingThread(Runnable r) { if (EventQueue.isDispatchThread()) { r.run();/*from w w w . jav a 2 s .c om*/ } else { try { SwingUtilities.invokeAndWait(r); } catch (Exception ex) { throw new RuntimeException(ex); } } }
From source file:iqq.app.core.service.impl.EventServiceImpl.java
@Override public void broadcast(final UIEvent event) { if (EventQueue.isDispatchThread()) { doBroadcast(event);/*from ww w. j a v a2 s .co m*/ } else { EventQueue.invokeLater(new Runnable() { public void run() { doBroadcast(event); } }); } }
From source file:Main.java
/** * @return true if the current thread is an AWT event dispatching thread. *//*from w w w . j a va 2s . co m*/ public static boolean isEventDispatchThread() { return EventQueue.isDispatchThread(); }
From source file:Main.java
/** * Returns true if e has the permissions to * access the system clipboard and if it is allowed gesture (if * checkGesture is true)//w w w .j ava2s . c o m * * @param e AWTEvent to check * @param checkGesture boolean */ private static boolean canEventAccessSystemClipboard(AWTEvent e, boolean checkGesture) { if (EventQueue.isDispatchThread()) { /* * Checking event permissions makes sense only for event * dispathing thread */ if (e instanceof InputEvent && (!checkGesture || isAccessClipboardGesture((InputEvent) e))) { return inputEvent_canAccessSystemClipboard((InputEvent) e); } else { return false; } } else { return true; } }
From source file:org.moeaframework.examples.gp.regression.SymbolicRegressionGUI.java
/** * Updates the GUI with a new intermediate solution. * /* w w w . j a v a2 s. com*/ * @param solution the new solution * @param generation the current generation count * @param maxGenerations the maximum generations being run */ public void update(Solution solution, int generation, int maxGenerations) { this.solution = solution; this.generation = generation; this.maxGenerations = maxGenerations; if (EventQueue.isDispatchThread()) { updateOnEventQueue(); } else { EventQueue.invokeLater(new Runnable() { @Override public void run() { updateOnEventQueue(); } }); } }
From source file:org.coding.git.api.CodingNetConnection.java
@NotNull private ResponsePage doRequest(@NotNull String uri, @Nullable String requestBody, @NotNull Collection<Header> headers, @NotNull HttpVerb verb) throws IOException { if (myAborted) throw new CodingNetOperationCanceledException(); if (EventQueue.isDispatchThread() && !ApplicationManager.getApplication().isUnitTestMode()) { LOG.warn("Network operation in EDT"); // TODO: fix }/*from www . j a v a 2 s. c o m*/ CloseableHttpResponse response = null; try { response = doREST(uri, requestBody, headers, verb); if (myAborted) throw new CodingNetOperationCanceledException(); //--HTTP?? checkStatusCode(response, requestBody); HttpEntity entity = response.getEntity(); if (entity == null) { return createResponse(response); } JsonElement ret = parseResponse(entity.getContent()); if (ret.isJsonNull()) { return createResponse(response); } //--CodingNet?? checkCodingNetCode(ret); String nextPage = null; Header pageHeader = response.getFirstHeader("Link"); if (pageHeader != null) { for (HeaderElement element : pageHeader.getElements()) { NameValuePair rel = element.getParameterByName("rel"); if (rel != null && "next".equals(rel.getValue())) { String urlString = element.toString(); int begin = urlString.indexOf('<'); int end = urlString.lastIndexOf('>'); if (begin == -1 || end == -1) { LOG.error("Invalid 'Link' header", "{" + pageHeader.toString() + "}"); break; } nextPage = urlString.substring(begin + 1, end); break; } } } return createResponse(ret, nextPage, response); } catch (SSLHandshakeException e) { // User canceled operation from CertificateManager if (e.getCause() instanceof CertificateException) { LOG.info("Host SSL certificate is not trusted", e); throw new CodingNetOperationCanceledException("Host SSL certificate is not trusted", e); } throw e; } catch (IOException e) { if (myAborted) throw new CodingNetOperationCanceledException("Operation canceled", e); throw e; } finally { myRequest = null; if (response != null) { response.close(); } if (!myReusable) { myClient.close(); } } }
From source file:com.kenai.redminenb.query.RedmineQueryController.java
public void selectFilter(final Filter filter) { if (filter != null) { // XXX this part should be handled in the issues table - move the filtercombo and the label over int c = 0; for (RedmineIssue issue : query.getIssues()) { if (filter.accept(issue.getNode())) { c++;// w w w.ja v a 2 s.co m } } final int issueCount = c; Runnable r = new Runnable() { @Override public void run() { queryPanel.filterComboBox.setSelectedItem(filter); setIssueCount(issueCount); } }; if (EventQueue.isDispatchThread()) { r.run(); } else { EventQueue.invokeLater(r); } } issueTable.setFilter(filter); }
From source file:io.github.moosbusch.lumpi.util.LumpiUtil.java
public static boolean isEDT() { return EventQueue.isDispatchThread(); }
From source file:com.t3.client.TabletopTool.java
public static BufferedImage takeMapScreenShot(final PlayerView view) { final ZoneRenderer renderer = clientFrame.getCurrentZoneRenderer(); if (renderer == null) { return null; }//from w w w.j av a 2s .c o m Dimension size = renderer.getSize(); if (size.width == 0 || size.height == 0) { return null; } BufferedImage image = new BufferedImage(size.width, size.height, Transparency.OPAQUE); final Graphics2D g = image.createGraphics(); g.setClip(0, 0, size.width, size.height); // Have to do this on the EDT so that there aren't any odd side effects // of rendering // using a renderer that's on screen if (!EventQueue.isDispatchThread()) { try { EventQueue.invokeAndWait(new Runnable() { @Override public void run() { renderer.renderZone(g, view); } }); } catch (InterruptedException ie) { TabletopTool.showError("While creating snapshot", ie); } catch (InvocationTargetException ite) { TabletopTool.showError("While creating snapshot", ite); } } else { renderer.renderZone(g, view); } g.dispose(); return image; }
From source file:net.rptools.maptool.client.MapTool.java
public static BufferedImage takeMapScreenShot(final PlayerView view) { final ZoneRenderer renderer = clientFrame.getCurrentZoneRenderer(); if (renderer == null) { return null; }/*w w w .jav a2 s .c o m*/ Dimension size = renderer.getSize(); if (size.width == 0 || size.height == 0) { return null; } BufferedImage image = new BufferedImage(size.width, size.height, Transparency.OPAQUE); final Graphics2D g = image.createGraphics(); g.setClip(0, 0, size.width, size.height); // Have to do this on the EDT so that there aren't any odd side effects // of rendering // using a renderer that's on screen if (!EventQueue.isDispatchThread()) { try { EventQueue.invokeAndWait(new Runnable() { public void run() { renderer.renderZone(g, view); } }); } catch (InterruptedException ie) { MapTool.showError("While creating snapshot", ie); } catch (InvocationTargetException ite) { MapTool.showError("While creating snapshot", ite); } } else { renderer.renderZone(g, view); } g.dispose(); return image; }