1 package com.nightlabs.io; 2 3 import java.beans.PropertyChangeListener ; 4 import java.beans.PropertyChangeSupport ; 5 6 public abstract class AbstractIOFilterWithProgress 7 implements IOFilterWithProgress 8 { 9 public static final String PROGRESS_CHANGED = "progress changed"; 10 11 public AbstractIOFilterWithProgress() { 12 super(); 13 pcs = new PropertyChangeSupport (this); 14 } 15 16 protected PropertyChangeSupport pcs = null; 17 public void addPropertyChangeListener(PropertyChangeListener pcl) { 18 pcs.addPropertyChangeListener(pcl); 19 } 20 public void removePropertyChangeListener(PropertyChangeListener pcl) { 21 pcs.removePropertyChangeListener(pcl); 22 } 23 24 protected int currentWork = 0; 25 protected void setCurrentWork(int work) { 26 int oldWork = currentWork; 27 currentWork = work; 28 pcs.firePropertyChange(PROGRESS_CHANGED, oldWork, currentWork); 29 } 30 public int getCurrentWork() { 31 return currentWork; 32 } 33 34 protected int totalWork = 100; 35 public int getTotalWork() { 36 return totalWork; 37 } 38 39 } 40 | Popular Tags |