1 19 20 21 package org.netbeans.progress.spi; 22 23 27 public final class ProgressEvent { 28 29 public static final int TYPE_START = 0; 30 public static final int TYPE_FINISH = 4; 31 public static final int TYPE_REQUEST_STOP = 3; 32 public static final int TYPE_PROGRESS = 1; 33 public static final int TYPE_SWITCH = 5; 34 public static final int TYPE_SILENT = 6; 35 36 private InternalHandle source; 37 private long estimatedCompletion; 38 private int percentageDone; 39 private int workunitsDone; 40 private String message; 41 private int type; 42 private boolean watched; 43 private boolean switched; 44 private String displayName; 45 46 49 public ProgressEvent(InternalHandle src, int type, boolean isWatched) { 50 source = src; 51 estimatedCompletion = -1; 52 percentageDone = -1; 53 workunitsDone = -1; 54 message = null; 55 this.type = type; 56 watched = isWatched; 57 switched = (type == TYPE_SWITCH); 58 } 59 60 63 public ProgressEvent(InternalHandle src, int type, boolean isWatched, String msg) { 64 this(src, type, isWatched); 65 message = msg; 66 } 67 71 public ProgressEvent(InternalHandle src, String msg, int units, int percentage, long estimate, boolean isWatched) { 72 this(src, TYPE_PROGRESS, isWatched); 73 workunitsDone = units; 74 percentageDone = percentage; 75 estimatedCompletion = estimate; 76 message = msg; 77 } 78 public ProgressEvent(InternalHandle src, String msg, int units, int percentage, long estimate, boolean isWatched, String displayName) { 79 this(src, msg, units, percentage, estimate, isWatched); 80 this.displayName = displayName; 81 } 82 83 public InternalHandle getSource() { 84 return source; 85 } 86 87 public long getEstimatedCompletion() { 88 return estimatedCompletion; 89 } 90 91 public int getPercentageDone() { 92 return percentageDone; 93 } 94 95 public int getWorkunitsDone() { 96 return workunitsDone; 97 } 98 99 public String getMessage() { 100 return message; 101 } 102 103 public int getType() { 104 return type; 105 } 106 107 public boolean isWatched() { 108 return watched; 109 } 110 111 115 public void copyMessageFromEarlier(ProgressEvent last) { 116 if (message == null) { 117 message = last.getMessage(); 118 } 119 if (displayName == null) { 120 displayName = last.getDisplayName(); 121 } 122 } 123 124 public void markAsSwitched() { 125 switched = true; 126 } 127 128 public boolean isSwitched() { 129 return switched; 130 } 131 132 public String getDisplayName() { 133 return displayName; 134 } 135 136 } 137 | Popular Tags |