001: /*
002: * SQLeonardo :: java database frontend
003: * Copyright (C) 2004 nickyb@users.sourceforge.net
004: *
005: * This program is free software; you can redistribute it and/or
006: * modify it under the terms of the GNU General Public License
007: * as published by the Free Software Foundation; either version 2
008: * of the License, or (at your option) any later version.
009: *
010: * This program is distributed in the hope that it will be useful,
011: * but WITHOUT ANY WARRANTY; without even the implied warranty of
012: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
013: * GNU General Public License for more details.
014: *
015: * You should have received a copy of the GNU General Public License
016: * along with this program; if not, write to the Free Software
017: * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
018: *
019: */
020:
021: package nickyb.sqleonardo.environment.ctrl.content;
022:
023: import java.awt.event.ActionEvent;
024: import java.awt.event.ActionListener;
025:
026: import javax.swing.JButton;
027: import javax.swing.JLabel;
028: import javax.swing.JProgressBar;
029: import javax.swing.border.CompoundBorder;
030: import javax.swing.border.EmptyBorder;
031: import javax.swing.border.EtchedBorder;
032:
033: import nickyb.sqleonardo.common.gui.BorderLayoutPanel;
034: import nickyb.sqleonardo.common.gui.CustomLineBorder;
035: import nickyb.sqleonardo.environment.Application;
036:
037: public abstract class AbstractMaskPerform extends BorderLayoutPanel {
038: static final short SQL = 0;
039: static final short TXT = 1;
040: static final short WEB = 2;
041:
042: protected JProgressBar progress;
043: protected JButton btnStop;
044: protected JLabel lblFile;
045: protected JLabel lblMsg;
046:
047: protected ContentView view;
048:
049: public AbstractMaskPerform() {
050: super (2, 10);
051: setBorder(new CompoundBorder(new CustomLineBorder(false, false,
052: true, false), new EmptyBorder(20, 10, 15, 10)));
053:
054: lblFile = new JLabel("file: <empty>");
055: lblFile.setBorder(new CustomLineBorder(false, false, true,
056: false));
057: setComponentNorth(lblFile);
058:
059: btnStop = new JButton(Application.resources
060: .getIcon(Application.ICON_STOP));
061: btnStop.setEnabled(false);
062: btnStop.addActionListener(new ActionListener() {
063: public void actionPerformed(ActionEvent e) {
064: AbstractMaskPerform.this .lblMsg.setText("stopped!");
065: AbstractMaskPerform.this .btnStop.setEnabled(false);
066:
067: AbstractMaskPerform.this .view.onTableChanged(true);
068: AbstractMaskPerform.this .view.getControl()
069: .doRefreshStatus();
070: }
071: });
072:
073: progress = new JProgressBar();
074: progress.setBorder(new EtchedBorder(EtchedBorder.LOWERED));
075:
076: BorderLayoutPanel statusbar = new BorderLayoutPanel(2, 2);
077: statusbar.setComponentNorth(progress);
078: statusbar.setComponentCenter(lblMsg = new JLabel("..."));
079: statusbar.setComponentEast(btnStop);
080:
081: setComponentSouth(statusbar);
082: }
083:
084: void setContent(ContentView view) {
085: this .view = view;
086: }
087:
088: abstract void setType(short type, String tname, String fname);
089:
090: // -----------------------------------------------------------------------------------------
091: // ?????????????????????????????????????????????????????????????????????????????????????????
092: // -----------------------------------------------------------------------------------------
093: boolean aborted() {
094: return !btnStop.isEnabled();
095: }
096:
097: void init() {
098: btnStop.setEnabled(true);
099: lblMsg.setText("wait...");
100: }
101:
102: abstract void next();
103:
104: abstract boolean finished();
105: // -----------------------------------------------------------------------------------------
106: // -----------------------------------------------------------------------------------------
107: }
|