2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.taxeditor
.model
;
12 import java
.lang
.reflect
.Field
;
13 import java
.lang
.reflect
.InvocationTargetException
;
14 import java
.util
.ArrayList
;
15 import java
.util
.Collection
;
16 import java
.util
.LinkedHashMap
;
17 import java
.util
.List
;
18 import java
.util
.TreeSet
;
19 import java
.util
.UUID
;
21 import org
.apache
.commons
.lang
.StringUtils
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.eclipse
.core
.commands
.ExecutionException
;
24 import org
.eclipse
.core
.commands
.NotEnabledException
;
25 import org
.eclipse
.core
.commands
.NotHandledException
;
26 import org
.eclipse
.core
.commands
.common
.NotDefinedException
;
27 import org
.eclipse
.core
.commands
.operations
.AbstractOperation
;
28 import org
.eclipse
.core
.commands
.operations
.IOperationHistory
;
29 import org
.eclipse
.core
.runtime
.IAdaptable
;
30 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
31 import org
.eclipse
.core
.runtime
.IStatus
;
32 import org
.eclipse
.core
.runtime
.NullProgressMonitor
;
33 import org
.eclipse
.core
.runtime
.OperationCanceledException
;
34 import org
.eclipse
.core
.runtime
.Status
;
35 import org
.eclipse
.core
.runtime
.SubProgressMonitor
;
36 import org
.eclipse
.core
.runtime
.jobs
.ISchedulingRule
;
37 import org
.eclipse
.core
.runtime
.jobs
.Job
;
38 import org
.eclipse
.e4
.ui
.model
.application
.ui
.basic
.MPart
;
39 import org
.eclipse
.jface
.action
.IStatusLineManager
;
40 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
41 import org
.eclipse
.jface
.resource
.ColorRegistry
;
42 import org
.eclipse
.jface
.resource
.FontRegistry
;
43 import org
.eclipse
.swt
.graphics
.Color
;
44 import org
.eclipse
.swt
.graphics
.Font
;
45 import org
.eclipse
.swt
.widgets
.Display
;
46 import org
.eclipse
.swt
.widgets
.Shell
;
47 import org
.eclipse
.ui
.IEditorPart
;
48 import org
.eclipse
.ui
.IViewPart
;
49 import org
.eclipse
.ui
.IViewReference
;
50 import org
.eclipse
.ui
.IWorkbench
;
51 import org
.eclipse
.ui
.IWorkbenchPage
;
52 import org
.eclipse
.ui
.IWorkbenchPart
;
53 import org
.eclipse
.ui
.IWorkbenchWindow
;
54 import org
.eclipse
.ui
.PartInitException
;
55 import org
.eclipse
.ui
.PlatformUI
;
56 import org
.eclipse
.ui
.handlers
.IHandlerService
;
57 import org
.eclipse
.ui
.ide
.undo
.WorkspaceUndoUtil
;
58 import org
.eclipse
.ui
.internal
.E4PartWrapper
;
59 import org
.eclipse
.ui
.part
.EditorPart
;
60 import org
.eclipse
.ui
.progress
.IProgressConstants
;
61 import org
.eclipse
.ui
.progress
.IProgressService
;
62 import org
.eclipse
.ui
.progress
.IWorkbenchSiteProgressService
;
63 import org
.eclipse
.ui
.themes
.ITheme
;
64 import org
.eclipse
.ui
.themes
.IThemeManager
;
66 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
67 import eu
.etaxonomy
.cdm
.api
.service
.IProgressMonitorService
;
68 import eu
.etaxonomy
.cdm
.common
.monitor
.IRemotingProgressMonitor
;
69 import eu
.etaxonomy
.cdm
.model
.common
.IEnumTerm
;
70 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
71 import eu
.etaxonomy
.taxeditor
.operation
.IFeedbackGenerator
;
72 import eu
.etaxonomy
.taxeditor
.operation
.IPostMoniteredOperationEnabled
;
73 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
74 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmHandler
;
75 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
76 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
77 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.ReportTextDialog
;
78 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmDataViewer
;
79 import eu
.etaxonomy
.taxeditor
.view
.detail
.DetailsViewPart
;
80 import eu
.etaxonomy
.taxeditor
.view
.supplementaldata
.SupplementalDataViewPart
;
88 public abstract class AbstractUtility
{
90 private static final Logger logger
= Logger
.getLogger(AbstractUtility
.class);
92 /** Constant <code>statusLineManager</code> */
93 protected static IStatusLineManager statusLineManager
;
96 public static boolean closeAll() {
97 if(getActivePage()!=null){
98 return getActivePage().closeAllEditors(true);
104 * Close the given editor.
107 * The <tt>MultipageTaxonEditor</tt> to close.
108 * @return <tt>true</tt> on success
110 public static boolean close(EditorPart editor
) {
111 return getActivePage() != null ?
getActivePage().closeEditor(editor
, true):false;
114 public static Shell
getShell() {
116 return TaxeditorStorePlugin
.getDefault().getWorkbench()
117 .getActiveWorkbenchWindow().getShell();
120 public static IWorkbenchPage
getActivePage() {
122 return TaxeditorStorePlugin
.getDefault().getWorkbench()
123 .getActiveWorkbenchWindow().getActivePage();
124 } catch(NullPointerException npe
){
129 public static IWorkbenchPart
getActiveWorkbenchPart() {
130 IWorkbenchPage activePage
= getActivePage();
131 if(activePage
!=null){
132 IWorkbenchPart activePart
= activePage
.getActivePart();
133 if(activePart
!=null){
140 public static Object
getActiveE4Part() {
141 IWorkbenchPage activePage
= getActivePage();
142 if(activePage
!=null){
143 IWorkbenchPart activePart
= activePage
.getActivePart();
144 Object e4WrappedPart
= getE4WrappedPart(activePart
);
145 return e4WrappedPart
!=null?e4WrappedPart
:activePart
;
150 public static Object
getE4WrappedPart(Object activePart
){
151 if(activePart
instanceof E4PartWrapper
){
152 //FIXME can be removed when E4 migration is complete
154 Field field
= activePart
.getClass().getDeclaredField("wrappedPart");
155 field
.setAccessible(true);
156 Object object
= field
.get(activePart
);
157 if(object
instanceof MPart
){
158 return ((MPart
) object
).getObject();
160 } catch (NoSuchFieldException
| SecurityException
| IllegalArgumentException
| IllegalAccessException e
) {
167 public static IWorkbench
getWorkbench() {
168 return TaxeditorStorePlugin
.getDefault().getWorkbench();
171 public static IWorkbenchWindow
getWorkbenchWindow() {
172 if (getWorkbench().getWorkbenchWindowCount() > 1) {
173 throw new IllegalStateException("More than one workbench window");
175 return getWorkbench().getWorkbenchWindows()[0];
178 public static IViewPart
showView(String id
) {
180 return PlatformUI
.getWorkbench().getActiveWorkbenchWindow()
182 .showView(id
, null, IWorkbenchPage
.VIEW_VISIBLE
);
183 } catch (PartInitException e
) {
184 MessagingUtils
.messageDialog("Error opening view", AbstractUtility
.class, "Could not open view: " + id
, e
);
189 public static void hideView(IViewPart view
) {
190 PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
194 public static IViewPart
getView(String id
, boolean restore
) {
195 IWorkbench workbench
= PlatformUI
.getWorkbench();
196 IWorkbenchWindow activeWorkbenchWindow
= workbench
.getActiveWorkbenchWindow();
197 IViewReference
[] references
= null;
198 if(activeWorkbenchWindow
!=null && activeWorkbenchWindow
.getActivePage()!=null){
199 references
= activeWorkbenchWindow
.getActivePage().getViewReferences();
201 else if(workbench
.getWorkbenchWindows().length
>0 && workbench
.getWorkbenchWindows()[0].getActivePage()!=null){
202 references
= workbench
.getWorkbenchWindows()[0].getActivePage().getViewReferences();
204 if(references
!=null){
205 for (IViewReference reference
: references
) {
206 if (reference
.getId().equals(id
)) {
207 return reference
.getView(restore
);
214 public static Object
getService(Class api
) {
215 return TaxeditorStorePlugin
.getDefault().getWorkbench().getService(api
);
218 public static ITheme
getCurrentTheme() {
219 IThemeManager themeManager
= TaxeditorStorePlugin
.getDefault()
220 .getWorkbench().getThemeManager();
221 return themeManager
.getCurrentTheme();
225 * Fonts registered to the plugin may be obtained with the Eclipse themeing
226 * functionality. Thus fonts are chooseable by the user via
227 * Preferences->General->Appearance->Colors and Fonts
229 * @return the FontRegistry for the current theme
231 public static FontRegistry
getFontRegistry() {
232 return getCurrentTheme().getFontRegistry();
235 public static Font
getFont(String symbolicName
) {
236 return getFontRegistry().get(symbolicName
);
240 * Color registered to the plugin may be obtained with the Eclipse themeing
241 * functionality. Thus colors are editable by the user via
242 * Preferences->General->Appearance->Colors and Fonts
244 * @return the ColorRegistry for the current theme
246 public static ColorRegistry
getColorRegistry() {
247 return getCurrentTheme().getColorRegistry();
250 public static Color
getColor(String symbolicName
) {
251 return getColorRegistry().get(symbolicName
);
254 public static IStatus
executeOperation(final AbstractPostOperation operation
) {
255 if (getOperationHistory() == null) {
256 throw new IllegalArgumentException(
257 "There is no operation history for this context");
260 final IAdaptable uiInfoAdapter
= WorkspaceUndoUtil
261 .getUIInfoAdapter(getShell());
263 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
266 public void run(IProgressMonitor monitor
)
267 throws InvocationTargetException
, InterruptedException
{
268 String operationlabel
= operation
.getLabel();
269 monitor
.beginTask(operationlabel
, 100);
270 IStatus status
= Status
.CANCEL_STATUS
;
272 operation
.addContext(IOperationHistory
.GLOBAL_UNDO_CONTEXT
);
273 status
= getOperationHistory().execute(operation
, monitor
,
275 } catch (ExecutionException e
) {
277 MessagingUtils
.operationDialog(this, e
, TaxeditorStorePlugin
.PLUGIN_ID
, operationlabel
, null);
283 String statusString
= status
.equals(Status
.OK_STATUS
) ?
"completed"
285 setStatusLine(operationlabel
+ " " + statusString
+ ".");
291 runInUI(runnable
, null);
292 } catch (Exception e
) {
293 MessagingUtils
.messageDialog("Error executing operation", AbstractUtility
.class, "An error occured while executing " + operation
.getLabel(), e
);
296 IPostOperationEnabled postOperationEnabled
= operation
297 .getPostOperationEnabled();
298 if (postOperationEnabled
!= null) {
299 postOperationEnabled
.onComplete();
301 return Status
.OK_STATUS
;
304 public static IStatus
executeOperation(final AbstractOperation operation
, final RemotingCdmHandler handler
) {
305 if (getOperationHistory() == null) {
306 throw new IllegalArgumentException(
307 "There is no operation history for this context");
310 final IAdaptable uiInfoAdapter
= WorkspaceUndoUtil
311 .getUIInfoAdapter(getShell());
313 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
316 public void run(IProgressMonitor monitor
)
317 throws InvocationTargetException
, InterruptedException
{
318 String operationlabel
= operation
.getLabel();
319 monitor
.beginTask(operationlabel
, 100);
320 IStatus status
= Status
.CANCEL_STATUS
;
322 operation
.addContext(IOperationHistory
.GLOBAL_UNDO_CONTEXT
);
323 status
= getOperationHistory().execute(operation
, monitor
,
325 if(handler
!= null) {
326 handler
.postOperation(status
);
328 } catch (ExecutionException e
) {
329 MessagingUtils
.operationDialog(this, e
, TaxeditorStorePlugin
.PLUGIN_ID
, operationlabel
, null);
334 String statusString
= status
.equals(Status
.OK_STATUS
) ?
"completed"
336 setStatusLine(operationlabel
+ " " + statusString
+ ".");
342 runInUI(runnable
, null);
343 } catch (Exception e
) {
344 MessagingUtils
.messageDialog("Error executing operation", AbstractUtility
.class, "An error occured while executing " + operation
.getLabel(), e
);
347 return Status
.OK_STATUS
;
351 * Executes a remoting monitored operation
353 * @param label for the operation
354 * @param uuid of the remoting monitor already started on the server
355 * @param pollInterval in milliseconds
356 * @param cancelable flag which determines whether the operation can be cancelled
357 * @param postOp callback for running post operation logic
360 public static IStatus
executeMoniteredOperation(final String label
,
362 final int pollInterval
,
363 final boolean cancelable
,
364 final IPostMoniteredOperationEnabled postOp
,
365 final IFeedbackGenerator feedbackGenerator
) {
368 // get the remoting monitor the first time to make sure that the
369 // operation is valid
370 final IProgressMonitorService progressMonitorService
= CdmApplicationState
.getCurrentAppConfig().getProgressMonitorService();
371 final IRemotingProgressMonitor firstRemotingMonitor
= progressMonitorService
.getRemotingMonitor(uuid
);
372 if(firstRemotingMonitor
== null) {
373 throw new IllegalStateException("Remoting progress monitor is null");
376 Job job
= new Job(label
) {
380 public IStatus
run(IProgressMonitor monitor
) {
381 // run the monitor until the operation is finished
382 IRemotingProgressMonitor remotingMonitor
;
384 remotingMonitor
= CdmStore
.getProgressMonitorClientManager().pollMonitor(label
,
390 } catch (Exception ex
) {
391 return new Status(Status
.ERROR
, TaxeditorStorePlugin
.PLUGIN_ID
, "Operation Interrupted", ex
);
393 final StringBuilder reportSb
= new StringBuilder();
395 for(String report
: remotingMonitor
.getReports()) {
396 reportSb
.append(report
);
398 if(!StringUtils
.isBlank(reportSb
.toString())) {
399 Display
.getDefault().asyncExec(new Runnable() {
402 // display reports with possibility to save
403 ReportTextDialog dialog
= new ReportTextDialog(PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getShell());
404 dialog
.setTitle(label
+ " Report");
405 dialog
.setReportText(reportSb
.toString());
410 return Status
.OK_STATUS
;
414 protected void canceling() {
415 CdmStore
.getCurrentApplicationConfiguration().getProgressMonitorService().cancel(uuid
);
420 job
.setProperty(IProgressConstants
.KEEP_PROPERTY
, true);
425 } catch (Exception e
) {
426 MessagingUtils
.errorDialog("Error executing operation",
427 AbstractUtility
.class,
428 "An error occured while executing " + label
,
429 TaxeditorStorePlugin
.PLUGIN_ID
,
434 return Status
.OK_STATUS
;
437 public static IOperationHistory
getOperationHistory() {
438 return getWorkbench().getOperationSupport().getOperationHistory();
441 public static void setStatusLine(final String message
) {
442 Display
.getDefault().asyncExec(new Runnable() {
446 statusLineManager
.setMessage(message
);
453 public static IProgressMonitor
getMonitor() {
454 statusLineManager
.setCancelEnabled(false);
455 return statusLineManager
.getProgressMonitor();
459 * Starts either the given {@link IProgressMonitor} if it's not
460 * <code>null</code> or a new {@link NullProgressMonitor}.
462 * @param progressMonitor
463 * The {@link IProgressMonitor} or <code>null</code> if no
464 * progress should be reported.
466 * The name of the main task.
468 * The number of steps this task is subdivided into.
469 * @return The {@link IProgressMonitor}.
471 public static IProgressMonitor
startMainMonitor(
472 IProgressMonitor progressMonitor
, String taskName
, int steps
) {
473 IProgressMonitor newMonitor
= progressMonitor
;
474 if (newMonitor
== null) {
475 newMonitor
= new NullProgressMonitor();
477 newMonitor
.beginTask(taskName
== null ?
"" : taskName
, steps
);
478 newMonitor
.subTask(" ");
483 * Creates a {@link SubProgressMonitor} if the given
484 * {@link IProgressMonitor} is not <code>null</code> and not a
485 * {@link NullProgressMonitor}.
487 * @param progressMonitor
488 * The parent {@link IProgressMonitor} of the
489 * {@link SubProgressMonitor} to be created.
491 * The number of steps this subtask is subdivided into. Must be a
492 * positive number and must not be
493 * {@link IProgressMonitor#UNKNOWN}.
494 * @return The {@link IProgressMonitor}.
496 public static IProgressMonitor
getSubProgressMonitor(
497 IProgressMonitor progressMonitor
, int ticks
) {
498 if (progressMonitor
== null) {
499 return new NullProgressMonitor();
501 if (progressMonitor
instanceof NullProgressMonitor
) {
502 return progressMonitor
;
505 return new SubProgressMonitor(progressMonitor
, ticks
);
509 * Checks whether the user canceled this operation. If not canceled, the
510 * given number of steps are declared as done.
513 * a {@link org.eclipse.core.runtime.IProgressMonitor} object.
517 public static void workedChecked(IProgressMonitor newMonitor
, int steps
) {
518 // In case the progress monitor was canceled throw an exception.
519 if (newMonitor
.isCanceled()) {
520 throw new OperationCanceledException();
522 // Otherwise declare this step as done.
523 newMonitor
.worked(steps
);
527 * Present a progress dialog to the user. This dialog will block the UI
530 * an implementation of {@link IRunnableWithProgress}
531 * @throws java.lang.InterruptedException
533 * @throws java.lang.reflect.InvocationTargetException
536 public static void busyCursorWhile(IRunnableWithProgress runnable
)
537 throws InvocationTargetException
, InterruptedException
{
538 getProgressService().busyCursorWhile(runnable
);
541 public static void runInUI(IRunnableWithProgress runnable
,
542 ISchedulingRule rule
) throws InvocationTargetException
,
543 InterruptedException
{
544 getProgressService().runInUI(getWorkbenchWindow(), runnable
, rule
);
547 public static void run(boolean fork
, boolean cancelable
,
548 IRunnableWithProgress runnable
) throws InvocationTargetException
,
549 InterruptedException
{
550 getProgressService().run(fork
, cancelable
, runnable
);
553 public static IProgressService
getProgressService() {
554 IWorkbench workbench
= PlatformUI
.getWorkbench();
555 return workbench
.getProgressService();
558 public static IWorkbenchSiteProgressService
getProgressService2() {
559 return (IWorkbenchSiteProgressService
) getService(IWorkbenchSiteProgressService
.class);
562 public static String
getPluginId() {
563 return "eu.taxeditor";
566 public static IEditorPart
getActiveEditor() {
567 return getActivePage() != null ?
getActivePage().getActiveEditor()
571 public static Object
getActiveE4Editor() {
572 if(getActivePage()!=null){
573 IEditorPart activeEditor
= getActivePage().getActiveEditor();
574 Object wrappedPart
= getE4WrappedPart(getActivePage().getActivePart());
575 return wrappedPart
!=null?wrappedPart
:activeEditor
;
580 public static DetailsViewPart
getDetailsView() {
581 return (DetailsViewPart
) getView(DetailsViewPart
.ID
, false);
584 public static void refreshDetailsViewer() {
585 if (getDetailsView() != null) {
586 ((AbstractCdmDataViewer
) getDetailsView().getViewer()).refresh();
590 public static void reflowDetailsViewer() {
591 if (getDetailsView() != null) {
592 ((AbstractCdmDataViewer
) getDetailsView().getViewer()).reflow();
596 public static SupplementalDataViewPart
getSupplementalDataView() {
597 return (SupplementalDataViewPart
) getView(SupplementalDataViewPart
.ID
,
601 public static void reflowSupplementalViewer() {
602 if (getSupplementalDataView() != null) {
603 ((AbstractCdmDataViewer
) getSupplementalDataView().getViewer())
610 * Orders a Collection of {@link IEnumTerm}s according to the term
613 * The returned map will be be ordered primarily by root elements,
614 * secondarily by the child elements and their children resp., both ascending alphabetically. <br>
616 * A {@link Collection} of {@link IEnumTerm}s for which the term
617 * hierarchy should be created
618 * @return a map which holds the terms as keys and their string
619 * representation via {@link IEnumTerm#getMessage()} as values
621 public static <T
extends IEnumTerm
<T
>> LinkedHashMap
<T
, String
> orderTerms(Collection
<T
> terms
) {
622 TreeSet
<TermNode
<T
>> parentElements
= new TreeSet
<TermNode
<T
>>();
623 parentElements
.addAll(getTermHierarchy(terms
));
625 // create list according to the type hierarchy (root elements alphabetically with recursive children also alphabetically)
626 LinkedHashMap
<T
, String
> result
= new LinkedHashMap
<T
, String
>();
627 parseTermTree(parentElements
, result
, -1);
631 private static<T
extends IEnumTerm
<T
>> void parseTermTree(Collection
<TermNode
<T
>> children
, LinkedHashMap
<T
, String
> result
, int depth
){
633 for(TermNode
<T
> node
:children
){
634 String indentString
= "";
635 for(int i
=0;i
<depth
;i
++){
639 indentString
+= "- ";
641 result
.put(node
.term
, indentString
+ node
.term
.getMessage());
642 parseTermTree(node
.children
, result
, depth
);
646 private static<T
extends IEnumTerm
<T
>> void addToParents(List
<TermNode
<T
>> parents
, Collection
<T
> terms
){
647 List
<TermNode
<T
>> hasChildrenList
= new ArrayList
<TermNode
<T
>>();
649 // only terms with parents
650 if(term
.getKindOf()!=null){
651 TermNode
<T
> parentNode
= new TermNode
<T
>(term
.getKindOf());
652 TermNode
<T
> childNode
= new TermNode
<T
>(term
);
653 if(parents
.contains(parentNode
)){
654 // parent found in parent list -> add this term to parent's child list
655 parents
.get(parents
.indexOf(parentNode
)).addChild(childNode
);
656 if(!term
.getGeneralizationOf().isEmpty()){
657 // has more children -> add to list which will be the parent for the next recursion
658 hasChildrenList
.add(childNode
);
663 if(!hasChildrenList
.isEmpty()){
664 addToParents(hasChildrenList
, terms
);
668 private static<T
extends IEnumTerm
<T
>> List
<TermNode
<T
>> getTermHierarchy(Collection
<T
> terms
){
669 List
<TermNode
<T
>> parents
= new ArrayList
<TermNode
<T
>>();
672 T parentTerm
= term
.getKindOf();
673 if(parentTerm
==null){
675 parents
.add(new TermNode
<T
>(term
));
678 addToParents(parents
, terms
);
682 @SuppressWarnings("unchecked")
684 * Recursively iterates over all term parents until no more parent is found i.e. the root node
685 * @param term The term for which the parent should be found
686 * @return the root terms of the term hierarchy
688 private static<T
extends IEnumTerm
<T
>> T
getParentFor(T term
){
689 // PP: cast should be safe. Why is Eclipse complaining??
690 T parent
= term
.getKindOf();
695 return getParentFor(term
.getKindOf());
699 private static class TermNode
<T
extends IEnumTerm
<T
>> implements Comparable
<TermNode
<T
>>{
700 private final T term
;
701 private final TreeSet
<TermNode
<T
>> children
;
703 public TermNode(T term
) {
706 this.children
= new TreeSet
<TermNode
<T
>>();
709 public void addChild(TermNode
<T
> child
){
710 this.children
.add(child
);
713 public TreeSet
<TermNode
<T
>> getChildren() {
722 public int hashCode() {
723 final int prime
= 31;
725 result
= prime
* result
+ ((term
== null) ?
0 : term
.hashCode());
730 public boolean equals(Object obj
) {
737 if (getClass() != obj
.getClass()) {
740 TermNode other
= (TermNode
) obj
;
742 if (other
.term
!= null) {
745 } else if (!term
.equals(other
.term
)) {
752 public int compareTo(TermNode
<T
> that
) {
753 return this.term
.getMessage().compareTo(that
.term
.getMessage());
758 public static void executeCommand(String commandId
, Object source
, String pluginId
) {
759 IHandlerService handlerService
= (IHandlerService
) AbstractUtility
.getService(IHandlerService
.class);
760 Exception exception
= null;
762 handlerService
.executeCommand(commandId
, null);
763 } catch (ExecutionException e
) {
765 } catch (NotDefinedException e
) {
767 } catch (NotEnabledException e
) {
769 } catch (NotHandledException e
) {
772 if(exception
!= null) {
773 MessagingUtils
.errorDialog("Error executing command",
775 "Could not execute command with id " + commandId
,