BrightSide Workbench Full Report + Source Code
org.turro.elephant.impl.navigation.Navigator Class Reference
Collaboration diagram for org.turro.elephant.impl.navigation.Navigator:

Public Member Functions

 Navigator (ElContext context)
 
void initialize ()
 
boolean somethingToShow ()
 
void draw () throws IOException
 
Collection< ContextNavigatorItemcontexts () throws IOException
 
String getStart ()
 
String getEnd ()
 
String getStartBody ()
 
String getEndBody ()
 
NavigatorType getType ()
 
void setType (NavigatorType type)
 
void setTypeString (String typeStr)
 
String getCssClass ()
 
void setCssClass (String cssClass)
 
boolean isDrawDecorators ()
 
void setDrawDecorators (boolean drawDecorators)
 
int getPreloaded ()
 
void setPreloaded (int preloaded)
 
boolean isDynamicLoad ()
 
void setDynamicLoad (boolean dynamicLoad)
 
int getLevel ()
 
void setLevel (int level)
 
boolean isShowCurrent ()
 
void setShowCurrent (boolean showCurrent)
 
boolean isShowTitle ()
 
void setShowTitle (boolean showTitle)
 
void drawTabulator (int level) throws IOException
 
void drawLocation () throws IOException
 
void drawOptions (boolean decorators, int level, int preloaded, boolean current) throws IOException
 
boolean hasOptions (int level, int preloaded, boolean current) throws IOException
 
void drawTraversal (boolean title) throws IOException
 
Collection< ContextNavigatorItemcontextTabulator (int level) throws IOException
 
Collection< ContextNavigatorItemcontextLocation () throws IOException
 
Collection< ContextNavigatorItemcontextOptions (int level, int preloaded, boolean current) throws IOException
 
Collection< ContextNavigatorItemcontextTraversal () throws IOException
 

Protected Attributes

IConstructor constructor
 
ElContext context
 
SortedSet< ElContextcontexts
 
int level
 
boolean dynamicLoad
 
NavigatorType type
 
String cssClass
 

Detailed Description

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

Definition at line 36 of file Navigator.java.

Constructor & Destructor Documentation

◆ Navigator()

org.turro.elephant.impl.navigation.Navigator.Navigator ( ElContext  context)

Creates a new instance of Navigator

Parameters
context

Definition at line 48 of file Navigator.java.

Here is the call graph for this function:

Member Function Documentation

◆ contextLocation()

Collection<ContextNavigatorItem> org.turro.elephant.impl.navigation.Navigator.contextLocation ( ) throws IOException

Definition at line 425 of file Navigator.java.

425  {
426  setType(NavigatorType.LOCATION);
427  setCssClass(null);
428  initialize();
429  return contexts();
430  }
Here is the call graph for this function:

◆ contextOptions()

Collection<ContextNavigatorItem> org.turro.elephant.impl.navigation.Navigator.contextOptions ( int  level,
int  preloaded,
boolean  current 
) throws IOException

Definition at line 432 of file Navigator.java.

432  {
433  setType(NavigatorType.OPTIONS);
434  setCssClass(null);
435  setDrawDecorators(false);
436  setLevel(level);
437  setPreloaded(preloaded);
438  setShowCurrent(current);
439  initialize();
440  return contexts();
441  }
void setDrawDecorators(boolean drawDecorators)
Definition: Navigator.java:324
void setShowCurrent(boolean showCurrent)
Definition: Navigator.java:356
Here is the call graph for this function:

◆ contexts()

Collection<ContextNavigatorItem> org.turro.elephant.impl.navigation.Navigator.contexts ( ) throws IOException

Definition at line 161 of file Navigator.java.

161  {
162  ArrayList<ContextNavigatorItem> list = new ArrayList<>();
163  if(current != null) {
164  ElContext elCurrent = ElContextMap.getContext(current.getPath());
165  if(elCurrent != null) {
166  if (type == NavigatorType.LOCATION) {
167  for(ElContext ctx : elCurrent.getAncestors()) {
168  list.add(new ContextNavigatorItem(ctx, elCurrent));
169  }
170  } else if (type == NavigatorType.TRAVERSAL) {
171  int levelUsed = level - 1;
172  ElContext previous = elCurrent.getPrevious(),
173  next = elCurrent.getNext(true);
174  int currLevel = elCurrent.getLevel();
175  if (previous != null && ((levelUsed > 0 && currLevel > levelUsed) || levelUsed == 0)) {
176  list.add(new ContextNavigatorItem(previous, elCurrent));
177  } else {
178  list.add(null);
179  }
180  if (elCurrent.getParent() != null && !elCurrent.getParent().equals(previous) && ((levelUsed > 0 && currLevel > levelUsed) || levelUsed == 0)) {
181  list.add(new ContextNavigatorItem(elCurrent.getParent(), elCurrent));
182  } else {
183  list.add(null);
184  }
185  if (next != null) {
186  list.add(new ContextNavigatorItem(next, elCurrent));
187  } else {
188  list.add(null);
189  }
190  } else if (type == NavigatorType.FLOATING) {
191  for(ElContext ctx : elCurrent.getVisibleChildren()) {
192  if (ctx.canDisplay()) {
193  list.add(new ContextNavigatorItem(ctx, elCurrent));
194  }
195  }
196  } else {
197  for(ElContext ctx : ElContextMap.getContexts(elCurrent.getPath(), level)) {
198  if (ctx.canDisplay()) {
199  list.add(new ContextNavigatorItem(ctx, elCurrent));
200  }
201  }
202  }
203  }
204  }
205  return list;
206  }
Here is the call graph for this function:

◆ contextTabulator()

Collection<ContextNavigatorItem> org.turro.elephant.impl.navigation.Navigator.contextTabulator ( int  level) throws IOException

Definition at line 417 of file Navigator.java.

417  {
418  setType(NavigatorType.TABULATOR);
419  setCssClass(null);
420  setLevel(level);
421  initialize();
422  return contexts();
423  }
Here is the call graph for this function:

◆ contextTraversal()

Collection<ContextNavigatorItem> org.turro.elephant.impl.navigation.Navigator.contextTraversal ( ) throws IOException

Definition at line 443 of file Navigator.java.

443  {
444  setType(NavigatorType.TRAVERSAL);
445  setCssClass(null);
446  initialize();
447  return contexts();
448  }
Here is the call graph for this function:

◆ draw()

void org.turro.elephant.impl.navigation.Navigator.draw ( ) throws IOException

Definition at line 77 of file Navigator.java.

77  {
78  if (!contexts.isEmpty()) {
79  PrintWriter out = constructor.getOut();
80  out.print(getStart());
81  if (type == NavigatorType.LOCATION) {
82  ElContext[] ancestor = current.getAncestors().toArray(new ElContext[0]);
83  for (ElContext ancestor1 : ancestor) {
84  out.print("<a href='" + ancestor1.getWebPath() + "'>" + ancestor1.getName() + "</a>");
85  }
86  // TODO: provide aditional entries comming from elements, JavaScript?
87  out.print("<span id='ext_location'></span>");
88 // if (dynamicLoad) {
89 // constructor.addOnLoadedJavaScript("$$('.location a').each(function(node) { prepareNavigator('" + constructor.getRootWebPath() + "', node, 0); });");
90 // }
91  } else if (type == NavigatorType.TRAVERSAL) {
92  int levelUsed = level - 1;
93  ElContext previous = getPrevious(current),
94  next = getNext(current, true);
95  int currLevel = current.getLevel();
96  out.print("<table width='100%'><tr><td width='35%' align='left'>");
97  if (previous != null && ((levelUsed > 0 && currLevel > levelUsed) || levelUsed == 0)) {
98  out.print("<span id='trav-previous'><a href='" + previous.getWebPath() + "'>" + previous.getName() + "</a></span>");
99  }
100  out.print("</td><td width='30%' align='center'>");
101  if (current.getParent() != null && !current.getParent().equals(previous) && ((levelUsed > 0 && currLevel > levelUsed) || levelUsed == 0)) {
102  out.print("<span id='trav-parent'><a href='" + current.getParent().getWebPath() + "'>" + current.getParent().getName() + "</a></span>");
103  }
104  out.print("</td><td width='35%' align='right'>");
105  if (next != null) {
106  out.print("<span id='trav-next'><a href='" + next.getWebPath() + "'>" + next.getName() + "</a></span>");
107  }
108  out.print("</td></tr></table>");
109  if (showTitle) {
110  out.print("<div class='context-title'>" + current.getName() + "</div>");
111  }
112 // if (dynamicLoad) {
113 // constructor.addOnLoadedJavaScript("$$('.traversal a').each(function(node) { prepareNavigator('" + constructor.getRootWebPath() + "', node, 0); });");
114 // }
115  } else if (type == NavigatorType.FLOATING) {
116  if (drawDecorators && type != NavigatorType.TABULATOR) {
117  out.print("<div class='" + cssClass + "_top'><div></div></div>");
118  }
119  out.print(getStartBody());
120  for (ElContext ctx : contexts) {
121  if (ctx.canDisplay()) {
122  renderContext(out, ctx, current);
123  doChildren(out, ctx, current, preloaded);
124  out.print("</li>");
125  }
126  }
127  out.print(getEndBody());
128  if (drawDecorators && type != NavigatorType.TABULATOR) {
129  out.print("<div class='" + cssClass + "_bottom'><div></div></div>");
130  }
131  } else {
132  String offsetLeft = "0";
133  if (drawDecorators && type != NavigatorType.TABULATOR) {
134  out.print("<div class='" + cssClass + "_top'><div></div></div>");
135  }
136  out.print(getStartBody());
137  for (ElContext ctx : contexts) {
138  if (ctx.canDisplay()) {
139  renderContext(out, ctx, current);
140  doChildren(out, ctx, current, preloaded);
141  out.print("</li>");
142  }
143  }
144  out.print(getEndBody());
145  if (drawDecorators && type != NavigatorType.TABULATOR) {
146  out.print("<div class='" + cssClass + "_bottom'><div></div></div>");
147  offsetLeft = "100";
148  }
149  //TODO: check roles and make children also sortable
150  //constructor.addOnLoadedJavaScript("Sortable.create('id_" + cssClass +
151  // "' " + (type == NavigatorType.TABULATOR ? ",{constraint: 'horizontal'}" : "") + ")");
152  if (dynamicLoad && type == NavigatorType.TABULATOR) {
153  //constructor.addOnLoadedJavaScript("$$('." + cssClass + " a').each(function(node) { prepareNavigator('" + constructor.getRootWebPath() + "', node, " + offsetLeft + "); });");
154  constructor.addOnLoadedJavaScript("$('." + cssClass + "').find('a').each(function(index) { prepareNavigator('" + ElephantContext.getRootWebPath() + "', $(this), " + offsetLeft + "); });");
155  }
156  }
157  out.print(getEnd());
158  }
159  }
boolean equals(Object obj)
Definition: ElContext.java:621
TreeSet< ElContext > getAncestors()
Definition: ElContext.java:235
void addOnLoadedJavaScript(String script)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ drawLocation()

void org.turro.elephant.impl.navigation.Navigator.drawLocation ( ) throws IOException

Definition at line 376 of file Navigator.java.

376  {
377  setType(NavigatorType.LOCATION);
378  setCssClass(null);
379  initialize();
380  draw();
381  }
Here is the call graph for this function:

◆ drawOptions()

void org.turro.elephant.impl.navigation.Navigator.drawOptions ( boolean  decorators,
int  level,
int  preloaded,
boolean  current 
) throws IOException

Definition at line 383 of file Navigator.java.

383  {
384  setType(NavigatorType.OPTIONS);
385  setCssClass(null);
386  setDrawDecorators(decorators);
387  setLevel(level);
388  setPreloaded(preloaded);
389  setShowCurrent(current);
390  initialize();
391  draw();
392  }
Here is the call graph for this function:

◆ drawTabulator()

void org.turro.elephant.impl.navigation.Navigator.drawTabulator ( int  level) throws IOException

Definition at line 368 of file Navigator.java.

368  {
369  setType(NavigatorType.TABULATOR);
370  setCssClass(null);
371  setLevel(level);
372  initialize();
373  draw();
374  }
Here is the call graph for this function:

◆ drawTraversal()

void org.turro.elephant.impl.navigation.Navigator.drawTraversal ( boolean  title) throws IOException

Definition at line 409 of file Navigator.java.

409  {
410  setType(NavigatorType.TRAVERSAL);
411  setCssClass(null);
412  setShowTitle(title);
413  initialize();
414  draw();
415  }
Here is the call graph for this function:

◆ getCssClass()

String org.turro.elephant.impl.navigation.Navigator.getCssClass ( )

Definition at line 312 of file Navigator.java.

312  {
313  return cssClass;
314  }

◆ getEnd()

String org.turro.elephant.impl.navigation.Navigator.getEnd ( )

Definition at line 230 of file Navigator.java.

230  {
231  return "</div>";
232  }
Here is the caller graph for this function:

◆ getEndBody()

String org.turro.elephant.impl.navigation.Navigator.getEndBody ( )

Definition at line 238 of file Navigator.java.

238  {
239  return "</ul>";
240  }
Here is the caller graph for this function:

◆ getLevel()

int org.turro.elephant.impl.navigation.Navigator.getLevel ( )

Definition at line 344 of file Navigator.java.

344  {
345  return level;
346  }

◆ getPreloaded()

int org.turro.elephant.impl.navigation.Navigator.getPreloaded ( )

Definition at line 328 of file Navigator.java.

328  {
329  return preloaded;
330  }

◆ getStart()

String org.turro.elephant.impl.navigation.Navigator.getStart ( )

Definition at line 226 of file Navigator.java.

226  {
227  return "<div class='" + cssClass + "'>";
228  }
Here is the caller graph for this function:

◆ getStartBody()

String org.turro.elephant.impl.navigation.Navigator.getStartBody ( )

Definition at line 234 of file Navigator.java.

234  {
235  return "<ul id='id_" + cssClass + "' class='" + cssClass + "'>";
236  }
Here is the caller graph for this function:

◆ getType()

NavigatorType org.turro.elephant.impl.navigation.Navigator.getType ( )

Definition at line 296 of file Navigator.java.

296  {
297  return type;
298  }

◆ hasOptions()

boolean org.turro.elephant.impl.navigation.Navigator.hasOptions ( int  level,
int  preloaded,
boolean  current 
) throws IOException

Definition at line 394 of file Navigator.java.

394  {
395  setType(NavigatorType.OPTIONS);
396  setCssClass(null);
397  setLevel(level);
398  setPreloaded(preloaded);
399  setShowCurrent(current);
400  initialize();
401  for(ElContext ctx : contexts) {
402  if (ctx.canDisplay()) {
403  return true;
404  }
405  }
406  return false; //contexts.length > 0;
407  }
Here is the call graph for this function:

◆ initialize()

void org.turro.elephant.impl.navigation.Navigator.initialize ( )

Definition at line 53 of file Navigator.java.

53  {
54  this.constructor = Application.getApplication().getConstructor();
55  this.current = constructor.getCurrentContext();
56  if(current != null) {
57  if(type == NavigatorType.FLOATING) {
58  this.contexts = new ContextAdapter(context.getChildren()).getVisible();
59  }
60  else {
61  levelUsed = level;
62  if(type == NavigatorType.TRAVERSAL) {
63  levelUsed--;
64  }
65  this.contexts = ElContextMap.getContexts(current.getPath(), levelUsed);
66  }
67  if(cssClass == null) {
68  cssClass = type.name().toLowerCase();
69  }
70  }
71  }
TreeSet< ElContext > getChildren()
Definition: ElContext.java:196
Here is the call graph for this function:
Here is the caller graph for this function:

◆ isDrawDecorators()

boolean org.turro.elephant.impl.navigation.Navigator.isDrawDecorators ( )

Definition at line 320 of file Navigator.java.

320  {
321  return drawDecorators;
322  }

◆ isDynamicLoad()

boolean org.turro.elephant.impl.navigation.Navigator.isDynamicLoad ( )

Definition at line 336 of file Navigator.java.

336  {
337  return dynamicLoad;
338  }

◆ isShowCurrent()

boolean org.turro.elephant.impl.navigation.Navigator.isShowCurrent ( )

Definition at line 352 of file Navigator.java.

352  {
353  return showCurrent;
354  }

◆ isShowTitle()

boolean org.turro.elephant.impl.navigation.Navigator.isShowTitle ( )

Definition at line 360 of file Navigator.java.

360  {
361  return showTitle;
362  }

◆ setCssClass()

void org.turro.elephant.impl.navigation.Navigator.setCssClass ( String  cssClass)

Definition at line 316 of file Navigator.java.

316  {
317  this.cssClass = cssClass;
318  }
Here is the caller graph for this function:

◆ setDrawDecorators()

void org.turro.elephant.impl.navigation.Navigator.setDrawDecorators ( boolean  drawDecorators)

Definition at line 324 of file Navigator.java.

324  {
325  this.drawDecorators = drawDecorators;
326  }
Here is the caller graph for this function:

◆ setDynamicLoad()

void org.turro.elephant.impl.navigation.Navigator.setDynamicLoad ( boolean  dynamicLoad)

Definition at line 340 of file Navigator.java.

340  {
341  this.dynamicLoad = dynamicLoad;
342  }
Here is the caller graph for this function:

◆ setLevel()

void org.turro.elephant.impl.navigation.Navigator.setLevel ( int  level)

Definition at line 348 of file Navigator.java.

348  {
349  this.level = level;
350  }
Here is the caller graph for this function:

◆ setPreloaded()

void org.turro.elephant.impl.navigation.Navigator.setPreloaded ( int  preloaded)

Definition at line 332 of file Navigator.java.

332  {
333  this.preloaded = preloaded;
334  }
Here is the caller graph for this function:

◆ setShowCurrent()

void org.turro.elephant.impl.navigation.Navigator.setShowCurrent ( boolean  showCurrent)

Definition at line 356 of file Navigator.java.

356  {
357  this.showCurrent = showCurrent;
358  }
Here is the caller graph for this function:

◆ setShowTitle()

void org.turro.elephant.impl.navigation.Navigator.setShowTitle ( boolean  showTitle)

Definition at line 364 of file Navigator.java.

364  {
365  this.showTitle = showTitle;
366  }
Here is the caller graph for this function:

◆ setType()

void org.turro.elephant.impl.navigation.Navigator.setType ( NavigatorType  type)

Definition at line 300 of file Navigator.java.

300  {
301  this.type = type;
302  }
Here is the caller graph for this function:

◆ setTypeString()

void org.turro.elephant.impl.navigation.Navigator.setTypeString ( String  typeStr)

Definition at line 304 of file Navigator.java.

304  {
305  for (NavigatorType nt : NavigatorType.values()) {
306  if (nt.name().toLowerCase().equals(typeStr.toLowerCase())) {
307  this.type = nt;
308  }
309  }
310  }

◆ somethingToShow()

boolean org.turro.elephant.impl.navigation.Navigator.somethingToShow ( )

Definition at line 73 of file Navigator.java.

73  {
74  return (contexts != null) && (!contexts.isEmpty());
75  }

Member Data Documentation

◆ constructor

IConstructor org.turro.elephant.impl.navigation.Navigator.constructor
protected

Definition at line 38 of file Navigator.java.

◆ context

ElContext org.turro.elephant.impl.navigation.Navigator.context
protected

Definition at line 39 of file Navigator.java.

◆ contexts

SortedSet<ElContext> org.turro.elephant.impl.navigation.Navigator.contexts
protected

Definition at line 40 of file Navigator.java.

◆ cssClass

String org.turro.elephant.impl.navigation.Navigator.cssClass
protected

Definition at line 44 of file Navigator.java.

◆ dynamicLoad

boolean org.turro.elephant.impl.navigation.Navigator.dynamicLoad
protected

Definition at line 42 of file Navigator.java.

◆ level

int org.turro.elephant.impl.navigation.Navigator.level
protected

Definition at line 41 of file Navigator.java.

◆ type

NavigatorType org.turro.elephant.impl.navigation.Navigator.type
protected

Definition at line 43 of file Navigator.java.


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