001: /*
002: * The contents of this file are subject to the Mozilla Public License
003: * Version 1.1 (the "License"); you may not use this file except in
004: * compliance with the License. You may obtain a copy of the License at
005: * http://www.mozilla.org/MPL/
006: *
007: * Software distributed under the License is distributed on an "AS IS"
008: * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
009: * License for the specific language governing rights and limitations
010: * under the License.
011: *
012: * The Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
013: *
014: * The Initial Developer of the Original Code is iSQL-Viewer, A Mutli-Platform Database Tool.
015: * Portions created by Mark A. Kobold are Copyright (C) 2000-2007. All Rights Reserved.
016: *
017: * Contributor(s):
018: * Mark A. Kobold [mkobold <at> isqlviewer <dot> com].
019: *
020: * If you didn't download this code from the following link, you should check
021: * if you aren't using an obsolete version: http://www.isqlviewer.com
022: */
023: package org.isqlviewer.event;
024:
025: import java.util.EventObject;
026:
027: /**
028: * Event for describing a progression.
029: * <p>
030: * This object is mainly designed to complement JProgressBars. this method supports most of the values to properly
031: * describe a state of progress to a JProgressBar.
032: * <p>
033: * This class is also setup to be mutable so that ProgressEvent do not always have to be instantiated.
034: *
035: * @author Mark A. Kobold <mkobold at isqlviewer dot com>
036: * @version 1.0
037: */
038: public class ProgressEvent extends EventObject {
039:
040: private static final long serialVersionUID = -2854383461733335079L;
041: private int progress = 0;
042: private int maximum = 0;
043: private String note = "";
044:
045: /**
046: * Default constructor.
047: * <p>
048: * Creates the event with the given source, specified progress and maximum values.
049: *
050: * @see #setMaximum(int)
051: * @see #setProgress(int)
052: * @param source of which the event comes from.
053: * @param progress the current progress.
054: * @param maximum the maximum value as it relates to the progress.
055: */
056: public ProgressEvent(Object source, int progress, int maximum) {
057:
058: super (source);
059: setMaximum(maximum);
060: setProgress(progress);
061: }
062:
063: /**
064: * @return the maximum value for this event.
065: */
066: public int getMaximum() {
067:
068: return maximum;
069: }
070:
071: /**
072: * @return the current progress for this event, -1 for indeterminate.
073: */
074: public int getProgress() {
075:
076: return progress;
077: }
078:
079: /**
080: * @param progress indicator for this event.
081: */
082: public void setProgress(int progress) {
083:
084: this .progress = progress;
085: }
086:
087: /**
088: * @return String that shows extra information regarding this event.
089: */
090: public String getNote() {
091:
092: return note;
093: }
094:
095: /**
096: * @param note extra information regarding this event.
097: */
098: public void setNote(String note) {
099:
100: this .note = note;
101: }
102:
103: /**
104: * @param maximum value of the total progress.
105: */
106: protected void setMaximum(int maximum) {
107:
108: this.maximum = maximum;
109: }
110:
111: }
|