use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ArchiveViewer method cmd_updateArchive.
// updateVDisplay
/**
* Update Archive Info
*/
private void cmd_updateArchive() {
MArchive ar = m_archives[m_index];
boolean update = false;
if (!isSame(nameField.getText(), ar.getName())) {
String newText = nameField.getText();
if (newText != null && newText.length() > 0) {
ar.setName(newText);
update = true;
}
}
if (!isSame(descriptionField.getText(), ar.getDescription())) {
ar.setDescription(descriptionField.getText());
update = true;
}
if (!isSame(helpField.getText(), ar.getHelp())) {
ar.setHelp(helpField.getText());
update = true;
}
log.info("Update=" + update);
if (update)
ar.saveEx();
//
m_index++;
updateVDisplay(false);
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class Viewer method cmd_archive.
// cmd_sendMail
/**
* Archive Report directly
*/
private void cmd_archive() {
boolean success = false;
// No Copy
byte[] data = Document.getPDFAsArray(m_reportEngine.getLayout().getPageable(false));
if (data != null) {
MArchive archive = new MArchive(Env.getCtx(), m_reportEngine.getPrintInfo(), null);
archive.setBinaryData(data);
success = archive.save();
}
if (success)
ADialog.info(m_WindowNo, this, "Archived");
else
ADialog.error(m_WindowNo, this, "ArchiveError");
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ArchiveEngine method archive.
/**
* Get/Create Archive.
* @param layout layout
* @param info print info
* @return existing document or newly created if Client enabled archiving.
* Will return NULL if archiving not enabled
*/
public byte[] archive(LayoutEngine layout, PrintInfo info) {
// Do we need to Archive ?
MClient client = MClient.get(layout.getCtx());
String aaClient = client.getAutoArchive();
// role.getAutoArchive(); // TODO
String aaRole = null;
String aa = aaClient;
if (aa == null)
aa = MClient.AUTOARCHIVE_None;
if (aaRole != null) {
if (aaRole.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
else if (aaRole.equals(MClient.AUTOARCHIVE_Documents) && !aaClient.equals(MClient.AUTOARCHIVE_AllReportsDocuments))
aa = aaRole;
}
// Mothing to Archive
if (aa.equals(MClient.AUTOARCHIVE_None))
return null;
// Archive External only
if (aa.equals(MClient.AUTOARCHIVE_ExternalDocuments)) {
if (info.isReport())
return null;
}
// Archive Documents only
if (aa.equals(MClient.AUTOARCHIVE_Documents)) {
if (info.isReport())
return null;
}
// Create Printable
// No Copy
byte[] data = Document.getPDFAsArray(layout.getPageable(false));
if (data == null)
return null;
// TODO to be done async
MArchive archive = new MArchive(layout.getCtx(), info, null);
archive.setBinaryData(data);
archive.saveEx();
return data;
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ArchiveViewer method updateVDisplay.
// updateQDisplay
/**
* Update View Display
* @param next show next Archive
*/
private void updateVDisplay(boolean next) {
if (m_archives == null)
m_archives = new MArchive[0];
if (next)
m_index++;
else
m_index--;
if (m_index >= m_archives.length - 1)
m_index = m_archives.length - 1;
if (m_index < 0)
m_index = 0;
bBack.setEnabled(m_index > 0);
bNext.setEnabled(m_index < m_archives.length - 1);
updateArchive.setEnabled(false);
//
log.info("Index=" + m_index + ", Length=" + m_archives.length);
if (m_archives.length == 0) {
positionInfo.setText("No Record Found");
createdByField.setText("");
createdField.setValue(null);
nameField.setText("");
descriptionField.setText("");
helpField.setText("");
pdfViewer.clearDocument();
return;
}
//
positionInfo.setText(m_index + 1 + " " + Msg.getMsg(Env.getCtx(), "of") + " " + m_archives.length);
MArchive ar = m_archives[m_index];
createdByField.setText(ar.getCreatedByName());
createdField.setValue(ar.getCreated());
nameField.setText(ar.getName());
descriptionField.setText(ar.getDescription());
helpField.setText(ar.getHelp());
//
try {
InputStream in = ar.getInputStream();
pdfViewer.setScale(reportField.isSelected() ? 50 : 75);
if (in != null)
pdfViewer.loadPDF(in);
else
pdfViewer.clearDocument();
} catch (Exception e) {
log.log(Level.SEVERE, "pdf", e);
pdfViewer.clearDocument();
}
}
use of org.compiere.model.MArchive in project adempiere by adempiere.
the class ZkReportViewer method cmd_archive.
// cmd_sendMail
/**
* Archive Report directly
*/
private void cmd_archive() {
boolean success = false;
// No Copy
byte[] data = Document.getPDFAsArray(m_reportEngine.getLayout().getPageable(false));
if (data != null) {
MArchive archive = new MArchive(Env.getCtx(), m_reportEngine.getPrintInfo(), null);
archive.setBinaryData(data);
success = archive.save();
}
if (success)
FDialog.info(m_WindowNo, this, "Archived");
else
FDialog.error(m_WindowNo, this, "ArchiveError");
}
Aggregations