📄 wfactivity.java
字号:
catch (Exception e)
{
log.log(Level.SEVERE, sql, e);
}
try
{
if (pstmt != null)
pstmt.close ();
pstmt = null;
}
catch (Exception e)
{
pstmt = null;
}
m_activities = new MWFActivity[list.size ()];
list.toArray (m_activities);
//
log.fine("#" + m_activities.length
+ "(" + (System.currentTimeMillis()-start) + "ms)");
m_index = 0;
return m_activities.length;
} // loadActivities
/**
* Display.
* Fill Editors
*/
public void display ()
{
log.fine("Index=" + m_index);
//
fTextMsg.setText("");
fAnswerText.setVisible(false);
fAnswerList.setVisible(false);
fAnswerButton.setIcon(Env.getImageIcon("mWindow.gif"));
fAnswerButton.setVisible(false);
fTextMsg.setReadWrite(m_activities.length != 0);
bZoom.setEnabled(m_activities.length != 0);
bOK.setEnabled(m_activities.length != 0);
fForward.setValue(null);
fForward.setEnabled(m_activities.length != 0);
statusBar.setStatusDB(String.valueOf(m_index) + "/" + m_activities.length);
m_activity = null;
if (m_activities.length > 0)
{
if (m_index+1 > m_activities.length)
{
log.log(Level.SEVERE, "Index (" + m_index
+ ") greater then activity length=" + m_activities.length);
m_index = 0;
}
else
m_activity = m_activities[m_index];
}
// Nothing to show
if (m_activity == null)
{
fNode.setText ("");
fDescription.setText ("");
fHelp.setText ("");
fHistory.setText ("");
statusBar.setStatusDB("0/0");
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFNoActivities"));
bNext.setEnabled(false);
bPrevious.setEnabled(false);
return;
}
// Display Activity
fNode.setText (m_activity.getNodeName());
fDescription.setText (m_activity.getNodeDescription());
fHelp.setText (m_activity.getNodeHelp());
//
fHistory.setText (m_activity.getHistoryHTML());
// User Actions
MWFNode node = m_activity.getNode();
if (MWFNode.ACTION_UserChoice.equals(node.getAction()))
{
if (m_column == null)
m_column = node.getColumn();
if (m_column != null && m_column.get_ID() != 0)
{
int dt = m_column.getAD_Reference_ID();
if (dt == DisplayType.YesNo)
{
ValueNamePair[] values = MRefList.getList(319, false); // _YesNo
fAnswerList.setModel(new DefaultComboBoxModel(values));
fAnswerList.setVisible(true);
}
else if (dt == DisplayType.List)
{
ValueNamePair[] values = MRefList.getList(m_column.getAD_Reference_Value_ID(), false);
fAnswerList.setModel(new DefaultComboBoxModel(values));
fAnswerList.setVisible(true);
}
else // other display types come here
{
fAnswerText.setText ("");
fAnswerText.setVisible(true);
}
}
}
// --
else if (MWFNode.ACTION_UserWindow.equals(node.getAction())
|| MWFNode.ACTION_UserForm.equals(node.getAction()))
{
fAnswerButton.setText(node.getName());
fAnswerButton.setToolTipText(node.getDescription());
fAnswerButton.setVisible(true);
}
else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
log.log(Level.SEVERE, "Workflow Action not implemented yet");
else
log.log(Level.SEVERE, "Unknown Node Action: " + node.getAction());
//
if (m_menu != null)
{
m_menu.updateInfo(); // calls loadActivities - updates menu tab
}
// End
if (m_index+1 >= m_activities.length)
{
m_index = m_activities.length - 1;
bNext.setEnabled(false);
}
else
bNext.setEnabled(true);
// Start
if (m_index <= 0)
{
m_index = 0;
bPrevious.setEnabled(false);
}
else
bPrevious.setEnabled(true);
statusBar.setStatusDB((m_index+1) + "/" + m_activities.length);
statusBar.setStatusLine(Msg.getMsg(Env.getCtx(), "WFActivities"));
} // display
/**
* Action Listener
* @param e event
* @see java.awt.event.ActionListener#actionPerformed(ActionEvent)
*/
public void actionPerformed (ActionEvent e)
{
this.setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
//
if (e.getSource() == bNext || e.getSource() == bPrevious)
{
if (e.getSource() == bNext)
m_index++;
else
m_index--;
display();
}
else if (e.getSource() == bZoom)
cmd_zoom();
else if (e.getSource() == bOK)
cmd_OK();
else if (e.getSource() == fAnswerButton)
cmd_button();
//
this.setCursor(Cursor.getDefaultCursor());
} // actionPerformed
/**
* Zoom
*/
private void cmd_zoom()
{
log.config("Activity=" + m_activity);
if (m_activity == null)
return;
AEnv.zoom(m_activity.getAD_Table_ID(), m_activity.getRecord_ID());
} // cmd_zoom
/**
* Answer Button
*/
private void cmd_button()
{
log.config("Activity=" + m_activity);
if (m_activity == null)
return;
//
MWFNode node = m_activity.getNode();
if (MWFNode.ACTION_UserWindow.equals(node.getAction()))
{
int AD_Window_ID = node.getAD_Window_ID(); // Explicit Window
String ColumnName = m_activity.getPO().get_TableName() + "_ID";
int Record_ID = m_activity.getRecord_ID();
MQuery query = MQuery.getEqualQuery(ColumnName, Record_ID);
boolean IsSOTrx = m_activity.isSOTrx();
//
log.info("Zoom to AD_Window_ID=" + AD_Window_ID
+ " - " + query + " (IsSOTrx=" + IsSOTrx + ")");
AWindow frame = new AWindow();
if (!frame.initWindow(AD_Window_ID, query))
return;
AEnv.showCenterScreen(frame);
frame = null;
}
else if (MWFNode.ACTION_UserForm.equals(node.getAction()))
{
int AD_Form_ID = node.getAD_Form_ID();
FormFrame ff = new FormFrame();
ff.openForm(AD_Form_ID);
ff.pack();
AEnv.showCenterScreen(ff);
}
else if (MWFNode.ACTION_UserWorkbench.equals(node.getAction()))
{
}
else
log.log(Level.SEVERE, "No User Action:" + node.getAction());
} // cmd_button
/**
* Save
*/
private void cmd_OK()
{
log.config("Activity=" + m_activity);
if (m_activity == null)
return;
int AD_User_ID = Env.getAD_User_ID(Env.getCtx());
String textMsg = fTextMsg.getText();
//
MWFNode node = m_activity.getNode();
Object forward = fForward.getValue();
if (forward != null)
{
log.config("Forward to " + forward);
int fw = ((Integer)forward).intValue();
if (fw == AD_User_ID || fw == 0)
{
log.log(Level.SEVERE, "Forward User=" + fw);
return;
}
if (!m_activity.forwardTo(fw, textMsg))
{
ADialog.error(m_WindowNo, this, "CannotForward");
return;
}
}
// User Choice - Answer
else if (MWFNode.ACTION_UserChoice.equals(node.getAction()))
{
if (m_column == null)
m_column = node.getColumn();
// Do we have an answer?
int dt = m_column.getAD_Reference_ID();
String value = fAnswerText.getText();
if (dt == DisplayType.YesNo || dt == DisplayType.List)
{
ValueNamePair pp = (ValueNamePair)fAnswerList.getSelectedItem();
value = pp.getValue();
}
if (value == null || value.length() == 0)
{
ADialog.error(m_WindowNo, this, "FillMandatory", Msg.getMsg(Env.getCtx(), "Answer"));
return;
}
//
log.config("Answer=" + value + " - " + textMsg);
try
{
m_activity.setUserChoice(AD_User_ID, value, dt, textMsg);
}
catch (Exception e)
{
log.log(Level.SEVERE, node.getName(), e);
ADialog.error(m_WindowNo, this, "Error", e.toString());
return;
}
}
// User Action
else
{
log.config("Action=" + node.getAction() + " - " + textMsg);
try
{
m_activity.setUserConfirmation(AD_User_ID, textMsg);
}
catch (Exception e)
{
log.log(Level.SEVERE, node.getName(), e);
ADialog.error(m_WindowNo, this, "Error", e.toString());
return;
}
}
// Next
loadActivities();
display();
} // cmd_OK
} // WFActivity
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -