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,13 +123,20 @@ 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;
@Override
public void onPageAttached(Page newpage, Page oldpage) {
super.onPageAttached(newpage, oldpage);
if (newpage != null)
try {
dynInit(); dynInit();
jbInit(); jbInit();
} }
@ -136,6 +144,10 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
{ {
log.log(Level.SEVERE, "init", e); log.log(Level.SEVERE, "init", e);
} }
}
};
} }
/** /**
@ -221,23 +233,28 @@ 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);
Rows rows;
Row row;
Div div;
if(showQuery){
Grid gridQuery = new Grid(); Grid gridQuery = new Grid();
gridQuery.setWidth("500px"); gridQuery.setWidth("500px");
gridQuery.setStyle("margin:0; padding:0;"); gridQuery.setStyle("margin:0; padding:0;");
gridQuery.makeNoStrip(); gridQuery.makeNoStrip();
gridQuery.setOddRowSclass("even"); gridQuery.setOddRowSclass("even");
Rows rows = new Rows(); rows = new Rows();
gridQuery.appendChild(rows); gridQuery.appendChild(rows);
Row row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
row.setAlign("right"); row.setAlign("right");
row.appendCellChild(reportField, 3); row.appendCellChild(reportField, 3);
row = new Row(); row = new Row();
rows.appendChild(row); rows.appendChild(row);
Div div = new Div(); div = new Div();
div.setStyle("text-align: right;"); div.setStyle("text-align: right;");
div.appendChild(processLabel); div.appendChild(processLabel);
row.appendCellChild(div, 1); row.appendCellChild(div, 1);
@ -317,7 +334,7 @@ public class WArchiveViewer extends Archive implements IFormController, EventLis
tabpanels.appendChild(tabQueryPanel); tabpanels.appendChild(tabQueryPanel);
tabs.appendChild(tabQuery); 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;
Integer C_BPartner_ID = null;
String name = null;
String description = null;
String help = null;
KeyNamePair table = null;
KeyNamePair createdBy = null;
Timestamp createdFrom = null;
Timestamp createdTo = null;
if (showQuery) {
ListItem listitem = processField.getSelectedItem();
process = null;
if (listitem != null) if (listitem != null)
process = (KeyNamePair)listitem.getValue(); process = (KeyNamePair)listitem.getValue();
listitem = tableField.getSelectedItem(); listitem = tableField.getSelectedItem();
KeyNamePair table = null; table = null;
if (listitem != null) if (listitem != null)
table = (KeyNamePair)listitem.getValue(); table = (KeyNamePair)listitem.getValue();
Integer C_BPartner_ID = (Integer)bPartnerField.getValue(); C_BPartner_ID = (Integer)bPartnerField.getValue();
String name = nameQField.getText(); name = nameQField.getText();
String description = descriptionQField.getText(); description = descriptionQField.getText();
String help = helpQField.getText(); help = helpQField.getText();
listitem = createdByQField.getSelectedItem(); listitem = createdByQField.getSelectedItem();
KeyNamePair createdBy = null; createdBy = null;
if (listitem != null) if (listitem != null)
createdBy = (KeyNamePair)listitem.getValue(); createdBy = (KeyNamePair)listitem.getValue();
Date date = null; Date date = null;
Timestamp createdFrom = null; createdFrom = null;
if (createdQFrom.getValue() != null) if (createdQFrom.getValue() != null)
{ {
date = createdQFrom.getValue(); date = createdQFrom.getValue();
createdFrom = new Timestamp(date.getTime()); createdFrom = new Timestamp(date.getTime());
} }
Timestamp createdTo = null; createdTo = null;
if (createdQTo.getValue() != null) if (createdQTo.getValue() != null)
{ {
date = createdQTo.getValue(); date = createdQTo.getValue();
createdTo = new Timestamp(date.getTime()); 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;
} }