comparison 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
comparison
equal deleted inserted replaced
69:07b9d96fd764 70:46a6e0e6ccd4
1 /******************************************************************************* 1 /*******************************************************************************
2 * Copyright (c) 2004, 2007 IBM Corporation and others. 2 * Copyright (c) 2004, 2008 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials 3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0 4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at 5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html 6 * http://www.eclipse.org/legal/epl-v10.html
7 * 7 *
497 throw exception; 497 throw exception;
498 } 498 }
499 499
500 // Perform the execution, if there is a handler. 500 // Perform the execution, if there is a handler.
501 if ((handler !is null) && (handler.isHandled())) { 501 if ((handler !is null) && (handler.isHandled())) {
502 setEnabled(event.getApplicationContext());
502 if (!isEnabled()) { 503 if (!isEnabled()) {
503 NotEnabledException exception = new NotEnabledException( 504 NotEnabledException exception = new NotEnabledException(
504 "Trying to execute the disabled command " ~ getId()); //$NON-NLS-1$ 505 "Trying to execute the disabled command " ~ getId()); //$NON-NLS-1$
505 fireNotEnabled(exception); 506 fireNotEnabled(exception);
506 throw exception; 507 throw exception;
733 } 734 }
734 735
735 /** 736 /**
736 * Returns the help context identifier associated with this command. This 737 * Returns the help context identifier associated with this command. This
737 * method should not be called by clients. Clients should use 738 * method should not be called by clients. Clients should use
738 * {@link CommandManager#getHelpContextId(String)} instead. 739 * {@link CommandManager#getHelpContextId(Command)} instead.
739 * 740 *
740 * @return The help context identifier for this command; may be 741 * @return The help context identifier for this command; may be
741 * <code>null</code> if there is none. 742 * <code>null</code> if there is none.
742 * @since 3.2 743 * @since 3.2
743 */ 744 */
859 if (handler is null) { 860 if (handler is null) {
860 return false; 861 return false;
861 } 862 }
862 863
863 return handler.isEnabled(); 864 return handler.isEnabled();
865 }
866
867 /**
868 * Called be the framework to allow the handler to update its enabled state.
869 *
870 * @param evaluationContext
871 * the state to evaluate against. May be <code>null</code>
872 * which indicates that the handler can query whatever model that
873 * is necessary. This context must not be cached.
874 * @since 3.4
875 */
876 public void setEnabled(Object evaluationContext) {
877 if (handler instanceof IHandler2) {
878 ((IHandler2) handler).setEnabled(evaluationContext);
879 }
864 } 880 }
865 881
866 /** 882 /**
867 * Returns whether this command has a handler, and whether this handler is 883 * Returns whether this command has a handler, and whether this handler is
868 * also handled. 884 * also handled.
1002 1018
1003 return true; 1019 return true;
1004 } 1020 }
1005 1021
1006 /** 1022 /**
1007 * @return 1023 * @return the handler listener
1008 */ 1024 */
1009 private IHandlerListener getHandlerListener() { 1025 private IHandlerListener getHandlerListener() {
1010 if (handlerListener is null) { 1026 if (handlerListener is null) {
1011 handlerListener = new class IHandlerListener { 1027 handlerListener = new class IHandlerListener {
1012 public void handlerChanged(HandlerEvent handlerEvent) { 1028 public void handlerChanged(HandlerEvent handlerEvent) {