BrightSide Workbench Full Report + Source Code
org.turro.file.zul.tree.FileItem Class Reference
Inheritance diagram for org.turro.file.zul.tree.FileItem:
Collaboration diagram for org.turro.file.zul.tree.FileItem:

Public Member Functions

 FileItem (File file)
 
 FileItem (String label, File file)
 
 FileItem (String label)
 
 FileItem ()
 
FileTree getTree ()
 
FileItem getParentFile ()
 
String getFileLabel ()
 
void doAddFolder () throws InterruptedException
 
void doRename () throws InterruptedException
 
void showContents ()
 
void reloadContents ()
 
File getFile ()
 
String getPath ()
 
void processSelection (boolean openItem)
 
void initPreview ()
 
void afterCompose ()
 

Detailed Description

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

Definition at line 52 of file FileItem.java.

Constructor & Destructor Documentation

◆ FileItem() [1/4]

org.turro.file.zul.tree.FileItem.FileItem ( File  file)

Definition at line 60 of file FileItem.java.

60  {
61  this(null, file);
62  }

◆ FileItem() [2/4]

org.turro.file.zul.tree.FileItem.FileItem ( String  label,
File  file 
)

Definition at line 64 of file FileItem.java.

64  {
65  super();
66  this.fileLabel = label;
67  setValue(file);
68  setOpen(false);
69  addEventListener(Events.ON_OPEN, new EventListener<Event>() {
70  @Override
71  public void onEvent(Event event) throws Exception {
72  processSelection(false);
73  }
74  });
75  //initLoadOnDemand();
76  }

◆ FileItem() [3/4]

org.turro.file.zul.tree.FileItem.FileItem ( String  label)

Definition at line 78 of file FileItem.java.

78  {
79  throw new UnsupportedOperationException("Do not use");
80  }

◆ FileItem() [4/4]

org.turro.file.zul.tree.FileItem.FileItem ( )

Definition at line 82 of file FileItem.java.

82  {
83  throw new UnsupportedOperationException("Do not use");
84  }

Member Function Documentation

◆ afterCompose()

void org.turro.file.zul.tree.FileItem.afterCompose ( )

Definition at line 313 of file FileItem.java.

313  {
314  addCells();
315  File file = (File) getValue();
316  if(file.isFile()) {
317  setImage(getMimeImage());
318  } else if(!file.exists() || file.isDirectory()) {
319  setImage("/_zul/images/folder.png");
320  addChildrenSpace();
321  }
322  }
Here is the caller graph for this function:

◆ doAddFolder()

void org.turro.file.zul.tree.FileItem.doAddFolder ( ) throws InterruptedException

Definition at line 99 of file FileItem.java.

99  {
100  InputDialog.getInput(
101  getPage(),
102  I_.get("Folder"),
103  new InputField[] {
104  new InputField("Name", "", null, 0)
105  }, new Command() {
106  @Override
107  public Object execute(Context context) {
108  InputField[] fields = (InputField[]) context.get("fields");
109  if(fields.length > 0) {
110  for(InputField f : fields) {
111  if("Name".equals(f.getLabel())) {
112  File newFolder = new File(getFile().getAbsolutePath() + "/" + f.getValue());
113  if(newFolder.mkdirs()) {
114  reloadContents();
115  }
116  }
117  }
118  }
119  return null;
120  }
121  });
122  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ doRename()

void org.turro.file.zul.tree.FileItem.doRename ( ) throws InterruptedException

Definition at line 124 of file FileItem.java.

124  {
125  if(getParentItem() == null) return;
126  InputDialog.getInput(
127  getPage(),
128  I_.get("Rename"),
129  new InputField[] {
130  new InputField("Name", getFile().getName(), null, 0)
131  }, new Command() {
132  @Override
133  public Object execute(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  String path = FileUtil.getParentPath(getFile().getAbsolutePath());
139  if(path != null) {
140  if(getFile().renameTo(new File(path + "/" + f.getValue()))) {
141  FileItem.this.setValue(new File(path + "/" + f.getValue()));
142  FileItem.this.setLabel(getFile().getName());
143  }
144  }
145  }
146  }
147  }
148  return null;
149  }
150  });
151  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getFile()

File org.turro.file.zul.tree.FileItem.getFile ( )

Definition at line 165 of file FileItem.java.

165  {
166  return (File) getValue();
167  }
Here is the caller graph for this function:

◆ getFileLabel()

String org.turro.file.zul.tree.FileItem.getFileLabel ( )

Definition at line 95 of file FileItem.java.

95  {
96  return fileLabel;
97  }
Here is the caller graph for this function:

◆ getParentFile()

FileItem org.turro.file.zul.tree.FileItem.getParentFile ( )

Definition at line 91 of file FileItem.java.

91  {
92  return (FileItem) getParentItem();
93  }
Here is the caller graph for this function:

◆ getPath()

String org.turro.file.zul.tree.FileItem.getPath ( )

Definition at line 169 of file FileItem.java.

169  {
170  String path = "";
171  FileItem fi = this;
172  while(fi != null) {
173  if(fi.getParentFile() == null) {
174  break;
175  }
176  path = "/" + fi.getFile().getName() + path;
177  fi = fi.getParentFile();
178  }
179  return path;
180  }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ getTree()

FileTree org.turro.file.zul.tree.FileItem.getTree ( )

Definition at line 87 of file FileItem.java.

87  {
88  return (FileTree) super.getTree();
89  }

◆ initPreview()

void org.turro.file.zul.tree.FileItem.initPreview ( )

Definition at line 202 of file FileItem.java.

202  {
203  File file = getValue();
204  if(!file.isDirectory()) {
205  FilePreview fp = new FilePreview(file);
206  getTree().getParent().appendChild(fp);
207  setTooltip(fp);
208  }
209  }
Here is the caller graph for this function:

◆ processSelection()

void org.turro.file.zul.tree.FileItem.processSelection ( boolean  openItem)

Definition at line 182 of file FileItem.java.

182  {
183  if(getFile().isDirectory()) {
184  if(openItem) {
185  if(!isOpen()) {
186  showContents();
187  } else {
188  setOpen(false);
189  }
190  } else {
191  if(isOpen()) {
192  showContents();
193  } else {
194  setOpen(false);
195  }
196  }
197  } else {
198  getTree().getActionMenu().open(this);
199  }
200  }
Here is the caller graph for this function:

◆ reloadContents()

void org.turro.file.zul.tree.FileItem.reloadContents ( )

Definition at line 158 of file FileItem.java.

158  {
159  if(children != null) {
160  children.getChildren().clear();
161  showContents();
162  }
163  }

◆ showContents()

void org.turro.file.zul.tree.FileItem.showContents ( )

Definition at line 153 of file FileItem.java.

153  {
154  fillFolder();
155  setOpen(true);
156  }
Here is the caller graph for this function:

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