30 |
30 |
import java.util.ArrayList;
|
31 |
31 |
import java.util.Collections;
|
32 |
32 |
import java.util.Comparator;
|
|
33 |
import java.util.List;
|
33 |
34 |
|
34 |
35 |
import org.eclipse.core.runtime.IAdaptable;
|
35 |
36 |
import org.eclipse.core.runtime.Platform;
|
... | ... | |
37 |
38 |
import org.eclipse.jface.viewers.Viewer;
|
38 |
39 |
import org.eclipse.ui.model.IWorkbenchAdapter;
|
39 |
40 |
import org.txm.core.results.TXMResult;
|
|
41 |
import org.txm.objects.CorpusBuild;
|
40 |
42 |
import org.txm.objects.Project;
|
41 |
43 |
import org.txm.objects.Workspace;
|
42 |
44 |
import org.txm.searchengine.cqp.corpus.MainCorpus;
|
... | ... | |
101 |
103 |
*/
|
102 |
104 |
@Override
|
103 |
105 |
public Object[] getElements(Object element) {
|
104 |
|
// return element;
|
105 |
|
//
|
106 |
|
// if (element instanceof Workspace) {
|
107 |
|
// ArrayList<MainCorpus> elements = new ArrayList<MainCorpus>();
|
108 |
|
// Workspace p = (Workspace) element;
|
109 |
|
//
|
110 |
|
// for (Project b : p.getProjects()) {
|
111 |
|
// for (TXMResult o : b.getChildren(MainCorpus.class)) {
|
112 |
|
// elements.add((MainCorpus)o);
|
113 |
|
// }
|
114 |
|
// }
|
115 |
|
// //System.out.println("get elements: "+elements);
|
116 |
|
// Collections.sort(elements, new Comparator<MainCorpus>() {
|
117 |
|
//
|
118 |
|
// @Override
|
119 |
|
// public int compare(MainCorpus o1, MainCorpus o2) {
|
120 |
|
// if (o1 == null) return -1;
|
121 |
|
// if (o2 == null) return 1;
|
122 |
|
// return o1.getName().compareTo(o2.getName());
|
123 |
|
// }
|
124 |
|
// });
|
125 |
|
// //System.out.println("corpora view content: "+elements);
|
126 |
|
// return elements.toArray();
|
127 |
|
// } else
|
128 |
|
if (element instanceof TXMResult) {
|
|
106 |
// return element;
|
|
107 |
//
|
|
108 |
// if (element instanceof Workspace) {
|
|
109 |
// ArrayList<MainCorpus> elements = new ArrayList<MainCorpus>();
|
|
110 |
// Workspace p = (Workspace) element;
|
|
111 |
//
|
|
112 |
// for (Project b : p.getProjects()) {
|
|
113 |
// for (TXMResult o : b.getChildren(MainCorpus.class)) {
|
|
114 |
// elements.add((MainCorpus)o);
|
|
115 |
// }
|
|
116 |
// }
|
|
117 |
// //System.out.println("get elements: "+elements);
|
|
118 |
// Collections.sort(elements, new Comparator<MainCorpus>() {
|
|
119 |
//
|
|
120 |
// @Override
|
|
121 |
// public int compare(MainCorpus o1, MainCorpus o2) {
|
|
122 |
// if (o1 == null) return -1;
|
|
123 |
// if (o2 == null) return 1;
|
|
124 |
// return o1.getName().compareTo(o2.getName());
|
|
125 |
// }
|
|
126 |
// });
|
|
127 |
// //System.out.println("corpora view content: "+elements);
|
|
128 |
// return elements.toArray();
|
|
129 |
// } else
|
|
130 |
if (element instanceof Workspace) {
|
|
131 |
Workspace w = (Workspace)element;
|
|
132 |
ArrayList<CorpusBuild> corpora = new ArrayList<CorpusBuild>();
|
|
133 |
for (Project p : w.getProjects()) {
|
|
134 |
corpora.addAll(p.getCorpora());
|
|
135 |
}
|
|
136 |
return corpora.toArray();
|
|
137 |
} else if (element instanceof TXMResult) {
|
129 |
138 |
return ((TXMResult)element).getChildren().toArray();
|
|
139 |
} else if (element instanceof List) {
|
|
140 |
List list = (List)element;
|
|
141 |
return list.toArray();
|
130 |
142 |
}
|
131 |
143 |
return new Object[0];
|
132 |
144 |
}
|
... | ... | |
136 |
148 |
*/
|
137 |
149 |
@Override
|
138 |
150 |
public Object getParent(Object element) {
|
139 |
|
// IWorkbenchAdapter adapter = getAdapter(element);
|
140 |
|
// if (adapter != null) {
|
141 |
|
// return adapter.getParent(element);
|
142 |
|
// }
|
143 |
|
// else
|
144 |
|
if (element instanceof TXMResult) {
|
|
151 |
// IWorkbenchAdapter adapter = getAdapter(element);
|
|
152 |
// if (adapter != null) {
|
|
153 |
// return adapter.getParent(element);
|
|
154 |
// }
|
|
155 |
// else
|
|
156 |
if (element instanceof TXMResult) {
|
145 |
157 |
return ((TXMResult)element).getParent();
|
146 |
158 |
}
|
147 |
159 |
return null;
|