IDEMPIERE-1345 Allow Translation Export from webui
This commit is contained in:
parent
f1b344bcbe
commit
3b60b8913d
|
@ -0,0 +1,11 @@
|
|||
SET SQLBLANKLINES ON
|
||||
SET DEFINE OFF
|
||||
|
||||
-- Sep 9, 2013 4:25:23 PM COT
|
||||
-- IDEMPIERE-1345 Allow Translation Export from webui
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Export ZIP',200230,'D','d68b4fb8-d613-47a5-879b-c54aa9d3c415','ExportZIP','Y',TO_DATE('2013-09-09 16:25:22','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_DATE('2013-09-09 16:25:22','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201309091625_IDEMPIERE-1345.sql') FROM dual
|
||||
;
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
-- Sep 9, 2013 4:25:23 PM COT
|
||||
-- IDEMPIERE-1345 Allow Translation Export from webui
|
||||
INSERT INTO AD_Message (MsgType,MsgText,AD_Message_ID,EntityType,AD_Message_UU,Value,IsActive,Updated,CreatedBy,UpdatedBy,AD_Org_ID,Created,AD_Client_ID) VALUES ('I','Export ZIP',200230,'D','d68b4fb8-d613-47a5-879b-c54aa9d3c415','ExportZIP','Y',TO_TIMESTAMP('2013-09-09 16:25:22','YYYY-MM-DD HH24:MI:SS'),100,100,0,TO_TIMESTAMP('2013-09-09 16:25:22','YYYY-MM-DD HH24:MI:SS'),0)
|
||||
;
|
||||
|
||||
SELECT register_migration_script('201309091625_IDEMPIERE-1345.sql') FROM dual
|
||||
;
|
||||
|
|
@ -11,6 +11,8 @@ Import-Package: javax.activation;version="1.1.1",
|
|||
org.apache.commons.codec.binary,
|
||||
org.apache.ecs,
|
||||
org.apache.ecs.xhtml,
|
||||
org.apache.tools.ant,
|
||||
org.apache.tools.ant.taskdefs,
|
||||
org.compiere.css,
|
||||
org.osgi.framework;version="1.5.0",
|
||||
org.osgi.service.event;version="1.3.0",
|
||||
|
|
|
@ -46,7 +46,11 @@ import org.adempiere.webui.panel.StatusBarPanel;
|
|||
import org.adempiere.webui.session.SessionManager;
|
||||
import org.adempiere.webui.util.ReaderInputStream;
|
||||
import org.adempiere.webui.window.FDialog;
|
||||
import org.adempiere.webui.window.MultiFileDownloadDialog;
|
||||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.tools.ant.Project;
|
||||
import org.apache.tools.ant.Target;
|
||||
import org.apache.tools.ant.taskdefs.Zip;
|
||||
import org.compiere.install.Translation;
|
||||
import org.compiere.install.TranslationController;
|
||||
import org.compiere.util.Env;
|
||||
|
@ -100,6 +104,7 @@ public class WTranslationDialog extends TranslationController implements IFormCo
|
|||
|
||||
private Button bExport = new Button();
|
||||
private Button bImport = new Button();
|
||||
private Button bExportZIP = new Button();
|
||||
private Button bImportZIP = new Button();
|
||||
|
||||
private Label lClient = new Label();
|
||||
|
@ -128,6 +133,8 @@ public class WTranslationDialog extends TranslationController implements IFormCo
|
|||
bExport.setStyle("text-align: right;");
|
||||
bImport.setLabel(Msg.getMsg(Env.getCtx(), "Import"));
|
||||
bImport.addActionListener(this);
|
||||
bExportZIP.setLabel(Msg.getMsg(Env.getCtx(), "ExportZIP"));
|
||||
bExportZIP.addActionListener(this);
|
||||
bImportZIP.setLabel(Msg.getMsg(Env.getCtx(), "ImportZIP"));
|
||||
bImportZIP.setUpload(AdempiereWebUI.getUploadSetting());
|
||||
bImportZIP.addEventListener(Events.ON_UPLOAD, this);
|
||||
|
@ -152,10 +159,16 @@ public class WTranslationDialog extends TranslationController implements IFormCo
|
|||
row.appendChild(div);
|
||||
|
||||
div = new Div();
|
||||
div.setStyle("text-align: center;");
|
||||
div.setStyle("text-align: left;");
|
||||
div.appendChild(bImport);
|
||||
row.appendChild(div);
|
||||
|
||||
row = rows.newRow();
|
||||
div = new Div();
|
||||
div.setStyle("text-align: right;");
|
||||
div.appendChild(bExportZIP);
|
||||
row.appendChild(div);
|
||||
|
||||
div = new Div();
|
||||
div.setStyle("text-align: left;");
|
||||
div.appendChild(bImportZIP);
|
||||
|
@ -247,13 +260,17 @@ public class WTranslationDialog extends TranslationController implements IFormCo
|
|||
return;
|
||||
}
|
||||
|
||||
final FolderBrowser directoryDialog = new FolderBrowser(true);
|
||||
directoryDialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
callImportProcess(directoryDialog.getPath());
|
||||
}
|
||||
});
|
||||
if ((e.getTarget() == bImport || e.getTarget() == bExport)) {
|
||||
final FolderBrowser directoryDialog = new FolderBrowser(true);
|
||||
directoryDialog.addEventListener(DialogEvents.ON_WINDOW_CLOSE, new EventListener<Event>() {
|
||||
@Override
|
||||
public void onEvent(Event event) throws Exception {
|
||||
callImportProcess(directoryDialog.getPath());
|
||||
}
|
||||
});
|
||||
} else if (e.getTarget() == bExportZIP) {
|
||||
processExportZIP();
|
||||
}
|
||||
} // onEvent
|
||||
|
||||
private void callImportProcess(String directory) {
|
||||
|
@ -408,4 +425,48 @@ public class WTranslationDialog extends TranslationController implements IFormCo
|
|||
out.close();
|
||||
}
|
||||
|
||||
private void processExportZIP() {
|
||||
File tempfolder;
|
||||
try {
|
||||
tempfolder = File.createTempFile(m_AD_Language.getValue(), ".trl");
|
||||
tempfolder.delete();
|
||||
tempfolder.mkdir();
|
||||
} catch (IOException e1) {
|
||||
throw new AdempiereException("Problem creating temp folder", e1);
|
||||
}
|
||||
// export to temp folder
|
||||
callImportProcess(tempfolder.getPath());
|
||||
|
||||
// and now zip the exported files
|
||||
File destZipFile = null;
|
||||
try {
|
||||
destZipFile = File.createTempFile(m_AD_Language.getValue() + "_trlExport_", ".zip");
|
||||
} catch (Throwable e) {
|
||||
throw new AdempiereException("Unable to create temp file", e);
|
||||
}
|
||||
destZipFile.delete();
|
||||
|
||||
Zip zipper = new Zip();
|
||||
zipper.setDestFile(destZipFile);
|
||||
zipper.setBasedir(tempfolder);
|
||||
zipper.setUpdate(false);
|
||||
zipper.setCompress(true);
|
||||
zipper.setCaseSensitive(false);
|
||||
zipper.setFilesonly(true);
|
||||
zipper.setTaskName("zip");
|
||||
zipper.setTaskType("zip");
|
||||
zipper.setProject(new Project());
|
||||
zipper.setOwningTarget(new Target());
|
||||
zipper.execute();
|
||||
|
||||
try {
|
||||
FileUtils.deleteDirectory(tempfolder);
|
||||
} catch (IOException e) {}
|
||||
|
||||
MultiFileDownloadDialog downloadDialog = new MultiFileDownloadDialog(new File [] {destZipFile});
|
||||
downloadDialog.setPage(getForm().getPage());
|
||||
downloadDialog.setTitle(Msg.getMsg(Env.getCtx(), "ExportZIP"));
|
||||
Events.postEvent(downloadDialog, new Event(MultiFileDownloadDialog.ON_SHOW));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue