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();
gridQuery.appendChild(rows);
Row row = new Row(); if(showQuery){
rows.appendChild(row); Grid gridQuery = new Grid();
row.setAlign("right"); gridQuery.setWidth("500px");
row.appendCellChild(reportField, 3); gridQuery.setStyle("margin:0; padding:0;");
gridQuery.makeNoStrip();
gridQuery.setOddRowSclass("even");
row = new Row(); rows = new Rows();
rows.appendChild(row); gridQuery.appendChild(rows);
Div div = new Div();
div.setStyle("text-align: right;");
div.appendChild(processLabel);
row.appendCellChild(div, 1);
row.appendCellChild(processField, 2);
processField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(bPartnerLabel);
row.appendCellChild(div, 1);
row.appendCellChild(bPartnerField.getComponent(), 2);
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(tableLabel);
row.appendCellChild(div, 1);
row.appendCellChild(tableField, 2);
tableField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(nameQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(nameQField, 2);
nameQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(descriptionQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(descriptionQField, 2);
descriptionQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(helpQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(helpQField, 2);
helpQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(createdByQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(createdByQField, 2);
createdByQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(createdQLabel);
row.appendChild(div);
row.appendChild(createdQFrom);
row.appendChild(createdQTo);
div = new Div();
div.setStyle("text-align: center;");
div.appendChild(gridQuery);
Tabpanel tabQueryPanel = new Tabpanel();
tabQueryPanel.appendChild(div);
Tab tabQuery = new Tab(Msg.getMsg(Env.getCtx(), "ViewerQuery")); row = new Row();
rows.appendChild(row);
row.setAlign("right");
row.appendCellChild(reportField, 3);
tabpanels.appendChild(tabQueryPanel); row = new Row();
tabs.appendChild(tabQuery); rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(processLabel);
row.appendCellChild(div, 1);
row.appendCellChild(processField, 2);
processField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(bPartnerLabel);
row.appendCellChild(div, 1);
row.appendCellChild(bPartnerField.getComponent(), 2);
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(tableLabel);
row.appendCellChild(div, 1);
row.appendCellChild(tableField, 2);
tableField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(nameQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(nameQField, 2);
nameQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(descriptionQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(descriptionQField, 2);
descriptionQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(helpQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(helpQField, 2);
helpQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(createdByQLabel);
row.appendCellChild(div, 1);
row.appendCellChild(createdByQField, 2);
createdByQField.setWidth("100%");
row = new Row();
rows.appendChild(row);
div = new Div();
div.setStyle("text-align: right;");
div.appendChild(createdQLabel);
row.appendChild(div);
row.appendChild(createdQFrom);
row.appendChild(createdQTo);
div = new Div();
div.setStyle("text-align: center;");
div.appendChild(gridQuery);
Tabpanel tabQueryPanel = new Tabpanel();
tabQueryPanel.appendChild(div);
Tab tabQuery = new Tab(Msg.getMsg(Env.getCtx(), "ViewerQuery"));
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;
} }