Example usage for java.awt EventQueue invokeAndWait

List of usage examples for java.awt EventQueue invokeAndWait

Introduction

In this page you can find the example usage for java.awt EventQueue invokeAndWait.

Prototype

public static void invokeAndWait(Runnable runnable) throws InterruptedException, InvocationTargetException 

Source Link

Document

Causes runnable to have its run method called in the #isDispatchThread dispatch thread of Toolkit#getSystemEventQueue the system EventQueue .

Usage

From source file:org.parosproxy.paros.extension.trap.ProxyListenerTrap.java

private void setHttpDisplay(final HttpPanel httpPanel, final HttpMessage msg, final boolean isRequest) {
    try {//  www . ja  v a 2s  . c om
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                httpPanel.setMessage(msg, isRequest);
            }
        });
    } catch (Exception e) {
    }

}

From source file:org.zaproxy.zap.extension.compare.ExtensionCompare.java

@Override
public void sessionChanged(final Session session) {
    if (EventQueue.isDispatchThread()) {
        sessionChangedEventHandler(session);

    } else {//from www . j ava 2 s .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.brk.ProxyListenerBreak.java

private void setBreakDisplay(final HttpMessage msg, boolean isRequest) {
    setHttpDisplay(getBreakPanel(), msg, isRequest);
    getBreakPanel().breakPointDisplayed();
    try {/*from   w w w  .  ja va 2 s.co  m*/
        EventQueue.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                View.getSingleton().getMainFrame().toFront();
            }
        });
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    }
}

From source file:org.parosproxy.paros.extension.trap.ProxyListenerTrap.java

private void waitUntilContinue(final HttpMessage msg, final boolean isRequest) {
    getTrapPanel().setContinue(false);/* w w w .  j a  va 2s .  c  o  m*/
    while (!getTrapPanel().isContinue()) {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    try {
        EventQueue.invokeAndWait(new Runnable() {
            public void run() {
                getTrapPanel().getMessage(msg, isRequest);
                getTrapPanel().setMessage(null, isRequest);
            }
        });
    } catch (Exception ie) {
        //logPane.append(ERROR_LOG, ie.getMessage());
    }

}

From source file:org.kineticsystem.commons.data.view.actions.MoveBackMouseAction.java

/**
 * This method is called when the user press a mouse button on the button
 * connected to this action.//from   w w  w.  j av  a2  s  .  c o  m
 * @param event The mouse event.
 */
public void mousePressed(MouseEvent event) {

    if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {

        mover = new Accelerator() {

            public void execute() {

                if (navigator.isMoveBackEnabled()) {
                    try {
                        EventQueue.invokeAndWait(new Runnable() {
                            public void run() {
                                navigator.moveBack();
                            }
                        });
                    } catch (Exception ex) {
                        logger.info(ex);
                    }
                } else {
                    interrupt();
                }
            }
        };
        mover.setPriority(Thread.NORM_PRIORITY);
        mover.start();
    }
}

From source file:org.kineticsystem.commons.data.view.actions.MoveForwardMouseAction.java

/**
 * This method is called when the user press a mouse button on the button
 * connected to this action.//from  w w w. jav  a 2  s.co  m
 * @param event The mouse event.
 */
public void mousePressed(MouseEvent event) {

    if ((event.getModifiers() & InputEvent.BUTTON1_MASK) != 0) {

        mover = new Accelerator() {

            public void execute() {

                if (navigator.isMoveForwardEnabled()) {
                    try {
                        EventQueue.invokeAndWait(new Runnable() {
                            public void run() {
                                navigator.moveNext();
                            }
                        });
                    } catch (Exception ex) {
                        logger.info(ex);
                    }
                } else {
                    interrupt();
                }
            }
        };
        mover.setPriority(Thread.NORM_PRIORITY);
        mover.start();
    }
}

From source file:org.zaproxy.zap.extension.brk.ProxyListenerBreak.java

private void setHttpDisplay(final BreakPanel breakPanel, final HttpMessage msg, final boolean isRequest) {
    try {//from www  .j  a v a  2  s . c om
        EventQueue.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                breakPanel.setMessage(msg, isRequest);
            }
        });
    } catch (Exception e) {
        log.warn(e.getMessage(), e);
    }

}

From source file:org.parosproxy.paros.extension.manualrequest.http.impl.HttpPanelSender.java

@Override
public void handleSendMessage(Message aMessage) throws IllegalArgumentException, IOException {
    final HttpMessage httpMessage = (HttpMessage) aMessage;
    try {//from   w ww  .  j  a  v a2s .c  o m
        final ModeRedirectionValidator redirectionValidator = new ModeRedirectionValidator();
        boolean followRedirects = getButtonFollowRedirects().isSelected();
        if (followRedirects) {
            getDelegate().sendAndReceive(httpMessage,
                    HttpRequestConfig.builder().setRedirectionValidator(redirectionValidator).build());
        } else {
            getDelegate().sendAndReceive(httpMessage, false);
        }

        EventQueue.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                if (!httpMessage.getResponseHeader().isEmpty()) {
                    // Indicate UI new response arrived
                    responsePanel.updateContent();

                    if (!followRedirects) {
                        persistAndShowMessage(httpMessage);
                    } else if (!redirectionValidator.isRequestValid()) {
                        View.getSingleton().showWarningDialog(
                                Constant.messages.getString("manReq.outofscope.redirection.warning",
                                        redirectionValidator.getInvalidRedirection()));
                    }
                }
            }
        });

        ZapGetMethod method = (ZapGetMethod) httpMessage.getUserObject();
        notifyPersistentConnectionListener(httpMessage, null, method);

    } catch (final HttpMalformedHeaderException mhe) {
        throw new IllegalArgumentException("Malformed header error.", mhe);

    } catch (final UnknownHostException uhe) {
        throw new IOException("Error forwarding to an Unknown host: " + uhe.getMessage(), uhe);

    } catch (final SSLException sslEx) {
        throw sslEx;
    } catch (final IOException ioe) {
        throw new IOException("IO error in sending request: " + ioe.getClass() + ": " + ioe.getMessage(), ioe);

    } catch (final Exception e) {
        logger.error(e.getMessage(), e);
    }
}

From source file:org.zaproxy.zap.extension.jxbrowserlinux64.selenium.JxBrowserProvider.java

private RemoteWebDriver getRemoteWebDriver(final int requesterId, final String proxyAddress,
        final int proxyPort) {
    if (View.isInitialised()) {
        try {/*from w  w  w  . ja  va 2  s .  c o m*/
            GetWebDriverRunnable wb = new GetWebDriverRunnable(requesterId, proxyAddress, proxyPort);
            EventQueue.invokeAndWait(wb);
            return wb.getWebDriver();
        } catch (InvocationTargetException | InterruptedException e) {
            throw new WebDriverException(e);
        }
    }

    synchronized (this) {
        return getRemoteWebDriverImpl(requesterId, proxyAddress, proxyPort);
    }
}

From source file:org.zaproxy.zap.extension.brk.ProxyListenerBreak.java

private void waitUntilContinue(final HttpMessage msg, final boolean isRequest) {
    // Note that multiple requests and responses can get built up, so pressing continue only
    // releases the current break, not all of them.
    //getBreakPanel().setContinue(false);
    while (getBreakPanel().isHoldMessage()) {
        try {/*from  www . ja  v  a 2s  . com*/
            Thread.sleep(100);
        } catch (InterruptedException e) {
            log.warn(e.getMessage(), e);
        }
    }
    try {
        EventQueue.invokeAndWait(new Runnable() {
            @Override
            public void run() {
                getBreakPanel().getMessage(msg, isRequest);
            }
        });
    } catch (Exception ie) {
        log.warn(ie.getMessage(), ie);
    }

}