瀏覽代碼

Added Animation rename

Thomas Buck 13 年之前
父節點
當前提交
078d966a13
共有 2 個檔案被更改,包括 58 行新增11 行删除
  1. 56
    9
      Cube Control/frame.java
  2. 2
    2
      Cube Control/makefile

+ 56
- 9
Cube Control/frame.java 查看文件

66
   private JButton animDown = new JButton();
66
   private JButton animDown = new JButton();
67
   private JButton animAdd = new JButton();
67
   private JButton animAdd = new JButton();
68
   private JButton animRemove = new JButton();
68
   private JButton animRemove = new JButton();
69
+  private JButton animRename = new JButton();
69
   private JTextField animPath = new JTextField();
70
   private JTextField animPath = new JTextField();
70
   private JButton load = new JButton();
71
   private JButton load = new JButton();
71
   private JButton save = new JButton();
72
   private JButton save = new JButton();
85
     String[] Optionen = {"Yes", "No"};
86
     String[] Optionen = {"Yes", "No"};
86
     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
     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
     if (Auswahl == JOptionPane.YES_OPTION) {
88
     if (Auswahl == JOptionPane.YES_OPTION) {
88
-       worker.saveState(animPath.getText());
89
        return 1;
89
        return 1;
90
     } else {
90
     } else {
91
        return 0;
91
        return 0;
93
   }
93
   }
94
 
94
 
95
   private String askString(String title, String text) {
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
   private void errorMessage(String s) {
99
   private void errorMessage(String s) {
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
   public frame(String title) {
147
   public frame(String title) {
133
     // Frame-Initialisierung
148
     // Frame-Initialisierung
134
     super(title);
149
     super(title);
145
     addWindowListener(new WindowAdapter() {
160
     addWindowListener(new WindowAdapter() {
146
       public void windowClosing(WindowEvent evt) {
161
       public void windowClosing(WindowEvent evt) {
147
              if (worker.changedStateSinceSave()) {
162
              if (worker.changedStateSinceSave()) {
148
-                  saveExitDialog();
163
+                  if (saveExitDialog() == 1) {
164
+					  save();
165
+				  } else {
166
+					  return;
167
+				  }
149
              }
168
              }
150
              System.exit(0);
169
              System.exit(0);
151
       }
170
       }
292
 	cp.add(frameRename);
311
 	cp.add(frameRename);
293
 	frameRename.addActionListener(new ActionListener() {
312
 	frameRename.addActionListener(new ActionListener() {
294
 		public void actionPerformed(ActionEvent evt) {
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
 			frameList.setModel(frameListModel);
326
 			frameList.setModel(frameListModel);
298
 		}
327
 		}
299
 	});
328
 	});
322
     animList.setModel(animModel);
351
     animList.setModel(animModel);
323
     //jList2Model.addElement("");
352
     //jList2Model.addElement("");
324
     cp.add(animScrollPane);
353
     cp.add(animScrollPane);
354
+
325
     animUp.setBounds(224, 264, 99, 25);
355
     animUp.setBounds(224, 264, 99, 25);
326
     animUp.setText("Move up");
356
     animUp.setText("Move up");
327
     animUp.setFont(new Font("Dialog", Font.PLAIN, 13));
357
     animUp.setFont(new Font("Dialog", Font.PLAIN, 13));
332
       }
362
       }
333
     });
363
     });
334
 
364
 
335
-    animDown.setBounds(224, 360, 99, 25);
365
+    animDown.setBounds(224, 342, 99, 25);
336
     animDown.setText("Move down");
366
     animDown.setText("Move down");
337
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
367
     animDown.setFont(new Font("Dialog", Font.PLAIN, 13));
338
     cp.add(animDown);
368
     cp.add(animDown);
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
     animAdd.setText("Add");
393
     animAdd.setText("Add");
347
     animAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
394
     animAdd.setFont(new Font("Dialog", Font.PLAIN, 13));
348
     cp.add(animAdd);
395
     cp.add(animAdd);
352
       }
399
       }
353
     });
400
     });
354
 
401
 
355
-    animRemove.setBounds(224, 328, 99, 25);
402
+    animRemove.setBounds(224, 316, 99, 25);
356
     animRemove.setText("Remove");
403
     animRemove.setText("Remove");
357
     animRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
404
     animRemove.setFont(new Font("Dialog", Font.PLAIN, 13));
358
     cp.add(animRemove);
405
     cp.add(animRemove);
421
     });
468
     });
422
 
469
 
423
     jLabel4.setBounds(536, 208, 112, 20);
470
     jLabel4.setBounds(536, 208, 112, 20);
424
-    jLabel4.setText("Frames remaining:");
471
+    jLabel4.setText("Remaining:");
425
     jLabel4.setFont(new Font("Dialog", Font.PLAIN, 13));
472
     jLabel4.setFont(new Font("Dialog", Font.PLAIN, 13));
426
     cp.add(jLabel4);
473
     cp.add(jLabel4);
427
     frameRemaining.setBounds(536, 232, 113, 24);
474
     frameRemaining.setBounds(536, 232, 113, 24);

+ 2
- 2
Cube Control/makefile 查看文件

6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
6
 JAVAFILES = cubeWorker.java layerEditFrame.java frame.java
7
 
7
 
8
 ifeq ($(TARGET),win)
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
 else
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
 endif
12
 endif
13
 
13
 
14
 all: build clean
14
 all: build clean

Loading…
取消
儲存