Révision 1651
tmp/org.txm.rcp/src/main/java/org/txm/rcp/handlers/results/DeleteObject.java (revision 1651) | ||
---|---|---|
61 | 61 |
import org.txm.rcp.messages.TXMUIMessages; |
62 | 62 |
import org.txm.rcp.preferences.RCPPreferences; |
63 | 63 |
import org.txm.rcp.utils.JobHandler; |
64 |
import org.txm.rcp.utils.SWTEditorsUtils; |
|
64 | 65 |
import org.txm.rcp.views.corpora.CorporaView; |
65 | 66 |
import org.txm.searchengine.cqp.corpus.CQPCorpus; |
66 | 67 |
import org.txm.searchengine.cqp.corpus.MainCorpus; |
... | ... | |
218 | 219 |
|
219 | 220 |
//close corresponding editors |
220 | 221 |
for(Object obj : allObjectDeleted) { |
221 |
closeEditorOfSelection(obj);
|
|
222 |
closeEditorOf(obj); |
|
222 | 223 |
} |
223 | 224 |
} catch(Exception e) { |
224 | 225 |
} |
... | ... | |
276 | 277 |
// // FIXME: when TXMResult will be implemented, only this code must be left |
277 | 278 |
if (o instanceof TXMResult) { |
278 | 279 |
TXMResult r = (TXMResult)o; |
280 |
List<TXMResult> children = r.getDeepChildren(); |
|
279 | 281 |
if (r.isLocked()) return deleted; |
280 | 282 |
|
281 | 283 |
if (r instanceof MainCorpus) { |
... | ... | |
290 | 292 |
} |
291 | 293 |
Log.info(NLS.bind(TXMUIMessages.deletedColonP0, o)); |
292 | 294 |
deleted.add(o); |
295 |
deleted.addAll(children); |
|
293 | 296 |
} |
294 | 297 |
else { |
295 | 298 |
Log.severe(TXMCoreMessages.bind("Can not delete: {0}.", o)); |
... | ... | |
303 | 306 |
* |
304 | 307 |
* @param o the object used by an editor |
305 | 308 |
*/ |
306 |
public static void closeEditorOfSelection(Object o) {
|
|
309 |
public static void closeEditorOf(Object o) { |
|
307 | 310 |
|
308 | 311 |
TXMResult r = (TXMResult) o; |
309 |
List<TXMResult> all = r.getDeepChildren(); |
|
312 |
List<TXMResult> all = new ArrayList<TXMResult>();//r.getDeepChildren();
|
|
310 | 313 |
all.add(r); |
311 |
|
|
312 |
//FIXME use SWTEditorsUtils.getEditors() |
|
313 |
for (TXMResult tr : all) { // close editors of the result and its children |
|
314 |
for (IWorkbenchPage page : getPages()) { |
|
315 |
for (IEditorReference editorref : page.getEditorReferences()) { |
|
316 |
IEditorPart editor = editorref.getEditor(false); |
|
317 | 314 |
|
318 |
if(editor instanceof TXMEditor && o instanceof TXMResult) {
|
|
315 |
ArrayList<TXMEditor> editors = SWTEditorsUtils.getEditors();
|
|
319 | 316 |
|
320 |
if (tr == ((TXMEditor)editor).getResult()) { |
|
321 |
editor.getEditorSite().getPage().closeEditor(editor, true); |
|
322 |
} |
|
323 |
} |
|
317 |
//FIXME use SWTEditorsUtils.getEditors() |
|
318 |
for (TXMResult tr : all) { // close editors of the result and its children |
|
319 |
for (TXMEditor<?> editor : editors) { |
|
320 |
if (tr == editor.getResult()) { |
|
321 |
editor.getEditorSite().getPage().closeEditor(editor, true); |
|
324 | 322 |
} |
325 | 323 |
} |
326 | 324 |
} |
tmp/org.txm.rcp/src/main/java/org/txm/rcp/utils/SWTEditorsUtils.java (revision 1651) | ||
---|---|---|
45 | 45 |
public static IEditorPart getEditor(TXMResult result) { |
46 | 46 |
|
47 | 47 |
// FIXME: SJ: old version, doesn't work with ChartEditorInput |
48 |
// for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) { |
|
49 |
// for (IWorkbenchPage page : window.getPages()) { |
|
50 |
// return page.findEditor(new TXMResultEditorInput<TXMResult>(result)); |
|
51 |
// } |
|
52 |
// } |
|
53 |
// return null; |
|
54 |
|
|
48 |
// for (IWorkbenchWindow window : PlatformUI.getWorkbench().getWorkbenchWindows()) {
|
|
49 |
// for (IWorkbenchPage page : window.getPages()) {
|
|
50 |
// return page.findEditor(new TXMResultEditorInput<TXMResult>(result));
|
|
51 |
// }
|
|
52 |
// }
|
|
53 |
// return null;
|
|
54 |
|
|
55 | 55 |
// FIXME: SJ: new version, also works with ChartEditorInput |
56 | 56 |
ArrayList<TXMEditor> editors = getEditors(result); |
57 | 57 |
if(!editors.isEmpty()) { |
58 | 58 |
return editors.get(0); |
59 | 59 |
} |
60 |
|
|
60 |
|
|
61 | 61 |
return null; |
62 | 62 |
} |
63 | 63 |
|
... | ... | |
83 | 83 |
for (int i = 0; i < txmMultipageEditor.getEditors().size(); i++) { |
84 | 84 |
if(txmMultipageEditor.getEditors().get(i) instanceof TXMEditor) { |
85 | 85 |
TXMEditor txmEditor = ((TXMEditor)txmMultipageEditor.getEditors().get(i)); |
86 |
editors.add(txmEditor);
|
|
86 |
editors.add(txmEditor); |
|
87 | 87 |
} |
88 | 88 |
} |
89 | 89 |
} |
... | ... | |
93 | 93 |
return editors; |
94 | 94 |
} |
95 | 95 |
|
96 |
|
|
96 |
|
|
97 | 97 |
/** |
98 | 98 |
* Gets all opened editors for the specified result. |
99 | 99 |
* @param result |
... | ... | |
103 | 103 |
|
104 | 104 |
ArrayList<TXMEditor> editors = new ArrayList<TXMEditor>(); |
105 | 105 |
|
106 |
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); |
|
107 |
for (IWorkbenchWindow window : windows) { |
|
108 |
IWorkbenchPage[] pages = window.getPages(); |
|
109 |
for (IWorkbenchPage page : pages) { |
|
110 |
for (IEditorReference reference : page.getEditorReferences()) { |
|
111 |
IEditorPart tmpEditor = reference.getEditor(false); |
|
106 |
ArrayList<TXMEditor> all_editors = getEditors(); |
|
112 | 107 |
|
113 |
if(tmpEditor instanceof TXMEditor && results.contains(((TXMEditor)tmpEditor).getResult())) { |
|
114 |
editors.add((TXMEditor) tmpEditor); |
|
115 |
} |
|
116 |
else if(tmpEditor instanceof TXMMultiPageEditor) { |
|
117 |
TXMMultiPageEditor txmMultipageEditor = ((TXMMultiPageEditor)tmpEditor); |
|
118 |
for (int i = 0; i < txmMultipageEditor.getEditors().size(); i++) { |
|
119 |
if(txmMultipageEditor.getEditors().get(i) instanceof TXMEditor) { |
|
120 |
TXMEditor txmEditor = ((TXMEditor)txmMultipageEditor.getEditors().get(i)); |
|
121 |
if(results.contains(((TXMEditor)tmpEditor).getResult())) { |
|
122 |
editors.add(txmEditor); |
|
123 |
} |
|
124 |
} |
|
125 |
} |
|
126 |
} |
|
127 |
} |
|
108 |
for (TXMEditor txmEditor : all_editors) { |
|
109 |
|
|
110 |
if (results.contains(txmEditor.getResult())) { |
|
111 |
editors.add(txmEditor); |
|
128 | 112 |
} |
129 | 113 |
} |
130 | 114 |
|
131 | 115 |
return editors; |
132 | 116 |
} |
133 |
|
|
117 |
|
|
134 | 118 |
/** |
135 | 119 |
* Gets all opened editors for the specified result. |
136 | 120 |
* @param result |
... | ... | |
140 | 124 |
|
141 | 125 |
ArrayList<TXMEditor> editors = new ArrayList<TXMEditor>(); |
142 | 126 |
|
143 |
IWorkbenchWindow[] windows = PlatformUI.getWorkbench().getWorkbenchWindows(); |
|
144 |
for (IWorkbenchWindow window : windows) { |
|
145 |
IWorkbenchPage[] pages = window.getPages(); |
|
146 |
for (IWorkbenchPage page : pages) { |
|
147 |
for (IEditorReference reference : page.getEditorReferences()) { |
|
148 |
IEditorPart tmpEditor = reference.getEditor(false); |
|
127 |
ArrayList<TXMEditor> all_editors = getEditors(); |
|
149 | 128 |
|
150 |
if(tmpEditor instanceof TXMEditor && ((TXMEditor)tmpEditor).getResult() == result) { |
|
151 |
editors.add((TXMEditor) tmpEditor); |
|
152 |
} |
|
153 |
else if(tmpEditor instanceof TXMMultiPageEditor) { |
|
154 |
TXMMultiPageEditor txmMultipageEditor = ((TXMMultiPageEditor)tmpEditor); |
|
155 |
for (int i = 0; i < txmMultipageEditor.getEditors().size(); i++) { |
|
156 |
if(txmMultipageEditor.getEditors().get(i) instanceof TXMEditor) { |
|
157 |
TXMEditor txmEditor = ((TXMEditor)txmMultipageEditor.getEditors().get(i)); |
|
158 |
if(txmEditor.getResult() == result) { |
|
159 |
editors.add(txmEditor); |
|
160 |
} |
|
161 |
} |
|
162 |
} |
|
163 |
} |
|
164 |
} |
|
129 |
for (TXMEditor txmEditor : all_editors) { |
|
130 |
|
|
131 |
if (result == txmEditor.getResult()) { |
|
132 |
editors.add(txmEditor); |
|
165 | 133 |
} |
166 | 134 |
} |
167 | 135 |
|
... | ... | |
309 | 277 |
} |
310 | 278 |
return false; |
311 | 279 |
} |
312 |
|
|
280 |
|
|
313 | 281 |
public static boolean activateEditor(TXMResult r) { |
314 | 282 |
IEditorPart e = getEditor(r); |
315 | 283 |
if (e != null && e instanceof TXMEditor && ((TXMEditor)e).getResult() == r) { |
Formats disponibles : Unified diff