📄 wwindow.java
字号:
/**************************************************************************
* Return MultiRow Form details
* @param action action
* @param wsc session context
* @param ws window status
* @return Form
*/
private WebDoc getMR_Form (String action, WebSessionCtx wsc, WWindowStatus ws)
{
log.fine("Tab=" + ws.curTab.getTabNo());
int initRowNo = ws.curTab.getCurrentRow();
/**
* Table Header
*/
table table = new table().setAlign(AlignType.CENTER);
table.setClass("MultiRow");
table.setBorder(1);
table.setCellSpacing(1);
tr line = new tr();
// First Column
line.addElement(new th().addElement(" "));
// Tab not displayed
if (!ws.curTab.isDisplayed())
return createLayout (action, table, wsc, ws, "", "-");
int noFields = ws.curTab.getFieldCount();
// for all (header) columns
for (int colNo = 0; colNo < noFields; colNo++)
{
MField field = ws.curTab.getField(colNo);
if (field.isDisplayed(false))
{
th th = new th();
th.addElement(field.getHeader()); // Name
th.setAbbr(field.getDescription()); // Description
line.addElement(th);
}
} // for all columns
table.addElement(new thead().addElement(line));
/**
* Table Lines
*/
int lastRow = initRowNo + MAX_LINES;
lastRow = Math.min(lastRow, ws.curTab.getRowCount());
for (int lineNo = initRowNo; lineNo < lastRow; lineNo++)
{
// Row
ws.curTab.navigate(lineNo);
line = new tr();
// Selector
button selector = new button();
selector.addElement(">"); // displays ">"
selector.setOnClick("document." + FORM_NAME + "." + P_MR_RowNo + ".value='" + lineNo + "'; submit();");
line.addElement(new td().addElement(selector));
// for all columns
for (int colNo = 0; colNo < noFields; colNo++)
{
td td = new td();
//
MField field = ws.curTab.getField(colNo);
if (!field.isDisplayed(false))
continue;
// Get Data - turn to string
Object data = ws.curTab.getValue(field.getColumnName());
String info = null;
//
if (data == null)
info = "";
else
{
int dt = field.getDisplayType();
switch (dt)
{
case DisplayType.Date:
info = wsc.dateFormat.format(data);
td.setAlign("right");
break;
case DisplayType.DateTime:
info = wsc.dateTimeFormat.format(data);
td.setAlign("right");
break;
case DisplayType.Amount:
info = wsc.amountFormat.format(data);
td.setAlign("right");
break;
case DisplayType.Number:
case DisplayType.CostPrice:
info = wsc.numberFormat.format(data);
td.setAlign("right");
break;
case DisplayType.Quantity:
info = wsc.quantityFormat.format(data);
td.setAlign("right");
break;
case DisplayType.Integer:
info = wsc.integerFormat.format(data);
td.setAlign("right");
break;
case DisplayType.YesNo:
info = Msg.getMsg(ws.ctx, data.toString());
break;
/** @todo output formatting 2 */
default:
if (DisplayType.isLookup(dt))
info = field.getLookup().getDisplay(data);
else
info = data.toString();
}
}
// Empty info
if (info == null || info.length() == 0)
info = " "; // Space
//
td.addElement(info);
line.addElement(td);
} // for all columns
table.addElement(line);
} // for all table lines
// Status Line
String statusDB = String.valueOf(initRowNo+1) + "-" + String.valueOf(lastRow) + " # " + ws.curTab.getRowCount();
return createLayout (action, table, wsc, ws, "", statusDB);
} // getMR_Form
/**
* Create Window Layout.
* @param action form action
* @param contentTable content table
* @param wsc web session context
* @param ws window status
* @param statusInfo status line info
* @param statusDB status db info
* @return Form
*/
private static WebDoc createLayout (String action, table contentTable,
WebSessionCtx wsc, WWindowStatus ws, String statusInfo, String statusDB)
{
form myForm = null;
myForm = new form(action);
myForm.setTarget(WebEnv.TARGET_WINDOW);
myForm.setID("WWindow" + ws.mWindow.getAD_Window_ID());
String AD_Language = Env.getAD_Language(ws.ctx);
// Window
myForm.setName(FORM_NAME);
myForm.addElement(new input("hidden", P_Command, "")); // button commands
myForm.addElement(new input("hidden", P_MR_RowNo, "")); // RowNo
myForm.addElement(new input("hidden", P_ChangedColumn, "")); //
// Set Title of main window
String title = ws.mWindow.getName() + " - " + wsc.loginInfo;
myForm.addElement(new script("top.document.title='" + title + "';"));
// Buttons
td toolbar = new td(null, AlignType.LEFT, AlignType.MIDDLE, true);
// Toolbar
toolbar.addElement(createImage(AD_Language, "Ignore",
"reset();", true, false));
toolbar.addElement(" ");
toolbar.addElement(createImage(AD_Language, "Help",
"startPopup('WHelp?AD_Window_ID=" + ws.mWindow.getAD_Window_ID() + "');",
true, false));
toolbar.addElement(createImage(AD_Language, "New"));
toolbar.addElement(createImage(AD_Language, "Delete",
"if (confirm(deleteText)) submit();", true, false));
toolbar.addElement(createImage(AD_Language, "Save"));
toolbar.addElement(" ");
toolbar.addElement(createImage(AD_Language, "Find"));
toolbar.addElement(createImage(AD_Language, "Refresh"));
toolbar.addElement(createImage(AD_Language, "Attachment",
"startPopup('WAttachment');",
ws.curTab.canHaveAttachment(), ws.curTab.hasAttachment()));
toolbar.addElement(createImage(AD_Language, "Multi", null, true, !ws.curTab.isSingleRow()));
toolbar.addElement(" ");
toolbar.addElement(createImage(AD_Language, "History",
null, ws.mWindow.isTransaction()&&ws.curTab.getTabNo()==0, !ws.curTab.isOnlyCurrentRows()));
toolbar.addElement(" ");
boolean isFirst = ws.curTab.getCurrentRow() < 1;
toolbar.addElement(createImage(AD_Language, "First", null, !isFirst, false));
toolbar.addElement(createImage(AD_Language, "Previous", null, !isFirst, false));
boolean isLast = ws.curTab.getCurrentRow()+1 == ws.curTab.getRowCount();
toolbar.addElement(createImage(AD_Language, "Next", null, !isLast, false));
toolbar.addElement(createImage(AD_Language, "Last", null, !isLast, false));
toolbar.addElement(" ");
toolbar.addElement(createImage(AD_Language, "Report"));
toolbar.addElement(createImage(AD_Language, "Print"));
toolbar.addElement(" ");
toolbar.addElement(createImage(AD_Language, "Exit"));
// Tabs
td tabbar = new td("windowCenter", AlignType.LEFT, AlignType.MIDDLE, false);
tabbar.addElement(new input(input.TYPE_HIDDEN, P_Tab, ""));
for (int i = 0; i < ws.mWindow.getTabCount(); i++)
{
MTab tab = ws.mWindow.getTab(i);
if (tab.isSortTab())
continue;
big big = new big(tab.getName());
if (ws.curTab.getTabNo() == i)
big.setID("tabSelected"); // css
else
{
big.setID("tab"); // css
big.setOnClick("alert('" + tab.getName() + "');");
big.setOnClick("document." + FORM_NAME + "." + P_Tab + ".value='" + i + "';submit();");
}
// Status: Description
if (tab.getDescription().length() > 0)
big.setOnMouseOver("status='" + tab.getDescription() + "';return true;");
tabbar.addElement(big);
}
// Top Table
table topTable = new table ("0", "0", "5", "100%", null);
topTable.setID("WWindow.topTable");
topTable.addElement(new tr(toolbar));
topTable.addElement(new tr(tabbar));
myForm.addElement(topTable);
// Fields
myForm.addElement(contentTable);
// Status Line
table statusTable = new table ("0", "0", "0", "100%", null);
topTable.setID("WWindow.statusLine");
tr statusLine = new tr();
statusLine.addElement(new td().setWidth("85%").setAlign(AlignType.LEFT)
.addElement(statusInfo));
statusLine.addElement(new td().setWidth("10%").setAlign(AlignType.RIGHT)
.addElement(new small(statusDB)));
statusLine.addElement(new td().setWidth("5%").setAlign(AlignType.RIGHT)
.addElement(createImage(AD_Language, "Save")));
statusTable.addElement(statusLine).setClass("windowCenter");
myForm.addElement(statusTable);
// fini
/** @todo Dynamic Display */
// myForm.addElement(new script("dynDisplay(); createWCmd();")); // initial Display & set Cmd Window
WebDoc doc = createPage(ws);
// Main Table
doc.getTable().addElement(new tr()
.addElement(
new td(null, AlignType.CENTER, AlignType.MIDDLE,
true, myForm).setColSpan(2)));
//
return doc;
} // createLayout
/**
* Create Page.
* - Set Header
* @param ws status
* @return WDoc page
*/
private static WebDoc createPage (WWindowStatus ws)
{
WebDoc doc = WebDoc.createWindow (ws.mWindow.getName());
// Set Variables
doc.getBody().addElement(
new script("deleteText='" + Msg.getMsg(ws.ctx, "DeleteRecord?") + "';"));
//
return doc;
} // createPage
/**************************************************************************
* Create Image with name, id of button_name and set P_Command onClick
* @param AD_Language
* @param name Name of the Image used also for Name24.gif
* @param js_command Java script command, null results in 'submit();', an empty string disables OnClick
* @param enabled Enable the immage button, if not uses the "D" image
* @param pressed If true, use the "X" image
* @return Image
*/
private static img createImage (String AD_Language, String name, String js_command, boolean enabled, boolean pressed)
{
StringBuffer imgName = new StringBuffer(name);
if (!enabled)
imgName.append("D");
else if (pressed)
imgName.append("X");
imgName.append("24.gif");
//
img img = new img (WebEnv.getImageDirectory(imgName.toString()), name);
if (enabled)
img.setAlt(Msg.getMsg(AD_Language, name)); // Translate ToolTip
//
if (!pressed || !enabled)
img.setID("imgButton"); // css
else
img.setID("imgButtonPressed"); // css
//
if (js_command == null)
js_command = "submit();";
if (js_command.length() > 0 && enabled)
img.setOnClick("document." + FORM_NAME + "." + P_Command + ".value='" + name + "';" + js_command);
//
return img;
} // createImage
/**
* Create enabled Image with name, id of button_name and sumbit command
* @param AD_Language
* @param name Name of the Image used also for Name24.gif
* @return Image
*/
private static img createImage (String AD_Language, String name)
{
return createImage (AD_Language, name, null, true, false);
} // createImage
/**************************************************************************
* Add Field to Line
* @param wsc session context
* @param line format element
* @param field field
* @param oData original data
* @param hasDependents has Callout function(s)
*/
private void addField (WebSessionCtx wsc, tr line, MField field,
Object oData, boolean hasDependents)
{
String columnName = field.getColumnName();
// Any Error?
boolean error = field.isErrorValue();
if (error)
oData = field.getErrorValue();
int dt = field.getDisplayType();
boolean hasCallout = field.getCallout().length() > 0;
/**
* HTML Label Element
* ID = ID_columnName
*
* HTML Input Elements
* NAME = columnName
* ID = ID_columnName
*/
WebField wField = new WebField (wsc,
columnName, field.getHeader(), field.getDescription(),
dt, field.getFieldLength(), field.getDisplayLength(), field.isLongField(),
// readOnly context check, mandatory no context check,
!field.isEditable(true), field.isMandatory(false), error,
hasDependents, hasCallout);
line
.addElement(wField.getLabel())
.addElement(wField.getField(field.getLookup(), oData));
} // addField
} // WWindow
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -