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.update.schema.ui;
22
23 import java.net.URL;
24 import java.util.HashSet;
25 import java.util.List;
26 import java.util.Map;
27 import java.util.Set;
28
29 import org.efaps.update.LinkInstance;
30 import org.efaps.util.EFapsException;
31
32 /**
33 * @author The eFaps Team
34 * @version $Id$
35 * TODO: description
36 */
37 public class SearchUpdate
38 extends MenuUpdate
39 {
40 /** Link from search to default search command. */
41 private static final Link LINK2DEFAULTCMD = new UniqueLink("Admin_UI_LinkDefaultSearchCommand", "From",
42 "Admin_UI_Command", "To");
43
44 /**
45 * All known links for the search schema update.
46 */
47 private static final Set<Link> ALLLINKS = new HashSet<Link>();
48 static {
49 SearchUpdate.ALLLINKS.add(SearchUpdate.LINK2DEFAULTCMD);
50 SearchUpdate.ALLLINKS.addAll(MenuUpdate.ALLLINKS);
51 }
52
53 /**
54 *
55 * @param _url URL of the file
56 */
57 public SearchUpdate(final URL _url)
58 {
59 super(_url, "Admin_UI_Search", SearchUpdate.ALLLINKS);
60 }
61
62 /**
63 * Creates new instance of class {@link SearchDefinition}.
64 *
65 * @return new definition instance
66 * @see SearchDefinition
67 */
68 @Override
69 protected AbstractDefinition newDefinition()
70 {
71 return new SearchDefinition();
72 }
73
74 /**
75 * TODO comment!
76 *
77 */
78 public class SearchDefinition
79 extends MenuDefinition
80 {
81 @Override
82 protected void readXML(final List<String> _tags,
83 final Map<String, String> _attributes,
84 final String _text)
85 throws EFapsException
86 {
87 final String value = _tags.get(0);
88 if ("default".equals(value)) {
89 if (_tags.size() > 1) {
90 final String subValue = _tags.get(1);
91 if ("command".equals(subValue)) {
92 // assigns a command as default for the search menu
93 addLink(SearchUpdate.LINK2DEFAULTCMD, new LinkInstance(_text));
94 } else {
95 super.readXML(_tags, _attributes, _text);
96 }
97 }
98 } else {
99 super.readXML(_tags, _attributes, _text);
100 }
101 }
102 }
103 }