19 package org.turro.zkoss.text;
22 import java.util.HashMap;
23 import org.turro.string.Strings;
24 import org.turro.elephant.context.ElephantContext;
25 import org.turro.elephant.util.Components;
26 import org.turro.i18n.I_;
27 import org.turro.zkoss.dialog.SelectionDialog;
28 import org.zkoss.zk.ui.Executions;
29 import org.zkoss.zk.ui.IdSpace;
30 import org.zkoss.zk.ui.event.Event;
31 import org.zkoss.zk.ui.event.Events;
32 import org.zkoss.zk.ui.event.UploadEvent;
33 import org.zkoss.zk.ui.select.Selectors;
34 import org.zkoss.zk.ui.select.annotation.Listen;
35 import org.zkoss.zk.ui.select.annotation.Wire;
36 import org.zkoss.zkmax.zul.Dropupload;
37 import org.zkoss.zul.Div;
38 import org.zkoss.zul.Hlayout;
39 import org.zkoss.zul.Toolbarbutton;
40 import org.zkoss.zul.West;
50 private boolean readOnlyRepository =
false, noTreeRepository =
false;
51 private String initialFolder;
55 @Wire(
"#treePanel")
private West treePanel;
56 @Wire(
"#upload")
private Toolbarbutton upload;
57 @Wire(
"#dropUpload")
private Dropupload dropUpload;
58 @Wire(
"#buttons")
private Hlayout buttons;
60 @Listen(
"onClick = #newFolder")
62 if(!noTreeRepository && !readOnlyRepository) {
67 @Listen(
"onClick = #delFolder")
69 if(!noTreeRepository && !readOnlyRepository) {
74 @Listen(
"onUpload = #upload")
76 repositoryContent.
addMedias(event.getMedias());
87 @Listen(
"onUpload = #dropUpload")
89 repositoryContent.
addMedias(event.getMedias());
93 @Listen(
"onSelect = #repositoriesTree")
99 @Listen(
"onSelect = #repositoryContent")
101 result = (File) event.getData();
106 HashMap args =
new HashMap();
108 args.put(
"i_",
I_.
api());
109 args.put(
"i",
I_.
map());
111 Executions.createComponents(
"/WEB-INF/_zul/bs/comps/editor/repositoryWalker.zul",
this, args);
112 Selectors.wireComponents(
this,
this,
false);
113 Selectors.wireEventListeners(
this,
this);
114 this.wikiElement = wikiElement;
118 if(Strings.isBlank(initialFolder)) {
119 initialFolder = folder;
139 return readOnlyRepository;
143 this.readOnlyRepository = readOnlyRepository;
144 upload.setDisabled(readOnlyRepository);
145 if(readOnlyRepository) {
146 dropUpload.setDetection(
"none");
147 dropUpload.setVisible(
false);
152 return noTreeRepository;
156 this.noTreeRepository = noTreeRepository;
157 treePanel.setVisible(!noTreeRepository);
160 private boolean isRoot(File repository) {
161 return repository !=
null ? repository.getAbsolutePath().endsWith(initialFolder) :
true;
static String getRealPath(String path)
static Components from(Object component)
static I18nByKey byKeyMap()
static I18nApiWrapper api()
static I18nMapWrapper map()
static I18nCompatibilityMap compatibilityMap()
void selectFolder(String folder)
File getSelectedRepository()
void setMatchFilter(String matchFilter)
void setFolder(File folder)
void addMedias(Media[] medias)
void setFilter(String filter)
void selectFolder(String folder)
void onDropUpload(UploadEvent event)
boolean isReadOnlyRepository()
void setNoTreeRepository(boolean noTreeRepository)
void onSelectFile(Event event)
RepositoryWalker(WikiElement wikiElement)
void onUpload(UploadEvent event)
boolean isNoTreeRepository()
void setReadOnlyRepository(boolean readOnlyRepository)
boolean renderImage(File image)