001/* 002 * This file is part of McIDAS-V 003 * 004 * Copyright 2007-2025 005 * Space Science and Engineering Center (SSEC) 006 * University of Wisconsin - Madison 007 * 1225 W. Dayton Street, Madison, WI 53706, USA 008 * https://www.ssec.wisc.edu/mcidas/ 009 * 010 * All Rights Reserved 011 * 012 * McIDAS-V is built on Unidata's IDV and SSEC's VisAD libraries, and 013 * some McIDAS-V source code is based on IDV and VisAD source code. 014 * 015 * McIDAS-V is free software; you can redistribute it and/or modify 016 * it under the terms of the GNU Lesser Public License as published by 017 * the Free Software Foundation; either version 3 of the License, or 018 * (at your option) any later version. 019 * 020 * McIDAS-V is distributed in the hope that it will be useful, 021 * but WITHOUT ANY WARRANTY; without even the implied warranty of 022 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 023 * GNU Lesser Public License for more details. 024 * 025 * You should have received a copy of the GNU Lesser Public License 026 * along with this program. If not, see https://www.gnu.org/licenses/. 027 */ 028package edu.wisc.ssec.mcidasv.util; 029 030import java.util.List; 031import java.util.concurrent.AbstractExecutorService; 032import java.util.concurrent.TimeUnit; 033 034import javax.swing.SwingUtilities; 035 036 037/** 038 * Executor built atop SwingUtilities. Courtesy of <i>Java Concurrency in 039 * Practice</i>, written by Brian Goetz and Tim Peierls. 040 */ 041// TODO: couldn't find a license for this code? is it public domain? 042public class GuiExecutor extends AbstractExecutorService { 043 // Singletons have a private constructor and a public factory 044 private static final GuiExecutor instance = new GuiExecutor(); 045 046 private GuiExecutor() { 047 } 048 049 public static GuiExecutor instance() { 050 return instance; 051 } 052 053 public void execute(Runnable r) { 054 if (SwingUtilities.isEventDispatchThread()) 055 r.run(); 056 else 057 SwingUtilities.invokeLater(r); 058 } 059 060 public void shutdown() { 061 throw new UnsupportedOperationException(); 062 } 063 064 public List<Runnable> shutdownNow() { 065 throw new UnsupportedOperationException(); 066 } 067 068 public boolean awaitTermination(long timeout, TimeUnit unit) 069 throws InterruptedException { 070 throw new UnsupportedOperationException(); 071 } 072 073 public boolean isShutdown() { 074 return false; 075 } 076 077 public boolean isTerminated() { 078 return false; 079 } 080}