18 package org.turro.file.action;
21 import java.io.FileNotFoundException;
22 import java.io.FilenameFilter;
23 import java.io.IOException;
24 import java.util.Properties;
25 import java.util.logging.Level;
26 import java.util.logging.Logger;
27 import org.turro.elephant.context.ElephantContext;
28 import org.turro.elephant.impl.util.ShellExecutor;
29 import org.turro.file.FolderFile;
30 import org.turro.i18n.I_;
46 return I_.
get(
"Create a gallery");
51 return "/_zul/images/gallery.png";
57 File thumbs =
new File(ff.
getFile().getAbsolutePath() +
"/thumbs");
59 if (!thumbs.exists()) {
62 for (File file : ff.
getFile().listFiles(
new FilenameFilter() {
64 public boolean accept(File dir, String name) {
65 return !name.endsWith(
".properties") && name.contains(
".") && name.matches(
".*\\.(jpg|jpeg|png|gif|tif)");
68 for (
int i = 0; i < 20; i++) {
69 String command = props.getProperty(
"cmdimg" + i,
null);
70 if (command !=
null) {
71 String thumbName = file.getName();
72 thumbName = thumbName.substring(0, thumbName.lastIndexOf(
".")) +
".png";
73 new ShellExecutor().
execute(command.replaceAll(
"#file", file.getAbsolutePath()).replaceAll(
"#thumb", thumbs.getAbsolutePath() +
"/" + thumbName));
78 for (File file : ff.
getFile().listFiles(
new FilenameFilter() {
80 public boolean accept(File dir, String name) {
81 return !name.endsWith(
".properties") && name.contains(
".") && name.matches(
".*\\.(avi|mpeg|mpg|vob|divx)");
84 for (
int i = 0; i < 20; i++) {
85 String command = props.getProperty(
"cmdvid" + i,
null);
86 if (command !=
null) {
87 String flvName = file.getAbsolutePath();
88 flvName = flvName.substring(0, flvName.lastIndexOf(
".")) +
".flv";
89 new ShellExecutor().
execute(command.replaceAll(
"#file", file.getAbsolutePath()).replaceAll(
"#flv", flvName));
94 for (File file : ff.
getFile().listFiles(
new FilenameFilter() {
96 public boolean accept(File dir, String name) {
97 return !name.endsWith(
".properties") && name.contains(
".") && name.matches(
".*\\.(flv)");
100 for (
int i = 0; i < 20; i++) {
101 String command = props.getProperty(
"cmdflv" + i,
null);
102 if (command !=
null) {
103 String thumbName = file.getName();
104 thumbName = thumbName.substring(0, thumbName.lastIndexOf(
".")) +
".png";
105 new ShellExecutor().
execute(command.replaceAll(
"#file", file.getAbsolutePath()).replaceAll(
"#thumb", thumbs.getAbsolutePath() +
"/" + thumbName));
109 for (File file : thumbs.listFiles(
new FilenameFilter() {
111 public boolean accept(File dir, String name) {
112 return name.endsWith(
".png");
115 for (
int i = 0; i < 20; i++) {
116 String command = props.getProperty(
"cmdthumb" + i,
null);
117 if (command !=
null) {
123 }
catch (FileNotFoundException ex) {
125 }
catch (IOException ex) {
static String logMsg(String msg)
int execute(String command)
Properties getProperties()
GalleryAction(FolderFile ff)
static String get(String msg)