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

Collapse All | Expand All

(-)src/org/eclipse/ui/internal/wizards/datatransfer/WizardProjectsImportPage.java (+43 lines)
Lines 32-37 Link Here
32
import org.eclipse.core.resources.IProject;
32
import org.eclipse.core.resources.IProject;
33
import org.eclipse.core.resources.IProjectDescription;
33
import org.eclipse.core.resources.IProjectDescription;
34
import org.eclipse.core.resources.IResource;
34
import org.eclipse.core.resources.IResource;
35
import org.eclipse.core.resources.IResourceStatus;
35
import org.eclipse.core.resources.IWorkspace;
36
import org.eclipse.core.resources.IWorkspace;
36
import org.eclipse.core.resources.ResourcesPlugin;
37
import org.eclipse.core.resources.ResourcesPlugin;
37
import org.eclipse.core.runtime.CoreException;
38
import org.eclipse.core.runtime.CoreException;
Lines 71-82 Link Here
71
import org.eclipse.swt.widgets.DirectoryDialog;
72
import org.eclipse.swt.widgets.DirectoryDialog;
72
import org.eclipse.swt.widgets.FileDialog;
73
import org.eclipse.swt.widgets.FileDialog;
73
import org.eclipse.swt.widgets.Label;
74
import org.eclipse.swt.widgets.Label;
75
import org.eclipse.swt.widgets.Shell;
74
import org.eclipse.swt.widgets.Text;
76
import org.eclipse.swt.widgets.Text;
75
import org.eclipse.ui.actions.WorkspaceModifyOperation;
77
import org.eclipse.ui.actions.WorkspaceModifyOperation;
76
import org.eclipse.ui.dialogs.IOverwriteQuery;
78
import org.eclipse.ui.dialogs.IOverwriteQuery;
77
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
79
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
78
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
80
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
79
import org.eclipse.ui.internal.ide.StatusUtil;
81
import org.eclipse.ui.internal.ide.StatusUtil;
82
import org.eclipse.ui.internal.ide.dialogs.MissingPathVariableDialog;
80
import org.eclipse.ui.statushandlers.StatusManager;
83
import org.eclipse.ui.statushandlers.StatusManager;
81
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
84
import org.eclipse.ui.wizards.datatransfer.FileSystemStructureProvider;
82
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
85
import org.eclipse.ui.wizards.datatransfer.ImportOperation;
Lines 255-260 Link Here
255
	// The last selected path to mimize searches
258
	// The last selected path to mimize searches
256
	private String lastPath;
259
	private String lastPath;
257
260
261
	private Shell shell;
262
258
	/**
263
	/**
259
	 * Creates a new project creation wizard page.
264
	 * Creates a new project creation wizard page.
260
	 * 
265
	 * 
Lines 282-287 Link Here
282
	 */
287
	 */
283
	public void createControl(Composite parent) {
288
	public void createControl(Composite parent) {
284
289
290
		shell = parent.getShell();
285
		initializeDialogUnits(parent);
291
		initializeDialogUnits(parent);
286
292
287
		Composite workArea = new Composite(parent, SWT.NONE);
293
		Composite workArea = new Composite(parent, SWT.NONE);
Lines 1186-1191 Link Here
1186
					30));
1192
					30));
1187
			project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(
1193
			project.open(IResource.BACKGROUND_REFRESH, new SubProgressMonitor(
1188
					monitor, 70));
1194
					monitor, 70));
1195
			validateResourceLinks(workspace, project);
1189
		} catch (CoreException e) {
1196
		} catch (CoreException e) {
1190
			throw new InvocationTargetException(e);
1197
			throw new InvocationTargetException(e);
1191
		} finally {
1198
		} finally {
Lines 1211-1216 Link Here
1211
	}
1218
	}
1212
1219
1213
	/**
1220
	/**
1221
	 * @param workspace
1222
	 * @param project
1223
	 * @throws CoreException
1224
	 */
1225
	private void validateResourceLinks(final IWorkspace workspace,
1226
			final IProject project) throws CoreException {
1227
		final HashSet missingLinks = new HashSet();
1228
		IResource[] projectResources = project.members();
1229
		for (int i = 0; i < projectResources.length; i++) {
1230
			IResource resource = projectResources[i];
1231
			if (resource.isLinked()){
1232
				final IStatus status = workspace.validateLinkLocation(resource, resource.getRawLocation());
1233
				if (IResourceStatus.VARIABLE_NOT_DEFINED_WARNING == status.getCode()){
1234
					missingLinks.add(resource.getRawLocation().segment(0));
1235
				}
1236
			}
1237
		}
1238
		if (!missingLinks.isEmpty()){
1239
			System.out.println("Missing Resource Variables:"); //$NON-NLS-1$
1240
			for (Iterator iterator = missingLinks.iterator(); iterator
1241
					.hasNext();) {
1242
				String missingLink = (String) iterator.next();
1243
				System.out.println(missingLink);
1244
			}
1245
			final MissingPathVariableDialog missingDialog = new MissingPathVariableDialog(shell, ResourcesPlugin.getWorkspace()
1246
	                .getPathVariableManager() ,missingLinks);
1247
			getShell().getDisplay().asyncExec(new Runnable(){
1248
				public void run() {
1249
					missingDialog.open();
1250
				}
1251
			});
1252
			
1253
		}
1254
	}
1255
1256
	/**
1214
	 * The <code>WizardDataTransfer</code> implementation of this
1257
	 * The <code>WizardDataTransfer</code> implementation of this
1215
	 * <code>IOverwriteQuery</code> method asks the user whether the existing
1258
	 * <code>IOverwriteQuery</code> method asks the user whether the existing
1216
	 * resource at the given path should be overwritten.
1259
	 * resource at the given path should be overwritten.
(-)src/org/eclipse/ui/internal/ide/dialogs/MissingPathVariableDialog.java (+156 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 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
12
package org.eclipse.ui.internal.ide.dialogs;
13
14
import java.util.Set;
15
16
import org.eclipse.core.resources.IPathVariableManager;
17
import org.eclipse.jface.dialogs.Dialog;
18
import org.eclipse.jface.dialogs.IDialogConstants;
19
import org.eclipse.jface.dialogs.TitleAreaDialog;
20
import org.eclipse.swt.SWT;
21
import org.eclipse.swt.layout.FormAttachment;
22
import org.eclipse.swt.layout.FormData;
23
import org.eclipse.swt.layout.FormLayout;
24
import org.eclipse.swt.layout.GridData;
25
import org.eclipse.swt.widgets.Button;
26
import org.eclipse.swt.widgets.Composite;
27
import org.eclipse.swt.widgets.Control;
28
import org.eclipse.swt.widgets.Label;
29
import org.eclipse.swt.widgets.List;
30
import org.eclipse.swt.widgets.Shell;
31
import org.eclipse.ui.internal.ide.IDEWorkbenchMessages;
32
33
/**
34
 * @since 3.4
35
 *
36
 */
37
public class MissingPathVariableDialog extends TitleAreaDialog {
38
39
	private Set missingNames;
40
	private IPathVariableManager manager;
41
	private Label variableNameLabel;
42
	private List variableNameField;
43
	private Button okButton;
44
45
	/**
46
	 * @param parentShell
47
	 */
48
	public MissingPathVariableDialog(Shell parentShell, IPathVariableManager manager, Set missingNames) {
49
		super(parentShell);
50
		this.missingNames = missingNames;
51
		this.manager = manager;
52
		this.manager.getPathVariableNames();
53
	}
54
55
	/* (non-Javadoc)
56
	 * @see org.eclipse.jface.dialogs.TitleAreaDialog#createDialogArea(org.eclipse.swt.widgets.Composite)
57
	 */
58
	protected Control createDialogArea(Composite parent) {
59
	    // top level composite
60
	    Composite parentComposite = (Composite) super.createDialogArea(parent);
61
	
62
	    initializeDialogUnits(parentComposite);
63
	    
64
	    // creates dialog area composite
65
	    Composite contents = createComposite(parentComposite);
66
	
67
	    // creates and lay outs dialog area widgets 
68
	    createWidgets(contents);
69
	
70
	
71
	    Dialog.applyDialogFont(parentComposite);
72
	    
73
	    return contents;
74
	}
75
76
	/**
77
	 * Creates and configures this dialog's main composite.
78
	 * 
79
	 * @param parentComposite parent's composite
80
	 * @return this dialog's main composite
81
	 */
82
	private Composite createComposite(Composite parentComposite) {
83
	    // creates a composite with standard margins and spacing
84
	    Composite contents = new Composite(parentComposite, SWT.NONE);
85
	
86
	    FormLayout layout = new FormLayout();
87
	
88
	    contents.setLayout(layout);
89
	    contents.setLayoutData(new GridData(GridData.FILL_BOTH));
90
	
91
		setTitle(IDEWorkbenchMessages.PathVariableDialog_dialogTitle_newVariable);
92
	    setMessage(IDEWorkbenchMessages.PathVariableDialog_message_newVariable);
93
	    return contents;
94
	}
95
96
	/**
97
	 * Creates widgets for this dialog.
98
	 * 
99
	 * @param contents the parent composite where to create widgets
100
	 */
101
	private void createWidgets(Composite contents) {
102
	    FormData data;
103
	
104
	    String nameLabelText = IDEWorkbenchMessages.PathVariableDialog_variableName;
105
	
106
	    // variable name label
107
	    variableNameLabel = new Label(contents, SWT.LEFT);
108
	    variableNameLabel.setText(nameLabelText);
109
	
110
	    data = new FormData();
111
	    data.top = new FormAttachment(0,
112
	    		convertVerticalDLUsToPixels(IDialogConstants.VERTICAL_MARGIN));
113
	    data.left = new FormAttachment(0,
114
	    		convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN));
115
	    variableNameLabel.setLayoutData(data);
116
	
117
	    // variable name field.  Attachments done after all widgets created.
118
	    variableNameField = new List(contents, SWT.SINGLE | SWT.BORDER);
119
	    String[] names = new String[missingNames.size()];
120
	    variableNameField.setItems((String[])this.missingNames.toArray(names));
121
	    
122
	
123
	    data = new FormData();
124
	    data.left = new FormAttachment(0,
125
	    		convertHorizontalDLUsToPixels(IDialogConstants.HORIZONTAL_MARGIN));
126
	    data.top = new FormAttachment(variableNameLabel,
127
	            convertVerticalDLUsToPixels(5));
128
129
 
130
        data = new FormData();
131
        data.left = new FormAttachment(variableNameLabel,
132
                convertHorizontalDLUsToPixels(5));
133
        data.top = new FormAttachment(variableNameLabel,
134
                convertVerticalDLUsToPixels(5), SWT.CENTER);
135
        variableNameField.setLayoutData(data);
136
        
137
138
139
	
140
	}
141
142
	/**
143
	 * Adds buttons to this dialog's button bar.
144
	 * 
145
	 * @see org.eclipse.jface.dialogs.Dialog#createButtonsForButtonBar
146
	 */
147
	protected void createButtonsForButtonBar(Composite parent) {
148
	    okButton = createButton(parent, IDialogConstants.OK_ID,
149
	            IDialogConstants.OK_LABEL, true);
150
	    okButton.setEnabled(true);
151
	
152
	    createButton(parent, IDialogConstants.CANCEL_ID,
153
	            IDialogConstants.CANCEL_LABEL, false);
154
	}
155
156
}

Return to bug 208085