Added
Link Here
|
1 |
package org.eclipse.compare.internal.patch; |
2 |
|
3 |
import java.io.IOException; |
4 |
|
5 |
import org.eclipse.compare.CompareConfiguration; |
6 |
import org.eclipse.compare.structuremergeviewer.DiffTreeViewer; |
7 |
import org.eclipse.core.resources.IStorage; |
8 |
import org.eclipse.core.runtime.CoreException; |
9 |
import org.eclipse.core.runtime.ListenerList; |
10 |
import org.eclipse.jface.action.IMenuManager; |
11 |
import org.eclipse.jface.viewers.ISelection; |
12 |
import org.eclipse.jface.viewers.ISelectionChangedListener; |
13 |
import org.eclipse.jface.viewers.StructuredSelection; |
14 |
import org.eclipse.swt.widgets.Composite; |
15 |
import org.eclipse.swt.widgets.Control; |
16 |
import org.eclipse.ui.IEditorInput; |
17 |
import org.eclipse.ui.part.FileEditorInput; |
18 |
import org.eclipse.ui.part.Page; |
19 |
import org.eclipse.ui.texteditor.IDocumentProvider; |
20 |
import org.eclipse.ui.views.contentoutline.IContentOutlinePage; |
21 |
|
22 |
public class PatchContentOutlinePage extends Page implements |
23 |
IContentOutlinePage/*, ISelectionChangedListener*/ { |
24 |
DiffTreeViewer treeViewer; |
25 |
IEditorInput fInput; |
26 |
private ListenerList selectionChangedListeners = new ListenerList(); |
27 |
private WorkspacePatcher fPatcher; |
28 |
|
29 |
public PatchContentOutlinePage(IDocumentProvider documentProvider, |
30 |
PatchEditor patchEditor) { |
31 |
// TODO Auto-generated constructor stub |
32 |
} |
33 |
|
34 |
public void setInput(IEditorInput editorInput) { |
35 |
fInput = editorInput; |
36 |
} |
37 |
|
38 |
public void createControl(Composite parent) { |
39 |
getPatcher(); |
40 |
CompareConfiguration patchConfiguration = new CompareConfiguration(); |
41 |
PatchCompareEditorInput editorInput = new PatchCompareEditorInput( |
42 |
fPatcher, patchConfiguration) { |
43 |
protected void fillContextMenu(IMenuManager manager) { |
44 |
// TODO Auto-generated method stub |
45 |
} |
46 |
}; |
47 |
treeViewer = (DiffTreeViewer) editorInput.createDiffViewer(parent); |
48 |
editorInput.buildTree(); |
49 |
} |
50 |
|
51 |
private WorkspacePatcher getPatcher() { |
52 |
if (fPatcher == null) { |
53 |
if (fInput instanceof FileEditorInput) { |
54 |
IStorage patch = ((FileEditorInput) fInput).getStorage(); |
55 |
WorkspacePatcher patcher = new WorkspacePatcher(); |
56 |
if (patch != null) { |
57 |
try { |
58 |
patcher.parse(patch); |
59 |
} catch (IOException e) { |
60 |
// TODO Auto-generated catch block |
61 |
e.printStackTrace(); |
62 |
} catch (CoreException e) { |
63 |
// TODO Auto-generated catch block |
64 |
e.printStackTrace(); |
65 |
} |
66 |
fPatcher = patcher; |
67 |
} |
68 |
} |
69 |
} |
70 |
return fPatcher; |
71 |
} |
72 |
|
73 |
public Control getControl() { |
74 |
if (treeViewer == null) { |
75 |
return null; |
76 |
} |
77 |
return treeViewer.getControl(); |
78 |
} |
79 |
|
80 |
public void setFocus() { |
81 |
treeViewer.getControl().setFocus(); |
82 |
} |
83 |
|
84 |
public void addSelectionChangedListener(ISelectionChangedListener listener) { |
85 |
selectionChangedListeners.add(listener); |
86 |
} |
87 |
|
88 |
public ISelection getSelection() { |
89 |
if (treeViewer == null) { |
90 |
return StructuredSelection.EMPTY; |
91 |
} |
92 |
return treeViewer.getSelection(); |
93 |
} |
94 |
|
95 |
public void removeSelectionChangedListener( |
96 |
ISelectionChangedListener listener) { |
97 |
// TODO Auto-generated method stub |
98 |
} |
99 |
|
100 |
public void setSelection(ISelection selection) { |
101 |
// TODO Auto-generated method stub |
102 |
} |
103 |
} |