use of org.compiere.process.DocOptions in project adempiere by adempiere.
the class VDocAction method dynInit.
// jbInit
/**
* Dynamic Init - determine valid DocActions based on DocStatus for the different documents.
* <pre>
* DocStatus (131)
?? Unknown
AP * Approved
CH Changed
CL * Closed
CO * Completed
DR Drafted
IN Inactive
NA Not Approved
PE Posting Error
PO * Posted
PR * Printed
RE Reversed
TE Transfer Error
TR * Transferred
VO * Voided
XX Being Processed
*
* DocAction (135)
-- <None>
AP * Approve
CL * Close
CO * Complete
PO * Post
PR * Print
RA Reverse - Accrual
RC Reverse - Correction
RE RE-activate
RJ Reject
TR * Transfer
VO * Void
XL Unlock
* </pre>
* @param Record_ID id
*/
private void dynInit(int Record_ID) {
String DocStatus = (String) m_mTab.getValue("DocStatus");
String DocAction = (String) m_mTab.getValue("DocAction");
//
Object Processing = m_mTab.getValue("Processing");
String OrderType = Env.getContext(Env.getCtx(), m_WindowNo, "OrderType");
String IsSOTrx = Env.getContext(Env.getCtx(), m_WindowNo, "IsSOTrx");
if (DocStatus == null) {
message.setText("*** ERROR ***");
return;
}
log.fine("DocStatus=" + DocStatus + ", DocAction=" + DocAction + ", OrderType=" + OrderType + ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing + ", AD_Table_ID=" + m_AD_Table_ID + ", Record_ID=" + Record_ID);
//
String[] options = new String[s_value.length];
int index = 0;
/**
* Check Existence of Workflow Activities
*/
String wfStatus = MWFActivity.getActiveInfo(Env.getCtx(), m_AD_Table_ID, Record_ID);
if (wfStatus != null) {
ADialog.error(m_WindowNo, this, "WFActiveForRecord", wfStatus);
return;
}
// Status Change
if (!checkStatus(m_mTab.getTableName(), Record_ID, DocStatus)) {
ADialog.error(m_WindowNo, this, "DocumentStatusChanged");
return;
}
/*******************
* General Actions
*/
String[] docActionHolder = new String[] { DocAction };
index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options);
MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID);
PO po = table.getPO(Record_ID, null);
if (po instanceof DocOptions)
index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options, index);
Integer doctypeId = (Integer) m_mTab.getValue("C_DocType_ID");
if (doctypeId == null || doctypeId.intValue() == 0) {
doctypeId = (Integer) m_mTab.getValue("C_DocTypeTarget_ID");
}
log.fine("get doctype: " + doctypeId);
if (doctypeId != null) {
index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()), doctypeId, options, index);
}
DocAction = docActionHolder[0];
/**
* Fill actionCombo
*/
for (int i = 0; i < index; i++) {
// Search for option and add it
boolean added = false;
for (int j = 0; j < s_value.length && !added; j++) if (options[i].equals(s_value[j])) {
actionCombo.addItem(s_name[j]);
added = true;
}
}
// setDefault
if (// If None, suggest closing
DocAction.equals("--"))
DocAction = DocumentEngine.ACTION_Close;
String defaultV = "";
for (int i = 0; i < s_value.length && defaultV.equals(""); i++) if (DocAction.equals(s_value[i]))
defaultV = s_name[i];
if (!defaultV.equals(""))
actionCombo.setSelectedItem(defaultV);
}
use of org.compiere.process.DocOptions in project adempiere by adempiere.
the class WDocActionPanel method dynInit.
/**
* Dynamic Init - determine valid DocActions based on DocStatus for the different documents.
*/
private void dynInit() {
//
Object Processing = gridTab.getValue("Processing");
String OrderType = Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "OrderType");
String IsSOTrx = Env.getContext(Env.getCtx(), gridTab.getWindowNo(), "IsSOTrx");
if (DocStatus == null) {
//message.setText("*** ERROR ***");
return;
}
logger.fine("DocStatus=" + DocStatus + ", DocAction=" + DocAction + ", OrderType=" + OrderType + ", IsSOTrx=" + IsSOTrx + ", Processing=" + Processing + ", AD_Table_ID=" + gridTab.getAD_Table_ID() + ", Record_ID=" + gridTab.getRecord_ID());
int index = 0;
if (lstDocAction.getSelectedItem() != null) {
String selected = (lstDocAction.getSelectedItem().getValue()).toString();
for (int i = 0; i < s_value.length && index == 0; i++) {
if (s_value[i].equals(selected)) {
index = i;
}
}
}
String[] options = new String[s_value.length];
/**
* Check Existence of Workflow Acrivities
*/
String wfStatus = MWFActivity.getActiveInfo(Env.getCtx(), m_AD_Table_ID, gridTab.getRecord_ID());
if (wfStatus != null) {
FDialog.error(gridTab.getWindowNo(), this, "WFActiveForRecord", wfStatus);
return;
}
// Status Change
if (!checkStatus(gridTab.getTableName(), gridTab.getRecord_ID(), DocStatus)) {
FDialog.error(gridTab.getWindowNo(), this, "DocumentStatusChanged");
return;
}
/*******************
* General Actions
*/
String[] docActionHolder = new String[] { DocAction };
index = DocumentEngine.getValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options);
MTable table = MTable.get(Env.getCtx(), m_AD_Table_ID);
PO po = table.getPO(gridTab.getRecord_ID(), null);
if (po instanceof DocOptions)
index = ((DocOptions) po).customizeValidActions(DocStatus, Processing, OrderType, IsSOTrx, m_AD_Table_ID, docActionHolder, options, index);
Integer doctypeId = (Integer) gridTab.getValue("C_DocType_ID");
if (doctypeId == null || doctypeId.intValue() == 0) {
doctypeId = (Integer) gridTab.getValue("C_DocTypeTarget_ID");
}
logger.fine("get doctype: " + doctypeId);
if (doctypeId != null) {
index = DocumentEngine.checkActionAccess(Env.getAD_Client_ID(Env.getCtx()), Env.getAD_Role_ID(Env.getCtx()), doctypeId, options, index);
}
DocAction = docActionHolder[0];
/**
* Fill actionCombo
*/
boolean firstadded = true;
for (int i = 0; i < index; i++) {
// Serach for option and add it
boolean added = false;
for (int j = 0; j < s_value.length && !added; j++) {
if (options[i].equals(s_value[j])) {
Listitem newitem = lstDocAction.appendItem(s_name[j], s_value[j]);
if (firstadded) {
// select by default the first added item - can be changed below
lstDocAction.setSelectedItem(newitem);
firstadded = false;
}
added = true;
}
}
}
// look if the current DocAction is within the list and assign it as selected if it exists
List<Listitem> lst = (List<Listitem>) lstDocAction.getItems();
for (Listitem item : lst) {
String value = item.getValue().toString();
if (DocAction.equals(value)) {
lstDocAction.setSelectedItem(item);
label.setValue(s_description[getSelectedIndex()]);
}
}
// setDefault
if (// If None, suggest closing
DocAction.equals("--"))
DocAction = DocumentEngine.ACTION_Close;
}