@SuppressWarnings("rawtypes") private JComponent makeEditor(LibArgument la) { switch (arg.kind) { case Argument.ARG_BOOLEAN: final String[] sab = {"false", "true"}; return new JComboBox(sab); case Argument.ARG_MENU: if (la == null) return new JTextField(arg.getVal()); final String[] sam = la.menu.split("\\|"); // $NON-NLS-1$ return new JComboBox(sam); case Argument.ARG_COLOR: return new ColorSelect(Util.convertGmColor(Integer.parseInt(arg.getVal()))); case Argument.ARG_SPRITE: case Argument.ARG_SOUND: case Argument.ARG_BACKGROUND: case Argument.ARG_PATH: case Argument.ARG_SCRIPT: case Argument.ARG_GMOBJECT: case Argument.ARG_ROOM: case Argument.ARG_FONT: case Argument.ARG_TIMELINE: Resource.Kind rk = Argument.getResourceKind(arg.kind); return new ResourceMenu(rk, getNoSelectionString(rk), 120); default: return new JTextField(arg.getVal()); } }
@SuppressWarnings({"unchecked", "rawtypes"}) public void discard() { if (editor instanceof JTextField) { ((JTextField) editor).setText(arg.getVal()); } else if (editor instanceof JComboBox) { ((JComboBox) editor).setSelectedIndex(Integer.parseInt(arg.getVal())); } else if (editor instanceof ColorSelect) { Color c = Util.convertGmColor(Integer.parseInt(arg.getVal())); ((ColorSelect) editor).setSelectedColor(c); } else if (editor instanceof ResourceMenu) { try { ((ResourceMenu) editor).setSelected(arg.getRes()); } catch (NumberFormatException nfe) { } } }