3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
11 package eu
.etaxonomy
.taxeditor
.model
;
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
.jface
.action
.IStatusLineManager
;
38 import org
.eclipse
.jface
.dialogs
.ProgressMonitorDialog
;
39 import org
.eclipse
.jface
.operation
.IRunnableWithProgress
;
40 import org
.eclipse
.jface
.resource
.ColorRegistry
;
41 import org
.eclipse
.jface
.resource
.FontRegistry
;
42 import org
.eclipse
.jface
.window
.ApplicationWindow
;
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
.PartInitException
;
54 import org
.eclipse
.ui
.PlatformUI
;
55 import org
.eclipse
.ui
.handlers
.IHandlerService
;
56 import org
.eclipse
.ui
.ide
.undo
.WorkspaceUndoUtil
;
57 import org
.eclipse
.ui
.part
.EditorPart
;
58 import org
.eclipse
.ui
.progress
.IProgressService
;
59 import org
.eclipse
.ui
.progress
.IWorkbenchSiteProgressService
;
60 import org
.eclipse
.ui
.themes
.ITheme
;
61 import org
.eclipse
.ui
.themes
.IThemeManager
;
63 import eu
.etaxonomy
.cdm
.api
.application
.CdmApplicationState
;
64 import eu
.etaxonomy
.cdm
.api
.service
.IProgressMonitorService
;
65 import eu
.etaxonomy
.cdm
.common
.monitor
.IRemotingProgressMonitor
;
66 import eu
.etaxonomy
.cdm
.model
.common
.IEnumTerm
;
67 import eu
.etaxonomy
.taxeditor
.operation
.AbstractPostOperation
;
68 import eu
.etaxonomy
.taxeditor
.operation
.IPostMoniteredOperationEnabled
;
69 import eu
.etaxonomy
.taxeditor
.operation
.IPostOperationEnabled
;
70 import eu
.etaxonomy
.taxeditor
.operation
.RemotingCdmHandler
;
71 import eu
.etaxonomy
.taxeditor
.store
.CdmStore
;
72 import eu
.etaxonomy
.taxeditor
.store
.internal
.TaxeditorStorePlugin
;
73 import eu
.etaxonomy
.taxeditor
.ui
.dialog
.ReportTextDialog
;
74 import eu
.etaxonomy
.taxeditor
.view
.AbstractCdmDataViewer
;
75 import eu
.etaxonomy
.taxeditor
.view
.detail
.DetailsViewPart
;
76 import eu
.etaxonomy
.taxeditor
.view
.supplementaldata
.SupplementalDataViewPart
;
80 * Abstract AbstractUtility class.
87 public abstract class AbstractUtility
{
89 private static final Logger logger
= Logger
.getLogger(AbstractUtility
.class);
91 /** Constant <code>statusLineManager</code> */
92 protected static IStatusLineManager statusLineManager
;
102 public static boolean closeAll() {
103 return getActivePage().closeAllEditors(true);
107 * Close the given editor.
110 * The <tt>MultipageTaxonEditor</tt> to close.
111 * @return <tt>true</tt> on success
113 public static boolean close(EditorPart editor
) {
114 return getActivePage().closeEditor(editor
, true);
122 * @return a {@link org.eclipse.swt.widgets.Shell} object.
124 public static Shell
getShell() {
126 return TaxeditorStorePlugin
.getDefault().getWorkbench()
127 .getActiveWorkbenchWindow().getShell();
135 * @return a {@link org.eclipse.ui.IWorkbenchPage} object.
137 public static IWorkbenchPage
getActivePage() {
139 return TaxeditorStorePlugin
.getDefault().getWorkbench()
140 .getActiveWorkbenchWindow().getActivePage();
148 * @return a {@link org.eclipse.ui.IWorkbenchPart} object.
150 public static IWorkbenchPart
getActivePart() {
151 return getActivePage() != null ?
getActivePage().getActivePart() : null;
154 public static IWorkbench
getWorkbench() {
155 return TaxeditorStorePlugin
.getDefault().getWorkbench();
163 * @return a {@link org.eclipse.jface.window.ApplicationWindow} object.
165 public static ApplicationWindow
getWorkbenchWindow() {
166 if (getWorkbench().getWorkbenchWindowCount() > 1) {
167 throw new IllegalStateException("More than one workbench window");
169 return (ApplicationWindow
) getWorkbench().getWorkbenchWindows()[0];
178 * a {@link java.lang.String} object.
179 * @return a {@link org.eclipse.ui.IViewPart} object.
181 public static IViewPart
showView(String id
) {
183 return PlatformUI
.getWorkbench().getActiveWorkbenchWindow()
185 .showView(id
, null, IWorkbenchPage
.VIEW_VISIBLE
);
186 } catch (PartInitException e
) {
187 MessagingUtils
.messageDialog("Error opening view", AbstractUtility
.class, "Could not open view: " + id
, e
);
198 * a {@link org.eclipse.ui.IViewPart} object.
200 public static void hideView(IViewPart view
) {
201 PlatformUI
.getWorkbench().getActiveWorkbenchWindow().getActivePage()
211 * a {@link java.lang.String} object.
214 * @return a {@link org.eclipse.ui.IViewPart} object.
216 public static IViewPart
getView(String id
, boolean restore
) {
217 IViewReference
[] references
= PlatformUI
.getWorkbench()
218 .getActiveWorkbenchWindow().getActivePage().getViewReferences();
219 for (IViewReference reference
: references
) {
220 if (reference
.getId().equals(id
)) {
221 return reference
.getView(restore
);
233 * a {@link java.lang.Class} object.
234 * @return a {@link java.lang.Object} object.
236 public static Object
getService(Class api
) {
237 return TaxeditorStorePlugin
.getDefault().getWorkbench().getService(api
);
245 * @return a {@link org.eclipse.ui.themes.ITheme} object.
247 public static ITheme
getCurrentTheme() {
248 IThemeManager themeManager
= TaxeditorStorePlugin
.getDefault()
249 .getWorkbench().getThemeManager();
250 return themeManager
.getCurrentTheme();
254 * Fonts registered to the plugin may be obtained with the Eclipse themeing
255 * functionality. Thus fonts are chooseable by the user via
256 * Preferences->General->Appearance->Colors and Fonts
258 * @return the FontRegistry for the current theme
260 public static FontRegistry
getFontRegistry() {
261 return getCurrentTheme().getFontRegistry();
269 * @param symbolicName
270 * a {@link java.lang.String} object.
271 * @return a {@link org.eclipse.swt.graphics.Font} object.
273 public static Font
getFont(String symbolicName
) {
274 return getFontRegistry().get(symbolicName
);
278 * Color registered to the plugin may be obtained with the Eclipse themeing
279 * functionality. Thus colors are editable by the user via
280 * Preferences->General->Appearance->Colors and Fonts
282 * @return the ColorRegistry for the current theme
284 public static ColorRegistry
getColorRegistry() {
285 return getCurrentTheme().getColorRegistry();
293 * @param symbolicName
294 * a {@link java.lang.String} object.
295 * @return a {@link org.eclipse.swt.graphics.Color} object.
297 public static Color
getColor(String symbolicName
) {
298 return getColorRegistry().get(symbolicName
);
308 * {@link eu.etaxonomy.taxeditor.operation.AbstractPostTaxonOperation}
310 * @return a {@link org.eclipse.core.runtime.IStatus} object.
312 public static IStatus
executeOperation(final AbstractPostOperation operation
) {
313 if (getOperationHistory() == null) {
314 throw new IllegalArgumentException(
315 "There is no operation history for this context");
318 final IAdaptable uiInfoAdapter
= WorkspaceUndoUtil
319 .getUIInfoAdapter(getShell());
321 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
324 public void run(IProgressMonitor monitor
)
325 throws InvocationTargetException
, InterruptedException
{
326 String operationlabel
= operation
.getLabel();
327 monitor
.beginTask(operationlabel
, 100);
328 IStatus status
= Status
.CANCEL_STATUS
;
330 operation
.addContext(IOperationHistory
.GLOBAL_UNDO_CONTEXT
);
331 status
= getOperationHistory().execute(operation
, monitor
,
333 } catch (ExecutionException e
) {
335 MessagingUtils
.operationDialog(this, e
, TaxeditorStorePlugin
.PLUGIN_ID
, operationlabel
, null);
341 String statusString
= status
.equals(Status
.OK_STATUS
) ?
"completed"
343 setStatusLine(operationlabel
+ " " + statusString
+ ".");
349 runInUI(runnable
, null);
350 } catch (Exception e
) {
351 MessagingUtils
.messageDialog("Error executing operation", AbstractUtility
.class, "An error occured while executing " + operation
.getLabel(), e
);
354 IPostOperationEnabled postOperationEnabled
= operation
355 .getPostOperationEnabled();
356 if (postOperationEnabled
!= null) {
357 postOperationEnabled
.onComplete();
359 return Status
.OK_STATUS
;
362 public static IStatus
executeOperation(final AbstractOperation operation
, final RemotingCdmHandler handler
) {
363 if (getOperationHistory() == null) {
364 throw new IllegalArgumentException(
365 "There is no operation history for this context");
368 final IAdaptable uiInfoAdapter
= WorkspaceUndoUtil
369 .getUIInfoAdapter(getShell());
371 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
374 public void run(IProgressMonitor monitor
)
375 throws InvocationTargetException
, InterruptedException
{
376 String operationlabel
= operation
.getLabel();
377 monitor
.beginTask(operationlabel
, 100);
378 IStatus status
= Status
.CANCEL_STATUS
;
380 operation
.addContext(IOperationHistory
.GLOBAL_UNDO_CONTEXT
);
381 status
= getOperationHistory().execute(operation
, monitor
,
383 if(handler
!= null) {
384 handler
.postOperation(status
);
386 } catch (ExecutionException e
) {
387 MessagingUtils
.operationDialog(this, e
, TaxeditorStorePlugin
.PLUGIN_ID
, operationlabel
, null);
392 String statusString
= status
.equals(Status
.OK_STATUS
) ?
"completed"
394 setStatusLine(operationlabel
+ " " + statusString
+ ".");
400 runInUI(runnable
, null);
401 } catch (Exception e
) {
402 MessagingUtils
.messageDialog("Error executing operation", AbstractUtility
.class, "An error occured while executing " + operation
.getLabel(), e
);
405 return Status
.OK_STATUS
;
409 * Executes a remoting monitored operation
411 * @param label for the operation
412 * @param uuid of the remoting monitor already started on the server
413 * @param pollInterval in milliseconds
414 * @param cancelable flag which determines whether the operation can be cancelled
415 * @param postOp callback for running post operation logic
418 public static IStatus
executeMoniteredOperation(final String label
,
420 final int pollInterval
,
421 final boolean cancelable
,
422 final IPostMoniteredOperationEnabled postOp
) {
425 // get the remoting monitor the first time to make sure that the
426 // operation is valid
427 final IProgressMonitorService progressMonitorService
= CdmApplicationState
.getCurrentAppConfig().getProgressMonitorService();
428 final IRemotingProgressMonitor firstRemotingMonitor
= progressMonitorService
.getRemotingMonitor(uuid
);
429 if(firstRemotingMonitor
== null) {
430 throw new IllegalStateException("Remoting progress monitor is null");
433 final ProgressMonitorDialog progressDialog
= new ProgressMonitorDialog(getShell());
434 IRunnableWithProgress runnable
= new IRunnableWithProgress() {
437 public void run(IProgressMonitor monitor
) throws InvocationTargetException
, InterruptedException
{
438 // run the monitor untilthe operation is finished
439 IRemotingProgressMonitor remotingMonitor
= CdmStore
.getProgressMonitorClientManager().pollMonitor(label
, uuid
, pollInterval
, postOp
, monitor
);
440 final StringBuilder reportSb
= new StringBuilder();
442 for(String report
: remotingMonitor
.getReports()) {
443 reportSb
.append(report
);
445 if(!StringUtils
.isBlank(reportSb
.toString())) {
446 Display
.getDefault().asyncExec(new Runnable() {
449 // display reports with possibility to save
450 ReportTextDialog dialog
= new ReportTextDialog(progressDialog
.getShell());
451 dialog
.setTitle(label
+ " Report");
452 dialog
.setReportText(reportSb
.toString());
460 progressDialog
.run(true, cancelable
, runnable
);
461 } catch (Exception e
) {
462 MessagingUtils
.errorDialog("Error executing operation",
463 AbstractUtility
.class,
464 "An error occured while executing " + label
,
465 TaxeditorStorePlugin
.PLUGIN_ID
,
470 return Status
.OK_STATUS
;
476 * getOperationHistory
479 * @return a {@link org.eclipse.core.commands.operations.IOperationHistory}
482 public static IOperationHistory
getOperationHistory() {
483 return getWorkbench().getOperationSupport().getOperationHistory();
492 * a {@link java.lang.String} object.
494 public static void setStatusLine(final String message
) {
495 Display
.getDefault().asyncExec(new Runnable() {
499 statusLineManager
.setMessage(message
);
511 * @return a {@link org.eclipse.core.runtime.IProgressMonitor} object.
513 public static IProgressMonitor
getMonitor() {
514 statusLineManager
.setCancelEnabled(false);
515 return statusLineManager
.getProgressMonitor();
519 * Starts either the given {@link IProgressMonitor} if it's not
520 * <code>null</code> or a new {@link NullProgressMonitor}.
522 * @param progressMonitor
523 * The {@link IProgressMonitor} or <code>null</code> if no
524 * progress should be reported.
526 * The name of the main task.
528 * The number of steps this task is subdivided into.
529 * @return The {@link IProgressMonitor}.
531 public static IProgressMonitor
startMainMonitor(
532 IProgressMonitor progressMonitor
, String taskName
, int steps
) {
533 IProgressMonitor newMonitor
= progressMonitor
;
534 if (newMonitor
== null) {
535 newMonitor
= new NullProgressMonitor();
537 newMonitor
.beginTask(taskName
== null ?
"" : taskName
, steps
);
538 newMonitor
.subTask(" ");
543 * Creates a {@link SubProgressMonitor} if the given
544 * {@link IProgressMonitor} is not <code>null</code> and not a
545 * {@link NullProgressMonitor}.
547 * @param progressMonitor
548 * The parent {@link IProgressMonitor} of the
549 * {@link SubProgressMonitor} to be created.
551 * The number of steps this subtask is subdivided into. Must be a
552 * positive number and must not be
553 * {@link IProgressMonitor#UNKNOWN}.
554 * @return The {@link IProgressMonitor}.
556 public static IProgressMonitor
getSubProgressMonitor(
557 IProgressMonitor progressMonitor
, int ticks
) {
558 if (progressMonitor
== null) {
559 return new NullProgressMonitor();
561 if (progressMonitor
instanceof NullProgressMonitor
) {
562 return progressMonitor
;
565 return new SubProgressMonitor(progressMonitor
, ticks
);
569 * Checks whether the user canceled this operation. If not canceled, the
570 * given number of steps are declared as done.
573 * a {@link org.eclipse.core.runtime.IProgressMonitor} object.
577 public static void workedChecked(IProgressMonitor newMonitor
, int steps
) {
578 // In case the progress monitor was canceled throw an exception.
579 if (newMonitor
.isCanceled()) {
580 throw new OperationCanceledException();
582 // Otherwise declare this step as done.
583 newMonitor
.worked(steps
);
587 * Present a progress dialog to the user. This dialog will block the UI
590 * an implementation of {@link IRunnableWithProgress}
591 * @throws java.lang.InterruptedException
593 * @throws java.lang.reflect.InvocationTargetException
596 public static void busyCursorWhile(IRunnableWithProgress runnable
)
597 throws InvocationTargetException
, InterruptedException
{
598 getProgressService().busyCursorWhile(runnable
);
606 * @see {@link IProgressService#runInUI(org.eclipse.jface.operation.IRunnableContext, IRunnableWithProgress, ISchedulingRule)}
608 * a {@link org.eclipse.jface.operation.IRunnableWithProgress}
611 * a {@link org.eclipse.core.runtime.jobs.ISchedulingRule}
613 * @throws java.lang.reflect.InvocationTargetException
615 * @throws java.lang.InterruptedException
618 public static void runInUI(IRunnableWithProgress runnable
,
619 ISchedulingRule rule
) throws InvocationTargetException
,
620 InterruptedException
{
621 getProgressService().runInUI(getWorkbenchWindow(), runnable
, rule
);
634 * a {@link org.eclipse.jface.operation.IRunnableWithProgress}
636 * @throws java.lang.reflect.InvocationTargetException
638 * @throws java.lang.InterruptedException
641 public static void run(boolean fork
, boolean cancelable
,
642 IRunnableWithProgress runnable
) throws InvocationTargetException
,
643 InterruptedException
{
644 getProgressService().run(fork
, cancelable
, runnable
);
652 * @return a {@link org.eclipse.ui.progress.IProgressService} object.
654 public static IProgressService
getProgressService() {
655 IWorkbench workbench
= PlatformUI
.getWorkbench();
656 return workbench
.getProgressService();
661 * getProgressService2
664 * @return a {@link org.eclipse.ui.progress.IWorkbenchSiteProgressService}
667 public static IWorkbenchSiteProgressService
getProgressService2() {
668 return (IWorkbenchSiteProgressService
) getService(IWorkbenchSiteProgressService
.class);
676 * @return a {@link java.lang.String} object.
678 public static String
getPluginId() {
679 return "eu.taxeditor";
687 * @return a {@link org.eclipse.ui.IEditorPart} object.
689 public static IEditorPart
getActiveEditor() {
690 return getActivePage() != null ?
getActivePage().getActiveEditor()
699 * @return a {@link eu.etaxonomy.taxeditor.view.detail.DetailsViewPart}
702 public static DetailsViewPart
getDetailsView() {
703 return (DetailsViewPart
) getView(DetailsViewPart
.ID
, false);
708 * refreshDetailsViewer
711 public static void refreshDetailsViewer() {
712 if (getDetailsView() != null) {
713 ((AbstractCdmDataViewer
) getDetailsView().getViewer()).refresh();
719 * reflowDetailsViewer
722 public static void reflowDetailsViewer() {
723 if (getDetailsView() != null) {
724 ((AbstractCdmDataViewer
) getDetailsView().getViewer()).reflow();
728 public static SupplementalDataViewPart
getSupplementalDataView() {
729 return (SupplementalDataViewPart
) getView(SupplementalDataViewPart
.ID
,
733 public static void reflowSupplementalViewer() {
734 if (getSupplementalDataView() != null) {
735 ((AbstractCdmDataViewer
) getSupplementalDataView().getViewer())
742 * Orders a Collection of {@link IEnumTerm}s according to the term
745 * The returned map will be be ordered primarily by root elements,
746 * secondarily by the child elements and their children resp., both ascending alphabetically. <br>
748 * A {@link Collection} of {@link IEnumTerm}s for which the term
749 * hierarchy should be created
750 * @return a map which holds the terms as keys and their string
751 * representation via {@link IEnumTerm#getMessage()} as values
753 public static <T
extends IEnumTerm
<T
>> LinkedHashMap
<T
, String
> orderTerms(Collection
<T
> terms
) {
754 TreeSet
<TermNode
<T
>> parentElements
= new TreeSet
<TermNode
<T
>>();
755 parentElements
.addAll(getTermHierarchy(terms
));
757 // create list according to the type hierarchy (root elements alphabetically with recursive children also alphabetically)
758 LinkedHashMap
<T
, String
> result
= new LinkedHashMap
<T
, String
>();
759 parseTermTree(parentElements
, result
, -1);
763 private static<T
extends IEnumTerm
<T
>> void parseTermTree(Collection
<TermNode
<T
>> children
, LinkedHashMap
<T
, String
> result
, int depth
){
765 for(TermNode
<T
> node
:children
){
766 String indentString
= "";
767 for(int i
=0;i
<depth
;i
++){
771 indentString
+= "- ";
773 result
.put(node
.term
, indentString
+ node
.term
.getMessage());
774 parseTermTree(node
.children
, result
, depth
);
778 private static<T
extends IEnumTerm
<T
>> void addToParents(List
<TermNode
<T
>> parents
, Collection
<T
> terms
){
779 List
<TermNode
<T
>> hasChildrenList
= new ArrayList
<TermNode
<T
>>();
781 // only terms with parents
782 if(term
.getKindOf()!=null){
783 TermNode
<T
> parentNode
= new TermNode
<T
>(term
.getKindOf());
784 TermNode
<T
> childNode
= new TermNode
<T
>(term
);
785 if(parents
.contains(parentNode
)){
786 // parent found in parent list -> add this term to parent's child list
787 parents
.get(parents
.indexOf(parentNode
)).addChild(childNode
);
788 if(!term
.getGeneralizationOf().isEmpty()){
789 // has more children -> add to list which will be the parent for the next recursion
790 hasChildrenList
.add(childNode
);
795 if(!hasChildrenList
.isEmpty()){
796 addToParents(hasChildrenList
, terms
);
800 private static<T
extends IEnumTerm
<T
>> List
<TermNode
<T
>> getTermHierarchy(Collection
<T
> terms
){
801 List
<TermNode
<T
>> parents
= new ArrayList
<TermNode
<T
>>();
804 T parentTerm
= term
.getKindOf();
805 if(parentTerm
==null){
807 parents
.add(new TermNode
<T
>(term
));
810 addToParents(parents
, terms
);
814 @SuppressWarnings("unchecked")
816 * Recursively iterates over all term parents until no more parent is found i.e. the root node
817 * @param term The term for which the parent should be found
818 * @return the root terms of the term hierarchy
820 private static<T
extends IEnumTerm
<T
>> T
getParentFor(T term
){
821 // PP: cast should be safe. Why is Eclipse complaining??
822 T parent
= term
.getKindOf();
827 return getParentFor(term
.getKindOf());
831 private static class TermNode
<T
extends IEnumTerm
<T
>> implements Comparable
<TermNode
<T
>>{
832 private final T term
;
833 private final TreeSet
<TermNode
<T
>> children
;
839 public TermNode(T term
) {
842 this.children
= new TreeSet
<TermNode
<T
>>();
845 public void addChild(TermNode
<T
> child
){
846 this.children
.add(child
);
850 * @return the children
852 public TreeSet
<TermNode
<T
>> getChildren() {
864 * @see java.lang.Object#hashCode()
867 public int hashCode() {
868 final int prime
= 31;
870 result
= prime
* result
+ ((term
== null) ?
0 : term
.hashCode());
875 * @see java.lang.Object#equals(java.lang.Object)
878 public boolean equals(Object obj
) {
885 if (getClass() != obj
.getClass()) {
888 TermNode other
= (TermNode
) obj
;
890 if (other
.term
!= null) {
893 } else if (!term
.equals(other
.term
)) {
900 * @see java.lang.Comparable#compareTo(java.lang.Object)
903 public int compareTo(TermNode
<T
> that
) {
904 return this.term
.getMessage().compareTo(that
.term
.getMessage());
909 public static void executeCommand(String commandId
, Object source
, String pluginId
) {
910 IHandlerService handlerService
= (IHandlerService
) AbstractUtility
.getService(IHandlerService
.class);
911 Exception exception
= null;
913 handlerService
.executeCommand(commandId
, null);
914 } catch (ExecutionException e
) {
916 } catch (NotDefinedException e
) {
918 } catch (NotEnabledException e
) {
920 } catch (NotHandledException e
) {
923 if(exception
!= null) {
924 MessagingUtils
.errorDialog("Error executing command",
926 "Could not execute command with id " + commandId
,