BrightSide Workbench Full Report + Source Code
org.turro.elephant.web.ContextComposer Class Reference
Inheritance diagram for org.turro.elephant.web.ContextComposer:
Collaboration diagram for org.turro.elephant.web.ContextComposer:

Public Member Functions

void onSelectContext (Event event)
 
void onSaveDetail (Event event)
 
void onCreateChild (Event event)
 
void onRemoveContext (Event event)
 
void onAddAttribute (Event event)
 
void onBaseChange (Event event)
 
void onVersionChange (Event event)
 
void onRemoveVersion (Event event)
 
void onDiffVersion (Event event)
 
void onSaveContent (Event event)
 
void onChange (Event event)
 
void doFinally () throws Exception
 
void doBeforeComposeChildren (Component comp) throws Exception
 

Detailed Description

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

Definition at line 60 of file ContextComposer.java.

Member Function Documentation

◆ doBeforeComposeChildren()

void org.turro.elephant.web.ContextComposer.doBeforeComposeChildren ( Component  comp) throws Exception

Definition at line 271 of file ContextComposer.java.

271  {
272  comp.setAttribute("edit", editingContext);
273  super.doBeforeComposeChildren(comp);
274  }

◆ doFinally()

void org.turro.elephant.web.ContextComposer.doFinally ( ) throws Exception

Definition at line 246 of file ContextComposer.java.

246  {
247  saveDetail.setDisabled(true);
248  saveDetail.setAutodisable("+self");
249  savePage.setDisabled(true);
250  savePage.setAutodisable("+self");
251  saveElement.setDisabled(true);
252  saveElement.setAutodisable("+self");
253  saveContent.setDisabled(true);
254  saveContent.setAutodisable("+self");
255  createChild.setDisabled(true);
256  removeContext.setDisabled(true);
257  wikiEditor.addResolver(w -> StyledElement.contextuals(w, ElephantContext.getRootWebPath(),
258  editingContext.getContext().getPath(), WebContext.relativeRepository()));
259  }
void addResolver(IWikiResolver resolver)
Here is the call graph for this function:

◆ onAddAttribute()

void org.turro.elephant.web.ContextComposer.onAddAttribute ( Event  event)

Definition at line 163 of file ContextComposer.java.

163  {
164  InputDialog.getInput(getPage(),
165  "Attribute",
166  new InputField[]{
167  new InputField("Name", "", null, 0)
168  }, (Context context) -> {
169  InputField[] fields = (InputField[]) context.get("fields");
170  if(fields.length > 0) {
171  for(InputField f : fields) {
172  if("Name".equals(f.getLabel())) {
173  createAttribute((String) f.getValue());
174  }
175  }
176  }
177  return null;
178  });
179  }
Here is the call graph for this function:

◆ onBaseChange()

void org.turro.elephant.web.ContextComposer.onBaseChange ( Event  event)

Definition at line 182 of file ContextComposer.java.

182  {
183  updateVersion();
184  }

◆ onChange()

void org.turro.elephant.web.ContextComposer.onChange ( Event  event)

Definition at line 236 of file ContextComposer.java.

236  {
237  saveDetail.setDisabled(false);
238  savePage.setDisabled(false);
239  saveElement.setDisabled(false);
240  saveContent.setDisabled(!editingContext.isEditable(base.getObjectValue(), blang.getObjectValue()));
241  wikiEditor.setReadonly(saveContent.isDisabled());
242  if(editingContext.getContext() != null) editingContext.getContext().resetDefaultLocales();
243  }
boolean isEditable(String base, String lang)
void setReadonly(boolean value)
Here is the call graph for this function:

◆ onCreateChild()

void org.turro.elephant.web.ContextComposer.onCreateChild ( Event  event)

Definition at line 121 of file ContextComposer.java.

121  {
122  InputDialog.getInput(getPage(),
123  "Child context",
124  new InputField[]{
125  new InputField("Name", "", null, 0) {
126  @Override
127  protected HtmlBasedComponent createEditor() {
128  Textbox tb = new Textbox();
129  tb.setConstraint("/[a-z][a-z0-9\\-]+/: {Start with a lowercase letter, then lowercase letters, numbers or hypens}");
130  return tb;
131  }
132  }
133  }, (Context context) -> {
134  InputField[] fields = (InputField[]) context.get("fields");
135  if(fields.length > 0) {
136  for(InputField f : fields) {
137  if("Name".equals(f.getLabel())) {
138  createAndSelect((String) f.getValue());
139  }
140  }
141  }
142  return null;
143  });
144  }
Here is the call graph for this function:

◆ onDiffVersion()

void org.turro.elephant.web.ContextComposer.onDiffVersion ( Event  event)

Definition at line 213 of file ContextComposer.java.

213  {
214  try {
215  File oldFile = editingContext.getContext().getResources().getEditable(
216  base.getObjectValue(), blang.getObjectValue(), bversion.getObjectValue());
217  String oldText = FileUtil.getContentWithLineBreaks(oldFile);
218  File newFile = editingContext.getContext().getResources().getEditable(
219  base.getObjectValue(), blang.getObjectValue(), CollectionUtil.from(bversion.getCollection()).first());
220  String newText = FileUtil.getContentWithLineBreaks(newFile);
221  Windows.showHtml("Diff", Diffs.diff(oldText, newText).efficiency().html());
222  } catch (IOException ex) {
223  Logger.getLogger(ContextComposer.class.getName()).log(Level.SEVERE, null, ex);
224  }
225  }
File getEditable(String base, String lang, String version)
Here is the call graph for this function:

◆ onRemoveContext()

void org.turro.elephant.web.ContextComposer.onRemoveContext ( Event  event)

Definition at line 147 of file ContextComposer.java.

147  {
148  Messages.confirmDeletion().add(editingContext.getContext().getId()).show(() -> {
149  ElContext parent = editingContext.getContext().getParent();
150  if(parent == null) {
151  Clients.showNotification("Cannot remove root");
152  } else {
153  Folder.from(editingContext.getContext().getFile()).remove();
154  ElContextMap.reset();
155  contextTree.reload();
156  contextTree.selectPath(parent.getPath());
157  onSelectContext(null);
158  }
159  });
160  }
Here is the call graph for this function:

◆ onRemoveVersion()

void org.turro.elephant.web.ContextComposer.onRemoveVersion ( Event  event)

Definition at line 204 of file ContextComposer.java.

204  {
205  Messages.confirmDeletion().add(bversion.getObjectValue()).show(() -> {
206  editingContext.removeVersion(base.getObjectValue(),
207  blang.getObjectValue(), bversion.getObjectValue());
208  updateContent();
209  });
210  }
void removeVersion(String base, String lang, String version)
Here is the call graph for this function:

◆ onSaveContent()

void org.turro.elephant.web.ContextComposer.onSaveContent ( Event  event)

Definition at line 228 of file ContextComposer.java.

228  {
229  editingContext.saveContent(Authentication.getIContact(), base.getObjectValue(),
230  blang.getObjectValue(), wikiEditor.getValue(), wikiEditor.getHtml(),
231  autoremove.isChecked());
232  updateContent();
233  }
void saveContent(IContact contact, String base, String lang, String wiki, String html, boolean autoremove)
Here is the call graph for this function:

◆ onSaveDetail()

void org.turro.elephant.web.ContextComposer.onSaveDetail ( Event  event)

Definition at line 114 of file ContextComposer.java.

114  {
115  saveAttributes(editingContext.getContext());
116  ElContextMap.reset();
117  SitemapGenerator.generateSitemap();
118  }
Here is the call graph for this function:

◆ onSelectContext()

void org.turro.elephant.web.ContextComposer.onSelectContext ( Event  event)

Definition at line 95 of file ContextComposer.java.

95  {
96  ContextItem contextItem = (ContextItem) contextTree.getSelectedItem();
97  editingContext.setContext(contextItem.getElContext());
98  contextId.invalidate();
99  formDetail.invalidate();
100  formPage.invalidate();
101  formElement.invalidate();
102  formRepository.invalidate();
103  formSocial.invalidate();
104  saveDetail.setDisabled(true);
105  savePage.setDisabled(true);
106  saveElement.setDisabled(true);
107  createChild.setDisabled(contextItem == null);
108  removeContext.setDisabled(contextItem == null);
109  addAttribute.setDisabled(contextItem == null);
110  updateContent();
111  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ onVersionChange()

void org.turro.elephant.web.ContextComposer.onVersionChange ( Event  event)

Definition at line 187 of file ContextComposer.java.

187  {
188  File file = editingContext.getContext().getResources().getEditable(
189  base.getObjectValue(), blang.getObjectValue(), bversion.getObjectValue());
190  if(file != null) {
191  try {
192  removeVersion.setDisabled(false);
193  diffVersion.setDisabled(false);
194  wikiEditor.setValue(FileUtil.getContentWithLineBreaks(file));
195  } catch (IOException ex) {
196  Logger.getLogger(ContextComposer.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
197  }
198  } else {
199  wikiEditor.setValue(null);
200  }
201  }
void setValue(String value)
Definition: WikiEditor.java:98
Here is the call graph for this function:

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