Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 400399 | Differences between
and this patch

Collapse All | Expand All

(-)a/bundles/org.eclipse.ui.ide/src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java (-99 / +66 lines)
Lines 51-59 Link Here
51
import org.eclipse.core.runtime.SubProgressMonitor;
51
import org.eclipse.core.runtime.SubProgressMonitor;
52
import org.eclipse.jface.dialogs.Dialog;
52
import org.eclipse.jface.dialogs.Dialog;
53
import org.eclipse.jface.dialogs.ErrorDialog;
53
import org.eclipse.jface.dialogs.ErrorDialog;
54
import org.eclipse.jface.dialogs.IDialogConstants;
55
import org.eclipse.jface.dialogs.IDialogSettings;
54
import org.eclipse.jface.dialogs.IDialogSettings;
56
import org.eclipse.jface.dialogs.MessageDialog;
57
import org.eclipse.jface.layout.PixelConverter;
55
import org.eclipse.jface.layout.PixelConverter;
58
import org.eclipse.jface.operation.IRunnableWithProgress;
56
import org.eclipse.jface.operation.IRunnableWithProgress;
59
import org.eclipse.jface.viewers.CheckStateChangedEvent;
57
import org.eclipse.jface.viewers.CheckStateChangedEvent;
Lines 65-71 Link Here
65
import org.eclipse.jface.viewers.LabelProvider;
63
import org.eclipse.jface.viewers.LabelProvider;
66
import org.eclipse.jface.viewers.Viewer;
64
import org.eclipse.jface.viewers.Viewer;
67
import org.eclipse.jface.viewers.ViewerComparator;
65
import org.eclipse.jface.viewers.ViewerComparator;
68
import org.eclipse.jface.wizard.WizardPage;
69
import org.eclipse.osgi.util.NLS;
66
import org.eclipse.osgi.util.NLS;
70
import org.eclipse.swt.SWT;
67
import org.eclipse.swt.SWT;
71
import org.eclipse.swt.events.FocusAdapter;
68
import org.eclipse.swt.events.FocusAdapter;
Lines 74-94 Link Here
74
import org.eclipse.swt.events.TraverseEvent;
71
import org.eclipse.swt.events.TraverseEvent;
75
import org.eclipse.swt.events.TraverseListener;
72
import org.eclipse.swt.events.TraverseListener;
76
import org.eclipse.swt.graphics.Color;
73
import org.eclipse.swt.graphics.Color;
74
import org.eclipse.swt.graphics.Point;
77
import org.eclipse.swt.layout.GridData;
75
import org.eclipse.swt.layout.GridData;
78
import org.eclipse.swt.layout.GridLayout;
76
import org.eclipse.swt.layout.GridLayout;
79
import org.eclipse.swt.widgets.Button;
77
import org.eclipse.swt.widgets.Button;
78
import org.eclipse.swt.widgets.Combo;
80
import org.eclipse.swt.widgets.Composite;
79
import org.eclipse.swt.widgets.Composite;
81
import org.eclipse.swt.widgets.DirectoryDialog;
80
import org.eclipse.swt.widgets.DirectoryDialog;
81
import org.eclipse.swt.widgets.Event;
82
import org.eclipse.swt.widgets.FileDialog;
82
import org.eclipse.swt.widgets.FileDialog;
83
import org.eclipse.swt.widgets.Group;
83
import org.eclipse.swt.widgets.Label;
84
import org.eclipse.swt.widgets.Label;
84
import org.eclipse.swt.widgets.Text;
85
import org.eclipse.ui.IWorkingSet;
85
import org.eclipse.ui.IWorkingSet;
86
import org.eclipse.ui.IWorkingSetManager;
86
import org.eclipse.ui.IWorkingSetManager;
87
import org.eclipse.ui.PlatformUI;
87
import org.eclipse.ui.PlatformUI;
88
import org.eclipse.ui.actions.WorkspaceModifyOperation;
88
import org.eclipse.ui.actions.WorkspaceModifyOperation;
89
import org.eclipse.ui.dialogs.IOverwriteQuery;
89
import org.eclipse.ui.dialogs.WizardDataTransferPage;
90
import org.eclipse.ui.dialogs.WorkingSetGroup;
90
import org.eclipse.ui.dialogs.WorkingSetGroup;
91
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
92
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
91
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
93
import org.eclipse.ui.internal.ide.StatusUtil;
92
import org.eclipse.ui.internal.ide.StatusUtil;
94
import org.eclipse.ui.statushandlers.StatusManager;
93
import org.eclipse.ui.statushandlers.StatusManager;
Lines 99-106 Link Here
99
 * The WizardProjectsImportPage is the page that allows the user to import
98
 * The WizardProjectsImportPage is the page that allows the user to import
100
 * projects from a particular location.
99
 * projects from a particular location.
101
 */
100
 */
102
public class WizardProjectsImportPage extends WizardPage implements
101
public class WizardProjectsImportPage extends WizardDataTransferPage {
103
		IOverwriteQuery {
104
102
105
	/**
103
	/**
106
	 * The name of the folder containing metadata information for the workspace.
104
	 * The name of the folder containing metadata information for the workspace.
Lines 287-299 Link Here
287
	}
285
	}
288
286
289
	// dialog store id constants
287
	// dialog store id constants
288
    private final static String STORE_DIRECTORIES = "WizardProjectsImportPage.STORE_DIRECTORIES";//$NON-NLS-1$
289
    private final static String STORE_ARCHIVES = "WizardProjectsImportPage.STORE_ARCHIVES";//$NON-NLS-1$
290
290
	private final static String STORE_NESTED_PROJECTS = "WizardProjectsImportPage.STORE_NESTED_PROJECTS"; //$NON-NLS-1$
291
	private final static String STORE_NESTED_PROJECTS = "WizardProjectsImportPage.STORE_NESTED_PROJECTS"; //$NON-NLS-1$
291
	
292
	
292
	private final static String STORE_COPY_PROJECT_ID = "WizardProjectsImportPage.STORE_COPY_PROJECT_ID"; //$NON-NLS-1$
293
	private final static String STORE_COPY_PROJECT_ID = "WizardProjectsImportPage.STORE_COPY_PROJECT_ID"; //$NON-NLS-1$
293
294
294
	private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
295
	private final static String STORE_ARCHIVE_SELECTED = "WizardProjectsImportPage.STORE_ARCHIVE_SELECTED"; //$NON-NLS-1$
295
296
296
	private Text directoryPathField;
297
	private Combo directoryPathField;
297
298
298
	private CheckboxTreeViewer projectsList;
299
	private CheckboxTreeViewer projectsList;
299
300
Lines 323-329 Link Here
323
324
324
	private Button projectFromArchiveRadio;
325
	private Button projectFromArchiveRadio;
325
326
326
	private Text archivePathField;
327
	private Combo archivePathField;
327
328
328
	private Button browseDirectoriesButton;
329
	private Button browseDirectoriesButton;
329
330
Lines 403-409 Link Here
403
404
404
		createProjectsRoot(workArea);
405
		createProjectsRoot(workArea);
405
		createProjectsList(workArea);
406
		createProjectsList(workArea);
406
		createOptionsArea(workArea);
407
		createOptionsGroup(workArea);
407
		createWorkingSetGroup(workArea);
408
		createWorkingSetGroup(workArea);
408
		restoreWidgetValues();
409
		restoreWidgetValues();
409
		Dialog.applyDialogFont(workArea);
410
		Dialog.applyDialogFont(workArea);
Lines 419-434 Link Here
419
		workingSetGroup = new WorkingSetGroup(workArea, currentSelection, workingSetIds);
420
		workingSetGroup = new WorkingSetGroup(workArea, currentSelection, workingSetIds);
420
	}
421
	}
421
422
422
	/**
423
	protected void createOptionsGroupButtons(Group optionsGroup) {
423
	 * Create the area with the extra options.
424
	 * 
425
	 * @param workArea
426
	 */
427
	private void createOptionsArea(Composite workArea) {
428
		Composite optionsGroup = new Composite(workArea, SWT.NONE);
429
		optionsGroup.setLayout(new GridLayout());
430
		optionsGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
431
432
		nestedProjectsCheckbox = new Button(optionsGroup, SWT.CHECK);
424
		nestedProjectsCheckbox = new Button(optionsGroup, SWT.CHECK);
433
		nestedProjectsCheckbox
425
		nestedProjectsCheckbox
434
				.setText(DataTransferMessages.WizardProjectsImportPage_SearchForNestedProjects);
426
				.setText(DataTransferMessages.WizardProjectsImportPage_SearchForNestedProjects);
Lines 667-674 Link Here
667
		projectFromDirectoryRadio
659
		projectFromDirectoryRadio
668
				.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
660
				.setText(DataTransferMessages.WizardProjectsImportPage_RootSelectTitle);
669
661
670
		// project location entry field
662
		// project location entry combo
671
		this.directoryPathField = new Text(projectGroup, SWT.BORDER);
663
		this.directoryPathField = new Combo(projectGroup, SWT.BORDER);
672
664
673
		GridData directoryPathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
665
		GridData directoryPathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
674
		directoryPathData.widthHint = new PixelConverter(directoryPathField).convertWidthInCharsToPixels(25);
666
		directoryPathData.widthHint = new PixelConverter(directoryPathField).convertWidthInCharsToPixels(25);
Lines 685-692 Link Here
685
		projectFromArchiveRadio
677
		projectFromArchiveRadio
686
				.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
678
				.setText(DataTransferMessages.WizardProjectsImportPage_ArchiveSelectTitle);
687
679
688
		// project location entry field
680
		// project location entry combo
689
		archivePathField = new Text(projectGroup, SWT.BORDER);
681
		archivePathField = new Combo(projectGroup, SWT.BORDER);
690
682
691
		GridData archivePathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
683
		GridData archivePathData = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL);
692
		archivePathData.widthHint = new PixelConverter(archivePathField).convertWidthInCharsToPixels(25);
684
		archivePathData.widthHint = new PixelConverter(archivePathField).convertWidthInCharsToPixels(25);
Lines 759-764 Link Here
759
751
760
		});
752
		});
761
753
754
		directoryPathField.addSelectionListener(new SelectionAdapter() {
755
			public void widgetSelected(SelectionEvent e) {
756
				updateProjectsList(directoryPathField.getText().trim());
757
			}
758
		});
759
762
		archivePathField.addTraverseListener(new TraverseListener() {
760
		archivePathField.addTraverseListener(new TraverseListener() {
763
761
764
			/*
762
			/*
Lines 786-791 Link Here
786
			 * .events.FocusEvent)
784
			 * .events.FocusEvent)
787
			 */
785
			 */
788
			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
786
			public void focusLost(org.eclipse.swt.events.FocusEvent e) {
787
				updateProjectsList(archivePathField.getText().trim());
788
			}
789
		});
790
791
		archivePathField.addSelectionListener(new SelectionAdapter() {
792
			public void widgetSelected(SelectionEvent e) {
789
				updateProjectsList(archivePathField.getText().trim());
793
				updateProjectsList(archivePathField.getText().trim());
790
			}
794
			}
791
		});
795
		});
Lines 1067-1090 Link Here
1067
1071
1068
		archivePathField.setFocus();
1072
		archivePathField.setFocus();
1069
		return null;
1073
		return null;
1070
	}
1071
1072
	/**
1073
	 * Display an error dialog with the specified message.
1074
	 * 
1075
	 * @param message
1076
	 * 		the error message
1077
	 */
1078
	protected void displayErrorDialog(String message) {
1079
		MessageDialog.open(MessageDialog.ERROR, getContainer().getShell(),
1080
				getErrorDialogTitle(), message, SWT.SHEET);
1081
	}
1082
1083
	/**
1084
	 * Get the title for an error dialog. Subclasses should override.
1085
	 */
1086
	protected String getErrorDialogTitle() {
1087
		return IDEWorkbenchMessages.WizardExportPage_internalErrorTitle;
1088
	}
1074
	}
1089
1075
1090
	/**
1076
	/**
Lines 1447-1504 Link Here
1447
	}
1433
	}
1448
1434
1449
	/**
1435
	/**
1450
	 * The <code>WizardDataTransfer</code> implementation of this
1451
	 * <code>IOverwriteQuery</code> method asks the user whether the existing
1452
	 * resource at the given path should be overwritten.
1453
	 * 
1454
	 * @param pathString
1455
	 * @return the user's reply: one of <code>"YES"</code>, <code>"NO"</code>,
1456
	 * 	<code>"ALL"</code>, or <code>"CANCEL"</code>
1457
	 */
1458
	public String queryOverwrite(String pathString) {
1459
1460
		Path path = new Path(pathString);
1461
1462
		String messageString;
1463
		// Break the message up if there is a file name and a directory
1464
		// and there are at least 2 segments.
1465
		if (path.getFileExtension() == null || path.segmentCount() < 2) {
1466
			messageString = NLS.bind(
1467
					IDEWorkbenchMessages.WizardDataTransfer_existsQuestion,
1468
					pathString);
1469
		} else {
1470
			messageString = NLS
1471
					.bind(
1472
							IDEWorkbenchMessages.WizardDataTransfer_overwriteNameAndPathQuestion,
1473
							path.lastSegment(), path.removeLastSegments(1)
1474
									.toOSString());
1475
		}
1476
1477
		final MessageDialog dialog = new MessageDialog(getContainer()
1478
				.getShell(), IDEWorkbenchMessages.Question, null,
1479
				messageString, MessageDialog.QUESTION, new String[] {
1480
						IDialogConstants.YES_LABEL,
1481
						IDialogConstants.YES_TO_ALL_LABEL,
1482
						IDialogConstants.NO_LABEL,
1483
						IDialogConstants.NO_TO_ALL_LABEL,
1484
						IDialogConstants.CANCEL_LABEL }, 0) {
1485
			protected int getShellStyle() {
1486
				return super.getShellStyle() | SWT.SHEET;
1487
			}
1488
		};
1489
		String[] response = new String[] { YES, ALL, NO, NO_ALL, CANCEL };
1490
		// run in syncExec because callback is from an operation,
1491
		// which is probably not running in the UI thread.
1492
		getControl().getDisplay().syncExec(new Runnable() {
1493
			public void run() {
1494
				dialog.open();
1495
			}
1496
		});
1497
		return dialog.getReturnCode() < 0 ? CANCEL : response[dialog
1498
				.getReturnCode()];
1499
	}
1500
1501
	/**
1502
	 * Method used for test suite.
1436
	 * Method used for test suite.
1503
	 * 
1437
	 * 
1504
	 * @return Button the Import from Directory RadioButton
1438
	 * @return Button the Import from Directory RadioButton
Lines 1600-1606 Link Here
1600
		// take care of the checkbox
1534
		// take care of the checkbox
1601
		IDialogSettings settings = getDialogSettings();
1535
		IDialogSettings settings = getDialogSettings();
1602
		if (settings != null) {
1536
		if (settings != null) {
1603
			// checkbox
1537
            restoreFromHistory(settings, STORE_DIRECTORIES, directoryPathField);
1538
            restoreFromHistory(settings, STORE_ARCHIVES, archivePathField);
1539
1540
            // checkbox
1604
			nestedProjects = settings.getBoolean(STORE_NESTED_PROJECTS);
1541
			nestedProjects = settings.getBoolean(STORE_NESTED_PROJECTS);
1605
			nestedProjectsCheckbox.setSelection(nestedProjects);
1542
			nestedProjectsCheckbox.setSelection(nestedProjects);
1606
			lastNestedProjects = nestedProjects;
1543
			lastNestedProjects = nestedProjects;
Lines 1640-1652 Link Here
1640
1577
1641
			if (dir) {
1578
			if (dir) {
1642
				directoryPathField.setText(initialPath);
1579
				directoryPathField.setText(initialPath);
1643
				directoryPathField.setSelection(initialPath.length());
1580
				directoryPathField.setSelection(new Point(initialPath.length(), initialPath.length()));
1644
				directoryRadioSelected();
1581
				directoryRadioSelected();
1645
			} else {
1582
			} else {
1646
				archivePathField.setText(initialPath);
1583
				archivePathField.setText(initialPath);
1647
				archivePathField.setSelection(initialPath.length());
1584
				archivePathField.setSelection(new Point(initialPath.length(), initialPath.length()));
1648
				archiveRadioSelected();
1585
				archiveRadioSelected();
1649
			}
1586
			}
1587
		}
1588
	}
1589
1590
	private void restoreFromHistory(IDialogSettings settings, String key, Combo combo) {
1591
		String[] sourceNames = settings.getArray(key);
1592
		if (sourceNames == null) {
1593
			return; // ie.- no values stored, so stop
1594
		}
1595
1596
		for (int i = 0; i < sourceNames.length; i++) {
1597
			combo.add(sourceNames[i]);
1650
		}
1598
		}
1651
	}
1599
	}
1652
1600
Lines 1659-1671 Link Here
1659
	public void saveWidgetValues() {
1607
	public void saveWidgetValues() {
1660
		IDialogSettings settings = getDialogSettings();
1608
		IDialogSettings settings = getDialogSettings();
1661
		if (settings != null) {
1609
		if (settings != null) {
1662
			settings.put(STORE_NESTED_PROJECTS, nestedProjectsCheckbox.getSelection());
1610
            saveInHistory(settings, STORE_DIRECTORIES, directoryPathField.getText());
1611
            saveInHistory(settings, STORE_ARCHIVES, archivePathField.getText());
1612
1613
            settings.put(STORE_NESTED_PROJECTS, nestedProjectsCheckbox.getSelection());
1663
			
1614
			
1664
			settings.put(STORE_COPY_PROJECT_ID, copyCheckbox.getSelection());
1615
			settings.put(STORE_COPY_PROJECT_ID, copyCheckbox.getSelection());
1665
1616
1666
			settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio
1617
			settings.put(STORE_ARCHIVE_SELECTED, projectFromArchiveRadio
1667
					.getSelection());
1618
					.getSelection());
1668
		}
1619
		}
1620
	}
1621
1622
	private void saveInHistory(IDialogSettings settings, String key, String value) {
1623
		String[] sourceNames = settings.getArray(key);
1624
		if (sourceNames == null) {
1625
			sourceNames = new String[0];
1626
		}
1627
		sourceNames = addToHistory(sourceNames, value);
1628
		settings.put(key, sourceNames);
1669
	}
1629
	}
1670
1630
1671
	/**
1631
	/**
Lines 1685-1689 Link Here
1685
	public Button getNestedProjectsCheckbox() {
1645
	public Button getNestedProjectsCheckbox() {
1686
		return nestedProjectsCheckbox;
1646
		return nestedProjectsCheckbox;
1687
	}
1647
	}
1648
1649
	public void handleEvent(Event event) {
1650
	}
1651
1652
	protected boolean allowNewContainerName() {
1653
		return true;
1654
	}
1688
	
1655
	
1689
}
1656
}

Return to bug 400399