1   /*
2    * Copyright 2003 - 2013 The eFaps Team
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   * Revision:        $Rev$
17   * Last Changed:    $Date$
18   * Last Changed By: $Author$
19   */
20  
21  package org.efaps.admin.ui.field;
22  
23  import java.util.UUID;
24  
25  import org.efaps.admin.ui.Table;
26  import org.efaps.ci.CIAdminUserInterface;
27  import org.efaps.util.EFapsException;
28  import org.efaps.util.cache.CacheReloadException;
29  
30  /**
31   * @author The eFaps Team
32   * @version $Id$
33   */
34  public class FieldTable
35      extends Field
36  {
37      /**
38       * Needed for serialization.
39       */
40      private static final long serialVersionUID = 1L;
41  
42      /**
43       * The instance variable stores the target user interface table object which
44       * is shown by the this field.
45       */
46      private long targetTableID = 0;
47  
48      /**
49       * Name of the field the StructurBrowser is bedded into the target.
50       */
51      private String targetStructurBrowserField;
52  
53      /**
54       * Standard checkboxes for a table must be shown. The checkboxes are used
55       * e.g. to delete selected.
56       *
57       * @see #isTargetShowCheckBoxes
58       * @see #setTargetShowCheckBoxes
59       */
60      private boolean targetShowCheckBoxes = false;
61  
62      /**
63       * Is the StructurBrowser Forced to be Expanded.
64       */
65      private boolean targetStructurBrowserForceExpand = false;
66  
67      /**
68       * Constructor.
69       *
70       * @param _id id of this FieldTable
71       * @param _uuid uuid of this FieldTable
72       * @param _name name of this FieldTable
73       */
74      public FieldTable(final long _id,
75                        final String _uuid,
76                        final String _name)
77      {
78          super(_id, _uuid, _name);
79      }
80  
81      /**
82       * {@inheritDoc}
83       */
84      @Override
85      protected void setLinkProperty(final UUID _linkTypeUUID,
86                                     final long _toId,
87                                     final UUID _toTypeUUID,
88                                     final String _toName)
89          throws EFapsException
90      {
91          if (_linkTypeUUID.equals(CIAdminUserInterface.LinkTargetTable.uuid)) {
92              this.targetTableID = _toId;
93          }
94          super.setLinkProperty(_linkTypeUUID, _toId, _toTypeUUID, _toName);
95      }
96  
97      /**
98       * {@inheritDoc}
99       */
100     @Override
101     protected void setProperty(final String _name,
102                                final String _value)
103         throws CacheReloadException
104     {
105         if ("TargetStructurBrowserField".equals(_name)) {
106             this.targetStructurBrowserField = _value;
107         } else if ("TargetShowCheckBoxes".equals(_name)) {
108             this.targetShowCheckBoxes = "true".equalsIgnoreCase(_value);
109         } else if ("TargetStructurBrowserForceExpand".equals(_name)) {
110             this.targetStructurBrowserForceExpand = "true".equalsIgnoreCase(_value);
111         } else {
112             super.setProperty(_name, _value);
113         }
114     }
115 
116     /**
117      * Returns for given parameter <i>_id</i> the instance of class
118      * {@link Field}.
119      *
120      * @param _id id to search in the cache
121      * @return instance of class {@link Field}
122      */
123     public static FieldTable get(final long _id)
124     {
125         return (FieldTable) Field.get(_id);
126     }
127 
128     /**
129      * This is the getter method for the instance variable {@link #targetTable}.
130      *
131      * @return value of instance variable {@link #targetTable}
132      * @throws CacheReloadException on error
133      */
134     public Table getTargetTable()
135         throws CacheReloadException
136     {
137         return Table.get(this.targetTableID);
138     }
139 
140     /**
141      * Getter method for the instance variable {@link #targetStructurBrowserField}.
142      *
143      * @return value of instance variable {@link #targetStructurBrowserField}
144      */
145     public String getTargetStructurBrowserField()
146     {
147         return this.targetStructurBrowserField;
148     }
149 
150     /**
151      * This is the setter method for the instance variable
152      * {@link #targetShowCheckBoxes}.
153      *
154      * @return value of instance variable {@link #targetShowCheckBoxes}
155      * @see #targetShowCheckBoxes
156      * @see #setTargetShowCheckBoxes
157      */
158     public boolean isTargetShowCheckBoxes()
159     {
160         return this.targetShowCheckBoxes;
161     }
162 
163     /**
164      * Getter method for the instance variable {@link #targetStructurBrowserForceExpand}.
165      *
166      * @return value of instance variable {@link #targetStructurBrowserForceExpand}
167      */
168     public boolean isTargetStructurBrowserForceExpand()
169     {
170         return this.targetStructurBrowserForceExpand;
171     }
172 }