BrightSide Workbench Full Report + Source Code
org.turro.zkoss.text.WikiEditor Class Reference
Inheritance diagram for org.turro.zkoss.text.WikiEditor:
Collaboration diagram for org.turro.zkoss.text.WikiEditor:

Public Member Functions

 WikiEditor ()
 
void setValue (String value)
 
String getValue ()
 
String getHtml ()
 
void setImageFolder (String folder)
 
String getImageFolder ()
 
void setFileFolder (String folder)
 
String getFileFolder ()
 
boolean isReadonly ()
 
void setReadonly (boolean value)
 
boolean isReadOnlyRepository ()
 
void setReadOnlyRepository (boolean readOnlyRepository)
 
boolean isNoTreeRepository ()
 
void setNoTreeRepository (boolean noTreeRepository)
 
boolean isElWiki ()
 
void addResolver (IWikiResolver resolver)
 
void onCaret (Event event)
 
void onHeader1 ()
 
void onHeader2 ()
 
void onHeader3 ()
 
void onHeader4 ()
 
void onBlock ()
 
void onSpan ()
 
void onNote ()
 
void onStartColumn ()
 
void onEndColumns ()
 
void onTabulator ()
 
void onBlind ()
 
void onBold ()
 
void onItalic ()
 
void onRegular ()
 
void onToWiki ()
 
void onPreview ()
 
void onHtml ()
 
void onStartWiki ()
 
void onStopWiki ()
 
void onStartJava ()
 
void onStopJava ()
 
void onStartXml ()
 
void onStopXml ()
 
void onAlignLeft ()
 
void onAlignCenter ()
 
void onAlignRight ()
 
void onAlignJustify ()
 
void onFloatLeft ()
 
void onFloatright ()
 
void onUlList ()
 
void onOlList ()
 
void onThl ()
 
void onThr ()
 
void onTrl ()
 
void onTrr ()
 
void onTcl ()
 
void onTcr ()
 
void onTet ()
 
void onEraser ()
 
void onColor (InputEvent event)
 
void onBackground (InputEvent event)
 
void onLink ()
 
void onImage ()
 
void onTemplate ()
 
void onSnippet ()
 
void onElWiki ()
 

Detailed Description

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

Definition at line 64 of file WikiEditor.java.

Constructor & Destructor Documentation

◆ WikiEditor()

org.turro.zkoss.text.WikiEditor.WikiEditor ( )

Definition at line 77 of file WikiEditor.java.

77  {
78  setSclass("wikiEditor");
79  Executions.createComponents("/WEB-INF/_zul/bs/comps/editor/wikiInput.zul", this, null);
80  Selectors.wireComponents(this, this, false);
81  Selectors.wireEventListeners(this, this);
82  wikibox.setWidgetListener("onClick",
83  "zAu.send(new zk.Event(this,\"onCaret\",zk(this.$n()).getSelectionRange()+\"\",{toServer:true}));");
84  wikibox.setWidgetListener("onBlur",
85  "zAu.send(new zk.Event(this,\"onCaret\",zk(this.$n()).getSelectionRange()+\"\",{toServer:true}));");
86  wikibox.setWidgetListener("onSelection",
87  "zAu.send(new zk.Event(this,\"onCaret\",zk(this.$n()).getSelectionRange()+\"\",{toServer:true}));");
88  wikibox.setWidgetListener("onChanging",
89  "zAu.send(new zk.Event(this,\"onCaret\",zk(this.$n()).getSelectionRange()+\"\",{toServer:true}));");
90  wikibox.addEventListener(Events.ON_CHANGE, new EventListener<InputEvent>() {
91  @Override
92  public void onEvent(InputEvent event) throws Exception {
93  Events.postEvent(WikiEditor.this, event);
94  }
95  });
96  }

Member Function Documentation

◆ addResolver()

void org.turro.zkoss.text.WikiEditor.addResolver ( IWikiResolver  resolver)

Definition at line 160 of file WikiEditor.java.

160  {
161  if(resolver != null) resolvers.add(resolver);
162  }
Here is the caller graph for this function:

◆ getFileFolder()

String org.turro.zkoss.text.WikiEditor.getFileFolder ( )

Definition at line 123 of file WikiEditor.java.

123  {
124  return fileFolder;
125  }
Here is the caller graph for this function:

◆ getHtml()

String org.turro.zkoss.text.WikiEditor.getHtml ( )

Definition at line 107 of file WikiEditor.java.

107  {
108  return getHtml(wikibox.getValue(), false);
109  }
Here is the caller graph for this function:

◆ getImageFolder()

String org.turro.zkoss.text.WikiEditor.getImageFolder ( )

Definition at line 115 of file WikiEditor.java.

115  {
116  return imageFolder;
117  }
Here is the caller graph for this function:

◆ getValue()

String org.turro.zkoss.text.WikiEditor.getValue ( )

Definition at line 103 of file WikiEditor.java.

103  {
104  return wikibox.getValue();
105  }
Here is the caller graph for this function:

◆ isElWiki()

boolean org.turro.zkoss.text.WikiEditor.isElWiki ( )

Definition at line 156 of file WikiEditor.java.

156  {
157  return elwiki.isCheckmark();
158  }

◆ isNoTreeRepository()

boolean org.turro.zkoss.text.WikiEditor.isNoTreeRepository ( )

Definition at line 148 of file WikiEditor.java.

148  {
149  return noTreeRepository;
150  }

◆ isReadonly()

boolean org.turro.zkoss.text.WikiEditor.isReadonly ( )

Definition at line 127 of file WikiEditor.java.

127  {
128  return wikibox.isReadonly();
129  }

◆ isReadOnlyRepository()

boolean org.turro.zkoss.text.WikiEditor.isReadOnlyRepository ( )

Definition at line 140 of file WikiEditor.java.

140  {
141  return readOnlyRepository;
142  }

◆ onAlignCenter()

void org.turro.zkoss.text.WikiEditor.onAlignCenter ( )

Definition at line 328 of file WikiEditor.java.

328  {
329  putAttribute("text-align", "center");
330  }

◆ onAlignJustify()

void org.turro.zkoss.text.WikiEditor.onAlignJustify ( )

Definition at line 338 of file WikiEditor.java.

338  {
339  putAttribute("text-align", "justify");
340  }

◆ onAlignLeft()

void org.turro.zkoss.text.WikiEditor.onAlignLeft ( )

Definition at line 323 of file WikiEditor.java.

323  {
324  putAttribute("text-align", "left");
325  }

◆ onAlignRight()

void org.turro.zkoss.text.WikiEditor.onAlignRight ( )

Definition at line 333 of file WikiEditor.java.

333  {
334  putAttribute("text-align", "right");
335  }

◆ onBackground()

void org.turro.zkoss.text.WikiEditor.onBackground ( InputEvent  event)

Definition at line 408 of file WikiEditor.java.

408  {
409  putAttribute("background-color", event.getValue());
410  }

◆ onBlind()

void org.turro.zkoss.text.WikiEditor.onBlind ( )

Definition at line 230 of file WikiEditor.java.

230  {
231  insert("\n[blind(Caption1)]\n","Content1\n[blind(Caption2)]\nContent2\n[/blind]\n");
232  }

◆ onBlock()

void org.turro.zkoss.text.WikiEditor.onBlock ( )

Definition at line 200 of file WikiEditor.java.

200  {
201  insert("\n[block]\n", "\n[/block]\n");
202  }

◆ onBold()

void org.turro.zkoss.text.WikiEditor.onBold ( )

Definition at line 235 of file WikiEditor.java.

235  {
236  WikiElement we = new WikiElement(selectionStart, selectionEnd, wikibox, WikiElement.NON_BLOCK_ELEMENTS);
237  if(selectionStart == selectionEnd && we.inside() && !we.isTag("img")) {
238  putAttribute("font-weight", "bold");
239  } else {
240  insert("**","**", true);
241  }
242  }
Here is the call graph for this function:

◆ onCaret()

void org.turro.zkoss.text.WikiEditor.onCaret ( Event  event)

Definition at line 165 of file WikiEditor.java.

165  {
166  String v[] = ((String) event.getData()).split(",");
167  selectionStart = Integer.valueOf(v[0]);
168  selectionEnd = Integer.valueOf(v[1]);
169  }

◆ onColor()

void org.turro.zkoss.text.WikiEditor.onColor ( InputEvent  event)

Definition at line 403 of file WikiEditor.java.

403  {
404  putAttribute("color", event.getValue());
405  }

◆ onElWiki()

void org.turro.zkoss.text.WikiEditor.onElWiki ( )

Definition at line 505 of file WikiEditor.java.

505  {
506  elwiki.setCheckmark(!elwiki.isCheckmark());
507  }

◆ onEndColumns()

void org.turro.zkoss.text.WikiEditor.onEndColumns ( )

Definition at line 220 of file WikiEditor.java.

220  {
221  insert("\n[/column]\n");
222  }

◆ onEraser()

void org.turro.zkoss.text.WikiEditor.onEraser ( )

Definition at line 398 of file WikiEditor.java.

398  {
399  removeAttributes();
400  }

◆ onFloatLeft()

void org.turro.zkoss.text.WikiEditor.onFloatLeft ( )

Definition at line 343 of file WikiEditor.java.

343  {
344  putAttribute("float", "left");
345  }

◆ onFloatright()

void org.turro.zkoss.text.WikiEditor.onFloatright ( )

Definition at line 348 of file WikiEditor.java.

348  {
349  putAttribute("float", "right");
350  }

◆ onHeader1()

void org.turro.zkoss.text.WikiEditor.onHeader1 ( )

Definition at line 172 of file WikiEditor.java.

172  {
173  insertOnStartLine("---+", new String[] {
174  "---++++", "---+++", "---++", "---+"
175  });
176  }

◆ onHeader2()

void org.turro.zkoss.text.WikiEditor.onHeader2 ( )

Definition at line 179 of file WikiEditor.java.

179  {
180  insertOnStartLine("---++", new String[] {
181  "---++++", "---+++", "---++", "---+"
182  });
183  }

◆ onHeader3()

void org.turro.zkoss.text.WikiEditor.onHeader3 ( )

Definition at line 186 of file WikiEditor.java.

186  {
187  insertOnStartLine("---+++", new String[] {
188  "---++++", "---+++", "---++", "---+"
189  });
190  }

◆ onHeader4()

void org.turro.zkoss.text.WikiEditor.onHeader4 ( )

Definition at line 193 of file WikiEditor.java.

193  {
194  insertOnStartLine("---++++", new String[] {
195  "---++++", "---+++", "---++", "---+"
196  });
197  }

◆ onHtml()

void org.turro.zkoss.text.WikiEditor.onHtml ( )

Definition at line 279 of file WikiEditor.java.

279  {
280  Div div = new Div();
281  div.setSclass("wikiEditor");
282  Textbox html = new Textbox(getHtml(wikibox.getValue(), false));
283  html.setSclass("wikiBox");
284  html.setReadonly(true);
285  html.setMultiline(true);
286  html.setHflex("1");
287  html.setVflex("1");
288  div.appendChild(html);
289  SelectionDialog.showComponent(getPage(), "HTML", div, "800px", "80%", null);
290  }
Here is the call graph for this function:

◆ onImage()

void org.turro.zkoss.text.WikiEditor.onImage ( )

Definition at line 437 of file WikiEditor.java.

437  {
438  WikiElement we = new WikiElement(selectionStart, wikibox, "img");
439 // if(!we.isTag("img")) {
440 // we.forgetAndCreate("img");
441 // }
442  final RepositoryWalker repositories = new RepositoryWalker(we);
443  repositories.selectFolder(imageFolder);
444  repositories.setFilter(RepositoryContent.IMAGE_FILTER);
445  repositories.setReadOnlyRepository(readOnlyRepository);
446  repositories.setNoTreeRepository(noTreeRepository);
447  SelectionDialog.showComponent(getPage(), I_.get("Repository"), repositories, "90%", "90%", new Command() {
448  @Override
449  public Object execute(Context context) {
450  if(repositories.renderResult()) {
451  wikibox.setSelectionRange(selectionStart, selectionStart);
452  wikibox.setFocus(true);
453  Events.postEvent(new InputEvent("onChange", WikiEditor.this, wikibox.getValue(), null));
454  }
455  return null;
456  }
457  });
458  }
Here is the call graph for this function:

◆ onItalic()

void org.turro.zkoss.text.WikiEditor.onItalic ( )

Definition at line 245 of file WikiEditor.java.

245  {
246  WikiElement we = new WikiElement(selectionStart, selectionEnd, wikibox, WikiElement.NON_BLOCK_ELEMENTS);
247  if(selectionStart == selectionEnd && we.inside() && !we.isTag("img")) {
248  putAttribute("font-style", "italic");
249  } else {
250  insert("__","__", true);
251  }
252  }
Here is the call graph for this function:

◆ onLink()

void org.turro.zkoss.text.WikiEditor.onLink ( )

Definition at line 413 of file WikiEditor.java.

413  {
414  WikiElement we = new WikiElement(selectionStart, selectionEnd, wikibox);
415  if(!we.isTag("link")) {
416  we.forgetAndCreate("link");
417  }
418  Link link = new Link(we);
419  link.setFileFolder(fileFolder);
420  link.setReadOnlyRepository(readOnlyRepository);
421  link.setNoTreeRepository(noTreeRepository);
422  SelectionDialog.getComponent(Executions.getCurrent().getDesktop().getFirstPage(), "Link", link, "500px", "300px", new Command() {
423  @Override
424  public Object execute(Context context) {
425  Link link = (Link) context.get("component");
426  if(link != null && link.renderResult()) {
427  wikibox.setSelectionRange(selectionStart, selectionStart);
428  wikibox.setFocus(true);
429  Events.postEvent(new InputEvent("onChange", WikiEditor.this, wikibox.getValue(), null));
430  }
431  return null;
432  }
433  });
434  }
Here is the call graph for this function:

◆ onNote()

void org.turro.zkoss.text.WikiEditor.onNote ( )

Definition at line 210 of file WikiEditor.java.

210  {
211  insert("\n[note]", "[/note]\n");
212  }

◆ onOlList()

void org.turro.zkoss.text.WikiEditor.onOlList ( )

Definition at line 358 of file WikiEditor.java.

358  {
359  insertOnStartLine(" 1 ", " * ");
360  }

◆ onPreview()

void org.turro.zkoss.text.WikiEditor.onPreview ( )

Definition at line 270 of file WikiEditor.java.

270  {
271  Div div = new Div();
272  div.setStyle("overflow:auto;");
273  Html html = new Html(getHtml(wikibox.getValue(), true));
274  div.appendChild(html);
275  SelectionDialog.showComponent(getPage(), I_.get("Preview"), div, "800px", "80%", null);
276  }
Here is the call graph for this function:

◆ onRegular()

void org.turro.zkoss.text.WikiEditor.onRegular ( )

Definition at line 255 of file WikiEditor.java.

255  {
256  insert("==","==", true);
257  }

◆ onSnippet()

void org.turro.zkoss.text.WikiEditor.onSnippet ( )

Definition at line 483 of file WikiEditor.java.

483  {
484  File wsnip = new File(ElephantContext.getRealPath("/WEB-INF/elephant/wiki/snippets"));
485  if(wsnip.exists()) {
486  FileListbox fl = new FileListbox();
487  fl.setExact(true);
488  fl.setFilter(".*\\.wiki");
489  fl.setDir(wsnip);
490  fl.addEventListener(Events.ON_DOUBLE_CLICK, (Event event) -> {
491  insert(FileUtil.getContentWithLineBreaks(fl.getObjectValue()));
492  Events.postEvent(new Event(Events.ON_CLOSE, Components.from(fl).parent(SelectionDialog.class)));
493  });
494  SelectionDialog.showComponent(getPage(), I_.get("Repository"), fl, "300px", "50%", (Context context) -> {
495  if(fl.getObjectValue() != null) {
496  wikibox.setFocus(true);
497  Events.postEvent(new InputEvent("onChange", WikiEditor.this, wikibox.getValue(), null));
498  }
499  return null;
500  });
501  }
502  }
Here is the call graph for this function:

◆ onSpan()

void org.turro.zkoss.text.WikiEditor.onSpan ( )

Definition at line 205 of file WikiEditor.java.

205  {
206  insert("[span]", "[/span]");
207  }

◆ onStartColumn()

void org.turro.zkoss.text.WikiEditor.onStartColumn ( )

Definition at line 215 of file WikiEditor.java.

215  {
216  insert("\n[column]\n");
217  }

◆ onStartJava()

void org.turro.zkoss.text.WikiEditor.onStartJava ( )

Definition at line 303 of file WikiEditor.java.

303  {
304  insert("\n$java\n");
305  }

◆ onStartWiki()

void org.turro.zkoss.text.WikiEditor.onStartWiki ( )

Definition at line 293 of file WikiEditor.java.

293  {
294  insert("\n$wiki\n");
295  }

◆ onStartXml()

void org.turro.zkoss.text.WikiEditor.onStartXml ( )

Definition at line 313 of file WikiEditor.java.

313  {
314  insert("\n$xml\n");
315  }

◆ onStopJava()

void org.turro.zkoss.text.WikiEditor.onStopJava ( )

Definition at line 308 of file WikiEditor.java.

308  {
309  insert("\n$no_java\n");
310  }

◆ onStopWiki()

void org.turro.zkoss.text.WikiEditor.onStopWiki ( )

Definition at line 298 of file WikiEditor.java.

298  {
299  insert("\n$no_wiki\n");
300  }

◆ onStopXml()

void org.turro.zkoss.text.WikiEditor.onStopXml ( )

Definition at line 318 of file WikiEditor.java.

318  {
319  insert("\n$no_xml\n");
320  }

◆ onTabulator()

void org.turro.zkoss.text.WikiEditor.onTabulator ( )

Definition at line 225 of file WikiEditor.java.

225  {
226  insert("\n[tab(Caption1)]\n","Content1\n[tab(Caption2)]\nContent2\n[/tab]\n");
227  }

◆ onTcl()

void org.turro.zkoss.text.WikiEditor.onTcl ( )

Definition at line 383 of file WikiEditor.java.

383  {
384  insert("\n|<");
385  }

◆ onTcr()

void org.turro.zkoss.text.WikiEditor.onTcr ( )

Definition at line 388 of file WikiEditor.java.

388  {
389  insert("\n|>");
390  }

◆ onTemplate()

void org.turro.zkoss.text.WikiEditor.onTemplate ( )

Definition at line 461 of file WikiEditor.java.

461  {
462  File wtmpl = new File(ElephantContext.getRealPath("/WEB-INF/elephant/wiki/templates"));
463  if(wtmpl.exists()) {
464  FileListbox fl = new FileListbox();
465  fl.setExact(true);
466  fl.setFilter(".*\\.wiki");
467  fl.setDir(wtmpl);
468  fl.addEventListener(Events.ON_DOUBLE_CLICK, (Event event) -> {
469  insert(FileUtil.getContentWithLineBreaks(fl.getObjectValue()));
470  Events.postEvent(new Event(Events.ON_CLOSE, Components.from(fl).parent(SelectionDialog.class)));
471  });
472  SelectionDialog.showComponent(getPage(), I_.get("Repository"), fl, "300px", "50%", (Context context) -> {
473  if(fl.getObjectValue() != null) {
474  wikibox.setFocus(true);
475  Events.postEvent(new InputEvent("onChange", WikiEditor.this, wikibox.getValue(), null));
476  }
477  return null;
478  });
479  }
480  }
Here is the call graph for this function:

◆ onTet()

void org.turro.zkoss.text.WikiEditor.onTet ( )

Definition at line 393 of file WikiEditor.java.

393  {
394  insert("\n-||");
395  }

◆ onThl()

void org.turro.zkoss.text.WikiEditor.onThl ( )

Definition at line 363 of file WikiEditor.java.

363  {
364  insert("\n||<");
365  }

◆ onThr()

void org.turro.zkoss.text.WikiEditor.onThr ( )

Definition at line 368 of file WikiEditor.java.

368  {
369  insert("\n||>");
370  }

◆ onToWiki()

void org.turro.zkoss.text.WikiEditor.onToWiki ( )

Definition at line 260 of file WikiEditor.java.

260  {
261  String v = wikibox.getValue();
262  String w = Parser.toWiki(v);
263  wikibox.setSelectedText(0, v.length(), w, false);
264  wikibox.setSelectionRange(0, 0);
265  wikibox.setFocus(true);
266  Events.postEvent(new InputEvent("onChange", this, wikibox.getValue(), null));
267  }
Here is the call graph for this function:

◆ onTrl()

void org.turro.zkoss.text.WikiEditor.onTrl ( )

Definition at line 373 of file WikiEditor.java.

373  {
374  insert("\n|-<");
375  }

◆ onTrr()

void org.turro.zkoss.text.WikiEditor.onTrr ( )

Definition at line 378 of file WikiEditor.java.

378  {
379  insert("\n|->");
380  }

◆ onUlList()

void org.turro.zkoss.text.WikiEditor.onUlList ( )

Definition at line 353 of file WikiEditor.java.

353  {
354  insertOnStartLine(" * ", " 1 ");
355  }

◆ setFileFolder()

void org.turro.zkoss.text.WikiEditor.setFileFolder ( String  folder)

Definition at line 119 of file WikiEditor.java.

119  {
120  this.fileFolder = folder;
121  }
Here is the caller graph for this function:

◆ setImageFolder()

void org.turro.zkoss.text.WikiEditor.setImageFolder ( String  folder)

Definition at line 111 of file WikiEditor.java.

111  {
112  this.imageFolder = folder;
113  }
Here is the caller graph for this function:

◆ setNoTreeRepository()

void org.turro.zkoss.text.WikiEditor.setNoTreeRepository ( boolean  noTreeRepository)

Definition at line 152 of file WikiEditor.java.

152  {
153  this.noTreeRepository = noTreeRepository;
154  }

◆ setReadonly()

void org.turro.zkoss.text.WikiEditor.setReadonly ( boolean  value)

Definition at line 131 of file WikiEditor.java.

131  {
132  wikibox.setReadonly(value);
133  for(Object obj : wikibar.getChildren()) {
134  if(obj instanceof Menuitem) {
135  ((Menuitem) obj).setDisabled(value);
136  }
137  }
138  }
Here is the caller graph for this function:

◆ setReadOnlyRepository()

void org.turro.zkoss.text.WikiEditor.setReadOnlyRepository ( boolean  readOnlyRepository)

Definition at line 144 of file WikiEditor.java.

144  {
145  this.readOnlyRepository = readOnlyRepository;
146  }
Here is the caller graph for this function:

◆ setValue()

void org.turro.zkoss.text.WikiEditor.setValue ( String  value)

Definition at line 98 of file WikiEditor.java.

98  {
99  setWiki(value);
100  elwiki.setCheckmark(WikiParser.isElWiki(value));
101  }
Here is the caller graph for this function:

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