~soylent-tv/truckliststudio/trickliststudiogit

« back to all changes in this revision

Viewing changes to src/truckliststudio/TrucklistStudio.java

  • Committer: Karl Ellis
  • Date: 2016-08-23 13:32:40 UTC
  • Revision ID: git-v1:6d4fd849eff0bfc9c367a43214c8bba29aaa6a2f
Update sources to TrucklistStudio 0.9.2 build 77

Show diffs side-by-side

added added

removed removed

Lines of Context:
41
41
import java.util.Properties;
42
42
import java.util.Set;
43
43
import java.util.TreeSet;
 
44
import java.util.concurrent.Executors;
 
45
import java.util.concurrent.ScheduledExecutorService;
 
46
import java.util.concurrent.TimeUnit;
44
47
import java.util.logging.Level;
45
48
import java.util.logging.Logger;
46
49
import java.util.prefs.BackingStoreException;
149
152
    public static boolean x64 = false;
150
153
    public static boolean winGS = false;
151
154
    private boolean editingPhase = true;
 
155
    private boolean mooving = false;
 
156
    private int prevIndex = 0;
 
157
    private int selIndex = 0;
 
158
    boolean loadingFinish = false;
152
159
 
153
160
    @Override
154
161
    public void closeSource(String name) {
573
580
        listenerOP.resetSinks(null);
574
581
        if (cmdFile != null) {
575
582
            loadAtStart(cmdFile, null);
 
583
            while (!loadingFinish) {
 
584
                Tools.sleep(1000);
 
585
                System.out.println("Load Finish: " + loadingFinish);
 
586
            }
576
587
        }
577
588
        if (cmdOut != null) {
578
589
            listenerOP.addLoadingTrack(cmdOut); // used addLoadingTrack to activate Output from command line.
579
590
        }
580
591
        if (cmdAutoStart) {
581
 
            listenerTSTP.resetSinks(null); // used resetSinks to AutoPlay from command line.
 
592
            if (loadingFinish) {
 
593
                Tools.sleep(2000);
 
594
                listenerTSTP.resetSinks(null); // used resetSinks to AutoPlay from command line.
 
595
            }
582
596
        }
583
597
        if (cmdRemote) {
584
598
            listenerTSTP.setRemoteOn();
1224
1238
        jSeparator4.setOpaque(true);
1225
1239
        toolbar.add(jSeparator4);
1226
1240
 
1227
 
        tglAutoAR.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_button.png"))); // NOI18N
 
1241
        tglAutoAR.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_flat_button.png"))); // NOI18N
1228
1242
        tglAutoAR.setToolTipText("Automatic A/R detection Switch.");
1229
1243
        tglAutoAR.setFocusable(false);
1230
1244
        tglAutoAR.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
1232
1246
        tglAutoAR.setMinimumSize(new java.awt.Dimension(25, 25));
1233
1247
        tglAutoAR.setName("tglAutoAR"); // NOI18N
1234
1248
        tglAutoAR.setPreferredSize(new java.awt.Dimension(28, 29));
1235
 
        tglAutoAR.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_button.png"))); // NOI18N
1236
 
        tglAutoAR.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_button_selected.png"))); // NOI18N
 
1249
        tglAutoAR.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_flat_button.png"))); // NOI18N
 
1250
        tglAutoAR.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/ar_flat_button_selected.png"))); // NOI18N
1237
1251
        tglAutoAR.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
1238
1252
        tglAutoAR.addActionListener(new java.awt.event.ActionListener() {
1239
1253
            public void actionPerformed(java.awt.event.ActionEvent evt) {
1242
1256
        });
1243
1257
        toolbar.add(tglAutoAR);
1244
1258
 
1245
 
        tglAutoTrack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button.png"))); // NOI18N
 
1259
        tglAutoTrack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button_Flat.png"))); // NOI18N
1246
1260
        tglAutoTrack.setToolTipText("Automatic \"Make a Track\" Switch.");
1247
1261
        tglAutoTrack.setFocusable(false);
1248
1262
        tglAutoTrack.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
1250
1264
        tglAutoTrack.setMinimumSize(new java.awt.Dimension(25, 25));
1251
1265
        tglAutoTrack.setName("tglAutoTrack"); // NOI18N
1252
1266
        tglAutoTrack.setPreferredSize(new java.awt.Dimension(28, 29));
1253
 
        tglAutoTrack.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button.png"))); // NOI18N
1254
 
        tglAutoTrack.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button_selected2.png"))); // NOI18N
 
1267
        tglAutoTrack.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button_Flat.png"))); // NOI18N
 
1268
        tglAutoTrack.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/track_button_selected_Flat.png"))); // NOI18N
1255
1269
        tglAutoTrack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
1256
1270
        tglAutoTrack.addActionListener(new java.awt.event.ActionListener() {
1257
1271
            public void actionPerformed(java.awt.event.ActionEvent evt) {
1260
1274
        });
1261
1275
        toolbar.add(tglAutoTrack);
1262
1276
 
1263
 
        tglAutoTitle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText.png"))); // NOI18N
 
1277
        tglAutoTitle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText_Flat.png"))); // NOI18N
1264
1278
        tglAutoTitle.setToolTipText("Automatic make a Text overlay Title for each Track");
1265
1279
        tglAutoTitle.setFocusable(false);
1266
1280
        tglAutoTitle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
1268
1282
        tglAutoTitle.setMinimumSize(new java.awt.Dimension(25, 25));
1269
1283
        tglAutoTitle.setName("tglAutoTitle"); // NOI18N
1270
1284
        tglAutoTitle.setPreferredSize(new java.awt.Dimension(28, 29));
1271
 
        tglAutoTitle.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText.png"))); // NOI18N
1272
 
        tglAutoTitle.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText_active.png"))); // NOI18N
 
1285
        tglAutoTitle.setRolloverIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText_Flat.png"))); // NOI18N
 
1286
        tglAutoTitle.setSelectedIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/overlayText_active_Flat.png"))); // NOI18N
1273
1287
        tglAutoTitle.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
1274
1288
        tglAutoTitle.addActionListener(new java.awt.event.ActionListener() {
1275
1289
            public void actionPerformed(java.awt.event.ActionEvent evt) {
1278
1292
        });
1279
1293
        toolbar.add(tglAutoTitle);
1280
1294
 
1281
 
        btnApplyTitle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/apply_titling.png"))); // NOI18N
 
1295
        btnApplyTitle.setIcon(new javax.swing.ImageIcon(getClass().getResource("/truckliststudio/resources/tango/apply_titling_Flat.png"))); // NOI18N
1282
1296
        btnApplyTitle.setToolTipText(bundle.getString("ICON_ALL")); // NOI18N
1283
1297
        btnApplyTitle.setFocusable(false);
1284
1298
        btnApplyTitle.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
2223
2237
                                String[] videoNativeSize = null;
2224
2238
                                int w = 0;
2225
2239
                                int h = 0;
2226
 
//                                if (os == OS.WINDOWS) {
2227
 
//                                    String[] lineRParts = lineR.split(",");
2228
 
//                                    String[] tempNativeSize = lineRParts[3].split(" ");
2229
 
//                                    videoNativeSize = tempNativeSize[1].split("x");
2230
 
//                                } else {
2231
 
                                    String[] lineRParts = lineR.split(",");
2232
 
                                    String[] tempNativeSize = lineRParts[2].split(" ");
2233
 
                                    videoNativeSize = tempNativeSize[1].split("x");
2234
 
//                                }
 
2240
                                String[] lineRParts = lineR.split(",");
 
2241
                                String[] tempNativeSize = lineRParts[2].split(" ");
 
2242
                                videoNativeSize = tempNativeSize[1].split("x");
2235
2243
                                try {
2236
2244
                                    w = Integer.parseInt(videoNativeSize[0]);
2237
2245
                                    h = Integer.parseInt(videoNativeSize[1]);
3276
3284
    }//GEN-LAST:event_tabSourcesMouseClicked
3277
3285
 
3278
3286
    private void videoDesktopMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_videoDesktopMouseWheelMoved
3279
 
        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3280
 
        int dir = evt.getWheelRotation();
3281
 
        int selIndex = tabPane.getSelectedIndex();
3282
 
        int maxIndex = tabPane.getTabCount() - 1;
3283
 
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
3284
 
            selIndex = maxIndex - selIndex;
 
3287
        JTabbedPane pane = (JTabbedPane) evt.getSource();
 
3288
        int units = evt.getWheelRotation();
 
3289
        int oldIndex = pane.getSelectedIndex();
 
3290
        int newIndex = oldIndex + units;
 
3291
        Tools.sleep(30);
 
3292
        if (newIndex < 0) {
 
3293
            pane.setSelectedIndex(0);
 
3294
        } else if (newIndex >= pane.getTabCount()) {
 
3295
            pane.setSelectedIndex(pane.getTabCount() - 1);
3285
3296
        } else {
3286
 
            selIndex += dir;
 
3297
            pane.setSelectedIndex(newIndex);
3287
3298
        }
3288
 
        tabPane.setSelectedIndex(selIndex);
 
3299
//        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
 
3300
//        int dir = evt.getWheelRotation();
 
3301
//        int selIndex = tabPane.getSelectedIndex();
 
3302
//        int maxIndex = tabPane.getTabCount() - 1;
 
3303
//        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
 
3304
//            selIndex = maxIndex - selIndex;
 
3305
//        } else {
 
3306
//            selIndex += dir;
 
3307
//        }
 
3308
//        tabPane.setSelectedIndex(selIndex);
3289
3309
    }//GEN-LAST:event_videoDesktopMouseWheelMoved
3290
3310
 
3291
3311
    private void musicDesktopMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_musicDesktopMouseWheelMoved
3292
 
        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3293
 
        int dir = evt.getWheelRotation();
3294
 
        int selIndex = tabPane.getSelectedIndex();
3295
 
        int maxIndex = tabPane.getTabCount() - 1;
3296
 
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
3297
 
            selIndex = maxIndex - selIndex;
 
3312
        JTabbedPane pane = (JTabbedPane) evt.getSource();
 
3313
        int units = evt.getWheelRotation();
 
3314
        int oldIndex = pane.getSelectedIndex();
 
3315
        int newIndex = oldIndex + units;
 
3316
        Tools.sleep(30);
 
3317
        if (newIndex < 0) {
 
3318
            pane.setSelectedIndex(0);
 
3319
        } else if (newIndex >= pane.getTabCount()) {
 
3320
            pane.setSelectedIndex(pane.getTabCount() - 1);
3298
3321
        } else {
3299
 
            selIndex += dir;
 
3322
            pane.setSelectedIndex(newIndex);
3300
3323
        }
3301
 
        tabPane.setSelectedIndex(selIndex);
 
3324
//        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
 
3325
//        int dir = evt.getWheelRotation();
 
3326
//        int selIndex = tabPane.getSelectedIndex();
 
3327
//        int maxIndex = tabPane.getTabCount() - 1;
 
3328
//        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
 
3329
//            selIndex = maxIndex - selIndex;
 
3330
//        } else {
 
3331
//            selIndex += dir;
 
3332
//        }
 
3333
//        tabPane.setSelectedIndex(selIndex);
3302
3334
    }//GEN-LAST:event_musicDesktopMouseWheelMoved
3303
3335
 
3304
3336
    private void pictureDesktopMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_pictureDesktopMouseWheelMoved
3305
 
        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3306
 
        int dir = evt.getWheelRotation();
3307
 
        int selIndex = tabPane.getSelectedIndex();
3308
 
        int maxIndex = tabPane.getTabCount() - 1;
3309
 
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
3310
 
            selIndex = maxIndex - selIndex;
 
3337
        JTabbedPane pane = (JTabbedPane) evt.getSource();
 
3338
        int units = evt.getWheelRotation();
 
3339
        int oldIndex = pane.getSelectedIndex();
 
3340
        int newIndex = oldIndex + units;
 
3341
        Tools.sleep(30);
 
3342
        if (newIndex < 0) {
 
3343
            pane.setSelectedIndex(0);
 
3344
        } else if (newIndex >= pane.getTabCount()) {
 
3345
            pane.setSelectedIndex(pane.getTabCount() - 1);
3311
3346
        } else {
3312
 
            selIndex += dir;
 
3347
            pane.setSelectedIndex(newIndex);
3313
3348
        }
3314
 
        tabPane.setSelectedIndex(selIndex);
 
3349
//        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
 
3350
//        int dir = evt.getWheelRotation();
 
3351
//        int selIndex = tabPane.getSelectedIndex();
 
3352
//        int maxIndex = tabPane.getTabCount() - 1;
 
3353
//        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
 
3354
//            selIndex = maxIndex - selIndex;
 
3355
//        } else {
 
3356
//            selIndex += dir;
 
3357
//        }
 
3358
//        tabPane.setSelectedIndex(selIndex);
3315
3359
    }//GEN-LAST:event_pictureDesktopMouseWheelMoved
3316
3360
 
3317
3361
    private void textDesktopMouseWheelMoved(java.awt.event.MouseWheelEvent evt) {//GEN-FIRST:event_textDesktopMouseWheelMoved
3318
 
        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3319
 
        int dir = evt.getWheelRotation();
3320
 
        int selIndex = tabPane.getSelectedIndex();
3321
 
        int maxIndex = tabPane.getTabCount() - 1;
3322
 
        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
3323
 
            selIndex = maxIndex - selIndex;
 
3362
        JTabbedPane pane = (JTabbedPane) evt.getSource();
 
3363
        int units = evt.getWheelRotation();
 
3364
        int oldIndex = pane.getSelectedIndex();
 
3365
        int newIndex = oldIndex + units;
 
3366
        Tools.sleep(30);
 
3367
        if (newIndex < 0) {
 
3368
            pane.setSelectedIndex(0);
 
3369
        } else if (newIndex >= pane.getTabCount()) {
 
3370
            pane.setSelectedIndex(pane.getTabCount() - 1);
3324
3371
        } else {
3325
 
            selIndex += dir;
 
3372
            pane.setSelectedIndex(newIndex);
3326
3373
        }
3327
 
        tabPane.setSelectedIndex(selIndex);
 
3374
//        JTabbedPane tabPane = (JTabbedPane) evt.getSource();
 
3375
//        int dir = evt.getWheelRotation();
 
3376
//        int selIndex = tabPane.getSelectedIndex();
 
3377
//        int maxIndex = tabPane.getTabCount() - 1;
 
3378
//        if ((selIndex == 0 && dir < 0) || (selIndex == maxIndex && dir > 0)) {
 
3379
//            selIndex = maxIndex - selIndex;
 
3380
//        } else {
 
3381
//            selIndex += dir;
 
3382
//        }
 
3383
//        tabPane.setSelectedIndex(selIndex);
3328
3384
    }//GEN-LAST:event_textDesktopMouseWheelMoved
3329
3385
 
3330
3386
    private void videoDesktopStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_videoDesktopStateChanged
3331
3387
        if (editingPhase) {
3332
3388
            JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3333
3389
            int selIndex = tabPane.getSelectedIndex();
3334
 
            if (selIndex != -1) {
3335
 
                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
3336
 
                for (Stream s : streamS) {
3337
 
                    if (s.getName().equals(streamName)) {
3338
 
                        selectedSource(s);
3339
 
                        if (s.isPlaying()) {
3340
 
                            btnRemoveSource.setEnabled(false);
3341
 
                        } else {
3342
 
                            btnRemoveSource.setEnabled(true);
 
3390
//            System.out.println("StateChanged Index = " + tabPane.getSelectedIndex());
 
3391
            Runnable task = () -> {
 
3392
                if (selIndex == tabPane.getSelectedIndex()) {
 
3393
//                    System.out.println("StateChanged Old Index = " + selIndex);
 
3394
                    if (selIndex != -1) {
 
3395
                        String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3396
                        for (Stream s : streamS) {
 
3397
                            if (s.getName().equals(streamName)) {
 
3398
                                selectedSource(s);
 
3399
                                if (s.isPlaying()) {
 
3400
                                    btnRemoveSource.setEnabled(false);
 
3401
                                } else {
 
3402
                                    btnRemoveSource.setEnabled(true);
 
3403
                                }
 
3404
                                break;
 
3405
                            }
3343
3406
                        }
3344
3407
                    }
3345
3408
                }
3346
 
            }
 
3409
            };
 
3410
            worker.schedule(task, 1, TimeUnit.SECONDS);
 
3411
//            if (selIndex != -1) {
 
3412
//                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3413
//                for (Stream s : streamS) {
 
3414
//                    if (s.getName().equals(streamName)) {
 
3415
//                        selectedSource(s);
 
3416
//                        if (s.isPlaying()) {
 
3417
//                            btnRemoveSource.setEnabled(false);
 
3418
//                        } else {
 
3419
//                            btnRemoveSource.setEnabled(true);
 
3420
//                        }
 
3421
//                    }
 
3422
//                }
 
3423
//            }
3347
3424
        }
3348
3425
    }//GEN-LAST:event_videoDesktopStateChanged
3349
3426
 
3351
3428
        if (editingPhase) {
3352
3429
            JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3353
3430
            int selIndex = tabPane.getSelectedIndex();
3354
 
            if (selIndex != -1) {
3355
 
                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
3356
 
                for (Stream s : streamS) {
3357
 
                    if (s.getName().equals(streamName)) {
3358
 
                        selectedSource(s);
3359
 
                        if (s.isPlaying()) {
3360
 
                            btnRemoveSource.setEnabled(false);
3361
 
                        } else {
3362
 
                            btnRemoveSource.setEnabled(true);
 
3431
            Runnable task = () -> {
 
3432
                if (selIndex == tabPane.getSelectedIndex()) {
 
3433
//                    System.out.println("StateChanged Old Index = " + selIndex);
 
3434
                    if (selIndex != -1) {
 
3435
                        String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3436
                        for (Stream s : streamS) {
 
3437
                            if (s.getName().equals(streamName)) {
 
3438
                                selectedSource(s);
 
3439
                                if (s.isPlaying()) {
 
3440
                                    btnRemoveSource.setEnabled(false);
 
3441
                                } else {
 
3442
                                    btnRemoveSource.setEnabled(true);
 
3443
                                }
 
3444
                                break;
 
3445
                            }
3363
3446
                        }
3364
3447
                    }
3365
3448
                }
3366
 
            }
 
3449
            };
 
3450
            worker.schedule(task, 1, TimeUnit.SECONDS);
 
3451
//            if (selIndex != -1) {
 
3452
//                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3453
//                for (Stream s : streamS) {
 
3454
//                    if (s.getName().equals(streamName)) {
 
3455
//                        selectedSource(s);
 
3456
//                        if (s.isPlaying()) {
 
3457
//                            btnRemoveSource.setEnabled(false);
 
3458
//                        } else {
 
3459
//                            btnRemoveSource.setEnabled(true);
 
3460
//                        }
 
3461
//                    }
 
3462
//                }
 
3463
//            }
3367
3464
        }
3368
3465
    }//GEN-LAST:event_musicDesktopStateChanged
3369
3466
 
3371
3468
        if (editingPhase) {
3372
3469
            JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3373
3470
            int selIndex = tabPane.getSelectedIndex();
3374
 
            if (selIndex != -1) {
3375
 
                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
3376
 
                for (Stream s : streamS) {
3377
 
                    if (s.getName().equals(streamName)) {
3378
 
                        selectedSource(s);
3379
 
                        if (s.isPlaying()) {
3380
 
                            btnRemoveSource.setEnabled(false);
3381
 
                        } else {
3382
 
                            btnRemoveSource.setEnabled(true);
 
3471
            Runnable task = () -> {
 
3472
                if (selIndex == tabPane.getSelectedIndex()) {
 
3473
//                    System.out.println("StateChanged Old Index = " + selIndex);
 
3474
                    if (selIndex != -1) {
 
3475
                        String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3476
                        for (Stream s : streamS) {
 
3477
                            if (s.getName().equals(streamName)) {
 
3478
                                selectedSource(s);
 
3479
                                if (s.isPlaying()) {
 
3480
                                    btnRemoveSource.setEnabled(false);
 
3481
                                } else {
 
3482
                                    btnRemoveSource.setEnabled(true);
 
3483
                                }
 
3484
                                break;
 
3485
                            }
3383
3486
                        }
3384
3487
                    }
3385
3488
                }
3386
 
            }
 
3489
            };
 
3490
            worker.schedule(task, 1, TimeUnit.SECONDS);
 
3491
//            if (selIndex != -1) {
 
3492
//                String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3493
//                for (Stream s : streamS) {
 
3494
//                    if (s.getName().equals(streamName)) {
 
3495
//                        selectedSource(s);
 
3496
//                        if (s.isPlaying()) {
 
3497
//                            btnRemoveSource.setEnabled(false);
 
3498
//                        } else {
 
3499
//                            btnRemoveSource.setEnabled(true);
 
3500
//                        }
 
3501
//                    }
 
3502
//                }
 
3503
//            }
3387
3504
        }
3388
3505
    }//GEN-LAST:event_pictureDesktopStateChanged
3389
3506
 
3391
3508
        if (editingPhase) {
3392
3509
            JTabbedPane tabPane = (JTabbedPane) evt.getSource();
3393
3510
            int selIndex = tabPane.getSelectedIndex();
3394
 
            if (selIndex != -1) {
3395
 
                String streamName = tabPane.getTitleAt(selIndex);
3396
 
                for (Stream s : streamS) {
3397
 
                    if (s.getName().equals(streamName)) {
3398
 
                        selectedSource(s);
3399
 
                        if (s.isPlaying()) {
3400
 
                            btnRemoveSource.setEnabled(false);
3401
 
                        } else {
3402
 
                            btnRemoveSource.setEnabled(true);
 
3511
            Runnable task = () -> {
 
3512
                if (selIndex == tabPane.getSelectedIndex()) {
 
3513
//                    System.out.println("StateChanged Old Index = " + selIndex);
 
3514
                    if (selIndex != -1) {
 
3515
                        String streamName = tabPane.getTitleAt(selIndex).replace("<html><body><table width='20'>", "").replace("</table></body></html>", "").replace("<span></span>", "");
 
3516
                        for (Stream s : streamS) {
 
3517
                            if (s.getName().equals(streamName)) {
 
3518
                                selectedSource(s);
 
3519
                                if (s.isPlaying()) {
 
3520
                                    btnRemoveSource.setEnabled(false);
 
3521
                                } else {
 
3522
                                    btnRemoveSource.setEnabled(true);
 
3523
                                }
 
3524
                                break;
 
3525
                            }
3403
3526
                        }
3404
3527
                    }
3405
3528
                }
3406
 
            }
 
3529
            };
 
3530
            worker.schedule(task, 1, TimeUnit.SECONDS);
 
3531
//            if (selIndex != -1) {
 
3532
//                String streamName = tabPane.getTitleAt(selIndex);
 
3533
//                for (Stream s : streamS) {
 
3534
//                    if (s.getName().equals(streamName)) {
 
3535
//                        selectedSource(s);
 
3536
//                        if (s.isPlaying()) {
 
3537
//                            btnRemoveSource.setEnabled(false);
 
3538
//                        } else {
 
3539
//                            btnRemoveSource.setEnabled(true);
 
3540
//                        }
 
3541
//                    }
 
3542
//                }
 
3543
//            }
3407
3544
        }
3408
3545
    }//GEN-LAST:event_textDesktopStateChanged
3409
3546
 
3453
3590
    private void btnApplyTitleActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnApplyTitleActionPerformed
3454
3591
        int result = JOptionPane.showConfirmDialog(this, "!!! Warning !!! Overwrites all previous Tracks titles.", "Attention", JOptionPane.YES_NO_CANCEL_OPTION);
3455
3592
        if (result == JFileChooser.APPROVE_OPTION) {
3456
 
            
 
3593
 
3457
3594
            ArrayList<Stream> trkList = new ArrayList<>();
3458
3595
            for (Stream s : master.getStreams()) {
3459
3596
                if (s.getisATrack() && !s.getClass().toString().contains("Sink")) {
3695
3832
    private javax.swing.JTabbedPane videoDesktop;
3696
3833
    private javax.swing.JScrollPane videoScroll;
3697
3834
    // End of variables declaration//GEN-END:variables
 
3835
    private static final ScheduledExecutorService worker = Executors.newSingleThreadScheduledExecutor();
3698
3836
 
3699
3837
    @Override
3700
3838
    public void selectedSource(Stream source) {
3708
3846
 
3709
3847
        tabControls.removeAll();
3710
3848
        tabControls.repaint();
 
3849
        
3711
3850
        ArrayList<Component> comps = SourceControls.getControls(source);
3712
3851
        for (Component c : comps) {
3713
3852
            String cName = c.getName();
3866
4005
                }
3867
4006
                setTrkStudioState(true);
3868
4007
                editingPhase = true;
 
4008
                loadingFinish = true;
3869
4009
                return null;
3870
4010
            }
3871
4011