1   /*
2    * Copyright 2002-2004 the original author or authors.
3    * 
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not
5    * use this file except in compliance with the License. You may obtain a copy of
6    * the License at
7    * 
8    * http://www.apache.org/licenses/LICENSE-2.0
9    * 
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12   * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13   * License for the specific language governing permissions and limitations under
14   * the License.
15   */
16  package org.springframework.richclient.command.support;
17  
18  import org.springframework.richclient.command.ActionCommand;
19  
20  /**
21   * @author Peter De Bruycker
22   */
23  public class AdditionalStateTestCommand extends ActionCommand {
24  
25      private boolean myenabledState = true;
26      
27      private boolean myvisibleState = true;
28  
29      public AdditionalStateTestCommand() {
30      }
31  
32      public AdditionalStateTestCommand(String id) {
33          super(id);
34      }
35  
36      /**
37       * @see org.springframework.richclient.command.ActionCommand#doExecuteCommand()
38       */
39      protected void doExecuteCommand() {
40      }
41  
42      public boolean isMyenabledState() {
43          return myenabledState;
44      }
45  
46      public boolean isEnabled() {
47          return super.isEnabled() && isMyenabledState();
48      }
49      
50      public void setMyenabledState(boolean myenabledState) {
51          if (hasChanged(myenabledState, isMyenabledState())) {
52              this.myenabledState = myenabledState;
53              updatedEnabledState();
54          }
55      }
56      
57      public boolean isVisible() {
58          return super.isVisible() && isMyvisibleState();
59      }
60  
61      public boolean isMyvisibleState() {
62          return myvisibleState;
63      }
64  
65      public void setMyvisibleState(boolean myvisibleState) {
66          if (hasChanged(myvisibleState, isMyvisibleState())) {
67              this.myvisibleState = myvisibleState;
68              updatedVisibleState();
69          }
70      }
71  }