OSDN Git Service

キャンセルボタンの処理実装
authoryukihane <yukihane.feather@gmail.com>
Tue, 30 Aug 2011 05:45:37 +0000 (14:45 +0900)
committeryukihane <yukihane.feather@gmail.com>
Tue, 30 Aug 2011 05:45:37 +0000 (14:45 +0900)
frontend/src/yukihane/inqubus/gui/MainFrame.java
frontend/src/yukihane/inqubus/model/Target.java
frontend/src/yukihane/inqubus/model/TargetsTableModel.java

index 44a2b7c..0c60591 100644 (file)
@@ -144,6 +144,7 @@ public class MainFrame extends JFrame {
 
         setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
 
+        btnStop.addActionListener(new StopActionListener());
         btnApply.addActionListener(new ApplyActionListener());
 
         pnlMain.setBorder(BorderFactory.createEtchedBorder());
@@ -367,6 +368,18 @@ public class MainFrame extends JFrame {
         }
     }
 
+    private class StopActionListener implements ActionListener {
+
+        @Override
+        public void actionPerformed(ActionEvent e) {
+            // FIXME 待機中に停止しても「状態」の表示が変わらない。
+            final int row = tblDisplay.getSelectedRow();
+            final Target t = targetModel.getTarget(row);
+            final boolean res = taskManager.cancel(t.getRowId());
+            logger.log(Level.FINE, "停止: {0} {1}", new Object[]{t.getVideoId(), res});
+        }
+    }
+
     private class ApplyActionListener implements ActionListener {
 
         @Override
index 2e7e923..1b67bc9 100644 (file)
@@ -19,7 +19,7 @@ public class Target {
         return requestProcess.getRowId();
     }
 
-    String getVideoId() {
+    public String getVideoId() {
         return getRequestProcess().getVideoId();
     }
 
index 380a099..af93f57 100644 (file)
@@ -84,6 +84,10 @@ public class TargetsTableModel extends AbstractTableModel {
         addTarget(list);
     }
 
+    public Target getTarget(int rowIndex) {
+        return targets.get(rowIndex);
+    }
+
     public void setStatus(int id, TaskKind taskKind, TaskStatus taskStatus, double percent, String status) {
         int pos = -1;
         for (int i = 0; i < targets.size(); i++) {