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
22 package org.efaps.admin.ui.field;
23
24 import java.util.UUID;
25
26 import org.efaps.admin.ui.Command;
27 import org.efaps.ci.CIAdminUserInterface;
28 import org.efaps.util.EFapsException;
29 import org.efaps.util.cache.CacheReloadException;
30
31
32 /**
33 * TODO comment!
34 *
35 * @author The eFaps Team
36 * @version $Id$
37 */
38 public class FieldPicker
39 extends Field
40 {
41 /**
42 * Needed for serialization.
43 */
44 private static final long serialVersionUID = 1L;
45
46 /**
47 * ID of the Command to be executed on the picker field.
48 */
49 private long commandID;
50
51 /**
52 * @param _id id of the field
53 * @param _uuid UUID of the field
54 * @param _name name of the field
55 */
56 public FieldPicker(final long _id,
57 final String _uuid,
58 final String _name)
59 {
60 super(_id, _uuid, _name);
61 }
62
63 /**
64 * Getter method for the instance variable {@link #command}.
65 *
66 * @return value of instance variable {@link #command}
67 * @throws CacheReloadException on error
68 */
69 public Command getCommand()
70 throws CacheReloadException
71 {
72 return Command.get(this.commandID);
73 }
74
75 /**
76 * {@inheritDoc}
77 */
78 @Override
79 protected void setLinkProperty(final UUID _linkTypeUUID,
80 final long _toId,
81 final UUID _toTypeUUID,
82 final String _toName)
83 throws EFapsException
84 {
85 if (_linkTypeUUID.equals(CIAdminUserInterface.LinkField2Command.uuid)) {
86 this.commandID = _toId;
87 }
88 super.setLinkProperty(_linkTypeUUID, _toId, _toTypeUUID, _toName);
89 }
90
91 /**
92 * Returns for given parameter <i>_id</i> the instance of class
93 * {@link Field}.
94 *
95 * @param _id id to search in the cache
96 * @return instance of class {@link Field}
97 */
98 public static FieldPicker get(final long _id)
99 {
100 return (FieldPicker) Field.get(_id);
101 }
102 }