/*
* 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("");
}
}
}