Browse Source

Added Animation rename

Thomas Buck 12 years ago
parent
commit
078d966a13
2 changed files with 58 additions and 11 deletions
  1. 56
    9
      Cube Control/frame.java
  2. 2
    2
      Cube Control/makefile

+ 56
- 9
Cube Control/frame.java View File

@@ -66,6 +66,7 @@ public class frame extends JFrame implements ListSelectionListener {
66 66
   private JButton animDown = new JButton();
67 67
   private JButton animAdd = new JButton();
68 68
   private JButton animRemove = new JButton();
69
+  private JButton animRename = new JButton();
69 70
   private JTextField animPath = new JTextField();
70 71
   private JButton load = new JButton();
71 72
   private JButton save = new JButton();
@@ -85,7 +86,6 @@ public class frame extends JFrame implements ListSelectionListener {
85 86
     String[] Optionen = {"Yes", "No"};
86 87
     int Auswahl = JOptionPane.showOptionDialog(this, "Do you want to save your changes?", "Save?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, Optionen, Optionen[0]);
87 88
     if (Auswahl == JOptionPane.YES_OPTION) {
88
-       worker.saveState(animPath.getText());
89 89
        return 1;
90 90
     } else {
91 91
        return 0;
@@ -93,7 +93,7 @@ public class frame extends JFrame implements ListSelectionListener {
93 93
   }
94 94
 
95 95
   private String askString(String title, String text) {
96
-	  return JOptionPane.showInputDialog(null, title, text, JOptionPane.QUESTION_MESSAGE);
96
+	  return JOptionPane.showInputDialog(null, text, title, JOptionPane.QUESTION_MESSAGE);
97 97
   }
98 98
 
99 99
   private void errorMessage(String s) {
@@ -129,6 +129,21 @@ public class frame extends JFrame implements ListSelectionListener {
129 129
     }
130 130
   }
131 131
 
132
+  private void save() {
133
+	  if (fileSelected == false) {
134
+  		  JFileChooser fc = new JFileChooser();
135
+  		  int ret = fc.showSaveDialog(this);
136
+    	  if (ret == JFileChooser.APPROVE_OPTION) {
137
+      		File file = fc.getSelectedFile();
138
+      		fileSelected = true;
139
+      		animPath.setText(file.getPath());
140
+      		worker.saveState(animPath.getText());
141
+    	  }
142
+  	  } else {
143
+    	worker.saveState(animPath.getText());
144
+  	  }
145
+  }
146
+
132 147
   public frame(String title) {
133 148
     // Frame-Initialisierung
134 149
     super(title);
@@ -145,7 +160,11 @@ public class frame extends JFrame implements ListSelectionListener {
145 160
     addWindowListener(new WindowAdapter() {
146 161
       public void windowClosing(WindowEvent evt) {
147 162
              if (worker.changedStateSinceSave()) {
148
-                  saveExitDialog();
163
+                  if (saveExitDialog() == 1) {
164
+					  save();
165
+				  } else {
166
+					  return;
167
+				  }
149 168
              }
150 169
              System.exit(0);
151 170
       }
@@ -292,8 +311,18 @@ public class frame extends JFrame implements ListSelectionListener {
292 311
 	cp.add(frameRename);
293 312
 	frameRename.addActionListener(new ActionListener() {
294 313
 		public void actionPerformed(ActionEvent evt) {
295
-			worker.setFrameName(askString("Rename", "Rename " + frameList.getSelectedValue()), animList.getSelectedIndex(), frameList.getSelectedIndex());
296
-			frameListModel.set(frameList.getSelectedIndex(), worker.getFrameName(animList.getSelectedIndex(), frameList.getSelectedIndex()));
314
+			int a = animList.getSelectedIndex();
315
+			if (a < 0) {
316
+				errorMessage("Select an animation!");
317
+				return;
318
+			}
319
+			int f = frameList.getSelectedIndex();
320
+			if (f < 0) {
321
+				errorMessage("Select a frame!");
322
+				return;
323
+			}
324
+			worker.setFrameName(askString("Rename", "Rename " + frameList.getSelectedValue() + "?"), a, f);
325
+			frameListModel.set(f, worker.getFrameName(a, f));
297 326
 			frameList.setModel(frameListModel);
298 327
 		}
299 328
 	});
@@ -322,6 +351,7 @@ public class frame extends JFrame implements ListSelectionListener {
322 351
     animList.setModel(animModel);
323 352
     //jList2Model.addElement("");
324 353
     cp.add(animScrollPane);
354
+
325 355
     animUp.setBounds(224, 264, 99, 25);
326 356
     animUp.setText("Move up");
327 357
     animUp.setFont(new Font("Dialog", Font.PLAIN, 13));
@@ -332,7 +362,7 @@ public class frame extends JFrame implements ListSelectionListener {
332 362
       }
333 363
     });
334 364
 
335
-    animDown.setBounds(224, 360, 99, 25);
365
+    animDown.setBounds(224, 342, 99, 25);
336 366
     animDown.setText("Move down");
337 367
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
338 368
     cp.add(animDown);
@@ -342,7 +372,24 @@ public class frame extends JFrame implements ListSelectionListener {
342 372
       }
343 373
     });
344 374
 
345
-    animAdd.setBounds(224, 296, 99, 25);
375
+	animRename.setBounds(224, 368, 99, 25);
376
+	animRename.setText("Rename");
377
+	animRename.setFont(new Font("Dialog", Font.PLAIN, 13));
378
+	cp.add(animRename);
379
+	animRename.addActionListener(new ActionListener() {
380
+		public void actionPerformed(ActionEvent evt) {
381
+			int a = animList.getSelectedIndex();
382
+			if (a < 0) {
383
+				errorMessage("Select an animation!");
384
+				return;
385
+			}
386
+			worker.setAnimationName(askString("Rename", "Rename " + animList.getSelectedValue() + "?"), a);
387
+			animModel.set(a, worker.getAnimationName(a));
388
+			animList.setModel(animModel);
389
+		}
390
+	});
391
+
392
+    animAdd.setBounds(224, 290, 99, 25);
346 393
     animAdd.setText("Add");
347 394
     animAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
348 395
     cp.add(animAdd);
@@ -352,7 +399,7 @@ public class frame extends JFrame implements ListSelectionListener {
352 399
       }
353 400
     });
354 401
 
355
-    animRemove.setBounds(224, 328, 99, 25);
402
+    animRemove.setBounds(224, 316, 99, 25);
356 403
     animRemove.setText("Remove");
357 404
     animRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
358 405
     cp.add(animRemove);
@@ -421,7 +468,7 @@ public class frame extends JFrame implements ListSelectionListener {
421 468
     });
422 469
 
423 470
     jLabel4.setBounds(536, 208, 112, 20);
424
-    jLabel4.setText("Frames remaining:");
471
+    jLabel4.setText("Remaining:");
425 472
     jLabel4.setFont(new Font("Dialog", Font.PLAIN, 13));
426 473
     cp.add(jLabel4);
427 474
     frameRemaining.setBounds(536, 232, 113, 24);

+ 2
- 2
Cube Control/makefile View File

@@ -6,9 +6,9 @@ TARGET = unix
6 6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
7 7
 
8 8
 ifeq ($(TARGET),win)
9
-CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class frame$$23.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
9
+CLASSES = cubeWorker.class layerEditFrame.class layerEditFrame$$1.class layerEditFrame$$2.class layerEditFrame$$3.class layerEditFrame$$4.class frame.class frame$$1.class frame$$2.class frame$$3.class frame$$4.class frame$$5.class frame$$6.class frame$$7.class frame$$8.class frame$$9.class frame$$10.class frame$$11.class frame$$12.class frame$$13.class frame$$14.class frame$$15.class frame$$16.class frame$$17.class frame$$18.class frame$$19.class frame$$20.class frame$$21.class frame$$22.class frame$$23.class frame$$24.class AFrame.class Animation.class AnimationUtility.class LEDoff.png LEDon.png
10 10
 else
11
-CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'frame$$23.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
11
+CLASSES = 'cubeWorker.class' 'layerEditFrame.class' 'layerEditFrame$$1.class' 'layerEditFrame$$2.class' 'layerEditFrame$$3.class' 'layerEditFrame$$4.class' 'frame.class' 'frame$$1.class' 'frame$$2.class' 'frame$$3.class' 'frame$$4.class' 'frame$$5.class' 'frame$$6.class' 'frame$$7.class' 'frame$$8.class' 'frame$$9.class' 'frame$$10.class' 'frame$$11.class' 'frame$$12.class' 'frame$$13.class' 'frame$$14.class' 'frame$$15.class' 'frame$$16.class' 'frame$$17.class' 'frame$$18.class' 'frame$$19.class' 'frame$$20.class' 'frame$$21.class' 'frame$$22.class' 'frame$$23.class' 'frame$$24.class' 'AFrame.class' 'Animation.class' 'AnimationUtility.class' 'LEDoff.png' 'LEDon.png'
12 12
 endif
13 13
 
14 14
 all: build clean

Loading…
Cancel
Save