Child: [r8] (diff)

Download this file

StudioUI.java    903 lines (786 with data), 44.6 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
/*
* SPDXVersion: SPDX-1.1
*
* Creator: Person: Nuno Brito (nuno.brito@triplecheck.de)
*
* Creator: Organization: TripleCheck (contact@triplecheck.de)
*
* Created: 2013-08-30T00:00:00Z
*
* LicenseName: NOASSERTION
*
* FileName: StudioUI.java
*
* FileType: SOURCE
*
* FileCopyrightText: <text> Copyright 2013 Nuno Brito, TripleCheck </text>
*
* FileComment: <text> The initial GUI for the end-users </text>
*/
package GUI;
import definitions.is;
import java.awt.Toolkit;
import java.net.URL;
import javax.swing.JEditorPane;
import javax.swing.JTree;
import javax.swing.UIManager;
import javax.swing.UnsupportedLookAndFeelException;
import spdxlib.FileInfo;
import spdxlib.SPDXfile;
import main.core;
public class StudioUI extends javax.swing.JFrame {
// helps to avoid loading the same information multiple times
TreeNodeSPDX lastNodeSelected;
public String searchText = "Search..";
/**
* Creates new form StudioUI
*/
public StudioUI() {
// adopt the default user interface menus and buttons
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
} catch (ClassNotFoundException ex) {} catch (IllegalAccessException ex) {
} catch (InstantiationException ex) {
} catch (UnsupportedLookAndFeelException ex) {
}
// get the window icon working
URL imgURL = this.getClass().getResource(is.defaultIcon);
setIconImage(Toolkit.getDefaultToolkit().getImage(imgURL));
initComponents();
doSettings();
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
jTabbedPane1 = new javax.swing.JTabbedPane();
panelProducts = new javax.swing.JPanel();
search = new javax.swing.JTextField();
jSplitPane1 = new javax.swing.JSplitPane();
tabProducts = new javax.swing.JTabbedPane();
panelDetails = new javax.swing.JPanel();
buttonProductNewSPDX = new javax.swing.JButton();
buttonProductEditSPDX = new javax.swing.JButton();
jScrollPane1 = new javax.swing.JScrollPane();
productText = new javax.swing.JEditorPane();
tabProductSPDX = new javax.swing.JPanel();
jScrollPane3 = new javax.swing.JScrollPane();
productTextSPDX = new javax.swing.JTextArea();
jScrollPane5 = new javax.swing.JScrollPane();
jList1 = new javax.swing.JList();
jScrollPane6 = new javax.swing.JScrollPane();
jEditorPane1 = new javax.swing.JEditorPane();
jScrollPane8 = new javax.swing.JScrollPane();
productTree = new javax.swing.JTree();
jLabel6 = new javax.swing.JLabel();
panelLibrary = new javax.swing.JPanel();
libraryAdd = new javax.swing.JButton();
librarySearch = new javax.swing.JTextField();
jSplitPane2 = new javax.swing.JSplitPane();
jScrollPane4 = new javax.swing.JScrollPane();
libraryText = new javax.swing.JEditorPane();
jScrollPane7 = new javax.swing.JScrollPane();
libraryTree = new javax.swing.JTree();
jLabel4 = new javax.swing.JLabel();
panelHome = new javax.swing.JPanel();
jScrollPane2 = new javax.swing.JScrollPane();
jEditorPane2 = new javax.swing.JEditorPane();
jToolBar2 = new javax.swing.JToolBar();
jPanel3 = new javax.swing.JPanel();
search1 = new javax.swing.JTextField();
jScrollPane9 = new javax.swing.JScrollPane();
box = new javax.swing.JEditorPane();
jPanel7 = new javax.swing.JPanel();
jLabel1 = new javax.swing.JLabel();
textSourceFolder = new javax.swing.JTextField();
buttonSettingsChooseBaseFolder = new javax.swing.JButton();
jLabel3 = new javax.swing.JLabel();
textStoreSPDX = new javax.swing.JTextField();
buttonChooseFolderSPDXfileLocation = new javax.swing.JButton();
jLabel39 = new javax.swing.JLabel();
jLabel40 = new javax.swing.JLabel();
textStoreSPDX27 = new javax.swing.JTextField();
textStoreSPDX28 = new javax.swing.JTextField();
jLabel41 = new javax.swing.JLabel();
textStoreSPDX29 = new javax.swing.JTextField();
textStoreSPDX30 = new javax.swing.JTextField();
jLabel42 = new javax.swing.JLabel();
jLabel44 = new javax.swing.JLabel();
jButton14 = new javax.swing.JButton();
jLabel11 = new javax.swing.JLabel();
jComboBox1 = new javax.swing.JComboBox();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("SPDX studio");
setLocationByPlatform(true);
jTabbedPane1.setTabPlacement(javax.swing.JTabbedPane.LEFT);
search.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
search.setMargin(new java.awt.Insets(2, 6, 2, 2));
jSplitPane1.setBorder(null);
jSplitPane1.setDividerLocation(160);
tabProducts.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
productTabVisibleSPDX(evt);
}
});
buttonProductNewSPDX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/wand.png"))); // NOI18N
buttonProductNewSPDX.setText("Create new");
buttonProductNewSPDX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonProductNewSPDXActionPerformed(evt);
}
});
buttonProductEditSPDX.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/pencil.png"))); // NOI18N
buttonProductEditSPDX.setText("Edit");
buttonProductEditSPDX.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonProductEditSPDXActionPerformed(evt);
}
});
productText.setContentType("text/html");
productText.setText("<html>\r\n <head>\r\n\r\n </head>\r\n <body>\r\n On this tab you can either edit an existing software product or create a new one from scratch.\n </body>\r\n</html>\r\n");
jScrollPane1.setViewportView(productText);
javax.swing.GroupLayout panelDetailsLayout = new javax.swing.GroupLayout(panelDetails);
panelDetails.setLayout(panelDetailsLayout);
panelDetailsLayout.setHorizontalGroup(
panelDetailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelDetailsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelDetailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelDetailsLayout.createSequentialGroup()
.addGap(0, 107, Short.MAX_VALUE)
.addComponent(buttonProductEditSPDX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonProductNewSPDX))
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addContainerGap())
);
panelDetailsLayout.setVerticalGroup(
panelDetailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelDetailsLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 313, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(panelDetailsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(buttonProductNewSPDX)
.addComponent(buttonProductEditSPDX))
.addContainerGap())
);
tabProducts.addTab("Details", new javax.swing.ImageIcon(getClass().getResource("/icons/fingerprint.png")), panelDetails); // NOI18N
tabProductSPDX.addComponentListener(new java.awt.event.ComponentAdapter() {
public void componentShown(java.awt.event.ComponentEvent evt) {
showProductTabSPDX(evt);
}
});
productTextSPDX.setColumns(20);
productTextSPDX.setLineWrap(true);
productTextSPDX.setRows(5);
productTextSPDX.setWrapStyleWord(true);
jScrollPane3.setViewportView(productTextSPDX);
jList1.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
jScrollPane5.setViewportView(jList1);
jScrollPane6.setViewportView(jEditorPane1);
javax.swing.GroupLayout tabProductSPDXLayout = new javax.swing.GroupLayout(tabProductSPDX);
tabProductSPDX.setLayout(tabProductSPDXLayout);
tabProductSPDXLayout.setHorizontalGroup(
tabProductSPDXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(tabProductSPDXLayout.createSequentialGroup()
.addContainerGap()
.addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 268, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(tabProductSPDXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jScrollPane6, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
.addComponent(jScrollPane5, javax.swing.GroupLayout.Alignment.TRAILING))
.addContainerGap())
);
tabProductSPDXLayout.setVerticalGroup(
tabProductSPDXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, tabProductSPDXLayout.createSequentialGroup()
.addContainerGap()
.addGroup(tabProductSPDXLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jScrollPane3)
.addGroup(tabProductSPDXLayout.createSequentialGroup()
.addComponent(jScrollPane5, javax.swing.GroupLayout.DEFAULT_SIZE, 223, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jScrollPane6, javax.swing.GroupLayout.PREFERRED_SIZE, 128, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
);
tabProducts.addTab("SPDX", new javax.swing.ImageIcon(getClass().getResource("/icons/document-number.png")), tabProductSPDX); // NOI18N
jSplitPane1.setRightComponent(tabProducts);
jScrollPane8.setAutoscrolls(true);
productTree.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
productTree.setMaximumSize(new java.awt.Dimension(172, 76));
productTree.setMinimumSize(new java.awt.Dimension(172, 0));
productTree.setPreferredSize(new java.awt.Dimension(100, 76));
productTree.setRowHeight(19);
productTree.setToggleClickCount(1);
productTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
productChanged(evt);
}
});
jScrollPane8.setViewportView(productTree);
jSplitPane1.setLeftComponent(jScrollPane8);
jLabel6.setText("Search");
javax.swing.GroupLayout panelProductsLayout = new javax.swing.GroupLayout(panelProducts);
panelProducts.setLayout(panelProductsLayout);
panelProductsLayout.setHorizontalGroup(
panelProductsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelProductsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelProductsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE)
.addGroup(panelProductsLayout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(search)))
.addContainerGap())
);
panelProductsLayout.setVerticalGroup(
panelProductsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelProductsLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelProductsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(search, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSplitPane1)
.addContainerGap())
);
jTabbedPane1.addTab("Products", new javax.swing.ImageIcon(getClass().getResource("/icons/socket.png")), panelProducts); // NOI18N
libraryAdd.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/plus.png"))); // NOI18N
libraryAdd.setText("Add");
librarySearch.setFont(new java.awt.Font("Arial", 1, 13)); // NOI18N
librarySearch.setMargin(new java.awt.Insets(2, 6, 2, 2));
librarySearch.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
librarySearchActionPerformed(evt);
}
});
jSplitPane2.setBorder(null);
libraryText.setContentType("text/html");
libraryText.setEditable(false);
jScrollPane4.setViewportView(libraryText);
jSplitPane2.setRightComponent(jScrollPane4);
libraryTree.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
libraryTree.setMinimumSize(new java.awt.Dimension(72, 0));
libraryTree.setRowHeight(19);
libraryTree.addTreeSelectionListener(new javax.swing.event.TreeSelectionListener() {
public void valueChanged(javax.swing.event.TreeSelectionEvent evt) {
libraryTreeChanged(evt);
}
});
jScrollPane7.setViewportView(libraryTree);
jSplitPane2.setLeftComponent(jScrollPane7);
jLabel4.setText("Search: ");
javax.swing.GroupLayout panelLibraryLayout = new javax.swing.GroupLayout(panelLibrary);
panelLibrary.setLayout(panelLibraryLayout);
panelLibraryLayout.setHorizontalGroup(
panelLibraryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelLibraryLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelLibraryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 499, Short.MAX_VALUE)
.addGroup(panelLibraryLayout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(librarySearch)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(libraryAdd)))
.addContainerGap())
);
panelLibraryLayout.setVerticalGroup(
panelLibraryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelLibraryLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelLibraryLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(librarySearch, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(libraryAdd)
.addComponent(jLabel4))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jSplitPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 397, Short.MAX_VALUE)
.addContainerGap())
);
jTabbedPane1.addTab("Library", new javax.swing.ImageIcon(getClass().getResource("/icons/photo-album-blue.png")), panelLibrary); // NOI18N
jScrollPane2.setViewportView(jEditorPane2);
jToolBar2.setRollover(true);
jPanel3.setName("Search box"); // NOI18N
search1.setFont(new java.awt.Font("Tahoma", 2, 12)); // NOI18N
search1.setText("Search..");
search1.setMargin(new java.awt.Insets(2, 8, 2, 2));
search1.addFocusListener(new java.awt.event.FocusAdapter() {
public void focusGained(java.awt.event.FocusEvent evt) {
search1FocusGained(evt);
}
public void focusLost(java.awt.event.FocusEvent evt) {
search1FocusLost(evt);
}
});
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
jPanel3.setLayout(jPanel3Layout);
jPanel3Layout.setHorizontalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addComponent(search1, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 22, Short.MAX_VALUE))
);
jPanel3Layout.setVerticalGroup(
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(search1)
.addContainerGap())
);
jToolBar2.add(jPanel3);
box.setBorder(javax.swing.BorderFactory.createEmptyBorder(3, 3, 3, 3));
box.setContentType("text/html");
box.setEditable(false);
box.setFont(box.getFont().deriveFont(box.getFont().getSize()-1f));
box.setToolTipText("Messages");
box.setMinimumSize(new java.awt.Dimension(56, 20));
box.setOpaque(false);
box.setPreferredSize(new java.awt.Dimension(50, 20));
jScrollPane9.setViewportView(box);
javax.swing.GroupLayout panelHomeLayout = new javax.swing.GroupLayout(panelHome);
panelHome.setLayout(panelHomeLayout);
panelHomeLayout.setHorizontalGroup(
panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHomeLayout.createSequentialGroup()
.addGroup(panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHomeLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane2)
.addGroup(panelHomeLayout.createSequentialGroup()
.addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))))
.addGroup(panelHomeLayout.createSequentialGroup()
.addGap(226, 226, 226)
.addComponent(jScrollPane9)))
.addContainerGap())
);
panelHomeLayout.setVerticalGroup(
panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelHomeLayout.createSequentialGroup()
.addContainerGap()
.addGroup(panelHomeLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(panelHomeLayout.createSequentialGroup()
.addComponent(jToolBar2, javax.swing.GroupLayout.PREFERRED_SIZE, 42, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 112, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, panelHomeLayout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jScrollPane9, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 276, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap())
);
jTabbedPane1.addTab("Home", new javax.swing.ImageIcon(getClass().getResource("/icons/home.png")), panelHome); // NOI18N
jLabel1.setText("Folder where your source files are normally located");
textSourceFolder.setEditable(false);
textSourceFolder.setText(" ");
buttonSettingsChooseBaseFolder.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-horizontal-open.png"))); // NOI18N
buttonSettingsChooseBaseFolder.setText("Choose folder");
buttonSettingsChooseBaseFolder.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonSettingsChooseBaseFolderActionPerformed(evt);
}
});
jLabel3.setText("Folder where SPDX files are stored");
textStoreSPDX.setEditable(false);
textStoreSPDX.setText(" ");
buttonChooseFolderSPDXfileLocation.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/folder-horizontal-open.png"))); // NOI18N
buttonChooseFolderSPDXfileLocation.setText("Choose folder");
buttonChooseFolderSPDXfileLocation.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
buttonChooseFolderSPDXfileLocationActionPerformed(evt);
}
});
jLabel39.setText("Person");
jLabel40.setText("Email contact of person");
textStoreSPDX27.setText(" ");
textStoreSPDX28.setText(" ");
jLabel41.setText("Organization");
textStoreSPDX29.setText(" ");
textStoreSPDX30.setText(" ");
jLabel42.setText("Email contact of organization");
jLabel44.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel44.setText("Default details for new SPDX documents");
jButton14.setIcon(new javax.swing.ImageIcon(getClass().getResource("/icons/tick.png"))); // NOI18N
jButton14.setText("Save");
jLabel11.setText("Data license");
jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7);
jPanel7.setLayout(jPanel7Layout);
jPanel7Layout.setHorizontalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel1)
.addComponent(jLabel3))
.addGap(237, 264, Short.MAX_VALUE))
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(textStoreSPDX)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonChooseFolderSPDXfileLocation))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
.addComponent(textSourceFolder)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(buttonSettingsChooseBaseFolder))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel7Layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(jButton14, javax.swing.GroupLayout.PREFERRED_SIZE, 121, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap())
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel39)
.addComponent(textStoreSPDX27, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel40)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(textStoreSPDX28)
.addGap(166, 166, 166))))
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel44)
.addGroup(jPanel7Layout.createSequentialGroup()
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel41)
.addComponent(textStoreSPDX29, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel42)
.addComponent(textStoreSPDX30, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jLabel11)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(0, 0, Short.MAX_VALUE))))
);
jPanel7Layout.setVerticalGroup(
jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textSourceFolder, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonSettingsChooseBaseFolder))
.addGap(18, 18, 18)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textStoreSPDX, javax.swing.GroupLayout.PREFERRED_SIZE, 33, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(buttonChooseFolderSPDXfileLocation))
.addGap(11, 11, 11)
.addComponent(jLabel44)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jLabel39)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(textStoreSPDX27, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(textStoreSPDX28, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jLabel40)
.addGap(26, 26, 26)))
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jLabel41)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textStoreSPDX29, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(jPanel7Layout.createSequentialGroup()
.addComponent(jLabel42)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(textStoreSPDX30, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel11)
.addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 142, Short.MAX_VALUE)
.addComponent(jButton14)
.addContainerGap())
);
jTabbedPane1.addTab("Settings", new javax.swing.ImageIcon(getClass().getResource("/icons/gear.png")), jPanel7); // NOI18N
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jTabbedPane1)
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jTabbedPane1)
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void librarySearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_librarySearchActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_librarySearchActionPerformed
private void buttonSettingsChooseBaseFolderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonSettingsChooseBaseFolderActionPerformed
// TODO add your handling code here:
chooseSettingsFolder();
}//GEN-LAST:event_buttonSettingsChooseBaseFolderActionPerformed
private void buttonChooseFolderSPDXfileLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonChooseFolderSPDXfileLocationActionPerformed
chooseSPDXFolder();
}//GEN-LAST:event_buttonChooseFolderSPDXfileLocationActionPerformed
private void buttonProductNewSPDXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProductNewSPDXActionPerformed
createNewSPDX();
}//GEN-LAST:event_buttonProductNewSPDXActionPerformed
private void buttonProductEditSPDXActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonProductEditSPDXActionPerformed
editSPDX();
}//GEN-LAST:event_buttonProductEditSPDXActionPerformed
private void libraryTreeChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_libraryTreeChanged
// Something has changed on the tree list of products
//swingUtils.treeItemSelected(libraryTree, libraryText);
}//GEN-LAST:event_libraryTreeChanged
private void productChanged(javax.swing.event.TreeSelectionEvent evt) {//GEN-FIRST:event_productChanged
doProductChangedClick(productTree, productText);
}//GEN-LAST:event_productChanged
private void productTabVisibleSPDX(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_productTabVisibleSPDX
}//GEN-LAST:event_productTabVisibleSPDX
private void showProductTabSPDX(java.awt.event.ComponentEvent evt) {//GEN-FIRST:event_showProductTabSPDX
}//GEN-LAST:event_showProductTabSPDX
private void search1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_search1FocusGained
doSearchMouseClicked();
//doGainedFocusHookMessage("Search Box");
}//GEN-LAST:event_search1FocusGained
private void search1FocusLost(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_search1FocusLost
doSearchMouseClicked();
//doLostFocusHookMessage("Search Box");
}//GEN-LAST:event_search1FocusLost
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/*
* Set the Nimbus look and feel
*/
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/*
* If Nimbus (introduced in Java SE 6) is not available, stay with the
* default look and feel. For details see
* http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(StudioUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(StudioUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(StudioUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(StudioUI.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/*
* Create and display the form
*/
java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() {
new StudioUI().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JEditorPane box;
private javax.swing.JButton buttonChooseFolderSPDXfileLocation;
private javax.swing.JButton buttonProductEditSPDX;
private javax.swing.JButton buttonProductNewSPDX;
private javax.swing.JButton buttonSettingsChooseBaseFolder;
private javax.swing.JButton jButton14;
private javax.swing.JComboBox jComboBox1;
private javax.swing.JEditorPane jEditorPane1;
private javax.swing.JEditorPane jEditorPane2;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel11;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel39;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel40;
private javax.swing.JLabel jLabel41;
private javax.swing.JLabel jLabel42;
private javax.swing.JLabel jLabel44;
private javax.swing.JLabel jLabel6;
private javax.swing.JList jList1;
private javax.swing.JPanel jPanel3;
private javax.swing.JPanel jPanel7;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JScrollPane jScrollPane2;
private javax.swing.JScrollPane jScrollPane3;
private javax.swing.JScrollPane jScrollPane4;
private javax.swing.JScrollPane jScrollPane5;
private javax.swing.JScrollPane jScrollPane6;
private javax.swing.JScrollPane jScrollPane7;
private javax.swing.JScrollPane jScrollPane8;
private javax.swing.JScrollPane jScrollPane9;
private javax.swing.JSplitPane jSplitPane1;
private javax.swing.JSplitPane jSplitPane2;
private javax.swing.JTabbedPane jTabbedPane1;
private javax.swing.JToolBar jToolBar2;
private javax.swing.JButton libraryAdd;
private javax.swing.JTextField librarySearch;
private javax.swing.JEditorPane libraryText;
private javax.swing.JTree libraryTree;
private javax.swing.JPanel panelDetails;
private javax.swing.JPanel panelHome;
private javax.swing.JPanel panelLibrary;
private javax.swing.JPanel panelProducts;
private javax.swing.JEditorPane productText;
private javax.swing.JTextArea productTextSPDX;
private javax.swing.JTree productTree;
private javax.swing.JTextField search;
private javax.swing.JTextField search1;
private javax.swing.JPanel tabProductSPDX;
private javax.swing.JTabbedPane tabProducts;
private javax.swing.JTextField textSourceFolder;
private javax.swing.JTextField textStoreSPDX;
private javax.swing.JTextField textStoreSPDX27;
private javax.swing.JTextField textStoreSPDX28;
private javax.swing.JTextField textStoreSPDX29;
private javax.swing.JTextField textStoreSPDX30;
// End of variables declaration//GEN-END:variables
/**
* Choose from where the source code fileSection are processed
*/
private void chooseSettingsFolder() {
GUI.swingUtils.chooseFolder(textSourceFolder, is.settings);
}
/**
* Choose where to store the resulting SPDX file
*/
private void chooseSPDXFolder() {
GUI.swingUtils.chooseFolder(textStoreSPDX, is.folderSPDX);
}
/**
* used during initialisation of this GUI to fill up the proper
* values that were saved before
*/
private void doSettings() {
//productTextSPDX.setEditorKit(new NumberedEditorKit());
textSourceFolder.setText(core.settings.read(is.settings));
textStoreSPDX.setText(core.settings.read(is.folderSPDX));
// get the library filled with the found SPDX documents
swingUtils.populateTree(libraryTree);
}
/**
* create a new SPDX document based on basic information that
* we have available
*/
private void doCreateSPDX() {
// get the base folder that was selected
String source = core.settings.read(is.settings);
// if no base folder is chosen, do nothing here
if((source == null)||(source.isEmpty())){
// return;
}
// // get the selected folder and run the SPDX creation
// File baseFolder = new File(source);
// actions.findLibrarySPDX(baseFolder);
}
private void createNewSPDX() {
Editor.main(null);
}
/**
* launches the window to edit a given SPDX file
*/
private void editSPDX() {
// preflight check
if(productTree.getSelectionCount()==0){
// return;
}
}
/**
* What should be done when the user clicks on the tree and expects
* to see data on the right side tabs?
*/
private void doProductChangedClick(JTree productTree,
JEditorPane productText) {
//swingUtils.treeItemSelected(productTree, productText);
// we need to know which package is currently selected
TreeNodeSPDX node = swingUtils.getNodePackage(productTree);
// add a nice memory of which package is currently selected
if((node != null)&&
(node != lastNodeSelected)){
// launch a thread to update the text file
Thread thread = new Thread(){
@Override
public void run(){
showTextProductTabSPDX();
}
};
thread.start();
// update which node has last been selected
lastNodeSelected = node;
}
// should we move the line of the SPDX document to a specific position?
TreeNodeSPDX currentNode = swingUtils.getSelectedNode(productTree);
if(currentNode == null){
return;
}
// go to its line
if(currentNode.nodeType == NodeType.file){
FileInfo file = (FileInfo) currentNode.getUserObject();
int lineNumber = file.tagFileName.linePosition;
productTextSPDX.setCaretPosition(productTextSPDX.getDocument()
.getDefaultRootElement().getElement(lineNumber)
.getStartOffset());
System.out.println("Change to line " + lineNumber);
}
// all done
}
/**
* Loads up the text for the currently selected package
*/
private void showTextProductTabSPDX() {
// display the text from the original spdx document
TreeNodeSPDX node = swingUtils.getNodePackage(productTree);
// preflight check
if(node == null){
return;
}
// process our text file
SPDXfile spdx = (SPDXfile) node.getUserObject();
//String text = utils.files.readAsString(spdx.file);
productTextSPDX.setText(spdx.rawText);
productTextSPDX.setCaretPosition(0);
// change the tab title
String counter = (spdx.rawText.length()>0) ? " ("
+ spdx.rawText.split("\n").length
+ " lines)" : "1";
tabProducts.setTitleAt(1, "SPDX" + counter);
}
/**
* React whenever the user wants to start a search
*/
private void doSearchMouseClicked() {
System.out.println("Starting search..");
String currentTerm = search.getText();
if(currentTerm.equals(searchText)){
search.setText("");
}
}
}