home *** CD-ROM | disk | FTP | other *** search
- import java.awt.event.FocusEvent;
- import java.awt.event.FocusListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.util.Enumeration;
- import java.util.Vector;
- import javax.swing.JComboBox;
- import javax.swing.JComponent;
- import javax.swing.border.BevelBorder;
- import javax.swing.text.JTextComponent;
- import org.w3c.dom.Element;
-
- public class AttribEditor implements FocusListener, ItemListener {
- // $FF: renamed from: el org.w3c.dom.Element
- Element field_0;
- JComponent control;
- String name;
- boolean textfield = false;
- String oldText = null;
- XMLPro theApp;
-
- AttribEditor(String var1, String var2, Element var3, boolean var4, XMLPro var5) {
- this.theApp = var5;
- int var6 = 5;
- if (var1 != null) {
- var6 = (int)((double)var1.length() / 1.3);
- }
-
- if (var6 < 5) {
- var6 = 5;
- }
-
- this.control = new KTextAtt(var6, this);
- this.oldText = var3.getAttribute(var2);
- if (var1 != null) {
- ((KTextAtt)this.control).setText(StringUtils.replaceStr(var1, "<", '<'));
- }
-
- ((KTextAtt)this.control).setBorder(new BevelBorder(1));
- this.textfield = true;
- this.field_0 = var3;
- this.name = var2;
- if (var4 && !this.theApp.editFixedAttributes) {
- this.control.setEnabled(false);
- }
-
- this.control.addFocusListener(this);
- }
-
- AttribEditor(String var1, Vector var2, String var3, Element var4, boolean var5, XMLPro var6) {
- this.theApp = var6;
- boolean var7 = false;
- boolean var8 = false;
- boolean var9 = false;
- this.control = new JComboBox();
- ((JComboBox)this.control).setBorder(new BevelBorder(1));
- this.oldText = var4.getAttribute(var3);
- Enumeration var10 = var2.elements();
-
- while(var10.hasMoreElements()) {
- String var11 = (String)var10.nextElement();
- ((JComboBox)this.control).addItem(var11);
- if (var11.equals(var1)) {
- var9 = true;
- ((JComboBox)this.control).setSelectedItem(var11);
- }
- }
-
- if (!var9) {
- ((JComboBox)this.control).addItem(var1);
- ((JComboBox)this.control).setSelectedItem(var1);
- }
-
- this.field_0 = var4;
- this.name = var3;
- ((JComboBox)this.control).addItemListener(this);
- if (var5 && !this.theApp.editFixedAttributes) {
- this.control.setEnabled(false);
- }
-
- }
-
- public void focusGained(FocusEvent var1) {
- this.theApp.treeSelected = false;
- if (this.theApp.lastText != null && this.theApp.lastText != this.control) {
- this.theApp.lastText.setSelectionStart(0);
- this.theApp.lastText.setSelectionEnd(0);
- }
-
- }
-
- public void focusLost(FocusEvent var1) {
- ElemNode var3 = this.theApp.elems.selectedElem;
- this.oldText = this.field_0.getAttribute(this.name);
- String var2 = ((JTextComponent)this.control).getText();
- var2 = StringUtils.replaceStr(var2, '<', "<");
- if (this.oldText == null || !this.oldText.equals(var2)) {
- if (var2.length() > 0) {
- this.field_0.setAttribute(this.name, var2);
- } else {
- this.field_0.removeAttribute(this.name);
- }
-
- this.theApp.xmlDocument.validated = false;
- this.theApp.xmlDocument.modified = true;
- this.theApp.undoManager.attributeTextMod(var3, this.name, this.oldText);
- }
-
- this.oldText = var2;
- if (this.control instanceof JTextComponent) {
- this.theApp.lastText = (JTextComponent)this.control;
- }
-
- }
-
- public void itemStateChanged(ItemEvent var1) {
- if (this.theApp.lastText != null) {
- this.theApp.lastText.setSelectionStart(0);
- this.theApp.lastText.setSelectionEnd(0);
- }
-
- if (var1.getStateChange() == 1) {
- ElemNode var2 = this.theApp.elems.selectedElem;
- String var3 = (String)((JComboBox)this.control).getSelectedItem();
- this.oldText = this.field_0.getAttribute(this.name);
- this.field_0.setAttribute(this.name, var3);
- this.theApp.xmlDocument.validated = false;
- this.theApp.xmlDocument.modified = true;
- this.theApp.undoManager.attributeTextMod(var2, this.name, this.oldText);
- }
-
- }
- }
-