Source code: org/meowers/cide/edcide/tileset/TileSetEditor.java
1 /*
2 * TileSetEditor.java
3 *
4 * Created on February 11, 2002, 2:52 AM
5 */
6
7 package org.meowers.cide.edcide.tileset;
8
9 import org.meowers.cide.data.*;
10 import org.meowers.cide.edcide.*;
11 import org.meowers.cide.edcide.map.*;
12
13 /**
14 *
15 * @author praxis
16 */
17 public class TileSetEditor extends EdCideEditor {
18
19 private GameData gd;
20 private EdCideTreeNode tileSetNode;
21 private TileSet tileSet;
22
23 /** Creates new form TileSetEditor */
24 public TileSetEditor() {
25 initComponents();
26
27 }
28
29 public TileSetEditor(GameData gd, EdCideTreeNode tileSetNode) {
30 initComponents();
31 this.gd = gd;
32 this.tileSetNode = tileSetNode;
33 tileSet = (TileSet) tileSetNode.getGameObject();
34
35 // name
36 nameTextField.setText(tileSet.getName());
37
38 allTilesList.setCellRenderer(new TileListCellRenderer());
39 allTilesList.setModel(new TileListModel(gd));
40
41 setTilesList.setCellRenderer(new TileListCellRenderer());
42 setTilesList.setModel(new TileListModel(tileSet));
43
44 }
45
46 /** This method is called from within the constructor to
47 * initialize the form.
48 * WARNING: Do NOT modify this code. The content of this method is
49 * always regenerated by the Form Editor.
50 */
51 private void initComponents() {//GEN-BEGIN:initComponents
52 jPanel1 = new javax.swing.JPanel();
53 nameLabel = new javax.swing.JLabel();
54 nameTextField = new javax.swing.JTextField();
55 centerPanel = new javax.swing.JPanel();
56 allTilesScrollPane = new javax.swing.JScrollPane();
57 allTilesList = new javax.swing.JList();
58 conrolPanel = new javax.swing.JPanel();
59 addButton = new javax.swing.JButton();
60 removeButton = new javax.swing.JButton();
61 setTilesScrollPane = new javax.swing.JScrollPane();
62 setTilesList = new javax.swing.JList();
63
64 setLayout(new java.awt.BorderLayout());
65
66 nameLabel.setText("Name");
67 jPanel1.add(nameLabel);
68
69 nameTextField.setPreferredSize(new java.awt.Dimension(85, 17));
70 jPanel1.add(nameTextField);
71
72 add(jPanel1, java.awt.BorderLayout.NORTH);
73
74 centerPanel.setLayout(new java.awt.GridLayout(1, 0));
75
76 allTilesScrollPane.setViewportView(allTilesList);
77
78 centerPanel.add(allTilesScrollPane);
79
80 addButton.setText("Add -->");
81 addButton.addActionListener(new java.awt.event.ActionListener() {
82 public void actionPerformed(java.awt.event.ActionEvent evt) {
83 addButtonActionPerformed(evt);
84 }
85 });
86
87 conrolPanel.add(addButton);
88
89 removeButton.setText("<-- Remove");
90 removeButton.addActionListener(new java.awt.event.ActionListener() {
91 public void actionPerformed(java.awt.event.ActionEvent evt) {
92 removeButtonActionPerformed(evt);
93 }
94 });
95
96 conrolPanel.add(removeButton);
97
98 centerPanel.add(conrolPanel);
99
100 setTilesScrollPane.setViewportView(setTilesList);
101
102 centerPanel.add(setTilesScrollPane);
103
104 add(centerPanel, java.awt.BorderLayout.CENTER);
105
106 }//GEN-END:initComponents
107
108 private void removeButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeButtonActionPerformed
109 tileSet.removeTile((Tile) setTilesList.getSelectedValue());
110 ((TileListModel) setTilesList.getModel()).changed();
111 }//GEN-LAST:event_removeButtonActionPerformed
112
113 private void addButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addButtonActionPerformed
114 tileSet.addTile((Tile) allTilesList.getSelectedValue());
115 ((TileListModel) setTilesList.getModel()).changed();
116 }//GEN-LAST:event_addButtonActionPerformed
117
118 public boolean apply() {
119 tileSet.setName(nameTextField.getText());
120 tileSetNode.updateText();
121 return true;
122 }
123
124 public void revert() {
125 }
126
127 // Variables declaration - do not modify//GEN-BEGIN:variables
128 private javax.swing.JPanel jPanel1;
129 private javax.swing.JLabel nameLabel;
130 private javax.swing.JTextField nameTextField;
131 private javax.swing.JPanel centerPanel;
132 private javax.swing.JScrollPane allTilesScrollPane;
133 private javax.swing.JList allTilesList;
134 private javax.swing.JPanel conrolPanel;
135 private javax.swing.JButton addButton;
136 private javax.swing.JButton removeButton;
137 private javax.swing.JScrollPane setTilesScrollPane;
138 private javax.swing.JList setTilesList;
139 // End of variables declaration//GEN-END:variables
140
141 }