@@ -0,0 +1,1950 @@
+package editor.views.viewlisteners;%0A%0Aimport xml.Element;%0A%0Aimport javax.swing.*;%0Aimport javax.swing.event.DocumentEvent;%0Aimport javax.swing.event.DocumentListener;%0A%0A/**%0A * This class is used to watch for changes to attribute fields in the editor%0A */%0Apublic class AttributeDocumentListener extends ElementDocumentListener%0A        implements DocumentListener %7B%0A%0A    enum Source %7B%0A        NONE, NAME, VALUE%0A    %7D%0A%0A    private int attributeIndex;%0A    private JTextField nameField;%0A    private JTextField valueField;%0A%0A    public AttributeDocumentListener(Element element,%0A                                     int attributeIndex,%0A                                     JTextField nameField,%0A                                     JTextField valueField) %7B%0A        super(element);%0A        this.attributeIndex = attributeIndex;%0A        this.nameField = nameField;%0A        this.valueField = valueField;%0A    %7D%0A%0A    private Source determineSource(DocumentEvent event) %7B%0A        if (event.getDocument() == nameField.getDocument()) %7B%0A            return Source.NAME;%0A        %7D else if (event.getDocument() == valueField.getDocument()) %7B%0A            return Source.VALUE;%0A        %7D else %7B%0A            return Source.NONE;%0A        %7D%0A    %7D%0A%0A    private void updateAttribute(DocumentEvent event) %7B%0A        String text = getStringFromEvent(event);%0A%0A        if (determineSource(event) == Source.NAME) %7B%0A            elem.renameAttribute(attributeIndex, text);%0A        %7D else if (determineSource(event) == Source.VALUE) %7B%0A            elem.setAttribute(elem.getAttributeName(attributeIndex), text);%0A        %7D%0A    %7D%0A%0A    @Override%0A    public void insertUpdate(DocumentEvent documentEvent) %7B%0A        updateAttribute(documentEvent);%0A    %7D%0A%0A    @Override%0A    public void removeUpdate(DocumentEvent documentEvent) %7B%0A        updateAttribute(documentEvent);%0A    %7D%0A%0A    @Override%0A    public void changedUpdate(DocumentEvent documentEvent) %7B%0A        updateAttribute(documentEvent);%0A    %7D%0A%7D%0A

Add AttributeDocumentListener