View | Details | Raw Unified | Return to bug 301144 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/core/internal/resources/PathVariable.java (+8 lines)
Lines 10-15 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.core.internal.resources;
11
package org.eclipse.core.internal.resources;
12
12
13
import org.eclipse.core.internal.resources.projectvariables.*;
14
13
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.IResource;
14
import org.eclipse.core.resources.IPathVariable;
16
import org.eclipse.core.resources.IPathVariable;
15
17
Lines 42-45 Link Here
42
		ProjectVariableProviderManager.Descriptor descriptor = ProjectVariableProviderManager.getDefault().findDescriptor(variableName);
44
		ProjectVariableProviderManager.Descriptor descriptor = ProjectVariableProviderManager.getDefault().findDescriptor(variableName);
43
		return descriptor != null;
45
		return descriptor != null;
44
	}
46
	}
47
48
	public boolean isPreferred() {
49
		return !(variableName.equals(WorkspaceLocationVariableResolver.NAME) ||
50
				variableName.equals(WorkspaceParentLocationVariableResolver.NAME) ||
51
				variableName.equals(ParentVariableResolver.NAME));
52
	}
45
}
53
}
(-)src/org/eclipse/core/internal/resources/PathVariableUtil.java (-1 / +1 lines)
Lines 236-242 Link Here
236
	}
236
	}
237
237
238
	static public String buildParentPathVariable(String variable, int difference, boolean generateMacro) {
238
	static public String buildParentPathVariable(String variable, int difference, boolean generateMacro) {
239
		String 	newString = "PARENT-" + difference + "-" + variable;    //$NON-NLS-1$//$NON-NLS-2$
239
		String 	newString = ParentVariableResolver.NAME + "-" + difference + "-" + variable;    //$NON-NLS-1$//$NON-NLS-2$
240
240
241
		if (!generateMacro)
241
		if (!generateMacro)
242
			newString = "${" + newString + "}";    //$NON-NLS-1$//$NON-NLS-2$
242
			newString = "${" + newString + "}";    //$NON-NLS-1$//$NON-NLS-2$
(-)src/org/eclipse/core/internal/resources/Workspace.java (-9 / +2 lines)
Lines 13-20 Link Here
13
 *******************************************************************************/
13
 *******************************************************************************/
14
package org.eclipse.core.internal.resources;
14
package org.eclipse.core.internal.resources;
15
15
16
import org.eclipse.core.internal.resources.projectvariables.WorkspaceParentLocationVariableResolver;
17
18
import java.io.IOException;
16
import java.io.IOException;
19
import java.io.InputStream;
17
import java.io.InputStream;
20
import java.net.URI;
18
import java.net.URI;
Lines 25-32 Link Here
25
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
23
import org.eclipse.core.internal.localstore.FileSystemResourceManager;
26
import org.eclipse.core.internal.properties.IPropertyManager;
24
import org.eclipse.core.internal.properties.IPropertyManager;
27
import org.eclipse.core.internal.refresh.RefreshManager;
25
import org.eclipse.core.internal.refresh.RefreshManager;
28
import org.eclipse.core.internal.resources.projectvariables.ParentVariableResolver;
29
import org.eclipse.core.internal.resources.projectvariables.WorkspaceLocationVariableResolver;
30
import org.eclipse.core.internal.utils.*;
26
import org.eclipse.core.internal.utils.*;
31
import org.eclipse.core.internal.watson.*;
27
import org.eclipse.core.internal.watson.*;
32
import org.eclipse.core.resources.*;
28
import org.eclipse.core.resources.*;
Lines 877-887 Link Here
877
		// look if one variable in the destination project matches
873
		// look if one variable in the destination project matches
878
		String[] variables = destPathVariableManager.getPathVariableNames(dest);
874
		String[] variables = destPathVariableManager.getPathVariableNames(dest);
879
		for (int i = 0; i < variables.length; i++) {
875
		for (int i = 0; i < variables.length; i++) {
880
			if (variables[i].equals(WorkspaceLocationVariableResolver.NAME))
876
			IPathVariable pathVariable = destPathVariableManager.getPathVariable(variables[i], dest);
881
				continue;
877
			if (!pathVariable.isPreferred())
882
			if (variables[i].equals(WorkspaceParentLocationVariableResolver.NAME))
883
				continue;
884
			if (variables[i].equals(ParentVariableResolver.NAME))
885
				continue;
878
				continue;
886
			IPath resolveDestVariable = URIUtil.toPath(destPathVariableManager
879
			IPath resolveDestVariable = URIUtil.toPath(destPathVariableManager
887
					.resolveURI(destPathVariableManager.getValue(variables[i], dest), dest));
880
					.resolveURI(destPathVariableManager.getValue(variables[i], dest), dest));
(-)src/org/eclipse/core/resources/IPathVariable.java (+10 lines)
Lines 41-46 Link Here
41
	public boolean isReadOnly();
41
	public boolean isReadOnly();
42
42
43
	/**
43
	/**
44
	 * Returns whether a IPathVariable is a variable that is
45
	 * suited for programatically determining which variable is
46
	 * the most appropriate when create new linked resources.
47
	 * 
48
	 * @return true if the path variable is preferred.
49
	 * @since 3.6
50
	 */
51
	public boolean isPreferred();
52
53
	/**
44
	 * If the variable supports extensions (specified as
54
	 * If the variable supports extensions (specified as
45
	 * "${VARNAME-EXTENSIONNAME}"), this method can return the list of possible
55
	 * "${VARNAME-EXTENSIONNAME}"), this method can return the list of possible
46
	 * extensions, or null if none are supported.
56
	 * extensions, or null if none are supported.
(-)contexts_Workbench.xml (+3 lines)
Lines 1209-1212 Link Here
1209
        <description>This view allows you to display web pages. By default, it is used to display web pages when they are opened from the workbench. You can modify this setting in the Web Browser preferences available from the link below.</description>
1209
        <description>This view allows you to display web pages. By default, it is used to display web pages when they are opened from the workbench. You can modify this setting in the Web Browser preferences available from the link below.</description>
1210
        <topic label="Web Browser preferences" href="/org.eclipse.platform.doc.user/reference/ref-42.htm"/>
1210
        <topic label="Web Browser preferences" href="/org.eclipse.platform.doc.user/reference/ref-42.htm"/>
1211
    </context>
1211
    </context>
1212
    <context id="import_type_dialog">
1213
        <description>This dialog allows you to customize how a file and folder hierarchy is recreated in a project.</description>
1214
    </context>
1212
</contexts>
1215
</contexts>
(-)src/org/eclipse/ui/ide/dialogs/ImportTypeDialog.java (-122 / +508 lines)
Lines 10-24 Link Here
10
 *******************************************************************************/
10
 *******************************************************************************/
11
package org.eclipse.ui.ide.dialogs;
11
package org.eclipse.ui.ide.dialogs;
12
12
13
import java.io.File;
14
import java.net.URI;
15
import java.util.ArrayList;
16
17
import org.eclipse.core.filesystem.URIUtil;
18
import org.eclipse.core.resources.IContainer;
19
import org.eclipse.core.resources.IPathVariable;
13
import org.eclipse.core.resources.IPathVariableManager;
20
import org.eclipse.core.resources.IPathVariableManager;
14
import org.eclipse.core.resources.IResource;
21
import org.eclipse.core.resources.IResource;
15
import org.eclipse.core.resources.ResourcesPlugin;
22
import org.eclipse.core.resources.ResourcesPlugin;
23
import org.eclipse.core.runtime.IPath;
24
import org.eclipse.core.runtime.Path;
16
import org.eclipse.jface.dialogs.IDialogConstants;
25
import org.eclipse.jface.dialogs.IDialogConstants;
17
import org.eclipse.jface.dialogs.MessageDialog;
26
import org.eclipse.jface.dialogs.TrayDialog;
27
import org.eclipse.jface.preference.IPreferenceStore;
28
import org.eclipse.jface.resource.CompositeImageDescriptor;
29
import org.eclipse.jface.resource.ImageDescriptor;
18
import org.eclipse.jface.window.Window;
30
import org.eclipse.jface.window.Window;
19
import org.eclipse.swt.SWT;
31
import org.eclipse.swt.SWT;
32
import org.eclipse.swt.dnd.DND;
20
import org.eclipse.swt.events.SelectionEvent;
33
import org.eclipse.swt.events.SelectionEvent;
21
import org.eclipse.swt.events.SelectionListener;
34
import org.eclipse.swt.events.SelectionListener;
35
import org.eclipse.swt.graphics.Image;
36
import org.eclipse.swt.graphics.Point;
22
import org.eclipse.swt.layout.GridData;
37
import org.eclipse.swt.layout.GridData;
23
import org.eclipse.swt.layout.GridLayout;
38
import org.eclipse.swt.layout.GridLayout;
24
import org.eclipse.swt.widgets.Button;
39
import org.eclipse.swt.widgets.Button;
Lines 27-62 Link Here
27
import org.eclipse.swt.widgets.Control;
42
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Label;
43
import org.eclipse.swt.widgets.Label;
29
import org.eclipse.swt.widgets.Shell;
44
import org.eclipse.swt.widgets.Shell;
45
import org.eclipse.ui.ISharedImages;
46
import org.eclipse.ui.PlatformUI;
30
import org.eclipse.ui.internal.ide.IDEInternalPreferences;
47
import org.eclipse.ui.internal.ide.IDEInternalPreferences;
31
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
48
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
32
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
49
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
50
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
51
import org.eclipse.ui.internal.ide.misc.OverlayIcon;
52
import org.eclipse.ui.plugin.AbstractUIPlugin;
33
53
34
/**
54
/**
55
 * Dialog to customize how files and resources are created in a project hierarchy
35
 * @since 3.6
56
 * @since 3.6
36
 *
57
 *
37
 */
58
 */
38
public class ImportTypeDialog extends MessageDialog implements SelectionListener {
59
public class ImportTypeDialog extends TrayDialog implements SelectionListener {
60
61
	/**
62
	 * Do not perform an import operation
63
	 */
64
	public final static int IMPORT_NONE 			= 0;
65
	/**
66
	 * Copy the files and folders to the destination
67
	 */
68
	public final static int IMPORT_COPY 			= 1;
69
	/**
70
	 * Recreate the file and folder hierarchy using groups and links
71
	 */
72
	public final static int IMPORT_VIRTUAL_FOLDERS_AND_LINKS = 2;
73
	/**
74
	 * Create linked resources for each file and folder
75
	 */
76
	public final static int IMPORT_LINK 			= 4;
77
	/**
78
	 * Move the files and folders to the destination
79
	 */
80
	public final static int IMPORT_MOVE 			= 8;
81
	/**
82
	 * Import only files
83
	 */
84
	public final static int IMPORT_FILES_ONLY		= 16;
85
	
86
	/**
87
	 * @param shell
88
	 * @param dropOperation
89
	 * @param names
90
	 * @param target
91
	 */
92
	public ImportTypeDialog(Shell shell, int dropOperation, String[] names, IContainer target) {
93
		this(shell, selectAppropriateMask(dropOperation, names, target), getPreferredVariable(names, target), target.isVirtual());
94
	}
95
96
97
	/**
98
	 * @param shell
99
	 * @param dropOperation
100
	 * @param sources
101
	 * @param target
102
	 */
103
	public ImportTypeDialog(Shell shell, int dropOperation,
104
			IResource[] sources, IContainer target) {
105
		this(shell, selectAppropriateMask(dropOperation, sources, target), getPreferredVariable(sources, target), target.isVirtual());
106
	}
107
108
	/**
109
	 * @param names
110
	 * @param target
111
	 * @return the most appropriate path variable given the context
112
	 */
113
	private static String getPreferredVariable(String[] names,
114
			IContainer target) {
115
		IPath[] paths = new IPath[names.length];
116
		for (int i = 0; i < names.length; i++) {
117
			paths[i] = Path.fromOSString(names[i]);
118
		}
119
		return getPreferredVariable(paths, target);
120
	}
121
	/**
122
	 * @param sources
123
	 * @param target
124
	 * @return the most appropriate path variable given the context
125
	 */
126
	private static String getPreferredVariable(IResource[] sources,
127
			IContainer target) {
128
		IPath[] paths = new IPath[sources.length];
129
		for (int i = 0; i < sources.length; i++) {
130
			paths[i] = sources[i].getLocation();
131
		}
132
		return getPreferredVariable(paths, target);
133
	}
134
135
	/**
136
	 * Find the most appropriate path variable for a set of paths.
137
	 * The first thing is to find a common root for all the paths.
138
	 * So for the following paths:
139
	 * 		c:\foo\path\bar\dir1\file1.txt
140
	 * 		c:\foo\path\bar\dir2\file2.txt
141
	 * The following root will be selected:
142
	 * 		c:\foo\path\bar\
143
	 * Then, given all the path variable locations, the variable
144
	 * who's distance (in segments) from the common root in the smallest
145
	 * will be chosen.
146
	 * A priority is given as to variables enclosing the root, as others
147
	 * only being enclosed by the root.
148
	 *
149
	 * So if there's two variables, being 
150
	 * 		FOO - c:\foo\
151
	 * 		DIR1 - c:\foo\path\bar\dir1
152
	 * And the common root is:
153
	 * 		c:\foo\path\bar
154
	 * FOO will be selected over DIR1, even through the distance between 
155
	 * the common root and DIR1 is (1), and the distance between the 
156
	 * common root and FOO is (2).  This is because selecting DIR1 would
157
	 * cause the location to be relative to its parent.
158
	 * @param paths
159
	 * @param target
160
	 * @return the most appropriate path variable given the context
161
	 */
162
	private static String getPreferredVariable(IPath[] paths,
163
			IContainer target) {
164
		IPath commonRoot = null;
165
		for (int i = 0; i < paths.length; i++) {
166
			if (paths[i] != null) {
167
				if (commonRoot == null)
168
					commonRoot = paths[i];
169
				else  {
170
					int count = commonRoot.matchingFirstSegments(paths[i]);
171
					int remainingSegments = commonRoot.segmentCount() - count;
172
					if (remainingSegments <= 0)
173
						return null;
174
					commonRoot = commonRoot.removeLastSegments(remainingSegments);
175
				}
176
			}
177
		}
178
		
179
		String mostAppropriate = null;
180
		String mostAppropriateToParent = null;
181
		int mostAppropriateCount = Integer.MAX_VALUE;
182
		int mostAppropriateCountToParent = Integer.MAX_VALUE;
183
		IPathVariableManager pathVariableManager = target.getProject().getPathVariableManager();
184
		String [] variables = pathVariableManager.getPathVariableNames(target);
185
		
186
		for (int i = 0; i < variables.length; i++) {
187
			IPathVariable var = pathVariableManager.getPathVariable(variables[i], target);
188
			if (var.isPreferred()) {
189
				URI value = pathVariableManager.getValue(variables[i], target);
190
				if (value != null) {
191
					IPath path = URIUtil.toPath(value);
192
					if (path != null) {
193
						int difference = path.matchingFirstSegments(commonRoot);
194
						if (difference > 0) {
195
							if (difference < mostAppropriateCount) {
196
								mostAppropriateCount = difference;
197
								mostAppropriate = variables[i];
198
							}
199
						}
200
						else {
201
							// calculate if commonRoot could be relative to the parent of path
202
							difference = commonRoot.matchingFirstSegments(path);
203
							if (difference > 0) {
204
								if (difference < mostAppropriateCountToParent) {
205
									mostAppropriateCountToParent = difference;
206
									mostAppropriateToParent = variables[i];
207
								}
208
							}
209
						}
210
					}
211
				}
212
			}
213
		}
214
		
215
		if (mostAppropriate == null) {
216
			if (mostAppropriateToParent == null)
217
				return "PROJECT_LOC"; //$NON-NLS-1$
218
			return mostAppropriateToParent;
219
		}
220
		return mostAppropriate;
221
	}
222
223
	/**
224
	 * @param dropOperation
225
	 * @param names
226
	 * @param target
227
	 * @return the appropriate import mask given the files dropped on the target
228
	 */
229
	private static int selectAppropriateMask(int dropOperation, String[] names, IContainer target) {
230
		int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
231
		if (!target.isVirtual() && (dropOperation != DND.DROP_LINK))
232
			mask |= ImportTypeDialog.IMPORT_COPY;
233
		if (areOnlyFiles(names))
234
			mask |= ImportTypeDialog.IMPORT_FILES_ONLY;
235
		return mask;
236
	}
237
238
	/**
239
	 * @param dropOperation
240
	 * @param resources
241
	 * @param target
242
	 * @return the appropriate import mask given the files dropped on the target
243
	 */
244
	private static int selectAppropriateMask(int dropOperation, IResource[] resources, IContainer target) {
245
		int mask = ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
246
		if (!target.isVirtual() && (dropOperation != DND.DROP_LINK))
247
			mask |= ImportTypeDialog.IMPORT_COPY;
248
		if (areOnlyFiles(resources))
249
			mask |= ImportTypeDialog.IMPORT_FILES_ONLY;
250
		return mask;
251
	}
252
253
	private static boolean areOnlyFiles(String[] names) {
254
		for (int i = 0; i < names.length; i++) {
255
			File file = new File(names[i]);
256
			if (file.exists() && !file.isFile())
257
				return false;
258
		}
259
		return true;
260
	}
261
262
	private static boolean areOnlyFiles(IResource[] resources) {
263
		for (int i = 0; i < resources.length; i++) {
264
			if (resources[i].getType() != IResource.FILE)
265
				return false;
266
		}
267
		return true;
268
	}
269
270
	private Image fileImage;
271
	private Image linkedFileImage;
272
	private Image folderAndFileImage;
273
	private Image virtualFolderAndFileImage;
274
	private Image linkedFolderAndFileImage;
275
	private int operationMask;
276
	private int currentSelection;
277
	private Button copyButton = null;
278
	private Button shadowCopyButton = null;
279
	private Button linkButton = null;
280
	private Button moveButton = null;
281
	private Combo variableCombo = null;
282
	private Button alwaysPerformThisOperation = null;
283
	private Button variableCheckbox = null;
284
	private String variable = null;
285
	private IResource receivingResource = null;
286
	private boolean targetIsVirtual;
287
	private String preferredVariable;
39
288
40
	/**
289
	/**
41
	 * @param parentShell
290
	 * @param parentShell
42
	 * @param operationMask
291
	 * @param operationMask
43
	 */
292
	 */
44
	public ImportTypeDialog(Shell parentShell, int operationMask) {
293
	private ImportTypeDialog(Shell parentShell, int operationMask, String preferredVariable, boolean targetIsVirtual) {
45
		super(parentShell, IDEWorkbenchMessages.ImportTypeDialog_title, null, IDEWorkbenchMessages.ImportTypeDialog_question,
294
		super(parentShell);
46
				MessageDialog.QUESTION, new String[] {IDialogConstants.OK_LABEL, IDialogConstants.CANCEL_LABEL}, 0);
47
		
295
		
296
		this.preferredVariable = preferredVariable;
48
		this.operationMask = operationMask;
297
		this.operationMask = operationMask;
298
		this.targetIsVirtual = targetIsVirtual;
49
		currentSelection = 0;
299
		currentSelection = 0;
50
		String tmp = readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE);
300
		String tmp = readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE);
51
		if (tmp.length() > 0)
301
		if (tmp.length() > 0)
52
			currentSelection = Integer.parseInt(tmp);
302
			currentSelection = Integer.parseInt(tmp);
53
		currentSelection = currentSelection & operationMask;
303
		currentSelection = currentSelection & operationMask;
54
		if (currentSelection == 0) {
304
		if (currentSelection == 0) {
55
			if ((operationMask & IMPORT_COPY) != 0)
305
			if (hasFlag(IMPORT_COPY))
56
				currentSelection = IMPORT_COPY;
306
				currentSelection = IMPORT_COPY;
57
			else
307
			else
58
				currentSelection = IMPORT_MOVE;
308
				currentSelection = IMPORT_MOVE;
59
		}
309
		}
310
		ImageDescriptor fileDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
311
                ISharedImages.IMG_OBJ_FILE);
312
		ImageDescriptor folderDescriptor = PlatformUI.getWorkbench().getSharedImages().getImageDescriptor(
313
                ISharedImages.IMG_OBJ_FOLDER);
314
315
		ImageDescriptor[][] linkedResourceOverlayMap = new ImageDescriptor[4][1];
316
		linkedResourceOverlayMap[1]= new ImageDescriptor[] {AbstractUIPlugin.imageDescriptorFromPlugin(
317
				IDEWorkbenchPlugin.IDE_WORKBENCH,
318
		"$nl$/icons/full/ovr16/link_ovr.gif")}; //$NON-NLS-1$
319
		
320
		CompositeImageDescriptor linkedFileDescriptor = new OverlayIcon(fileDescriptor, linkedResourceOverlayMap, new Point(16, 16)); 
321
322
		CompositeImageDescriptor linkedFolderDescriptor = new OverlayIcon(folderDescriptor, linkedResourceOverlayMap, new Point(16, 16)); 
323
324
		ImageDescriptor[][] virtualFolderOverlayMap = new ImageDescriptor[4][1];
325
		virtualFolderOverlayMap[1]= new ImageDescriptor[] {AbstractUIPlugin.imageDescriptorFromPlugin(
326
				IDEWorkbenchPlugin.IDE_WORKBENCH,
327
			"$nl$/icons/full/ovr16/virt_ovr.gif")}; //$NON-NLS-1$
328
		CompositeImageDescriptor virtualFolderDescriptor = new OverlayIcon(folderDescriptor, virtualFolderOverlayMap, new Point(16, 16)); 
329
330
		fileImage = fileDescriptor.createImage();
331
		
332
		linkedFileImage = linkedFileDescriptor.createImage();
333
334
		CompositeImageDescriptor desc = new AlignedCompositeImageDescriptor(fileDescriptor, folderDescriptor);
335
		folderAndFileImage = desc.createImage();
336
337
		desc = new AlignedCompositeImageDescriptor(linkedFileDescriptor, virtualFolderDescriptor);
338
		virtualFolderAndFileImage = desc.createImage();
339
340
		desc = new AlignedCompositeImageDescriptor(linkedFileDescriptor, linkedFolderDescriptor);
341
		linkedFolderAndFileImage = desc.createImage();
342
		
343
		if (Boolean.valueOf(readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE)).booleanValue())
344
			variable = preferredVariable;
345
	}
346
347
	class AlignedCompositeImageDescriptor extends CompositeImageDescriptor {
348
349
		ImageDescriptor first, second;
350
		
351
		private int SPACE = 4;
352
		AlignedCompositeImageDescriptor(ImageDescriptor first, ImageDescriptor second) {
353
			this.first = first;
354
			this.second = second;
355
		}
356
		/* (non-Javadoc)
357
		 * @see org.eclipse.jface.resource.CompositeImageDescriptor#drawCompositeImage(int, int)
358
		 */
359
		protected void drawCompositeImage(int width, int height) {
360
            drawImage(first.getImageData(), 0, 0);
361
            drawImage(second.getImageData(), first.getImageData().width + SPACE, 0);
362
		}
363
364
		/* (non-Javadoc)
365
		 * @see org.eclipse.jface.resource.CompositeImageDescriptor#getSize()
366
		 */
367
		protected Point getSize() {
368
			return new Point(first.getImageData().width + second.getImageData().width + SPACE, 
369
					Math.max(first.getImageData().height, second.getImageData().height));
370
		}
371
		
372
	}
373
	
374
	/* (non-Javadoc)
375
	 * @see org.eclipse.jface.dialogs.TrayDialog#close()
376
	 */
377
	public boolean close() {
378
		fileImage.dispose();
379
		linkedFileImage.dispose();
380
		folderAndFileImage.dispose();
381
		virtualFolderAndFileImage.dispose();
382
		linkedFolderAndFileImage.dispose();
383
		return super.close();
60
	}
384
	}
61
385
62
	// the format of the context is operationMask,value:operationMask,value:operationMask,value
386
	// the format of the context is operationMask,value:operationMask,value:operationMask,value
Lines 101-143 Link Here
101
	}
425
	}
102
	
426
	
103
	/**
427
	/**
104
	 * Generate linked resources relative to their preferred variable (typically the PROJECT_LOC variable)
105
	 */
106
	public static final String AUTOMATIC = "PROJECT_LOC"; //$NON-NLS-1$
107
	/**
108
	 * Generate linked resources with absolute path locations.
109
	 */
110
	public static final String ABSOLUTE_PATH = "default"; //$NON-NLS-1$
111
112
	/**
113
	 * @return The currently selected variable, or AUTOMATIC or ABSOLUTE_PATH
428
	 * @return The currently selected variable, or AUTOMATIC or ABSOLUTE_PATH
114
	 */
429
	 */
115
	public String getVariable() {
430
	public String getVariable() {
116
		if (variable == ABSOLUTE_PATH)
117
			return null;
118
		return variable;
431
		return variable;
119
	}
432
	}
120
433
121
	/**
122
	 * Copy the files and folders to the destination
123
	 */
124
	public final static int IMPORT_COPY 			= 1;
125
	/**
126
	 * Recreate the file and folder hierarchy using groups and links
127
	 */
128
	public final static int IMPORT_GROUPS_AND_LINKS = 2;
129
	/**
130
	 * Create linked resources for each file and folder
131
	 */
132
	public final static int IMPORT_LINK 			= 4;
133
	/**
134
	 * Move the files and folders to the destination
135
	 */
136
	public final static int IMPORT_MOVE 			= 8;
137
	/**
138
	 * Do not perform an import operation
139
	 */
140
	public final static int IMPORT_NONE 			= 0;
141
434
142
	/**
435
	/**
143
	 * @return The current selection (one of IMPORT_COPY, IMPORT_GROUPS_AND_LINKS, IMPORT_LINK and IMPORT_MOVE)
436
	 * @return The current selection (one of IMPORT_COPY, IMPORT_GROUPS_AND_LINKS, IMPORT_LINK and IMPORT_MOVE)
Lines 146-234 Link Here
146
		return currentSelection;
439
		return currentSelection;
147
	}
440
	}
148
	
441
	
149
	private int operationMask;
150
	private int currentSelection;
151
	private Button copyButton = null;
152
	private Button shadowCopyButton = null;
153
	private Button linkButton = null;
154
	private Button moveButton = null;
155
	private Combo variableCombo = null;
156
	private Button alwaysPerformThisOperation = null;
157
	private Label variableLabel = null;
158
	private String variable = ABSOLUTE_PATH;
159
	private IResource receivingResource = null;
160
	
161
	/* (non-Javadoc)
442
	/* (non-Javadoc)
162
	 * @see org.eclipse.jface.dialogs.MessageDialog#open()
443
	 * @see org.eclipse.jface.dialogs.MessageDialog#open()
163
	 */
444
	 */
164
	public int open() {
445
	public int open() {
165
		String showDialogMap = readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG);
446
		IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
166
		if (showDialogMap.length() == 0 || !Boolean.valueOf(showDialogMap).booleanValue())
447
		
448
		String mode = store.getString(targetIsVirtual? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE);
449
450
		if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT))
167
			return super.open();
451
			return super.open();
168
		return Window.OK;
452
		if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_COPY)) {
453
			this.currentSelection = IMPORT_COPY;
454
			return Window.OK;
455
		}
456
		if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY) && hasFlag(IMPORT_MOVE)) {
457
			this.currentSelection = IMPORT_MOVE;
458
			return Window.OK;
459
		}
460
		if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK) && hasFlag(IMPORT_LINK)) {
461
			this.currentSelection = IMPORT_LINK;
462
			return Window.OK;
463
		}
464
		if (mode.equals(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER) && hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS)) {
465
			this.currentSelection = IMPORT_VIRTUAL_FOLDERS_AND_LINKS;
466
			return Window.OK;
467
		}
468
469
		return super.open();
169
	}
470
	}
170
471
171
	protected Control createCustomArea(Composite parent) {
472
	protected void configureShell(Shell shell) {
473
		super.configureShell(shell);
474
		String title = (operationMask & IMPORT_FILES_ONLY) != 0 ? IDEWorkbenchMessages.ImportTypeDialog_titleFilesOnly:
475
			IDEWorkbenchMessages.ImportTypeDialog_title;
476
		shell.setText(title);
477
		PlatformUI.getWorkbench().getHelpSystem().setHelp(shell,
478
				IIDEHelpContextIds.IMPORT_TYPE_DIALOG);
479
	}
480
481
	protected Control createMessageArea(Composite parent) {
172
		Composite composite = new Composite(parent, 0);
482
		Composite composite = new Composite(parent, 0);
173
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
483
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
174
 		composite.setLayoutData(gridData);
484
 		composite.setLayoutData(gridData);
175
485
176
 		GridLayout layout = new GridLayout();
486
		
487
		GridLayout layout = new GridLayout();
177
		layout.numColumns = 1;
488
		layout.numColumns = 1;
178
		layout.verticalSpacing = 9;
489
		layout.marginTop= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN);
179
		layout.marginLeft = 32;
490
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
180
		layout.marginTop = 0;
181
		composite.setLayout(layout);
491
		composite.setLayout(layout);
182
492
183
		if ((operationMask & IMPORT_COPY) != 0) {
493
		String message = (operationMask & IMPORT_FILES_ONLY) != 0 ? IDEWorkbenchMessages.ImportTypeDialog_questionFilesOnly:
494
			IDEWorkbenchMessages.ImportTypeDialog_question;
495
496
		// create message
497
		if (message != null) {
498
			Label messageLabel = new Label(composite, SWT.WRAP);
499
			messageLabel.setText(message);
500
			gridData = new GridData(SWT.FILL, SWT.BEGINNING, true, false);
501
			messageLabel.setLayoutData(gridData);
502
		}
503
		return composite;
504
	}
505
506
	protected Control createDialogArea(Composite parent) {
507
		boolean linkIsOnlyChoice = hasFlag(IMPORT_LINK) && !(hasFlag(IMPORT_COPY | IMPORT_MOVE) || (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS) && !hasFlag(IMPORT_FILES_ONLY)));
508
509
		if (!linkIsOnlyChoice)
510
			createMessageArea(parent);
511
		Composite composite = new Composite(parent, 0);
512
		GridData gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
513
 		composite.setLayoutData(gridData);
514
515
		
516
		GridLayout layout = new GridLayout();
517
		layout.numColumns = 1;
518
		layout.marginWidth= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
519
		layout.verticalSpacing= convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_SPACING);
520
		layout.horizontalSpacing= convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_SPACING);
521
522
		int indent= linkIsOnlyChoice ? 0: convertWidthInCharsToPixels(3);
523
524
		layout.marginWidth += indent;
525
		composite.setLayout(layout);
526
		
527
		if (hasFlag(IMPORT_COPY)) {
184
			copyButton = new Button(composite, SWT.RADIO);
528
			copyButton = new Button(composite, SWT.RADIO);
185
			copyButton.setText(IDEWorkbenchMessages.ImportTypeDialog_copyFilesAndDirectories);
529
			copyButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_copyFiles: IDEWorkbenchMessages.ImportTypeDialog_copyFilesAndDirectories);
186
			gridData = new GridData(GridData.FILL_HORIZONTAL);
530
			gridData = new GridData(GridData.FILL_HORIZONTAL);
187
			copyButton.setLayoutData(gridData);
531
			copyButton.setLayoutData(gridData);
188
			copyButton.setData(new Integer(IMPORT_COPY));
532
			copyButton.setData(new Integer(IMPORT_COPY));
189
			copyButton.addSelectionListener(this);
533
			copyButton.addSelectionListener(this);
534
			if (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS | IMPORT_LINK))
535
				copyButton.setImage(hasFlag(IMPORT_FILES_ONLY) ? fileImage:folderAndFileImage);
190
		}
536
		}
191
		
537
		
192
		if ((operationMask & IMPORT_MOVE) != 0) {
538
		if (hasFlag(IMPORT_MOVE)) {
193
			moveButton = new Button(composite, SWT.RADIO);
539
			moveButton = new Button(composite, SWT.RADIO);
194
			moveButton.setText(IDEWorkbenchMessages.ImportTypeDialog_moveFilesAndDirectories);
540
			moveButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_moveFiles:IDEWorkbenchMessages.ImportTypeDialog_moveFilesAndDirectories);
195
			gridData = new GridData(GridData.FILL_HORIZONTAL);
541
			gridData = new GridData(GridData.FILL_HORIZONTAL);
196
			moveButton.setLayoutData(gridData);
542
			moveButton.setLayoutData(gridData);
197
			moveButton.setData(new Integer(IMPORT_MOVE));
543
			moveButton.setData(new Integer(IMPORT_MOVE));
198
			moveButton.addSelectionListener(this);
544
			moveButton.addSelectionListener(this);
199
		}
545
		}
200
546
201
		if ((operationMask & IMPORT_GROUPS_AND_LINKS) != 0) {
547
		if (hasFlag(IMPORT_LINK) && !linkIsOnlyChoice) {
202
			shadowCopyButton = new Button(composite, SWT.RADIO);
203
			shadowCopyButton.setText(IDEWorkbenchMessages.ImportTypeDialog_recreateFilesAndDirectories);
204
			gridData = new GridData(GridData.FILL_HORIZONTAL);
205
			shadowCopyButton.setLayoutData(gridData);
206
			shadowCopyButton.setData(new Integer(IMPORT_GROUPS_AND_LINKS));
207
			shadowCopyButton.addSelectionListener(this);
208
		}
209
		if ((operationMask & IMPORT_LINK) != 0) {
210
			linkButton = new Button(composite, SWT.RADIO);
548
			linkButton = new Button(composite, SWT.RADIO);
211
			linkButton.setText(IDEWorkbenchMessages.ImportTypeDialog_createLinks);
549
			linkButton.setText(hasFlag(IMPORT_FILES_ONLY) ? IDEWorkbenchMessages.ImportTypeDialog_linkFiles:IDEWorkbenchMessages.ImportTypeDialog_createLinks);
212
			gridData = new GridData(GridData.FILL_HORIZONTAL);
550
			gridData = new GridData(GridData.FILL_HORIZONTAL);
213
			linkButton.setLayoutData(gridData);
551
			linkButton.setLayoutData(gridData);
214
			linkButton.setData(new Integer(IMPORT_LINK));
552
			linkButton.setData(new Integer(IMPORT_LINK));
215
			linkButton.addSelectionListener(this);
553
			linkButton.addSelectionListener(this);
554
			linkButton.setImage(hasFlag(IMPORT_FILES_ONLY) ? linkedFileImage:linkedFolderAndFileImage);
216
		}
555
		}
217
556
218
		if ((operationMask & (IMPORT_GROUPS_AND_LINKS | IMPORT_LINK)) != 0) {
557
		if (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS) && !hasFlag(IMPORT_FILES_ONLY)) {
558
			shadowCopyButton = new Button(composite, SWT.RADIO);
559
			shadowCopyButton.setText(IDEWorkbenchMessages.ImportTypeDialog_recreateFilesAndDirectories);
560
			gridData = new GridData(GridData.FILL_HORIZONTAL);
561
			shadowCopyButton.setLayoutData(gridData);
562
			shadowCopyButton.setData(new Integer(IMPORT_VIRTUAL_FOLDERS_AND_LINKS));
563
			shadowCopyButton.addSelectionListener(this);
564
			shadowCopyButton.setImage(virtualFolderAndFileImage);
565
		}
566
567
		if (hasFlag(IMPORT_VIRTUAL_FOLDERS_AND_LINKS | IMPORT_LINK)) {
219
			Composite variableGroup = new Composite(composite, 0);
568
			Composite variableGroup = new Composite(composite, 0);
220
			gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
569
			gridData = new GridData(SWT.FILL, SWT.FILL, true, true);
221
			variableGroup.setLayoutData(gridData);
570
			variableGroup.setLayoutData(gridData);
222
571
223
	 		layout = new GridLayout();
572
	 		layout = new GridLayout();
224
			layout.numColumns = 2;
573
			layout.numColumns = 2;
225
			layout.verticalSpacing = 9;
574
			layout.marginWidth= 0;
226
			variableGroup.setLayout(layout);
575
			variableGroup.setLayout(layout);
227
576
228
			variableLabel = new Label(variableGroup, 0);
577
			variableCheckbox = new Button(variableGroup, SWT.CHECK);
229
			variableLabel.setText(IDEWorkbenchMessages.ImportTypeDialog_importElementsAs);
578
			variableCheckbox.setText(IDEWorkbenchMessages.ImportTypeDialog_importElementsAs);
579
			variableCheckbox.setToolTipText(IDEWorkbenchMessages.ImportTypeDialog_importElementsAsTooltip);
230
			gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
580
			gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
231
			variableLabel.setLayoutData(gridData);
581
			variableCheckbox.setLayoutData(gridData);
582
			variableCheckbox.addSelectionListener(new SelectionListener() {
583
				public void widgetSelected(SelectionEvent e) {
584
					selectRelativeCombo();
585
				}
586
				public void widgetDefaultSelected(SelectionEvent e) {
587
					selectRelativeCombo();
588
				}
589
				private void selectRelativeCombo() {
590
					if (variableCheckbox.getSelection()) {
591
						variableCombo.setEnabled(true);
592
						selectVariable(variableCombo.getItem(variableCombo.getSelectionIndex()));
593
					}
594
					else {
595
						variableCombo.setEnabled(false);
596
						variable = null;
597
					}
598
						
599
				}
600
			});
232
			
601
			
233
			variableCombo = new Combo(variableGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
602
			variableCombo = new Combo(variableGroup, SWT.DROP_DOWN | SWT.READ_ONLY);
234
			gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); // GridData.FILL_HORIZONTAL);
603
			gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING); // GridData.FILL_HORIZONTAL);
Lines 248-331 Link Here
248
				}
617
				}
249
			});
618
			});
250
			setupVariableContent();
619
			setupVariableContent();
251
			selectVariable(readContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VARIABLE));
620
			variableCheckbox.setSelection(variable != null);
621
			if (variable != null)
622
				selectVariable(variable);
623
			else
624
				selectVariable(preferredVariable);
252
		}
625
		}
253
		
626
		
254
		alwaysPerformThisOperation = new Button(composite, SWT.CHECK);
627
		if (linkIsOnlyChoice) {
255
		alwaysPerformThisOperation.setText(IDEWorkbenchMessages.ImportTypeDialog_alwaysPerformThisOperation);
628
			currentSelection = IMPORT_LINK;
629
			parent.getShell().setText(IDEWorkbenchMessages.ImportTypeDialog_titleFilesLinking);
630
		}
631
		alwaysPerformThisOperation = new Button(parent, SWT.CHECK);
632
		alwaysPerformThisOperation.setText(linkIsOnlyChoice? IDEWorkbenchMessages.ImportTypeDialog_alwaysUseLocationWhenLinkingFiles: IDEWorkbenchMessages.ImportTypeDialog_alwaysPerformThisOperation);
256
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
633
		gridData = new GridData(GridData.HORIZONTAL_ALIGN_BEGINNING);
634
		gridData.horizontalIndent = convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN);
257
		alwaysPerformThisOperation.setLayoutData(gridData);
635
		alwaysPerformThisOperation.setLayoutData(gridData);
258
636
259
		refreshSelection();
637
		refreshSelection();
260
		return composite;
638
		return composite;
261
	}
639
	}
640
641
	private boolean hasFlag(int flag) {
642
		return (operationMask & flag) != 0;
643
	}
262
	
644
	
263
	private void editVariables() {
645
	private void editVariables() {
646
		String selectedItem = variable;
264
		PathVariableEditDialog dialog = new PathVariableEditDialog(getShell());
647
		PathVariableEditDialog dialog = new PathVariableEditDialog(getShell());
265
		dialog.setResource(receivingResource);
648
		dialog.setResource(receivingResource);
266
		if (dialog.open() == IDialogConstants.OK_ID) {
649
		if (dialog.open() == IDialogConstants.OK_ID) {
267
			String[] variableNames = (String[]) dialog.getResult();
650
			String[] variableNames = (String[]) dialog.getResult();
268
			if (variableNames != null && variableNames.length >= 1) {
651
			if (variableNames != null && variableNames.length >= 1) {
269
				variable = variableNames[0];
652
				selectedItem = variableNames[0];
270
			}
653
			}
271
		}
654
		}
272
		setupVariableContent();
655
		setupVariableContent();
273
		selectVariable(variable);
656
		if (selectedItem != null) {
657
			selectVariable(selectedItem);
658
		}
274
	}
659
	}
275
660
276
	private void selectVariable(String var) {
661
	private void selectVariable(String var) {
277
		if (var.equals(IDEWorkbenchMessages.ImportTypeDialog_automatic) || var.equals(AUTOMATIC)) {
662
		String[] items = variableCombo.getItems();
278
			variableCombo.select(0);
663
		for (int i = 0; i < items.length; i++) {
279
			variable = var;
664
			if (var.equals(items[i])) {
280
		}
665
				variableCombo.select(i);
281
		else
666
				variable = items[i];
282
		if (var.equals(IDEWorkbenchMessages.ImportTypeDialog_absolutePath) || var.equals(ABSOLUTE_PATH)) {
667
				return;
283
			variableCombo.select(1);
284
			variable = var;
285
		}
286
		else {
287
			String[] items = variableCombo.getItems();
288
			for (int i = 0; i < items.length; i++) {
289
				if (var.equals(items[i])) {
290
					variableCombo.select(i);
291
					if (i == 0)
292
						variable = AUTOMATIC;
293
					else
294
					if (i == 1)
295
						variable = ABSOLUTE_PATH;
296
					else
297
						variable = items[i];
298
					return;
299
				}
300
			}
668
			}
301
			variableCombo.select(0);
302
			variable = AUTOMATIC;
303
		}
669
		}
670
		variableCombo.select(0);
671
		variable = items[0];
304
	}
672
	}
673
305
	private void setupVariableContent() {
674
	private void setupVariableContent() {
306
		String[] items;
307
		IPathVariableManager pathVariableManager;
675
		IPathVariableManager pathVariableManager;
308
		if (receivingResource != null)
676
		if (receivingResource != null)
309
			pathVariableManager = receivingResource.getProject().getPathVariableManager();
677
			pathVariableManager = receivingResource.getProject().getPathVariableManager();
310
		else
678
		else
311
			pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
679
			pathVariableManager = ResourcesPlugin.getWorkspace().getPathVariableManager();
312
		String[] variables = pathVariableManager.getPathVariableNames();
680
		String[] variables = pathVariableManager.getPathVariableNames(receivingResource);
313
		items = new String[variables.length + 3];
681
		
314
		items[0] = IDEWorkbenchMessages.ImportTypeDialog_automatic;
682
		ArrayList items = new ArrayList();
315
		items[1] = IDEWorkbenchMessages.ImportTypeDialog_absolutePath;
683
		for (int i = 0; i < variables.length; i++) {
316
		for (int i = 0; i < variables.length; i++)
684
			if (variables[i].equals("PARENT")) //$NON-NLS-1$
317
			items[i + 2] = variables[i];
685
				continue;
318
		items[items.length - 1] = IDEWorkbenchMessages.ImportTypeDialog_editVariables;
686
			items.add(variables[i]);
319
		variableCombo.setItems(items);
687
		}
688
		items.add(IDEWorkbenchMessages.ImportTypeDialog_editVariables);
689
		variableCombo.setItems((String[]) items.toArray(new String[0]));
320
		super.getShell().layout(true);
690
		super.getShell().layout(true);
321
	}
691
	}
322
	
692
	
323
	protected void buttonPressed(int buttonId) {
693
	protected void buttonPressed(int buttonId) {
324
		if (buttonId == IDialogConstants.OK_ID) {
694
		if (buttonId == IDialogConstants.OK_ID) {
325
			writeContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE, Integer.toString(currentSelection));
695
			writeContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE, Integer.toString(currentSelection));
326
			String storageVariable = currentSelection == 0? AUTOMATIC: (currentSelection == 1 ? ABSOLUTE_PATH:variable);
696
			writeContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE, Boolean.toString(variable != null));
327
			writeContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VARIABLE, storageVariable);
697
328
			writeContextPreference(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG, Boolean.toString(alwaysPerformThisOperation.getSelection()));
698
			IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
699
			if (alwaysPerformThisOperation.getSelection()) {
700
				String mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT;
701
				switch(currentSelection) {
702
				case IMPORT_COPY:
703
				case IMPORT_MOVE:
704
					mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY;
705
					break;
706
				case IMPORT_LINK:
707
					mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK;
708
					break;
709
				case IMPORT_VIRTUAL_FOLDERS_AND_LINKS:
710
					mode = IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER;
711
					break;
712
				}
713
				store.putValue(targetIsVirtual? IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE:IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE, mode);
714
			}
329
		}
715
		}
330
		super.buttonPressed(buttonId);
716
		super.buttonPressed(buttonId);
331
	}
717
	}
Lines 344-358 Link Here
344
		if (copyButton != null)
730
		if (copyButton != null)
345
			copyButton.setSelection(currentSelection == IMPORT_COPY);
731
			copyButton.setSelection(currentSelection == IMPORT_COPY);
346
		if (shadowCopyButton != null)
732
		if (shadowCopyButton != null)
347
			shadowCopyButton.setSelection(currentSelection == IMPORT_GROUPS_AND_LINKS);
733
			shadowCopyButton.setSelection(currentSelection == IMPORT_VIRTUAL_FOLDERS_AND_LINKS);
348
		if (linkButton != null)
734
		if (linkButton != null)
349
			linkButton.setSelection(currentSelection == IMPORT_LINK);
735
			linkButton.setSelection(currentSelection == IMPORT_LINK);
350
		if (moveButton != null)
736
		if (moveButton != null)
351
			moveButton.setSelection(currentSelection == IMPORT_MOVE);
737
			moveButton.setSelection(currentSelection == IMPORT_MOVE);
738
		if (variableCheckbox != null)
739
			variableCheckbox.setEnabled((currentSelection & (IMPORT_VIRTUAL_FOLDERS_AND_LINKS | IMPORT_LINK)) != 0);
352
		if (variableCombo != null)
740
		if (variableCombo != null)
353
			variableCombo.setEnabled((currentSelection & (IMPORT_GROUPS_AND_LINKS | IMPORT_LINK)) != 0);
741
			variableCombo.setEnabled(variableCheckbox.getSelection() && variableCheckbox.isEnabled());
354
		if (variableLabel != null)
355
			variableLabel.setEnabled((currentSelection & (IMPORT_GROUPS_AND_LINKS | IMPORT_LINK)) != 0);
356
	}
742
	}
357
743
358
	/** Set the project that is the destination of the import operation
744
	/** Set the project that is the destination of the import operation
(-)src/org/eclipse/ui/internal/ide/IDEInternalPreferences.java (-2 / +16 lines)
Lines 95-102 Link Here
95
    // Type of import
95
    // Type of import
96
    public static final String IMPORT_FILES_AND_FOLDERS_TYPE = "IMPORT_FILES_AND_FOLDERS_TYPE"; //$NON-NLS-1$
96
    public static final String IMPORT_FILES_AND_FOLDERS_TYPE = "IMPORT_FILES_AND_FOLDERS_TYPE"; //$NON-NLS-1$
97
    
97
    
98
    // Preferred variable for file and folder imports
98
    // (boolean) Using variable relative paths for the import file and folder dialog
99
    public static final String IMPORT_FILES_AND_FOLDERS_VARIABLE = "IMPORT_FILES_AND_FOLDERS_VARIABLE"; //$NON-NLS-1$
99
    public static final String IMPORT_FILES_AND_FOLDERS_RELATIVE = "IMPORT_FILES_AND_FOLDERS_RELATIVE"; //$NON-NLS-1$
100
101
    // (string) Save all dirty editors before running a full or incremental build 
102
    public static final String IMPORT_FILES_AND_FOLDERS_MODE = "IMPORT_FILES_AND_FOLDERS_MODE"; //$NON-NLS-1$
103
104
    // (string) Save all dirty editors before running a full or incremental build 
105
    public static final String IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE = "IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE"; //$NON-NLS-1$
106
107
    public static final String IMPORT_FILES_AND_FOLDERS_MODE_PROMPT = MessageDialogWithToggle.PROMPT;
108
109
    public static final String IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY = "MOVE_COPY"; //$NON-NLS-1$
110
111
    public static final String IMPORT_FILES_AND_FOLDERS_MODE_LINK = "LINK"; //$NON-NLS-1$
112
    
113
    public static final String IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER = "LINK_AND_VIRTUAL_FOLDER"; //$NON-NLS-1$
100
114
101
    // Always show this import window
115
    // Always show this import window
102
    public static final String IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG = "IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG"; //$NON-NLS-1$
116
    public static final String IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG = "IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG"; //$NON-NLS-1$
(-)src/org/eclipse/ui/internal/ide/IDEPreferenceInitializer.java (-2 / +4 lines)
Lines 78-90 Link Here
78
		node.putInt(IDEInternalPreferences.MARKER_LIMITS_VALUE, 100);
78
		node.putInt(IDEInternalPreferences.MARKER_LIMITS_VALUE, 100);
79
		
79
		
80
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE, ""); //$NON-NLS-1$
80
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_TYPE, ""); //$NON-NLS-1$
81
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VARIABLE, ""); //$NON-NLS-1$
81
		node.putBoolean(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_RELATIVE, true);
82
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_SHOW_DIALOG, ""); //$NON-NLS-1$
83
82
84
		//Filter migration
83
		//Filter migration
85
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_BOOKMARK_FILTERS, false);
84
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_BOOKMARK_FILTERS, false);
86
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_TASK_FILTERS, false);
85
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_TASK_FILTERS, false);
87
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_PROBLEM_FILTERS, false);
86
		node.putBoolean(MarkerSupportInternalUtilities.MIGRATE_PROBLEM_FILTERS, false);
87
		
88
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE, IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT);
89
		node.put(IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE, IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT);
88
	}
90
	}
89
91
90
	private String getHelpSeparatorKey(String groupId) {
92
	private String getHelpSeparatorKey(String groupId) {
(-)src/org/eclipse/ui/internal/ide/IDEWorkbenchMessages.java (-2 / +13 lines)
Lines 484-489 Link Here
484
	public static String LinkedResourcesPreference_enableLinkedResources;
484
	public static String LinkedResourcesPreference_enableLinkedResources;
485
	public static String LinkedResourcesPreference_linkedResourcesWarningTitle;
485
	public static String LinkedResourcesPreference_linkedResourcesWarningTitle;
486
	public static String LinkedResourcesPreference_linkedResourcesWarningMessage;
486
	public static String LinkedResourcesPreference_linkedResourcesWarningMessage;
487
	public static String LinkedResourcesPreference_dragAndDropHandlingMessage;
488
	public static String LinkedResourcesPreference_dragAndDropVirtualFolderHandlingMessage;
489
	public static String LinkedResourcesPreference_link;
490
	public static String linkedResourcesPreference_copy;
491
	public static String LinkedResourcesPreference_linkAndVirtualFolder;
487
492
488
	// The following six keys are marked as unused by the NLS search, but they are indirectly used
493
	// The following six keys are marked as unused by the NLS search, but they are indirectly used
489
	// and should be removed.
494
	// and should be removed.
Lines 734-749 Link Here
734
	public static String PathVariableSelectionDialog_ExtensionDialog_description;
739
	public static String PathVariableSelectionDialog_ExtensionDialog_description;
735
740
736
	public static String ImportTypeDialog_title;
741
	public static String ImportTypeDialog_title;
742
	public static String ImportTypeDialog_titleFilesOnly;
743
	public static String ImportTypeDialog_titleFilesLinking;
737
	public static String ImportTypeDialog_question;
744
	public static String ImportTypeDialog_question;
745
	public static String ImportTypeDialog_questionFilesOnly;
738
	public static String ImportTypeDialog_moveFilesAndDirectories;
746
	public static String ImportTypeDialog_moveFilesAndDirectories;
739
	public static String ImportTypeDialog_copyFilesAndDirectories;
747
	public static String ImportTypeDialog_copyFilesAndDirectories;
748
	public static String ImportTypeDialog_moveFiles;
749
	public static String ImportTypeDialog_copyFiles;
740
	public static String ImportTypeDialog_recreateFilesAndDirectories;
750
	public static String ImportTypeDialog_recreateFilesAndDirectories;
741
	public static String ImportTypeDialog_createLinks;
751
	public static String ImportTypeDialog_createLinks;
752
	public static String ImportTypeDialog_linkFiles;
742
	public static String ImportTypeDialog_importElementsAs;
753
	public static String ImportTypeDialog_importElementsAs;
743
	public static String ImportTypeDialog_automatic;
754
	public static String ImportTypeDialog_importElementsAsTooltip;
744
	public static String ImportTypeDialog_absolutePath;
745
	public static String ImportTypeDialog_editVariables;
755
	public static String ImportTypeDialog_editVariables;
746
	public static String ImportTypeDialog_alwaysPerformThisOperation;
756
	public static String ImportTypeDialog_alwaysPerformThisOperation;
757
	public static String ImportTypeDialog_alwaysUseLocationWhenLinkingFiles;
747
758
748
	// ==============================================================================
759
	// ==============================================================================
749
	// Editor Framework
760
	// Editor Framework
(-)src/org/eclipse/ui/internal/ide/IIDEHelpContextIds.java (+3 lines)
Lines 148-153 Link Here
148
    public static final String PATH_VARIABLE_SELECTION_DIALOG = PREFIX
148
    public static final String PATH_VARIABLE_SELECTION_DIALOG = PREFIX
149
            + "path_variable_selection_dialog"; //$NON-NLS-1$
149
            + "path_variable_selection_dialog"; //$NON-NLS-1$
150
150
151
    public static final String IMPORT_TYPE_DIALOG = PREFIX
152
    + "import_type_dialog"; //$NON-NLS-1$
153
151
    public static final String SAVE_AS_DIALOG = PREFIX
154
    public static final String SAVE_AS_DIALOG = PREFIX
152
    + "save_as_dialog_context"; //$NON-NLS-1$
155
    + "save_as_dialog_context"; //$NON-NLS-1$
153
156
(-)src/org/eclipse/ui/internal/ide/ResourceDragAndDropEditor.java (+192 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2005, 2007 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.ui.internal.ide;
12
13
import org.eclipse.jface.preference.IPreferenceStore;
14
import org.eclipse.swt.SWT;
15
import org.eclipse.swt.graphics.Font;
16
import org.eclipse.swt.layout.GridData;
17
import org.eclipse.swt.layout.GridLayout;
18
import org.eclipse.swt.widgets.Button;
19
import org.eclipse.swt.widgets.Composite;
20
import org.eclipse.swt.widgets.Group;
21
22
/**
23
 * A class to handle editing of the Line delimiter preferences in core.
24
 * 
25
 * @since 3.1
26
 */
27
public class ResourceDragAndDropEditor {
28
29
	class PreferenceGroup
30
	{
31
		String preferenceKey;
32
		String title;
33
		String[] labels;
34
		String[] values;
35
		Button[] buttons;
36
		
37
		public PreferenceGroup(String title, String pref, String[] labels, String[] values) {
38
			this.preferenceKey = pref;
39
			this.title = title;
40
			this.labels = labels;
41
			this.values = values;
42
		}
43
		
44
		public void createControl(Composite parent) {
45
			Font font = parent.getFont();
46
			Group group = new Group(parent, SWT.NONE);
47
			GridData data = new GridData(GridData.FILL_HORIZONTAL);
48
			group.setLayoutData(data);
49
			GridLayout layout = new GridLayout();
50
			layout.numColumns = labels.length;
51
			group.setLayout(layout);
52
			group.setText(title);
53
			group.setFont(font);
54
55
			buttons = new Button[labels.length];
56
			for (int i = 0; i < labels.length; i++) {
57
				buttons[i] = new Button(group, SWT.RADIO);
58
				buttons[i].setText(labels[i]);
59
				buttons[i].setData(values[i]);
60
				buttons[i].setFont(font);
61
			}
62
		}
63
64
		/**
65
		 * 
66
		 */
67
		public void doLoad() {
68
			String resourcePreference = getStoredValue(false);
69
			updateState(resourcePreference);
70
		}
71
		/**
72
		 * @param value
73
		 */
74
		private void updateState(String value) {
75
			for (int i = 0; i < labels.length; i++) {
76
				if (value.equals(buttons[i].getData()))
77
					buttons[i].setSelection(true);
78
			}
79
		}
80
81
		/**
82
		 * 
83
		 */
84
		public void loadDefault() {
85
			String value = getStoredValue(true);
86
			updateState(value);
87
		}
88
		/**
89
		 * Returns the value that is currently stored for the encoding.
90
		 * @param useDefault 
91
		 * 
92
		 * @return the currently stored encoding
93
		 */
94
		public String getStoredValue(boolean useDefault) {
95
			IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
96
			if (useDefault)
97
				return store.getDefaultString(preferenceKey);
98
			return store.getString(preferenceKey);
99
		}
100
101
		 /**
102
		 * @return the current selection
103
		 */
104
		private String getSelection() {
105
			for (int i = 0; i < labels.length; i++) {
106
				if (buttons[i].getSelection())
107
					return (String) buttons[i].getData();
108
			}
109
			return values[0];
110
		}
111
112
		/**
113
		 * 
114
		 */
115
		public void store() {
116
			IPreferenceStore store = IDEWorkbenchPlugin.getDefault().getPreferenceStore();
117
			store.putValue(preferenceKey, getSelection());
118
		}
119
	}
120
	
121
	PreferenceGroup folderPref;
122
	PreferenceGroup virtualFolderPref;
123
	/**
124
	 * Creates a new drag and drop resource editor with the given preference name, label
125
	 * and parent.
126
	 * 
127
	 * @param composite
128
	 *            the parent of the field editor's control
129
	 */
130
	public ResourceDragAndDropEditor(Composite composite) {
131
		folderPref = new PreferenceGroup(IDEWorkbenchMessages.LinkedResourcesPreference_dragAndDropHandlingMessage,
132
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE,
133
				new String[] {
134
				IDEWorkbenchMessages.Prompt,
135
				IDEWorkbenchMessages.linkedResourcesPreference_copy,
136
				IDEWorkbenchMessages.LinkedResourcesPreference_link, 
137
				IDEWorkbenchMessages.LinkedResourcesPreference_linkAndVirtualFolder },
138
				new String[] {IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT,
139
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_MOVE_COPY,
140
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK,
141
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER});
142
		virtualFolderPref = new PreferenceGroup(IDEWorkbenchMessages.LinkedResourcesPreference_dragAndDropVirtualFolderHandlingMessage,
143
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_VIRTUAL_FOLDER_MODE,
144
				new String[] {
145
				IDEWorkbenchMessages.Prompt,
146
				IDEWorkbenchMessages.LinkedResourcesPreference_link, 
147
				IDEWorkbenchMessages.LinkedResourcesPreference_linkAndVirtualFolder },
148
				new String[] {IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_PROMPT,
149
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK,
150
				IDEInternalPreferences.IMPORT_FILES_AND_FOLDERS_MODE_LINK_AND_VIRTUAL_FOLDER});
151
		createControl(composite);
152
	}
153
154
	/**
155
	 * Creates this field editor's main control containing all of its basic
156
	 * controls.
157
	 * 
158
	 * @param parent
159
	 *            the parent control
160
	 */
161
	protected void createControl(Composite parent) {
162
		folderPref.createControl(parent);
163
		virtualFolderPref.createControl(parent);
164
	}
165
166
	/**
167
	 * Load the list items from core and update the state of the buttons to
168
	 * match what the preference is currently set to.
169
	 */
170
	public void doLoad() {
171
		folderPref.doLoad();
172
		virtualFolderPref.doLoad();
173
	}
174
175
	/**
176
	 * Initializes this field editor with the preference value from the
177
	 * preference store.
178
	 */
179
	public void loadDefault() {
180
		folderPref.loadDefault();
181
		virtualFolderPref.loadDefault();
182
	}
183
184
	/**
185
	 * Store the currently selected line delimiter value in the preference
186
	 * store.
187
	 */
188
	public void store() {
189
		folderPref.store();
190
		virtualFolderPref.store();
191
	}
192
}
(-)src/org/eclipse/ui/internal/ide/dialogs/LinkedResourcesPreferencePage.java (+32 lines)
Lines 31-36 Link Here
31
import org.eclipse.ui.PlatformUI;
31
import org.eclipse.ui.PlatformUI;
32
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
32
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
33
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
33
import org.eclipse.ui.internal.ide.IIDEHelpContextIds;
34
import org.eclipse.ui.internal.ide.ResourceDragAndDropEditor;
34
35
35
/**
36
/**
36
 * Preference page for linked resources. 
37
 * Preference page for linked resources. 
Lines 47-52 Link Here
47
48
48
    private PathVariablesGroup pathVariablesGroup;
49
    private PathVariablesGroup pathVariablesGroup;
49
50
51
	private ResourceDragAndDropEditor dragAndDropHandlingEditor;
52
50
    /**
53
    /**
51
     * Constructs a preference page of path variables.
54
     * Constructs a preference page of path variables.
52
     * Omits "Restore Defaults"/"Apply Changes" buttons.
55
     * Omits "Restore Defaults"/"Apply Changes" buttons.
Lines 105-110 Link Here
105
                    }
108
                    }
106
                });
109
                });
107
110
111
		createLineSeparatorEditorControls(pageComponent);
108
        createSpace(pageComponent);
112
        createSpace(pageComponent);
109
113
110
        topLabel = new Label(pageComponent, SWT.NONE);
114
        topLabel = new Label(pageComponent, SWT.NONE);
Lines 126-131 Link Here
126
        return pageComponent;
130
        return pageComponent;
127
    }
131
    }
128
132
133
    /* (non-Javadoc)
134
	 * @see org.eclipse.jface.preference.PreferencePage#performDefaults()
135
	 */
136
	protected void performDefaults() {
137
		dragAndDropHandlingEditor.loadDefault();
138
		super.performDefaults();
139
	}
140
141
	/**
142
     * Create a composite that contains the line delimiter controls
143
     * 
144
     * @param parent
145
     */
146
    private void createLineSeparatorEditorControls(Composite parent){
147
    	Composite lineComposite = new Composite(parent,SWT.NONE);
148
		final GridLayout gridLayout = new GridLayout();
149
		gridLayout.marginWidth = 0;
150
		gridLayout.marginHeight = 0;
151
		lineComposite.setLayout(gridLayout);
152
153
		lineComposite.setLayoutData(new GridData(
154
                GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL));
155
		
156
		dragAndDropHandlingEditor = new ResourceDragAndDropEditor(lineComposite);
157
		dragAndDropHandlingEditor.doLoad();
158
    }
159
129
    /**
160
    /**
130
     * Creates a tab of one horizontal spans.
161
     * Creates a tab of one horizontal spans.
131
     *
162
     *
Lines 167-172 Link Here
167
     * @see PathVariablesGroup#performOk()
198
     * @see PathVariablesGroup#performOk()
168
     */
199
     */
169
    public boolean performOk() {
200
    public boolean performOk() {
201
		dragAndDropHandlingEditor.store();
170
        return pathVariablesGroup.performOk();
202
        return pathVariablesGroup.performOk();
171
    }
203
    }
172
204
(-)src/org/eclipse/ui/internal/ide/messages.properties (-11 / +23 lines)
Lines 484-489 Link Here
484
LinkedResourcesPreference_enableLinkedResources = &Enable linked resources
484
LinkedResourcesPreference_enableLinkedResources = &Enable linked resources
485
LinkedResourcesPreference_linkedResourcesWarningTitle = Enabled Linked Resources
485
LinkedResourcesPreference_linkedResourcesWarningTitle = Enabled Linked Resources
486
LinkedResourcesPreference_linkedResourcesWarningMessage = You have enabled a feature which may give rise to incompatibilities if projects are shared by users of different versions of the workbench.  Please consult the documentation for further details.
486
LinkedResourcesPreference_linkedResourcesWarningMessage = You have enabled a feature which may give rise to incompatibilities if projects are shared by users of different versions of the workbench.  Please consult the documentation for further details.
487
LinkedResourcesPreference_dragAndDropHandlingMessage = Drag and drop items on a folder or project
488
LinkedResourcesPreference_dragAndDropVirtualFolderHandlingMessage = Drag and drop items on a virtual folder
489
LinkedResourcesPreference_link=&Link
490
linkedResourcesPreference_copy=&Copy
491
LinkedResourcesPreference_linkAndVirtualFolder=Link and create &virtual folders
487
492
488
# The following six keys are marked as unused by the NLS search, but they are indirectly used
493
# The following six keys are marked as unused by the NLS search, but they are indirectly used
489
# and should be removed.
494
# and should be removed.
Lines 755-772 Link Here
755
PathVariableSelectionDialog_ExtensionDialog_title = Variable Extension
760
PathVariableSelectionDialog_ExtensionDialog_title = Variable Extension
756
PathVariableSelectionDialog_ExtensionDialog_description = Choose extension to {0}
761
PathVariableSelectionDialog_ExtensionDialog_description = Choose extension to {0}
757
762
758
ImportTypeDialog_title=File and Folder Import
763
ImportTypeDialog_title=File and Folder Operation
759
ImportTypeDialog_question=Select how files and folders should be imported in the project:
764
ImportTypeDialog_titleFilesOnly= File Operation
760
ImportTypeDialog_moveFilesAndDirectories=Move the files and directories
765
ImportTypeDialog_titleFilesLinking= Link Files
761
ImportTypeDialog_copyFilesAndDirectories=Copy the files and directories.
766
ImportTypeDialog_question=Select how files and folders should be imported into the project:
762
ImportTypeDialog_recreateFilesAndDirectories=Recreate the file and directory hierarchy with virtual folders and links.
767
ImportTypeDialog_questionFilesOnly=Select how files should be imported into the project:
763
ImportTypeDialog_createLinks=Create links for each file and directory.
768
ImportTypeDialog_moveFilesAndDirectories=&Move files and folders
764
ImportTypeDialog_importElementsAs=Create linked resources as relative to:
769
ImportTypeDialog_copyFilesAndDirectories=&Copy files and folders 
765
ImportTypeDialog_automatic=<Automatic>
770
ImportTypeDialog_moveFiles=&Move files
766
ImportTypeDialog_absolutePath=<Absolute Path>
771
ImportTypeDialog_copyFiles=&Copy files
772
ImportTypeDialog_recreateFilesAndDirectories=Link to files and recreate folder structure with &virtual folders
773
ImportTypeDialog_createLinks=&Link to files and folders
774
ImportTypeDialog_linkFiles=&Link to files
775
ImportTypeDialog_importElementsAs=Create link locations &relative to:
776
ImportTypeDialog_importElementsAsTooltip=If this option is not selected, link locations will be created as absolute paths
777
ImportTypeDialog_automatic=Default
778
ImportTypeDialog_absolutePath=Absolute Path
767
ImportTypeDialog_editVariables=Edit Variables...
779
ImportTypeDialog_editVariables=Edit Variables...
768
ImportTypeDialog_alwaysPerformThisOperation=Always perform the selected operation in this context
780
ImportTypeDialog_alwaysPerformThisOperation=&Always perform the selected operation
769
781
ImportTypeDialog_alwaysUseLocationWhenLinkingFiles=&Always use the selected location
770
# ==============================================================================
782
# ==============================================================================
771
# Editor Framework
783
# Editor Framework
772
# ==============================================================================
784
# ==============================================================================
(-)src/org/eclipse/ui/views/navigator/NavigatorDropAdapter.java (-11 / +5 lines)
Lines 277-286 Link Here
277
                        getShell());
277
                        getShell());
278
				// if the target is a group and all sources are files, then automatically create links
278
				// if the target is a group and all sources are files, then automatically create links
279
				int type;
279
				int type;
280
				int mask = ImportTypeDialog.IMPORT_GROUPS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
280
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), getCurrentOperation(), names, target);
281
				if (!target.isVirtual() && (getCurrentOperation() != DND.DROP_LINK))
282
					mask |= ImportTypeDialog.IMPORT_COPY;
283
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), mask);
284
				dialog.setResource(target);
281
				dialog.setResource(target);
285
				if (dialog.open() == Window.OK)
282
				if (dialog.open() == Window.OK)
286
					type = dialog.getSelection();
283
					type = dialog.getSelection();
Lines 290-296 Link Here
290
					case ImportTypeDialog.IMPORT_COPY:
287
					case ImportTypeDialog.IMPORT_COPY:
291
						operation.copyFiles(names, target);
288
						operation.copyFiles(names, target);
292
						break;
289
						break;
293
					case ImportTypeDialog.IMPORT_GROUPS_AND_LINKS:
290
					case ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS:
294
						if (dialog.getVariable() != null)
291
						if (dialog.getVariable() != null)
295
							operation.setRelativeVariable(dialog.getVariable());
292
							operation.setRelativeVariable(dialog.getVariable());
296
						operation.createGroupAndLinks(names, target);
293
						operation.createGroupAndLinks(names, target);
Lines 308-314 Link Here
308
        return problems;
305
        return problems;
309
    }
306
    }
310
307
311
    /**
308
	/**
312
     * Performs a resource copy
309
     * Performs a resource copy
313
     */
310
     */
314
    private IStatus performResourceCopy(Shell shell, IResource[] sources) {
311
    private IStatus performResourceCopy(Shell shell, IResource[] sources) {
Lines 348-360 Link Here
348
			}
345
			}
349
			// if all sources are either links or groups, copy then normally, don't show the dialog
346
			// if all sources are either links or groups, copy then normally, don't show the dialog
350
			if (!allSourceAreLinksOrGroups) {
347
			if (!allSourceAreLinksOrGroups) {
351
				int mask = ImportTypeDialog.IMPORT_GROUPS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
348
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), getCurrentOperation(), sources, target);
352
				if (!target.isVirtual() && (getCurrentOperation() != DND.DROP_LINK))
353
					mask |= ImportTypeDialog.IMPORT_COPY;
354
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), mask);
355
				dialog.setResource(target);
349
				dialog.setResource(target);
356
				if (dialog.open() == Window.OK) {
350
				if (dialog.open() == Window.OK) {
357
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_GROUPS_AND_LINKS)
351
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
358
						operation.setCreateGroups(true);
352
						operation.setCreateGroups(true);
359
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
353
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
360
						operation.setCreateLinks(true);
354
						operation.setCreateLinks(true);
(-)src/org/eclipse/ui/navigator/resources/ResourceDropAdapterAssistant.java (-10 / +4 lines)
Lines 400-412 Link Here
400
			// if all sources are either links or groups, copy then normally,
400
			// if all sources are either links or groups, copy then normally,
401
			// don't show the dialog
401
			// don't show the dialog
402
			if (!allSourceAreLinksOrGroups) {
402
			if (!allSourceAreLinksOrGroups) {
403
				int mask = ImportTypeDialog.IMPORT_GROUPS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
403
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), dropAdapter.getCurrentOperation(), sources, target);
404
				if (!target.isVirtual() && (dropAdapter.getCurrentOperation() != DND.DROP_LINK))
405
					mask |= ImportTypeDialog.IMPORT_COPY;
406
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), mask);
407
				dialog.setResource(target);
404
				dialog.setResource(target);
408
				if (dialog.open() == Window.OK) {
405
				if (dialog.open() == Window.OK) {
409
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_GROUPS_AND_LINKS)
406
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS)
410
						operation.setCreateGroups(true);
407
						operation.setCreateGroups(true);
411
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
408
					if (dialog.getSelection() == ImportTypeDialog.IMPORT_LINK)
412
						operation.setCreateLinks(true);
409
						operation.setCreateLinks(true);
Lines 485-494 Link Here
485
				// if the target is a group and all sources are files, then
482
				// if the target is a group and all sources are files, then
486
				// automatically create links
483
				// automatically create links
487
				int type;
484
				int type;
488
				int mask = ImportTypeDialog.IMPORT_GROUPS_AND_LINKS | ImportTypeDialog.IMPORT_LINK;
485
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), finalAdapter.getCurrentOperation(), names, target);
489
				if (!target.isVirtual() && (finalAdapter.getCurrentOperation() != DND.DROP_LINK))
490
					mask |= ImportTypeDialog.IMPORT_COPY;
491
				ImportTypeDialog dialog = new ImportTypeDialog(getShell(), mask);
492
				dialog.setResource(target);
486
				dialog.setResource(target);
493
				if (dialog.open() == Window.OK)
487
				if (dialog.open() == Window.OK)
494
					type = dialog.getSelection();
488
					type = dialog.getSelection();
Lines 498-504 Link Here
498
				case ImportTypeDialog.IMPORT_COPY:
492
				case ImportTypeDialog.IMPORT_COPY:
499
					operation.copyFiles(names, target);
493
					operation.copyFiles(names, target);
500
					break;
494
					break;
501
				case ImportTypeDialog.IMPORT_GROUPS_AND_LINKS:
495
				case ImportTypeDialog.IMPORT_VIRTUAL_FOLDERS_AND_LINKS:
502
					if (dialog.getVariable() != null)
496
					if (dialog.getVariable() != null)
503
						operation.setRelativeVariable(dialog.getVariable());
497
						operation.setRelativeVariable(dialog.getVariable());
504
					operation.createGroupAndLinks(names, target);
498
					operation.createGroupAndLinks(names, target);

Return to bug 301144