📄 valuepreference.java
字号:
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 (CLogMgt.isLevelFine())
{
lAttributeValue.setVisible(false);
lValueValue.setVisible(false);
}
// ActionListener
cbClient.setEnabled(false);
cbClient.setSelected(true);
// cbClient.addActionListener(this);
// Can Change Org
if (MRole.PREFERENCETYPE_Client.equals(m_role.getPreferenceType()))
cbOrg.addActionListener(this);
else
{
cbOrg.setEnabled(false);
cbOrg.setSelected(true);
}
// Can Change User
if (MRole.PREFERENCETYPE_Client.equals(m_role.getPreferenceType())
|| MRole.PREFERENCETYPE_Organization.equals(m_role.getPreferenceType()))
cbUser.addActionListener(this);
else
{
cbUser.setEnabled(false);
cbUser.setSelected(true);
}
// Can change all/specific
cbWindow.addActionListener(this);
// Other
confirmPanel.addActionListener(this);
bDelete = confirmPanel.addButton(ConfirmPanel.createDeleteButton(true));
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 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);
expl.append("entire System");
}
else
expl.append("entire System");
//
if (cbUser.isSelected())
expl.append(", this User");
else
expl.append(", 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.info("");
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.fine( sql.toString());
int no = DB.executeUpdate(sql.toString(), null);
if (no > 0)
Env.setContext(m_ctx, getContextKey(), (String)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.info("");
// --- Delete first
int no = delete();
// Handle NULL
if (m_Value == null || m_Value.length() == 0)
{
if (DisplayType.isLookup(m_DisplayType))
m_Value = "-1"; // -1 may cause problems (BPartner - M_DiscountSchema
else if (DisplayType.isDate(m_DisplayType))
m_Value = " ";
else
{
ADialog.warn(m_WindowNo, this, "ValuePreferenceNotInserted");
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.getNextID(m_ctx, "AD_Preference", null);
//
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.fine( sql.toString());
no = DB.executeUpdate(sql.toString(), null);
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 + -