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 114108
Collapse All | Expand All

(-)compare/org/eclipse/compare/internal/patch/PatchTargetPage.java (+8 lines)
Lines 22-27 Link Here
22
import org.eclipse.jface.dialogs.Dialog;
22
import org.eclipse.jface.dialogs.Dialog;
23
import org.eclipse.jface.dialogs.MessageDialog;
23
import org.eclipse.jface.dialogs.MessageDialog;
24
import org.eclipse.jface.viewers.CheckboxTreeViewer;
24
import org.eclipse.jface.viewers.CheckboxTreeViewer;
25
import org.eclipse.jface.viewers.DoubleClickEvent;
26
import org.eclipse.jface.viewers.IDoubleClickListener;
25
import org.eclipse.jface.viewers.ISelection;
27
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.viewers.ISelectionChangedListener;
28
import org.eclipse.jface.viewers.ISelectionChangedListener;
27
import org.eclipse.jface.viewers.SelectionChangedEvent;
29
import org.eclipse.jface.viewers.SelectionChangedEvent;
Lines 158-163 Link Here
158
				updateWidgetEnablements();
160
				updateWidgetEnablements();
159
			}
161
			}
160
		});
162
		});
163
		
164
		fPatchTargets.addDoubleClickListener(new IDoubleClickListener() {
165
			public void doubleClick(DoubleClickEvent event) {
166
				fPatchWizard.showPage(getNextPage());
167
			}
168
		});
161
	}
169
	}
162
170
163
	/**
171
	/**
(-)compare/org/eclipse/compare/internal/patch/PatchWizard.java (-1 / +17 lines)
Lines 15-20 Link Here
15
import org.eclipse.compare.internal.CompareUIPlugin;
15
import org.eclipse.compare.internal.CompareUIPlugin;
16
import org.eclipse.compare.internal.ExceptionHandler;
16
import org.eclipse.compare.internal.ExceptionHandler;
17
import org.eclipse.compare.internal.Utilities;
17
import org.eclipse.compare.internal.Utilities;
18
import org.eclipse.compare.internal.patch.CompareWithPatchAction.PatchWizardDialog;
18
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.resources.IResource;
19
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.CoreException;
20
import org.eclipse.core.runtime.IProgressMonitor;
21
import org.eclipse.core.runtime.IProgressMonitor;
Lines 22-27 Link Here
22
import org.eclipse.core.runtime.jobs.MultiRule;
23
import org.eclipse.core.runtime.jobs.MultiRule;
23
import org.eclipse.jface.dialogs.IDialogSettings;
24
import org.eclipse.jface.dialogs.IDialogSettings;
24
import org.eclipse.jface.viewers.ISelection;
25
import org.eclipse.jface.viewers.ISelection;
26
import org.eclipse.jface.wizard.IWizardPage;
25
import org.eclipse.jface.wizard.Wizard;
27
import org.eclipse.jface.wizard.Wizard;
26
import org.eclipse.ui.actions.WorkspaceModifyOperation;
28
import org.eclipse.ui.actions.WorkspaceModifyOperation;
27
29
Lines 36-41 Link Here
36
38
37
	private WorkspacePatcher fPatcher;
39
	private WorkspacePatcher fPatcher;
38
40
41
	private PatchWizardDialog dialog;
42
	
39
	/*
43
	/*
40
	 * Creates a wizard for applying a patch file to the workspace.
44
	 * Creates a wizard for applying a patch file to the workspace.
41
	 */
45
	 */
Lines 93-99 Link Here
93
	public boolean performFinish() {
97
	public boolean performFinish() {
94
		
98
		
95
		fPatcher.setName(fPatchWizardPage.getPatchName());
99
		fPatcher.setName(fPatchWizardPage.getPatchName());
96
100
		
101
		//Make sure that the patch has been read
102
		if (!fPatchWizardPage.isPatchRead())
103
			fPatchWizardPage.readInPatch();
104
		
97
		try {
105
		try {
98
			//Create scheduling rule based on the type of patch - single or workspace
106
			//Create scheduling rule based on the type of patch - single or workspace
99
			ISchedulingRule scheduleRule= null;
107
			ISchedulingRule scheduleRule= null;
Lines 138-142 Link Here
138
		
146
		
139
		return true;
147
		return true;
140
	}
148
	}
149
150
	public void setDialog(PatchWizardDialog dialog) {
151
		this.dialog = dialog;
152
	}
153
	
154
	public void showPage(IWizardPage page){
155
		dialog.showPage(page);
156
	}
141
}
157
}
142
158
(-)compare/org/eclipse/compare/internal/patch/CompareWithPatchAction.java (+1 lines)
Lines 82-87 Link Here
82
		
82
		
83
		if (areAllEditorsSaved()) {
83
		if (areAllEditorsSaved()) {
84
			PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard);
84
			PatchWizardDialog dialog= new PatchWizardDialog(CompareUIPlugin.getShell(), wizard);
85
			wizard.setDialog(dialog);
85
			dialog.open();
86
			dialog.open();
86
		}
87
		}
87
	}
88
	}
(-)compare/org/eclipse/compare/internal/patch/InputPatchPage.java (-27 / +51 lines)
Lines 29-34 Link Here
29
import org.eclipse.jface.dialogs.Dialog;
29
import org.eclipse.jface.dialogs.Dialog;
30
import org.eclipse.jface.dialogs.IDialogSettings;
30
import org.eclipse.jface.dialogs.IDialogSettings;
31
import org.eclipse.jface.dialogs.MessageDialog;
31
import org.eclipse.jface.dialogs.MessageDialog;
32
import org.eclipse.jface.viewers.DoubleClickEvent;
33
import org.eclipse.jface.viewers.IDoubleClickListener;
32
import org.eclipse.jface.viewers.ISelectionChangedListener;
34
import org.eclipse.jface.viewers.ISelectionChangedListener;
33
import org.eclipse.jface.viewers.SelectionChangedEvent;
35
import org.eclipse.jface.viewers.SelectionChangedEvent;
34
import org.eclipse.jface.viewers.StructuredSelection;
36
import org.eclipse.jface.viewers.StructuredSelection;
Lines 97-102 Link Here
97
	
99
	
98
	protected final static String INPUTPATCHPAGE_NAME= "InputPatchPage"; //$NON-NLS-1$
100
	protected final static String INPUTPATCHPAGE_NAME= "InputPatchPage"; //$NON-NLS-1$
99
	
101
	
102
	private String patchSource = null;
103
	
104
	private boolean patchRead = false;
105
	
100
	class ActivationListener extends ShellAdapter {
106
	class ActivationListener extends ShellAdapter {
101
		public void shellActivated(ShellEvent e) {
107
		public void shellActivated(ShellEvent e) {
102
			//Allow error messages if the selected input actually has something selected in it
108
			//Allow error messages if the selected input actually has something selected in it
Lines 173-181 Link Here
173
	public IWizardPage getNextPage() {
179
	public IWizardPage getNextPage() {
174
180
175
		WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher();
181
		WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher();
182
		
183
		//Read in the patch
184
		readInPatch();
185
		
186
		Diff[] diffs= patcher.getDiffs();
187
		if (diffs == null || diffs.length == 0) {
188
			String format= PatchMessages.InputPatchPage_NoDiffsFound_format;	
189
			String message= MessageFormat.format(format, new String[] { patchSource });
190
			MessageDialog.openInformation(null,
191
				PatchMessages.InputPatchPage_PatchErrorDialog_title, message); 
192
			return this;
193
		}
194
195
		// guess prefix count
196
		int guess= 0; // guessPrefix(diffs);
197
		patcher.setStripPrefixSegments(guess);
198
199
		//If this is a workspace patch we don't need to set a target as the targets will be figured out from 
200
		//all of the projects that make up the patch and continue on to final preview page 
201
		//else go on to target selection page
202
		if (patcher.isWorkspacePatch()) {
203
			return fPatchWizard.getPage(PreviewPatchPage.PREVIEWPATCHPAGE_NAME);
204
		}
176
205
177
		String source= ""; //$NON-NLS-1$
206
		return super.getNextPage();
207
	}
178
208
209
	/*
210
	 * Reads in the patch contents
211
	 */
212
	public void readInPatch(){
213
		WorkspacePatcher patcher= ((PatchWizard) getWizard()).getPatcher();
179
		// Create a reader for the input
214
		// Create a reader for the input
180
		Reader reader= null;
215
		Reader reader= null;
181
		try {
216
		try {
Lines 189-195 Link Here
189
					if (o instanceof String)
224
					if (o instanceof String)
190
						reader= new StringReader((String)o);
225
						reader= new StringReader((String)o);
191
				}
226
				}
192
				source= PatchMessages.InputPatchPage_Clipboard_title;
227
				patchSource= PatchMessages.InputPatchPage_Clipboard_title;
193
			} else if (inputMethod==FILE) {
228
			} else if (inputMethod==FILE) {
194
				String patchFilePath= getPatchFilePath();
229
				String patchFilePath= getPatchFilePath();
195
				if (patchFilePath != null) {
230
				if (patchFilePath != null) {
Lines 201-207 Link Here
201
							PatchMessages.InputPatchPage_PatchFileNotFound_message); 
236
							PatchMessages.InputPatchPage_PatchFileNotFound_message); 
202
					}
237
					}
203
				}
238
				}
204
				source= PatchMessages.InputPatchPage_PatchFile_title;
239
				patchSource= PatchMessages.InputPatchPage_PatchFile_title;
205
			} else if (inputMethod==WORKSPACE) {
240
			} else if (inputMethod==WORKSPACE) {
206
				//Get the selected patch file (tree will only allow for one selection)
241
				//Get the selected patch file (tree will only allow for one selection)
207
				IResource[] resources= Utilities.getResources(fTreeViewer.getSelection());
242
				IResource[] resources= Utilities.getResources(fTreeViewer.getSelection());
Lines 216-228 Link Here
216
						MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message);
251
						MessageDialog.openError(null, PatchMessages.InputPatchPage_PatchErrorDialog_title, PatchMessages.InputPatchPage_PatchFileNotFound_message);
217
					}
252
					}
218
				}
253
				}
219
				source= PatchMessages.InputPatchPage_WorkspacePatch_title;
254
				patchSource= PatchMessages.InputPatchPage_WorkspacePatch_title;
220
			}
255
			}
221
			
256
			
222
			// parse the input
257
			// parse the input
223
			if (reader != null) {
258
			if (reader != null) {
224
				try {
259
				try {
225
					patcher.parse(new BufferedReader(reader));
260
					patcher.parse(new BufferedReader(reader));
261
					patchRead=true;
226
				} catch (IOException ex) {
262
				} catch (IOException ex) {
227
					MessageDialog.openError(null,
263
					MessageDialog.openError(null,
228
						PatchMessages.InputPatchPage_PatchErrorDialog_title, 
264
						PatchMessages.InputPatchPage_PatchErrorDialog_title, 
Lines 238-267 Link Here
238
				}
274
				}
239
			}
275
			}
240
		}
276
		}
241
		
242
		Diff[] diffs= patcher.getDiffs();
243
		if (diffs == null || diffs.length == 0) {
244
			String format= PatchMessages.InputPatchPage_NoDiffsFound_format;	
245
			String message= MessageFormat.format(format, new String[] { source });
246
			MessageDialog.openInformation(null,
247
				PatchMessages.InputPatchPage_PatchErrorDialog_title, message); 
248
			return this;
249
		}
250
251
		// guess prefix count
252
		int guess= 0; // guessPrefix(diffs);
253
		patcher.setStripPrefixSegments(guess);
254
255
		//If this is a workspace patch we don't need to set a target as the targets will be figured out from 
256
		//all of the projects that make up the patch and continue on to final preview page 
257
		//else go on to target selection page
258
		if (patcher.isWorkspacePatch()) {
259
			return fPatchWizard.getPage(PreviewPatchPage.PREVIEWPATCHPAGE_NAME);
260
		}
261
262
		return super.getNextPage();
263
	}
277
	}
264
			
278
	
265
	/* (non-JavaDoc)
279
	/* (non-JavaDoc)
266
	 * Method declared in IWizardPage.
280
	 * Method declared in IWizardPage.
267
	 */
281
	 */
Lines 386-391 Link Here
386
				updateWidgetEnablements();
400
				updateWidgetEnablements();
387
			}
401
			}
388
		});
402
		});
403
		
404
		fTreeViewer.addDoubleClickListener(new IDoubleClickListener() {
405
			public void doubleClick(DoubleClickEvent event) {
406
				fPatchWizard.showPage(getNextPage());
407
			}
408
		});
389
	}
409
	}
390
410
391
	private void addWorkspaceControls(Composite composite) {
411
	private void addWorkspaceControls(Composite composite) {
Lines 812-816 Link Here
812
		
832
		
813
		return (String[]) l.toArray(new String[l.size()]);
833
		return (String[]) l.toArray(new String[l.size()]);
814
	}
834
	}
835
836
	public boolean isPatchRead() {
837
		return patchRead;
838
	}
815
}
839
}
816
840

Return to bug 114108