Lines 34-40
Link Here
|
34 |
import org.eclipse.compare.structuremergeviewer.DiffNode; |
34 |
import org.eclipse.compare.structuremergeviewer.DiffNode; |
35 |
import org.eclipse.compare.structuremergeviewer.Differencer; |
35 |
import org.eclipse.compare.structuremergeviewer.Differencer; |
36 |
import org.eclipse.compare.structuremergeviewer.ICompareInput; |
36 |
import org.eclipse.compare.structuremergeviewer.ICompareInput; |
37 |
import org.eclipse.compare.structuremergeviewer.IDiffElement; |
|
|
38 |
import org.eclipse.core.resources.IContainer; |
37 |
import org.eclipse.core.resources.IContainer; |
39 |
import org.eclipse.core.resources.IFile; |
38 |
import org.eclipse.core.resources.IFile; |
40 |
import org.eclipse.core.resources.IProject; |
39 |
import org.eclipse.core.resources.IProject; |
Lines 56-62
Link Here
|
56 |
import org.eclipse.jface.text.Document; |
55 |
import org.eclipse.jface.text.Document; |
57 |
import org.eclipse.jface.text.IDocument; |
56 |
import org.eclipse.jface.text.IDocument; |
58 |
import org.eclipse.jface.text.Position; |
57 |
import org.eclipse.jface.text.Position; |
|
|
58 |
import org.eclipse.jface.viewers.CheckStateChangedEvent; |
59 |
import org.eclipse.jface.viewers.CheckboxTreeViewer; |
59 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
60 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
|
|
61 |
import org.eclipse.jface.viewers.ICheckStateListener; |
60 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
62 |
import org.eclipse.jface.viewers.IDoubleClickListener; |
61 |
import org.eclipse.jface.viewers.ISelection; |
63 |
import org.eclipse.jface.viewers.ISelection; |
62 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
64 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
Lines 86-92
Link Here
|
86 |
import org.eclipse.swt.widgets.Listener; |
88 |
import org.eclipse.swt.widgets.Listener; |
87 |
import org.eclipse.swt.widgets.Shell; |
89 |
import org.eclipse.swt.widgets.Shell; |
88 |
import org.eclipse.swt.widgets.Text; |
90 |
import org.eclipse.swt.widgets.Text; |
|
|
91 |
import org.eclipse.swt.widgets.TreeItem; |
89 |
import org.eclipse.ui.IWorkbenchPart; |
92 |
import org.eclipse.ui.IWorkbenchPart; |
|
|
93 |
import org.eclipse.ui.dialogs.ContainerCheckedTreeViewer; |
90 |
import org.eclipse.ui.model.BaseWorkbenchContentProvider; |
94 |
import org.eclipse.ui.model.BaseWorkbenchContentProvider; |
91 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
95 |
import org.eclipse.ui.model.WorkbenchLabelProvider; |
92 |
import org.eclipse.ui.views.navigator.ResourceComparator; |
96 |
import org.eclipse.ui.views.navigator.ResourceComparator; |
Lines 97-146
Link Here
|
97 |
*/ |
101 |
*/ |
98 |
public class GenerateDiffFileWizard extends Wizard { |
102 |
public class GenerateDiffFileWizard extends Wizard { |
99 |
|
103 |
|
100 |
//The initial size of this wizard. |
104 |
// The initial size of this wizard. |
101 |
protected final static int INITIAL_WIDTH = 300; |
105 |
protected final static int INITIAL_WIDTH = 300; |
102 |
protected final static int INITIAL_HEIGHT = 350; |
106 |
protected final static int INITIAL_HEIGHT = 350; |
103 |
|
107 |
|
104 |
public static void run(DocumentMerger merger, Shell shell, boolean rightToLeft) { |
108 |
public static void run(DocumentMerger merger, Shell shell, |
|
|
109 |
boolean rightToLeft) { |
105 |
final String title = CompareMessages.GenerateLocalDiff_title; |
110 |
final String title = CompareMessages.GenerateLocalDiff_title; |
106 |
final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(merger, rightToLeft); |
111 |
final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard( |
|
|
112 |
merger, rightToLeft); |
107 |
wizard.setWindowTitle(title); |
113 |
wizard.setWindowTitle(title); |
108 |
WizardDialog dialog = new WizardDialog(shell, wizard); |
114 |
WizardDialog dialog = new WizardDialog(shell, wizard); |
109 |
|
115 |
|
110 |
dialog.addPageChangingListener(new IPageChangingListener() { |
116 |
dialog.addPageChangingListener(new IPageChangingListener() { |
111 |
|
117 |
|
112 |
public void handlePageChanging(PageChangingEvent event) { |
118 |
public void handlePageChanging(PageChangingEvent event) { |
113 |
if(event.getTargetPage() instanceof LocationPage) { |
119 |
if (event.getTargetPage() instanceof LocationPage) { |
114 |
LocationPage page = (LocationPage) event.getTargetPage(); |
120 |
LocationPage page = (LocationPage) event.getTargetPage(); |
115 |
page.updateAssociatedResources(); |
121 |
page.updateChangesControl(); |
116 |
} |
122 |
} |
117 |
} |
123 |
} |
118 |
|
124 |
|
119 |
}); |
125 |
}); |
120 |
|
126 |
|
121 |
dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); |
127 |
dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); |
122 |
dialog.open(); |
128 |
dialog.open(); |
123 |
} |
129 |
} |
|
|
130 |
|
124 |
public static void run(IResource[] input, Shell shell) { |
131 |
public static void run(IResource[] input, Shell shell) { |
125 |
final String title = CompareMessages.GenerateLocalDiff_title; |
132 |
final String title = CompareMessages.GenerateLocalDiff_title; |
126 |
final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(input); |
133 |
final GenerateDiffFileWizard wizard = new GenerateDiffFileWizard(input); |
127 |
wizard.setWindowTitle(title); |
134 |
wizard.setWindowTitle(title); |
128 |
WizardDialog dialog = new WizardDialog(shell, wizard); |
135 |
WizardDialog dialog = new WizardDialog(shell, wizard); |
129 |
|
136 |
|
130 |
dialog.addPageChangingListener(new IPageChangingListener() { |
137 |
dialog.addPageChangingListener(new IPageChangingListener() { |
131 |
|
138 |
|
132 |
public void handlePageChanging(PageChangingEvent event) { |
139 |
public void handlePageChanging(PageChangingEvent event) { |
133 |
if(event.getTargetPage() instanceof LocationPage) { |
140 |
if (event.getTargetPage() instanceof LocationPage) { |
134 |
LocationPage page = (LocationPage) event.getTargetPage(); |
141 |
LocationPage page = (LocationPage) event.getTargetPage(); |
135 |
page.updateAssociatedResources(); |
142 |
page.updateChangesControl(); |
136 |
} |
143 |
} |
137 |
} |
144 |
} |
138 |
|
145 |
|
139 |
}); |
146 |
}); |
140 |
|
147 |
|
141 |
dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); |
148 |
dialog.setMinimumPageSize(INITIAL_WIDTH, INITIAL_HEIGHT); |
142 |
dialog.open(); |
149 |
dialog.open(); |
143 |
|
150 |
|
144 |
} |
151 |
} |
145 |
|
152 |
|
146 |
protected class DirectionSelectionPage extends WizardPage { |
153 |
protected class DirectionSelectionPage extends WizardPage { |
Lines 169-201
Link Here
|
169 |
|
176 |
|
170 |
layout.marginHeight = IDialogConstants.VERTICAL_MARGIN; |
177 |
layout.marginHeight = IDialogConstants.VERTICAL_MARGIN; |
171 |
layout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN; |
178 |
layout.marginWidth = IDialogConstants.HORIZONTAL_MARGIN; |
172 |
layout.verticalSpacing = IDialogConstants.VERTICAL_SPACING*2; |
179 |
layout.verticalSpacing = IDialogConstants.VERTICAL_SPACING * 2; |
173 |
layout.horizontalSpacing = IDialogConstants.HORIZONTAL_SPACING*2; |
180 |
layout.horizontalSpacing = IDialogConstants.HORIZONTAL_SPACING * 2; |
174 |
layout.numColumns = 2; |
181 |
layout.numColumns = 2; |
175 |
|
182 |
|
176 |
composite.setLayout(layout); |
183 |
composite.setLayout(layout); |
177 |
composite.setLayoutData(new GridData()); |
184 |
composite.setLayoutData(new GridData()); |
178 |
setControl(composite); |
185 |
setControl(composite); |
179 |
|
186 |
|
180 |
fromLeftLabel = new Label(composite, SWT.HORIZONTAL|SWT.SHADOW_OUT); |
187 |
fromLeftLabel = new Label(composite, SWT.HORIZONTAL |
|
|
188 |
| SWT.SHADOW_OUT); |
181 |
fromLeftLabel.setText(CompareMessages.GenerateDiffFileWizard_Left); |
189 |
fromLeftLabel.setText(CompareMessages.GenerateDiffFileWizard_Left); |
182 |
fromLeftLabel.setLayoutData(new GridData( |
190 |
fromLeftLabel.setLayoutData(new GridData(SWT.BEGINNING, SWT.CENTER, |
183 |
SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); |
191 |
false, false, 1, 1)); |
184 |
|
192 |
|
185 |
fromLeftOption = new Button(composite, SWT.RADIO); |
193 |
fromLeftOption = new Button(composite, SWT.RADIO); |
186 |
fromLeftOption.setText(leftPath); |
194 |
fromLeftOption.setText(leftPath); |
187 |
fromLeftOption.setLayoutData(new GridData( |
195 |
fromLeftOption.setLayoutData(new GridData(SWT.BEGINNING, |
188 |
SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); |
196 |
SWT.CENTER, false, false, 1, 1)); |
189 |
|
197 |
|
190 |
fromRightLabel = new Label(composite, SWT.HORIZONTAL|SWT.SHADOW_OUT); |
198 |
fromRightLabel = new Label(composite, SWT.HORIZONTAL |
191 |
fromRightLabel.setText(CompareMessages.GenerateDiffFileWizard_Right); |
199 |
| SWT.SHADOW_OUT); |
192 |
fromRightLabel.setLayoutData(new GridData( |
200 |
fromRightLabel |
193 |
SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); |
201 |
.setText(CompareMessages.GenerateDiffFileWizard_Right); |
|
|
202 |
fromRightLabel.setLayoutData(new GridData(SWT.BEGINNING, |
203 |
SWT.CENTER, false, false, 1, 1)); |
194 |
|
204 |
|
195 |
fromRightOption = new Button(composite, SWT.RADIO); |
205 |
fromRightOption = new Button(composite, SWT.RADIO); |
196 |
fromRightOption.setText(rightPath); |
206 |
fromRightOption.setText(rightPath); |
197 |
fromRightOption.setLayoutData(new GridData( |
207 |
fromRightOption.setLayoutData(new GridData(SWT.BEGINNING, |
198 |
SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); |
208 |
SWT.CENTER, false, false, 1, 1)); |
199 |
|
209 |
|
200 |
fromRadioGroup.add(LEFT_OPTION, fromLeftOption); |
210 |
fromRadioGroup.add(LEFT_OPTION, fromLeftOption); |
201 |
fromRadioGroup.add(RIGHT_OPTION, fromRightOption); |
211 |
fromRadioGroup.add(RIGHT_OPTION, fromRightOption); |
Lines 260-278
Link Here
|
260 |
protected IPath[] foldersToCreate; |
270 |
protected IPath[] foldersToCreate; |
261 |
protected int selectedLocation; |
271 |
protected int selectedLocation; |
262 |
|
272 |
|
|
|
273 |
private ContainerCheckedTreeViewer viewer; |
274 |
private LocalChangesContentProvider provider; |
263 |
/** |
275 |
/** |
264 |
* The default values store used to initialize the selections. |
276 |
* The default values store used to initialize the selections. |
265 |
*/ |
277 |
*/ |
266 |
private final DefaultValuesStore store; |
278 |
private final DefaultValuesStore store; |
|
|
279 |
private Button chgSelectAll; |
280 |
private Button chgDeselectAll; |
267 |
|
281 |
|
268 |
class LocationPageContentProvider extends BaseWorkbenchContentProvider { |
282 |
class LocationPageContentProvider extends BaseWorkbenchContentProvider { |
269 |
//Never show closed projects |
283 |
// Never show closed projects |
270 |
boolean showClosedProjects=false; |
284 |
boolean showClosedProjects = false; |
271 |
|
285 |
|
272 |
public Object[] getChildren(Object element) { |
286 |
public Object[] getChildren(Object element) { |
273 |
if (element instanceof IWorkspace) { |
287 |
if (element instanceof IWorkspace) { |
274 |
// check if closed projects should be shown |
288 |
// check if closed projects should be shown |
275 |
IProject[] allProjects = ((IWorkspace) element).getRoot().getProjects(); |
289 |
IProject[] allProjects = ((IWorkspace) element).getRoot() |
|
|
290 |
.getProjects(); |
276 |
if (showClosedProjects) |
291 |
if (showClosedProjects) |
277 |
return allProjects; |
292 |
return allProjects; |
278 |
|
293 |
|
Lines 305-319
Link Here
|
305 |
Control control = super.createContents(parent); |
320 |
Control control = super.createContents(parent); |
306 |
setTitle(CompareMessages.WorkspacePatchDialogTitle); |
321 |
setTitle(CompareMessages.WorkspacePatchDialogTitle); |
307 |
setMessage(CompareMessages.WorkspacePatchDialogDescription); |
322 |
setMessage(CompareMessages.WorkspacePatchDialogDescription); |
308 |
//create title image |
323 |
// create title image |
309 |
dlgTitleImage = CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF).createImage(); |
324 |
dlgTitleImage = CompareUIPlugin.getImageDescriptor( |
|
|
325 |
ICompareUIConstants.IMG_WIZBAN_DIFF).createImage(); |
310 |
setTitleImage(dlgTitleImage); |
326 |
setTitleImage(dlgTitleImage); |
311 |
|
327 |
|
312 |
return control; |
328 |
return control; |
313 |
} |
329 |
} |
314 |
|
330 |
|
315 |
protected Control createDialogArea(Composite parent) { |
331 |
protected Control createDialogArea(Composite parent) { |
316 |
Composite parentComposite = (Composite) super.createDialogArea(parent); |
332 |
Composite parentComposite = (Composite) super |
|
|
333 |
.createDialogArea(parent); |
317 |
|
334 |
|
318 |
// create a composite with standard margins and spacing |
335 |
// create a composite with standard margins and spacing |
319 |
Composite composite = new Composite(parentComposite, SWT.NONE); |
336 |
Composite composite = new Composite(parentComposite, SWT.NONE); |
Lines 329-352
Link Here
|
329 |
getShell().setText(CompareMessages.GenerateDiffFileWizard_9); |
346 |
getShell().setText(CompareMessages.GenerateDiffFileWizard_9); |
330 |
|
347 |
|
331 |
wsTreeViewer = new TreeViewer(composite, SWT.BORDER); |
348 |
wsTreeViewer = new TreeViewer(composite, SWT.BORDER); |
332 |
final GridData gd= new GridData(SWT.FILL, SWT.FILL, true, true); |
349 |
final GridData gd = new GridData(SWT.FILL, SWT.FILL, true, true); |
333 |
gd.widthHint= 550; |
350 |
gd.widthHint = 550; |
334 |
gd.heightHint= 250; |
351 |
gd.heightHint = 250; |
335 |
wsTreeViewer.getTree().setLayoutData(gd); |
352 |
wsTreeViewer.getTree().setLayoutData(gd); |
336 |
|
353 |
|
337 |
wsTreeViewer.setContentProvider(new LocationPageContentProvider()); |
354 |
wsTreeViewer |
338 |
wsTreeViewer.setComparator(new ResourceComparator(ResourceComparator.NAME)); |
355 |
.setContentProvider(new LocationPageContentProvider()); |
|
|
356 |
wsTreeViewer.setComparator(new ResourceComparator( |
357 |
ResourceComparator.NAME)); |
339 |
wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); |
358 |
wsTreeViewer.setLabelProvider(new WorkbenchLabelProvider()); |
340 |
wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); |
359 |
wsTreeViewer.setInput(ResourcesPlugin.getWorkspace()); |
341 |
|
360 |
|
342 |
//Open to whatever is selected in the workspace field |
361 |
// Open to whatever is selected in the workspace field |
343 |
IPath existingWorkspacePath = new Path(wsPathText.getText()); |
362 |
IPath existingWorkspacePath = new Path(wsPathText.getText()); |
344 |
if (existingWorkspacePath != null){ |
363 |
if (existingWorkspacePath != null) { |
345 |
//Ensure that this workspace path is valid |
364 |
// Ensure that this workspace path is valid |
346 |
IResource selectedResource = ResourcesPlugin.getWorkspace().getRoot().findMember(existingWorkspacePath); |
365 |
IResource selectedResource = ResourcesPlugin.getWorkspace() |
|
|
366 |
.getRoot().findMember(existingWorkspacePath); |
347 |
if (selectedResource != null) { |
367 |
if (selectedResource != null) { |
348 |
wsTreeViewer.expandToLevel(selectedResource, 0); |
368 |
wsTreeViewer.expandToLevel(selectedResource, 0); |
349 |
wsTreeViewer.setSelection(new StructuredSelection(selectedResource)); |
369 |
wsTreeViewer.setSelection(new StructuredSelection( |
|
|
370 |
selectedResource)); |
350 |
} |
371 |
} |
351 |
} |
372 |
} |
352 |
|
373 |
|
Lines 354-367
Link Here
|
354 |
layout = new GridLayout(2, false); |
375 |
layout = new GridLayout(2, false); |
355 |
layout.marginWidth = 0; |
376 |
layout.marginWidth = 0; |
356 |
group.setLayout(layout); |
377 |
group.setLayout(layout); |
357 |
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); |
378 |
group.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, |
|
|
379 |
false)); |
358 |
|
380 |
|
359 |
final Label label = new Label(group, SWT.NONE); |
381 |
final Label label = new Label(group, SWT.NONE); |
360 |
label.setLayoutData(new GridData()); |
382 |
label.setLayoutData(new GridData()); |
361 |
label.setText(CompareMessages.Fi_le_name__9); |
383 |
label.setText(CompareMessages.Fi_le_name__9); |
362 |
|
384 |
|
363 |
wsFilenameText = new Text(group,SWT.BORDER); |
385 |
wsFilenameText = new Text(group, SWT.BORDER); |
364 |
wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false)); |
386 |
wsFilenameText.setLayoutData(new GridData(SWT.FILL, SWT.TOP, |
|
|
387 |
true, false)); |
365 |
|
388 |
|
366 |
setupListeners(); |
389 |
setupListeners(); |
367 |
|
390 |
|
Lines 394-400
Link Here
|
394 |
} |
417 |
} |
395 |
// make sure that the filename is valid |
418 |
// make sure that the filename is valid |
396 |
if (!(ResourcesPlugin.getWorkspace().validateName(fileName, |
419 |
if (!(ResourcesPlugin.getWorkspace().validateName(fileName, |
397 |
IResource.FILE)).isOK() && modified) { |
420 |
IResource.FILE)).isOK() |
|
|
421 |
&& modified) { |
398 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); |
422 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); |
399 |
getButton(IDialogConstants.OK_ID).setEnabled(false); |
423 |
getButton(IDialogConstants.OK_ID).setEnabled(false); |
400 |
return; |
424 |
return; |
Lines 431-437
Link Here
|
431 |
} |
455 |
} |
432 |
|
456 |
|
433 |
private IContainer getSelectedContainer() { |
457 |
private IContainer getSelectedContainer() { |
434 |
Object obj = ((IStructuredSelection)wsTreeViewer.getSelection()).getFirstElement(); |
458 |
Object obj = ((IStructuredSelection) wsTreeViewer |
|
|
459 |
.getSelection()).getFirstElement(); |
435 |
if (obj instanceof IContainer) { |
460 |
if (obj instanceof IContainer) { |
436 |
wsSelectedContainer = (IContainer) obj; |
461 |
wsSelectedContainer = (IContainer) obj; |
437 |
} else if (obj instanceof IFile) { |
462 |
} else if (obj instanceof IFile) { |
Lines 451-465
Link Here
|
451 |
return super.close(); |
476 |
return super.close(); |
452 |
} |
477 |
} |
453 |
|
478 |
|
454 |
void setupListeners(){ |
479 |
void setupListeners() { |
455 |
wsTreeViewer.addSelectionChangedListener( |
480 |
wsTreeViewer |
456 |
new ISelectionChangedListener() { |
481 |
.addSelectionChangedListener(new ISelectionChangedListener() { |
457 |
public void selectionChanged(SelectionChangedEvent event) { |
482 |
public void selectionChanged( |
458 |
IStructuredSelection s = (IStructuredSelection)event.getSelection(); |
483 |
SelectionChangedEvent event) { |
459 |
Object obj=s.getFirstElement(); |
484 |
IStructuredSelection s = (IStructuredSelection) event |
|
|
485 |
.getSelection(); |
486 |
Object obj = s.getFirstElement(); |
460 |
if (obj instanceof IContainer) |
487 |
if (obj instanceof IContainer) |
461 |
wsSelectedContainer = (IContainer) obj; |
488 |
wsSelectedContainer = (IContainer) obj; |
462 |
else if (obj instanceof IFile){ |
489 |
else if (obj instanceof IFile) { |
463 |
IFile tempFile = (IFile) obj; |
490 |
IFile tempFile = (IFile) obj; |
464 |
wsSelectedContainer = tempFile.getParent(); |
491 |
wsSelectedContainer = tempFile.getParent(); |
465 |
wsFilenameText.setText(tempFile.getName()); |
492 |
wsFilenameText.setText(tempFile.getName()); |
Lines 468-487
Link Here
|
468 |
} |
495 |
} |
469 |
}); |
496 |
}); |
470 |
|
497 |
|
471 |
wsTreeViewer.addDoubleClickListener( |
498 |
wsTreeViewer.addDoubleClickListener(new IDoubleClickListener() { |
472 |
new IDoubleClickListener() { |
499 |
public void doubleClick(DoubleClickEvent event) { |
473 |
public void doubleClick(DoubleClickEvent event) { |
500 |
ISelection s = event.getSelection(); |
474 |
ISelection s= event.getSelection(); |
501 |
if (s instanceof IStructuredSelection) { |
475 |
if (s instanceof IStructuredSelection) { |
502 |
Object item = ((IStructuredSelection) s) |
476 |
Object item = ((IStructuredSelection)s).getFirstElement(); |
503 |
.getFirstElement(); |
477 |
if (wsTreeViewer.getExpandedState(item)) |
504 |
if (wsTreeViewer.getExpandedState(item)) |
478 |
wsTreeViewer.collapseToLevel(item, 1); |
505 |
wsTreeViewer.collapseToLevel(item, 1); |
479 |
else |
506 |
else |
480 |
wsTreeViewer.expandToLevel(item, 1); |
507 |
wsTreeViewer.expandToLevel(item, 1); |
481 |
} |
508 |
} |
482 |
validateDialog(); |
509 |
validateDialog(); |
483 |
} |
510 |
} |
484 |
}); |
511 |
}); |
485 |
|
512 |
|
486 |
wsFilenameText.addModifyListener(new ModifyListener() { |
513 |
wsFilenameText.addModifyListener(new ModifyListener() { |
487 |
public void modifyText(ModifyEvent e) { |
514 |
public void modifyText(ModifyEvent e) { |
Lines 492-514
Link Here
|
492 |
} |
519 |
} |
493 |
} |
520 |
} |
494 |
|
521 |
|
495 |
LocationPage(String pageName, String title, ImageDescriptor image, DefaultValuesStore store) { |
522 |
LocationPage(String pageName, String title, ImageDescriptor image, |
|
|
523 |
DefaultValuesStore store) { |
496 |
super(pageName, title, image); |
524 |
super(pageName, title, image); |
497 |
setPageComplete(false); |
525 |
setPageComplete(false); |
498 |
this.store= store; |
526 |
this.store = store; |
499 |
} |
527 |
} |
500 |
|
528 |
|
501 |
public void updateAssociatedResources() { |
529 |
public void updateChangesControl() { |
502 |
Differencer dif = new Differencer(); |
530 |
Differencer dif = new Differencer(); |
503 |
if(directionSelectionPage.isRightToLeft()) |
531 |
if (directionSelectionPage.isRightToLeft()) |
504 |
startNode = (DiffNode) dif.findDifferences(false, null, null, null, |
532 |
startNode = (DiffNode) dif.findDifferences(false, null, null, |
505 |
new FilteredBufferedResourceNode(rightResource), |
533 |
null, new FilteredBufferedResourceNode(rightResource), |
506 |
new FilteredBufferedResourceNode(leftResource)); |
534 |
new FilteredBufferedResourceNode(leftResource)); |
507 |
else if(!directionSelectionPage.isRightToLeft()) |
535 |
else if (!directionSelectionPage.isRightToLeft()) |
508 |
startNode = (DiffNode) dif.findDifferences(false, null, null, null, |
536 |
startNode = (DiffNode) dif.findDifferences(false, null, null, |
509 |
new FilteredBufferedResourceNode(leftResource), |
537 |
null, new FilteredBufferedResourceNode(leftResource), |
510 |
new FilteredBufferedResourceNode(rightResource)); |
538 |
new FilteredBufferedResourceNode(rightResource)); |
511 |
associatedResources = buildMap(startNode); |
539 |
provider.setNode(startNode); |
|
|
540 |
viewer.refresh(); |
541 |
initCheckedItems(); |
542 |
associatedResources = getSelectedAssociatedFiles(); |
512 |
} |
543 |
} |
513 |
|
544 |
|
514 |
/** |
545 |
/** |
Lines 517-535
Link Here
|
517 |
protected boolean validatePage() { |
548 |
protected boolean validatePage() { |
518 |
switch (selectedLocation) { |
549 |
switch (selectedLocation) { |
519 |
case WORKSPACE: |
550 |
case WORKSPACE: |
520 |
pageValid= validateWorkspaceLocation(); |
551 |
pageValid = validateWorkspaceLocation(); |
521 |
break; |
552 |
break; |
522 |
case FILESYSTEM: |
553 |
case FILESYSTEM: |
523 |
pageValid= validateFilesystemLocation(); |
554 |
pageValid = validateFilesystemLocation(); |
524 |
break; |
555 |
break; |
525 |
case CLIPBOARD: |
556 |
case CLIPBOARD: |
526 |
pageValid= true; |
557 |
pageValid = true; |
527 |
break; |
558 |
break; |
528 |
} |
559 |
} |
529 |
|
560 |
|
|
|
561 |
if ((associatedResources = getSelectedAssociatedFiles()).size() == 0) { |
562 |
pageValid = false; |
563 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_noChangesSelected); |
564 |
} |
565 |
|
530 |
/** |
566 |
/** |
531 |
* Avoid draw flicker by clearing error message |
567 |
* Avoid draw flicker by clearing error message if all is valid. |
532 |
* if all is valid. |
|
|
533 |
*/ |
568 |
*/ |
534 |
if (pageValid) { |
569 |
if (pageValid) { |
535 |
setMessage(null); |
570 |
setMessage(null); |
Lines 540-555
Link Here
|
540 |
} |
575 |
} |
541 |
|
576 |
|
542 |
/** |
577 |
/** |
543 |
* The following conditions must hold for the file system location |
578 |
* The following conditions must hold for the file system location to be |
544 |
* to be valid: |
579 |
* valid: - the path must be valid and non-empty - the path must be |
545 |
* - the path must be valid and non-empty |
580 |
* absolute - the specified file must be of type file - the parent must |
546 |
* - the path must be absolute |
581 |
* exist (new folders can be created via the browse button) |
547 |
* - the specified file must be of type file |
|
|
548 |
* - the parent must exist (new folders can be created via the browse button) |
549 |
*/ |
582 |
*/ |
550 |
private boolean validateFilesystemLocation() { |
583 |
private boolean validateFilesystemLocation() { |
551 |
final String pathString= fsPathText.getText().trim(); |
584 |
final String pathString = fsPathText.getText().trim(); |
552 |
if (pathString.length() == 0 || !new Path("").isValidPath(pathString)) { //$NON-NLS-1$ |
585 |
if (pathString.length() == 0 |
|
|
586 |
|| !new Path("").isValidPath(pathString)) { //$NON-NLS-1$ |
553 |
if (fsBrowsed) |
587 |
if (fsBrowsed) |
554 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); |
588 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); |
555 |
else |
589 |
else |
Lines 557-563
Link Here
|
557 |
return false; |
591 |
return false; |
558 |
} |
592 |
} |
559 |
|
593 |
|
560 |
final File file= new File(pathString); |
594 |
final File file = new File(pathString); |
561 |
if (!file.isAbsolute()) { |
595 |
if (!file.isAbsolute()) { |
562 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); |
596 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_0); |
563 |
return false; |
597 |
return false; |
Lines 568-579
Link Here
|
568 |
return false; |
602 |
return false; |
569 |
} |
603 |
} |
570 |
|
604 |
|
571 |
if (pathString.endsWith("/") || pathString.endsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ |
605 |
if (pathString.endsWith("/") || pathString.endsWith("\\")) { //$NON-NLS-1$//$NON-NLS-2$ |
572 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); |
606 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); |
573 |
return false; |
607 |
return false; |
574 |
} |
608 |
} |
575 |
|
609 |
|
576 |
final File parent= file.getParentFile(); |
610 |
final File parent = file.getParentFile(); |
577 |
if (!(parent.exists() && parent.isDirectory())) { |
611 |
if (!(parent.exists() && parent.isDirectory())) { |
578 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); |
612 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_3); |
579 |
return false; |
613 |
return false; |
Lines 582-617
Link Here
|
582 |
} |
616 |
} |
583 |
|
617 |
|
584 |
/** |
618 |
/** |
585 |
* The following conditions must hold for the file system location to be valid: |
619 |
* The following conditions must hold for the file system location to be |
586 |
* - a parent must be selected in the workspace tree view |
620 |
* valid: - a parent must be selected in the workspace tree view - the |
587 |
* - the resource name must be valid |
621 |
* resource name must be valid |
588 |
*/ |
622 |
*/ |
589 |
private boolean validateWorkspaceLocation() { |
623 |
private boolean validateWorkspaceLocation() { |
590 |
//make sure that the field actually has a filename in it - making |
624 |
// make sure that the field actually has a filename in it - making |
591 |
//sure that the user has had a chance to browse the workspace first |
625 |
// sure that the user has had a chance to browse the workspace first |
592 |
if (wsPathText.getText().equals("")){ //$NON-NLS-1$ |
626 |
if (wsPathText.getText().equals("")) { //$NON-NLS-1$ |
593 |
if (selectedLocation ==WORKSPACE && wsBrowsed) |
627 |
if (selectedLocation == WORKSPACE && wsBrowsed) |
594 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); |
628 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_5); |
595 |
else |
629 |
else |
596 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); |
630 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); |
597 |
return false; |
631 |
return false; |
598 |
} |
632 |
} |
599 |
|
633 |
|
600 |
//Make sure that all the segments but the last one (i.e. project + all |
634 |
// Make sure that all the segments but the last one (i.e. project + |
601 |
//folders) exist - file doesn't have to exist. It may have happened that |
635 |
// all |
602 |
//some folder refactoring has been done since this path was last saved. |
636 |
// folders) exist - file doesn't have to exist. It may have happened |
|
|
637 |
// that |
638 |
// some folder refactoring has been done since this path was last |
639 |
// saved. |
603 |
// |
640 |
// |
604 |
// The path will always be in format project/{folders}*/file - this |
641 |
// The path will always be in format project/{folders}*/file - this |
605 |
// is controlled by the workspace location dialog and by |
642 |
// is controlled by the workspace location dialog and by |
606 |
// validatePath method when path has been entered manually. |
643 |
// validatePath method when path has been entered manually. |
607 |
|
644 |
|
608 |
|
|
|
609 |
IPath pathToWorkspaceFile = new Path(wsPathText.getText()); |
645 |
IPath pathToWorkspaceFile = new Path(wsPathText.getText()); |
610 |
IStatus status = ResourcesPlugin.getWorkspace().validatePath(wsPathText.getText(), IResource.FILE); |
646 |
IStatus status = ResourcesPlugin.getWorkspace().validatePath( |
|
|
647 |
wsPathText.getText(), IResource.FILE); |
611 |
if (status.isOK()) { |
648 |
if (status.isOK()) { |
612 |
//Trim file name from path |
649 |
// Trim file name from path |
613 |
IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); |
650 |
IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); |
614 |
IResource container =ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); |
651 |
IResource container = ResourcesPlugin.getWorkspace().getRoot() |
|
|
652 |
.findMember(containerPath); |
615 |
if (container == null) { |
653 |
if (container == null) { |
616 |
if (selectedLocation == WORKSPACE) |
654 |
if (selectedLocation == WORKSPACE) |
617 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); |
655 |
setErrorMessage(CompareMessages.GenerateDiffFileWizard_4); |
Lines 636-680
Link Here
|
636 |
} |
674 |
} |
637 |
|
675 |
|
638 |
/** |
676 |
/** |
639 |
* Answers a full path to a file system file or <code>null</code> if the user |
677 |
* Answers a full path to a file system file or <code>null</code> if the |
640 |
* selected to save the patch in the clipboard. |
678 |
* user selected to save the patch in the clipboard. |
641 |
*/ |
679 |
*/ |
642 |
public File getFile() { |
680 |
public File getFile() { |
643 |
if (pageValid && selectedLocation == FILESYSTEM) { |
681 |
if (pageValid && selectedLocation == FILESYSTEM) { |
644 |
return new File(fsPathText.getText().trim()); |
682 |
return new File(fsPathText.getText().trim()); |
645 |
} |
683 |
} |
646 |
if (pageValid && selectedLocation == WORKSPACE) { |
684 |
if (pageValid && selectedLocation == WORKSPACE) { |
647 |
final String filename= wsPathText.getText().trim(); |
685 |
final String filename = wsPathText.getText().trim(); |
648 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
686 |
IWorkspaceRoot root = ResourcesPlugin.getWorkspace().getRoot(); |
649 |
final IFile file= root.getFile(new Path(filename)); |
687 |
final IFile file = root.getFile(new Path(filename)); |
650 |
return file.getLocation().toFile(); |
688 |
return file.getLocation().toFile(); |
651 |
} |
689 |
} |
652 |
return null; |
690 |
return null; |
653 |
} |
691 |
} |
654 |
|
692 |
|
655 |
/** |
693 |
/** |
656 |
* Answers the workspace string entered in the dialog or <code>null</code> if the user |
694 |
* Answers the workspace string entered in the dialog or |
657 |
* selected to save the patch in the clipboard or file system. |
695 |
* <code>null</code> if the user selected to save the patch in the |
|
|
696 |
* clipboard or file system. |
658 |
*/ |
697 |
*/ |
659 |
public String getWorkspaceLocation() { |
698 |
public String getWorkspaceLocation() { |
660 |
|
699 |
|
661 |
if (pageValid && selectedLocation == WORKSPACE) { |
700 |
if (pageValid && selectedLocation == WORKSPACE) { |
662 |
final String filename= wsPathText.getText().trim(); |
701 |
final String filename = wsPathText.getText().trim(); |
663 |
return filename; |
702 |
return filename; |
664 |
} |
703 |
} |
665 |
return null; |
704 |
return null; |
666 |
} |
705 |
} |
667 |
|
706 |
|
668 |
/** |
707 |
/** |
669 |
* Get the selected workspace resource if the patch is to be saved in the |
708 |
* Get the selected workspace resource if the patch is to be saved in |
670 |
* workspace, or null otherwise. |
709 |
* the workspace, or null otherwise. |
671 |
*/ |
710 |
*/ |
672 |
public IResource getResource() { |
711 |
public IResource getResource() { |
673 |
if (pageValid && selectedLocation == WORKSPACE) { |
712 |
if (pageValid && selectedLocation == WORKSPACE) { |
674 |
IPath pathToWorkspaceFile = new Path(wsPathText.getText().trim()); |
713 |
IPath pathToWorkspaceFile = new Path(wsPathText.getText() |
675 |
//Trim file name from path |
714 |
.trim()); |
|
|
715 |
// Trim file name from path |
676 |
IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); |
716 |
IPath containerPath = pathToWorkspaceFile.removeLastSegments(1); |
677 |
return ResourcesPlugin.getWorkspace().getRoot().findMember(containerPath); |
717 |
return ResourcesPlugin.getWorkspace().getRoot().findMember( |
|
|
718 |
containerPath); |
678 |
} |
719 |
} |
679 |
return null; |
720 |
return null; |
680 |
} |
721 |
} |
Lines 685-691
Link Here
|
685 |
*/ |
726 |
*/ |
686 |
public void createControl(Composite parent) { |
727 |
public void createControl(Composite parent) { |
687 |
|
728 |
|
688 |
final Composite composite= new Composite(parent, SWT.NULL); |
729 |
final Composite composite = new Composite(parent, SWT.NULL); |
689 |
GridLayout lay = new GridLayout(); |
730 |
GridLayout lay = new GridLayout(); |
690 |
lay.verticalSpacing = 15; |
731 |
lay.verticalSpacing = 15; |
691 |
composite.setLayout(lay); |
732 |
composite.setLayout(lay); |
Lines 693-705
Link Here
|
693 |
initializeDialogUnits(composite); |
734 |
initializeDialogUnits(composite); |
694 |
|
735 |
|
695 |
// set F1 help |
736 |
// set F1 help |
696 |
// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_SELECTION_PAGE); |
737 |
// TODO: |
|
|
738 |
// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, |
739 |
// IHelpContextIds.PATCH_SELECTION_PAGE); |
697 |
|
740 |
|
698 |
//Create a location group |
741 |
// Create a location group |
699 |
setupLocationControls(composite); |
742 |
setupLocationControls(composite); |
700 |
|
743 |
|
701 |
initializeDefaultValues(); |
744 |
initializeDefaultValues(); |
702 |
|
745 |
|
|
|
746 |
Label changesLabel = new Label(composite, SWT.HORIZONTAL); |
747 |
changesLabel.setText("Changes"); |
748 |
|
749 |
viewer = new ContainerCheckedTreeViewer(composite, SWT.CHECK |
750 |
| SWT.H_SCROLL | SWT.V_SCROLL | SWT.BORDER | SWT.HORIZONTAL); |
751 |
|
752 |
viewer.getControl().setLayoutData(new GridData(GridData.FILL_BOTH)); |
753 |
provider = new LocalChangesContentProvider(startNode); |
754 |
viewer.setContentProvider(provider); |
755 |
viewer.setLabelProvider(new LocalChangesLabelProvider()); |
756 |
viewer.setInput(leftResource.getWorkspace().getRoot()); |
757 |
initCheckedItems(); |
758 |
|
759 |
createSelectionButtons(composite); |
760 |
|
703 |
Dialog.applyDialogFont(parent); |
761 |
Dialog.applyDialogFont(parent); |
704 |
|
762 |
|
705 |
validatePage(); |
763 |
validatePage(); |
Lines 708-714
Link Here
|
708 |
setupListeners(); |
766 |
setupListeners(); |
709 |
} |
767 |
} |
710 |
|
768 |
|
711 |
|
769 |
private void createSelectionButtons(Composite composite) { |
|
|
770 |
final Composite buttonGroup = new Composite(composite, SWT.NONE); |
771 |
GridLayout layout = new GridLayout(); |
772 |
layout.numColumns = 2; |
773 |
layout.marginWidth = 0; |
774 |
layout.marginHeight = 0; |
775 |
layout.horizontalSpacing = 0; |
776 |
layout.verticalSpacing = 0; |
777 |
buttonGroup.setLayout(layout); |
778 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_END |
779 |
| GridData.VERTICAL_ALIGN_CENTER); |
780 |
buttonGroup.setLayoutData(data); |
781 |
|
782 |
chgSelectAll = createSelectionButton( |
783 |
CompareMessages.GenerateDiffFileWizard_SelectAll, |
784 |
buttonGroup); |
785 |
chgDeselectAll = createSelectionButton( |
786 |
CompareMessages.GenerateDiffFileWizard_DeselectAll, |
787 |
buttonGroup); |
788 |
} |
789 |
|
790 |
private Button createSelectionButton(String buttonName, |
791 |
Composite buttonGroup) { |
792 |
Button button = new Button(buttonGroup, SWT.PUSH); |
793 |
button.setText(buttonName); |
794 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
795 |
int widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
796 |
Point minSize = button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
797 |
data.widthHint = Math.max(widthHint, minSize.x); |
798 |
button.setLayoutData(data); |
799 |
return button; |
800 |
} |
801 |
|
712 |
/** |
802 |
/** |
713 |
* Setup the controls for the location. |
803 |
* Setup the controls for the location. |
714 |
*/ |
804 |
*/ |
Lines 756-767
Link Here
|
756 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
846 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL); |
757 |
widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
847 |
widthHint = convertHorizontalDLUsToPixels(IDialogConstants.BUTTON_WIDTH); |
758 |
minSize = fsBrowseButton |
848 |
minSize = fsBrowseButton |
759 |
.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
849 |
.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); |
760 |
data.widthHint = Math.max(widthHint, minSize.x); |
850 |
data.widthHint = Math.max(widthHint, minSize.x); |
761 |
wsBrowseButton.setLayoutData(data); |
851 |
wsBrowseButton.setLayoutData(data); |
762 |
|
852 |
|
763 |
// change the cpRadio layout to be of the same height as other rows' layout |
853 |
// change the cpRadio layout to be of the same height as other rows' |
764 |
((GridData)cpRadio.getLayoutData()).heightHint = minSize.y; |
854 |
// layout |
|
|
855 |
((GridData) cpRadio.getLayoutData()).heightHint = minSize.y; |
765 |
} |
856 |
} |
766 |
|
857 |
|
767 |
/** |
858 |
/** |
Lines 770-776
Link Here
|
770 |
*/ |
861 |
*/ |
771 |
private void initializeDefaultValues() { |
862 |
private void initializeDefaultValues() { |
772 |
|
863 |
|
773 |
selectedLocation= store.getLocationSelection(); |
864 |
selectedLocation = store.getLocationSelection(); |
774 |
|
865 |
|
775 |
updateRadioButtons(); |
866 |
updateRadioButtons(); |
776 |
|
867 |
|
Lines 778-795
Link Here
|
778 |
* Text fields. |
869 |
* Text fields. |
779 |
*/ |
870 |
*/ |
780 |
// We need to ensure that we have a valid workspace path - user |
871 |
// We need to ensure that we have a valid workspace path - user |
781 |
//could have altered workspace since last time this was saved |
872 |
// could have altered workspace since last time this was saved |
782 |
wsPathText.setText(store.getWorkspacePath()); |
873 |
wsPathText.setText(store.getWorkspacePath()); |
783 |
if(!validateWorkspaceLocation()) { |
874 |
if (!validateWorkspaceLocation()) { |
784 |
wsPathText.setText(""); //$NON-NLS-1$ |
875 |
wsPathText.setText(""); //$NON-NLS-1$ |
785 |
|
876 |
|
786 |
//Don't open wizard with an error - instead change selection |
877 |
// Don't open wizard with an error - instead change selection |
787 |
//to clipboard |
878 |
// to clipboard |
788 |
if (selectedLocation == WORKSPACE){ |
879 |
if (selectedLocation == WORKSPACE) { |
789 |
//clear the error message caused by the workspace not having |
880 |
// clear the error message caused by the workspace not |
790 |
//any workspace path entered |
881 |
// having |
|
|
882 |
// any workspace path entered |
791 |
setErrorMessage(null); |
883 |
setErrorMessage(null); |
792 |
selectedLocation=CLIPBOARD; |
884 |
selectedLocation = CLIPBOARD; |
793 |
updateRadioButtons(); |
885 |
updateRadioButtons(); |
794 |
} |
886 |
} |
795 |
} |
887 |
} |
Lines 822-835
Link Here
|
822 |
|
914 |
|
823 |
cpRadio.addListener(SWT.Selection, new Listener() { |
915 |
cpRadio.addListener(SWT.Selection, new Listener() { |
824 |
public void handleEvent(Event event) { |
916 |
public void handleEvent(Event event) { |
825 |
selectedLocation= CLIPBOARD; |
917 |
selectedLocation = CLIPBOARD; |
826 |
validatePage(); |
918 |
validatePage(); |
827 |
updateEnablements(); |
919 |
updateEnablements(); |
828 |
} |
920 |
} |
829 |
}); |
921 |
}); |
830 |
fsRadio.addListener(SWT.Selection, new Listener() { |
922 |
fsRadio.addListener(SWT.Selection, new Listener() { |
831 |
public void handleEvent(Event event) { |
923 |
public void handleEvent(Event event) { |
832 |
selectedLocation= FILESYSTEM; |
924 |
selectedLocation = FILESYSTEM; |
833 |
validatePage(); |
925 |
validatePage(); |
834 |
updateEnablements(); |
926 |
updateEnablements(); |
835 |
} |
927 |
} |
Lines 837-843
Link Here
|
837 |
|
929 |
|
838 |
wsRadio.addListener(SWT.Selection, new Listener() { |
930 |
wsRadio.addListener(SWT.Selection, new Listener() { |
839 |
public void handleEvent(Event event) { |
931 |
public void handleEvent(Event event) { |
840 |
selectedLocation= WORKSPACE; |
932 |
selectedLocation = WORKSPACE; |
841 |
validatePage(); |
933 |
validatePage(); |
842 |
updateEnablements(); |
934 |
updateEnablements(); |
843 |
} |
935 |
} |
Lines 853-861
Link Here
|
853 |
|
945 |
|
854 |
fsBrowseButton.addListener(SWT.Selection, new Listener() { |
946 |
fsBrowseButton.addListener(SWT.Selection, new Listener() { |
855 |
public void handleEvent(Event event) { |
947 |
public void handleEvent(Event event) { |
856 |
final FileDialog dialog = new FileDialog(getShell(), SWT.PRIMARY_MODAL | SWT.SAVE); |
948 |
final FileDialog dialog = new FileDialog(getShell(), |
|
|
949 |
SWT.PRIMARY_MODAL | SWT.SAVE); |
857 |
if (pageValid) { |
950 |
if (pageValid) { |
858 |
final File file= new File(fsPathText.getText()); |
951 |
final File file = new File(fsPathText.getText()); |
859 |
dialog.setFilterPath(file.getParent()); |
952 |
dialog.setFilterPath(file.getParent()); |
860 |
} |
953 |
} |
861 |
dialog.setText(CompareMessages.Save_Patch_As_5); |
954 |
dialog.setText(CompareMessages.Save_Patch_As_5); |
Lines 869-887
Link Here
|
869 |
} |
962 |
} |
870 |
}); |
963 |
}); |
871 |
|
964 |
|
872 |
|
|
|
873 |
|
874 |
wsBrowseButton.addListener(SWT.Selection, new Listener() { |
965 |
wsBrowseButton.addListener(SWT.Selection, new Listener() { |
875 |
public void handleEvent(Event event) { |
966 |
public void handleEvent(Event event) { |
876 |
final WorkspaceDialog dialog = new WorkspaceDialog(getShell()); |
967 |
final WorkspaceDialog dialog = new WorkspaceDialog( |
|
|
968 |
getShell()); |
877 |
wsBrowsed = true; |
969 |
wsBrowsed = true; |
878 |
dialog.open(); |
970 |
dialog.open(); |
879 |
validatePage(); |
971 |
validatePage(); |
880 |
} |
972 |
} |
881 |
}); |
973 |
}); |
882 |
|
974 |
|
|
|
975 |
chgSelectAll.addSelectionListener(new SelectionAdapter() { |
976 |
public void widgetSelected(SelectionEvent e) { |
977 |
initCheckedItems(); |
978 |
// Only bother changing isPageComplete state if the current |
979 |
// state |
980 |
// is not enabled |
981 |
if (!isPageComplete()) |
982 |
setPageComplete(validatePage()); |
983 |
} |
984 |
}); |
985 |
|
986 |
chgDeselectAll.addSelectionListener(new SelectionAdapter() { |
987 |
public void widgetSelected(SelectionEvent e) { |
988 |
viewer.setCheckedElements(new Object[0]); |
989 |
// Only bother changing isPageComplete state if the current |
990 |
// state |
991 |
// is enabled |
992 |
if (isPageComplete()) |
993 |
setPageComplete(validatePage()); |
994 |
} |
995 |
}); |
996 |
|
997 |
viewer.addCheckStateListener(new ICheckStateListener() { |
998 |
public void checkStateChanged(CheckStateChangedEvent event) { |
999 |
setPageComplete(validatePage()); |
1000 |
} |
1001 |
}); |
1002 |
|
883 |
} |
1003 |
} |
884 |
|
1004 |
|
|
|
1005 |
protected void initCheckedItems() { |
1006 |
TreeItem[] items = ((CheckboxTreeViewer) viewer).getTree() |
1007 |
.getItems(); |
1008 |
for (int i = 0; i < items.length; i++) { |
1009 |
((CheckboxTreeViewer) viewer).setChecked(items[i].getData(), |
1010 |
true); |
1011 |
} |
1012 |
} |
1013 |
|
1014 |
protected ArrayList getSelectedAssociatedFiles() { |
1015 |
Object[] elements = viewer.getCheckedElements(); |
1016 |
ArrayList result = new ArrayList(); |
1017 |
for (int i = 0; i < elements.length; i++) { |
1018 |
if (!(elements[i] instanceof IProject)) { |
1019 |
DiffNode node = (DiffNode) elements[i]; |
1020 |
IResource lr = Utilities.getResource(node.getLeft()); |
1021 |
IResource rr = Utilities.getResource(node.getRight()); |
1022 |
if (lr instanceof IFile || rr instanceof IFile) |
1023 |
result.add(new Object[] { lr, rr }); |
1024 |
} |
1025 |
} |
1026 |
return result; |
1027 |
} |
1028 |
|
885 |
/** |
1029 |
/** |
886 |
* Enable and disable controls based on the selected radio button. |
1030 |
* Enable and disable controls based on the selected radio button. |
887 |
*/ |
1031 |
*/ |
Lines 889-899
Link Here
|
889 |
fsBrowseButton.setEnabled(selectedLocation == FILESYSTEM); |
1033 |
fsBrowseButton.setEnabled(selectedLocation == FILESYSTEM); |
890 |
fsPathText.setEnabled(selectedLocation == FILESYSTEM); |
1034 |
fsPathText.setEnabled(selectedLocation == FILESYSTEM); |
891 |
if (selectedLocation == FILESYSTEM) |
1035 |
if (selectedLocation == FILESYSTEM) |
892 |
fsBrowsed=false; |
1036 |
fsBrowsed = false; |
893 |
wsPathText.setEnabled(selectedLocation == WORKSPACE); |
1037 |
wsPathText.setEnabled(selectedLocation == WORKSPACE); |
894 |
wsBrowseButton.setEnabled(selectedLocation == WORKSPACE); |
1038 |
wsBrowseButton.setEnabled(selectedLocation == WORKSPACE); |
895 |
if (selectedLocation == WORKSPACE) |
1039 |
if (selectedLocation == WORKSPACE) |
896 |
wsBrowsed=false; |
1040 |
wsBrowsed = false; |
897 |
} |
1041 |
} |
898 |
|
1042 |
|
899 |
public int getSelectedLocation() { |
1043 |
public int getSelectedLocation() { |
Lines 915-921
Link Here
|
915 |
public final static int FORMAT_STANDARD = 3; |
1059 |
public final static int FORMAT_STANDARD = 3; |
916 |
|
1060 |
|
917 |
/** |
1061 |
/** |
918 |
The possible root of the patch |
1062 |
* The possible root of the patch |
919 |
*/ |
1063 |
*/ |
920 |
public final static int ROOT_WORKSPACE = 1; |
1064 |
public final static int ROOT_WORKSPACE = 1; |
921 |
public final static int ROOT_PROJECT = 2; |
1065 |
public final static int ROOT_PROJECT = 2; |
Lines 925-933
Link Here
|
925 |
protected boolean initialized = false; |
1069 |
protected boolean initialized = false; |
926 |
|
1070 |
|
927 |
protected Button unifiedDiffOption; |
1071 |
protected Button unifiedDiffOption; |
928 |
protected Button unified_workspaceRelativeOption; //multi-patch format |
1072 |
protected Button unified_workspaceRelativeOption; // multi-patch format |
929 |
protected Button unified_projectRelativeOption; //full project path |
1073 |
protected Button unified_projectRelativeOption; // full project path |
930 |
protected Button unified_selectionRelativeOption; //use path of whatever is selected |
1074 |
protected Button unified_selectionRelativeOption; // use path of |
|
|
1075 |
// whatever is |
1076 |
// selected |
931 |
protected Button contextDiffOption; |
1077 |
protected Button contextDiffOption; |
932 |
protected Button regularDiffOption; |
1078 |
protected Button regularDiffOption; |
933 |
|
1079 |
|
Lines 942-948
Link Here
|
942 |
/** |
1088 |
/** |
943 |
* Constructor for PatchFileCreationOptionsPage. |
1089 |
* Constructor for PatchFileCreationOptionsPage. |
944 |
*/ |
1090 |
*/ |
945 |
protected OptionsPage(String pageName, String title, ImageDescriptor titleImage, DefaultValuesStore store) { |
1091 |
protected OptionsPage(String pageName, String title, |
|
|
1092 |
ImageDescriptor titleImage, DefaultValuesStore store) { |
946 |
super(pageName, title, titleImage); |
1093 |
super(pageName, title, titleImage); |
947 |
this.store = store; |
1094 |
this.store = store; |
948 |
} |
1095 |
} |
Lines 951-975
Link Here
|
951 |
* @see IDialogPage#createControl(Composite) |
1098 |
* @see IDialogPage#createControl(Composite) |
952 |
*/ |
1099 |
*/ |
953 |
public void createControl(Composite parent) { |
1100 |
public void createControl(Composite parent) { |
954 |
Composite composite= new Composite(parent, SWT.NULL); |
1101 |
Composite composite = new Composite(parent, SWT.NULL); |
955 |
GridLayout layout= new GridLayout(); |
1102 |
GridLayout layout = new GridLayout(); |
956 |
composite.setLayout(layout); |
1103 |
composite.setLayout(layout); |
957 |
composite.setLayoutData(new GridData()); |
1104 |
composite.setLayoutData(new GridData()); |
958 |
setControl(composite); |
1105 |
setControl(composite); |
959 |
|
1106 |
|
960 |
// set F1 help |
1107 |
// set F1 help |
961 |
// TODO: PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, IHelpContextIds.PATCH_OPTIONS_PAGE); |
1108 |
// TODO: |
|
|
1109 |
// PlatformUI.getWorkbench().getHelpSystem().setHelp(composite, |
1110 |
// IHelpContextIds.PATCH_OPTIONS_PAGE); |
962 |
|
1111 |
|
963 |
diffTypeGroup = new Group(composite, SWT.NONE); |
1112 |
diffTypeGroup = new Group(composite, SWT.NONE); |
964 |
layout = new GridLayout(); |
1113 |
layout = new GridLayout(); |
965 |
layout.marginHeight = 0; |
1114 |
layout.marginHeight = 0; |
966 |
diffTypeGroup.setLayout(layout); |
1115 |
diffTypeGroup.setLayout(layout); |
967 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); |
1116 |
GridData data = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
|
|
1117 |
| GridData.GRAB_HORIZONTAL); |
968 |
diffTypeGroup.setLayoutData(data); |
1118 |
diffTypeGroup.setLayoutData(data); |
969 |
diffTypeGroup.setText(CompareMessages.Diff_output_format_12); |
1119 |
diffTypeGroup.setText(CompareMessages.Diff_output_format_12); |
970 |
|
1120 |
|
971 |
unifiedDiffOption = new Button(diffTypeGroup, SWT.RADIO); |
1121 |
unifiedDiffOption = new Button(diffTypeGroup, SWT.RADIO); |
972 |
unifiedDiffOption.setText(CompareMessages.Unified__format_required_by_Compare_With_Patch_feature__13); |
1122 |
unifiedDiffOption |
|
|
1123 |
.setText(CompareMessages.Unified__format_required_by_Compare_With_Patch_feature__13); |
973 |
|
1124 |
|
974 |
contextDiffOption = new Button(diffTypeGroup, SWT.RADIO); |
1125 |
contextDiffOption = new Button(diffTypeGroup, SWT.RADIO); |
975 |
contextDiffOption.setText(CompareMessages.Context_14); |
1126 |
contextDiffOption.setText(CompareMessages.Context_14); |
Lines 985-1018
Link Here
|
985 |
layout = new GridLayout(); |
1136 |
layout = new GridLayout(); |
986 |
layout.numColumns = 2; |
1137 |
layout.numColumns = 2; |
987 |
unifiedGroup.setLayout(layout); |
1138 |
unifiedGroup.setLayout(layout); |
988 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL | GridData.GRAB_HORIZONTAL); |
1139 |
data = new GridData(GridData.HORIZONTAL_ALIGN_FILL |
|
|
1140 |
| GridData.GRAB_HORIZONTAL); |
989 |
unifiedGroup.setLayoutData(data); |
1141 |
unifiedGroup.setLayoutData(data); |
990 |
unifiedGroup.setText(CompareMessages.GenerateDiffFileWizard_10); |
1142 |
unifiedGroup.setText(CompareMessages.GenerateDiffFileWizard_10); |
991 |
|
1143 |
|
992 |
unified_workspaceRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
1144 |
unified_workspaceRelativeOption = new Button(unifiedGroup, |
993 |
unified_workspaceRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_6); |
1145 |
SWT.RADIO); |
|
|
1146 |
unified_workspaceRelativeOption |
1147 |
.setText(CompareMessages.GenerateDiffFileWizard_6); |
994 |
unified_workspaceRelativeOption.setLayoutData(new GridData( |
1148 |
unified_workspaceRelativeOption.setLayoutData(new GridData( |
995 |
SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); |
1149 |
SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); |
996 |
|
1150 |
|
997 |
unified_projectRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
1151 |
unified_projectRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
998 |
unified_projectRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_7); |
1152 |
unified_projectRelativeOption |
|
|
1153 |
.setText(CompareMessages.GenerateDiffFileWizard_7); |
999 |
unified_projectRelativeOption.setLayoutData(new GridData( |
1154 |
unified_projectRelativeOption.setLayoutData(new GridData( |
1000 |
SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); |
1155 |
SWT.BEGINNING, SWT.CENTER, false, false, 2, 1)); |
1001 |
|
1156 |
|
1002 |
unified_selectionRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
1157 |
unified_selectionRelativeOption = new Button(unifiedGroup, |
1003 |
unified_selectionRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_8); |
1158 |
SWT.RADIO); |
|
|
1159 |
unified_selectionRelativeOption |
1160 |
.setText(CompareMessages.GenerateDiffFileWizard_8); |
1004 |
unified_selectionRelativeOption.setLayoutData(new GridData( |
1161 |
unified_selectionRelativeOption.setLayoutData(new GridData( |
1005 |
SWT.BEGINNING, SWT.CENTER, false, true, 2, 1)); |
1162 |
SWT.BEGINNING, SWT.CENTER, false, true, 2, 1)); |
1006 |
|
1163 |
|
1007 |
unifiedRadioGroup.add(ROOT_WORKSPACE, unified_workspaceRelativeOption); |
1164 |
unifiedRadioGroup.add(ROOT_WORKSPACE, |
|
|
1165 |
unified_workspaceRelativeOption); |
1008 |
unifiedRadioGroup.add(ROOT_PROJECT, unified_projectRelativeOption); |
1166 |
unifiedRadioGroup.add(ROOT_PROJECT, unified_projectRelativeOption); |
1009 |
unifiedRadioGroup.add(ROOT_SELECTION, unified_selectionRelativeOption); |
1167 |
unifiedRadioGroup.add(ROOT_SELECTION, |
|
|
1168 |
unified_selectionRelativeOption); |
1010 |
|
1169 |
|
1011 |
Dialog.applyDialogFont(parent); |
1170 |
Dialog.applyDialogFont(parent); |
1012 |
|
1171 |
|
1013 |
initializeDefaultValues(); |
1172 |
initializeDefaultValues(); |
1014 |
|
1173 |
|
1015 |
//add listeners |
1174 |
// add listeners |
1016 |
unifiedDiffOption.addSelectionListener(new SelectionAdapter() { |
1175 |
unifiedDiffOption.addSelectionListener(new SelectionAdapter() { |
1017 |
public void widgetSelected(SelectionEvent e) { |
1176 |
public void widgetSelected(SelectionEvent e) { |
1018 |
setEnableUnifiedGroup(true); |
1177 |
setEnableUnifiedGroup(true); |
Lines 1038-1062
Link Here
|
1038 |
}); |
1197 |
}); |
1039 |
|
1198 |
|
1040 |
unified_workspaceRelativeOption |
1199 |
unified_workspaceRelativeOption |
1041 |
.addSelectionListener(new SelectionAdapter() { |
1200 |
.addSelectionListener(new SelectionAdapter() { |
1042 |
public void widgetSelected(SelectionEvent e) { |
1201 |
public void widgetSelected(SelectionEvent e) { |
1043 |
unifiedRadioGroup.setSelection(ROOT_WORKSPACE, false); |
1202 |
unifiedRadioGroup.setSelection(ROOT_WORKSPACE, |
1044 |
} |
1203 |
false); |
1045 |
}); |
1204 |
} |
|
|
1205 |
}); |
1046 |
|
1206 |
|
1047 |
unified_projectRelativeOption |
1207 |
unified_projectRelativeOption |
1048 |
.addSelectionListener(new SelectionAdapter() { |
1208 |
.addSelectionListener(new SelectionAdapter() { |
1049 |
public void widgetSelected(SelectionEvent e) { |
1209 |
public void widgetSelected(SelectionEvent e) { |
1050 |
unifiedRadioGroup.setSelection(ROOT_PROJECT, false); |
1210 |
unifiedRadioGroup.setSelection(ROOT_PROJECT, false); |
1051 |
} |
1211 |
} |
1052 |
}); |
1212 |
}); |
1053 |
|
1213 |
|
1054 |
unified_selectionRelativeOption |
1214 |
unified_selectionRelativeOption |
1055 |
.addSelectionListener(new SelectionAdapter() { |
1215 |
.addSelectionListener(new SelectionAdapter() { |
1056 |
public void widgetSelected(SelectionEvent e) { |
1216 |
public void widgetSelected(SelectionEvent e) { |
1057 |
unifiedRadioGroup.setSelection(ROOT_SELECTION, false); |
1217 |
unifiedRadioGroup.setSelection(ROOT_SELECTION, |
1058 |
} |
1218 |
false); |
1059 |
}); |
1219 |
} |
|
|
1220 |
}); |
1060 |
|
1221 |
|
1061 |
updateEnablements(); |
1222 |
updateEnablements(); |
1062 |
|
1223 |
|
Lines 1099-1105
Link Here
|
1099 |
} |
1260 |
} |
1100 |
|
1261 |
|
1101 |
protected void updateEnablements() { |
1262 |
protected void updateEnablements() { |
1102 |
if(diffTypeRadioGroup.selected != FORMAT_UNIFIED) |
1263 |
if (diffTypeRadioGroup.selected != FORMAT_UNIFIED) |
1103 |
setEnableUnifiedGroup(false); |
1264 |
setEnableUnifiedGroup(false); |
1104 |
} |
1265 |
} |
1105 |
|
1266 |
|
Lines 1132-1144
Link Here
|
1132 |
private final IDialogSettings dialogSettings; |
1293 |
private final IDialogSettings dialogSettings; |
1133 |
|
1294 |
|
1134 |
public DefaultValuesStore() { |
1295 |
public DefaultValuesStore() { |
1135 |
dialogSettings= CompareUIPlugin.getDefault().getDialogSettings(); |
1296 |
dialogSettings = CompareUIPlugin.getDefault().getDialogSettings(); |
1136 |
} |
1297 |
} |
1137 |
|
1298 |
|
1138 |
public int getLocationSelection() { |
1299 |
public int getLocationSelection() { |
1139 |
int value= LocationPage.CLIPBOARD; |
1300 |
int value = LocationPage.CLIPBOARD; |
1140 |
try { |
1301 |
try { |
1141 |
value= dialogSettings.getInt(PREF_LAST_SELECTION); |
1302 |
value = dialogSettings.getInt(PREF_LAST_SELECTION); |
1142 |
} catch (NumberFormatException e) { |
1303 |
} catch (NumberFormatException e) { |
1143 |
} |
1304 |
} |
1144 |
|
1305 |
|
Lines 1153-1168
Link Here
|
1153 |
} |
1314 |
} |
1154 |
|
1315 |
|
1155 |
public String getFilesystemPath() { |
1316 |
public String getFilesystemPath() { |
1156 |
final String path= dialogSettings.get(PREF_LAST_FS_PATH); |
1317 |
final String path = dialogSettings.get(PREF_LAST_FS_PATH); |
1157 |
return path != null ? path : ""; //$NON-NLS-1$ |
1318 |
return path != null ? path : ""; //$NON-NLS-1$ |
1158 |
} |
1319 |
} |
1159 |
|
1320 |
|
1160 |
public String getWorkspacePath() { |
1321 |
public String getWorkspacePath() { |
1161 |
final String path= dialogSettings.get(PREF_LAST_WS_PATH); |
1322 |
final String path = dialogSettings.get(PREF_LAST_WS_PATH); |
1162 |
return path != null ? path : ""; //$NON-NLS-1$ |
1323 |
return path != null ? path : ""; //$NON-NLS-1$ |
1163 |
} |
1324 |
} |
1164 |
|
1325 |
|
1165 |
|
|
|
1166 |
public int getFormatSelection() { |
1326 |
public int getFormatSelection() { |
1167 |
int value = OptionsPage.FORMAT_UNIFIED; |
1327 |
int value = OptionsPage.FORMAT_UNIFIED; |
1168 |
try { |
1328 |
try { |
Lines 1237-1245
Link Here
|
1237 |
|
1397 |
|
1238 |
private IResource rightResource; |
1398 |
private IResource rightResource; |
1239 |
private IResource leftResource; |
1399 |
private IResource leftResource; |
1240 |
|
1400 |
|
1241 |
private ArrayList associatedResources; |
1401 |
private ArrayList associatedResources; |
1242 |
|
1402 |
|
1243 |
public GenerateDiffFileWizard() { |
1403 |
public GenerateDiffFileWizard() { |
1244 |
super(); |
1404 |
super(); |
1245 |
setWindowTitle(CompareMessages.GenerateLocalDiff_title); |
1405 |
setWindowTitle(CompareMessages.GenerateLocalDiff_title); |
Lines 1249-1354
Link Here
|
1249 |
} |
1409 |
} |
1250 |
|
1410 |
|
1251 |
private DiffNode startNode; |
1411 |
private DiffNode startNode; |
1252 |
|
1412 |
|
1253 |
public GenerateDiffFileWizard(IResource[] input) { |
1413 |
public GenerateDiffFileWizard(IResource[] input) { |
1254 |
this(); |
1414 |
this(); |
1255 |
|
1415 |
|
1256 |
this.leftDoc = new Document(); |
1416 |
this.leftDoc = new Document(); |
1257 |
this.rightDoc = new Document(); |
1417 |
this.rightDoc = new Document(); |
1258 |
|
1418 |
|
1259 |
leftResource = input[0]; |
1419 |
leftResource = input[0]; |
1260 |
rightResource = input[1]; |
1420 |
rightResource = input[1]; |
1261 |
|
1421 |
|
1262 |
leftPath = leftResource.getFullPath().toString(); |
1422 |
leftPath = leftResource.getFullPath().toString(); |
1263 |
rightPath = rightResource.getFullPath().toString(); |
1423 |
rightPath = rightResource.getFullPath().toString(); |
1264 |
|
1424 |
|
1265 |
Differencer dif = new Differencer(); |
1425 |
Differencer dif = new Differencer(); |
1266 |
startNode = (DiffNode) dif.findDifferences(false, null, null, null, |
1426 |
startNode = (DiffNode) dif.findDifferences(false, null, null, null, |
1267 |
new FilteredBufferedResourceNode(leftResource), |
1427 |
new FilteredBufferedResourceNode(leftResource), |
1268 |
new FilteredBufferedResourceNode(rightResource)); |
1428 |
new FilteredBufferedResourceNode(rightResource)); |
1269 |
associatedResources = buildMap(startNode); |
1429 |
|
1270 |
|
|
|
1271 |
} |
1430 |
} |
1272 |
|
1431 |
|
1273 |
public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) { |
1432 |
public GenerateDiffFileWizard(DocumentMerger merger, boolean rightToLeft) { |
1274 |
this(); |
1433 |
this(); |
1275 |
this.leftDoc = merger.getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); |
1434 |
this.leftDoc = merger |
1276 |
this.rightDoc = merger.getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); |
1435 |
.getDocument(MergeViewerContentProvider.LEFT_CONTRIBUTOR); |
|
|
1436 |
this.rightDoc = merger |
1437 |
.getDocument(MergeViewerContentProvider.RIGHT_CONTRIBUTOR); |
1277 |
this.leftPath = merger.getCompareConfiguration().getLeftLabel(leftDoc); |
1438 |
this.leftPath = merger.getCompareConfiguration().getLeftLabel(leftDoc); |
1278 |
this.rightPath = merger.getCompareConfiguration().getRightLabel(rightDoc); |
1439 |
this.rightPath = merger.getCompareConfiguration().getRightLabel( |
|
|
1440 |
rightDoc); |
1279 |
this.rightToLeft = rightToLeft; |
1441 |
this.rightToLeft = rightToLeft; |
1280 |
IWorkbenchPart workbenchPart = merger.getCompareConfiguration().getContainer().getWorkbenchPart(); |
1442 |
IWorkbenchPart workbenchPart = merger.getCompareConfiguration() |
1281 |
|
1443 |
.getContainer().getWorkbenchPart(); |
1282 |
if(workbenchPart instanceof CompareEditor) { |
1444 |
|
1283 |
|
1445 |
if (workbenchPart instanceof CompareEditor) { |
1284 |
CompareEditor editor = (CompareEditor)workbenchPart; |
1446 |
|
1285 |
|
1447 |
CompareEditor editor = (CompareEditor) workbenchPart; |
1286 |
CompareEditorInput input = (CompareEditorInput)editor.getEditorInput(); |
1448 |
|
|
|
1449 |
CompareEditorInput input = (CompareEditorInput) editor |
1450 |
.getEditorInput(); |
1287 |
input.getCompareResult(); |
1451 |
input.getCompareResult(); |
1288 |
if(input.getCompareResult() instanceof ICompareInput) { |
1452 |
if (input.getCompareResult() instanceof ICompareInput) { |
1289 |
ICompareInput node = (ICompareInput)input.getCompareResult(); |
1453 |
ICompareInput node = (ICompareInput) input.getCompareResult(); |
1290 |
|
|
|
1291 |
leftResource = ((ResourceNode)node.getLeft()).getResource(); |
1292 |
rightResource = ((ResourceNode)node.getRight()).getResource(); |
1293 |
Differencer dif = new Differencer(); |
1294 |
startNode = (DiffNode) dif.findDifferences(false, null, null, null, |
1295 |
new FilteredBufferedResourceNode(leftResource), |
1296 |
new FilteredBufferedResourceNode(rightResource)); |
1297 |
|
1298 |
if(leftResource instanceof IFile && rightResource instanceof IFile) |
1299 |
associatedResources.add(new Object[] {leftResource, rightResource}); |
1300 |
|
1301 |
} |
1302 |
|
1303 |
} |
1304 |
} |
1305 |
|
1306 |
private ArrayList buildMap(DiffNode diff) { |
1307 |
ArrayList res = new ArrayList(); |
1308 |
IResource lresource = null; |
1309 |
IResource rresource = null; |
1310 |
IDiffElement[] children = diff.getChildren(); |
1311 |
if (children != null) { |
1312 |
for (int i = 0; i < children.length; i++) { |
1313 |
if (children[i] instanceof DiffNode) { |
1314 |
DiffNode o = (DiffNode) children[i]; |
1315 |
if (o != null && o.getKind() != Differencer.NO_CHANGE) { |
1316 |
DiffNode node = o; |
1317 |
|
1454 |
|
1318 |
ITypedElement left = node.getLeft(); |
1455 |
ITypedElement leftElem = node.getLeft(); |
1319 |
if (left instanceof BufferedResourceNode) { |
1456 |
ITypedElement rightElem = node.getRight(); |
1320 |
BufferedResourceNode bn = (BufferedResourceNode) left; |
|
|
1321 |
IResource resource = bn.getResource(); |
1322 |
if (resource instanceof IFile) { |
1323 |
lresource = resource; |
1324 |
} |
1325 |
|
1457 |
|
1326 |
} |
1458 |
leftResource = ((ResourceNode) node.getLeft()).getResource(); |
|
|
1459 |
rightResource = ((ResourceNode) node.getRight()).getResource(); |
1460 |
Differencer dif = new Differencer(); |
1461 |
startNode = (DiffNode) dif.findDifferences(false, null, null, |
1462 |
null, new FilteredBufferedResourceNode(leftResource), |
1463 |
new FilteredBufferedResourceNode(rightResource)); |
1327 |
|
1464 |
|
1328 |
ITypedElement right = node.getRight(); |
1465 |
if (leftResource instanceof IFile |
1329 |
if (right instanceof BufferedResourceNode) { |
1466 |
&& rightResource instanceof IFile) |
1330 |
BufferedResourceNode bn = (BufferedResourceNode) right; |
1467 |
associatedResources.add(new Object[] { leftResource, |
1331 |
IResource resource = bn.getResource(); |
1468 |
rightResource }); |
1332 |
if (resource instanceof IFile) { |
|
|
1333 |
rresource = resource; |
1334 |
} |
1335 |
} |
1336 |
|
1337 |
if(rresource != null || lresource != null) |
1338 |
res.add(new Object[] {lresource, rresource}); |
1339 |
lresource = null; |
1340 |
rresource = null; |
1341 |
} |
1342 |
|
1469 |
|
1343 |
res.addAll(buildMap((DiffNode) children[i])); |
|
|
1344 |
} |
1345 |
} |
1470 |
} |
1346 |
return res; |
1471 |
|
1347 |
} |
1472 |
} |
1348 |
return res; |
|
|
1349 |
} |
1473 |
} |
1350 |
|
1474 |
|
1351 |
|
|
|
1352 |
public void addPages() { |
1475 |
public void addPages() { |
1353 |
String pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; |
1476 |
String pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; |
1354 |
String pageDescription = CompareMessages.GenerateLocalDiff_Specify_the_file_which_contributes_the_changes; |
1477 |
String pageDescription = CompareMessages.GenerateLocalDiff_Specify_the_file_which_contributes_the_changes; |
Lines 1356-1368
Link Here
|
1356 |
pageTitle, |
1479 |
pageTitle, |
1357 |
pageTitle, |
1480 |
pageTitle, |
1358 |
CompareUIPlugin |
1481 |
CompareUIPlugin |
1359 |
.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF)); |
1482 |
.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF)); |
1360 |
directionSelectionPage.setDescription(pageDescription); |
1483 |
directionSelectionPage.setDescription(pageDescription); |
1361 |
addPage(directionSelectionPage); |
1484 |
addPage(directionSelectionPage); |
1362 |
|
1485 |
|
1363 |
pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; |
1486 |
pageTitle = CompareMessages.GenerateLocalDiff_pageTitle; |
1364 |
pageDescription = CompareMessages.GenerateLocalDiff_pageDescription; |
1487 |
pageDescription = CompareMessages.GenerateLocalDiff_pageDescription; |
1365 |
locationPage = new LocationPage(pageTitle, pageTitle, CompareUIPlugin.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF), defaultValuesStore); |
1488 |
locationPage = new LocationPage(pageTitle, pageTitle, CompareUIPlugin |
|
|
1489 |
.getImageDescriptor(ICompareUIConstants.IMG_WIZBAN_DIFF), |
1490 |
defaultValuesStore); |
1366 |
locationPage.setDescription(pageDescription); |
1491 |
locationPage.setDescription(pageDescription); |
1367 |
addPage(locationPage); |
1492 |
addPage(locationPage); |
1368 |
|
1493 |
|
Lines 1389-1398
Link Here
|
1389 |
} |
1514 |
} |
1390 |
|
1515 |
|
1391 |
protected void updateEnablements() { |
1516 |
protected void updateEnablements() { |
1392 |
diffTypeRadioGroup.setEnablement(false, new int[] { FORMAT_CONTEXT, |
1517 |
diffTypeRadioGroup.setEnablement(false, new int[] { |
1393 |
FORMAT_STANDARD }, FORMAT_UNIFIED); |
1518 |
FORMAT_CONTEXT, FORMAT_STANDARD }, FORMAT_UNIFIED); |
1394 |
unifiedRadioGroup.setEnablement(false, new int[] { |
1519 |
unifiedRadioGroup.setEnablement(false, new int[] { |
1395 |
ROOT_PROJECT, ROOT_SELECTION, ROOT_WORKSPACE } ); |
1520 |
ROOT_PROJECT, ROOT_SELECTION, ROOT_WORKSPACE }); |
1396 |
} |
1521 |
} |
1397 |
|
1522 |
|
1398 |
protected void setEnableUnifiedGroup(boolean enabled) { |
1523 |
protected void setEnableUnifiedGroup(boolean enabled) { |
Lines 1406-1486
Link Here
|
1406 |
|
1531 |
|
1407 |
private void createCustomRelativeControl() { |
1532 |
private void createCustomRelativeControl() { |
1408 |
Group unifiedGroup = optionsPage.getUnifiedGroup(); |
1533 |
Group unifiedGroup = optionsPage.getUnifiedGroup(); |
1409 |
final RadioButtonGroup unifiedRadioGroup = optionsPage.getUnifiedRadioGroup(); |
1534 |
final RadioButtonGroup unifiedRadioGroup = optionsPage |
|
|
1535 |
.getUnifiedRadioGroup(); |
1410 |
unified_customRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
1536 |
unified_customRelativeOption = new Button(unifiedGroup, SWT.RADIO); |
1411 |
unified_customRelativeOption.setText(CompareMessages.GenerateDiffFileWizard_13); |
1537 |
unified_customRelativeOption |
|
|
1538 |
.setText(CompareMessages.GenerateDiffFileWizard_13); |
1412 |
unified_customRelativeOption.setSelection(true); |
1539 |
unified_customRelativeOption.setSelection(true); |
1413 |
unified_customRelativeOption.setLayoutData(new GridData( |
1540 |
unified_customRelativeOption.setLayoutData(new GridData(SWT.BEGINNING, |
1414 |
SWT.BEGINNING, SWT.CENTER, false, false, 1, 1)); |
1541 |
SWT.CENTER, false, false, 1, 1)); |
1415 |
|
1542 |
|
1416 |
unified_customRelativeText = new Text(unifiedGroup, SWT.BORDER); |
1543 |
unified_customRelativeText = new Text(unifiedGroup, SWT.BORDER); |
1417 |
unified_customRelativeText.setLayoutData(new GridData( |
1544 |
unified_customRelativeText.setLayoutData(new GridData(SWT.FILL, |
1418 |
SWT.FILL, SWT.CENTER, true, false, 1, 1)); |
1545 |
SWT.CENTER, true, false, 1, 1)); |
1419 |
|
1546 |
|
1420 |
optionsPage.getUnifiedRadioGroup().add(OptionsPage.ROOT_CUSTOM, unified_customRelativeOption); |
1547 |
optionsPage.getUnifiedRadioGroup().add(OptionsPage.ROOT_CUSTOM, |
1421 |
unified_customRelativeOption.addSelectionListener(new SelectionAdapter() { |
1548 |
unified_customRelativeOption); |
1422 |
public void widgetSelected(SelectionEvent e) { |
1549 |
unified_customRelativeOption |
1423 |
unifiedRadioGroup.setSelection(OptionsPage.ROOT_CUSTOM, false); |
1550 |
.addSelectionListener(new SelectionAdapter() { |
1424 |
} |
1551 |
public void widgetSelected(SelectionEvent e) { |
1425 |
}); |
1552 |
unifiedRadioGroup.setSelection(OptionsPage.ROOT_CUSTOM, |
1426 |
optionsPage.updateDiffTypeEnablements(new int[] {OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD}, OptionsPage.FORMAT_UNIFIED); |
1553 |
false); |
1427 |
optionsPage.updateUnifiedEnablements(new int[] {OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, OptionsPage.ROOT_SELECTION}, OptionsPage.ROOT_CUSTOM); |
1554 |
} |
|
|
1555 |
}); |
1556 |
optionsPage.updateDiffTypeEnablements(new int[] { |
1557 |
OptionsPage.FORMAT_CONTEXT, OptionsPage.FORMAT_STANDARD }, |
1558 |
OptionsPage.FORMAT_UNIFIED); |
1559 |
optionsPage.updateUnifiedEnablements(new int[] { |
1560 |
OptionsPage.ROOT_PROJECT, OptionsPage.ROOT_WORKSPACE, |
1561 |
OptionsPage.ROOT_SELECTION }, OptionsPage.ROOT_CUSTOM); |
1428 |
} |
1562 |
} |
1429 |
|
1563 |
|
1430 |
/** |
1564 |
/** |
1431 |
* Declares the wizard banner iamge descriptor |
1565 |
* Declares the wizard banner iamge descriptor |
1432 |
*/ |
1566 |
*/ |
1433 |
protected void initializeDefaultPageImageDescriptor() { |
1567 |
protected void initializeDefaultPageImageDescriptor() { |
1434 |
final String iconPath= "icons/full/"; //$NON-NLS-1$ |
1568 |
final String iconPath = "icons/full/"; //$NON-NLS-1$ |
1435 |
try { |
1569 |
try { |
1436 |
final URL installURL = CompareUIPlugin.getDefault().getBundle().getEntry("/"); //$NON-NLS-1$ |
1570 |
final URL installURL = CompareUIPlugin.getDefault().getBundle() |
1437 |
final URL url = new URL(installURL, iconPath + "wizards/newconnect_wiz.gif"); //$NON-NLS-1$ |
1571 |
.getEntry("/"); //$NON-NLS-1$ |
|
|
1572 |
final URL url = new URL(installURL, iconPath |
1573 |
+ "wizards/newconnect_wiz.gif"); //$NON-NLS-1$ |
1438 |
ImageDescriptor desc = ImageDescriptor.createFromURL(url); |
1574 |
ImageDescriptor desc = ImageDescriptor.createFromURL(url); |
1439 |
setDefaultPageImageDescriptor(desc); |
1575 |
setDefaultPageImageDescriptor(desc); |
1440 |
} catch (MalformedURLException e) { |
1576 |
} catch (MalformedURLException e) { |
1441 |
// Should not happen. Ignore. |
1577 |
// Should not happen. Ignore. |
1442 |
} |
1578 |
} |
1443 |
} |
1579 |
} |
1444 |
|
1580 |
|
1445 |
/* (Non-javadoc) |
1581 |
/* |
1446 |
* Method declared on IWizard. |
1582 |
* (Non-javadoc) Method declared on IWizard. |
1447 |
*/ |
1583 |
*/ |
1448 |
public boolean needsProgressMonitor() { |
1584 |
public boolean needsProgressMonitor() { |
1449 |
return true; |
1585 |
return true; |
1450 |
} |
1586 |
} |
1451 |
|
1587 |
|
1452 |
/** |
1588 |
/** |
1453 |
* Completes processing of the wizard. If this method returns <code> |
1589 |
* Completes processing of the wizard. If this method returns <code> |
1454 |
* true</code>, the wizard will close; otherwise, it will stay active. |
1590 |
* true</code>, |
|
|
1591 |
* the wizard will close; otherwise, it will stay active. |
1455 |
*/ |
1592 |
*/ |
1456 |
public boolean performFinish() { |
1593 |
public boolean performFinish() { |
1457 |
final int location = locationPage.getSelectedLocation(); |
1594 |
final int location = locationPage.getSelectedLocation(); |
1458 |
|
1595 |
|
1459 |
final File file= location != LocationPage.CLIPBOARD? locationPage.getFile() : null; |
1596 |
final File file = location != LocationPage.CLIPBOARD ? locationPage |
|
|
1597 |
.getFile() : null; |
1460 |
|
1598 |
|
1461 |
if (!(file == null || validateFile(file))) { |
1599 |
if (!(file == null || validateFile(file))) { |
1462 |
return false; |
1600 |
return false; |
1463 |
} |
1601 |
} |
1464 |
|
1602 |
|
1465 |
//Validation of patch root |
1603 |
// Validation of patch root |
1466 |
// if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) { |
1604 |
// if(optionsPage.getRootSelection() == OptionsPage.ROOT_CUSTOM) { |
1467 |
// String path = optionsPage.getPath(); |
1605 |
// String path = optionsPage.getPath(); |
1468 |
// IFile file2; |
1606 |
// IFile file2; |
1469 |
// try { |
1607 |
// try { |
1470 |
// file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new Path(path)); |
1608 |
// file2 = ResourcesPlugin.getWorkspace().getRoot().getFile(new |
1471 |
// } catch(IllegalArgumentException e) { |
1609 |
// Path(path)); |
1472 |
// final String title = CompareMessages.GenerateLocalDiff_3; |
1610 |
// } catch(IllegalArgumentException e) { |
1473 |
// final String msg = CompareMessages.GenerateLocalDiff_4; |
1611 |
// final String title = CompareMessages.GenerateLocalDiff_3; |
1474 |
// final MessageDialog dialog = new MessageDialog(getShell(), title, |
1612 |
// final String msg = CompareMessages.GenerateLocalDiff_4; |
1475 |
// null, msg, MessageDialog.ERROR, |
1613 |
// final MessageDialog dialog = new MessageDialog(getShell(), title, |
1476 |
// new String[] { IDialogConstants.OK_LABEL }, 0); |
1614 |
// null, msg, MessageDialog.ERROR, |
1477 |
// dialog.open(); |
1615 |
// new String[] { IDialogConstants.OK_LABEL }, 0); |
1478 |
// return false; |
1616 |
// dialog.open(); |
1479 |
// } |
1617 |
// return false; |
1480 |
// if(!validateFile2(file2)) { |
1618 |
// } |
1481 |
// return false; |
1619 |
// if(!validateFile2(file2)) { |
1482 |
// } |
1620 |
// return false; |
1483 |
// } |
1621 |
// } |
|
|
1622 |
// } |
1484 |
|
1623 |
|
1485 |
// Create the patch |
1624 |
// Create the patch |
1486 |
generateDiffFile(file); |
1625 |
generateDiffFile(file); |
Lines 1491-1509
Link Here
|
1491 |
switch (location) { |
1630 |
switch (location) { |
1492 |
|
1631 |
|
1493 |
case LocationPage.WORKSPACE: |
1632 |
case LocationPage.WORKSPACE: |
1494 |
final String workspaceResource= locationPage.getWorkspaceLocation(); |
1633 |
final String workspaceResource = locationPage |
1495 |
if (workspaceResource != null){ |
1634 |
.getWorkspaceLocation(); |
1496 |
defaultValuesStore.storeLocationSelection(LocationPage.WORKSPACE); |
1635 |
if (workspaceResource != null) { |
|
|
1636 |
defaultValuesStore |
1637 |
.storeLocationSelection(LocationPage.WORKSPACE); |
1497 |
defaultValuesStore.storeWorkspacePath(workspaceResource); |
1638 |
defaultValuesStore.storeWorkspacePath(workspaceResource); |
1498 |
/* try { |
1639 |
/* |
1499 |
workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE, null); |
1640 |
* try { |
1500 |
} catch(CoreException e) { |
1641 |
* workspaceResource.getParent().refreshLocal(IResource.DEPTH_ONE |
1501 |
CVSUIPlugin.openError(getShell(), CVSUIMessages.GenerateCVSDiff_error, null, e); |
1642 |
* , null); } catch(CoreException e) { |
1502 |
return false; |
1643 |
* CVSUIPlugin.openError(getShell(), |
1503 |
} */ |
1644 |
* CVSUIMessages.GenerateCVSDiff_error, null, e); return false; |
|
|
1645 |
* } |
1646 |
*/ |
1504 |
} else { |
1647 |
} else { |
1505 |
//Problem with workspace location, open with clipboard next time |
1648 |
// Problem with workspace location, open with clipboard next |
1506 |
defaultValuesStore.storeLocationSelection(LocationPage.CLIPBOARD); |
1649 |
// time |
|
|
1650 |
defaultValuesStore |
1651 |
.storeLocationSelection(LocationPage.CLIPBOARD); |
1507 |
} |
1652 |
} |
1508 |
break; |
1653 |
break; |
1509 |
|
1654 |
|
Lines 1520-1526
Link Here
|
1520 |
return false; |
1665 |
return false; |
1521 |
} |
1666 |
} |
1522 |
|
1667 |
|
1523 |
|
|
|
1524 |
/** |
1668 |
/** |
1525 |
* Save default selections of Options Page |
1669 |
* Save default selections of Options Page |
1526 |
*/ |
1670 |
*/ |
Lines 1536-1555
Link Here
|
1536 |
if (targetFileEdited) { |
1680 |
if (targetFileEdited) { |
1537 |
toPath = optionsPage.getPath(); |
1681 |
toPath = optionsPage.getPath(); |
1538 |
} else { |
1682 |
} else { |
1539 |
if(directionSelectionPage.isRightToLeft()){ |
1683 |
if (directionSelectionPage.isRightToLeft()) { |
1540 |
toPath = this.rightPath; |
1684 |
toPath = this.rightPath; |
1541 |
} else { |
1685 |
} else { |
1542 |
toPath = this.leftPath; |
1686 |
toPath = this.leftPath; |
1543 |
} |
1687 |
} |
1544 |
} |
1688 |
} |
1545 |
if(directionSelectionPage.isRightToLeft()){ |
1689 |
if (directionSelectionPage.isRightToLeft()) { |
1546 |
oldPath = this.leftPath; |
1690 |
oldPath = this.leftPath; |
1547 |
} else { |
1691 |
} else { |
1548 |
oldPath = this.rightPath; |
1692 |
oldPath = this.rightPath; |
1549 |
} |
1693 |
} |
1550 |
|
1694 |
|
1551 |
//TODO extend formatter to use list of mergers. |
1695 |
// TODO extend formatter to use list of mergers. |
1552 |
UnifiedDiffFormatter formatter = new UnifiedDiffFormatter(createFormatterInput()); |
1696 |
UnifiedDiffFormatter formatter = new UnifiedDiffFormatter( |
|
|
1697 |
createFormatterInput()); |
1553 |
try { |
1698 |
try { |
1554 |
if (file == null) { |
1699 |
if (file == null) { |
1555 |
formatter.generateDiff(); |
1700 |
formatter.generateDiff(); |
Lines 1560-1683
Link Here
|
1560 |
throw new RuntimeException(e); |
1705 |
throw new RuntimeException(e); |
1561 |
} |
1706 |
} |
1562 |
} |
1707 |
} |
1563 |
|
1708 |
|
1564 |
private Object[][] createFormatterInput() { |
1709 |
private Object[][] createFormatterInput() { |
1565 |
Object[] resArr = associatedResources.toArray(); |
1710 |
Object[] resArr = associatedResources.toArray(); |
1566 |
int size = resArr.length; |
1711 |
int size = resArr.length; |
1567 |
Object[][] result = new Object[size][3]; |
1712 |
Object[][] result = new Object[size][3]; |
1568 |
DocumentMerger merg = null; |
1713 |
DocumentMerger merg = null; |
1569 |
for (int j = 0; j < size; j++) { |
1714 |
for (int j = 0; j < size; j++) { |
1570 |
IFile sourceRes = (IFile) ((Object[])resArr[j])[0]; |
1715 |
IFile sourceRes = (IFile) ((Object[]) resArr[j])[0]; |
1571 |
IFile targetRes = (IFile) ((Object[])resArr[j])[1]; |
1716 |
IFile targetRes = (IFile) ((Object[]) resArr[j])[1]; |
1572 |
merg = createDocumentMerger(sourceRes, targetRes); |
1717 |
merg = createDocumentMerger(sourceRes, targetRes); |
1573 |
result[j][0] = merg; |
1718 |
result[j][0] = merg; |
1574 |
result[j][1] = targetRes ; |
1719 |
result[j][1] = targetRes; |
1575 |
result[j][2] = sourceRes ; |
1720 |
result[j][2] = sourceRes; |
1576 |
} |
1721 |
} |
1577 |
return result; |
1722 |
return result; |
1578 |
} |
1723 |
} |
1579 |
|
1724 |
|
1580 |
private DocumentMerger createDocumentMerger(IFile leftFile, IFile rightFile){ |
1725 |
private DocumentMerger createDocumentMerger(IFile leftFile, IFile rightFile) { |
1581 |
IDocument leftDoc = convertFileToDocument(leftFile); |
1726 |
IDocument leftDoc = convertFileToDocument(leftFile); |
1582 |
IDocument rightDoc = convertFileToDocument(rightFile); |
1727 |
IDocument rightDoc = convertFileToDocument(rightFile); |
1583 |
if (leftDoc == null) { |
1728 |
if (leftDoc == null) { |
1584 |
leftDoc = new Document(); |
1729 |
leftDoc = new Document(); |
1585 |
} |
1730 |
} |
1586 |
if (rightDoc == null) { |
1731 |
if (rightDoc == null) { |
1587 |
rightDoc = new Document(); |
1732 |
rightDoc = new Document(); |
1588 |
} |
1733 |
} |
1589 |
DocumentMerger docMerger; |
1734 |
DocumentMerger docMerger; |
1590 |
docMerger = new DocumentMerger(new LocalDiffMergerInput(leftDoc, rightDoc)); |
1735 |
docMerger = new DocumentMerger(new LocalDiffMergerInput(leftDoc, |
1591 |
try { |
1736 |
rightDoc)); |
1592 |
docMerger.doDiff(); |
1737 |
try { |
1593 |
} catch (Exception e) { |
1738 |
docMerger.doDiff(); |
1594 |
throw new RuntimeException(e); |
1739 |
} catch (Exception e) { |
1595 |
} |
1740 |
throw new RuntimeException(e); |
1596 |
return docMerger; |
1741 |
} |
|
|
1742 |
return docMerger; |
1597 |
} |
1743 |
} |
1598 |
|
1744 |
|
1599 |
private IDocument convertFileToDocument(IFile file) { |
1745 |
private IDocument convertFileToDocument(IFile file) { |
1600 |
if(file == null) |
1746 |
if (file == null) |
1601 |
return null; |
1747 |
return null; |
1602 |
StringBuffer str = new StringBuffer(); |
1748 |
StringBuffer str = new StringBuffer(); |
1603 |
int c; |
1749 |
int c; |
1604 |
try{ |
1750 |
try { |
1605 |
InputStream inputStream = file.getContents(); |
1751 |
InputStream inputStream = file.getContents(); |
1606 |
while ((c = inputStream.read())!=-1){ |
1752 |
while ((c = inputStream.read()) != -1) { |
1607 |
str.append((char)c); |
1753 |
str.append((char) c); |
1608 |
} |
1754 |
} |
1609 |
inputStream.close(); |
1755 |
inputStream.close(); |
1610 |
return new Document(str.toString()); |
1756 |
return new Document(str.toString()); |
1611 |
}catch(Exception ex){ |
1757 |
} catch (Exception ex) { |
1612 |
CompareUIPlugin.log(ex); |
1758 |
CompareUIPlugin.log(ex); |
1613 |
} |
1759 |
} |
1614 |
|
1760 |
|
1615 |
return null; |
1761 |
return null; |
1616 |
} |
1762 |
} |
1617 |
|
1763 |
|
1618 |
private class LocalDiffMergerInput implements IDocumentMergerInput { |
1764 |
private class LocalDiffMergerInput implements IDocumentMergerInput { |
1619 |
|
1765 |
|
1620 |
private IDocument leftDoc; |
1766 |
private IDocument leftDoc; |
1621 |
private IDocument rightDoc; |
1767 |
private IDocument rightDoc; |
1622 |
|
1768 |
|
1623 |
public LocalDiffMergerInput(IDocument leftDoc, IDocument rightDoc) { |
1769 |
public LocalDiffMergerInput(IDocument leftDoc, IDocument rightDoc) { |
1624 |
this.leftDoc = leftDoc ; |
1770 |
this.leftDoc = leftDoc; |
1625 |
this.rightDoc= rightDoc; |
1771 |
this.rightDoc = rightDoc; |
|
|
1772 |
} |
1773 |
|
1774 |
public ITokenComparator createTokenComparator(String line) { |
1775 |
return new TokenComparator(line); |
1776 |
} |
1777 |
|
1778 |
public CompareConfiguration getCompareConfiguration() { |
1779 |
return new CompareConfiguration(); |
1780 |
} |
1781 |
|
1782 |
public IDocument getDocument(char contributor) { |
1783 |
switch (contributor) { |
1784 |
case MergeViewerContentProvider.LEFT_CONTRIBUTOR: |
1785 |
return leftDoc; |
1786 |
case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: |
1787 |
return rightDoc; |
1788 |
case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: |
1789 |
return null; |
1626 |
} |
1790 |
} |
1627 |
|
1791 |
return null; |
1628 |
public ITokenComparator createTokenComparator(String line) { |
|
|
1629 |
return new TokenComparator(line); |
1630 |
} |
1631 |
public CompareConfiguration getCompareConfiguration() { |
1632 |
return new CompareConfiguration(); |
1633 |
} |
1634 |
public IDocument getDocument(char contributor) { |
1635 |
switch (contributor) { |
1636 |
case MergeViewerContentProvider.LEFT_CONTRIBUTOR: |
1637 |
return leftDoc; |
1638 |
case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: |
1639 |
return rightDoc; |
1640 |
case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: |
1641 |
return null; |
1642 |
} |
1643 |
return null; |
1644 |
} |
1645 |
public int getHunkStart() { |
1646 |
return 0; |
1647 |
} |
1648 |
public Position getRegion(char contributor) { |
1649 |
switch (contributor) { |
1650 |
case MergeViewerContentProvider.LEFT_CONTRIBUTOR: |
1651 |
return new Position(0, leftDoc.getLength()); |
1652 |
case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: |
1653 |
return new Position(0, rightDoc.getLength()); |
1654 |
case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: |
1655 |
return new Position(0, 0); |
1656 |
} |
1657 |
return null; |
1658 |
} |
1659 |
public boolean isHunkOnLeft() { |
1660 |
return false; |
1661 |
} |
1662 |
public boolean isIgnoreAncestor() { |
1663 |
return true; |
1664 |
} |
1665 |
public boolean isPatchHunk() { |
1666 |
return false; |
1667 |
} |
1668 |
|
1669 |
public boolean isShowPseudoConflicts() { |
1670 |
return false; |
1671 |
} |
1672 |
public boolean isThreeWay() { |
1673 |
return false; |
1674 |
} |
1675 |
public boolean isPatchHunkOk() { |
1676 |
return false; |
1677 |
} |
1678 |
|
1679 |
} |
1792 |
} |
1680 |
|
1793 |
|
|
|
1794 |
public int getHunkStart() { |
1795 |
return 0; |
1796 |
} |
1797 |
|
1798 |
public Position getRegion(char contributor) { |
1799 |
switch (contributor) { |
1800 |
case MergeViewerContentProvider.LEFT_CONTRIBUTOR: |
1801 |
return new Position(0, leftDoc.getLength()); |
1802 |
case MergeViewerContentProvider.RIGHT_CONTRIBUTOR: |
1803 |
return new Position(0, rightDoc.getLength()); |
1804 |
case MergeViewerContentProvider.ANCESTOR_CONTRIBUTOR: |
1805 |
return new Position(0, 0); |
1806 |
} |
1807 |
return null; |
1808 |
} |
1809 |
|
1810 |
public boolean isHunkOnLeft() { |
1811 |
return false; |
1812 |
} |
1813 |
|
1814 |
public boolean isIgnoreAncestor() { |
1815 |
return true; |
1816 |
} |
1817 |
|
1818 |
public boolean isPatchHunk() { |
1819 |
return false; |
1820 |
} |
1821 |
|
1822 |
public boolean isShowPseudoConflicts() { |
1823 |
return false; |
1824 |
} |
1825 |
|
1826 |
public boolean isThreeWay() { |
1827 |
return false; |
1828 |
} |
1829 |
|
1830 |
public boolean isPatchHunkOk() { |
1831 |
return false; |
1832 |
} |
1833 |
|
1834 |
} |
1835 |
|
1681 |
public boolean validateFile(File file) { |
1836 |
public boolean validateFile(File file) { |
1682 |
|
1837 |
|
1683 |
if (file == null) |
1838 |
if (file == null) |
Lines 1693-1708
Link Here
|
1693 |
* The file exists. |
1848 |
* The file exists. |
1694 |
*/ |
1849 |
*/ |
1695 |
if (!file.canWrite()) { |
1850 |
if (!file.canWrite()) { |
1696 |
final String title= CompareMessages.GenerateLocalDiff_1; |
1851 |
final String title = CompareMessages.GenerateLocalDiff_1; |
1697 |
final String msg= CompareMessages.GenerateLocalDiff_2; |
1852 |
final String msg = CompareMessages.GenerateLocalDiff_2; |
1698 |
final MessageDialog dialog= new MessageDialog(getShell(), title, null, msg, MessageDialog.ERROR, new String[] { IDialogConstants.OK_LABEL }, 0); |
1853 |
final MessageDialog dialog = new MessageDialog(getShell(), title, |
|
|
1854 |
null, msg, MessageDialog.ERROR, |
1855 |
new String[] { IDialogConstants.OK_LABEL }, 0); |
1699 |
dialog.open(); |
1856 |
dialog.open(); |
1700 |
return false; |
1857 |
return false; |
1701 |
} |
1858 |
} |
1702 |
|
1859 |
|
1703 |
final String title = CompareMessages.GenerateLocalDiff_overwriteTitle; |
1860 |
final String title = CompareMessages.GenerateLocalDiff_overwriteTitle; |
1704 |
final String msg = CompareMessages.GenerateLocalDiff_overwriteMsg; |
1861 |
final String msg = CompareMessages.GenerateLocalDiff_overwriteMsg; |
1705 |
final MessageDialog dialog = new MessageDialog(getShell(), title, null, msg, MessageDialog.QUESTION, new String[] { IDialogConstants.YES_LABEL, IDialogConstants.CANCEL_LABEL }, 0); |
1862 |
final MessageDialog dialog = new MessageDialog(getShell(), title, null, |
|
|
1863 |
msg, MessageDialog.QUESTION, new String[] { |
1864 |
IDialogConstants.YES_LABEL, |
1865 |
IDialogConstants.CANCEL_LABEL }, 0); |
1706 |
dialog.open(); |
1866 |
dialog.open(); |
1707 |
if (dialog.getReturnCode() != 0) |
1867 |
if (dialog.getReturnCode() != 0) |
1708 |
return false; |
1868 |
return false; |
Lines 1736-1746
Link Here
|
1736 |
* The class maintain proper selection of radio button within the group: |
1896 |
* The class maintain proper selection of radio button within the group: |
1737 |
* <ul> |
1897 |
* <ul> |
1738 |
* <li>Only one button can be selected at the time.</li> |
1898 |
* <li>Only one button can be selected at the time.</li> |
1739 |
* <li>Disabled button can't be selected unless all buttons in the group |
1899 |
* <li>Disabled button can't be selected unless all buttons in the group are |
1740 |
* are disabled.</li> |
1900 |
* disabled.</li> |
1741 |
* </ul> |
1901 |
* </ul> |
1742 |
*/ |
1902 |
*/ |
1743 |
/*private*/ class RadioButtonGroup { |
1903 |
/* private */class RadioButtonGroup { |
1744 |
|
1904 |
|
1745 |
/** |
1905 |
/** |
1746 |
* List of buttons in the group. Both radio groups contain 3 elements. |
1906 |
* List of buttons in the group. Both radio groups contain 3 elements. |
Lines 1848-1854
Link Here
|
1848 |
// enable (or disable) given buttons |
2008 |
// enable (or disable) given buttons |
1849 |
for (int i = 0; i < buttonsToChange.length; i++) { |
2009 |
for (int i = 0; i < buttonsToChange.length; i++) { |
1850 |
((Button) this.buttons.get(buttonsToChange[i] - 1)) |
2010 |
((Button) this.buttons.get(buttonsToChange[i] - 1)) |
1851 |
.setEnabled(enabled); |
2011 |
.setEnabled(enabled); |
1852 |
} |
2012 |
} |
1853 |
// check whether the selected button is enabled |
2013 |
// check whether the selected button is enabled |
1854 |
if (!((Button) this.buttons.get(selected)).isEnabled()) { |
2014 |
if (!((Button) this.buttons.get(selected)).isEnabled()) { |
Lines 1862-1872
Link Here
|
1862 |
} |
2022 |
} |
1863 |
|
2023 |
|
1864 |
/** |
2024 |
/** |
1865 |
* Enable or disable given buttons with no default selection. The selection |
2025 |
* Enable or disable given buttons with no default selection. The |
1866 |
* will be set to an enabled button using the <code>selectEnabledOnly</code> method. |
2026 |
* selection will be set to an enabled button using the |
|
|
2027 |
* <code>selectEnabledOnly</code> method. |
1867 |
* |
2028 |
* |
1868 |
* @param enabled Indicates whether to enable or disable the buttons. |
2029 |
* @param enabled |
1869 |
* @param buttonsToChange Buttons to enable/disable. |
2030 |
* Indicates whether to enable or disable the buttons. |
|
|
2031 |
* @param buttonsToChange |
2032 |
* Buttons to enable/disable. |
1870 |
*/ |
2033 |
*/ |
1871 |
public void setEnablement(boolean enabled, int[] buttonsToChange) { |
2034 |
public void setEnablement(boolean enabled, int[] buttonsToChange) { |
1872 |
// -1 means that no default selection is given |
2035 |
// -1 means that no default selection is given |