/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.OkCancelDialog; /* */ import java.awt.Choice; /* */ import java.awt.Event; /* */ import java.awt.GridBagConstraints; /* */ import java.awt.List; /* */ import java.awt.TextField; /* */ import java.util.Enumeration; /* */ import java.util.StringTokenizer; /* */ import java.util.Vector; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ class LibEntContentEditorDialog /* */ extends OkCancelDialog /* */ { /* */ private static final long serialVersionUID = 1L; /* */ private Property property; /* 32 */ private TextField strField = new TextField(40); /* 33 */ private List list = new List(); /* 34 */ private Choice choice = new Choice(); /* */ /* */ private EditTile parent; /* 37 */ private static String[] choices = { /* 38 */ "WObject files", /* 39 */ "Behavior/Action files", /* 40 */ "Texture files" }; /* */ /* */ /* 43 */ private static String[] dirs = { /* 44 */ LibrariesTile.getLibSubdir(), /* 45 */ LibrariesTile.getLibSubdir(), /* 46 */ LibrariesTile.getLibSubdir() }; /* */ /* */ /* 49 */ private static String[] exts = { /* 50 */ WObject.getSaveExtension(), /* 51 */ "class", /* 52 */ TextureDecoder.getAllExts() }; /* */ /* */ /* */ /* */ LibEntContentEditorDialog(EditTile parent, String title, Property property) /* */ { /* 58 */ super(Console.getFrame(), parent, title); /* 59 */ this.property = property; /* 60 */ this.parent = parent; /* 61 */ ready(); /* */ } /* */ /* */ private void matchExt(String name) /* */ { /* 66 */ int lastDot = name.lastIndexOf('.'); /* 67 */ if (lastDot != -1) { /* 68 */ String ext = name.substring(lastDot + 1).toLowerCase(); /* 69 */ for (int i = 0; i < exts.length; i++) { /* 70 */ StringTokenizer t = new StringTokenizer(exts[i], ";"); /* 71 */ while (t.hasMoreTokens()) { /* 72 */ if (ext.equals(t.nextToken())) { /* 73 */ this.choice.select(i); /* 74 */ return; /* */ } /* */ } /* */ } /* */ } /* */ } /* */ /* */ protected void build() { /* 82 */ for (int i = 0; i < choices.length; i++) { /* 83 */ this.choice.addItem(choices[i]); /* */ } /* 85 */ String name = (String)this.property.get(); /* 86 */ if (name == null) { /* 87 */ name = ""; /* */ } /* 89 */ this.strField.setText(name); /* */ /* 91 */ matchExt(name); /* */ /* 93 */ setListContents(); /* */ /* 95 */ GridBagConstraints c = new GridBagConstraints(); /* 96 */ c.fill = 2; /* 97 */ c.weightx = 1.0D; /* 98 */ c.weighty = 1.0D; /* 99 */ c.gridwidth = 0; /* 100 */ add(this.gbag, this.strField, c); /* 101 */ c.gridheight = 6; /* 102 */ add(this.gbag, this.list, c); /* 103 */ c.gridheight = 1; /* 104 */ add(this.gbag, this.choice, c); /* 105 */ super.build(); /* */ } /* */ /* */ private void setListContents() /* */ { /* 110 */ int count = this.list.getItemCount(); /* 111 */ if (count != 0) /* */ { /* 113 */ this.list.removeAll(); /* */ } /* 115 */ int chosen = this.choice.getSelectedIndex(); /* 116 */ Enumeration files = new FileList(dirs[chosen], exts[chosen]) /* 117 */ .getList().elements(); /* 118 */ while (files.hasMoreElements()) { /* 119 */ this.list.add((String)files.nextElement()); /* */ } /* 121 */ String s = (String)this.property.get(); /* 122 */ this.strField.setText(s != null ? s : ""); /* */ } /* */ /* */ @Deprecated /* */ public boolean handleEvent(Event event) { /* 127 */ if (event.id == 701) { /* 128 */ this.strField.setText(this.list.getSelectedItem()); /* 129 */ this.strField.selectAll(); /* */ } /* 131 */ return super.handleEvent(event); /* */ } /* */ /* */ @Deprecated /* */ public boolean action(Event event, Object what) /* */ { /* 137 */ if (event.target == this.list) /* 138 */ event.target = this.okButton; /* 139 */ if (event.target == this.choice) /* 140 */ setListContents(); /* 141 */ return super.action(event, what); /* */ } /* */ /* */ protected boolean setValue() /* */ { /* 146 */ String text = this.strField.getText().trim(); /* 147 */ if (text.length() != 0) { /* 148 */ this.parent.addUndoableSet(this.property, text); /* 149 */ return true; /* */ } /* 151 */ return false; /* */ } /* */ /* */ /* */ /* */ public void setVisible(boolean visible) /* */ { /* 158 */ super.setVisible(visible); /* 159 */ if (visible) { /* 160 */ this.strField.requestFocus(); /* 161 */ this.strField.selectAll(); /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\LibEntContentEditorDialog.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */