Ignore:
Timestamp:
04/13/07 19:28:10 (5 years ago)
Author:
jlee
Message:

New ProgressDialog?; new directory handling; DnD still needs to be fixed now; other job types still need work

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/thestaticvoid/iriverter/ProgressDialog.java

    r157 r158  
    3030public class ProgressDialog extends Dialog implements SelectionListener, ProgressDialogInfo { 
    3131        private Shell shell; 
    32         private Label header, inputVideoLabel, inputVideo, outputVideoLabel, outputVideo, status; 
     32        private Label header, jobDescription, subdescription, miscellaneous1, miscellaneous2; 
    3333        private ProgressBar progressBar; 
    34         private String syncInputVideo, syncOutputVideo, syncStatus; 
    3534        private Button dismiss; 
    36         private int currentJob, totalJobs, syncPercentComplete; 
     35        private int currentJob, totalJobs; 
    3736         
    3837        public ProgressDialog(Shell parent, int style) { 
     
    5150                 
    5251                header = new Label(shell, SWT.NONE); 
    53                 header.setText("Converting"); 
     52                header.setText("Job"); 
    5453                FontData[] fontData = header.getFont().getFontData(); 
    5554                fontData[0].setStyle(SWT.BOLD); 
     
    5958                header.setLayoutData(gridData); 
    6059                 
    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); 
    6275                gridLayout = new GridLayout(); 
    6376                gridLayout.horizontalSpacing = 6; 
     
    6578                gridLayout.marginHeight = 0; 
    6679                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)); 
    7082                 
    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); 
    9385                 
    9486                dismiss = new Button(shell, SWT.PUSH); 
     
    122114        } 
    123115         
    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) { 
    148117                this.currentJob = currentJob; 
    149118                 
     
    151120                        public void run() { 
    152121                                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); 
    155124                                        header.pack(); 
    156125                                } 
     
    159128        } 
    160129         
    161         public synchronized void setTotalJobs(int totalJobs) { 
     130        public void setTotalJobs(int totalJobs) { 
    162131                this.totalJobs = totalJobs; 
    163132        } 
    164133         
    165         public synchronized void setInputVideo(String inputVideo) { 
    166                 syncInputVideo = inputVideo; 
    167  
     134        public synchronized void setJobDescription(final String jobDescription) { 
    168135                Display.getDefault().syncExec(new Runnable() { 
    169136                        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(); 
    173140                                } 
    174141                        } 
     
    176143        } 
    177144         
    178         public synchronized void setOutputVideo(String outputVideo) { 
    179                 syncOutputVideo = outputVideo; 
    180                  
     145        public void setPercentComplete(final int percentComplete) { 
    181146                Display.getDefault().syncExec(new Runnable() { 
    182147                        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(); 
    186160                                } 
    187161                        } 
     
    189163        } 
    190164         
    191         public synchronized void setPercentComplete(int percentComplete) { 
    192                 syncPercentComplete = percentComplete; 
    193                  
     165        public void setMiscellaneous1(final String miscellaneous1) { 
    194166                Display.getDefault().syncExec(new Runnable() { 
    195167                        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(); 
    210171                                } 
    211172                        } 
     
    213174        } 
    214175         
    215         public synchronized String getStatus() {                 
     176        public void setMiscellaneous2(final String miscellaneous2) { 
    216177                Display.getDefault().syncExec(new Runnable() { 
    217178                        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                                } 
    220183                        } 
    221184                }); 
    222                  
    223                 return syncStatus; 
    224185        } 
    225186} 
Note: See TracChangeset for help on using the changeset viewer.