Example usage for javax.swing SwingUtilities isEventDispatchThread

List of usage examples for javax.swing SwingUtilities isEventDispatchThread

Introduction

In this page you can find the example usage for javax.swing SwingUtilities isEventDispatchThread.

Prototype

public static boolean isEventDispatchThread() 

Source Link

Document

Returns true if the current thread is an AWT event dispatching thread.

Usage

From source file:org.audiveris.omr.log.LogUtil.java

/**
 * In the calling thread, start log annotation with stub ID.
 *
 * @param stub the sheet/stub related to processing
 *//*from www. j  a  va 2  s.  c  o  m*/
public static void start(SheetStub stub) {
    start(stub.getBook());

    if (!SwingUtilities.isEventDispatchThread()) {
        MDC.put(SHEET, stub.getNum());
    }
}

From source file:org.audiveris.omr.log.LogUtil.java

/**
 * In the calling thread, start log annotation with book ID.
 *
 * @param book the book related to processing
 *//*from www  .  j a v a2  s.  c o m*/
public static void start(Book book) {
    if (!SwingUtilities.isEventDispatchThread()) {
        String str = book.getAlias();

        if (str == null) {
            str = book.getRadix();
        }

        MDC.put(BOOK, str);
    }
}

From source file:org.audiveris.omr.log.LogUtil.java

/**
 * In the calling thread, stop book log annotation.
 *//*from ww w.j a  va2 s . co  m*/
public static void stopBook() {
    stopStub();

    if (!SwingUtilities.isEventDispatchThread()) {
        MDC.remove(BOOK);
    }
}

From source file:org.audiveris.omr.log.LogUtil.java

/**
 * In the calling thread, stop sheet stub log annotation.
 *///  w w  w  . j  a v  a2  s  .com
public static void stopStub() {
    if (!SwingUtilities.isEventDispatchThread()) {
        MDC.remove(SHEET);
    }
}

From source file:org.broad.igv.cbio.FilterGeneNetworkUI.java

private void loadcBioData(final List<String> geneLoci) {

    final IndefiniteProgressMonitor indefMonitor = new IndefiniteProgressMonitor(60);
    final ProgressBar progressBar = ProgressBar.showProgressDialog((Frame) getOwner(), "Loading cBio data...",
            indefMonitor, true);//from ww  w  . j  a  v a  2 s. co  m
    progressBar.setIndeterminate(true);
    indefMonitor.start();

    final Runnable showUI = new Runnable() {
        @Override
        public void run() {
            initComponents();
            initComponentData();
            setVisible(true);
        }
    };

    final Runnable runnable = new Runnable() {
        @Override
        public void run() {

            WaitCursorManager.CursorToken token = null;

            try {
                token = WaitCursorManager.showWaitCursor();
                network = GeneNetwork.getFromCBIO(geneLoci);
                if (network.vertexSet().size() == 0) {
                    MessageUtils
                            .showMessage("No results found for " + HttpUtils.buildURLString(geneLoci, ", "));
                } else {
                    network.annotateAll(IGV.getInstance().getAllTracks());
                    UIUtilities.invokeOnEventThread(showUI);
                }
            } catch (Exception e) {
                e.printStackTrace();
                log.error(e.getMessage());
                MessageUtils.showMessage("Error loading data: " + e.getMessage());
            } finally {
                WaitCursorManager.removeWaitCursor(token);

                if (progressBar != null) {
                    progressBar.close();
                    indefMonitor.stop();
                }
            }
        }
    };

    // If we're on the dispatch thread spawn a worker, otherwise just execute.
    if (SwingUtilities.isEventDispatchThread()) {
        SwingWorker worker = new SwingWorker() {
            @Override
            protected Object doInBackground() throws Exception {
                runnable.run();
                return null;
            }
        };

        worker.execute();
    } else {
        runnable.run();
    }
}

From source file:org.codinjutsu.tools.jenkins.logic.RequestManager.java

private boolean handleNotYetLoggedInState() {
    boolean threadStack = false;
    boolean result = false;
    if (SwingUtilities.isEventDispatchThread()) {
        logger.warn("RequestManager.handleNotYetLoggedInState called from EDT");
        threadStack = true;/*from w  ww  .  j ava2  s.c om*/
    }
    if (securityClient == null) {
        logger.warn("Not yet logged in, all calls until login will fail");
        threadStack = true;
        result = true;
    }
    if (threadStack)
        Thread.dumpStack();
    return result;
}

From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java

public void loadSelectedJob() {
    if (SwingUtilities.isEventDispatchThread()) {
        logger.warn("BrowserPanel.loadSelectedJob called from EDT");
    }/*from ww w  .  j  ava2  s  .  c  o  m*/
    final Job job = getSelectedJob();
    loadJob(job);

}

From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java

public void loadJob(final Job job) {
    if (!SwingUtilities.isEventDispatchThread()) {
        logger.warn("BrowserPanel.loadJob called from outside of EDT");
    }/*from   ww w  . ja v a 2 s.co m*/
    GuiUtil.runInSwingThread(
            new Task.Backgroundable(project, "Loading job", true, JenkinsLoadingTaskOption.INSTANCE) {

                private Job returnJob;

                @Override
                public void run(@NotNull ProgressIndicator indicator) {
                    returnJob = requestManager.loadJob(job);
                }

                @Override
                public void onSuccess() {
                    job.updateContentWith(returnJob);
                    updateJobNode(job);
                }

            });
}

From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java

public void loadView(final View view) {
    this.currentSelectedView = view;
    if (!SwingUtilities.isEventDispatchThread()) {
        logger.warn("BrowserPanel.loadView called from outside EDT");
    }//from  w  w w.  j a v  a2 s.c o  m
    new LoadSelectedViewJob(project).queue();
}

From source file:org.codinjutsu.tools.jenkins.view.BrowserPanel.java

public void refreshCurrentView() {
    if (!SwingUtilities.isEventDispatchThread()) {
        logger.warn("BrowserPanel.refreshCurrentView called outside EDT");
    }/*from w w w .j av a 2s  .c om*/
    new LoadSelectedViewJob(project).queue();
}