Path: blob/master/src/jdk.jconsole/share/classes/sun/tools/jconsole/Tab.java
40948 views
/*1* Copyright (c) 2004, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation. Oracle designates this7* particular file as subject to the "Classpath" exception as provided8* by Oracle in the LICENSE file that accompanied this code.9*10* This code is distributed in the hope that it will be useful, but WITHOUT11* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or12* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License13* version 2 for more details (a copy is included in the LICENSE file that14* accompanied this code).15*16* You should have received a copy of the GNU General Public License version17* 2 along with this work; if not, write to the Free Software Foundation,18* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.19*20* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA21* or visit www.oracle.com if you need additional information or have any22* questions.23*/2425package sun.tools.jconsole;2627import java.awt.*;28import javax.swing.*;2930@SuppressWarnings("serial") // JDK implementation class31public abstract class Tab extends JPanel {32private String name;33private Worker worker;3435protected VMPanel vmPanel;3637private SwingWorker<?, ?> prevSW;3839public Tab(VMPanel vmPanel, String name) {40this.vmPanel = vmPanel;41this.name = name;42}4344public SwingWorker<?, ?> newSwingWorker() {45return null;46}4748public void update() {49final ProxyClient proxyClient = vmPanel.getProxyClient();50if (!proxyClient.hasPlatformMXBeans()) {51throw new UnsupportedOperationException(52"Platform MXBeans not registered in MBeanServer");53}5455SwingWorker<?,?> sw = newSwingWorker();56// schedule SwingWorker to run only if the previous57// SwingWorker has finished its task and it hasn't started.58if (prevSW == null || prevSW.isDone()) {59if (sw == null || sw.getState() == SwingWorker.StateValue.PENDING) {60prevSW = sw;61if (sw != null) {62sw.execute();63}64}65}66}6768public synchronized void dispose() {69if(worker != null)70worker.stopWorker();7172// Subclasses will override to clean up73}7475protected VMPanel getVMPanel() {76return vmPanel;77}7879OverviewPanel[] getOverviewPanels() {80return null;81}8283public synchronized void workerAdd(Runnable job) {84if (worker == null) {85worker = new Worker(name+"-"+vmPanel.getConnectionName());86worker.start();87}88worker.add(job);89}9091public Dimension getPreferredSize() {92return new Dimension(700, 500);93}94}959697