📄 valuepreference.java
字号:
cbClient.setText(Msg.translate(m_ctx, "AD_Client_ID"));
cbClient.setEnabled(false);
cbClient.setSelected(true);
cbOrg.setText(Msg.translate(m_ctx, "AD_Org_ID"));
cbUser.setText(Msg.translate(m_ctx, "AD_User_ID"));
cbWindow.setText(Msg.translate(m_ctx, "AD_Window_ID"));
cbWindow.setSelected(true);
//
setPanel.setLayout(setLayout);
fAttribute.setEditable(false);
fValue.setEditable(false);
this.getContentPane().add(setPanel, BorderLayout.NORTH);
setPanel.add(lAttribute, new GridBagConstraints(0, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(fAttribute, new GridBagConstraints(1, 0, 4, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(lValue, new GridBagConstraints(0, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(fValue, new GridBagConstraints(1, 1, 4, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(lSetFor, new GridBagConstraints(0, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(cbClient, new GridBagConstraints(1, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(cbOrg, new GridBagConstraints(2, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(cbUser, new GridBagConstraints(3, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(cbWindow, new GridBagConstraints(4, 2, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
setPanel.add(lAttributeValue, new GridBagConstraints(5, 0, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
setPanel.add(lValueValue, new GridBagConstraints(5, 1, 1, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(0, 0, 0, 0), 0, 0));
setPanel.add(lExplanation, new GridBagConstraints(1, 3, 4, 1, 0.0, 0.0
,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(5, 5, 5, 5), 0, 0));
//
currentPanel.setBorder(titledBorder);
currentPanel.setLayout(currentLayout);
// this.getContentPane().add(currentPanel, BorderLayout.CENTER);
currentPanel.add(scrollPane, BorderLayout.CENTER);
scrollPane.getViewport().add(table, null);
this.getContentPane().add(confirmPanel, BorderLayout.SOUTH);
} // jbInit
/**
* Dynamic Init
*/
private void dynInit()
{
// Set Attribute/Value
fAttribute.setText(m_DisplayAttribute);
lAttributeValue.setText(m_Attribute);
fValue.setText(m_DisplayValue);
lValueValue.setText(m_Value);
if (Log.getTraceLevel() < Log.l6_Database)
{
lAttributeValue.setVisible(false);
lValueValue.setVisible(false);
}
// ActionListener
cbClient.addActionListener(this);
cbOrg.addActionListener(this);
cbUser.addActionListener(this);
cbWindow.addActionListener(this);
// Other
confirmPanel.addActionListener(this);
bDelete = confirmPanel.addButton("Delete", Msg.getMsg(Env.getCtx(), "Delete"), Env.getImageIcon("Delete24.gif"), 0);
bDelete.addActionListener(this);
setExplanation();
} // dynInit
/**
* Action Listener
* @param e event
*/
public void actionPerformed (ActionEvent e)
{
if (e.getActionCommand().equals(ConfirmPanel.A_CANCEL))
{
dispose();
}
else if (e.getActionCommand().equals(ConfirmPanel.A_OK))
{
insert();
dispose();
}
else if (e.getSource() == bDelete)
{
int no = delete();
if (no == 0)
ADialog.warn(m_WindowNo, this, "ValuePreferenceNotFound");
else
ADialog.info(m_WindowNo, this, "ValuePreferenceDeleted", String.valueOf(no));
dispose();
}
else
setExplanation();
} // actionPerformed
/**
* Set Explanation
*/
private void setExplanation()
{
/** @todo translation */
StringBuffer expl = new StringBuffer("For ");
if (cbClient.isSelected() && cbOrg.isSelected())
expl.append("this specific Client and Organization");
else if (cbClient.isSelected() && !cbOrg.isSelected())
expl.append("all Organizations of this Client");
else if (!cbClient.isSelected() && cbOrg.isSelected())
cbOrg.setSelected(false);
else
expl.append("entire System");
if (cbUser.isSelected())
expl.append(" and this User");
else
expl.append(" and all Users");
if (cbWindow.isSelected())
expl.append(" and this Window");
else
expl.append(" and all Windows");
//
if (Env.getLanguage(Env.getCtx()).isBaseLanguage())
{
lExplanation.setText (expl.toString ());
this.pack ();
}
} // setExplanation
/**
* Delete Preference
* @return number of rows deleted
*/
public int delete()
{
Log.trace(Log.l1_User, "ValuePreference.delete");
StringBuffer sql = new StringBuffer ("DELETE FROM AD_Preference WHERE ");
sql.append("AD_Client_ID=").append(cbClient.isSelected() ? m_AD_Client_ID : 0);
sql.append(" AND AD_Org_ID=").append(cbOrg.isSelected() ? m_AD_Org_ID : 0);
if (cbUser.isSelected())
sql.append(" AND AD_User_ID=").append(m_AD_User_ID);
else
sql.append(" AND AD_User_ID IS NULL");
if (cbWindow.isSelected())
sql.append(" AND AD_Window_ID=").append(m_AD_Window_ID);
else
sql.append(" AND AD_Window_ID IS NULL");
sql.append(" AND Attribute='").append(m_Attribute).append("'");
//
Log.trace(Log.l6_Database, sql.toString());
int no = DB.executeUpdate(sql.toString());
if (no > 0)
Env.setContext(m_ctx, getContextKey(), null);
return no;
} // delete
/**
* Get Context Key
* @return Context Key
*/
private String getContextKey()
{
if (cbWindow.isSelected())
return "P" + m_AD_Window_ID + "|" + m_Attribute;
else
return "P|" + m_Attribute;
} // getContextKey
/**
* Save to Disk
*/
public void insert()
{
Log.trace(Log.l1_User, "ValuePreference.insert");
// --- Delete first
int no = delete();
// Only Delete
if (m_Value == null || m_Value.length() == 0)
{
if (no == 0)
ADialog.warn(m_WindowNo, this, "ValuePreferenceNotFound");
else
ADialog.info(m_WindowNo, this, "ValuePreferenceDeleted", String.valueOf(no));
return;
}
// --- Inserting
int Client_ID = cbClient.isSelected() ? m_AD_Client_ID : 0;
int Org_ID = cbOrg.isSelected() ? m_AD_Org_ID : 0;
int AD_Preference_ID = DB.getKeyNextNo(m_ctx, m_WindowNo, "AD_Preference");
//
StringBuffer sql = new StringBuffer ("INSERT INTO AD_Preference ("
+ "AD_Preference_ID, AD_Client_ID, AD_Org_ID, IsActive, Created,CreatedBy,Updated,UpdatedBy,"
+ "AD_Window_ID, AD_User_ID, Attribute, Value) VALUES (");
sql.append(AD_Preference_ID).append(",").append(Client_ID).append(",").append(Org_ID)
.append(", 'Y',SysDate,").append(m_AD_User_ID).append(",SysDate,").append(m_AD_User_ID).append(", ");
if (cbWindow.isSelected())
sql.append(m_AD_Window_ID).append(",");
else
sql.append("NULL,") ;
if (cbUser.isSelected())
sql.append(m_AD_User_ID).append(",");
else
sql.append("NULL,");
sql.append("'").append(m_Attribute).append("','").append(m_Value).append("')");
//
Log.trace(Log.l6_Database, sql.toString());
no = DB.executeUpdate(sql.toString());
if (no == 1)
{
Env.setContext(m_ctx, getContextKey(), m_Value);
ADialog.info(m_WindowNo, this, "ValuePreferenceInserted");
}
else
ADialog.warn(m_WindowNo, this, "ValuePreferenceNotInserted");
} // insert
} // ValuePreference
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -