|
From: Matthias K <mat...@us...> - 2006-04-26 16:39:23
|
Update of /cvsroot/jcommander/plugins/org.jcommander.ui.filepanel/src/org/jcommander/ui/filepanel/performers In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3053/src/org/jcommander/ui/filepanel/performers Modified Files: FileCopyPerformer.java FileDeletePerformer.java Log Message: first part of migration to JFace dialogs Index: FileCopyPerformer.java =================================================================== RCS file: /cvsroot/jcommander/plugins/org.jcommander.ui.filepanel/src/org/jcommander/ui/filepanel/performers/FileCopyPerformer.java,v retrieving revision 1.34 retrieving revision 1.35 diff -C2 -d -r1.34 -r1.35 *** FileCopyPerformer.java 17 Apr 2006 21:31:00 -0000 1.34 --- FileCopyPerformer.java 26 Apr 2006 16:39:19 -0000 1.35 *************** *** 31,42 **** public class FileCopyPerformer { protected TabMediator mediator; ! protected Shell confirmDialog; protected Shell progressDialog; ! protected CopyConfirmDialogComposite confirmDialogComposite; protected CopyProgressDialogComposite progressDialogComposite; ! protected static final int NO_OPTION = 0; ! protected static final int OK_OPTION = 1; ! protected static final int CANCEL_OPTION = 2; protected int selectedOption; --- 31,43 ---- public class FileCopyPerformer { protected TabMediator mediator; ! //protected Shell confirmDialog; ! protected CopyConfirmDialog confirmDialog; protected Shell progressDialog; ! //protected CopyConfirmDialogComposite confirmDialogComposite; protected CopyProgressDialogComposite progressDialogComposite; ! //protected static final int NO_OPTION = 0; ! //protected static final int OK_OPTION = 1; ! //protected static final int CANCEL_OPTION = 2; protected int selectedOption; *************** *** 118,122 **** }); ! waitForUserChoice(); } --- 119,123 ---- }); ! //waitForUserChoice(); } *************** *** 209,213 **** files = predefinedSourceFiles; } ! String[] names = confirmDialogComposite.getSelectionList().getItems(); Vector buffer = new Vector(); if(names != null) { --- 210,214 ---- files = predefinedSourceFiles; } ! String[] names = confirmDialog.getNames(); Vector buffer = new Vector(); if(names != null) { *************** *** 222,225 **** --- 223,227 ---- for(int i = 0; i < buffer.size(); i++) sourceFiles[i] = (FileObject)buffer.get(i); + selectedOption = confirmDialog.getReturnCode(); } }); *************** *** 227,240 **** sourceFiles = mediator.getFileTab().getActiveFilePanel().getFileControl().getSelectedFiles(); ! selectedOption = OK_OPTION; } ! if(selectedOption == OK_OPTION) { // Display copy progress dialog EclipseBroker.getDisplay().syncExec(new Runnable() { public void run() { ! if(confirmDialog != null && !confirmDialog.isDisposed()) { ! confirmDialog.setVisible(false); ! } showProgressDialog(); --- 229,242 ---- sourceFiles = mediator.getFileTab().getActiveFilePanel().getFileControl().getSelectedFiles(); ! selectedOption = IDialogConstants.OK_ID; } ! if(selectedOption == IDialogConstants.OK_ID) { // Display copy progress dialog EclipseBroker.getDisplay().syncExec(new Runnable() { public void run() { ! // if(confirmDialog != null && !confirmDialog.isDisposed()) { ! // confirmDialog.setVisible(false); ! // } showProgressDialog(); *************** *** 253,265 **** performCopy(); ! }else { ! EclipseBroker.getDisplay().syncExec(new Runnable() { ! public void run() { ! if(confirmDialog != null && !confirmDialog.isDisposed()) { ! confirmDialog.setVisible(false); ! } ! } ! }); ! } } --- 255,267 ---- performCopy(); ! }//else { ! // EclipseBroker.getDisplay().syncExec(new Runnable() { ! // public void run() { ! // if(confirmDialog != null && !confirmDialog.isDisposed()) { ! // confirmDialog.setVisible(false); ! // } ! // } ! // }); ! // } } *************** *** 456,472 **** Shell shell = EclipseBroker.getShell(); ! final SelectionAdapter cancelButtonSelectionAdapter = new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! resumeOperationThread = true; ! selectedOption = CANCEL_OPTION; ! ! synchronized (workerLock) { ! workerLock.notifyAll(); ! } ! } ! }; ! confirmDialog = Utils.createOperationDialog(shell, mediator); ! confirmDialogComposite = new CopyConfirmDialogComposite(confirmDialog, SWT.NONE); FileObject[] sourceFiles = null; --- 458,464 ---- Shell shell = EclipseBroker.getShell(); ! confirmDialog = new CopyConfirmDialog(shell); ! confirmDialog.create(); FileObject[] sourceFiles = null; *************** *** 480,484 **** } ! List copyList = confirmDialogComposite.getSelectionList(); for(int i=0;i<sourceFiles.length;i++) { --- 472,476 ---- } ! List copyList = confirmDialog.getSelectionList(); for(int i=0;i<sourceFiles.length;i++) { *************** *** 486,513 **** } ! confirmDialog.setDefaultButton(confirmDialogComposite.getOkButton()); ! confirmDialog.addShellListener(new ShellAdapter() { ! public void shellClosed(ShellEvent e) { ! cancelButtonSelectionAdapter.widgetSelected(null); ! } ! }); ! ! confirmDialogComposite.getOkButton().addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! keepSelected = confirmDialogComposite.isKeptSelected(); ! resumeOperationThread = true; ! selectedOption = OK_OPTION; ! ! synchronized (workerLock) { ! workerLock.notifyAll(); ! } ! } ! }); ! ! confirmDialogComposite.selectDeleteCheckBox(deleteSourceFiles); ! ! confirmDialogComposite.getCancelButton().addSelectionListener(cancelButtonSelectionAdapter); ! ! Utils.accomodateComposite(confirmDialogComposite); FilePanel targetPanel = null; --- 478,482 ---- } ! confirmDialog.selectDeleteCheckBox(deleteSourceFiles); FilePanel targetPanel = null; *************** *** 524,543 **** .getCurrentParent(); ! //confirmDialogComposite.getCopyTarget().setText(targetDir.getName().getRootURI() + targetDir.getName().getPath()); ! confirmDialogComposite.setCopyTarget(VfsManagerExtension.getDisplayablePath(targetDir));//targetDir.getName().getRootURI() + targetDir.getName().getPath()); if(predefinedSourceFiles != null) { ! confirmDialogComposite.getKeepSelectedCheckBox().setEnabled(false); ! confirmDialogComposite.getDeleteCheckBox().setEnabled(false); } if (deleteSourceFiles) { ! confirmDialog.setText("Confirm Move Operation"); } ! else confirmDialog.setText("Confirm Copy Operation"); ! WindowUtils.pack(confirmDialog); ! WindowUtils.centerRelativeTo(confirmDialog, shell); ! confirmDialog.setVisible(true); ! confirmDialog.setActive(); } --- 493,512 ---- .getCurrentParent(); ! confirmDialog.setCopyTarget(VfsManagerExtension.getDisplayablePath(targetDir));//targetDir.getName().getRootURI() + targetDir.getName().getPath()); if(predefinedSourceFiles != null) { ! confirmDialog.getKeepSelectedCheckBox().setEnabled(false); ! confirmDialog.getDeleteCheckBox().setEnabled(false); } if (deleteSourceFiles) { ! confirmDialog.getShell().setText("Confirm Move Operation"); } ! else confirmDialog.getShell().setText("Confirm Copy Operation"); ! //WindowUtils.pack(confirmDialog); ! //WindowUtils.centerRelativeTo(confirmDialog, shell); ! //confirmDialog.setVisible(true); ! //confirmDialog.setActive(); ! confirmDialog.open(); } Index: FileDeletePerformer.java =================================================================== RCS file: /cvsroot/jcommander/plugins/org.jcommander.ui.filepanel/src/org/jcommander/ui/filepanel/performers/FileDeletePerformer.java,v retrieving revision 1.17 retrieving revision 1.18 diff -C2 -d -r1.17 -r1.18 *** FileDeletePerformer.java 17 Apr 2006 14:53:59 -0000 1.17 --- FileDeletePerformer.java 26 Apr 2006 16:39:19 -0000 1.18 *************** *** 8,12 **** import org.apache.commons.vfs.*; import org.apache.commons.vfs.provider.local.LocalFile; ! import org.eclipse.jface.preference.IPreferenceStore; import org.eclipse.swt.*; import org.eclipse.swt.events.*; --- 8,12 ---- import org.apache.commons.vfs.*; import org.apache.commons.vfs.provider.local.LocalFile; ! import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.*; import org.eclipse.swt.events.*; *************** *** 32,40 **** protected Shell progressDialog; protected DeleteConfirmDialogComposite confirmDialogComposite; protected DeleteProgressDialogComposite progressDialogComposite; ! protected static final int NO_OPTION = 0; ! protected static final int OK_OPTION = 1; ! protected static final int CANCEL_OPTION = 2; protected int selectedOption; --- 32,41 ---- protected Shell progressDialog; protected DeleteConfirmDialogComposite confirmDialogComposite; + protected DeleteConfirmDialog dialog; protected DeleteProgressDialogComposite progressDialogComposite; ! // protected static final int NO_OPTION = 0; ! // protected static final int OK_OPTION = 1; ! // protected static final int CANCEL_OPTION = 2; protected int selectedOption; *************** *** 42,46 **** protected boolean resumeOperationThread; protected Thread operationThread; ! private Object workerLock = new Object(); protected int totalFiles; --- 43,47 ---- protected boolean resumeOperationThread; protected Thread operationThread; ! //private Object workerLock = new Object(); protected int totalFiles; *************** *** 89,93 **** }); ! waitForUserChoice(); EclipseBroker.getDisplay().syncExec(new Runnable() { --- 90,94 ---- }); ! //waitForUserChoice(); EclipseBroker.getDisplay().syncExec(new Runnable() { *************** *** 96,100 **** .getFileControl() .getSelectedFiles(); ! String[] names = confirmDialogComposite.getDeleteFileList().getItems(); Vector buffer = new Vector(); if(names != null) { --- 97,101 ---- .getFileControl() .getSelectedFiles(); ! String[] names = dialog.getNames(); Vector buffer = new Vector(); if(names != null) { *************** *** 112,121 **** }); ! if(selectedOption == OK_OPTION) { // Display delete progress dialog EclipseBroker.getDisplay().syncExec(new Runnable() { public void run() { - confirmDialog.setVisible(false); - showProgressDialog(); } --- 113,120 ---- }); ! if(dialog.getReturnCode()==IDialogConstants.YES_ID) { // Display delete progress dialog EclipseBroker.getDisplay().syncExec(new Runnable() { public void run() { showProgressDialog(); } *************** *** 130,141 **** } }); - }else { - EclipseBroker.getDisplay().syncExec(new Runnable() { - public void run() { - if(!confirmDialog.isDisposed()) { - confirmDialog.setVisible(false); - } - } - }); } } --- 129,132 ---- *************** *** 258,275 **** } ! /** ! * ! */ ! protected void waitForUserChoice() { ! resumeOperationThread = false; ! ! while(!resumeOperationThread) { ! synchronized (workerLock) { ! try { ! workerLock.wait(); ! }catch(InterruptedException ex) {} ! } ! } ! } /** --- 249,266 ---- } ! // /** ! // * ! // */ ! // protected void waitForUserChoice() { ! // resumeOperationThread = false; ! // ! // while(!resumeOperationThread) { ! // synchronized (workerLock) { ! // try { ! // workerLock.wait(); ! // }catch(InterruptedException ex) {} ! // } ! // } ! // } /** *************** *** 277,336 **** */ protected void showConfirmDialog() { Shell shell = EclipseBroker.getShell(); ! final SelectionAdapter cancelButtonSelectionAdapter = new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! resumeOperationThread = true; ! selectedOption = CANCEL_OPTION; ! ! synchronized (workerLock) { ! workerLock.notifyAll(); ! } ! } ! }; ! confirmDialog = Utils.createOperationDialog(shell, mediator); ! confirmDialog.setText("Delete files"); ! confirmDialogComposite = new DeleteConfirmDialogComposite(confirmDialog, SWT.NONE); FileObject[] sourceFiles = sourcePanel ! .getFileControl() ! .getSelectedFiles(); ! List deleteFilesList = confirmDialogComposite.getDeleteFileList(); ! for(int i=0;i<sourceFiles.length;i++) { deleteFilesList.add(sourceFiles[i].getName().getBaseName()); if(moveToRecycle && !(sourceFiles[i] instanceof LocalFile)) { moveToRecycle = false; ! confirmDialogComposite.disableMoveToRecycle(); } } ! confirmDialog.setDefaultButton(confirmDialogComposite.getNoButton()); ! confirmDialog.addShellListener(new ShellAdapter() { ! public void shellClosed(ShellEvent e) { ! cancelButtonSelectionAdapter.widgetSelected(null); ! } ! }); ! ! confirmDialogComposite.getYesButton().addSelectionListener(new SelectionAdapter() { ! public void widgetSelected(SelectionEvent e) { ! resumeOperationThread = true; ! selectedOption = OK_OPTION; ! ! synchronized (workerLock) { ! workerLock.notifyAll(); ! } ! } ! }); ! ! confirmDialogComposite.getNoButton().addSelectionListener(cancelButtonSelectionAdapter); ! Utils.accomodateComposite(confirmDialogComposite); ! WindowUtils.pack(confirmDialog); ! WindowUtils.centerRelativeTo(confirmDialog, shell); ! confirmDialog.setVisible(true); ! confirmDialog.setActive(); } } --- 268,353 ---- */ protected void showConfirmDialog() { + Shell shell = EclipseBroker.getShell(); ! dialog = new DeleteConfirmDialog(shell); ! dialog.create(); FileObject[] sourceFiles = sourcePanel ! .getFileControl() ! .getSelectedFiles(); ! List deleteFilesList = dialog.getDeleteFileList(); ! for(int i=0;i<sourceFiles.length;i++) { deleteFilesList.add(sourceFiles[i].getName().getBaseName()); if(moveToRecycle && !(sourceFiles[i] instanceof LocalFile)) { moveToRecycle = false; ! dialog.disableMoveToRecycle(); } } ! dialog.open(); ! //dialog.getr ! // /////////////// ! // ! // Shell shell = EclipseBroker.getShell(); ! // ! // final SelectionAdapter cancelButtonSelectionAdapter = new SelectionAdapter() { ! // public void widgetSelected(SelectionEvent e) { ! // resumeOperationThread = true; ! // selectedOption = CANCEL_OPTION; ! // ! // synchronized (workerLock) { ! // workerLock.notifyAll(); ! // } ! // } ! // }; ! // ! // confirmDialog = Utils.createOperationDialog(shell, mediator); ! // confirmDialog.setText("Delete files"); ! // confirmDialogComposite = new DeleteConfirmDialogComposite(confirmDialog, SWT.NONE); ! // ! // FileObject[] sourceFiles = sourcePanel ! // .getFileControl() ! // .getSelectedFiles(); ! // List deleteFilesList = confirmDialogComposite.getDeleteFileList(); ! // ! // for(int i=0;i<sourceFiles.length;i++) { ! // deleteFilesList.add(sourceFiles[i].getName().getBaseName()); ! // if(moveToRecycle && !(sourceFiles[i] instanceof LocalFile)) { ! // moveToRecycle = false; ! // confirmDialogComposite.disableMoveToRecycle(); ! // } ! // } ! // ! // confirmDialog.setDefaultButton(confirmDialogComposite.getNoButton()); ! // confirmDialog.addShellListener(new ShellAdapter() { ! // public void shellClosed(ShellEvent e) { ! // cancelButtonSelectionAdapter.widgetSelected(null); ! // } ! // }); ! // ! // confirmDialogComposite.getYesButton().addSelectionListener(new SelectionAdapter() { ! // public void widgetSelected(SelectionEvent e) { ! // resumeOperationThread = true; ! // selectedOption = OK_OPTION; ! // ! // synchronized (workerLock) { ! // workerLock.notifyAll(); ! // } ! // } ! // }); ! // ! // confirmDialogComposite.getNoButton().addSelectionListener(cancelButtonSelectionAdapter); ! // ! // Utils.accomodateComposite(confirmDialogComposite); ! // ! // WindowUtils.pack(confirmDialog); ! // WindowUtils.centerRelativeTo(confirmDialog, shell); ! // confirmDialog.setVisible(true); ! // confirmDialog.setActive(); } } |