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

Public Member Functions

String getEncoding ()
 
void setEncoding (String encoding)
 
File getFile ()
 
void setFile (File file)
 
void setForcedSyntax (String forcedSyntax)
 
void setDisabled (boolean value)
 
void setText (String value)
 
void save ()
 
void saveAs (final Command command) throws IOException
 
void newFile (final File folder, final Command command) throws IOException
 
void afterCompose ()
 

Protected Attributes

File file
 
String encoding = null
 

Detailed Description

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

Definition at line 40 of file CodemirrorEditor.java.

Member Function Documentation

◆ afterCompose()

void org.turro.zkoss.text.CodemirrorEditor.afterCompose ( )

Definition at line 156 of file CodemirrorEditor.java.

156  {
157  try {
158  if(file != null) {
159  setSyntax(!Strings.isBlank(forcedSyntax) ? forcedSyntax : FileUtil.getExtension(file).toLowerCase());
160  if(FileUtil.getExtension(file).toLowerCase().equals("properties")) {
161  setValue(FileUtil.getPropertiesContent(file, Strings.isBlank(encoding) ? ElephantContext.getEncoding() : encoding));
162  } else {
163  setValue(FileUtil.getContent(file, Strings.isBlank(encoding) ? ElephantContext.getEncoding() : encoding));
164  }
165  }
166  } catch (IOException ex) {
167  Logger.getLogger(CodemirrorEditor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
168  }
169  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getEncoding()

String org.turro.zkoss.text.CodemirrorEditor.getEncoding ( )

Definition at line 45 of file CodemirrorEditor.java.

45  {
46  return encoding;
47  }

◆ getFile()

File org.turro.zkoss.text.CodemirrorEditor.getFile ( )

Definition at line 53 of file CodemirrorEditor.java.

53  {
54  return file;
55  }

◆ newFile()

void org.turro.zkoss.text.CodemirrorEditor.newFile ( final File  folder,
final Command  command 
) throws IOException

Definition at line 127 of file CodemirrorEditor.java.

127  {
128  InputDialog.getInput(
129  getPage(),
130  I_.get("New"),
131  new InputField[] {
132  new InputField("Name", "", null, 0)
133  }, new Command() {
134  @Override
135  public Object execute(Context context) {
136  InputField[] fields = (InputField[]) context.get("fields");
137  if(fields.length > 0) {
138  for(InputField f : fields) {
139  if("Name".equals(f.getLabel())) {
140  String path = folder.getAbsolutePath();
141  if(path != null) {
142  file = new File(path + "/" + f.getValue());
143  save();
144  context.put("file", file);
145  if(command != null) command.execute(context);
146  }
147  }
148  }
149  }
150  return null;
151  }
152  });
153  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ save()

void org.turro.zkoss.text.CodemirrorEditor.save ( )

Definition at line 73 of file CodemirrorEditor.java.

73  {
74  try {
75  if(!file.getParentFile().exists()) {
76  file.getParentFile().mkdirs();
77  }
78  if(FileUtil.getExtension(file).toLowerCase().equals("properties")) {
79  FileUtil.setPropertiesContent(file, getValue(), Strings.isBlank(encoding) ? ElephantContext.getEncoding() : encoding);
80  } else {
81  FileUtil.setContent(file, getValue(), Strings.isBlank(encoding) ? ElephantContext.getEncoding() : encoding);
82  }
83  } catch (IOException ex) {
84  Logger.getLogger(CodemirrorEditor.class.getName()).log(Level.SEVERE, ElephantContext.logMsg(null), ex);
85  }
86  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ saveAs()

void org.turro.zkoss.text.CodemirrorEditor.saveAs ( final Command  command) throws IOException

Definition at line 88 of file CodemirrorEditor.java.

88  {
89  InputDialog.getInput(
90  getPage(),
91  I_.get("Save as"),
92  new InputField[] {
93  new InputField("Name", getFile().getName(), null, 0),
94  new InputField("Override", Boolean.valueOf(Boolean.TRUE), null, 0)
95  }, new Command() {
96  @Override
97  public Object execute(Context context) {
98  InputField[] fields = (InputField[]) context.get("fields");
99  if(fields.length > 0) {
100  String name = null;
101  boolean override = false;
102  for(InputField f : fields) {
103  if("Name".equals(f.getLabel())) {
104  name = (String) f.getValue();
105  } else if("Override".equals(f.getLabel())) {
106  override = (Boolean) f.getValue();
107  }
108  }
109  if(!Strings.isBlank(name)) {
110  String path = FileUtil.getParentPath(file.getAbsolutePath());
111  if(path != null) {
112  if(override && !path.contains("/site")) {
113  path += "/site";
114  }
115  file = new File(path + "/" + name);
116  save();
117  context.put("file", file);
118  if(command != null) command.execute(context);
119  }
120  }
121  }
122  return null;
123  }
124  });
125  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setDisabled()

void org.turro.zkoss.text.CodemirrorEditor.setDisabled ( boolean  value)

Definition at line 65 of file CodemirrorEditor.java.

65  {
66  setReadonly(value);
67  }
Here is the caller graph for this function:

◆ setEncoding()

void org.turro.zkoss.text.CodemirrorEditor.setEncoding ( String  encoding)

Definition at line 49 of file CodemirrorEditor.java.

49  {
50  this.encoding = encoding;
51  }
Here is the caller graph for this function:

◆ setFile()

void org.turro.zkoss.text.CodemirrorEditor.setFile ( File  file)

Definition at line 57 of file CodemirrorEditor.java.

57  {
58  this.file = file;
59  }
Here is the caller graph for this function:

◆ setForcedSyntax()

void org.turro.zkoss.text.CodemirrorEditor.setForcedSyntax ( String  forcedSyntax)

Definition at line 61 of file CodemirrorEditor.java.

61  {
62  this.forcedSyntax = forcedSyntax;
63  }

◆ setText()

void org.turro.zkoss.text.CodemirrorEditor.setText ( String  value)

Definition at line 69 of file CodemirrorEditor.java.

69  {
70  setValue(value);
71  }
Here is the caller graph for this function:

Member Data Documentation

◆ encoding

String org.turro.zkoss.text.CodemirrorEditor.encoding = null
protected

Definition at line 43 of file CodemirrorEditor.java.

◆ file

File org.turro.zkoss.text.CodemirrorEditor.file
protected

Definition at line 42 of file CodemirrorEditor.java.


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