Changeset 158 for trunk/src/org/thestaticvoid/iriverter/ProgressDialog.java
- Timestamp:
- 04/13/07 19:28:10 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/thestaticvoid/iriverter/ProgressDialog.java
r157 r158 30 30 public class ProgressDialog extends Dialog implements SelectionListener, ProgressDialogInfo { 31 31 private Shell shell; 32 private Label header, inputVideoLabel, inputVideo, outputVideoLabel, outputVideo, status;32 private Label header, jobDescription, subdescription, miscellaneous1, miscellaneous2; 33 33 private ProgressBar progressBar; 34 private String syncInputVideo, syncOutputVideo, syncStatus;35 34 private Button dismiss; 36 private int currentJob, totalJobs , syncPercentComplete;35 private int currentJob, totalJobs; 37 36 38 37 public ProgressDialog(Shell parent, int style) { … … 51 50 52 51 header = new Label(shell, SWT.NONE); 53 header.setText(" Converting");52 header.setText("Job"); 54 53 FontData[] fontData = header.getFont().getFontData(); 55 54 fontData[0].setStyle(SWT.BOLD); … … 59 58 header.setLayoutData(gridData); 60 59 61 Composite infoComp = new Composite(shell, SWT.NONE); 60 jobDescription = new Label(shell, SWT.NONE); 61 fontData = jobDescription.getFont().getFontData(); 62 fontData[0].setStyle(SWT.BOLD); 63 jobDescription.setFont(new Font(getParent().getDisplay(), fontData)); 64 65 progressBar = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); 66 progressBar.setMaximum(100); 67 progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 68 69 subdescription = new Label(shell, SWT.NONE); 70 fontData = subdescription.getFont().getFontData(); 71 fontData[0].setStyle(SWT.ITALIC); 72 subdescription.setFont(new Font(getParent().getDisplay(), fontData)); 73 74 Composite details = new Composite(shell, SWT.NONE); 62 75 gridLayout = new GridLayout(); 63 76 gridLayout.horizontalSpacing = 6; … … 65 78 gridLayout.marginHeight = 0; 66 79 gridLayout.marginWidth = 0; 67 gridLayout.numColumns = 2; 68 infoComp.setLayout(gridLayout); 69 infoComp.setLayoutData(new GridData(GridData.FILL_BOTH)); 80 details.setLayout(gridLayout); 81 details.setLayoutData(new GridData(GridData.FILL_BOTH)); 70 82 71 inputVideoLabel = new Label(infoComp, SWT.NONE); 72 inputVideoLabel.setText("Input:"); 73 fontData = inputVideoLabel.getFont().getFontData(); 74 fontData[0].setStyle(SWT.BOLD); 75 inputVideoLabel.setFont(new Font(getParent().getDisplay(), fontData)); 76 77 inputVideo = new Label(infoComp, SWT.NONE); 78 79 outputVideoLabel = new Label(infoComp, SWT.NONE); 80 outputVideoLabel.setText("Output:"); 81 outputVideoLabel.setFont(new Font(getParent().getDisplay(), fontData)); 82 83 outputVideo = new Label(infoComp, SWT.NONE); 84 85 progressBar = new ProgressBar(shell, SWT.HORIZONTAL | SWT.SMOOTH); 86 progressBar.setMaximum(100); 87 progressBar.setLayoutData(new GridData(GridData.FILL_HORIZONTAL)); 88 89 status = new Label(shell, SWT.NONE); 90 fontData = status.getFont().getFontData(); 91 fontData[0].setStyle(SWT.ITALIC); 92 status.setFont(new Font(getParent().getDisplay(), fontData)); 83 miscellaneous1 = new Label(details, SWT.NONE); 84 miscellaneous2 = new Label(details, SWT.NONE); 93 85 94 86 dismiss = new Button(shell, SWT.PUSH); … … 122 114 } 123 115 124 public synchronized void complete(final boolean success) { 125 Display.getDefault().syncExec(new Runnable() { 126 public void run() { 127 if (!success) { 128 MessageBox dialog = new MessageBox(getParent().getShell(), SWT.ICON_ERROR); 129 dialog.setText("There Was an Error While Converting"); 130 dialog.setMessage("An error occurred while converting " + inputVideo.getText()); 131 dialog.open(); 132 } 133 134 shell.setText("Complete"); 135 header.setText("Complete"); 136 inputVideoLabel.setText(""); 137 inputVideo.setText(""); 138 outputVideoLabel.setText(""); 139 outputVideo.setText(""); 140 progressBar.setSelection(100); 141 status.setText(""); 142 dismiss.setText("Close"); 143 } 144 }); 145 } 146 147 public synchronized void setCurrentJob(int currentJob) { 116 public void setCurrentJob(int currentJob) { 148 117 this.currentJob = currentJob; 149 118 … … 151 120 public void run() { 152 121 if (!shell.isDisposed() && !header.isDisposed()) { 153 shell.setText(" Converting" + ProgressDialog.this.currentJob + " of " + totalJobs);154 header.setText(" Converting" + ProgressDialog.this.currentJob + " of " + totalJobs);122 shell.setText("Job " + ProgressDialog.this.currentJob + " of " + totalJobs); 123 header.setText("Job " + ProgressDialog.this.currentJob + " of " + totalJobs); 155 124 header.pack(); 156 125 } … … 159 128 } 160 129 161 public synchronizedvoid setTotalJobs(int totalJobs) {130 public void setTotalJobs(int totalJobs) { 162 131 this.totalJobs = totalJobs; 163 132 } 164 133 165 public synchronized void setInputVideo(String inputVideo) { 166 syncInputVideo = inputVideo; 167 134 public synchronized void setJobDescription(final String jobDescription) { 168 135 Display.getDefault().syncExec(new Runnable() { 169 136 public void run() { 170 if (!ProgressDialog.this. inputVideo.isDisposed()) {171 ProgressDialog.this. inputVideo.setText(syncInputVideo);172 ProgressDialog.this. inputVideo.pack();137 if (!ProgressDialog.this.jobDescription.isDisposed()) { 138 ProgressDialog.this.jobDescription.setText(jobDescription); 139 ProgressDialog.this.jobDescription.pack(); 173 140 } 174 141 } … … 176 143 } 177 144 178 public synchronized void setOutputVideo(String outputVideo) { 179 syncOutputVideo = outputVideo; 180 145 public void setPercentComplete(final int percentComplete) { 181 146 Display.getDefault().syncExec(new Runnable() { 182 147 public void run() { 183 if (!ProgressDialog.this.outputVideo.isDisposed()) { 184 ProgressDialog.this.outputVideo.setText(syncOutputVideo); 185 ProgressDialog.this.outputVideo.pack(); 148 if (!progressBar.isDisposed()) 149 progressBar.setSelection(percentComplete); 150 } 151 }); 152 } 153 154 public void setSubdescription(final String subdescription) { 155 Display.getDefault().syncExec(new Runnable() { 156 public void run() { 157 if (!ProgressDialog.this.subdescription.isDisposed()) { 158 ProgressDialog.this.subdescription.setText(subdescription); 159 ProgressDialog.this.subdescription.pack(); 186 160 } 187 161 } … … 189 163 } 190 164 191 public synchronized void setPercentComplete(int percentComplete) { 192 syncPercentComplete = percentComplete; 193 165 public void setMiscellaneous1(final String miscellaneous1) { 194 166 Display.getDefault().syncExec(new Runnable() { 195 167 public void run() { 196 if (!progressBar.isDisposed()) 197 progressBar.setSelection(syncPercentComplete); 198 } 199 }); 200 } 201 202 public synchronized void setStatus(String status) { 203 syncStatus = status; 204 205 Display.getDefault().syncExec(new Runnable() { 206 public void run() { 207 if (!ProgressDialog.this.status.isDisposed()) { 208 ProgressDialog.this.status.setText(syncStatus); 209 ProgressDialog.this.status.pack(); 168 if (!ProgressDialog.this.miscellaneous1.isDisposed()) { 169 ProgressDialog.this.miscellaneous1.setText(miscellaneous1); 170 ProgressDialog.this.miscellaneous1.pack(); 210 171 } 211 172 } … … 213 174 } 214 175 215 public synchronized String getStatus() {176 public void setMiscellaneous2(final String miscellaneous2) { 216 177 Display.getDefault().syncExec(new Runnable() { 217 178 public void run() { 218 if (!status.isDisposed()) 219 syncStatus = status.getText(); 179 if (!ProgressDialog.this.miscellaneous2.isDisposed()) { 180 ProgressDialog.this.miscellaneous2.setText(miscellaneous2); 181 ProgressDialog.this.miscellaneous2.pack(); 182 } 220 183 } 221 184 }); 222 223 return syncStatus;224 185 } 225 186 }
Note: See TracChangeset
for help on using the changeset viewer.
