IDEMPIERE-142 Zk6 Port. Fixed layout for find window.
This commit is contained in:
parent
8bf2eb7614
commit
ba7a432b62
|
@ -35,6 +35,8 @@ import java.util.regex.Pattern;
|
|||
import org.adempiere.webui.LayoutUtils;
|
||||
import org.adempiere.webui.apps.AEnv;
|
||||
import org.adempiere.webui.component.Button;
|
||||
import org.adempiere.webui.component.Column;
|
||||
import org.adempiere.webui.component.Columns;
|
||||
import org.adempiere.webui.component.Combobox;
|
||||
import org.adempiere.webui.component.Grid;
|
||||
import org.adempiere.webui.component.Label;
|
||||
|
@ -47,7 +49,6 @@ import org.adempiere.webui.component.Panel;
|
|||
import org.adempiere.webui.component.Row;
|
||||
import org.adempiere.webui.component.Rows;
|
||||
import org.adempiere.webui.component.Tabpanel;
|
||||
import org.adempiere.webui.component.Textbox;
|
||||
import org.adempiere.webui.component.ToolBar;
|
||||
import org.adempiere.webui.component.ToolBarButton;
|
||||
import org.adempiere.webui.component.Window;
|
||||
|
@ -96,7 +97,7 @@ import org.zkoss.zul.Hbox;
|
|||
* @author Sendy Yagambrum
|
||||
* @date June 27, 2007
|
||||
*/
|
||||
public class FindWindow extends Window implements EventListener,ValueChangeListener
|
||||
public class FindWindow extends Window implements EventListener<Event>,ValueChangeListener
|
||||
{
|
||||
/**
|
||||
*
|
||||
|
@ -109,16 +110,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
/** Advanced Window Tab */
|
||||
private Window winAdvanced;
|
||||
//
|
||||
private Label lblDocumentNo;
|
||||
private Label lblDescription;
|
||||
private Label lblName;
|
||||
private Label lblValue;
|
||||
//
|
||||
private Textbox fieldDocumentNo;
|
||||
private Textbox fieldDescription;
|
||||
private Textbox fieldName;
|
||||
private Textbox fieldValue;
|
||||
//
|
||||
private Combobox fQueryName;
|
||||
//
|
||||
private Listbox advancedPanel;
|
||||
|
@ -144,10 +135,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
private int m_total;
|
||||
private PreparedStatement m_pstmt;
|
||||
//
|
||||
private boolean hasValue = false;
|
||||
private boolean hasDocNo = false;
|
||||
private boolean hasName = false;
|
||||
private boolean hasDescription = false;
|
||||
/** List of WEditors */
|
||||
private ArrayList<WEditor> m_sEditors = new ArrayList<WEditor>();
|
||||
/** Target Fields with AD_Column_ID as key */
|
||||
|
@ -162,10 +149,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
private int m_AD_Tab_ID = 0;
|
||||
private MUserQuery[] userQueries;
|
||||
private Rows contentSimpleRows;
|
||||
private Row pnlDocument;
|
||||
private Row pnlDescription;
|
||||
private Row pnlValue;
|
||||
private Row pnlName;
|
||||
private boolean m_createNew = false;
|
||||
|
||||
/** Index ColumnName = 0 */
|
||||
|
@ -235,32 +218,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
**/
|
||||
private void initSimple()
|
||||
{
|
||||
lblDocumentNo = new Label();
|
||||
lblDocumentNo.setValue(Msg.translate(Env.getCtx(),"DocumentNo").replaceAll("&", ""));
|
||||
|
||||
lblDescription = new Label();
|
||||
lblDescription.setValue(Msg.translate(Env.getCtx(),"Description").replaceAll("&", ""));
|
||||
|
||||
lblName = new Label();
|
||||
lblName.setValue(Msg.translate(Env.getCtx(),"Name").replaceAll("&", ""));
|
||||
|
||||
lblValue = new Label();
|
||||
lblValue.setValue(Msg.translate(Env.getCtx(),"Value").replaceAll("&", ""));
|
||||
|
||||
fieldDocumentNo = new Textbox();
|
||||
fieldDocumentNo.setId("fieldDocumentNo");
|
||||
fieldDocumentNo.setMaxlength(40);
|
||||
|
||||
fieldDescription = new Textbox();
|
||||
fieldDescription.setId("fieldDescription");
|
||||
fieldDescription.setMaxlength(40);
|
||||
|
||||
fieldName = new Textbox();
|
||||
fieldName.setMaxlength(40);
|
||||
|
||||
fieldValue = new Textbox();
|
||||
fieldValue.setMaxlength(40);
|
||||
|
||||
Button btnNew = new Button();
|
||||
btnNew.setName("btnNew");
|
||||
btnNew.setImage("/images/New24.png");
|
||||
|
@ -295,35 +252,28 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
hboxButton.appendChild(pnlButtonRight);
|
||||
hboxButton.setWidth("100%");
|
||||
|
||||
pnlDocument = new Row();
|
||||
pnlDocument.setId("pnlDocument");
|
||||
pnlDocument.appendChild(LayoutUtils.makeRightAlign(lblDocumentNo));
|
||||
pnlDocument.appendChild(fieldDocumentNo);
|
||||
|
||||
pnlDescription = new Row();
|
||||
pnlDescription.appendChild(LayoutUtils.makeRightAlign(lblDescription));
|
||||
pnlDescription.appendChild(fieldDescription);
|
||||
|
||||
pnlValue = new Row();
|
||||
pnlValue.appendChild(LayoutUtils.makeRightAlign(lblValue));
|
||||
pnlValue.appendChild(fieldValue);
|
||||
|
||||
pnlName = new Row();
|
||||
pnlName.appendChild(LayoutUtils.makeRightAlign(lblName));
|
||||
pnlName.appendChild(fieldName);
|
||||
|
||||
contentSimple = new Grid();
|
||||
contentSimple.setId("contentSimple");
|
||||
contentSimple.setWidth("100%");
|
||||
contentSimple.setStyle("width: 100%; position: relative");
|
||||
contentSimple.makeNoStrip();
|
||||
contentSimple.setHflex("1");
|
||||
contentSimple.setSizedByContent(true);
|
||||
|
||||
Columns columns = new Columns();
|
||||
Column column = new Column();
|
||||
column.setAlign("right");
|
||||
column.setWidth("30%");
|
||||
columns.appendChild(column);
|
||||
|
||||
column = new Column();
|
||||
column.setAlign("left");
|
||||
column.setWidth("70%");
|
||||
columns.appendChild(column);
|
||||
|
||||
contentSimple.appendChild(columns);
|
||||
|
||||
contentSimpleRows = new Rows();
|
||||
contentSimple.appendChild(contentSimpleRows);
|
||||
|
||||
contentSimpleRows.appendChild(pnlValue);
|
||||
contentSimpleRows.appendChild(pnlName);
|
||||
contentSimpleRows.appendChild(pnlDocument);
|
||||
contentSimpleRows.appendChild(pnlDescription);
|
||||
contentSimple.setVflex(true);
|
||||
|
||||
Borderlayout layout = new Borderlayout();
|
||||
|
@ -393,7 +343,7 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
Panel pnlButtonRight = new Panel();
|
||||
pnlButtonRight.appendChild(btnOk);
|
||||
pnlButtonRight.appendChild(btnCancel);
|
||||
pnlButtonRight.setAlign("right");
|
||||
pnlButtonRight.setStyle("text-align: right");
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.appendChild(btnNew);
|
||||
|
@ -410,23 +360,24 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
confirmPanel.setWidth("100%");
|
||||
|
||||
advancedPanel = new Listbox();
|
||||
advancedPanel.setSizedByContent(true);
|
||||
ListHead listhead = new ListHead();
|
||||
listhead.setSizable(true);
|
||||
|
||||
ListHeader lstHColumn = new ListHeader();
|
||||
lstHColumn.setLabel(Msg.translate(Env.getCtx(), "AD_Column_ID"));
|
||||
lstHColumn.setWidth("100px");
|
||||
lstHColumn.setWidth("250px");
|
||||
|
||||
ListHeader lstHOperator = new ListHeader();
|
||||
lstHOperator.setLabel(Msg.getMsg(Env.getCtx(), "Operator"));
|
||||
|
||||
ListHeader lstHQueryValue = new ListHeader();
|
||||
lstHQueryValue.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue"));
|
||||
lstHQueryValue.setWidth("210px");
|
||||
lstHQueryValue.setWidth("200px");
|
||||
|
||||
ListHeader lstHQueryTo = new ListHeader();
|
||||
lstHQueryTo.setLabel(Msg.getMsg(Env.getCtx(), "QueryValue2"));
|
||||
lstHQueryTo.setWidth("210px");
|
||||
lstHQueryTo.setWidth("200px");
|
||||
|
||||
listhead.appendChild(lstHColumn);
|
||||
listhead.appendChild(lstHOperator);
|
||||
|
@ -494,7 +445,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
for (int i = 0; i < m_findFields.length; i++)
|
||||
{
|
||||
GridField mField = m_findFields[i];
|
||||
String columnName = mField.getColumnName();
|
||||
|
||||
// Make Yes-No searchable as list
|
||||
if (mField.getVO().displayType == DisplayType.YesNo)
|
||||
|
@ -540,42 +490,13 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
}
|
||||
}
|
||||
|
||||
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||
if (columnName.equals("Value"))
|
||||
hasValue = true;
|
||||
else if (columnName.equals("Name"))
|
||||
hasName = true;
|
||||
else if (columnName.equals("DocumentNo"))
|
||||
hasDocNo = true;
|
||||
else if (columnName.equals("Description"))
|
||||
hasDescription = true;
|
||||
else
|
||||
/**/
|
||||
if (mField.isSelectionColumn())
|
||||
addSelectionColumn (mField);
|
||||
/** metas: teo_sarca: Specify exactly which are the search fields - http://sourceforge.net/projects/adempiere/forums/forum/610548/topic/3736214
|
||||
else if (columnName.indexOf("Name") != -1)
|
||||
addSelectionColumn (mField);
|
||||
/**/
|
||||
|
||||
// TargetFields
|
||||
m_targetFields.put (new Integer(mField.getAD_Column_ID()), mField);
|
||||
} // for all target tab fields
|
||||
|
||||
// Disable simple query fields
|
||||
pnlValue.setVisible(hasValue);
|
||||
if (hasValue)
|
||||
fieldValue.addEventListener(Events.ON_CHANGE,this);
|
||||
pnlDocument.setVisible(hasDocNo);
|
||||
if (hasDocNo)
|
||||
fieldDocumentNo.addEventListener(Events.ON_CHANGE,this);
|
||||
pnlName.setVisible(hasName);
|
||||
if (hasName)
|
||||
fieldName.addEventListener(Events.ON_CHANGE,this);
|
||||
pnlDescription.setVisible(hasDescription);
|
||||
if (hasDescription)
|
||||
fieldDescription.addEventListener(Events.ON_CHANGE,this);
|
||||
|
||||
m_total = getNoOfRecords(null, false);
|
||||
|
||||
} // initFind
|
||||
|
@ -597,7 +518,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
private void createFields()
|
||||
{
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setWidth("100%");
|
||||
|
||||
Listbox listColumn = new Listbox();
|
||||
listColumn.setId("listColumn"+listItem.getId());
|
||||
|
@ -738,8 +658,9 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
editor.setMandatory(false);
|
||||
editor.setReadWrite(true);
|
||||
editor.dynamicDisplay();
|
||||
editor.fillHorizontal();
|
||||
Label label = editor.getLabel();
|
||||
Component fieldLabel = editor.getComponent();
|
||||
Component fieldEditor = editor.getComponent();
|
||||
|
||||
//
|
||||
if (displayLength > 0) // set it back
|
||||
|
@ -747,13 +668,13 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
//
|
||||
|
||||
Row panel = new Row();
|
||||
panel.appendChild(LayoutUtils.makeRightAlign(label));
|
||||
panel.appendChild(fieldLabel);
|
||||
panel.appendChild(label);
|
||||
panel.appendChild(fieldEditor);
|
||||
|
||||
contentSimpleRows.appendChild(panel);
|
||||
m_sEditors.add(editor);
|
||||
|
||||
fieldLabel.addEventListener(Events.ON_OK,this);
|
||||
fieldEditor.addEventListener(Events.ON_OK,this);
|
||||
} // addSelectionColumn
|
||||
|
||||
public void onEvent(Event event) throws Exception
|
||||
|
@ -881,7 +802,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
String[] fields = segments[i].split(Pattern.quote(FIELD_SEPARATOR));
|
||||
|
||||
ListItem listItem = new ListItem();
|
||||
listItem.setWidth("100%");
|
||||
advancedPanel.appendChild(listItem);
|
||||
|
||||
Listbox listColumn = new Listbox();
|
||||
|
@ -1308,40 +1228,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
// Create Query String
|
||||
m_query = new MQuery(m_tableName);
|
||||
m_query.addRestriction(Env.parseContext(Env.getCtx(), m_targetWindowNo, m_whereExtended, false));
|
||||
if (hasValue && !fieldValue.getText().equals("%") && fieldValue.getText().length() != 0)
|
||||
{
|
||||
String value = fieldValue.getText().toUpperCase();
|
||||
|
||||
if (!value.endsWith("%"))
|
||||
value += "%";
|
||||
m_query.addRestriction("UPPER(Value)", MQuery.LIKE, value, lblValue.getValue(), value);
|
||||
}
|
||||
//
|
||||
if (hasDocNo && !fieldDocumentNo.getText().equals("%") && fieldDocumentNo.getText().length() != 0)
|
||||
{
|
||||
String value = fieldDocumentNo.getText().toUpperCase();
|
||||
|
||||
if (!value.endsWith("%"))
|
||||
value += "%";
|
||||
m_query.addRestriction("UPPER(DocumentNo)", MQuery.LIKE, value, lblDocumentNo.getValue(),value);
|
||||
}
|
||||
//
|
||||
if ((hasName) && !fieldName.getText().equals("%") && fieldName.getText().length() != 0)
|
||||
{
|
||||
String value = fieldName.getText().toUpperCase();
|
||||
|
||||
if (!value.endsWith("%"))
|
||||
value += "%";
|
||||
m_query.addRestriction("UPPER(Name)", MQuery.LIKE, value, lblName.getValue(), value);
|
||||
}
|
||||
//
|
||||
if (hasDescription && !fieldDescription.getText().equals("%") && fieldDescription.getText().length() != 0)
|
||||
{
|
||||
String value = fieldDescription.getText().toUpperCase();
|
||||
if (!value.endsWith("%"))
|
||||
value += "%";
|
||||
m_query.addRestriction("UPPER(Description)", MQuery.LIKE, value, lblDescription.getValue(), value);
|
||||
}
|
||||
// Special Editors
|
||||
for (int i = 0; i < m_sEditors.size(); i++)
|
||||
{
|
||||
|
@ -1781,13 +1667,6 @@ public class FindWindow extends Window implements EventListener,ValueChangeListe
|
|||
}
|
||||
|
||||
public void OnPostVisible() {
|
||||
if (hasDocNo)
|
||||
Clients.response(new AuFocus(fieldDocumentNo));
|
||||
else if (hasValue)
|
||||
Clients.response(new AuFocus(fieldValue));
|
||||
else if (hasName)
|
||||
Clients.response(new AuFocus(fieldName));
|
||||
else if (m_sEditors.size() > 0 && m_sEditors.get(0) != null)
|
||||
Clients.response(new AuFocus(m_sEditors.get(0).getComponent()));
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue