| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
package org.xmlhammer.gui.preferences; |
| 23 |
|
|
| 24 |
|
import java.util.ArrayList; |
| 25 |
|
import java.util.List; |
| 26 |
|
|
| 27 |
|
import javax.swing.JFrame; |
| 28 |
|
import javax.swing.table.DefaultTableModel; |
| 29 |
|
|
| 30 |
|
import org.xmlhammer.model.jaxp.Attribute; |
| 31 |
|
|
| 32 |
|
|
| 33 |
|
|
| 34 |
|
|
| 35 |
|
|
| 36 |
|
|
| 37 |
|
|
| 38 |
|
public class AttributesPanel extends PreferencesTablePanel { |
| 39 |
|
private static final long serialVersionUID = -4012144074923095588L; |
| 40 |
|
|
| 41 |
|
public AttributesPanel(JFrame parent, String name, String helpID) { |
| 42 |
44 |
this(parent, name, helpID, false); |
| 43 |
44 |
} |
| 44 |
|
|
| 45 |
|
public AttributesPanel(JFrame parent, String name, String helpID, boolean project) { |
| 46 |
88 |
super(parent, name, helpID, project); |
| 47 |
88 |
} |
| 48 |
|
|
| 49 |
|
protected DefaultTableModel getModel() { |
| 50 |
220 |
if ( model == null) { |
| 51 |
88 |
model = new ActivatableTableModel(); |
| 52 |
88 |
model.setColumnCount(3); |
| 53 |
88 |
model.setColumnIdentifiers(new String[] {" ", "Name", "Value"}); |
| 54 |
|
} |
| 55 |
|
|
| 56 |
220 |
return model; |
| 57 |
|
} |
| 58 |
|
|
| 59 |
|
|
| 60 |
|
protected int[] getColumnWidths() { |
| 61 |
88 |
return new int[] {25, 500, 500}; |
| 62 |
|
} |
| 63 |
|
|
| 64 |
|
public void setAttributes( List<Attribute> attributes) { |
| 65 |
88 |
while ( getModel().getRowCount() > 0) { |
| 66 |
0 |
getModel().removeRow(0); |
| 67 |
0 |
} |
| 68 |
|
|
| 69 |
88 |
for ( Attribute attribute : attributes) { |
| 70 |
0 |
getModel().addRow( new Object[] {attribute.isActive(), attribute.getName(), attribute.getValue()}); |
| 71 |
0 |
} |
| 72 |
88 |
} |
| 73 |
|
|
| 74 |
|
public List<Attribute> getAttributes() { |
| 75 |
44 |
List<Attribute> attributes = new ArrayList<Attribute>(); |
| 76 |
|
|
| 77 |
44 |
for ( int i = 0; i < getModel().getRowCount(); i++) { |
| 78 |
0 |
Attribute attribute = new Attribute(); |
| 79 |
0 |
attribute.setActive((Boolean)getModel().getValueAt( i, 0)); |
| 80 |
0 |
attribute.setName((String)getModel().getValueAt( i, 1)); |
| 81 |
0 |
attribute.setValue((String)getModel().getValueAt( i, 2)); |
| 82 |
|
|
| 83 |
0 |
attributes.add(attribute); |
| 84 |
|
} |
| 85 |
|
|
| 86 |
44 |
return attributes; |
| 87 |
|
} |
| 88 |
|
|
| 89 |
|
@Override |
| 90 |
|
protected Object[] getDefaultRowContent() { |
| 91 |
0 |
return new Object[] {Boolean.TRUE, "New Attribute Name", "New Attribute Value"}; |
| 92 |
|
} |
| 93 |
|
|
| 94 |
|
@Override |
| 95 |
|
protected String getName(int row) { |
| 96 |
0 |
return getModel().getValueAt(row, 1).toString(); |
| 97 |
|
} |
| 98 |
|
|
| 99 |
|
public String getHelpID() { |
| 100 |
0 |
return "preferences.dom.attributes"; |
| 101 |
|
} |
| 102 |
|
} |