Revision 860316c8
Added by Patrick Plitzner over 6 years ago
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/EditorUtil.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.editor; |
11 | 11 |
|
12 |
import java.util.HashSet; |
|
13 |
import java.util.Set; |
|
14 | 12 |
import java.util.UUID; |
15 | 13 |
|
16 | 14 |
import org.eclipse.core.commands.ExecutionEvent; |
... | ... | |
85 | 83 |
return editor; |
86 | 84 |
} |
87 | 85 |
|
88 |
/** |
|
89 |
* Opens a new editor window with the given TaxonEditorInput |
|
90 |
* |
|
91 |
* @param input |
|
92 |
* a {@link eu.etaxonomy.taxeditor.editor.TaxonEditorInput} |
|
93 |
* object. |
|
94 |
* @throws org.eclipse.ui.PartInitException |
|
95 |
* if any. |
|
96 |
*/ |
|
97 |
public static void open(TaxonEditorInput input) throws PartInitException { |
|
98 |
open(input, MultiPageTaxonEditor.ID); |
|
99 |
} |
|
100 |
|
|
101 | 86 |
public static void open(PolytomousKeyEditorInput input) |
102 | 87 |
throws PartInitException { |
103 | 88 |
open(input, KeyEditor.ID); |
... | ... | |
235 | 220 |
return isSaving; |
236 | 221 |
} |
237 | 222 |
|
238 |
/** |
|
239 |
* Returns a set of all currently open <code>MultiPageTaxonEditor</code>s. |
|
240 |
* |
|
241 |
* @return a {@link java.util.Set} object. |
|
242 |
*/ |
|
243 |
public static Set<IEditorPart> getOpenEditors() { |
|
244 |
Set<IEditorPart> taxonEditors = new HashSet<IEditorPart>(); |
|
245 |
|
|
246 |
if (getActivePage() != null) { |
|
247 |
for (IEditorReference reference : getActivePage() |
|
248 |
.getEditorReferences()) { |
|
249 |
IEditorPart editor = reference.getEditor(false); |
|
250 |
if (editor instanceof MultiPageTaxonEditor) { |
|
251 |
taxonEditors.add(editor); |
|
252 |
} |
|
253 |
} |
|
254 |
} |
|
255 |
|
|
256 |
return taxonEditors; |
|
257 |
} |
|
258 |
|
|
259 |
/** |
|
260 |
* Returns the currently active taxon editor |
|
261 |
* |
|
262 |
* @return the taxon editor that has focus |
|
263 |
*/ |
|
264 |
public static MultiPageTaxonEditor getActiveMultiPageTaxonEditor() { |
|
265 |
Object editorPart = getActiveE4Editor(); |
|
266 |
if (editorPart != null && editorPart instanceof MultiPageTaxonEditor) { |
|
267 |
MultiPageTaxonEditor editor = (MultiPageTaxonEditor) editorPart; |
|
268 |
editor.getConversationHolder().bind(); |
|
269 |
return editor; |
|
270 |
} |
|
271 |
return null; |
|
272 |
} |
|
273 |
|
|
274 |
/** |
|
275 |
* <p> |
|
276 |
* getActiveEditorPage |
|
277 |
* </p> |
|
278 |
* |
|
279 |
* @param page |
|
280 |
* a {@link eu.etaxonomy.taxeditor.editor.Page} object. |
|
281 |
* @return a {@link org.eclipse.ui.IEditorPart} object. |
|
282 |
*/ |
|
283 |
public static IEditorPart getActiveEditorPage(Page page) { |
|
284 |
MultiPageTaxonEditor editor = getActiveMultiPageTaxonEditor(); |
|
285 |
|
|
286 |
return editor != null ? editor.getPage(page) : null; |
|
287 |
} |
|
288 |
|
|
289 |
/** |
|
290 |
* Returns the selection of the currently active taxon editor |
|
291 |
* |
|
292 |
* @return a {@link org.eclipse.jface.viewers.ISelection} object. |
|
293 |
*/ |
|
294 |
public static ISelection getCurrentSelection() { |
|
295 |
if (getActiveMultiPageTaxonEditor() == null) { |
|
296 |
return null; |
|
297 |
} else { |
|
298 |
return getActiveMultiPageTaxonEditor().getSite() |
|
299 |
.getSelectionProvider().getSelection(); |
|
300 |
} |
|
301 |
} |
|
302 |
|
|
303 |
/** |
|
304 |
* <p> |
|
305 |
* getUndoContext |
|
306 |
* </p> |
|
307 |
* |
|
308 |
* @param editor |
|
309 |
* a {@link eu.etaxonomy.taxeditor.editor.MultiPageTaxonEditor} |
|
310 |
* object. |
|
311 |
* @return a {@link org.eclipse.core.commands.operations.IUndoContext} |
|
312 |
* object. |
|
313 |
*/ |
|
314 |
public static IUndoContext getUndoContext(MultiPageTaxonEditor editor) { |
|
315 |
return editor.getUndoContext(); |
|
316 |
} |
|
317 |
|
|
318 | 223 |
/** |
319 | 224 |
* <p> |
320 | 225 |
* getUndoContext |
Also available in: Unified diff
ref #6595 removed e3 name editor classes (unstable navigator plugin)