diff dwtx/core/commands/Command.d @ 70:46a6e0e6ccd4

Merge with d-fied sources of 3.4M7
author Frank Benoit <benoit@tionex.de>
date Thu, 22 May 2008 01:36:46 +0200
parents ea8ff534f622
children 4878bef4a38e
line wrap: on
line diff
--- a/dwtx/core/commands/Command.d	Mon May 19 13:41:06 2008 +0200
+++ b/dwtx/core/commands/Command.d	Thu May 22 01:36:46 2008 +0200
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2004, 2007 IBM Corporation and others.
+ * Copyright (c) 2004, 2008 IBM Corporation and others.
  * All rights reserved. This program and the accompanying materials
  * are made available under the terms of the Eclipse Public License v1.0
  * which accompanies this distribution, and is available at
@@ -499,6 +499,7 @@
 
         // Perform the execution, if there is a handler.
         if ((handler !is null) && (handler.isHandled())) {
+            setEnabled(event.getApplicationContext());
             if (!isEnabled()) {
                 NotEnabledException exception = new NotEnabledException(
                         "Trying to execute the disabled command " ~ getId()); //$NON-NLS-1$
@@ -735,7 +736,7 @@
     /**
      * Returns the help context identifier associated with this command. This
      * method should not be called by clients. Clients should use
-     * {@link CommandManager#getHelpContextId(String)} instead.
+     * {@link CommandManager#getHelpContextId(Command)} instead.
      *
      * @return The help context identifier for this command; may be
      *         <code>null</code> if there is none.
@@ -862,6 +863,21 @@
 
         return handler.isEnabled();
     }
+    
+    /**
+     * Called be the framework to allow the handler to update its enabled state.
+     * 
+     * @param evaluationContext
+     *            the state to evaluate against. May be <code>null</code>
+     *            which indicates that the handler can query whatever model that
+     *            is necessary.  This context must not be cached.
+     * @since 3.4
+     */
+    public void setEnabled(Object evaluationContext) {
+        if (handler instanceof IHandler2) {
+            ((IHandler2) handler).setEnabled(evaluationContext);
+        }
+    }
 
     /**
      * Returns whether this command has a handler, and whether this handler is
@@ -1004,7 +1020,7 @@
     }
 
     /**
-     * @return
+     * @return the handler listener
      */
     private IHandlerListener getHandlerListener() {
         if (handlerListener is null) {