IDEMPIERE-556 Archive Viewer must not allow search when arriving from button

This commit is contained in:
Diego Ruiz 2013-03-01 17:00:24 -05:00
parent a36ed8d030
commit eb26659562
2 changed files with 173 additions and 137 deletions

View File

@ -158,6 +158,7 @@ public class WArchive implements EventListener<Event>
ADForm form = ADForm.openForm(AD_Form_ID); ADForm form = ADForm.openForm(AD_Form_ID);
WArchiveViewer av = (WArchiveViewer) form.getICustomForm(); WArchiveViewer av = (WArchiveViewer) form.getICustomForm();
av.setShowQuery(false);
if (e.getTarget() == m_documents) if (e.getTarget() == m_documents)
av.query(false, m_AD_Table_ID, m_Record_ID); av.query(false, m_AD_Table_ID, m_Record_ID);
else if (e.getTarget() == m_reports) else if (e.getTarget() == m_reports)

View File

@ -59,6 +59,7 @@ import org.compiere.util.Env;
import org.compiere.util.KeyNamePair; import org.compiere.util.KeyNamePair;
import org.compiere.util.Msg; import org.compiere.util.Msg;
import org.zkoss.util.media.AMedia; import org.zkoss.util.media.AMedia;
import org.zkoss.zk.ui.Page;
import org.zkoss.zk.ui.event.Event; import org.zkoss.zk.ui.event.Event;
import org.zkoss.zk.ui.event.EventListener; import org.zkoss.zk.ui.event.EventListener;
import org.zkoss.zk.ui.event.Events; import org.zkoss.zk.ui.event.Events;
@ -122,20 +123,31 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
private Iframe iframe = new Iframe(); private Iframe iframe = new Iframe();
private Button bRefresh = new Button(); private Button bRefresh = new Button();
private boolean showQuery = true;
public WArchiveViewer() public WArchiveViewer()
{ {
log.info(""); log.info("");
try form = new CustomForm() {
{ private static final long serialVersionUID = 7226661630651936293L;
dynInit();
jbInit(); @Override
} public void onPageAttached(Page newpage, Page oldpage) {
catch(Exception e) super.onPageAttached(newpage, oldpage);
{ if (newpage != null)
log.log(Level.SEVERE, "init", e); try {
} dynInit();
jbInit();
}
catch(Exception e)
{
log.log(Level.SEVERE, "init", e);
}
}
};
} }
/** /**
@ -221,103 +233,108 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
reportField.setLabel(Msg.translate(Env.getCtx(), "IsReport")); reportField.setLabel(Msg.translate(Env.getCtx(), "IsReport"));
reportField.addEventListener(Events.ON_CHECK, this); reportField.addEventListener(Events.ON_CHECK, this);
Grid gridQuery = new Grid(); Rows rows;
gridQuery.setWidth("500px"); Row row;
gridQuery.setStyle("margin:0; padding:0;"); Div div;
gridQuery.makeNoStrip();
gridQuery.setOddRowSclass("even");
Rows rows = new Rows(); if(showQuery){
gridQuery.appendChild(rows); Grid gridQuery = new Grid();
gridQuery.setWidth("500px");
gridQuery.setStyle("margin:0; padding:0;");
gridQuery.makeNoStrip();
gridQuery.setOddRowSclass("even");
Row row = new Row(); rows = new Rows();
rows.appendChild(row); gridQuery.appendChild(rows);
row.setAlign("right");
row.appendCellChild(reportField, 3);
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
Div div = new Div(); row.setAlign("right");
div.setStyle("text-align: right;"); row.appendCellChild(reportField, 3);
div.appendChild(processLabel);
row.appendCellChild(div, 1);
row.appendCellChild(processField, 2);
processField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(bPartnerLabel); div.appendChild(processLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(bPartnerField.getComponent(), 2); row.appendCellChild(processField, 2);
processField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(tableLabel); div.appendChild(bPartnerLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(tableField, 2); row.appendCellChild(bPartnerField.getComponent(), 2);
tableField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(nameQLabel); div.appendChild(tableLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(nameQField, 2); row.appendCellChild(tableField, 2);
nameQField.setWidth("100%"); tableField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(descriptionQLabel); div.appendChild(nameQLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(descriptionQField, 2); row.appendCellChild(nameQField, 2);
descriptionQField.setWidth("100%"); nameQField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(helpQLabel); div.appendChild(descriptionQLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(helpQField, 2); row.appendCellChild(descriptionQField, 2);
helpQField.setWidth("100%"); descriptionQField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(createdByQLabel); div.appendChild(helpQLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
row.appendCellChild(createdByQField, 2); row.appendCellChild(helpQField, 2);
createdByQField.setWidth("100%"); helpQField.setWidth("100%");
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(createdQLabel); div.appendChild(createdByQLabel);
row.appendChild(div); row.appendCellChild(div, 1);
row.appendChild(createdQFrom); row.appendCellChild(createdByQField, 2);
row.appendChild(createdQTo); createdByQField.setWidth("100%");
div = new Div(); row = new Row();
div.setStyle("text-align: center;"); rows.appendChild(row);
div.appendChild(gridQuery); div = new Div();
div.setStyle("text-align: right;");
div.appendChild(createdQLabel);
row.appendChild(div);
row.appendChild(createdQFrom);
row.appendChild(createdQTo);
Tabpanel tabQueryPanel = new Tabpanel(); div = new Div();
tabQueryPanel.appendChild(div); div.setStyle("text-align: center;");
div.appendChild(gridQuery);
Tab tabQuery = new Tab(Msg.getMsg(Env.getCtx(), "ViewerQuery")); Tabpanel tabQueryPanel = new Tabpanel();
tabQueryPanel.appendChild(div);
tabpanels.appendChild(tabQueryPanel); Tab tabQuery = new Tab(Msg.getMsg(Env.getCtx(), "ViewerQuery"));
tabs.appendChild(tabQuery);
tabpanels.appendChild(tabQueryPanel);
tabs.appendChild(tabQuery);
}
Grid gridView = new Grid(); Grid gridView = new Grid();
gridView.setStyle("margin:0; padding:0;"); gridView.setStyle("margin:0; padding:0;");
gridView.makeNoStrip(); gridView.makeNoStrip();
@ -450,10 +467,10 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
SessionManager.getAppDesktop().closeActiveWindow(); SessionManager.getAppDesktop().closeActiveWindow();
else if (e.getTarget().getId().equals(ConfirmPanel.A_OK)) else if (e.getTarget().getId().equals(ConfirmPanel.A_OK))
{ {
if (tabbox.getSelectedIndex() == 1) if (showQuery && tabbox.getSelectedIndex() == 0)
SessionManager.getAppDesktop().closeActiveWindow();
else
cmd_query(); cmd_query();
else
SessionManager.getAppDesktop().closeActiveWindow();
} }
else if (e.getTarget() == reportField) else if (e.getTarget() == reportField)
updateQDisplay(); updateQDisplay();
@ -465,7 +482,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
iframe.invalidate(); iframe.invalidate();
else if (e.getTarget() instanceof Tab) else if (e.getTarget() instanceof Tab)
{ {
if(tabbox.getSelectedIndex() == 1) if(tabbox.getSelectedIndex() == (showQuery ? 1 : 0))
iframe.invalidate(); iframe.invalidate();
} }
@ -504,6 +521,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
MArchive ar = m_archives[m_index]; MArchive ar = m_archives[m_index];
ar.delete(true); ar.delete(true);
tabbox.setSelectedIndex(0); tabbox.setSelectedIndex(0);
cmd_query();
dynInit(); dynInit();
} }
} }
@ -639,51 +657,68 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
{ {
boolean reports = reportField.isChecked(); boolean reports = reportField.isChecked();
ListItem listitem = processField.getSelectedItem();
KeyNamePair process = null; KeyNamePair process = null;
if (listitem != null) Integer C_BPartner_ID = null;
process = (KeyNamePair)listitem.getValue(); String name = null;
String description = null;
listitem = tableField.getSelectedItem(); String help = null;
KeyNamePair table = null; KeyNamePair table = null;
if (listitem != null)
table = (KeyNamePair)listitem.getValue();
Integer C_BPartner_ID = (Integer)bPartnerField.getValue();
String name = nameQField.getText();
String description = descriptionQField.getText();
String help = helpQField.getText();
listitem = createdByQField.getSelectedItem();
KeyNamePair createdBy = null; KeyNamePair createdBy = null;
if (listitem != null)
createdBy = (KeyNamePair)listitem.getValue();
Date date = null;
Timestamp createdFrom = null; Timestamp createdFrom = null;
if (createdQFrom.getValue() != null)
{
date = createdQFrom.getValue();
createdFrom = new Timestamp(date.getTime());
}
Timestamp createdTo = null; Timestamp createdTo = null;
if (createdQTo.getValue() != null)
{ if (showQuery) {
date = createdQTo.getValue(); ListItem listitem = processField.getSelectedItem();
createdTo = new Timestamp(date.getTime()); process = null;
if (listitem != null)
process = (KeyNamePair)listitem.getValue();
listitem = tableField.getSelectedItem();
table = null;
if (listitem != null)
table = (KeyNamePair)listitem.getValue();
C_BPartner_ID = (Integer)bPartnerField.getValue();
name = nameQField.getText();
description = descriptionQField.getText();
help = helpQField.getText();
listitem = createdByQField.getSelectedItem();
createdBy = null;
if (listitem != null)
createdBy = (KeyNamePair)listitem.getValue();
Date date = null;
createdFrom = null;
if (createdQFrom.getValue() != null)
{
date = createdQFrom.getValue();
createdFrom = new Timestamp(date.getTime());
}
createdTo = null;
if (createdQTo.getValue() != null)
{
date = createdQTo.getValue();
createdTo = new Timestamp(date.getTime());
}
} }
cmd_query(reports, process, table, C_BPartner_ID, name, description, help, cmd_query(reports, process, table, C_BPartner_ID, name, description, help,
createdBy, createdFrom, createdTo); createdBy, createdFrom, createdTo);
// Display
tabbox.setSelectedIndex(1);
m_index = 1; m_index = 1;
if (showQuery)
tabbox.setSelectedIndex(1);
updateVDisplay(false); updateVDisplay(false);
} // cmd_query } // cmd_query
public void setShowQuery(boolean showQuery) {
this.showQuery = showQuery;
}
public ADForm getForm() { public ADForm getForm() {
return form; return form;
} }