74 |
ilm |
1 |
package org.openconcerto.modules.extensionbuilder.table;
|
|
|
2 |
|
|
|
3 |
import java.awt.Component;
|
|
|
4 |
|
|
|
5 |
import javax.swing.DefaultListCellRenderer;
|
|
|
6 |
import javax.swing.JList;
|
|
|
7 |
|
|
|
8 |
import org.openconcerto.erp.config.ComptaPropsConfiguration;
|
|
|
9 |
import org.openconcerto.sql.element.SQLElement;
|
|
|
10 |
import org.openconcerto.sql.model.SQLTable;
|
|
|
11 |
|
|
|
12 |
public class SQLTableListCellRenderer extends DefaultListCellRenderer {
|
|
|
13 |
@Override
|
|
|
14 |
public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
|
|
15 |
SQLTable t = (SQLTable) value;
|
|
|
16 |
value = getQualifiedName(t);
|
|
|
17 |
return super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus);
|
|
|
18 |
}
|
|
|
19 |
|
|
|
20 |
public static final String getQualifiedName(SQLTable t) {
|
|
|
21 |
String value = t.getName();
|
|
|
22 |
SQLElement e = ComptaPropsConfiguration.getInstanceCompta().getDirectory().getElement(t);
|
|
|
23 |
if (e != null) {
|
|
|
24 |
value = t.getName() + " (" + e.getPluralName() + ")";
|
|
|
25 |
}
|
|
|
26 |
return value;
|
|
|
27 |
}
|
|
|
28 |
}
|