90 import org.symbian.tools.wrttools.util.CoreUtil; |
90 import org.symbian.tools.wrttools.util.CoreUtil; |
91 import org.symbian.tools.wrttools.util.ProjectUtils; |
91 import org.symbian.tools.wrttools.util.ProjectUtils; |
92 |
92 |
93 @SuppressWarnings({ "restriction", "unchecked", "rawtypes" }) |
93 @SuppressWarnings({ "restriction", "unchecked", "rawtypes" }) |
94 public class WrtProjectLocationWizardPage extends WizardPage implements IOverwriteQuery { |
94 public class WrtProjectLocationWizardPage extends WizardPage implements IOverwriteQuery { |
95 |
|
96 /** |
|
97 * @since 3.5 |
|
98 * |
|
99 */ |
|
100 private final class ProjectLabelProvider extends LabelProvider implements IColorProvider { |
95 private final class ProjectLabelProvider extends LabelProvider implements IColorProvider { |
101 |
|
102 public Color getBackground(Object element) { |
96 public Color getBackground(Object element) { |
103 return null; |
97 return null; |
104 } |
98 } |
105 |
99 |
106 public Color getForeground(Object element) { |
100 public Color getForeground(Object element) { |
130 |
124 |
131 // Keep track of the directory that we browsed to last time |
125 // Keep track of the directory that we browsed to last time |
132 // the wizard was invoked. |
126 // the wizard was invoked. |
133 private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$ |
127 private static String previouslyBrowsedDirectory = ""; //$NON-NLS-1$ |
134 |
128 |
135 private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$ |
129 private static final String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$ |
136 |
130 |
137 private Text archivePathField; |
131 private Text archivePathField; |
138 |
|
139 private Button browseArchivesButton; |
132 private Button browseArchivesButton; |
140 |
|
141 private Button browseDirectoriesButton; |
133 private Button browseDirectoriesButton; |
142 |
134 private List createdProjects; |
143 List createdProjects; |
|
144 |
|
145 private Text directoryPathField; |
135 private Text directoryPathField; |
146 |
136 |
147 // The last time that the file or folder at the selected path was modified |
137 // The last time that the file or folder at the selected path was modified |
148 // to mimize searches |
138 // to mimize searches |
149 private long lastModified; |
139 private long lastModified; |
419 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
402 GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true); |
420 gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25); |
403 gridData.widthHint = new PixelConverter(projectsList.getControl()).convertWidthInCharsToPixels(25); |
421 gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10); |
404 gridData.heightHint = new PixelConverter(projectsList.getControl()).convertHeightInCharsToPixels(10); |
422 projectsList.getControl().setLayoutData(gridData); |
405 projectsList.getControl().setLayoutData(gridData); |
423 projectsList.setContentProvider(new ITreeContentProvider() { |
406 projectsList.setContentProvider(new ITreeContentProvider() { |
424 |
|
425 /* |
|
426 * (non-Javadoc) |
|
427 * |
|
428 * @see org.eclipse.jface.viewers.IContentProvider#dispose() |
|
429 */ |
|
430 public void dispose() { |
407 public void dispose() { |
431 |
408 } |
432 } |
|
433 |
|
434 /* |
|
435 * (non-Javadoc) |
|
436 * |
|
437 * @see |
|
438 * org.eclipse.jface.viewers.ITreeContentProvider#getChildren(java |
|
439 * .lang.Object) |
|
440 */ |
|
441 public Object[] getChildren(Object parentElement) { |
409 public Object[] getChildren(Object parentElement) { |
442 return null; |
410 return null; |
443 } |
411 } |
444 |
412 |
445 /* |
|
446 * (non-Javadoc) |
|
447 * |
|
448 * @see |
|
449 * org.eclipse.jface.viewers.IStructuredContentProvider#getElements |
|
450 * (java.lang.Object) |
|
451 */ |
|
452 public Object[] getElements(Object inputElement) { |
413 public Object[] getElements(Object inputElement) { |
453 return getProjectRecords(); |
414 return getProjectRecords(); |
454 } |
415 } |
455 |
416 |
456 /* |
|
457 * (non-Javadoc) |
|
458 * |
|
459 * @see |
|
460 * org.eclipse.jface.viewers.ITreeContentProvider#getParent(java |
|
461 * .lang.Object) |
|
462 */ |
|
463 public Object getParent(Object element) { |
417 public Object getParent(Object element) { |
464 return null; |
418 return null; |
465 } |
419 } |
466 |
420 |
467 /* |
|
468 * (non-Javadoc) |
|
469 * |
|
470 * @see |
|
471 * org.eclipse.jface.viewers.ITreeContentProvider#hasChildren(java |
|
472 * .lang.Object) |
|
473 */ |
|
474 public boolean hasChildren(Object element) { |
421 public boolean hasChildren(Object element) { |
475 return false; |
422 return false; |
476 } |
423 } |
477 |
424 |
478 /* |
|
479 * (non-Javadoc) |
|
480 * |
|
481 * @see |
|
482 * org.eclipse.jface.viewers.IContentProvider#inputChanged(org.eclipse |
|
483 * .jface.viewers.Viewer, java.lang.Object, java.lang.Object) |
|
484 */ |
|
485 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
425 public void inputChanged(Viewer viewer, Object oldInput, Object newInput) { |
486 } |
426 } |
487 |
427 |
488 }); |
428 }); |
489 |
429 |
490 projectsList.setLabelProvider(new ProjectLabelProvider()); |
430 projectsList.setLabelProvider(new ProjectLabelProvider()); |
491 |
431 |
492 projectsList.addCheckStateListener(new ICheckStateListener() { |
432 projectsList.addCheckStateListener(new ICheckStateListener() { |
493 /* |
|
494 * (non-Javadoc) |
|
495 * |
|
496 * @see |
|
497 * org.eclipse.jface.viewers.ICheckStateListener#checkStateChanged |
|
498 * (org.eclipse.jface.viewers.CheckStateChangedEvent) |
|
499 */ |
|
500 public void checkStateChanged(CheckStateChangedEvent event) { |
433 public void checkStateChanged(CheckStateChangedEvent event) { |
501 ProjectRecord element = (ProjectRecord) event.getElement(); |
434 ProjectRecord element = (ProjectRecord) event.getElement(); |
502 if (element.hasConflicts()) { |
435 if (element.hasConflicts()) { |
503 projectsList.setChecked(element, false); |
436 projectsList.setChecked(element, false); |
504 } |
437 } |
563 projectFromDirectoryRadio.setSelection(true); |
496 projectFromDirectoryRadio.setSelection(true); |
564 archivePathField.setEnabled(false); |
497 archivePathField.setEnabled(false); |
565 browseArchivesButton.setEnabled(false); |
498 browseArchivesButton.setEnabled(false); |
566 |
499 |
567 browseDirectoriesButton.addSelectionListener(new SelectionAdapter() { |
500 browseDirectoriesButton.addSelectionListener(new SelectionAdapter() { |
568 /* |
|
569 * (non-Javadoc) |
|
570 * |
|
571 * @see org.eclipse.swt.events.SelectionAdapter#widgetS |
|
572 * elected(org.eclipse.swt.events.SelectionEvent) |
|
573 */ |
|
574 public void widgetSelected(SelectionEvent e) { |
501 public void widgetSelected(SelectionEvent e) { |
575 handleLocationDirectoryButtonPressed(); |
502 handleLocationDirectoryButtonPressed(); |
576 } |
503 } |
577 |
504 |
578 }); |
505 }); |
579 |
506 |
580 browseArchivesButton.addSelectionListener(new SelectionAdapter() { |
507 browseArchivesButton.addSelectionListener(new SelectionAdapter() { |
581 /* |
|
582 * (non-Javadoc) |
|
583 * |
|
584 * @see |
|
585 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
586 * .swt.events.SelectionEvent) |
|
587 */ |
|
588 public void widgetSelected(SelectionEvent e) { |
508 public void widgetSelected(SelectionEvent e) { |
589 handleLocationArchiveButtonPressed(); |
509 handleLocationArchiveButtonPressed(); |
590 } |
510 } |
591 |
511 |
592 }); |
512 }); |
593 |
513 |
594 directoryPathField.addTraverseListener(new TraverseListener() { |
514 directoryPathField.addTraverseListener(new TraverseListener() { |
595 |
|
596 /* |
|
597 * (non-Javadoc) |
|
598 * |
|
599 * @see |
|
600 * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse |
|
601 * .swt.events.TraverseEvent) |
|
602 */ |
|
603 public void keyTraversed(TraverseEvent e) { |
515 public void keyTraversed(TraverseEvent e) { |
604 if (e.detail == SWT.TRAVERSE_RETURN) { |
516 if (e.detail == SWT.TRAVERSE_RETURN) { |
605 e.doit = false; |
517 e.doit = false; |
606 updateProjectsList(directoryPathField.getText().trim()); |
518 updateProjectsList(directoryPathField.getText().trim()); |
607 } |
519 } |
608 } |
520 } |
609 |
|
610 }); |
521 }); |
611 |
522 |
612 directoryPathField.addFocusListener(new FocusAdapter() { |
523 directoryPathField.addFocusListener(new FocusAdapter() { |
613 |
|
614 /* |
|
615 * (non-Javadoc) |
|
616 * |
|
617 * @see |
|
618 * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt |
|
619 * .events.FocusEvent) |
|
620 */ |
|
621 public void focusLost(org.eclipse.swt.events.FocusEvent e) { |
524 public void focusLost(org.eclipse.swt.events.FocusEvent e) { |
622 updateProjectsList(directoryPathField.getText().trim()); |
525 updateProjectsList(directoryPathField.getText().trim()); |
623 } |
526 } |
624 |
527 |
625 }); |
528 }); |
626 |
529 |
627 archivePathField.addTraverseListener(new TraverseListener() { |
530 archivePathField.addTraverseListener(new TraverseListener() { |
628 |
|
629 /* |
|
630 * (non-Javadoc) |
|
631 * |
|
632 * @see |
|
633 * org.eclipse.swt.events.TraverseListener#keyTraversed(org.eclipse |
|
634 * .swt.events.TraverseEvent) |
|
635 */ |
|
636 public void keyTraversed(TraverseEvent e) { |
531 public void keyTraversed(TraverseEvent e) { |
637 if (e.detail == SWT.TRAVERSE_RETURN) { |
532 if (e.detail == SWT.TRAVERSE_RETURN) { |
638 e.doit = false; |
533 e.doit = false; |
639 updateProjectsList(archivePathField.getText().trim()); |
534 updateProjectsList(archivePathField.getText().trim()); |
640 } |
535 } |
641 } |
536 } |
642 |
537 |
643 }); |
538 }); |
644 |
539 |
645 archivePathField.addFocusListener(new FocusAdapter() { |
540 archivePathField.addFocusListener(new FocusAdapter() { |
646 /* |
|
647 * (non-Javadoc) |
|
648 * |
|
649 * @see |
|
650 * org.eclipse.swt.events.FocusListener#focusLost(org.eclipse.swt |
|
651 * .events.FocusEvent) |
|
652 */ |
|
653 public void focusLost(org.eclipse.swt.events.FocusEvent e) { |
541 public void focusLost(org.eclipse.swt.events.FocusEvent e) { |
654 updateProjectsList(archivePathField.getText().trim()); |
542 updateProjectsList(archivePathField.getText().trim()); |
655 } |
543 } |
656 }); |
544 }); |
657 |
545 |
658 projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() { |
546 projectFromDirectoryRadio.addSelectionListener(new SelectionAdapter() { |
659 /* |
|
660 * (non-Javadoc) |
|
661 * |
|
662 * @see |
|
663 * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse |
|
664 * .swt.events.SelectionEvent) |
|
665 */ |
|
666 public void widgetSelected(SelectionEvent e) { |
547 public void widgetSelected(SelectionEvent e) { |
667 directoryRadioSelected(); |
548 directoryRadioSelected(); |
668 } |
549 } |
669 }); |
550 }); |
670 |
551 |
671 projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() { |
552 projectFromArchiveRadio.addSelectionListener(new SelectionAdapter() { |
672 /* |
|
673 * (non-Javadoc) |
|
674 * |
|
675 * @see |
|
676 * org.eclipse.swt.events.SelectionListener#widgetSelected(org.eclipse |
|
677 * .swt.events.SelectionEvent) |
|
678 */ |
|
679 public void widgetSelected(SelectionEvent e) { |
553 public void widgetSelected(SelectionEvent e) { |
680 archiveRadioSelected(); |
554 archiveRadioSelected(); |
681 } |
555 } |
682 }); |
556 }); |
683 } |
557 } |
684 |
558 |
685 /** |
559 /** |
686 * Create the selection buttons in the listComposite. |
560 * Create the selection buttons in the listComposite. |
687 * |
561 * |
688 * @param listComposite |
562 * @param listComposite |
689 */ |
563 */ |
690 private void createSelectionButtons(Composite listComposite) { |
564 private void createSelectionButtons(Composite listComposite) { |
691 Composite buttonsComposite = new Composite(listComposite, SWT.NONE); |
565 Composite buttonsComposite = new Composite(listComposite, SWT.NONE); |
692 GridLayout layout = new GridLayout(); |
566 GridLayout layout = new GridLayout(); |
714 setButtonLayoutData(selectAll); |
588 setButtonLayoutData(selectAll); |
715 |
589 |
716 Button deselectAll = new Button(buttonsComposite, SWT.PUSH); |
590 Button deselectAll = new Button(buttonsComposite, SWT.PUSH); |
717 deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll); |
591 deselectAll.setText(DataTransferMessages.DataTransfer_deselectAll); |
718 deselectAll.addSelectionListener(new SelectionAdapter() { |
592 deselectAll.addSelectionListener(new SelectionAdapter() { |
719 /* |
|
720 * (non-Javadoc) |
|
721 * |
|
722 * @see |
|
723 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
724 * .swt.events.SelectionEvent) |
|
725 */ |
|
726 public void widgetSelected(SelectionEvent e) { |
593 public void widgetSelected(SelectionEvent e) { |
727 |
|
728 projectsList.setCheckedElements(new Object[0]); |
594 projectsList.setCheckedElements(new Object[0]); |
729 setPageComplete(false); |
595 setPageComplete(false); |
730 } |
596 } |
731 }); |
597 }); |
732 Dialog.applyDialogFont(deselectAll); |
598 Dialog.applyDialogFont(deselectAll); |
733 setButtonLayoutData(deselectAll); |
599 setButtonLayoutData(deselectAll); |
734 |
600 |
735 Button refresh = new Button(buttonsComposite, SWT.PUSH); |
601 Button refresh = new Button(buttonsComposite, SWT.PUSH); |
736 refresh.setText(DataTransferMessages.DataTransfer_refresh); |
602 refresh.setText(DataTransferMessages.DataTransfer_refresh); |
737 refresh.addSelectionListener(new SelectionAdapter() { |
603 refresh.addSelectionListener(new SelectionAdapter() { |
738 /* |
|
739 * (non-Javadoc) |
|
740 * |
|
741 * @see |
|
742 * org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse |
|
743 * .swt.events.SelectionEvent) |
|
744 */ |
|
745 public void widgetSelected(SelectionEvent e) { |
604 public void widgetSelected(SelectionEvent e) { |
746 if (projectFromDirectoryRadio.getSelection()) { |
605 if (projectFromDirectoryRadio.getSelection()) { |
747 updateProjectsList(directoryPathField.getText().trim()); |
606 updateProjectsList(directoryPathField.getText().trim()); |
748 } else { |
607 } else { |
749 updateProjectsList(archivePathField.getText().trim()); |
608 updateProjectsList(archivePathField.getText().trim()); |
794 /** |
653 /** |
795 * Get the array of project records that can be imported from the source |
654 * Get the array of project records that can be imported from the source |
796 * workspace or archive, selected by the user. If a project with the same |
655 * workspace or archive, selected by the user. If a project with the same |
797 * name exists in both the source workspace and the current workspace, then |
656 * name exists in both the source workspace and the current workspace, then |
798 * the hasConflicts flag would be set on that project record. |
657 * the hasConflicts flag would be set on that project record. |
799 * |
658 * |
800 * Method declared public for test suite. |
659 * Method declared public for test suite. |
801 * |
660 * |
802 * @return ProjectRecord[] array of projects that can be imported into the |
661 * @return ProjectRecord[] array of projects that can be imported into the |
803 * workspace |
662 * workspace |
804 */ |
663 */ |
805 public ProjectRecord[] getProjectRecords() { |
664 public ProjectRecord[] getProjectRecords() { |
806 List projectRecords = new ArrayList(); |
665 List projectRecords = new ArrayList(); |
1102 // We can't access the radio button from the inner class so get the |
961 // We can't access the radio button from the inner class so get the |
1103 // status beforehand |
962 // status beforehand |
1104 final boolean dirSelected = this.projectFromDirectoryRadio.getSelection(); |
963 final boolean dirSelected = this.projectFromDirectoryRadio.getSelection(); |
1105 try { |
964 try { |
1106 getContainer().run(true, true, new IRunnableWithProgress() { |
965 getContainer().run(true, true, new IRunnableWithProgress() { |
1107 |
|
1108 /* |
|
1109 * (non-Javadoc) |
|
1110 * |
|
1111 * @see |
|
1112 * org.eclipse.jface.operation.IRunnableWithProgress#run(org |
|
1113 * .eclipse.core.runtime.IProgressMonitor) |
|
1114 */ |
|
1115 public void run(IProgressMonitor monitor) { |
966 public void run(IProgressMonitor monitor) { |
1116 |
967 |
1117 monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100); |
968 monitor.beginTask(DataTransferMessages.WizardProjectsImportPage_SearchingMessage, 100); |
1118 selectedProjects = new ProjectRecord[0]; |
969 selectedProjects = new ProjectRecord[0]; |
1119 Collection files = new ArrayList(); |
970 Collection files = new ArrayList(); |
1155 monitor.worked(50); |
1006 monitor.worked(50); |
1156 monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); |
1007 monitor.subTask(DataTransferMessages.WizardProjectsImportPage_ProcessingMessage); |
1157 while (filesIterator.hasNext()) { |
1008 while (filesIterator.hasNext()) { |
1158 selectedProjects[index++] = (ProjectRecord) filesIterator.next(); |
1009 selectedProjects[index++] = (ProjectRecord) filesIterator.next(); |
1159 } |
1010 } |
1160 } |
1011 } else if (dirSelected && directory.isDirectory()) { |
1161 |
|
1162 else if (dirSelected && directory.isDirectory()) { |
|
1163 |
|
1164 if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) { |
1012 if (!collectProjectFilesFromDirectory(files, directory, null, monitor)) { |
1165 return; |
1013 return; |
1166 } |
1014 } |
1167 Iterator filesIterator = files.iterator(); |
1015 Iterator filesIterator = files.iterator(); |
1168 selectedProjects = new ProjectRecord[files.size()]; |
1016 selectedProjects = new ProjectRecord[files.size()]; |