use of org.compiere.model.MAttachmentEntry in project lar_361 by comitsrl.
the class ReportStarterWithTxtExporter method getAttachmentResourceFile.
/**
* Get .property resource file from process attachment
* @param jasperName
* @param currLang
* @return File
*/
private File getAttachmentResourceFile(String jasperName, Language currLang) {
File resFile = null;
MAttachmentEntry[] entries = attachment.getEntries();
// try baseName + "_" + language
for (int i = 0; i < entries.length; i++) {
if (entries[i].getName().equals(jasperName + currLang.getLocale().getLanguage() + ".properties")) {
resFile = getAttachmentEntryFile(entries[i]);
break;
}
}
if (resFile == null) {
// try baseName only
for (int i = 0; i < entries.length; i++) {
if (entries[i].getName().equals(jasperName + ".properties")) {
resFile = getAttachmentEntryFile(entries[i]);
break;
}
}
}
return resFile;
}
use of org.compiere.model.MAttachmentEntry in project adempiere by adempiere.
the class WAttachment method displaySelected.
// displayData
/**
* Use to refresh preview frame, don't call directly.
*/
public void displaySelected() {
MAttachmentEntry entry = m_attachment.getEntry(displayIndex);
log.config("Index=" + displayIndex + " - " + entry);
if (entry != null && entry.getData() != null) {
bSave.setEnabled(true);
bDelete.setEnabled(true);
log.config(entry.toStringX());
try {
AMedia media = new AMedia(entry.getName(), null, entry.getContentType(), entry.getData());
preview.setContent(media);
preview.setVisible(true);
preview.invalidate();
} catch (Exception e) {
log.log(Level.SEVERE, "attachment", e);
}
}
}
use of org.compiere.model.MAttachmentEntry in project adempiere by adempiere.
the class WAttachment method saveAttachmentToFile.
// deleteAttachment
/**
* Save Attachment to File
*/
private void saveAttachmentToFile() {
int index = cbContent.getSelectedIndex();
log.info("index=" + index);
if (m_attachment.getEntryCount() < index)
return;
MAttachmentEntry entry = m_attachment.getEntry(index);
if (entry != null && entry.getData() != null) {
try {
AMedia media = new AMedia(entry.getName(), null, entry.getContentType(), entry.getData());
Filedownload.save(media);
} catch (Exception e) {
log.log(Level.SEVERE, "attachment", e);
}
}
}
use of org.compiere.model.MAttachmentEntry in project adempiere by adempiere.
the class ReportStarter method getAttachmentSubreports.
/**
* Get subreports from attachment. Assume all other jasper attachment is subreport.
* @param reportPath
* @return File[]
*/
private File[] getAttachmentSubreports(String reportPath) {
String name = reportPath.substring("attachment:".length()).trim();
ArrayList<File> subreports = new ArrayList<File>();
MAttachmentEntry[] entries = attachment.getEntries();
for (int i = 0; i < entries.length; i++) {
// @Trifon
if (!entries[i].getName().equals(name) && (entries[i].getName().toLowerCase().endsWith(".jrxml") || entries[i].getName().toLowerCase().endsWith(".jasper") || entries[i].getName().toLowerCase().endsWith(".jpg") || entries[i].getName().toLowerCase().endsWith(".png"))) {
File reportFile = getAttachmentEntryFile(entries[i]);
if (reportFile != null)
subreports.add(reportFile);
}
}
File[] subreportsTemp = new File[0];
subreportsTemp = subreports.toArray(subreportsTemp);
return subreportsTemp;
}
use of org.compiere.model.MAttachmentEntry in project adempiere by adempiere.
the class ReportStarter method getAttachmentResourceFile.
/**
* Get .property resource file from process attachment
* @param jasperName
* @param currLang
* @return File
*/
private File getAttachmentResourceFile(String jasperName, Language currLang) {
File resFile = null;
MAttachmentEntry[] entries = attachment.getEntries();
// try baseName + "_" + language
for (int i = 0; i < entries.length; i++) {
if (entries[i].getName().equals(jasperName + currLang.getLocale().getLanguage() + ".properties")) {
resFile = getAttachmentEntryFile(entries[i]);
break;
}
}
if (resFile == null) {
// try baseName only
for (int i = 0; i < entries.length; i++) {
if (entries[i].getName().equals(jasperName + ".properties")) {
resFile = getAttachmentEntryFile(entries[i]);
break;
}
}
}
return resFile;
}
Aggregations