Revision cdf77847
Added by Patrick Plitzner almost 11 years ago
eu.etaxonomy.taxeditor.navigation/src/main/java/eu/etaxonomy/taxeditor/navigation/navigator/TaxonNavigator.java | ||
---|---|---|
1 | 1 |
// $Id$ |
2 | 2 |
/** |
3 | 3 |
* Copyright (C) 2007 EDIT |
4 |
* European Distributed Institute of Taxonomy
|
|
4 |
* European Distributed Institute of Taxonomy |
|
5 | 5 |
* http://www.e-taxonomy.eu |
6 |
*
|
|
6 |
* |
|
7 | 7 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
8 | 8 |
* See LICENSE.TXT at the top of this package for the full license terms. |
9 | 9 |
*/ |
... | ... | |
18 | 18 |
import java.util.Set; |
19 | 19 |
import java.util.UUID; |
20 | 20 |
|
21 |
import org.eclipse.core.commands.Command; |
|
22 |
import org.eclipse.core.commands.common.NotDefinedException; |
|
23 | 21 |
import org.eclipse.core.runtime.IAdaptable; |
24 | 22 |
import org.eclipse.core.runtime.IProgressMonitor; |
25 | 23 |
import org.eclipse.jface.viewers.DoubleClickEvent; |
... | ... | |
27 | 25 |
import org.eclipse.ui.IMemento; |
28 | 26 |
import org.eclipse.ui.IViewSite; |
29 | 27 |
import org.eclipse.ui.PartInitException; |
30 |
import org.eclipse.ui.commands.ICommandService; |
|
31 |
import org.eclipse.ui.handlers.IHandlerService; |
|
32 | 28 |
import org.eclipse.ui.navigator.CommonNavigator; |
33 | 29 |
|
34 | 30 |
import eu.etaxonomy.cdm.api.conversation.ConversationHolder; |
... | ... | |
45 | 41 |
|
46 | 42 |
/** |
47 | 43 |
* Taxonomic tree implementation using Common Navigator Framework. |
48 |
*
|
|
44 |
* |
|
49 | 45 |
* @author p.ciardelli |
50 | 46 |
* @author n.hoffmann |
51 | 47 |
* @created 02.06.2009 |
... | ... | |
60 | 56 |
*/ |
61 | 57 |
public static final String ID = "eu.etaxonomy.taxeditor.navigation.navigator"; //$NON-NLS-1$ |
62 | 58 |
|
63 |
/** |
|
64 |
* Constant |
|
65 |
* <code>OPEN_COMMAND_ID="eu.etaxonomy.taxeditor.navigation.comma"{trunked}</code> |
|
66 |
*/ |
|
67 |
public static final String OPEN_COMMAND_ID = "eu.etaxonomy.taxeditor.navigation.command.editSelection"; |
|
68 |
|
|
69 | 59 |
private static final String TREE_PATH = "treepath"; |
70 | 60 |
|
71 | 61 |
private static final String TREE_PATHS = "treepaths"; |
... | ... | |
78 | 68 |
|
79 | 69 |
/* |
80 | 70 |
* (non-Javadoc) |
81 |
*
|
|
71 |
* |
|
82 | 72 |
* @see org.eclipse.ui.navigator.CommonNavigator#getInitialInput() |
83 | 73 |
*/ |
84 | 74 |
/** {@inheritDoc} */ |
... | ... | |
120 | 110 |
*/ |
121 | 111 |
public void refresh() { |
122 | 112 |
if(getConversationHolder() != null){ |
123 |
getConversationHolder().bind();
|
|
113 |
getConversationHolder().bind(); |
|
124 | 114 |
} |
125 | 115 |
getCommonViewer().refresh(); |
126 | 116 |
} |
... | ... | |
136 | 126 |
* <p> |
137 | 127 |
* restore |
138 | 128 |
* </p> |
139 |
*
|
|
129 |
* |
|
140 | 130 |
* @param memento |
141 | 131 |
* a {@link org.eclipse.ui.IMemento} object. |
142 | 132 |
* @param monitor |
... | ... | |
203 | 193 |
|
204 | 194 |
List<CdmBase> pathList = new ArrayList<CdmBase>(); |
205 | 195 |
|
206 |
if (string.length() == 0) |
|
207 |
return null; |
|
196 |
if (string.length() == 0) { |
|
197 |
return null; |
|
198 |
} |
|
208 | 199 |
|
209 | 200 |
for (String uuid : string.split(" ")) { |
210 | 201 |
CdmBase cdmBaseObject = CdmStore.getService( |
... | ... | |
216 | 207 |
IClassificationService.class).load( |
217 | 208 |
UUID.fromString(uuid)); |
218 | 209 |
|
219 |
if (cdmBaseObject == null) |
|
220 |
return null; |
|
210 |
if (cdmBaseObject == null) { |
|
211 |
return null; |
|
212 |
} |
|
221 | 213 |
} |
222 | 214 |
pathList.add(cdmBaseObject); |
223 | 215 |
} |
... | ... | |
234 | 226 |
* <p> |
235 | 227 |
* saveTreeState |
236 | 228 |
* </p> |
237 |
*
|
|
229 |
* |
|
238 | 230 |
* @param memento |
239 | 231 |
* a {@link org.eclipse.ui.IMemento} object. |
240 | 232 |
* @param progressMonitor |
... | ... | |
274 | 266 |
|
275 | 267 |
/* |
276 | 268 |
* (non-Javadoc) |
277 |
*
|
|
269 |
* |
|
278 | 270 |
* @see |
279 | 271 |
* eu.etaxonomy.cdm.api.conversation.IConversationEnabled#getConversationHolder |
280 | 272 |
* () |
... | ... | |
283 | 275 |
* <p> |
284 | 276 |
* getConversationHolder |
285 | 277 |
* </p> |
286 |
*
|
|
278 |
* |
|
287 | 279 |
* @return a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} |
288 | 280 |
* object. |
289 | 281 |
*/ |
... | ... | |
294 | 286 |
|
295 | 287 |
/* |
296 | 288 |
* (non-Javadoc) |
297 |
*
|
|
289 |
* |
|
298 | 290 |
* @see |
299 | 291 |
* eu.etaxonomy.cdm.persistence.hibernate.ICdmPostDataChangeObserver#update |
300 | 292 |
* (eu.etaxonomy.cdm.persistence.hibernate.CdmDataChangeMap) |
... | ... | |
320 | 312 |
|
321 | 313 |
/* |
322 | 314 |
* (non-Javadoc) |
323 |
*
|
|
315 |
* |
|
324 | 316 |
* @see org.eclipse.ui.part.WorkbenchPart#dispose() |
325 | 317 |
*/ |
326 | 318 |
/** {@inheritDoc} */ |
... | ... | |
335 | 327 |
|
336 | 328 |
/* |
337 | 329 |
* (non-Javadoc) |
338 |
*
|
|
330 |
* |
|
339 | 331 |
* @see org.eclipse.ui.navigator.CommonNavigator#setFocus() |
340 | 332 |
*/ |
341 | 333 |
/** {@inheritDoc} */ |
... | ... | |
350 | 342 |
|
351 | 343 |
/* |
352 | 344 |
* (non-Javadoc) |
353 |
*
|
|
345 |
* |
|
354 | 346 |
* @see |
355 | 347 |
* eu.etaxonomy.taxeditor.operations.IPostOperationEnabled#postOperation |
356 | 348 |
* (eu.etaxonomy.cdm.model.common.CdmBase) |
... | ... | |
366 | 358 |
* <p> |
367 | 359 |
* save |
368 | 360 |
* </p> |
369 |
*
|
|
361 |
* |
|
370 | 362 |
* @param memento |
371 | 363 |
* a {@link org.eclipse.ui.IMemento} object. |
372 | 364 |
* @param monitor |
... | ... | |
383 | 375 |
/** {@inheritDoc} */ |
384 | 376 |
@Override |
385 | 377 |
protected void handleDoubleClick(DoubleClickEvent anEvent) { |
386 |
|
|
387 |
ICommandService commandService = (ICommandService) getSite() |
|
388 |
.getService(ICommandService.class); |
|
389 |
|
|
390 |
Command command = commandService.getCommand(OPEN_COMMAND_ID); |
|
391 |
if (command.isEnabled()) { |
|
392 |
IHandlerService handlerService = (IHandlerService) getSite() |
|
393 |
.getService(IHandlerService.class); |
|
394 |
try { |
|
395 |
handlerService.executeCommand(OPEN_COMMAND_ID, null); |
|
396 |
} catch (NotDefinedException e) { |
|
397 |
throw new RuntimeException("Could not find open command: " |
|
398 |
+ OPEN_COMMAND_ID); |
|
399 |
} catch (Exception e) { |
|
400 |
NavigationUtil |
|
401 |
.error(getClass(), |
|
402 |
"An exception occured while trying to open a selection", |
|
403 |
e); |
|
404 |
} |
|
405 |
} |
|
378 |
NavigationUtil.executeEditHandler(); |
|
406 | 379 |
// If the double click is passed up to the super-class it will |
407 | 380 |
// expand/collapse trees. |
408 | 381 |
// We do not want that |
... | ... | |
413 | 386 |
* <p> |
414 | 387 |
* onComplete |
415 | 388 |
* </p> |
416 |
*
|
|
389 |
* |
|
417 | 390 |
* @return a boolean. |
418 | 391 |
*/ |
419 | 392 |
@Override |
... | ... | |
423 | 396 |
|
424 | 397 |
/* |
425 | 398 |
* (non-Javadoc) |
426 |
*
|
|
399 |
* |
|
427 | 400 |
* @see org.eclipse.ui.part.WorkbenchPart#showBusy(boolean) |
428 | 401 |
*/ |
429 | 402 |
/** {@inheritDoc} */ |
... | ... | |
450 | 423 |
if(o instanceof LoginManager){ |
451 | 424 |
refresh(); |
452 | 425 |
} |
453 |
|
|
426 |
|
|
454 | 427 |
} |
455 | 428 |
} |
Also available in: Unified diff
simplified code for opening editor in TaxonNavigator