001/* 002 * Copyright (c) 2003-2010 The Regents of the University of California. 003 * All rights reserved. 004 * 005 * '$Author: welker $' 006 * '$Date: 2010-05-06 05:21:26 +0000 (Thu, 06 May 2010) $' 007 * '$Revision: 24234 $' 008 * 009 * Permission is hereby granted, without written agreement and without 010 * license or royalty fees, to use, copy, modify, and distribute this 011 * software and its documentation for any purpose, provided that the above 012 * copyright notice and the following two paragraphs appear in all copies 013 * of this software. 014 * 015 * IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 016 * FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 017 * ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 018 * THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 019 * SUCH DAMAGE. 020 * 021 * THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 022 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 023 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 024 * PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 025 * CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 026 * ENHANCEMENTS, OR MODIFICATIONS. 027 * 028 */ 029 030package org.kepler.objectmanager.data; 031 032import java.awt.BorderLayout; 033import java.awt.Dimension; 034import java.awt.Rectangle; 035 036import javax.swing.JFrame; 037import javax.swing.JLabel; 038import javax.swing.JPanel; 039import javax.swing.JProgressBar; 040 041import org.kepler.objectmanager.cache.DataCacheListener; 042import org.kepler.objectmanager.cache.DataCacheObject; 043 044/** 045 * @author globus 046 * 047 * TODO To change the template for this generated type comment go to 048 * Window - Preferences - Java - Code Generation - Code and Comments 049 */ 050public class DataSrcProgressFrame extends JFrame implements DataCacheListener { 051 protected JLabel _msgText = new JLabel(); 052 protected JProgressBar _progressBar = new JProgressBar(0, 100); 053 054 /** 055 * Constructor 056 * 057 * @param aMsg 058 * initial message 059 */ 060 public DataSrcProgressFrame(String aMsg) { 061 setTitle("Data Download in Progress..."); 062 JPanel panel = new JPanel(new BorderLayout()); 063 _progressBar.setValue(0); 064 _progressBar.setStringPainted(false); 065 _progressBar.setIndeterminate(true); 066 _msgText = new JLabel(aMsg); 067 panel.add(_msgText, BorderLayout.NORTH); 068 panel.add(_progressBar, BorderLayout.CENTER); 069 setContentPane(panel); 070 071 setSize(new Dimension(500, 60)); 072 073 // Center on Screen 074 Rectangle screenRect = getGraphicsConfiguration().getBounds(); 075 /* 076 Insets screenInsets = Toolkit.getDefaultToolkit().getScreenInsets( 077 getGraphicsConfiguration()); 078 079 // Make sure we don't place the demo off the screen. 080 * int centerWidth = screenRect.width < getSize().width ? screenRect.x : 081 * screenRect.x + screenRect.width / 2 - getSize().width / 2; int 082 * centerHeight = screenRect.height < getSize().height ? screenRect.y : 083 * screenRect.y + screenRect.height / 2 - getSize().height / 2; 084 * 085 * centerHeight = centerHeight < screenInsets.top ? screenInsets.top : 086 * centerHeight; 087 * 088 * setLocation(centerWidth, centerHeight); 089 */ 090 091 int x = screenRect.width - getSize().width; 092 // int y = screenRect.height - getSize().height; 093 setLocation(x, screenRect.y); 094 // show(); 095 } 096 097 /** 098 * Sets the message text in the frame 099 * 100 * @param aMsg 101 */ 102 public void setMsg(String aMsg) { 103 _msgText.setText(aMsg); 104 _msgText.repaint(); 105 } 106 107 // ------------------------------------------------------------------------ 108 // -- DataCacheListener 109 // ------------------------------------------------------------------------ 110 111 public void complete(DataCacheObject aItem) { 112 hide(); 113 _progressBar.setValue(100); 114 _progressBar.setIndeterminate(false); 115 // aItem.clearProgress(); 116 } 117}