View Javadoc

1   /*
2      Copyright 2002-2006 Martin van den Bemt
3   
4      Licensed under the Apache License, Version 2.0 (the "License");
5      you may not use this file except in compliance with the License.
6      You may obtain a copy of 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,
12     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13     See the License for the specific language governing permissions and
14     limitations under the License.
15  */
16  package org.xulux.guilayer.swing.rules;
17  
18  import org.xulux.api.core.PartRequest;
19  import org.xulux.guilayer.swing.widgets.Table;
20  import org.xulux.rules.Rule;
21  
22  /**
23   * This is the rule for processing tables.
24   * The rule is to stop editing after someone hits the save button..
25   * Else the edited data will get lost..
26   *
27   * @author <a href="mailto:martin@mvdb.net">Martin van den Bemt</a>
28   * @version $Id: DefaultTableRule.java,v 1.1 2005/12/18 12:58:23 mvdb Exp $
29   */
30  public class DefaultTableRule extends Rule {
31  
32      /**
33       *
34       */
35      public DefaultTableRule() {
36          super();
37      }
38  
39      /**
40       * @see org.xulux.api.rules.IRule#pre(org.xulux.api.core.PartRequest)
41       */
42      public void pre(PartRequest request) {
43  
44          String action = request.getWidget().getProperty("defaultaction");
45          if (action != null && action.equalsIgnoreCase("save")) {
46              // get the owner of this rule..
47              Table table = (Table) getOwner();
48              table.stopEditing();
49          }
50      }
51  
52      /**
53       * @see org.xulux.api.rules.IRule#post(org.xulux.api.core.PartRequest)
54       */
55      public void post(PartRequest request) {
56      }
57  
58  }