BrightSide Workbench Full Report + Source Code
org.turro.parser.NavigationParser Class Reference
Inheritance diagram for org.turro.parser.NavigationParser:
Collaboration diagram for org.turro.parser.NavigationParser:

Public Member Functions

String getParserName ()
 
- Public Member Functions inherited from org.turro.parser.AbstractParser
 AbstractParser ()
 
ParserMacroSet getParserMacros ()
 
boolean execute (IConstructor constructor, PrintWriter out, String[] tokens)
 

Static Public Member Functions

static String escapeGrouping (String sequence)
 

Protected Member Functions

boolean doExecute ()
 
void explainMacros (ParserMacroSet macros)
 
- Protected Member Functions inherited from org.turro.parser.AbstractParser
String getMacroName ()
 
String getToken (String name)
 
String getToken (String name, boolean defParameter)
 
String getToken (String name, String def)
 
String getToken (int index)
 
String getToken (int index, boolean defParameter)
 
String getToken (int index, String def)
 
int getTokenSize ()
 
String getDefaultFor (int index)
 
void prepareProperties (ElephantMarker marker, String properties)
 

Additional Inherited Members

- Protected Attributes inherited from org.turro.parser.AbstractParser
IConstructor constructor
 
String[] tokens
 
PrintWriter out
 
String parserName
 
ParserMacroSet parserMacros = new ParserMacroSet()
 

Detailed Description

Author
Lluis TurrĂ³ Cutiller lluis.nosp@m.@tur.nosp@m.ro.or.nosp@m.g

Definition at line 44 of file NavigationParser.java.

Member Function Documentation

◆ doExecute()

boolean org.turro.parser.NavigationParser.doExecute ( )
protected

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 52 of file NavigationParser.java.

52  {
53  boolean done = false;
54  if("list".equals(getMacroName()) || "anchor".equals(getMacroName())) {
55  int currToken = 1;
56  boolean verbosePath = false;
57  boolean hidden = false;
58  boolean external = false;
59  ElContext root = ElContextMap.getContext(constructor.getRenderingContext().getPath());
60  List<ElContext> result = null;
61  String clickAction = "", cssClass = "";
62  while(currToken < tokens.length && root != null) {
63  if("popup".equals(tokens[currToken])) {
64  clickAction = "popupElement('" + ElephantContext.getRootWebPath() + "', $(this)); return false;";
65  cssClass = "popup";
66  }
67  else if("verbose".equals(tokens[currToken])) {
68  verbosePath = true;
69  }
70  else if("hidden".equals(tokens[currToken])) {
71  hidden = true;
72  }
73  else if("external".equals(tokens[currToken])) {
74  external = true;
75  }
76  else if("parent".equals(tokens[currToken])) {
77  root = root.getParent();
78  }
79  else if("root".equals(tokens[currToken])) {
80  root = ElContextMap.getContext("/");
81  }
82  else if("locate".equals(tokens[currToken])) {
83  if(tokens.length > currToken + 1) {
84  root = ElContextMap.getContext(tokens[currToken + 1].replace("*", constructor.getRenderingContext().getPath()));
85  currToken++;
86  }
87  }
88  else if("match".equals(tokens[currToken])) {
89  if(tokens.length > currToken + 1) {
90  root = getSingleContextFrom(root, tokens[currToken + 1]);
91  currToken++;
92  }
93  }
94  else if("level".equals(tokens[currToken])) {
95  if(tokens.length > currToken + 1) {
96  root = getLevelContextFrom(root, tokens[currToken + 1]);
97  currToken++;
98  }
99  }
100  else if("children".equals(tokens[currToken])) {
101  result = new ArrayList(root.getChildren());
102  break;
103  }
104  else if("all".equals(tokens[currToken])) {
105  result = getAllFrom(root, false);
106  break;
107  }
108  else if("leaf".equals(tokens[currToken])) {
109  result = getAllFrom(root, true);
110  break;
111  }
112  else if("ancestors".equals(tokens[currToken])) {
113  result = new ArrayList(root.getAncestors());
114  break;
115  }
116  else if("siblings".equals(tokens[currToken])) {
117  result = new ArrayList(root.getSiblings());
118  break;
119  }
120  else if("search".equals(tokens[currToken])) {
121  if(tokens.length > currToken + 1) {
122  result = getContextsFrom(root, tokens[currToken + 1]);
123  break;
124  }
125  }
126  else if("self".equals(tokens[currToken])) {
127  result = new ArrayList<>();
128  result.add(root);
129  break;
130  }
131  currToken++;
132  }
133  HTMLHelper hh = new HTMLHelper(out);
134  boolean list = "list".equals(tokens[0]);
135  if(result != null && !result.isEmpty()) {
136  if(list) {
137  hh.startTag("ul", "class='m_list'");
138  } else if(result.size() > 1) {
139  hh.write("[ ");
140  }
141  for(ElContext ctx : result) {
142  if(hidden || ctx.canDisplay()) {
143  if(list) {
144  hh.startTag("li");
145  }
146  if(external) {
147  hh.startExtAnchor(ctx.getWebPath(), null);
148  } else {
149  if(Strings.isBlank(ctx.getTarget()) || !Strings.isBlank(clickAction)) {
150  hh.startAnchor(ctx.getWebPath(), null, cssClass, clickAction);
151  } else {
152  hh.startTargetAnchor(ctx.getWebPath(), ctx.getTarget(), null);
153  }
154  }
155  if(verbosePath) {
156  hh.write(ctx.getVerbosePath(root));
157  } else {
158  hh.write(ctx.getName());
159  }
160  hh.endTag();
161  if(list) {
162  hh.endTag();
163  } else if(result.lastIndexOf(ctx) < result.size() - 1) {
164  hh.write(", ");
165  }
166  }
167  }
168  if(!list && result.size() > 1) {
169  hh.write(" ]");
170  }
171  hh.endAllTags();
172  } else {
173  hh.startTag((list ? "div" : "span"), "class='m_error'");
174  hh.write(getMacroName());
175  hh.endTag();
176  }
177  done = true;
178  } else if("navigator".equals(getMacroName())) {
179  ElContext root = constructor.getRenderingContext();
180  Navigator navigator = new Navigator(root);
181  navigator.setDynamicLoad("dynamic".equals(ElephantContext.getContextLoad()));
182  if("location".equals(getToken(1))) {
183  try {
184  navigator.setType(NavigatorType.LOCATION);
185  navigator.initialize();
186  navigator.draw();
187  } catch (IOException ex) {
188  Logger.getLogger(NavigationParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
189  }
190  } else if("traversal".equals(getToken(1))) {
191  try {
192  navigator.setType(NavigatorType.TRAVERSAL);
193  navigator.setShowTitle((Boolean) ObjectString.parseNativeString(getToken(2), Boolean.class, true));
194  navigator.initialize();
195  navigator.draw();
196  } catch (IOException ex) {
197  Logger.getLogger(NavigationParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
198  }
199  } else if("options".equals(getToken(1))) {
200  navigator.setType(NavigatorType.OPTIONS);
201  navigator.setDrawDecorators((Boolean) ObjectString.parseNativeString(getToken(2), Boolean.class, true));
202  navigator.setLevel((Integer) ObjectString.parseNativeString(getToken(3), Integer.class, true));
203  navigator.setPreloaded((Integer) ObjectString.parseNativeString(getToken(4), Integer.class, true));
204  navigator.setShowCurrent((Boolean) ObjectString.parseNativeString(getToken(5), Boolean.class, true));
205  navigator.initialize();
206  try {
207  navigator.draw();
208  } catch (IOException ex) {
209  Logger.getLogger(NavigationParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
210  }
211  } else if("tabulator".equals(getToken(1))) {
212  try {
213  navigator.setType(NavigatorType.TABULATOR);
214  navigator.setLevel((Integer) ObjectString.parseNativeString(getToken(2), Integer.class, true));
215  navigator.initialize();
216  navigator.draw();
217  } catch (IOException ex) {
218  Logger.getLogger(NavigationParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
219  }
220  }
221  done = true;
222  } else if("webmap".equals(getMacroName())) {
223  WebMap wm = new WebMap(constructor);
224  try {
225  wm.draw((Integer) ObjectString.parseNativeString(getToken(1), Integer.class, true));
226  } catch (IOException ex) {
227  Logger.getLogger(CoreParser.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
228  }
229  done = true;
230  }
231  return done;
232  }
Here is the call graph for this function:

◆ escapeGrouping()

static String org.turro.parser.NavigationParser.escapeGrouping ( String  sequence)
static

Definition at line 334 of file NavigationParser.java.

334  {
335  if(sequence == null || !sequence.contains("$")) return sequence;
336  StringBuilder sb = new StringBuilder(sequence);
337  int start = 0, p;
338  while((p = sb.indexOf("$", start)) > -1) {
339  sb.insert(p, '\\');
340  start = p + 2;
341  }
342  return sb.toString();
343  }

◆ explainMacros()

void org.turro.parser.NavigationParser.explainMacros ( ParserMacroSet  macros)
protected

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 235 of file NavigationParser.java.

235  {
236  macros.addMacro("navigator")
237  .addParameter("location", false);
238  macros.addMacro("navigator")
239  .addParameter("traversal", false)
240  .addParameter("show-title", true, "false");
241  macros.addMacro("navigator")
242  .addParameter("options", false)
243  .addParameter("decorators", false)
244  .addParameter("level", false)
245  .addParameter("preloaded", false)
246  .addParameter("show-current", true, "true");
247  macros.addMacro("navigator")
248  .addParameter("tabulator", false)
249  .addParameter("level", false);
250  macros.addMacro("webmap")
251  .addParameter("level", true, "1");
252  macros.addMacro("list")
253  .addParameter("behavioural_keywords", false, null, true)
254  .addPossibleValue("verbose")
255  .addPossibleValue("popup")
256  .addPossibleValue("hidden")
257  .addPossibleValue("external")
258  .addParameter("navigational_keywords", false, null, true)
259  .addPossibleValue("parent")
260  .addPossibleValue("root")
261  .addPossibleValue("level")
262  .addPossibleValue("locate")
263  .addPossibleValue("match")
264  .addParameter("selection_keywords", false, null, true)
265  .addPossibleValue("self")
266  .addPossibleValue("children")
267  .addPossibleValue("all")
268  .addPossibleValue("leaf")
269  .addPossibleValue("ancestors")
270  .addPossibleValue("siblings")
271  .addPossibleValue("search");
272  macros.addMacro("anchor")
273  .copyParametersFrom("list", macros);
274  }
Here is the call graph for this function:

◆ getParserName()

String org.turro.parser.NavigationParser.getParserName ( )

Reimplemented from org.turro.parser.AbstractParser.

Definition at line 47 of file NavigationParser.java.

47  {
48  return "Navigation";
49  }

The documentation for this class was generated from the following file: