//External and Core Libraries
import java.applet.AppletContext;
import java.awt.Color;
import java.awt.Dimension;
import javax.swing.*;
import java.io.File;
import java.io.IOException;
import org.w3c.dom.*;
import java.util.Vector;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilder;
import java.io.*;
import java.net.URI;
import java.net.URL;
//External Library System
import org.jfree.ui.RefineryUtilities;
import resources.BarChart;
import resources.PieChart;
@SuppressWarnings({ "unused", "serial" })
public class driver extends javax.swing.JFrame {
/** Creates new form driver */
public driver() {
initComponents();
}
// @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
private void initComponents() {
jMenuBar2 = new javax.swing.JMenuBar();
jMenu2 = new javax.swing.JMenu();
jMenu3 = new javax.swing.JMenu();
jSeparator3 = new javax.swing.JSeparator();
Panel_step2 = new javax.swing.JPanel();
comments_lbl = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
commentTextArea_txtarea = new javax.swing.JTextArea();
Panel_step1 = new javax.swing.JPanel();
outputSourceFilePath_lbl = new javax.swing.JLabel();
verifyFunctionality_btn = new javax.swing.JButton();
verification_lbl = new javax.swing.JLabel();
Panel_step3 = new javax.swing.JPanel();
reportType_lbl = new javax.swing.JLabel();
reportTypeBox_drpdwn = new javax.swing.JComboBox();
Panel_step6 = new javax.swing.JPanel();
restart_btn = new javax.swing.JButton();
generate_btn = new javax.swing.JButton();
Panel_step4 = new javax.swing.JPanel();
filterType_lbl1 = new javax.swing.JLabel();
xaxis_Components_chkbox = new javax.swing.JCheckBox();
yaxis_Components_chkbox = new javax.swing.JCheckBox();
yaxis_Responsibilitys_chkbox = new javax.swing.JCheckBox();
jSeparator5 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
xaxis_Responsibilitys_chkbox = new javax.swing.JCheckBox();
jSeparator2 = new javax.swing.JSeparator();
jSeparator1 = new javax.swing.JSeparator();
jSeparator4 = new javax.swing.JSeparator();
Panel_step5 = new javax.swing.JPanel();
detailedTextReport_lbl = new javax.swing.JLabel();
detailedTextReport_chkbox = new javax.swing.JCheckBox();
jMenuBar1 = new javax.swing.JMenuBar();
fileSystem = new javax.swing.JMenu();
newEnvironment_slct = new javax.swing.JMenuItem();
openEnvironment_slct = new javax.swing.JMenuItem();
saveEnvironment_slct = new javax.swing.JMenuItem();
helpSystem = new javax.swing.JMenu();
copyright_slct = new javax.swing.JMenuItem();
contents_slct = new javax.swing.JMenuItem();
jMenu2.setText("File");
jMenuBar2.add(jMenu2);
jMenu3.setText("Edit");
jMenuBar2.add(jMenu3);
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("Statistics Case Utility - Version 1.00 Alpha");
comments_lbl.setText("Comments:");
commentTextArea_txtarea.setColumns(20);
commentTextArea_txtarea.setLineWrap(true);
commentTextArea_txtarea.setRows(5);
commentTextArea_txtarea.setToolTipText("Write your comments here...");
commentTextArea_txtarea.setAutoscrolls(false);
jScrollPane1.setViewportView(commentTextArea_txtarea);
javax.swing.GroupLayout Panel_step2Layout = new javax.swing.GroupLayout(Panel_step2);
Panel_step2.setLayout(Panel_step2Layout);
Panel_step2Layout.setHorizontalGroup(
Panel_step2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step2Layout.createSequentialGroup()
.addContainerGap()
.addComponent(comments_lbl)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 464, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(242, 242, 242))
);
Panel_step2Layout.setVerticalGroup(
Panel_step2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step2Layout.createSequentialGroup()
.addContainerGap()
.addGroup(Panel_step2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 131, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(comments_lbl))
.addGap(20, 20, 20))
);
outputSourceFilePath_lbl.setText("Output Source File Path: ");
verifyFunctionality_btn.setText("Open & Verify");
verifyFunctionality_btn.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
verifyFunctionality_btnMouseReleased(evt);
}
});
javax.swing.GroupLayout Panel_step1Layout = new javax.swing.GroupLayout(Panel_step1);
Panel_step1.setLayout(Panel_step1Layout);
Panel_step1Layout.setHorizontalGroup(
Panel_step1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(outputSourceFilePath_lbl)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(verifyFunctionality_btn)
.addGap(79, 79, 79)
.addComponent(verification_lbl)
.addContainerGap(419, Short.MAX_VALUE))
);
Panel_step1Layout.setVerticalGroup(
Panel_step1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step1Layout.createSequentialGroup()
.addContainerGap()
.addGroup(Panel_step1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(outputSourceFilePath_lbl)
.addComponent(verifyFunctionality_btn)
.addComponent(verification_lbl))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
reportType_lbl.setText("Report Type:");
reportTypeBox_drpdwn.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"Bar Graph Report", "Pie Chart Report"}));
javax.swing.GroupLayout Panel_step3Layout = new javax.swing.GroupLayout(Panel_step3);
Panel_step3.setLayout(Panel_step3Layout);
Panel_step3Layout.setHorizontalGroup(
Panel_step3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step3Layout.createSequentialGroup()
.addContainerGap()
.addComponent(reportType_lbl)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(reportTypeBox_drpdwn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
Panel_step3Layout.setVerticalGroup(
Panel_step3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step3Layout.createSequentialGroup()
.addContainerGap()
.addGroup(Panel_step3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(reportType_lbl)
.addComponent(reportTypeBox_drpdwn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addContainerGap(19, Short.MAX_VALUE))
);
restart_btn.setText("Restart");
restart_btn.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
restart_btnMouseReleased(evt);
}
});
generate_btn.setText("Generate");
generate_btn.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
generate_btnMouseReleased(evt);
}
});
javax.swing.GroupLayout Panel_step6Layout = new javax.swing.GroupLayout(Panel_step6);
Panel_step6.setLayout(Panel_step6Layout);
Panel_step6Layout.setHorizontalGroup(
Panel_step6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step6Layout.createSequentialGroup()
.addGap(37, 37, 37)
.addComponent(restart_btn)
.addGap(106, 106, 106)
.addComponent(generate_btn)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
Panel_step6Layout.setVerticalGroup(
Panel_step6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step6Layout.createSequentialGroup()
.addGap(17, 17, 17)
.addGroup(Panel_step6Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(generate_btn)
.addComponent(restart_btn))
.addContainerGap(38, Short.MAX_VALUE))
);
filterType_lbl1.setText("Filter Type:");
xaxis_Components_chkbox.setText("# Components");
yaxis_Components_chkbox.setText("# Components");
yaxis_Responsibilitys_chkbox.setText("# Responsibilitys");
jSeparator5.setOrientation(javax.swing.SwingConstants.VERTICAL);
jLabel2.setText("X-Axis");
jLabel3.setText("Y-Axis");
xaxis_Responsibilitys_chkbox.setText("# Responsibilitys");
javax.swing.GroupLayout Panel_step4Layout = new javax.swing.GroupLayout(Panel_step4);
Panel_step4.setLayout(Panel_step4Layout);
Panel_step4Layout.setHorizontalGroup(
Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step4Layout.createSequentialGroup()
.addContainerGap()
.addComponent(filterType_lbl1)
.addGap(38, 38, 38)
.addGroup(Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(xaxis_Components_chkbox)
.addComponent(jLabel2)
.addComponent(xaxis_Responsibilitys_chkbox))
.addGap(18, 18, 18)
.addComponent(jSeparator5, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(34, 34, 34)
.addGroup(Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(yaxis_Components_chkbox)
.addComponent(jLabel3)
.addComponent(yaxis_Responsibilitys_chkbox))
.addContainerGap(37, Short.MAX_VALUE))
);
Panel_step4Layout.setVerticalGroup(
Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step4Layout.createSequentialGroup()
.addContainerGap()
.addGroup(Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jLabel3)
.addComponent(jSeparator5, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 85, Short.MAX_VALUE)
.addGroup(Panel_step4Layout.createSequentialGroup()
.addGroup(Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(filterType_lbl1)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(Panel_step4Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step4Layout.createSequentialGroup()
.addComponent(xaxis_Components_chkbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(xaxis_Responsibilitys_chkbox))
.addGroup(Panel_step4Layout.createSequentialGroup()
.addComponent(yaxis_Components_chkbox)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(yaxis_Responsibilitys_chkbox)))
.addGap(23, 23, 23)))
.addContainerGap())
);
detailedTextReport_lbl.setText("Detailed Text Report - Comming Soon:");
javax.swing.GroupLayout Panel_step5Layout = new javax.swing.GroupLayout(Panel_step5);
Panel_step5.setLayout(Panel_step5Layout);
Panel_step5Layout.setHorizontalGroup(
Panel_step5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step5Layout.createSequentialGroup()
.addContainerGap()
.addComponent(detailedTextReport_lbl)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(detailedTextReport_chkbox)
.addContainerGap(29, Short.MAX_VALUE))
);
Panel_step5Layout.setVerticalGroup(
Panel_step5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(Panel_step5Layout.createSequentialGroup()
.addGap(14, 14, 14)
.addGroup(Panel_step5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(detailedTextReport_lbl, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(detailedTextReport_chkbox, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(34, Short.MAX_VALUE))
);
fileSystem.setText("File");
newEnvironment_slct.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
newEnvironment_slct.setText("New Environment");
newEnvironment_slct.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
newEnvironment_slctMouseReleased(evt);
}
});
fileSystem.add(newEnvironment_slct);
openEnvironment_slct.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
openEnvironment_slct.setText("Load Environment");
openEnvironment_slct.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
openEnvironment_slctMouseReleased1(evt);
}
});
fileSystem.add(openEnvironment_slct);
saveEnvironment_slct.setText("Save Environment");
saveEnvironment_slct.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
saveEnvironment_slctMouseReleased(evt);
}
});
fileSystem.add(saveEnvironment_slct);
jMenuBar1.add(fileSystem);
helpSystem.setText("Help");
copyright_slct.setText("Copyright");
copyright_slct.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
copyright_slctMouseReleased(evt);
}
});
helpSystem.add(copyright_slct);
contents_slct.setText("Contents");
contents_slct.addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseReleased(java.awt.event.MouseEvent evt) {
contents_slct_slctMouseReleased(evt);
}
});
helpSystem.add(contents_slct);
jMenuBar1.add(helpSystem);
setJMenuBar(jMenuBar1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(232, 232, 232)
.addComponent(Panel_step6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(277, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(Panel_step1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(66, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 770, Short.MAX_VALUE))
.addComponent(Panel_step2, javax.swing.GroupLayout.DEFAULT_SIZE, 780, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup()
.addGap(10, 10, 10)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(Panel_step3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(Panel_step5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(Panel_step4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jSeparator4, javax.swing.GroupLayout.DEFAULT_SIZE, 770, Short.MAX_VALUE))))
.addGap(18, 18, 18))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(21, 21, 21)
.addComponent(Panel_step1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(40, 40, 40)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(Panel_step2, javax.swing.GroupLayout.PREFERRED_SIZE, 162, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(Panel_step3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(Panel_step5, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(Panel_step4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(jSeparator4, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(29, 29, 29)
.addComponent(Panel_step6, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(23, 23, 23))
);
pack();
}// </editor-fold>
private void copyright_slctMouseReleased(java.awt.event.MouseEvent evt) {
JOptionPane.showMessageDialog(null, "Statistical Case Utility (SCU)\nVersion 1.0 Alpha\n\nCreated By: Daniel Ricci - ID# 9118756", "Copyright Information", JOptionPane.INFORMATION_MESSAGE);
}
private void contents_slct_slctMouseReleased(java.awt.event.MouseEvent evt) {
try {
Process p=Runtime.getRuntime().exec("cmd /c start http://iosoft.ca/portal/TEMP/help/");
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
private void generate_btnMouseReleased(java.awt.event.MouseEvent evt) {
//onclick of the generate button
switch(reportTypeBox_drpdwn.getSelectedIndex()) {
case 0:
loadBarGraphReport();
break;
case 1:
loadPieChartReport();
break;
}
}
private void newEnvironment_slctMouseReleased(java.awt.event.MouseEvent evt) {
main(null);
}
private void verifyFunctionality_btnMouseReleased(java.awt.event.MouseEvent evt) {
// TODO - verify button functionality goes here
//open a file with an xml extension
JFileChooser c = new JFileChooser();
int rVal = c.showOpenDialog(null);
String filename = null;
String dir = null;
if (rVal == JFileChooser.APPROVE_OPTION) {
filename = c.getSelectedFile().getName();
dir = c.getCurrentDirectory().toString();
if (!(filename.endsWith(".xml"))) {
JOptionPane.showMessageDialog(null, "Error, please specify your file location with a .xml extension...", "Wrong File Format Detected", JOptionPane.ERROR_MESSAGE);
filename = null;
dir = null;
} else {
// JOptionPane.showMessageDialog(null, dir+"\\"+filename);
try {
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File(dir + "//" + filename));
doc.getDocumentElement().normalize();
//Get root node, if there is missing info then reject. It is important to know who did this file and its title, in any business.
if (doc.getDocumentElement().getAttribute("author").compareTo("") == 0
|| doc.getDocumentElement().getAttribute("id").compareTo("") == 0
|| doc.getDocumentElement().getAttribute("company").compareTo("") == 0
|| doc.getDocumentElement().getAttribute("author").compareTo("") == 0) {
JOptionPane.showMessageDialog(null, "Your file must havean Author, ID#, Title, and Company Name as its header.", "Missing Information Detected...", JOptionPane.ERROR_MESSAGE);
throw new Exception();
//JOptionPane.showMessageDialog(null, doc.getDocumentElement().getNodeName());
}
//Check to see if at least one path exists; end paths are automatically added and cannot be singly removed.
if (doc.getElementsByTagName("path").item(0) == null) {
JOptionPane.showMessageDialog(null, "There are no paths in your file, therefore no information can be portrayed.", "Missing Information", JOptionPane.ERROR_MESSAGE);
}
Vector<String> unique_id = new Vector<String>();
String[] element_node_names = {
"path",
"startNode",
"responsibilityNode",
"jointpath",};
String[] element_node_attribute_names = {
"id",
"title",};
for (int w = 0; w < element_node_attribute_names.length; ++w) {
for (int x = 0; x < element_node_names.length; ++x) {
for (int i = 0; i < doc.getElementsByTagName(element_node_names[x]).getLength(); ++i) {
Node temp = doc.getElementsByTagName(element_node_names[x]).item(i).getAttributes().getNamedItem(element_node_attribute_names[w]);
if (temp != null) {
Boolean found = false;
for (int j = 0; j < unique_id.size(); ++j) {
if (unique_id.get(j).equalsIgnoreCase(temp.getNodeValue())) {
found = true;
}
}
if (found == false) {
unique_id.add(temp.getNodeValue());
} else {
JOptionPane.showMessageDialog(null, temp.getNodeValue() + " exists in more than one element, please correct this...", "Duplicate Entity Error", JOptionPane.ERROR_MESSAGE);
this.verification_lbl.setText("Error, Your File is Corrupt and Needs Repair...");
this.verification_lbl.setForeground(Color.red);
throw new Exception();
}
}
}
}
unique_id.removeAllElements();
}
this.verification_lbl.setText("Your File is Valid...");
this.verification_lbl.setForeground(Color.blue);
} //end try block
catch (Exception e) {
}
}
}
}
//TODO - change name of the function
private void restart_btnMouseReleased(java.awt.event.MouseEvent evt) {
this.commentTextArea_txtarea.setText(null);
this.xaxis_Components_chkbox.setSelected(false);
this.yaxis_Components_chkbox.setSelected(false);
this.xaxis_Responsibilitys_chkbox.setSelected(false);
this.yaxis_Responsibilitys_chkbox.setSelected(false);
this.detailedTextReport_chkbox.setSelected(false);
this.reportTypeBox_drpdwn.setSelectedIndex(0);
}
private void saveEnvironment_slctMouseReleased(java.awt.event.MouseEvent evt) {
//Add functionality to save settings
JFileChooser c = new JFileChooser();
String dir = "";
BufferedWriter fos = null;
if (c.showSaveDialog(null) == JFileChooser.APPROVE_OPTION) {
dir = (c.getSelectedFile().getAbsolutePath())+".xml";
try {
fos = new BufferedWriter(new FileWriter(dir));
fos.write("<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>"); fos.newLine();
fos.write("<saveEnvironment author=\"Daniel Ricci\" id=\"9118756\" company=\"Concordia University\">");fos.newLine();
//fos.write("<source path=\""+dir+"\"></source>");fos.newLine();
fos.write("<comment text=\""+commentTextArea_txtarea.getText()+"\"></comment>");fos.newLine();
fos.write("<detailedTextReport isChecked=\""+detailedTextReport_chkbox.isSelected()+"\"></detailedTextReport>");fos.newLine();
fos.write("<xaxis_Components_chkbox isChecked=\""+xaxis_Components_chkbox.isSelected()+"\"></xaxis_Components_chkbox>");fos.newLine();
fos.write("<yaxis_Components_chkbox isChecked=\""+yaxis_Components_chkbox.isSelected()+"\"></yaxis_Components_chkbox>");fos.newLine();
fos.write("<xaxis_Responsibilitys_chkbox isChecked=\""+xaxis_Responsibilitys_chkbox.isSelected()+"\"></xaxis_Responsibilitys_chkbox>");fos.newLine();
fos.write("<yaxis_Responsibilitys_chkbox isChecked=\""+yaxis_Responsibilitys_chkbox.isSelected()+"\"></yaxis_Responsibilitys_chkbox>");fos.newLine();
fos.write("<reportTypeBox_drpdwn index=\""+reportTypeBox_drpdwn.getSelectedIndex()+"\"></yaxis_Responsibilitys_chkbox>");fos.newLine();
fos.write("</saveEnvironment>");
} catch (Exception e) {
}
finally {
if(fos != null) {
try {
fos.close();
} catch (Exception e) {
}
}
}
}
}
private void openEnvironment_slctMouseReleased1(java.awt.event.MouseEvent evt) {
//functionality to load an environment
JFileChooser c = new JFileChooser();
int rVal = c.showOpenDialog(null);
String filename = null;
@SuppressWarnings("unused")
String dir = null;
String path = null;
if (rVal == JFileChooser.APPROVE_OPTION) {
filename = c.getSelectedFile().getName();
dir = c.getCurrentDirectory().toString();
if (!(filename.endsWith(".xml"))) {
JOptionPane.showMessageDialog(null, "Error, please specify your file location with a .xml extension...", "Wrong File Format Detected", JOptionPane.ERROR_MESSAGE);
filename = null;
dir = null;
path = null;
} else {
try {
path = c.getSelectedFile().getAbsolutePath();
DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
Document doc = docBuilder.parse(new File(path));
doc.getDocumentElement().normalize();
if (!(doc.getDocumentElement().getNodeName().compareToIgnoreCase("saveEnvironment") == 0)) {
JOptionPane.showMessageDialog(null, "Your save file is not structured correctly....", "Wrong XML File Detected...", JOptionPane.ERROR_MESSAGE);
throw new Exception();
}
commentTextArea_txtarea.setText(doc.getElementsByTagName("comment").item(0).getAttributes().getNamedItem("text").getNodeValue().toString());
detailedTextReport_chkbox.setSelected((doc.getElementsByTagName("detailedTextReport").item(0).getAttributes().getNamedItem("isChecked").getNodeValue().compareTo("true") == 0));
xaxis_Components_chkbox.setSelected((doc.getElementsByTagName("xaxis_Components_chkbox").item(0).getAttributes().getNamedItem("isChecked").getNodeValue().compareTo("true") == 0));
yaxis_Components_chkbox.setSelected((doc.getElementsByTagName("yaxis_Components_chkbox").item(0).getAttributes().getNamedItem("isChecked").getNodeValue().compareTo("true") == 0));
xaxis_Responsibilitys_chkbox.setSelected((doc.getElementsByTagName("xaxis_Responsibilitys_chkbox").item(0).getAttributes().getNamedItem("isChecked").getNodeValue().compareTo("true") == 0));
yaxis_Responsibilitys_chkbox.setSelected((doc.getElementsByTagName("yaxis_Responsibilitys_chkbox").item(0).getAttributes().getNamedItem("isChecked").getNodeValue().compareTo("true") == 0));
reportTypeBox_drpdwn.setSelectedIndex(Integer.valueOf(doc.getElementsByTagName("reportTypeBox_drpdwn").item(0).getAttributes().getNamedItem("index").getNodeValue()));
} catch(Exception e) {
}
}
}
}
//TODO - Integrate function dynamically
public static void loadBarGraphReport() {
BarChart demo = new BarChart("Bar Chart Report Analysis");
demo.pack();
RefineryUtilities.centerFrameOnScreen(demo);
demo.setVisible(true);
}
public static void loadPieChartReport() {
PieChart p = new PieChart();
p.loadChart();
}
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new driver().setVisible(true);
}
});
}
// Variables declaration - do not modify
private javax.swing.JPanel Panel_step1;
private javax.swing.JPanel Panel_step2;
private javax.swing.JPanel Panel_step3;
private javax.swing.JPanel Panel_step4;
private javax.swing.JPanel Panel_step5;
private javax.swing.JPanel Panel_step6;
private javax.swing.JTextArea commentTextArea_txtarea;
private javax.swing.JLabel comments_lbl;
private javax.swing.JMenuItem contents_slct;
private javax.swing.JMenuItem copyright_slct;
private javax.swing.JCheckBox detailedTextReport_chkbox;
private javax.swing.JLabel detailedTextReport_lbl;
private javax.swing.JMenu fileSystem;
private javax.swing.JLabel filterType_lbl1;
private javax.swing.JButton generate_btn;
private javax.swing.JMenu helpSystem;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JMenu jMenu2;
private javax.swing.JMenu jMenu3;
private javax.swing.JMenuBar jMenuBar1;
private javax.swing.JMenuBar jMenuBar2;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JSeparator jSeparator1;
private javax.swing.JSeparator jSeparator2;
@SuppressWarnings("unused")
private javax.swing.JSeparator jSeparator3;
private javax.swing.JSeparator jSeparator4;
private javax.swing.JSeparator jSeparator5;
private javax.swing.JMenuItem newEnvironment_slct;
private javax.swing.JMenuItem openEnvironment_slct;
private javax.swing.JLabel outputSourceFilePath_lbl;
private javax.swing.JComboBox reportTypeBox_drpdwn;
private javax.swing.JLabel reportType_lbl;
private javax.swing.JButton restart_btn;
private javax.swing.JMenuItem saveEnvironment_slct;
private javax.swing.JLabel verification_lbl;
private javax.swing.JButton verifyFunctionality_btn;
private javax.swing.JCheckBox xaxis_Components_chkbox;
private javax.swing.JCheckBox xaxis_Responsibilitys_chkbox;
private javax.swing.JCheckBox yaxis_Components_chkbox;
private javax.swing.JCheckBox yaxis_Responsibilitys_chkbox;
// End of variables declaration
}