use of model.Coder in project dna by leifeld.
the class Sql method getCoder.
/* =========================================================================
* Coders
* ====================================================================== */
/**
* Retrieve a coder based on its ID. Works with DNA 2 and 3.
*
* @param coderId The ID of the coder to be retrieved from the database.
* @return The coder to be retrieved, as a {@link model.Coder
* Coder} object.
*
* @category coder
*/
public Coder getCoder(int coderId) {
Coder c = null;
try (Connection conn = ds.getConnection();
PreparedStatement s1 = conn.prepareStatement("SELECT * FROM CODERS WHERE ID = ?;");
PreparedStatement s2 = conn.prepareStatement("SELECT * FROM CODERRELATIONS WHERE Coder = ?;");
PreparedStatement s3 = conn.prepareStatement("SELECT Name, Red, Green, Blue FROM CODERS WHERE ID = ?;");
PreparedStatement s4 = conn.prepareStatement("SELECT Value FROM SETTINGS WHERE Property = 'version';")) {
ResultSet rs1, rs2, rs3;
// get DNA version
int v = 3;
rs1 = s4.executeQuery();
while (rs1.next()) {
if (rs1.getString("Value").startsWith("2")) {
v = 2;
}
}
rs1.close();
PreparedStatement s5V2 = null;
if (v == 2) {
s5V2 = conn.prepareStatement("SELECT Type, Permission FROM CODERPERMISSIONS WHERE Coder = ?;");
}
// get coder
int sourceCoderId, targetCoderId;
String targetCoderName = null;
Color targetCoderColor = null;
s1.setInt(1, coderId);
rs1 = s1.executeQuery();
while (rs1.next()) {
sourceCoderId = rs1.getInt("ID");
// get coder relations
s2.setInt(1, sourceCoderId);
rs2 = s2.executeQuery();
HashMap<Integer, CoderRelation> map = new HashMap<Integer, CoderRelation>();
while (rs2.next()) {
// get details from other coder and create coder relations map
targetCoderId = rs2.getInt("OtherCoder");
s3.setInt(1, targetCoderId);
rs3 = s3.executeQuery();
while (rs3.next()) {
targetCoderName = rs3.getString("Name");
targetCoderColor = new Color(rs3.getInt("Red"), rs3.getInt("Green"), rs3.getInt("Blue"));
}
map.put(rs2.getInt("OtherCoder"), new CoderRelation(targetCoderId, targetCoderName, targetCoderColor, rs2.getInt("viewDocuments") == 1, rs2.getInt("editDocuments") == 1, rs2.getInt("viewStatements") == 1, rs2.getInt("editStatements") == 1));
}
// create coder
if (v == 2) {
// DNA 2.0
s5V2.setInt(1, sourceCoderId);
rs2 = s5V2.executeQuery();
HashMap<String, Boolean> perm = new HashMap<String, Boolean>();
while (rs2.next()) {
if (rs2.getString("Type").equals("addDocuments")) {
perm.put("PermissionAddDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editDocuments")) {
perm.put("PermissionEditDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("deleteDocuments")) {
perm.put("PermissionDeleteDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("importDocuments")) {
perm.put("PermissionImportDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("addStatements")) {
perm.put("PermissionAddStatements", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editStatements")) {
perm.put("PermissionEditStatements", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("deleteStatements")) {
perm.put("PermissionDeleteStatements", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editAttributes")) {
perm.put("PermissionEditAttributes", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editRegex")) {
perm.put("PermissionEditRegex", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editStatementTypes")) {
perm.put("PermissionEditStatementTypes", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editCoders")) {
perm.put("PermissionEditCoders", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editCoderRelations")) {
perm.put("PermissionEditCoderRelations", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("viewOthersDocuments")) {
perm.put("PermissionViewOthersDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editOthersDocuments")) {
perm.put("PermissionEditOthersDocuments", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("viewOthersStatements")) {
perm.put("PermissionViewOthersStatements", rs2.getInt("Permission") == 1);
}
if (rs2.getString("Type").equals("editOthersStatements")) {
perm.put("PermissionEditOthersStatements", rs2.getInt("Permission") == 1);
}
}
rs2.close();
if (!perm.containsKey("permissionAddDocuments")) {
perm.put("PermissionAddDocuments", true);
}
if (!perm.containsKey("permissionEditDocuments")) {
perm.put("PermissionEditDocuments", true);
}
if (!perm.containsKey("permissionDeleteDocuments")) {
perm.put("PermissionDeleteDocuments", true);
}
if (!perm.containsKey("permissionImportDocuments")) {
perm.put("PermissionImportDocuments", true);
}
if (!perm.containsKey("permissionAddStatements")) {
perm.put("PermissionAddStatements", true);
}
if (!perm.containsKey("permissionEditStatements")) {
perm.put("PermissionEditStatements", true);
}
if (!perm.containsKey("permissionDeleteStatements")) {
perm.put("PermissionDeleteStatements", true);
}
if (!perm.containsKey("permissionEditAttributes")) {
perm.put("PermissionEditAttributes", true);
}
if (!perm.containsKey("permissionEditRegex")) {
perm.put("PermissionEditRegex", true);
}
if (!perm.containsKey("permissionEditStatementTypes")) {
perm.put("PermissionEditStatementTypes", true);
}
if (!perm.containsKey("permissionEditCoders")) {
perm.put("PermissionEditCoders", true);
}
if (!perm.containsKey("permissionEditCoderRelations")) {
perm.put("PermissionEditCoderRelations", true);
}
if (!perm.containsKey("permissionViewOthersDocuments")) {
perm.put("PermissionViewOthersDocuments", true);
}
if (!perm.containsKey("permissionEditOthersDocuments")) {
perm.put("PermissionEditOthersDocuments", true);
}
if (!perm.containsKey("permissionViewOthersStatements")) {
perm.put("PermissionViewOthersStatements", true);
}
if (!perm.containsKey("permissionEditOthersStatements")) {
perm.put("PermissionEditOthersStatements", true);
}
c = new Coder(coderId, rs1.getString("Name"), rs1.getInt("Red"), rs1.getInt("Green"), rs1.getInt("Blue"), 0, 14, 300, false, false, true, perm.get("PermissionAddDocuments"), perm.get("PermissionEditDocuments"), perm.get("PermissionDeleteDocuments"), perm.get("PermissionImportDocuments"), perm.get("PermissionAddStatements"), perm.get("PermissionEditStatements"), perm.get("PermissionDeleteStatements"), perm.get("PermissionEditAttributes"), perm.get("PermissionEditRegex"), perm.get("PermissionEditStatementTypes"), perm.get("PermissionEditCoders"), perm.get("PermissionEditCoderRelations"), perm.get("PermissionViewOthersDocuments"), perm.get("PermissionEditOthersDocuments"), perm.get("PermissionViewOthersStatements"), perm.get("PermissionEditOthersStatements"), map);
} else {
// DNA 3.0
c = new Coder(coderId, rs1.getString("Name"), rs1.getInt("Red"), rs1.getInt("Green"), rs1.getInt("Blue"), rs1.getInt("Refresh"), rs1.getInt("FontSize"), rs1.getInt("PopupWidth"), rs1.getInt("ColorByCoder") == 1, rs1.getInt("PopupDecoration") == 1, rs1.getInt("popupAutoComplete") == 1, rs1.getInt("PermissionAddDocuments") == 1, rs1.getInt("PermissionEditDocuments") == 1, rs1.getInt("PermissionDeleteDocuments") == 1, rs1.getInt("PermissionImportDocuments") == 1, rs1.getInt("PermissionAddStatements") == 1, rs1.getInt("PermissionEditStatements") == 1, rs1.getInt("PermissionDeleteStatements") == 1, rs1.getInt("PermissionEditAttributes") == 1, rs1.getInt("PermissionEditRegex") == 1, rs1.getInt("PermissionEditStatementTypes") == 1, rs1.getInt("PermissionEditCoders") == 1, rs1.getInt("PermissionEditCoderRelations") == 1, rs1.getInt("PermissionViewOthersDocuments") == 1, rs1.getInt("PermissionEditOthersDocuments") == 1, rs1.getInt("PermissionViewOthersStatements") == 1, rs1.getInt("PermissionEditOthersStatements") == 1, map);
}
}
if (v == 2) {
s5V2.close();
}
} catch (SQLException e) {
LogEvent l = new LogEvent(Logger.ERROR, "[SQL] Coder with ID " + coderId + " could not be retrieved from the database.", "The details of the coder with ID " + coderId + " could not be retrieved from the database. Check your database connection.", e);
Dna.logger.log(l);
}
return c;
}
use of model.Coder in project dna by leifeld.
the class CoderComboBoxRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
if (value == null) {
return new JLabel("select coder...");
} else {
Coder coder = (Coder) value;
CoderBadgePanel cbp = new CoderBadgePanel(coder, CoderComboBoxRenderer.this.buttonSize, CoderComboBoxRenderer.this.margin, CoderComboBoxRenderer.this.maxNameLength);
if (isSelected) {
UIDefaults defaults = javax.swing.UIManager.getDefaults();
Color bg = defaults.getColor("List.selectionBackground");
cbp.setBackground(bg);
}
return cbp;
}
}
use of model.Coder in project dna by leifeld.
the class CoderManager method loadCoder.
/**
* Check which coder is selected and populate the details, permissions, and
* coder relation lists and enable or disable GUI controls.
*/
private void loadCoder() {
if (!coderList.isSelectionEmpty()) {
// trigger only if selection has been completed and a coder is selected
selectedCoderCopy = new Coder(coderList.getSelectedValue());
if (selectedCoderCopy.getId() == 1) {
// do not make boxes editable if it is the Admin coder (ID = 1)
boxAddDocuments.setEnabled(false);
boxEditDocuments.setEnabled(false);
boxDeleteDocuments.setEnabled(false);
boxImportDocuments.setEnabled(false);
boxAddStatements.setEnabled(false);
boxEditStatements.setEnabled(false);
boxDeleteStatements.setEnabled(false);
boxEditAttributes.setEnabled(false);
boxEditRegex.setEnabled(false);
boxEditStatementTypes.setEnabled(false);
boxEditCoders.setEnabled(false);
boxEditCoderRelations.setEnabled(false);
boxViewOthersDocuments.setEnabled(false);
boxEditOthersDocuments.setEnabled(false);
boxViewOthersStatements.setEnabled(false);
boxEditOthersStatements.setEnabled(false);
} else {
boxAddDocuments.setEnabled(true);
boxEditDocuments.setEnabled(true);
boxDeleteDocuments.setEnabled(true);
boxImportDocuments.setEnabled(true);
boxAddStatements.setEnabled(true);
boxEditStatements.setEnabled(true);
boxDeleteStatements.setEnabled(true);
boxEditAttributes.setEnabled(true);
boxEditRegex.setEnabled(true);
boxEditStatementTypes.setEnabled(true);
boxEditCoders.setEnabled(true);
boxEditCoderRelations.setEnabled(true);
boxViewOthersDocuments.setEnabled(true);
boxEditOthersDocuments.setEnabled(true);
boxViewOthersStatements.setEnabled(true);
boxEditOthersStatements.setEnabled(true);
}
if (selectedCoderCopy.isPermissionAddDocuments()) {
boxAddDocuments.setSelected(true);
} else {
boxAddDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditDocuments()) {
boxEditDocuments.setSelected(true);
} else {
boxEditDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionDeleteDocuments()) {
boxDeleteDocuments.setSelected(true);
} else {
boxDeleteDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionImportDocuments()) {
boxImportDocuments.setSelected(true);
} else {
boxImportDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionAddStatements()) {
boxAddStatements.setSelected(true);
} else {
boxAddStatements.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditStatements()) {
boxEditStatements.setSelected(true);
} else {
boxEditStatements.setSelected(false);
}
if (selectedCoderCopy.isPermissionDeleteStatements()) {
boxDeleteStatements.setSelected(true);
} else {
boxDeleteStatements.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditAttributes()) {
boxEditAttributes.setSelected(true);
} else {
boxEditAttributes.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditRegex()) {
boxEditRegex.setSelected(true);
} else {
boxEditRegex.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditStatementTypes()) {
boxEditStatementTypes.setSelected(true);
} else {
boxEditStatementTypes.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditCoders()) {
boxEditCoders.setSelected(true);
} else {
boxEditCoders.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditCoderRelations()) {
boxEditCoderRelations.setSelected(true);
} else {
boxEditCoderRelations.setSelected(false);
}
if (selectedCoderCopy.isPermissionViewOthersDocuments()) {
boxViewOthersDocuments.setSelected(true);
} else {
boxViewOthersDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditOthersDocuments()) {
boxEditOthersDocuments.setSelected(true);
} else {
boxEditOthersDocuments.setSelected(false);
}
if (selectedCoderCopy.isPermissionViewOthersStatements()) {
boxViewOthersStatements.setSelected(true);
} else {
boxViewOthersStatements.setSelected(false);
}
if (selectedCoderCopy.isPermissionEditOthersStatements()) {
boxEditOthersStatements.setSelected(true);
} else {
boxEditOthersStatements.setSelected(false);
}
nameLabel.setEnabled(true);
colorLabel.setEnabled(true);
pw1Label.setEnabled(true);
pw2Label.setEnabled(true);
nameField.setText(selectedCoderCopy.getName());
colorButton.setColor(selectedCoderCopy.getColor());
if (selectedCoderCopy.getId() == 1) {
// do not permit editing if it is the Admin coder (ID = 1)
nameField.setEnabled(false);
colorButton.setEnabled(false);
pw1Field.setEnabled(false);
pw2Field.setEnabled(false);
} else {
nameField.setEnabled(true);
colorButton.setEnabled(true);
pw1Field.setEnabled(true);
pw2Field.setEnabled(true);
}
// coder relations
coderRelationsPanel.getTable().setEnabled(true);
coderRelationsPanel.getModel().clear();
for (HashMap.Entry<Integer, CoderRelation> entry : selectedCoderCopy.getCoderRelations().entrySet()) {
coderRelationsPanel.getModel().addRow(entry.getValue());
}
if (selectedCoderCopy.getId() == 1) {
// do not permitting selecting or unselecting coders if the Admin coder is selected (ID = 1)
coderRelationsPanel.getTable().setEnabled(false);
} else {
coderRelationsPanel.getTable().setEnabled(true);
}
} else if (coderList.isSelectionEmpty()) {
// reset button was pressed
selectedCoderCopy = null;
boxAddDocuments.setEnabled(false);
boxEditDocuments.setEnabled(false);
boxDeleteDocuments.setEnabled(false);
boxImportDocuments.setEnabled(false);
boxAddStatements.setEnabled(false);
boxEditStatements.setEnabled(false);
boxDeleteStatements.setEnabled(false);
boxEditAttributes.setEnabled(false);
boxEditRegex.setEnabled(false);
boxEditStatementTypes.setEnabled(false);
boxEditCoders.setEnabled(false);
boxEditCoderRelations.setEnabled(false);
boxViewOthersDocuments.setEnabled(false);
boxEditOthersDocuments.setEnabled(false);
boxViewOthersStatements.setEnabled(false);
boxEditOthersStatements.setEnabled(false);
boxAddDocuments.setSelected(false);
boxEditDocuments.setSelected(false);
boxDeleteDocuments.setSelected(false);
boxImportDocuments.setSelected(false);
boxAddStatements.setSelected(false);
boxEditStatements.setSelected(false);
boxDeleteStatements.setSelected(false);
boxEditAttributes.setSelected(false);
boxEditRegex.setSelected(false);
boxEditStatementTypes.setSelected(false);
boxEditCoders.setSelected(false);
boxEditCoderRelations.setSelected(false);
boxViewOthersDocuments.setSelected(false);
boxEditOthersDocuments.setSelected(false);
boxViewOthersStatements.setSelected(false);
boxEditOthersStatements.setSelected(false);
nameLabel.setEnabled(false);
nameField.setEnabled(false);
colorLabel.setEnabled(false);
colorButton.setEnabled(false);
pw1Label.setEnabled(false);
pw1Field.setEnabled(false);
pw2Label.setEnabled(false);
pw2Field.setEnabled(false);
nameField.setText("");
colorButton.setColor(Color.BLACK);
// coder relations
coderRelationsPanel.getModel().clear();
coderRelationsPanel.getTable().setEnabled(false);
}
}
use of model.Coder in project dna by leifeld.
the class MainWindow method newPopup.
/**
* Show a statement popup window.
*
* @param x X location on the screen.
* @param y Y location on the screen.
* @param s The statement to show.
* @param documentId The document ID for the statement.
* @param location The location of the popup window.
* @param coder The active coder.
*/
private void newPopup(double x, double y, Statement s, Point location) {
// determine coders for the coder combo box in the popup window
ArrayList<Coder> eligibleCoders = null;
if (Dna.sql.getActiveCoder().isPermissionEditStatements() && Dna.sql.getActiveCoder().isPermissionEditOthersStatements() && (Dna.sql.getActiveCoder().isPermissionEditOthersStatements(s.getCoderId()) || Dna.sql.getActiveCoder().getId() == s.getCoderId())) {
eligibleCoders = Dna.sql.getCoders();
for (int i = eligibleCoders.size() - 1; i >= 0; i--) {
if (Dna.sql.getActiveCoder().getId() != eligibleCoders.get(i).getId() && s.getCoderId() != eligibleCoders.get(i).getId() && !Dna.sql.getActiveCoder().isPermissionEditOthersStatements(eligibleCoders.get(i).getId())) {
eligibleCoders.remove(i);
}
}
}
// create popup window
this.popup = new Popup(x, y, s, location, Dna.sql.getActiveCoder(), eligibleCoders);
// duplicate button action listener
JButton duplicate = popup.getDuplicateButton();
duplicate.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (Dna.sql.getActiveCoder().isPermissionAddStatements() == true) {
// save popup changes
if (popup.isEditable() == true && popup.hasWindowDecoration() == true) {
String message = "Save any changes in Statement " + s.getId() + " before creating copy?";
int dialog = JOptionPane.showConfirmDialog(popup, message, "Confirmation", JOptionPane.YES_NO_OPTION);
if (dialog == 0) {
popup.saveContents(false);
}
} else if (popup.isEditable() && popup.hasWindowDecoration() == false) {
popup.saveContents(false);
}
// update statement table with changes to old statement that was saved
statusBar.statementRefreshStart();
Statement updatedOldStatement = popup.getStatementCopy();
int modelRow = statementTableModel.getModelRowById(updatedOldStatement.getId());
statementTableModel.getRow(modelRow).setCoderName(updatedOldStatement.getCoderName());
statementTableModel.getRow(modelRow).setCoderColor(updatedOldStatement.getCoderColor());
statementTableModel.fireTableRowsUpdated(modelRow, modelRow);
// clone the statement
int newStatementId = Dna.sql.cloneStatement(s.getId(), Dna.sql.getActiveCoder().getId());
// repaint statements in text if old statement was changed or new statement successfully created
if (newStatementId > 0 || (popup.isCoderChanged() && Dna.sql.getActiveCoder().isColorByCoder())) {
textPanel.paintStatements();
}
// put a cloned statement into the statement table and update view, then select statement
if (newStatementId > 0) {
documentTableModel.increaseFrequency(updatedOldStatement.getDocumentId());
updatedOldStatement.setId(newStatementId);
updatedOldStatement.setCoderId(Dna.sql.getActiveCoder().getId());
updatedOldStatement.setCoderName(Dna.sql.getActiveCoder().getName());
updatedOldStatement.setCoderColor(Dna.sql.getActiveCoder().getColor());
statementTableModel.addRow(updatedOldStatement);
statementPanel.setSelectedStatementId(newStatementId);
}
popup.dispose();
statusBar.statementRefreshEnd();
}
}
});
// remove button action listener
JButton remove = popup.getRemoveButton();
remove.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
int question = JOptionPane.showConfirmDialog(MainWindow.this, "Are you sure you want to remove this statement?", "Remove?", JOptionPane.YES_NO_OPTION);
if (question == 0) {
statusBar.statementRefreshStart();
boolean deleted = Dna.sql.deleteStatements(new int[] { s.getId() });
if (deleted) {
getTextPanel().paintStatements();
documentTableModel.decreaseFrequency(s.getDocumentId());
int statementModelRow = statementTableModel.getModelRowById(s.getId());
getStatementPanel().getStatementTable().clearSelection();
statementTableModel.removeStatements(new int[] { statementModelRow });
// log deleted statements
LogEvent l = new LogEvent(Logger.MESSAGE, "[GUI] Action executed: removed statement(s).", "Deleted statement(s) in the database and GUI.");
Dna.logger.log(l);
popup.dispose();
}
statusBar.statementRefreshEnd();
}
}
});
// save and close window or focus listener
if (popup.hasWindowDecoration() == true) {
popup.addWindowListener(new // listener for the X button in the window decoration
WindowAdapter() {
public void windowClosing(WindowEvent e) {
if (popup.isEditable() == true) {
if (popup.saveContents(true) == true) {
// check first if there are any changes; ask to save only if necessary
String message = "Save changes in Statement " + s.getId() + "?";
int dialog = JOptionPane.showConfirmDialog(popup, message, "Confirmation", JOptionPane.YES_NO_OPTION);
if (dialog == 0) {
popupSave(popup);
}
}
}
popup.dispose();
// clear statement table selection when popup window closed
statementPanel.getStatementTable().clearSelection();
}
});
popup.getCancelButton().addActionListener(new // cancel button action listener
ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
popup.dispose();
// clear statement table selection when popup window closed
statementPanel.getStatementTable().clearSelection();
}
});
popup.getSaveButton().addActionListener(new // save button action listener
ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
popupSave(popup);
popup.dispose();
// clear statement table selection when popup window closed
statementPanel.getStatementTable().clearSelection();
}
});
// popup.setModal(true); // disabled for now: set modal after adding controls because otherwise controls can't be added anymore while modal
} else {
// no window decoration: focus lost listener
popup.addWindowFocusListener(new WindowAdapter() {
public void windowLostFocus(WindowEvent e) {
popupSave(popup);
popup.dispose();
// clear statement table selection when popup window closed
statementPanel.getStatementTable().clearSelection();
}
});
}
// needs to be called after setting modal; hence here instead of in the Popup class
popup.setVisible(true);
}
use of model.Coder in project dna by leifeld.
the class CoderRenderer method getListCellRendererComponent.
@Override
public Component getListCellRendererComponent(JList<?> list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
Coder coder = (Coder) value;
CoderBadgePanel cbp;
if (coder == null) {
cbp = new CoderBadgePanel();
} else {
cbp = new CoderBadgePanel(coder, 18, 5, 100);
}
// list background
Color selectedColor = javax.swing.UIManager.getColor("List.selectionBackground");
// selected entry that is not in database: average of the previous two colors
Color defaultColor = javax.swing.UIManager.getColor("List.background");
if (isSelected == true) {
cbp.setBackground(selectedColor);
} else {
cbp.setBackground(defaultColor);
}
cbp.setOpaque(true);
return cbp;
}
Aggregations