diff --git a/.classpath b/.classpath new file mode 100644 index 0000000..6007430 --- /dev/null +++ b/.classpath @@ -0,0 +1,47 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/.gitignore b/.gitignore index 2a074d5..e67f50f 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ /ObjectLabSoftware/nbproject/private/ /ObjectLabSoftware/build/ /ObjectLabSoftware/dist/ -*.bak \ No newline at end of file +*.bak +/bin/ diff --git a/.project b/.project new file mode 100644 index 0000000..b27891d --- /dev/null +++ b/.project @@ -0,0 +1,17 @@ + + + OLI + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/Documentation/new BuildView.docx b/Documentation/new BuildView.docx new file mode 100644 index 0000000..f27a109 Binary files /dev/null and b/Documentation/new BuildView.docx differ diff --git a/ObjectLabSoftware/.classpath b/ObjectLabSoftware/.classpath index e6cd9a1..9f24163 100644 --- a/ObjectLabSoftware/.classpath +++ b/ObjectLabSoftware/.classpath @@ -8,6 +8,7 @@ + diff --git a/ObjectLabSoftware/computername b/ObjectLabSoftware/computername new file mode 100644 index 0000000..e69de29 diff --git a/ObjectLabSoftware/computername.txt b/ObjectLabSoftware/computername.txt new file mode 100644 index 0000000..7b9ad53 --- /dev/null +++ b/ObjectLabSoftware/computername.txt @@ -0,0 +1 @@ +127.0.0.1 diff --git a/ObjectLabSoftware/lib/postgresql-9.4.1208.jre6.jar b/ObjectLabSoftware/lib/postgresql-9.4.1208.jre6.jar new file mode 100644 index 0000000..9718d6e Binary files /dev/null and b/ObjectLabSoftware/lib/postgresql-9.4.1208.jre6.jar differ diff --git a/ObjectLabSoftware/nbproject/build-impl.xml b/ObjectLabSoftware/nbproject/build-impl.xml index 4627be4..aab5327 100755 --- a/ObjectLabSoftware/nbproject/build-impl.xml +++ b/ObjectLabSoftware/nbproject/build-impl.xml @@ -192,7 +192,12 @@ is divided into following sections: - + + + + + + @@ -218,6 +223,7 @@ is divided into following sections: + @@ -694,7 +700,7 @@ is divided into following sections: - + @@ -769,7 +775,7 @@ is divided into following sections: - + @@ -796,7 +802,7 @@ is divided into following sections: - + diff --git a/ObjectLabSoftware/nbproject/build-native.xml b/ObjectLabSoftware/nbproject/build-native.xml index 75448ad..1aa10a0 100644 --- a/ObjectLabSoftware/nbproject/build-native.xml +++ b/ObjectLabSoftware/nbproject/build-native.xml @@ -389,11 +389,9 @@ Portions Copyrighted 2013 Sun Microsystems, Inc. - - - - - + + + diff --git a/ObjectLabSoftware/nbproject/build-native.xml~ b/ObjectLabSoftware/nbproject/build-native.xml~ new file mode 100644 index 0000000..75448ad --- /dev/null +++ b/ObjectLabSoftware/nbproject/build-native.xml~ @@ -0,0 +1,953 @@ + + + + + + + + + Native Packager Ant calls based on SE support in JavaFX packager + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + self.addMappedName( + (source.indexOf("jfxrt.jar") >= 0) || + (source.indexOf("deploy.jar") >= 0) || + (source.indexOf("javaws.jar") >= 0) || + (source.indexOf("plugin.jar") >= 0) + ? "" : source + ); + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ObjectLabSoftware/nbproject/genfiles.properties b/ObjectLabSoftware/nbproject/genfiles.properties index b24e8cf..86e5bf5 100755 --- a/ObjectLabSoftware/nbproject/genfiles.properties +++ b/ObjectLabSoftware/nbproject/genfiles.properties @@ -4,5 +4,5 @@ build.xml.stylesheet.CRC32=8064a381@1.75.2.48 # This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml. # Do not edit this file. You may delete it but then the IDE will never regenerate such files for you. nbproject/build-impl.xml.data.CRC32=2377266f -nbproject/build-impl.xml.script.CRC32=fc86e766 -nbproject/build-impl.xml.stylesheet.CRC32=876e7a8f@1.75.2.48 +nbproject/build-impl.xml.script.CRC32=694ae75e +nbproject/build-impl.xml.stylesheet.CRC32=05530350@1.79.1.48 diff --git a/ObjectLabSoftware/nbproject/project.properties b/ObjectLabSoftware/nbproject/project.properties index b2936cc..3387488 100755 --- a/ObjectLabSoftware/nbproject/project.properties +++ b/ObjectLabSoftware/nbproject/project.properties @@ -37,7 +37,7 @@ file.reference.mysql-connector-java-5.1.23-bin.jar=lib\\mysql-connector-java-5.1 file.reference.ojdbc14.jar-1=lib\\ojdbc14.jar file.reference.poi-3.11-beta3-20141111.jar-3=lib\\poi-3.11-beta3-20141111.jar includes=** -jar.compress=false +jar.compress=true javac.classpath=\ ${libs.MySQLDriver.classpath}:\ ${libs.absolutelayout.classpath}:\ @@ -52,6 +52,7 @@ javac.classpath=\ # Space-separated list of extra javac options javac.compilerargs= javac.deprecation=false +javac.external.vm=false javac.processorpath=\ ${javac.classpath} javac.source=1.7 diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddDeviceView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddDeviceView.java index a0badac..d45c9ac 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddDeviceView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddDeviceView.java @@ -1,6 +1,7 @@ package ObjectLabEnterpriseSoftware; import java.awt.BorderLayout; +import java.awt.Dimension; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; @@ -115,7 +116,7 @@ private void initComponents() { getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N - jLabel1.setText("Add Printer"); + jLabel1.setText("Add Device"); getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 10, -1, -1)); getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 45, 440, 10)); getContentPane().add(printerNameTF, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 60, 124, -1)); @@ -123,7 +124,7 @@ private void initComponents() { printerNameL.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N printerNameL.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - printerNameL.setText("Printer Name:"); + printerNameL.setText("Device Name:"); getContentPane().add(printerNameL, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, -1, -1)); removeFieldButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N @@ -214,7 +215,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuBar1.add(EditMenu); setJMenuBar(jMenuBar1); - + getContentPane().setPreferredSize(new Dimension(475, 125)); + setSize(new Dimension(475, 125)); pack(); setLocationRelativeTo(null); }// //GEN-END:initComponents @@ -265,7 +267,7 @@ private void addFieldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GE fields.add(tfield); tlabel = new JLabel(); tlabel.setName("fieldL" + (count - 1)); - tlabel.setText("Field #" + (count - 1)); + tlabel.setText("Field Name " + (count - 1)); labels.add(tlabel); cbox = new JCheckBox(); cbox.setName("numberCB" + (count - 2)); diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddStudentView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddStudentView.java index e8b793f..3d20242 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddStudentView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AddStudentView.java @@ -9,11 +9,15 @@ import java.awt.event.KeyEvent; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; -import javax.mail.internet.AddressException; +import javax.mail.internet.AddressException; import javax.mail.internet.InternetAddress; import javax.swing.JOptionPane; -public class AddStudentView extends javax.swing.JFrame +public class AddStudentView { + +} + +/*public class AddStudentView extends javax.swing.JFrame { private static final String NAME_OF_PAGE = "New Student"; @@ -59,7 +63,7 @@ public void windowClosing(WindowEvent e) public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); - if (!((c >= '0') && (c <= '9') + /* if (!((c >= '0') && (c <= '9') || (c == KeyEvent.VK_BACK_SPACE) || (c == KeyEvent.VK_DELETE))) { @@ -70,8 +74,8 @@ else if (tuIDEntry.getText().length() >= 7) { getToolkit().beep(); e.consume(); - } - } + }*/ +/* } }); } @@ -80,8 +84,8 @@ else if (tuIDEntry.getText().length() >= 7) * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") - // //GEN-BEGIN:initComponents + // @SuppressWarnings("unchecked") + /* // //GEN-BEGIN:initComponents private void initComponents() { newStudentLabel = new javax.swing.JLabel(); @@ -160,7 +164,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { } }); getContentPane().add(emailEntry, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 170, 170, -1)); - + + backButton.setFocusPainted(false); backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N backButton.setToolTipText("Back"); backButton.setBorderPainted(false); @@ -216,7 +221,7 @@ else if (!email.isEmpty()) { if(InputValidation.isNumber(tuID)){ - if ((UtilController.addUser(tuID, firstName, lastName, email)) > 0) + /* if ((UtilController.addUser(tuID, firstName, lastName, email)) > 0) { JOptionPane.showMessageDialog(this, "Updating student data."); dispose(); @@ -233,10 +238,10 @@ else if (!email.isEmpty()) } } - } + } */ - }//GEN-LAST:event_submitActionPerformed + /* }//GEN-LAST:event_submitActionPerformed private void emailEntryActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_emailEntryActionPerformed // TODO add your handling code here: @@ -270,4 +275,4 @@ private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FI private javax.swing.JLabel tuID; private javax.swing.JTextField tuIDEntry; // End of variables declaration//GEN-END:variables -} +} */ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AdminSettingsView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AdminSettingsView.java index a115ae5..e1269aa 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AdminSettingsView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/AdminSettingsView.java @@ -5,16 +5,29 @@ */ package ObjectLabEnterpriseSoftware; +import java.awt.Dimension; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; + public class AdminSettingsView extends javax.swing.JFrame { - private static final String NAME_OF_PAGE = "Settings"; + public AdminSettingsView() { + } + private static final String NAME_OF_PAGE = "\tSettings"; private static final MainView home = new MainView(); - + // --nav bar views ~Alex + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private AdminSettingsView adminSettingsView; + // public void AdminSettingsViewStart() { initComponents(); + initNavBar(); setLocationRelativeTo(null); try { for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { @@ -45,7 +58,7 @@ public void windowClosing(WindowEvent e) @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents private void initComponents() { - + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); jButton5 = new javax.swing.JButton(); jButton4 = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); @@ -60,7 +73,7 @@ private void initComponents() { userGuide = new javax.swing.JMenuItem(); setTitle(UtilController.getPageName(NAME_OF_PAGE)); - setResizable(false); + getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jButton5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N @@ -68,6 +81,7 @@ private void initComponents() { jButton5.setBorderPainted(false); jButton5.setContentAreaFilled(false); jButton5.setFocusPainted(false); + jButton5.setVisible(false); // old backbutton still there but invis ~Alex jButton5.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton5ActionPerformed(evt); @@ -82,8 +96,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButton4ActionPerformed(evt); } }); - getContentPane().add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 70, 140, -1)); - getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, 320, 10)); + getContentPane().add(jButton4, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 70, 140, -1)); + getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 50, getContentPane().getWidth(), 10)); jButton1.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jButton1.setText("Archive"); @@ -92,7 +106,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); - getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 130, 140, -1)); + getContentPane().add(jButton1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 130, 140, -1)); addPrinterButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N addPrinterButton.setLabel("Add Device"); @@ -101,20 +115,20 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { addPrinterButtonActionPerformed(evt); } }); - getContentPane().add(addPrinterButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 100, 140, -1)); + getContentPane().add(addPrinterButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 100, 140, -1)); jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N jLabel1.setText("Settings"); - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(130, 10, -1, 30)); + getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 10, -1, 30)); jButton2.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - jButton2.setText("Remove Class/Printer"); + jButton2.setText("Remove Class/Device"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(evt); } }); - getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 160, 140, -1)); + getContentPane().add(jButton2, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 160, 140, -1)); jButton3.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jButton3.setText("Change Password"); @@ -123,14 +137,14 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jButton3ActionPerformed(evt); } }); - getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 190, 140, -1)); + getContentPane().add(jButton3, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 190, 140, -1)); jLabel2.setBackground(new java.awt.Color(40, 41, 40)); jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N jLabel2.setOpaque(true); - getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 370, 230)); + getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 750, 300)); - help.setText("Help"); + /* help.setText("Help"); userGuide.setText("User Guide"); userGuide.addActionListener(new java.awt.event.ActionListener() { @@ -142,10 +156,137 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuBar1.add(help); - setJMenuBar(jMenuBar1); - + setJMenuBar(jMenuBar1);*/ + setPreferredSize(new Dimension(650,375)); + setResizable(false); pack(); }// //GEN-END:initComponents + + + private void initNavBar() + { + + jMenuBar1.setPreferredSize(new Dimension(200, 30)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + //spacing + jMenuBar1.add(Box.createRigidArea(new Dimension(35,0))); + // + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + + navBtn_build.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_reports); + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_settings); + + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + } + + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new AdminSettingsView(); + adminSettingsView.AdminSettingsViewStart(); + dispose(); + + } + + + + /////// Nav Bar ~Alex ///// + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed // TODO add your handling code here: @@ -201,5 +342,9 @@ private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRS private javax.swing.JMenuBar jMenuBar1; private javax.swing.JSeparator jSeparator1; private javax.swing.JMenuItem userGuide; + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_settings; // End of variables declaration//GEN-END:variables } diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.form new file mode 100644 index 0000000..9880e5d --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.form @@ -0,0 +1,233 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTable1MouseClicked"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JTextField" name="jTextField1"> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="text" type="java.lang.String" value="Search"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton2MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="text" type="java.lang.String" value="Search by first name, last name, or Towson ID:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Balance"/> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextField4"> + </Component> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="text" type="java.lang.String" value="Add"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton3MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox1"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="3"> + <StringItem index="0" value="Z Corp Plaster"/> + <StringItem index="1" value="Objet Build"/> + <StringItem index="2" value="Objet Support"/> + </StringArray> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="Select Material:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" value="Enter Amount:"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.java new file mode 100644 index 0000000..2b493a9 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BalanceView.java @@ -0,0 +1,504 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Point; +import java.sql.ResultSet; +import java.util.ArrayList; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JTable; +import javax.swing.table.DefaultTableModel; +import javax.sql.*; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; + + +/** + * + * @author Russell + */ +public class BalanceView extends javax.swing.JFrame { + + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private BalanceView balanceView; + private newSettingsMenu adminSettingsView; + private MaterialTransactionHistoryView materialTransView; + private double amount = 0; + //private String firstName = ""; + //private String lastName = ""; + //private String id = ""; + private String enteredValue = ""; + /** + * Creates new form BalanceView + */ + //private static final String NAME_OF_PAGE = "Build File Creator"; + private static DefaultTableModel model; + private static MainView home = new MainView(); + public BalanceView() { + + getContentPane().setBackground(Color.WHITE); + initComponents(); + initNavBar(); + model = (DefaultTableModel) jTable1.getModel(); + updateBalanceWindow(enteredValue); + setVisible(true); + } + + +protected void updateBalanceWindow(String enteredValue) { + + model.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + /*if (!id.isEmpty()) + { + System.out.println(id); + queryResult = dbconn.searchStudentBalanceId(id); + } + else if (!lastName.isEmpty()) + { + queryResult = dbconn.searchStudentBalanceLName(lastName); + } + else if (!firstName.isEmpty()) + { + queryResult = dbconn.searchStudentBalanceFName(firstName); + } + else + { + queryResult = dbconn.searchStudentBalance(); + } + */ + if (!enteredValue.isEmpty()) + { + queryResult = dbconn.searchStudentBalanceAll(enteredValue); + } + else + { + queryResult = dbconn.searchStudentBalance(); + } + + while(queryResult.next()) + { + String first_name = queryResult.getString(1); + String last_name= queryResult.getString(2); + String towson_id = queryResult.getString(3); + String material1 = queryResult.getString(4); + String material2 = queryResult.getString(5); + String material3 = queryResult.getString(6); + System.out.println("Adding row..."); + model.addRow(new Object[] {first_name, last_name, towson_id, material1, material2, material3}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } +} + /** + * 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() { + + jMenuItem1 = new javax.swing.JMenuItem(); + jButton1 = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jTextField1 = new javax.swing.JTextField(); + jButton2 = new javax.swing.JButton(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + jTextField4 = new javax.swing.JTextField(); + jButton3 = new javax.swing.JButton(); + jComboBox1 = new javax.swing.JComboBox(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jMenuBar1 = new javax.swing.JMenuBar(); + + jMenuItem1.setText("jMenuItem1"); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Student Balance "); + + jButton1.setText("Logout"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jButton1MouseClicked(evt); + } + }); + + jTable1.setAutoCreateRowSorter(true); + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null}, + {null, null, null, null, null, null} + }, + new String [] { + "First Name", "Last Name", "Towson ID", "Z Corp Plaster", "Objet Build", "Objet Support" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jTable1MouseClicked(evt); + } + }); + jScrollPane1.setViewportView(jTable1); + + jButton2.setText("Search"); + jButton2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jButton2MouseClicked(evt); + } + }); + + jLabel4.setText("Search by first name, last name, or Towson ID:"); + + jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel5.setText("Student Balance"); + + jButton3.setText("Add"); + jButton3.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jButton3MouseClicked(evt); + } + }); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Z Corp Plaster", "Objet Build", "Objet Support" })); + + jLabel1.setText("Select Material:"); + + jLabel2.setText("Enter Amount:"); + 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() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jButton1) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 227, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jButton2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE) + .addComponent(jLabel2)) + .addComponent(jLabel1)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, 79, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 74, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addComponent(jLabel4))) + .addContainerGap()) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel5) + .addGap(210, 210, 210)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel5) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel1)) + .addGap(1, 1, 1) + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2) + .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton3) + .addComponent(jLabel2)) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 214, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(18, 18, 18) + .addComponent(jButton1) + .addContainerGap()) + ); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked + dispose(); + home.setVisible(true); + }//GEN-LAST:event_jButton1MouseClicked + + private void jButton2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MouseClicked + enteredValue = ""; + //firstName = ""; + //lastName = ""; + //id = ""; + enteredValue = jTextField1.getText(); + //firstName = jTextField1.getText(); + //lastName = jTextField2.getText(); + //id = jTextField3.getText(); + //updateBalanceWindow(firstName, lastName, id); + updateBalanceWindow(enteredValue); + }//GEN-LAST:event_jButton2MouseClicked + + private void jButton3MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton3MouseClicked + String stringTemp = jTextField4.getText(); + amount = Double.valueOf(stringTemp); + String studentId = null; + SQLMethods dbconn = new SQLMethods(); + if (jTable1.getRowCount() == 1 && !jTable1.contains(jTable1.getSelectedRow(),2)) + { + studentId = jTable1.getModel().getValueAt(0, 2).toString(); + } + else if (jTable1.contains(jTable1.getSelectedRow(), 2)) + { + studentId = jTable1.getModel().getValueAt(jTable1.getSelectedRow(), 2).toString(); + } + + if(jComboBox1.getSelectedItem().toString().equalsIgnoreCase("Z Corp Plaster")) + { + dbconn.addMaterial(studentId, amount, "z_corp_plaster"); + dbconn.addTransactionHistory(studentId, "z_corp_plaster", amount); + } + else if(jComboBox1.getSelectedItem().toString().equalsIgnoreCase("Objet Build")) + { + dbconn.addMaterial(studentId, amount, "objet_build"); + dbconn.addTransactionHistory(studentId, "objet_build", amount); + } + else if(jComboBox1.getSelectedItem().toString().equalsIgnoreCase("Objet Support")) + { + dbconn.addMaterial(studentId, amount, "objet_support"); + dbconn.addTransactionHistory(studentId, "objet_support", amount); + } + else + { + System.out.println("ERROR"); + } + + + dbconn.closeDBConnection(); + updateBalanceWindow(enteredValue); + }//GEN-LAST:event_jButton3MouseClicked + + private void jTable1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable1MouseClicked + JTable table =(JTable) evt.getSource(); + Point p = evt.getPoint(); + int row = table.rowAtPoint(p); + if (evt.getClickCount() == 2) { + // double-click a row + System.out.println("double clicked..."); + System.out.println(table.getValueAt(table.getSelectedRow(), 0).toString()); + + String fName = table.getValueAt(table.getSelectedRow(), 0).toString(); + String lName = table.getValueAt(table.getSelectedRow(), 1).toString(); + String id = table.getValueAt(table.getSelectedRow(), 2).toString(); + + materialTransView = new MaterialTransactionHistoryView(); + materialTransView.showHistory(fName, lName, id); + //dispose(); + } + }//GEN-LAST:event_jTable1MouseClicked + + /** + * @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(BalanceView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(BalanceView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(BalanceView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(BalanceView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new BalanceView().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; + private javax.swing.JTextField jTextField1; + private javax.swing.JTextField jTextField4; + // End of variables declaration//GEN-END:variables + private void initNavBar() + { + + jMenuBar1.setPreferredSize(new Dimension(275, 30)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(Box.createRigidArea(new Dimension(42,12))); + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + navBtn_build.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_reports); + + navBtn_balance = new JButton("Balance"); + navBtn_balance.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/stats_icon.png"))); + navBtn_balance.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_balance); + + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_settings); + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_balance.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_balanceActionPerformed(evt); + } + }); + + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + } + + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_balanceActionPerformed(java.awt.event.ActionEvent evt) + { + balanceView = new BalanceView(); + balanceView.setVisible(true); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new newSettingsMenu(); + adminSettingsView.setVisible(true); + dispose(); + + } + + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_settings; + private JButton navBtn_balance; +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.form index 59ba4ba..ed2e910 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.form +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.form @@ -52,42 +52,7 @@ </Component> </SubComponents> </Container> - <Menu class="javax.swing.JMenuBar" name="jMenuBar1"> - <SubComponents> - <Menu class="javax.swing.JMenu" name="removeBuildOpen"> - <Properties> - <Property name="text" type="java.lang.String" value="Remove Build"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="removeBuildOpenActionPerformed"/> - </Events> - <SubComponents> - <MenuItem class="javax.swing.JMenuItem" name="jMenuItem1"> - <Properties> - <Property name="text" type="java.lang.String" value="Remove Build"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jMenuItem1ActionPerformed"/> - </Events> - </MenuItem> - </SubComponents> - </Menu> - <Menu class="javax.swing.JMenu" name="helpMenu"> - <Properties> - <Property name="text" type="java.lang.String" value="Help"/> - </Properties> - <SubComponents> - <MenuItem class="javax.swing.JMenuItem" name="userGuide"> - <Properties> - <Property name="text" type="java.lang.String" value="User Guide"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="userGuideActionPerformed"/> - </Events> - </MenuItem> - </SubComponents> - </Menu> - </SubComponents> + <Menu class="javax.swing.JMenuBar" name="jMenuBar2"> </Menu> </NonVisualComponents> <Properties> @@ -98,7 +63,7 @@ <Property name="resizable" type="boolean" value="false"/> </Properties> <SyntheticProperties> - <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> + <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar2"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> <SyntheticProperty name="generateCenter" type="boolean" value="true"/> </SyntheticProperties> @@ -112,7 +77,7 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,-47,0,0,3,-49"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,2,127,0,0,3,-22"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> @@ -128,9 +93,6 @@ </Component> <Component class="javax.swing.JButton" name="Submit_Button"> <Properties> - <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> - <Color blue="0" green="ff" red="0" type="rgb"/> - </Property> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Segoe UI" size="11" style="0"/> </Property> @@ -141,7 +103,7 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="860" y="640" width="100" height="30"/> + <AbsoluteConstraints x="870" y="550" width="100" height="30"/> </Constraint> </Constraints> </Component> @@ -154,7 +116,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="120" width="200" height="19"/> + <AbsoluteConstraints x="20" y="120" width="200" height="19"/> </Constraint> </Constraints> </Component> @@ -226,7 +188,7 @@ </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="140" width="950" height="300"/> + <AbsoluteConstraints x="20" y="140" width="400" height="210"/> </Constraint> </Constraints> @@ -236,29 +198,16 @@ <Properties> <Property name="autoCreateRowSorter" type="boolean" value="true"/> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> - <Connection code="new javax.swing.table.DefaultTableModel() { Class[] types = new Class [] { java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class ,java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { true, false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }" type="code"/> + <Connection code="new javax.swing.table.DefaultTableModel() { Class[] types = new Class [] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class ,java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }" type="code"/> </Property> <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> - <TableColumnModel selectionModel="0"> - <Column maxWidth="30" minWidth="30" prefWidth="-1" resizable="true"> - <Title/> - <Editor/> - <Renderer/> - </Column> - <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false"> - <Title/> - <Editor/> - <Renderer/> - </Column> - <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="false"> - <Title/> - <Editor/> - <Renderer/> - </Column> - </TableColumnModel> + <TableColumnModel selectionModel="1"/> + </Property> + <Property name="cursor" type="java.awt.Cursor" editor="org.netbeans.modules.form.editors2.CursorEditor"> + <Color id="Default Cursor"/> </Property> <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> - <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> </Property> </Properties> </Component> @@ -298,66 +247,16 @@ </Constraint> </Constraints> </Component> - <Container class="javax.swing.JScrollPane" name="jScrollPane4"> - <AuxValues> - <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="480" width="950" height="150"/> - </Constraint> - </Constraints> - - <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> - <SubComponents> - <Component class="javax.swing.JTable" name="deviceInputTable"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Tahoma" size="20" style="0"/> - </Property> - <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> - <Connection code="new javax.swing.table.DefaultTableModel(new Object[]{}, 1) " type="code"/> - </Property> - <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> - <TableColumnModel selectionModel="0"/> - </Property> - <Property name="rowHeight" type="int" value="24"/> - <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> - <TableHeader reorderingAllowed="true" resizingAllowed="true"/> - </Property> - </Properties> - </Component> - </SubComponents> - </Container> <Component class="javax.swing.JLabel" name="jLabel3"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Segoe UI" size="12" style="1"/> </Property> - <Property name="text" type="java.lang.String" value="Enter Build Data:"/> + <Property name="text" type="java.lang.String" value="Previous Builds for Device:"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="460" width="150" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="backToMainMenu"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"/> - </Property> - <Property name="toolTipText" type="java.lang.String" value="Back"/> - <Property name="borderPainted" type="boolean" value="false"/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - <Property name="focusPainted" type="boolean" value="false"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="backToMainMenuActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="20" y="10" width="40" height="40"/> + <AbsoluteConstraints x="20" y="360" width="150" height="20"/> </Constraint> </Constraints> </Component> @@ -382,134 +281,88 @@ </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="runtimeLabel"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="1"/> - </Property> - <Property name="text" type="java.lang.String" value="Total Runtime:"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="580" y="650" width="-1" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JTextField" name="hourField"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="00"/> - </Properties> + <Container class="javax.swing.JScrollPane" name="jScrollPane4"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="660" y="650" width="20" height="-1"/> + <AbsoluteConstraints x="20" y="380" width="950" height="150"/> </Constraint> </Constraints> - </Component> - <Component class="javax.swing.JTextField" name="secondField"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="00"/> - <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> - <Dimension value="[20, 20]"/> - </Property> - </Properties> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="buildsForCurrentDeviceTable"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.table.DefaultTableModel() { Class[] types = new Class [] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }" type="code"/> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"/> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Container class="javax.swing.JScrollPane" name="jScrollPane6"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="720" y="650" width="-1" height="-1"/> + <AbsoluteConstraints x="540" y="140" width="430" height="210"/> </Constraint> </Constraints> - </Component> - <Component class="javax.swing.JTextField" name="minuteField"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="submissionsToBuildList"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.table.DefaultTableModel() { Class[] types = new Class [] { java.lang.Object.class, java.lang.Object.class, java.lang.Object.class ,java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; boolean[] canEdit = new boolean [] { false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }" type="code"/> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="1"/> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="logoutButton"> <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="00"/> - <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> - <Dimension value="[20, 20]"/> - </Property> + <Property name="text" type="java.lang.String" value="Logout"/> </Properties> <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="minuteFieldActionPerformed"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="logoutButtonActionPerformed"/> </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="690" y="650" width="-1" height="-1"/> + <AbsoluteConstraints x="20" y="550" width="100" height="30"/> </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="jLabel5"> + <Component class="javax.swing.JButton" name="swapButton"> <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="12" style="1"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value=":"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="680" y="650" width="10" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel6"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="12" style="1"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value=":"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="710" y="650" width="10" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel7"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="10" style="1"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="H"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="660" y="670" width="20" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel8"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="10" style="1"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="M"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="690" y="670" width="20" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel9"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="10" style="1"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/swap3.png"/> </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="S"/> </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="swapButtonMouseClicked"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="swapButtonActionPerformed"/> + </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="720" y="670" width="20" height="-1"/> + <AbsoluteConstraints x="440" y="240" width="80" height="40"/> </Constraint> </Constraints> </Component> @@ -521,7 +374,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="-6" y="-26" width="980" height="780"/> + <AbsoluteConstraints x="0" y="0" width="990" height="630"/> </Constraint> </Constraints> </Component> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.java index 29a13d3..b40cd47 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/BuildView.java @@ -5,19 +5,31 @@ import java.awt.event.WindowEvent; import java.io.File; import java.util.ArrayList; +import java.awt.Color; + +import javax.swing.ListSelectionModel; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; import javax.swing.JFileChooser; import javax.swing.JOptionPane; import javax.swing.JPanel; +import javax.swing.MutableComboBoxModel; import javax.swing.table.DefaultTableModel; public class BuildView extends javax.swing.JFrame { - private static final String NAME_OF_PAGE = "Build File Creator"; private static MainView home = new MainView(); private static RemoveBuildView removeWindow = new RemoveBuildView(); private static int countNumOfModels; - + // --nav bar views ~Alex + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private BalanceView balanceView; + private newSettingsMenu adminSettingsView; + // private static final DefaultTableModel invalidBuildLocationSelectedColumnModel = new DefaultTableModel(); private static String[] errorTextColumnHeader = { @@ -28,24 +40,29 @@ public class BuildView extends javax.swing.JFrame private ArrayList<String> trackableFields; private DefaultTableModel deviceDataModel; /* Used to hold data entered in by the user for the build to display */ - private DefaultTableModel fileTableModel; /* Used to hold accepted files (student submissions) that are to be displayed in the first table */ - + private DefaultTableModel fileTableModel; /* Used to hold available files (student submissions) displayed in the first table */ + private DefaultTableModel fileTableModel2; /*Used to hold current files which the add/remove come into play */ + private DefaultTableModel fileTableModel3; //Used to hold builds that have already been created for the selected device + private Device deviceModel = null; FileManager inst; - private static void updateViewData(DefaultTableModel model, ArrayList<ArrayList<Object>> view) + + //this function is never called + //Rajewski + /*private static void updateViewData(DefaultTableModel model, ArrayList<ArrayList<Object>> view) { - /* Clears up the rows in the view's model. */ + /* Clears up the rows in the view's model. for (int rows = model.getRowCount() - 1; rows >= 0; rows--) { model.removeRow(rows); } - /* Inserts data found in (ArrayList -> listOfRows) by row into the UI model to display */ + /* Inserts data found in (ArrayList -> listOfRows) by row into the UI model to display for (ArrayList<Object> row : view) { - /* We need to account for the checkbox by adding in a boolean value = false as the first value. */ + /* We need to account for the check box by adding in a boolean value = false as the first value. if(UtilController.findAndVerifyFile((String)(row.get(1)))){ row.add(0, (Boolean) false); model.addRow(row.toArray()); @@ -53,7 +70,7 @@ private static void updateViewData(DefaultTableModel model, ArrayList<ArrayList< //System.out.println(row.get(1)); } } - + */ private void clearEntries(DefaultTableModel fileTableModel) { while (fileTableModel.getRowCount() > 0) @@ -78,17 +95,17 @@ private boolean getAndValididateUserInput() /* filepathToSelectedDeviceBuild is the file location to the build file */ if (filepathToSelectedDeviceBuild.getText().isEmpty()) { - ErrorText.setText("Choose a build file below!"); + ErrorText.setText("Choose a build file from Current Jobs!"); ErrorText.setVisible(true); return false; } else { - //checks to see if any sleections in table exist to prevent no file submit case - for (int z = 0; z < fileTableModel.getRowCount(); z++) + //checks to see if any selections in table exist to prevent no file submit case + for (int z = 0; z < fileTableModel2.getRowCount(); z++) //changed to model2 so it has to be in this table in order to validate { - if ((Boolean) fileTableModel.getValueAt(z, 0)) + if (fileTableModel2.getValueAt(z, 0) != null) { - filesSelected = true; /* Atleast one file was checked off for being part of the build*/ + filesSelected = true; /* At least one file was checked off for being part of the build*/ break; } @@ -103,14 +120,16 @@ private boolean getAndValididateUserInput() } } + //Rajewski + //Removed becuase no more device input table /* Now that a printer has been selected, build file location, and files that are part of the build we can validate the input for the build data - */ + for (int column = 0; column < deviceInputTable.getColumnCount(); column++) { - /* Test the column input to see type */ + // Test the column input to see type / int testColumnInput = InputValidation.getDataType((String) deviceInputTable.getValueAt(0, column)); - /* Ask Device model which type the column SHOULD be */ + // Ask Device model which type the column SHOULD be / int expectedColumnInput = deviceModel.getFieldType(trackableFields.get(column)); if (testColumnInput == -1) @@ -125,10 +144,16 @@ private boolean getAndValididateUserInput() return false; } } + */ + return true; } - private boolean preprocessDataForSubmit() + //Rajewski + //Does not need to be called + /* + /based entirely on nonexistent deviceInputTable + /private boolean preprocessDataForSubmit() { for (int column = 0; column < deviceInputTable.getColumnCount(); column++) { @@ -141,6 +166,7 @@ private boolean preprocessDataForSubmit() } return true; } + */ private boolean submit() { @@ -150,29 +176,40 @@ private boolean submit() if (getAndValididateUserInput()) { - if(preprocessDataForSubmit()) + //Rajewski + //no need to call this now without the input table + //if(preprocessDataForSubmit()) + ErrorText.setVisible(false); + if (studentSubmissionTracked) { - ErrorText.setVisible(false); - if (studentSubmissionTracked) - { - filePathToBuildFile = filepathToSelectedDeviceBuild.getText(); - } else - { - filePathToBuildFile = "not_tracked_" + UtilController.getCurrentTimeFromDB(); - } - selectedJobID = new ArrayList<>(); + filePathToBuildFile = filepathToSelectedDeviceBuild.getText(); + } else + { + filePathToBuildFile = "not_tracked_" + UtilController.getCurrentTimeFromDB(); + } + selectedJobID = new ArrayList<>(); - /* "", "Job ID", "File name", "First name", "Last name", "Submission date", "Printer name", "Class name", "Class section" */ - for (int row = 0; row < fileTableModel.getRowCount(); row++) + /* "", "Job ID", "File name", "First name", "Last name", "Submission date", "Printer name", "Class name", "Class section" */ + for (int row = 0; row < submissionsToBuildList.getRowCount(); row++) + { + if (submissionsToBuildList.getValueAt(row, 0) != null) /* If checked then add file to list */ // has to be in the second table in order for a file to be successfully submitted { - if ((Boolean) fileTableModel.getValueAt(row, 0) /* If checked then add file to list */) - { - selectedJobID.add(Integer.parseInt((String) fileTableModel.getValueAt(row, 1))); - countNumOfModels++; - } + selectedJobID.add(Integer.parseInt((String) submissionsToBuildList.getValueAt(row, 0))); + countNumOfModels++; } - return UtilController.submitBuild(selectedJobID, deviceModel, filePathToBuildFile, countNumOfModels); } + System.out.println(selectedJobID + deviceModel.getDeviceName() + filePathToBuildFile + countNumOfModels); + + //Russell- Joe + //After clicking submit, you get to here. It passes all other error checks when you have at least + //one file in the right hand table, and one build file selected via Browse + //submitBuild is in UtilController + if(UtilController.submitBuild(selectedJobID, deviceModel, filePathToBuildFile, countNumOfModels)) + { + JOptionPane.showMessageDialog(null, "Build successfully created"); + return true; + } + //} } return false; } @@ -181,8 +218,15 @@ public void startMakeBuildProcess() { inst = new FileManager(); initComponents(); + // --nav bar views ~Alex + + initNavBar(); + // + buildFileLocationErrorStatusText.setVisible(false); - deviceInputTable.setVisible(false); + //Rajewski + //no more need for deviceInputTable calls + //deviceInputTable.setVisible(false); try { @@ -200,7 +244,11 @@ public void startMakeBuildProcess() } countNumOfModels = 0; + fileTableModel = (DefaultTableModel) studentSubmissionApprovedTableList.getModel(); + fileTableModel2 = (DefaultTableModel) submissionsToBuildList.getModel(); //added + fileTableModel3 = (DefaultTableModel) buildsForCurrentDeviceTable.getModel(); + ErrorText.setVisible(false); this.setVisible(true); @@ -247,26 +295,16 @@ private void initComponents() { studentSubmissionApprovedTableList = new javax.swing.JTable(); jLabel2 = new javax.swing.JLabel(); deviceNameComboBox = new javax.swing.JComboBox(); - jScrollPane4 = new javax.swing.JScrollPane(); - deviceInputTable = new javax.swing.JTable(); jLabel3 = new javax.swing.JLabel(); - backToMainMenu = new javax.swing.JButton(); buildFileLocationErrorStatusText = new javax.swing.JLabel(); - runtimeLabel = new javax.swing.JLabel(); - hourField = new javax.swing.JTextField(); - secondField = new javax.swing.JTextField(); - minuteField = new javax.swing.JTextField(); - jLabel5 = new javax.swing.JLabel(); - jLabel6 = new javax.swing.JLabel(); - jLabel7 = new javax.swing.JLabel(); - jLabel8 = new javax.swing.JLabel(); - jLabel9 = new javax.swing.JLabel(); + jScrollPane4 = new javax.swing.JScrollPane(); + buildsForCurrentDeviceTable = new javax.swing.JTable(); + jScrollPane6 = new javax.swing.JScrollPane(); + submissionsToBuildList = new javax.swing.JTable(); + logoutButton = new javax.swing.JButton(); + swapButton = new javax.swing.JButton(); jLabel1 = new javax.swing.JLabel(); - jMenuBar1 = new javax.swing.JMenuBar(); - removeBuildOpen = new javax.swing.JMenu(); - jMenuItem1 = new javax.swing.JMenuItem(); - helpMenu = new javax.swing.JMenu(); - userGuide = new javax.swing.JMenuItem(); + jMenuBar2 = new javax.swing.JMenuBar(); jList1.setModel(new javax.swing.AbstractListModel() { String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; @@ -289,7 +327,6 @@ private void initComponents() { getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 950, 10)); - Submit_Button.setBackground(new java.awt.Color(0, 255, 0)); Submit_Button.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N Submit_Button.setText("Submit Build"); Submit_Button.addActionListener(new java.awt.event.ActionListener() { @@ -297,11 +334,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { Submit_ButtonActionPerformed(evt); } }); - getContentPane().add(Submit_Button, new org.netbeans.lib.awtextra.AbsoluteConstraints(860, 640, 100, 30)); + getContentPane().add(Submit_Button, new org.netbeans.lib.awtextra.AbsoluteConstraints(870, 550, 100, 30)); jLabel4.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N jLabel4.setText("Choose jobs part of build: "); - getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 200, 19)); + getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 120, 200, 19)); buildLbl.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N buildLbl.setText("Build File Name:"); @@ -336,12 +373,13 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { { Class[] types = new Class [] { - java.lang.Boolean.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class + java.lang.Object.class, java.lang.Object.class, java.lang.Object.class ,java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class }; + boolean[] canEdit = new boolean [] { - true, false, false, false, false, false, false, false, false + false, false, false, false, false, false, false, false }; public Class getColumnClass(int columnIndex) @@ -353,16 +391,14 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } + }); + studentSubmissionApprovedTableList.setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR)); + studentSubmissionApprovedTableList.getTableHeader().setReorderingAllowed(false); jScrollPane3.setViewportView(studentSubmissionApprovedTableList); - if (studentSubmissionApprovedTableList.getColumnModel().getColumnCount() > 0) { - studentSubmissionApprovedTableList.getColumnModel().getColumn(0).setMinWidth(30); - studentSubmissionApprovedTableList.getColumnModel().getColumn(0).setMaxWidth(30); - studentSubmissionApprovedTableList.getColumnModel().getColumn(1).setResizable(false); - studentSubmissionApprovedTableList.getColumnModel().getColumn(2).setResizable(false); - } + studentSubmissionApprovedTableList.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); - getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 140, 950, 300)); + getContentPane().add(jScrollPane3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 140, 400, 210)); jLabel2.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N jLabel2.setText("Select Device:"); @@ -378,29 +414,9 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); getContentPane().add(deviceNameComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(250, 20, 170, -1)); - deviceInputTable.setFont(new java.awt.Font("Tahoma", 0, 20)); // NOI18N - deviceInputTable.setModel(new javax.swing.table.DefaultTableModel(new Object[]{}, 1) - ); - deviceInputTable.setRowHeight(24); - jScrollPane4.setViewportView(deviceInputTable); - - getContentPane().add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 480, 950, 150)); - jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N - jLabel3.setText("Enter Build Data:"); - getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 460, 150, 20)); - - backToMainMenu.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N - backToMainMenu.setToolTipText("Back"); - backToMainMenu.setBorderPainted(false); - backToMainMenu.setContentAreaFilled(false); - backToMainMenu.setFocusPainted(false); - backToMainMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - backToMainMenuActionPerformed(evt); - } - }); - getContentPane().add(backToMainMenu, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 10, 40, 40)); + jLabel3.setText("Previous Builds for Device:"); + getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 360, 150, 20)); buildFileLocationErrorStatusText.setFont(new java.awt.Font("Segoe UI", 1, 14)); // NOI18N buildFileLocationErrorStatusText.setForeground(new java.awt.Color(255, 0, 0)); @@ -410,91 +426,208 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { buildFileLocationErrorStatusText.setToolTipText(""); getContentPane().add(buildFileLocationErrorStatusText, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 70, 520, 20)); - runtimeLabel.setFont(new java.awt.Font("Segoe UI", 1, 11)); // NOI18N - runtimeLabel.setText("Total Runtime:"); - getContentPane().add(runtimeLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(580, 650, -1, 20)); - - hourField.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - hourField.setText("00"); - getContentPane().add(hourField, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 650, 20, -1)); + buildsForCurrentDeviceTable.setAutoCreateRowSorter(true); + buildsForCurrentDeviceTable.setModel(new javax.swing.table.DefaultTableModel() + { + Class[] types = new Class [] + { + java.lang.Object.class, java.lang.Object.class, java.lang.Object.class + }; - secondField.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - secondField.setText("00"); - secondField.setPreferredSize(new java.awt.Dimension(20, 20)); - getContentPane().add(secondField, new org.netbeans.lib.awtextra.AbsoluteConstraints(720, 650, -1, -1)); + boolean[] canEdit = new boolean [] + { + false, false, false + }; - minuteField.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - minuteField.setText("00"); - minuteField.setPreferredSize(new java.awt.Dimension(20, 20)); - minuteField.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - minuteFieldActionPerformed(evt); - } - }); - getContentPane().add(minuteField, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 650, -1, -1)); - - jLabel5.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N - jLabel5.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel5.setText(":"); - getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(680, 650, 10, 20)); - - jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N - jLabel6.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel6.setText(":"); - getContentPane().add(jLabel6, new org.netbeans.lib.awtextra.AbsoluteConstraints(710, 650, 10, 20)); - - jLabel7.setFont(new java.awt.Font("Segoe UI", 1, 10)); // NOI18N - jLabel7.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel7.setText("H"); - getContentPane().add(jLabel7, new org.netbeans.lib.awtextra.AbsoluteConstraints(660, 670, 20, -1)); - - jLabel8.setFont(new java.awt.Font("Segoe UI", 1, 10)); // NOI18N - jLabel8.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel8.setText("M"); - getContentPane().add(jLabel8, new org.netbeans.lib.awtextra.AbsoluteConstraints(690, 670, 20, -1)); - - jLabel9.setFont(new java.awt.Font("Segoe UI", 1, 10)); // NOI18N - jLabel9.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - jLabel9.setText("S"); - getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(720, 670, 20, -1)); - - jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(-6, -26, 980, 780)); - - removeBuildOpen.setText("Remove Build"); - removeBuildOpen.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - removeBuildOpenActionPerformed(evt); - } - }); + public Class getColumnClass(int columnIndex) + { + return types [columnIndex]; + } - jMenuItem1.setText("Remove Build"); - jMenuItem1.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem1ActionPerformed(evt); - } - }); - removeBuildOpen.add(jMenuItem1); + public boolean isCellEditable(int rowIndex, int columnIndex) + { + return canEdit [columnIndex]; + } + }); + buildsForCurrentDeviceTable.getTableHeader().setReorderingAllowed(false); + jScrollPane4.setViewportView(buildsForCurrentDeviceTable); - jMenuBar1.add(removeBuildOpen); + getContentPane().add(jScrollPane4, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 380, 950, 150)); - helpMenu.setText("Help"); + submissionsToBuildList.setAutoCreateRowSorter(true); + submissionsToBuildList.setModel(new javax.swing.table.DefaultTableModel() + { + Class[] types = new Class [] + { + java.lang.Object.class, java.lang.Object.class, java.lang.Object.class + ,java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class, java.lang.Object.class + }; + boolean[] canEdit = new boolean [] + { + false, false, false, false, false, false, false, false + }; + + public Class getColumnClass(int columnIndex) + { + return types [columnIndex]; + } + + public boolean isCellEditable(int rowIndex, int columnIndex) + { + return canEdit [columnIndex]; + } + + }); + submissionsToBuildList.getTableHeader().setReorderingAllowed(false); + jScrollPane6.setViewportView(submissionsToBuildList); + submissionsToBuildList.getColumnModel().getSelectionModel().setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELECTION); + + getContentPane().add(jScrollPane6, new org.netbeans.lib.awtextra.AbsoluteConstraints(540, 140, 430, 210)); + + logoutButton.setText("Logout"); + logoutButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + logoutButtonActionPerformed(evt); + } + }); + getContentPane().add(logoutButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 550, 100, 30)); + + swapButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/swap3.png"))); // NOI18N + swapButton.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + swapButtonMouseClicked(evt); + } + }); + swapButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + swapButtonActionPerformed(evt); + } + }); + getContentPane().add(swapButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(440, 240, 80, 40)); + + jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N + getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 990, 630)); + setJMenuBar(jMenuBar2); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + - userGuide.setText("User Guide"); - userGuide.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - userGuideActionPerformed(evt); - } - }); - helpMenu.add(userGuide); + private void initNavBar() + { - jMenuBar1.add(helpMenu); + jMenuBar2.setPreferredSize(new Dimension(275, 30)); + setJMenuBar(jMenuBar2); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + + jMenuBar2.add(Box.createRigidArea(new Dimension(170,12))); + jMenuBar2.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + navBtn_build.setPreferredSize(new Dimension(100,24)); + jMenuBar2.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + jMenuBar2.add(navBtn_reports); + + navBtn_balance = new JButton("Balance"); + navBtn_balance.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/stats_icon.png"))); + navBtn_balance.setPreferredSize(new Dimension(100,24)); + + jMenuBar2.add(navBtn_balance); + + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + jMenuBar2.add(navBtn_settings); + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_balance.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_balanceActionPerformed(evt); + } + }); + + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); - setJMenuBar(jMenuBar1); + } + + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_balanceActionPerformed(java.awt.event.ActionEvent evt) + { + balanceView= new BalanceView(); + balanceView.setVisible(true); + dispose(); - pack(); - setLocationRelativeTo(null); - }// </editor-fold>//GEN-END:initComponents + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new newSettingsMenu(); + adminSettingsView.setVisible(true); + dispose(); + + } + + + + /////// Nav Bar ~Alex ///// + + private void Submit_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_Submit_ButtonActionPerformed //add stl information to build table zcorp and create incomplete entry if (!submit()) @@ -503,10 +636,19 @@ private void Submit_ButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN } else { dispose(); - home.resetAdminMode(); + //Rajewski + //Will now reload build view instead of go to jobs manager. + //home.resetAdminMode(); + navBtn_buildActionPerformed(evt); } }//GEN-LAST:event_Submit_ButtonActionPerformed + private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed +//GEN-HEADEREND:event_logoutButtonActionPerformed + dispose(); + home.setVisible(true); + }//GEN-LAST:event_logoutButtonActionPerformed + private void filepathToSelectedDeviceBuildActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_filepathToSelectedDeviceBuildActionPerformed // TODO add your handling code here: }//GEN-LAST:event_filepathToSelectedDeviceBuildActionPerformed @@ -516,11 +658,17 @@ private void filepathToSelectedDeviceBuildActionPerformed(java.awt.event.ActionE * * @param evt */ + //this might be what brings up the page + //Rajewski private void browseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_browseBtnActionPerformed JFileChooser chooser = new JFileChooser();//Select Default + ///? + //Rajewski File defaultBuildDirectory; String device = (String)deviceNameComboBox.getSelectedItem(); device.toLowerCase(); + //RAJEWSKI + //WHAT DOES THIS DO? defaultBuildDirectory = new File(FileManager.getDeviceToPrint(device)); chooser.setPreferredSize(new Dimension(800, 500)); chooser.setCurrentDirectory(defaultBuildDirectory); @@ -535,47 +683,79 @@ private void browseBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR if (!filepathToSelectedDeviceBuild.getText().isEmpty() && deviceModel != null) { + //checks that new build file is unique if (!UtilController.isBuildFileLocationUsed(filepathToSelectedDeviceBuild.getText())) { - setupUserInputBuildData(); + //Rajewski + //create new function for making the list of builds table visible/populated for selected device + //call it here + //setupUserInputBuildData(); } else { filepathToSelectedDeviceBuild.setText(""); buildFileLocationErrorStatusText.setText("Select a unique build file location"); buildFileLocationErrorStatusText.setVisible(true); - invalidBuildLocationSelectedColumnModel.setColumnIdentifiers(errorTextColumnHeader); - deviceInputTable.setModel(invalidBuildLocationSelectedColumnModel); - deviceInputTable.setVisible(false); + //Rajewski + //deviceInputTable was removed and replaced with table of previous builds + + //invalidBuildLocationSelectedColumnModel.setColumnIdentifiers(errorTextColumnHeader); + //deviceInputTable.setModel(invalidBuildLocationSelectedColumnModel); + //deviceInputTable.setVisible(false); } } }//GEN-LAST:event_browseBtnActionPerformed - private void userGuideActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userGuideActionPerformed - // TODO add your handling code here: - UtilController.openAdminHelpPage(); - }//GEN-LAST:event_userGuideActionPerformed - + //Rajewski + //Removed because no longer used/needed for input table + /* private void setupUserInputBuildData() { buildFileLocationErrorStatusText.setVisible(false); - deviceModel.addField("Run time", 0); /* Should later remove this and make it a seperate parameter in the function submitBuild call (so the backend knows less about how the UI stores its data) */ - /* + deviceModel.addField("Run time", 0); /* Should later remove this and make it a seperate parameter in the function submitBuild call (so the backend knows less about how the UI stores its data) + deviceModel.addField("Hours", 0); deviceModel.addField("Minutes", 0); deviceModel.addField("Seconds", 0); - */ + trackableFields = deviceModel.getFieldNames(); deviceDataModel = new DefaultTableModel(trackableFields.toArray(), 1); + deviceInputTable.setModel(deviceDataModel); deviceInputTable.setVisible(true); } + */ + private void deviceNameComboBoxActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_deviceNameComboBoxActionPerformed {//GEN-HEADEREND:event_deviceNameComboBoxActionPerformed /* When a device is selected we put the info into the Device class and then detrmine how we update our view from here From here we can determine how we update our display and what type of data we require from the user as well as the column data to display. */ + + + clearEntries(fileTableModel); + clearEntries(fileTableModel2); + clearEntries(fileTableModel3); + studentSubmissionApprovedTableList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + submissionsToBuildList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); + + + /* + studentSubmissionApprovedTableList.setRowSelectionAllowed(true); + studentSubmissionApprovedTableList.setColumnSelectionAllowed(true); + studentSubmissionApprovedTableList.setCellSelectionEnabled(false); + + studentSubmissionApprovedTableList.setSelectionBackground(Color.BLUE); + studentSubmissionApprovedTableList.setSelectionForeground(Color.BLUE); + + submissionsToBuildList.setRowSelectionAllowed(true); + submissionsToBuildList.setColumnSelectionAllowed(true); + submissionsToBuildList.setCellSelectionEnabled(false); + + submissionsToBuildList.setSelectionBackground(Color.BLUE); + submissionsToBuildList.setSelectionForeground(Color.BLUE); + */ deviceModel = UtilController.getPrinterInfo((String) deviceNameComboBox.getSelectedItem()); if (deviceModel.getTrackSubmission()) @@ -586,22 +766,42 @@ private void deviceNameComboBoxActionPerformed(java.awt.event.ActionEvent evt)// { fileTableModel.setColumnIdentifiers(new String[] { - "", "Job ID", "File name", "First name", "Last name", "Submission date", "Printer name", "Class name", "Class section" + "Job ID", "File name", "First name", "Last name", "Submission date", "Printer name", "Class name", "Class section" + }); + + fileTableModel2.setColumnIdentifiers(new String[] + { + "Job ID", "File name", "First name", "Last name", "Submission date", "Printer name", "Class name", "Class section" + }); + for(int i = 0; i < approvedStudentSubmissions.size(); i++) + { + fileTableModel.addRow(new Object[] {approvedStudentSubmissions.get(i).get(0), approvedStudentSubmissions.get(i).get(1), + approvedStudentSubmissions.get(i).get(2), approvedStudentSubmissions.get(i).get(3), approvedStudentSubmissions.get(i).get(4), + approvedStudentSubmissions.get(i).get(5), approvedStudentSubmissions.get(i).get(6), approvedStudentSubmissions.get(i).get(7) + }); + //Rajewski + //development purposes + /*System.out.println(approvedStudentSubmissions.get(i).get(0) + "\t" + approvedStudentSubmissions.get(i).get(1) + "\t" + + approvedStudentSubmissions.get(i).get(2) + "\t" + approvedStudentSubmissions.get(i).get(3) + "\t" + approvedStudentSubmissions.get(i).get(4) + "\t" + + approvedStudentSubmissions.get(i).get(5) + "\t" + approvedStudentSubmissions.get(i).get(6) + "\t" + approvedStudentSubmissions.get(i).get(7));*/ + } - updateViewData(fileTableModel, approvedStudentSubmissions); - - /* Set UI to display the next steps in completing a build for student submissions that are tracked */ + submissionsToBuildList.setModel(fileTableModel2); + studentSubmissionApprovedTableList.setModel(fileTableModel); + submissionsToBuildList.setVisible(true); studentSubmissionApprovedTableList.setVisible(true); buildLbl.setVisible(true); browseBtn.setVisible(true); filepathToSelectedDeviceBuild.setVisible(true); + repaint(); } else { fileTableModel.setColumnIdentifiers(new String[] { - "There are no approved student submissions for the device " + deviceModel.getDeviceName() + "There are no approved student submissions for the " + deviceModel.getDeviceName() }); + submissionsToBuildList.setVisible(false); studentSubmissionApprovedTableList.setVisible(false); buildLbl.setVisible(false); browseBtn.setVisible(false); @@ -610,9 +810,12 @@ private void deviceNameComboBoxActionPerformed(java.awt.event.ActionEvent evt)// } else { - setupUserInputBuildData(); + //Rajewski + //deleted function + //setupUserInputBuildData(); studentSubmissionTracked = false; + submissionsToBuildList.setVisible(false); studentSubmissionApprovedTableList.setVisible(false); filepathToSelectedDeviceBuild.setVisible(false); buildLbl.setVisible(false); @@ -623,67 +826,273 @@ private void deviceNameComboBoxActionPerformed(java.awt.event.ActionEvent evt)// "Student submission for the " + deviceModel.getDeviceName() + " was added to Opt-Out of approval/denal of jobs" }); } + + setupBuildRecordsTable(); + }//GEN-LAST:event_deviceNameComboBoxActionPerformed - private void backToMainMenuActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_backToMainMenuActionPerformed - {//GEN-HEADEREND:event_backToMainMenuActionPerformed - dispose(); - home.resetAdminMode(); - }//GEN-LAST:event_backToMainMenuActionPerformed + private void setupBuildRecordsTable(){ + //Rajewski + //Setting up table of previous builds + fileTableModel3.setColumnIdentifiers(new String[] + { + "Build File Name", "Date", "Number of Files" - private void removeBuildOpenActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_removeBuildOpenActionPerformed - {//GEN-HEADEREND:event_removeBuildOpenActionPerformed + }); + buildsForCurrentDeviceTable.getColumnModel().getColumn(0).setPreferredWidth(410); + String currentDevice = (String) deviceNameComboBox.getSelectedItem(); + ArrayList<ArrayList<Object>> buildList = UtilController.arrayListOfBuilds(currentDevice); + for(int i = 0; i < buildList.size(); i++) + { + fileTableModel3.addRow(new Object[] { buildList.get(i).get(0), buildList.get(i).get(1), + buildList.get(i).get(2) + }); + //Rajewski + //line for testing + //System.out.println(buildList.get(i).get(0) + "\t" + buildList.get(i).get(1) + "\t" + buildList.get(i).get(2)); + } + + } + + private void swapButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_swapButtonActionPerformed + + }//GEN-LAST:event_swapButtonActionPerformed + + private void swapButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_swapButtonMouseClicked + // TODO add your handling code here: + //Rajewski + //Optimize this function later + /*studentSubmissionApprovedTableList.setRowSelectionAllowed(true); + studentSubmissionApprovedTableList.setColumnSelectionAllowed(true); + studentSubmissionApprovedTableList.setCellSelectionEnabled(true); + studentSubmissionApprovedTableList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + + submissionsToBuildList.setRowSelectionAllowed(true); + submissionsToBuildList.setColumnSelectionAllowed(true); + submissionsToBuildList.setCellSelectionEnabled(true); + submissionsToBuildList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); + */ + //Rajewski + //This is not good error checking. + /* + if (studentSubmissionApprovedTableList.equals(submissionsToBuildList.getSelectedRow())) //believe this check works //No, it does not Spring 2016. - Rajewski + { + JOptionPane.showMessageDialog(null, "File is already in the current jobs list!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + */ + + /*if(submissionsToBuildList.getSelectedRow() == 0) + { + ((MutableComboBoxModel) studentSubmissionApprovedTableList).addElement(submissionsToBuildList.getSelectedRow()); + ((MutableComboBoxModel) submissionsToBuildList).removeElement(submissionsToBuildList.getSelectedRow()); + }*/ + + //removed else if block becuase not having a selection could still mean that the other table has a selected row + /* + else if(submissionsToBuildList.getSelectedRow() == -1) + { + JOptionPane.showMessageDialog(null, "No file selected!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + */ + //gets all info for selected row to add to build table + + int k; + + /* + while(k < studentSubmissionApprovedTableList.getRowCount()){ + + + //k--; + } + k++; + //System.out.print(k + "\t"); + } + //System.out.println(); + */ + k = studentSubmissionApprovedTableList.getSelectedRow(); + System.out.println(k); + if(k != -1){ + fileTableModel2.addRow(new Object[] { + studentSubmissionApprovedTableList.getValueAt(k, 0), + studentSubmissionApprovedTableList.getValueAt(k, 1), + studentSubmissionApprovedTableList.getValueAt(k, 2), + studentSubmissionApprovedTableList.getValueAt(k, 3), + studentSubmissionApprovedTableList.getValueAt(k, 4), + studentSubmissionApprovedTableList.getValueAt(k, 5), + studentSubmissionApprovedTableList.getValueAt(k, 6), + studentSubmissionApprovedTableList.getValueAt(k, 7) + }); + fileTableModel.removeRow(k); + } + + + studentSubmissionApprovedTableList.setModel(fileTableModel); + submissionsToBuildList.setModel(fileTableModel2); - }//GEN-LAST:event_removeBuildOpenActionPerformed + /* + * + * removeClassListModel.addElement(currentClassListRC.getSelectedValue()); + currentDeviceListModel.removeElement(currentClassListRC.getSelectedValue()); + //((MutableComboBoxModel) studentSubmissionApprovedTableList).addElement(submissionsToBuildList.getSelectedRow()); + //((MutableComboBoxModel) submissionsToBuildList).removeElement(submissionsToBuildList.getSelectedRow()); + //removeClassList.setModel(removeClassListModel); + * + * */ + + + //Rajewski + //logic for moving a row from the new build table back to the approved files table + int j; +/* + while(j < submissionsToBuildList.getRowCount()){ + + //j--; + } + j++; + } + */ + + j = submissionsToBuildList.getSelectedRow(); + if(j != -1){ + fileTableModel.addRow(new Object[] { + submissionsToBuildList.getValueAt(j, 0), + submissionsToBuildList.getValueAt(j, 1), + submissionsToBuildList.getValueAt(j, 2), + submissionsToBuildList.getValueAt(j, 3), + submissionsToBuildList.getValueAt(j, 4), + submissionsToBuildList.getValueAt(j, 5), + submissionsToBuildList.getValueAt(j, 6), + submissionsToBuildList.getValueAt(j, 7) - private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItem1ActionPerformed - {//GEN-HEADEREND:event_jMenuItem1ActionPerformed - dispose(); - removeWindow.init(); - }//GEN-LAST:event_jMenuItem1ActionPerformed + }); + fileTableModel2.removeRow(j); + } + - private void minuteFieldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_minuteFieldActionPerformed + studentSubmissionApprovedTableList.setModel(fileTableModel); + submissionsToBuildList.setModel(fileTableModel2); + + + setupBuildRecordsTable(); + }//GEN-LAST:event_swapButtonMouseClicked +/* + private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_minuteFieldActionPerformed + }//GEN-LAST:event_jButton1ActionPerformed + + */ + private void addArrowActionPerformed (java.awt.event.ActionEvent evt) + { + if (studentSubmissionApprovedTableList.equals(submissionsToBuildList.getSelectedRow())) //believe this check works + { + JOptionPane.showMessageDialog(null, "File is already in the current jobs list!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + + /*if(submissionsToBuildList.getSelectedRow() == 0) + { + ((MutableComboBoxModel) studentSubmissionApprovedTableList).addElement(submissionsToBuildList.getSelectedRow()); + ((MutableComboBoxModel) submissionsToBuildList).removeElement(submissionsToBuildList.getSelectedRow()); + }*/ + + else if(submissionsToBuildList.getSelectedRow() == -1) + { + JOptionPane.showMessageDialog(null, "No file selected!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else + { + fileTableModel2.addRow(new Object[] { submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 0), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 1), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 2), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 3), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 4), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 5), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 6), + submissionsToBuildList.getValueAt(submissionsToBuildList.getSelectedRow(), 7) + + }); + + + + + fileTableModel.removeRow(submissionsToBuildList.getSelectedRow()); + + submissionsToBuildList.setModel(fileTableModel); + studentSubmissionApprovedTableList.setModel(fileTableModel2); + /* + * + * removeClassListModel.addElement(currentClassListRC.getSelectedValue()); + currentDeviceListModel.removeElement(currentClassListRC.getSelectedValue()); + //((MutableComboBoxModel) studentSubmissionApprovedTableList).addElement(submissionsToBuildList.getSelectedRow()); + //((MutableComboBoxModel) submissionsToBuildList).removeElement(submissionsToBuildList.getSelectedRow()); + //removeClassList.setModel(removeClassListModel); + * + * */ + + + } + } + + private void removeArrowActionPerformed (java.awt.event.ActionEvent evt) + { + fileTableModel.addRow(new Object[] { studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 0), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 1), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 2), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 3), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 4), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 5), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 6), + studentSubmissionApprovedTableList.getValueAt(studentSubmissionApprovedTableList.getSelectedRow(), 7) + + }); + + + + + fileTableModel2.removeRow(studentSubmissionApprovedTableList.getSelectedRow()); + submissionsToBuildList.setModel(fileTableModel); + studentSubmissionApprovedTableList.setModel(fileTableModel2); + } + private JButton navBtn_balance; + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_settings; + //Rajewski + //refactored submissionsToBuildList to submissionsToBuildList // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel ErrorText; private javax.swing.JButton Submit_Button; - private javax.swing.JButton backToMainMenu; private javax.swing.JButton browseBtn; private javax.swing.JLabel buildFileLocationErrorStatusText; private javax.swing.JLabel buildLbl; - private javax.swing.JTable deviceInputTable; + private javax.swing.JTable buildsForCurrentDeviceTable; private javax.swing.JComboBox deviceNameComboBox; private javax.swing.JTextField filepathToSelectedDeviceBuild; - private javax.swing.JMenu helpMenu; - private javax.swing.JTextField hourField; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; - private javax.swing.JLabel jLabel6; - private javax.swing.JLabel jLabel7; - private javax.swing.JLabel jLabel8; - private javax.swing.JLabel jLabel9; private javax.swing.JList jList1; - private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JMenuItem jMenuItem1; + private javax.swing.JMenuBar jMenuBar2; 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.JSeparator jSeparator1; private javax.swing.JTextArea jTextArea1; private javax.swing.JTextPane jTextPane1; - private javax.swing.JTextField minuteField; - private javax.swing.JMenu removeBuildOpen; - private javax.swing.JLabel runtimeLabel; - private javax.swing.JTextField secondField; + private javax.swing.JButton logoutButton; private javax.swing.JTable studentSubmissionApprovedTableList; - private javax.swing.JMenuItem userGuide; + private javax.swing.JTable submissionsToBuildList; + private javax.swing.JButton swapButton; // End of variables declaration//GEN-END:variables } + diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ChangePasswordView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ChangePasswordView.java index 6bea42c..51c106b 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ChangePasswordView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ChangePasswordView.java @@ -17,6 +17,7 @@ public class ChangePasswordView extends javax.swing.JFrame { + AdminSettingsView settings = new AdminSettingsView(); public void passwordChangeStart() { initComponents(); diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ClassMgr.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ClassMgr.java new file mode 100644 index 0000000..875787f --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ClassMgr.java @@ -0,0 +1,486 @@ +package ObjectLabEnterpriseSoftware; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.Font; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JOptionPane; + +import java.awt.Color; +import javax.swing.JScrollPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.ListModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.JButton; +import javax.swing.JTabbedPane; +import java.awt.Component; +import javax.swing.Box; +import javax.swing.DefaultListModel; +import javax.swing.JSplitPane; +import java.awt.Dimension; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JDesktopPane; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.ImageIcon; +import java.awt.Toolkit; + +public class ClassMgr extends JFrame { + public static final String [] arrayOfTowsonDepartments = {"AFST","AHLT","AMST","ANTH", + "ARAB","ARED","ART","ARTH","ASST","ASTR","BCLA","BIOL","BUSX","CDCE","CHEM","CHNS", + "CIS","CLST","COMM","COSC","CRMJ","DANC","DFST","DVMT","DVRD","DVWR","EBTM","ECED", + "ECON","ECSE","EDUC","EESE","ELED","EMF","ENGL","ENTR","ENVS","ESOL","FIN","FLPN","FMST", + "FREN","FRSC","GENL","GEOG","GEOL","GERM","GERO","GRK","HCMN","HEBR","HIST", + "HLTH","HONR","IDFA","IDHP","IDIS","IDNM","INLA","INST","ISTC","ITAL","ITEC", + "JPNS","KNES","LAST","LATN","LEGL","LGBT","LWAC","MATH","MBBB","MCOM","MKTG", + "MNGT","MTRO","MUED","MUSA","MUSC","NURS","OCTH","PHEA","PHIL","PHSC","PHYS", + "PORT","POSC","PSYC","REED","RLST","RUSS","SCED","SCIE","SOCI","SOSC","SPAN", + "SPED","SPPA","THEA","WMST","WRIT"}; + + + + + public ClassMgr() { + setIconImage(Toolkit.getDefaultToolkit().getImage(ClassMgr.class.getResource("/ObjectLabEnterpriseSoftware/images/icon.ico"))); + setPreferredSize(new Dimension(550, 370)); + setResizable(false); + setFont(new Font("Segoe UI", Font.PLAIN, 14)); + setTitle("Class Manager"); + getContentPane().setBackground(Color.WHITE); + initWindow(); + updateView(); + } // end of constructor + + private void initWindow() + { + + + + JLabel titleLabel = new JLabel("Class Manager"); + titleLabel.setBounds(189, 11, 178, 40); + titleLabel.setFont(new Font("Segoe UI", Font.BOLD, 24)); + titleLabel.setVisible(true); + getContentPane().setLayout(null); + getContentPane().add(titleLabel); + + JTabbedPane tabbedPane = new JTabbedPane(JTabbedPane.LEFT); + tabbedPane.setBounds(10, 59, 516, 264); + tabbedPane.setBackground(Color.LIGHT_GRAY); + getContentPane().add(tabbedPane); + tabbedPane.setVisible(true); + JPanel manageClassPanel = new JPanel(); + tabbedPane.addTab("Manage Classes", null, manageClassPanel, null); + manageClassPanel.setLayout(null); + + JLabel jLabel3 = new JLabel(); + jLabel3.setText("Inactive Classes"); + jLabel3.setFont(new Font("Segoe UI", Font.BOLD, 12)); + jLabel3.setBounds(20, 25, 110, 19); + manageClassPanel.add(jLabel3); + + jScrollPane3 = new JScrollPane(); + jScrollPane3.setBounds(20, 44, 139, 189); + manageClassPanel.add(jScrollPane3); + + allClassList = new JList(); + jScrollPane3.setViewportView(allClassList); + + addArrow = new JButton(); + addArrow.setText("--->"); + addArrow.setPreferredSize(new Dimension(60, 23)); + addArrow.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + addArrow.setBounds(169, 99, 90, 23); + manageClassPanel.add(addArrow); + + removeArrow = new JButton(); + removeArrow.setText("<---"); + removeArrow.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + removeArrow.setBounds(169, 129, 90, 23); + removeArrow.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + removeArrowActionPerformed(evt); + } + }); + manageClassPanel.add(removeArrow); + + jScrollPane4 = new JScrollPane(); + jScrollPane4.setBounds(269, 44, 139, 190); + manageClassPanel.add(jScrollPane4); + + currentClassList = new JList(); + jScrollPane4.setViewportView(currentClassList); + + JLabel lblActiveClasses = new JLabel(); + lblActiveClasses.setText("Active Classes"); + lblActiveClasses.setFont(new Font("Segoe UI", Font.BOLD, 12)); + lblActiveClasses.setBounds(269, 28, 129, 19); + manageClassPanel.add(lblActiveClasses); + + saveBtn = new JButton(); + saveBtn.setText("Apply Changes"); + saveBtn.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + saveBtn.setBounds(157, 236, 109, 23); + manageClassPanel.add(saveBtn); + + JPanel addClassPanel = new JPanel(); + tabbedPane.addTab("Add Class", null, addClassPanel, null); + addClassPanel.setBorder(null); + addClassPanel.setLayout(null); + + JLabel classNumLabel = new JLabel("Class Number:"); + classNumLabel.setBounds(0, 97, 95, 20); + classNumLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addClassPanel.add(classNumLabel); + + JLabel lblNewLabel = new JLabel("Department:"); + lblNewLabel.setBounds(0, 11, 82, 20); + addClassPanel.add(lblNewLabel); + lblNewLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + + JScrollPane classScrollPane = new JScrollPane(); + classScrollPane.setBounds(112, 14, 86, 75); + addClassPanel.add(classScrollPane); + + classList = new JList(arrayOfTowsonDepartments); + classScrollPane.setViewportView(classList); + classList.setBackground(Color.LIGHT_GRAY); + + classNumberInput = new JTextField(); + classNumberInput.setBounds(112, 99, 118, 20); + classNumLabel.setLabelFor(classNumberInput); + addClassPanel.add(classNumberInput); + classNumberInput.setColumns(10); + + JLabel sectionNumberLabel = new JLabel("Section Number:"); + sectionNumberLabel.setBounds(0, 124, 105, 20); + sectionNumberLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addClassPanel.add(sectionNumberLabel); + + SectionNumberInput = new JTextField(); + SectionNumberInput.setBounds(112, 126, 118, 20); + SectionNumberInput.setColumns(10); + addClassPanel.add(SectionNumberInput); + + JLabel professorInputLabel = new JLabel("Professor:"); + professorInputLabel.setBounds(0, 155, 105, 20); + professorInputLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addClassPanel.add(professorInputLabel); + + professorInput = new JTextField(); + professorInput.setBounds(112, 157, 118, 20); + professorInputLabel.setLabelFor(professorInput); + addClassPanel.add(professorInput); + professorInput.setColumns(10); + + JLabel lbllastName = new JLabel("(last name)"); + lbllastName.setBounds(0, 173, 72, 20); + lbllastName.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addClassPanel.add(lbllastName); + + addClassButton = new JButton("Add Class"); + addClassButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + addClass(arg0); + } + }); + addClassButton.setBounds(233, 187, 89, 23); + addClassPanel.add(addClassButton); + + JPanel removeClassPanel = new JPanel(); + tabbedPane.addTab("Remove Class", null, removeClassPanel, null); + removeClassPanel.setLayout(null); + + removePrinterButton = new JButton("Remove"); + removePrinterButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + removeClassButtonActionPerformed(arg0); + } + }); + removePrinterButton.setBounds(159, 236, 89, 23); + removeClassPanel.add(removePrinterButton); + + lblAvailableClasses = new JLabel(); + lblAvailableClasses.setText("Available Classes"); + lblAvailableClasses.setFont(new Font("Segoe UI", Font.BOLD, 12)); + lblAvailableClasses.setBounds(10, 25, 110, 19); + removeClassPanel.add(lblAvailableClasses); + + spAvaiableClassesRC = new JScrollPane(); + spAvaiableClassesRC.setBounds(10, 44, 139, 189); + removeClassPanel.add(spAvaiableClassesRC); + + currentClassListRC = new JList(); + spAvaiableClassesRC.setViewportView(currentClassListRC); + + addArrowRC = new JButton(); + addArrowRC.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + addArrowRCActionPerformed(evt); + } + }); + addArrowRC.setText("->"); + addArrowRC.setPreferredSize(new Dimension(60, 23)); + addArrowRC.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + addArrowRC.setBounds(159, 99, 90, 23); + removeClassPanel.add(addArrowRC); + + removeArrowRC = new JButton(); + removeArrowRC.setText("<-"); + removeArrowRC.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + removeArrowRC.setBounds(159, 143, 90, 23); + removeArrowRC.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + removeArrowRCActionPerformed(evt); + } + }); + removeClassPanel.add(removeArrowRC); + + JScrollPane spToBeRemovedRC = new JScrollPane(); + spToBeRemovedRC.setBounds(259, 44, 139, 190); + removeClassPanel.add(spToBeRemovedRC); + + removeClassList = new JList(); + spToBeRemovedRC.setViewportView(removeClassList); + + JLabel lblClassesToRemove = new JLabel(); + lblClassesToRemove.setText("Classes to remove"); + lblClassesToRemove.setFont(new Font("Segoe UI", Font.BOLD, 12)); + lblClassesToRemove.setBounds(259, 28, 129, 19); + removeClassPanel.add(lblClassesToRemove); + + backButton = new JLabel(""); + backButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + newSettingsMenu ns = new newSettingsMenu(); + ns.setVisible(true); + dispose(); + } + }); + backButton.setIcon(new ImageIcon(ClassMgr.class.getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); + backButton.setBounds(21, 11, 32, 33); + getContentPane().add(backButton); + + + addArrow.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + addArrowActionPerformed(evt); + } + }); + + saveBtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + saveBtnActionPerformed(evt); + } + }); + + pack(); + + setLocationRelativeTo(null); + } + + + protected void addClass(MouseEvent arg0) { + if (InputValidation.isEmpty(classList.getSelectedValue().toString()) | InputValidation.isEmpty(classNumberInput.getText()) + | InputValidation.isEmpty(SectionNumberInput.getText()) | InputValidation.isEmpty(professorInput.getText())) + { + JOptionPane.showMessageDialog(null, "Please enter all Class Values", + "Add Error", JOptionPane.ERROR_MESSAGE); + } else if (classList.getSelectedValue().toString().contains(" ") | classNumberInput.getText().contains(" ") + | SectionNumberInput.getText().contains(" ") | professorInput.getText().contains(" ")) + { + JOptionPane.showMessageDialog(null, "Values can only be one word each", + "Add Error", JOptionPane.ERROR_MESSAGE); + } else if (!InputValidation.isNumber(classNumberInput.getText()) + | !InputValidation.isNumber(SectionNumberInput.getText())) + { + JOptionPane.showMessageDialog(null, "Class Number and Section Numbers must " + + "contain only numbers", + "Add Error", JOptionPane.ERROR_MESSAGE); + } else if (!InputValidation.isAlpha(classList.getSelectedValue().toString()) | !InputValidation.isAlpha(professorInput.getText())) + { + JOptionPane.showMessageDialog(null, "Names must only contain letters.", + "Add Error", JOptionPane.ERROR_MESSAGE); + } else + { + String input = classList.getSelectedValue().toString().toUpperCase() + " " + + classNumberInput.getText() + " " + SectionNumberInput.getText(); + DefaultListModel temp = new DefaultListModel(); + temp.addElement(input); + + if (allClassListModel.contains(temp.elementAt(0)) || currentClassListModel.contains(temp.elementAt(0))) + { + JOptionPane.showMessageDialog(null, "Class already in all class list", + "Add Error", JOptionPane.ERROR_MESSAGE); + } else + { + allClassListModel.addElement(input.toUpperCase()); + UtilController.insertNewClass(classList.getSelectedValue().toString().toUpperCase(), classNumberInput.getText(), SectionNumberInput.getText(), professorInput.getText().trim()); + } + + temp.clear(); + JOptionPane.showMessageDialog(null, "Successfully added class!"); + updateView(); + } + + } + + + private DefaultListModel allClassListModel; + private DefaultListModel currentClassListModel; + private DefaultListModel removeClassListModel = new DefaultListModel(); + newSettingsMenu settings; + private static FileManager inst = null; + + private void updateView() + { + if(allClassListModel != null) + allClassListModel.clear(); + + if(currentClassListModel != null) + currentClassListModel.clear(); + + allClassListModel = UtilController.returnNonCurrentClasses(); /* false */ + currentClassListModel = UtilController.returnCurrentClasses(); /* true */ + + allClassList.setModel(allClassListModel); + currentClassList.setModel(currentClassListModel); + currentClassListRC.setModel(allClassListModel); + removeClassList.setModel(removeClassListModel); + } + + + + + + private void addArrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addArrowActionPerformed + if (currentClassListModel.contains(allClassList.getSelectedValue())) + { + JOptionPane.showMessageDialog(null, "Class already in current class list", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else if(allClassList.getSelectedValue() == null) + { + JOptionPane.showMessageDialog(null, "No class selected!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else + { + currentClassListModel.addElement(allClassList.getSelectedValue()); + allClassListModel.removeElement(allClassList.getSelectedValue()); + } + }//GEN-LAST:event_addArrowActionPerformed + + private void addArrowRCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addArrowActionPerformed + if (removeClassListModel.contains(currentClassListRC.getSelectedValue())) + { + JOptionPane.showMessageDialog(null, "Class already in current class list", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else if(currentClassListRC.getSelectedValue() == null) + { + JOptionPane.showMessageDialog(null, "No class selected!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else + { + removeClassListModel.addElement(currentClassListRC.getSelectedValue()); + allClassListModel.removeElement(currentClassListRC.getSelectedValue()); + + removeClassList.setModel(removeClassListModel); + + } + }//GEN-LAST:event_addArrowActionPerformed + + + private void saveBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveBtnActionPerformed + ArrayList<String> classes = new ArrayList<>(); + + for (int i = 0; i < currentClassListModel.getSize(); i++) + classes.add(currentClassListModel.elementAt(i).toString()); + + UtilController.updateAvailableClasses(classes); + updateView(); + }//GEN-LAST:event_saveBtnActionPerformed + + + + private void removeArrowActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeArrowActionPerformed + int i; + for (i = 0; i < currentClassListModel.getSize(); i++) + { + if (currentClassListModel.elementAt(i).equals(currentClassList.getSelectedValue())) + { + allClassListModel.addElement(currentClassListModel.elementAt(i)); + currentClassListModel.removeElementAt(i); + } + } + }//GEN-LAST:event_removeArrowActionPerformed + + + + + private void removeArrowRCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeArrowActionPerformed + int i; + for (i = 0; i < removeClassListModel.getSize(); i++) + { + if (removeClassListModel.elementAt(i).equals(removeClassList.getSelectedValue())) + { + allClassListModel.addElement(removeClassListModel.elementAt(i)); + removeClassListModel.removeElementAt(i); + } + } + }//GEN-LAST:event_removeArrowActionPerformed + + + + private void removeClassButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeClassButtonActionPerformed + + if(JOptionPane.showConfirmDialog(null, "Continue? If you delete this class you will no longer be able " + + "to select this class when building jobs.\nFiles associated with this class will not be deleted " + + "but they will no longer be associated with this class. Click 'YES' to CONFIRM DELETION this is permanent!","Warning",JOptionPane.YES_OPTION)==JOptionPane.YES_OPTION){ + for (int i = 0; i < removeClassListModel.getSize(); i++) + { + String selected = (String) removeClassListModel.elementAt(i); + System.out.println(selected); + int id = Integer.parseInt(selected.split(" ")[0]); + System.out.println(id); + UtilController.removeClass(id); + } + removeClassListModel.clear(); + updateView(); + } + else + JOptionPane.showMessageDialog(null, "Please select a class to remove."); + }//GEN-LAST:event_removeClassButtonActionPerformed + + private javax.swing.JScrollPane jScrollPane3; + private javax.swing.JScrollPane jScrollPane4; + private javax.swing.JButton saveBtn; + private javax.swing.JList allClassList; + private javax.swing.JList currentClassList; + private javax.swing.JButton addArrow; + private javax.swing.JButton removeArrow; + private JList removeClassList; + private JButton addArrowRC; + private JButton removeArrowRC; + private JButton addClassButton; + + private JTextField classNumberInput; + private JTextField SectionNumberInput; + private JTextField professorInput; + private JList currentClassListRC; + private JScrollPane spAvaiableClassesRC ; + private JLabel lblAvailableClasses; + private JButton removePrinterButton; + private JList classList ; + private JLabel backButton; +}// end of class \ No newline at end of file diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.form new file mode 100644 index 0000000..57e2c6a --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.form @@ -0,0 +1,88 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Rejected File Comment"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + <Component id="jComboBox1" max="32767" attributes="0"/> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="40" max="-2" attributes="0"/> + <Component id="jComboBox1" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="77" max="32767" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Done"/> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MouseClicked"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Rejected Comment"/> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox1"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> + <StringArray count="4"> + <StringItem index="0" value="Inccorect File Type "/> + <StringItem index="1" value="Not Enough Materail"/> + <StringItem index="2" value="Invalid File "/> + <StringItem index="3" value="Other "/> + </StringArray> + </Property> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.java new file mode 100644 index 0000000..d727bdc --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/CommentView.java @@ -0,0 +1,144 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; + +/** + * + * @author Russell + */ +public class CommentView extends javax.swing.JFrame { + + private static String comment; + private static String file; + //private static boolean isFinished; + + /** + * Creates new form CommentView + */ + public CommentView() { + + } + public CommentView(String studentFile) + { + + getContentPane().setBackground(Color.WHITE); + initComponents(); + file = studentFile; + setVisible(true); + } + /** + * 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() { + + jButton1 = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Rejected File Comment"); + + jButton1.setText("Done"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jButton1MouseClicked(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel1.setText("Rejected Comment"); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Inccorect File Type\t\t\t", "Not Enough Materail", "Invalid File ", "Other " })); + + 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() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jButton1)) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(0, 0, Short.MAX_VALUE)) + .addComponent(jComboBox1, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(40, 40, 40) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 77, Short.MAX_VALUE) + .addComponent(jButton1) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MouseClicked + + comment = jComboBox1.getSelectedItem().toString(); + SQLMethods dbconn = new SQLMethods(); + dbconn.updateFileComment(file, comment); + System.out.println("Comment"); + dbconn.closeDBConnection(); + //isFinished = true; + dispose(); + + }//GEN-LAST:event_jButton1MouseClicked + + + + /*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(CommentView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(CommentView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(CommentView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(CommentView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + */ + /* Create and display the form */ + /* java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new CommentView().setVisible(true); + } + }); + }*/ + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/DeviceMgr.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/DeviceMgr.java new file mode 100644 index 0000000..64d0d2e --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/DeviceMgr.java @@ -0,0 +1,725 @@ +package ObjectLabEnterpriseSoftware; + +import javax.swing.JFrame; +import javax.swing.JLabel; +import java.awt.Font; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.util.ArrayList; +import java.util.Arrays; + +import javax.swing.JComboBox; +import javax.swing.JList; +import javax.swing.JOptionPane; + +import java.awt.Color; +import javax.swing.JScrollPane; +import javax.swing.JPanel; +import javax.swing.JTextField; +import javax.swing.ListModel; +import javax.swing.table.DefaultTableModel; +import javax.swing.JButton; +import javax.swing.JCheckBox; +import javax.swing.JTabbedPane; +import java.awt.Component; +import javax.swing.Box; +import javax.swing.DefaultListModel; +import javax.swing.JSplitPane; +import java.awt.Dimension; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; +import javax.swing.JDesktopPane; +import javax.swing.JDialog; + +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import javax.swing.ImageIcon; +import javax.swing.JTextArea; +import java.awt.SystemColor; +import javax.swing.AbstractListModel; +import java.awt.Toolkit; + + +/* + * + * Device Manager + * @author=M. Alex Boyd + * + * TO DOS + * 1. Add error text for empty textfields when adding device + */ +public class DeviceMgr extends JFrame { + + + //Current count of labels and fields + ArrayList<String> currentDevices = UtilController.getListOfCurrentDevices(); + ListModel removeTable; + private int count = 0; + private boolean trackingSelected = true; + + + private DefaultListModel allClassListModel; + private DefaultListModel currentClassListModel; + private DefaultListModel removeClassListModel = new DefaultListModel(); + private DefaultListModel currentDeviceListModel = new DefaultListModel(); + newSettingsMenu settings; + private static FileManager inst = null; + public DeviceMgr() { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setIconImage(Toolkit.getDefaultToolkit().getImage(DeviceMgr.class.getResource("/ObjectLabEnterpriseSoftware/images/icon.ico"))); + setPreferredSize(new Dimension(550, 370)); + setResizable(false); + setFont(new Font("Segoe UI", Font.PLAIN, 14)); + setTitle("Device Manager"); + getContentPane().setBackground(Color.WHITE); + initWindow(); + updateView(); + + addWindowListener( + new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent we) + { + settings = new newSettingsMenu(); + settings.setVisible(true); + dispose(); + } + } + ); + + for(int i = 0; i < currentDevices.size(); i++) + { + currentDeviceListModel.addElement(currentDevices.get(i)); + } + + + } // end of constructor + + private void initWindow() + { + + + + JLabel titleLabel = new JLabel("Device Manager"); + titleLabel.setBounds(177, 8, 200, 40); + titleLabel.setFont(new Font("Segoe UI", Font.BOLD, 24)); + titleLabel.setVisible(true); + getContentPane().setLayout(null); + getContentPane().add(titleLabel); + + tabbedPane = new JTabbedPane(JTabbedPane.LEFT); + tabbedPane.setBounds(10, 55, 516, 287); + tabbedPane.setBackground(Color.LIGHT_GRAY); + getContentPane().add(tabbedPane); + tabbedPane.setVisible(true); + + addDevicePanel = new JPanel(); + tabbedPane.addTab("Add Device", null, addDevicePanel, null); + addDevicePanel.setBorder(null); + addDevicePanel.setLayout(null); + + deviceNameLabel = new JLabel("Device Name:"); + deviceNameLabel.setBounds(0, 11, 95, 20); + deviceNameLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addDevicePanel.add(deviceNameLabel); + + + deviceNameInput = new JTextField(); + deviceNameInput.setBounds(92, 13, 118, 20); + deviceNameLabel.setLabelFor(deviceNameInput); + addDevicePanel.add(deviceNameInput); + deviceNameInput.setColumns(10); + + fileExtLabel = new JLabel("Accepted File Extension:"); + fileExtLabel.setBounds(0, 42, 153, 20); + fileExtLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + addDevicePanel.add(fileExtLabel); + + fileExtInput = new JTextField(); + fileExtInput.setBounds(155, 44, 118, 20); + fileExtInput.setColumns(10); + addDevicePanel.add(fileExtInput); + + JTextArea txtDirections = new JTextArea(); + txtDirections.setBackground(SystemColor.menu); + txtDirections.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + txtDirections.setWrapStyleWord(true); + txtDirections.setText("Enter types of data this device requires: \n If it's a numerical value, enter field name and unit of measurement \n ex) Volume (g) \n If it's a non-numerical, just enter field name \n ex) Color"); + txtDirections.setBounds(0, 73, 401, 91); + addDevicePanel.add(txtDirections); + + fieldL1Label = new JLabel("Field name 2:"); + fieldL1Label.setFont(new Font("Tahoma", Font.PLAIN, 9)); + fieldL1Label.setBounds(10, 186, 70, 14); + fieldL1Label.setVisible(false); + addDevicePanel.add(fieldL1Label); + + fieldL0 = new JTextField(); + fieldL0.setFont(new Font("Tahoma", Font.PLAIN, 10)); + fieldL0.setColumns(10); + fieldL1Label.setLabelFor(fieldL0); + fieldL0.setBounds(80, 167, 86, 14); + addDevicePanel.add(fieldL0); + + numberValCheck0 = new JCheckBox("Numerical value"); + numberValCheck0.setFont(new Font("Tahoma", Font.PLAIN, 9)); + numberValCheck0.setBounds(174, 163, 101, 23); + addDevicePanel.add(numberValCheck0); + + addFieldButton = new JButton("Add Field"); + addFieldButton.setFont(new Font("Tahoma", Font.PLAIN, 9)); + addFieldButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + addFieldButtonActionPerformed(arg0); + } + }); + addFieldButton.setBounds(0, 262, 89, 20); + addDevicePanel.add(addFieldButton); + + saveButton = new JButton("Add Device"); + saveButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + addDevice(); + } + }); + saveButton.setBounds(332, 259, 89, 23); + addDevicePanel.add(saveButton); + + JPanel removeClassPanel = new JPanel(); + tabbedPane.addTab("Remove Device", null, removeClassPanel, null); + removeClassPanel.setLayout(null); + + removePrinterButton = new JButton("Remove"); + removePrinterButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent arg0) { + removeClassButtonActionPerformed(arg0); + } + }); + removePrinterButton.setBounds(159, 236, 89, 23); + removeClassPanel.add(removePrinterButton); + + lblAvailableClasses = new JLabel(); + lblAvailableClasses.setText("Available Devices"); + lblAvailableClasses.setFont(new Font("Segoe UI", Font.BOLD, 12)); + lblAvailableClasses.setBounds(10, 25, 110, 19); + removeClassPanel.add(lblAvailableClasses); + + spAvaiableClassesRC = new JScrollPane(); + spAvaiableClassesRC.setBounds(10, 44, 139, 189); + removeClassPanel.add(spAvaiableClassesRC); + + currentClassListRC = new JList(); + currentClassListRC.setModel(currentDeviceListModel); + spAvaiableClassesRC.setViewportView(currentClassListRC); + + addArrowRC = new JButton(); + addArrowRC.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + addArrowRCActionPerformed(evt); + } + }); + addArrowRC.setText("--->"); + addArrowRC.setPreferredSize(new Dimension(60, 23)); + addArrowRC.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + addArrowRC.setBounds(159, 99, 90, 23); + removeClassPanel.add(addArrowRC); + + removeArrowRC = new JButton(); + removeArrowRC.setText("<---"); + removeArrowRC.setFont(new Font("Segoe UI", Font.PLAIN, 11)); + removeArrowRC.setBounds(159, 143, 90, 23); + removeArrowRC.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent evt) { + removeArrowRCActionPerformed(evt); + } + }); + removeClassPanel.add(removeArrowRC); + + JScrollPane spToBeRemovedRC = new JScrollPane(); + spToBeRemovedRC.setBounds(259, 44, 139, 190); + removeClassPanel.add(spToBeRemovedRC); + + removeClassList = new JList(); + spToBeRemovedRC.setViewportView(removeClassList); + + JLabel lblClassesToRemove = new JLabel(); + lblClassesToRemove.setText("Devices to remove"); + lblClassesToRemove.setFont(new Font("Segoe UI", Font.BOLD, 12)); + lblClassesToRemove.setBounds(259, 28, 129, 19); + removeClassPanel.add(lblClassesToRemove); + + backButton = new JLabel(""); + backButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + newSettingsMenu ns = new newSettingsMenu(); + ns.setVisible(true); + dispose(); + } + }); + backButton.setIcon(new ImageIcon(DeviceMgr.class.getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); + backButton.setBounds(21, 11, 45, 37); + getContentPane().add(backButton); + + fieldL0Label = new JLabel("Field name 1:"); + fieldL0Label.setFont(new Font("Tahoma", Font.PLAIN, 10)); + fieldL0Label.setBounds(10, 167, 70, 14); + addDevicePanel.add(fieldL0Label); + + field1 = new JTextField(); + field1.setFont(new Font("Tahoma", Font.PLAIN, 9)); + field1.setColumns(10); + field1.setBounds(80, 186, 86, 14); + field1.setVisible(false); + addDevicePanel.add(field1); + + numberValCheck1 = new JCheckBox("Numerical value"); + numberValCheck1.setFont(new Font("Tahoma", Font.PLAIN, 9)); + numberValCheck1.setBounds(174, 182, 101, 23); + numberValCheck1.setVisible(false); + addDevicePanel.add(numberValCheck1); + + fieldL2Label = new JLabel("Field name 3:"); + fieldL2Label.setFont(new Font("Tahoma", Font.PLAIN, 9)); + fieldL2Label.setBounds(10, 200, 70, 23); + fieldL2Label.setVisible(false); + addDevicePanel.add(fieldL2Label); + + field2 = new JTextField(); + field2.setFont(new Font("Tahoma", Font.PLAIN, 9)); + field2.setColumns(10); + field2.setBounds(80, 204, 86, 14); + field2.setVisible(false); + addDevicePanel.add(field2); + + numberValCheck2 = new JCheckBox("Numerical value"); + numberValCheck2.setFont(new Font("Tahoma", Font.PLAIN, 9)); + numberValCheck2.setBounds(174, 200, 101, 23); + numberValCheck2.setVisible(false); + addDevicePanel.add(numberValCheck2); + + fieldL3Label = new JLabel("Field name 4:"); + fieldL3Label.setFont(new Font("Tahoma", Font.PLAIN, 9)); + fieldL3Label.setBounds(10, 222, 70, 14); + fieldL3Label.setVisible(false); + addDevicePanel.add(fieldL3Label); + + field3 = new JTextField(); + field3.setFont(new Font("Tahoma", Font.PLAIN, 9)); + field3.setColumns(10); + field3.setBounds(80, 222, 86, 14); + field3.setVisible(false); + addDevicePanel.add(field3); + + numberValCheck3 = new JCheckBox("Numerical value"); + numberValCheck3.setFont(new Font("Tahoma", Font.PLAIN, 9)); + numberValCheck3.setBounds(174, 218, 101, 23); + numberValCheck3.setVisible(false); + addDevicePanel.add(numberValCheck3); + + fieldL4Label = new JLabel("Field name 5:"); + fieldL4Label.setFont(new Font("Tahoma", Font.PLAIN, 9)); + fieldL4Label.setBounds(10, 243, 70, 14); + fieldL4Label.setVisible(false); + addDevicePanel.add(fieldL4Label); + + field4 = new JTextField(); + field4.setFont(new Font("Tahoma", Font.PLAIN, 9)); + field4.setColumns(10); + field4.setBounds(80, 243, 86, 14); + field4.setVisible(false); + addDevicePanel.add(field4); + + numberValCheck4 = new JCheckBox("Numerical value"); + numberValCheck4.setFont(new Font("Tahoma", Font.PLAIN, 9)); + numberValCheck4.setBounds(174, 239, 101, 23); + numberValCheck4.setVisible(false); + addDevicePanel.add(numberValCheck4); + + removeFieldButton = new JButton("Remove Field"); + removeFieldButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + removeFields(); + } + + }); + removeFieldButton.setFont(new Font("Tahoma", Font.PLAIN, 9)); + removeFieldButton.setBounds(100, 262, 110, 20); + addDevicePanel.add(removeFieldButton); + pack(); + + setLocationRelativeTo(null); + } + + + protected void addDevice() { // this is quick and dirty and ugly, validation should be seperated into seperate methods ~Alex + + String deviceName = null; + String fileExt = null; + ArrayList<String> fields = new ArrayList<String>(); + int[] boxes = new int[5]; + if(!deviceNameInput.getText().isEmpty()) + { + deviceName = deviceNameInput.getText(); + } + else + { + System.out.println("Device name empty! ADD ERROR TXT"); + } + + if(!fileExtInput.getText().isEmpty()) + { + fileExt = fileExtInput.getText(); + } + else + { + System.out.println("File extension field empty! ADD ERROR TXT"); + } + + + if(count >= 0) // count keeps track of visible fields (see removeFieldButton) + { + if(!fieldL0.getText().isEmpty()) + { + fields.add(fieldL0.getText()); + if(numberValCheck0.isSelected()) + { + boxes[0] = 1;// 1 = selected numerical value + } + } + else // field 0 will always be visible because remove button doesn't allow for it to be removed. (Need at least 1 field). + { + System.out.println("Field 1 Empty!"); + } + + + if(!field1.getText().isEmpty()) + { + fields.add(field1.getText()); + if(numberValCheck1.isSelected()) + { + boxes[1] = 1;// 1 = selected numerical value + } + } + else if( field1.isVisible() ) + { + System.out.println("Field 2 Empty!"); + } + + if(!field2.getText().isEmpty()) + { + fields.add(field2.getText()); + if(numberValCheck2.isSelected()) + { + boxes[2] = 1;// 1 = selected numerical value + } + } + else if( field2.isVisible() ) + { + System.out.println("Field 3 Empty!"); + } + + if(!field3.getText().isEmpty()) + { + fields.add(field3.getText()); + if(numberValCheck3.isSelected()) + { + boxes[3] = 1;// 1 = selected numerical value + } + } + else if( field3.isVisible() ) + { + System.out.println("Field 4 Empty!"); + } + + if(!field4.getText().isEmpty()) + { + fields.add(field4.getText()); + if(numberValCheck4.isSelected()) + { + boxes[4] = 1;// 1 = selected numerical value + } + } + else if( field4.isVisible() ) + { + System.out.println("Field 5 Empty!"); + } + + } + + if(!deviceName.equals(null) && !fileExt.equals(null)) + { + device = new Device(deviceName, + new ArrayList(Arrays.asList(fileExt.split(" "))), trackingSelected); + + for(int i = 0; i < fields.size(); i++) + { + if(boxes[i] == 1) // numerical value field + { + device.addField(fields.get(i), new Double("0")); + } + else + { + device.addField(fields.get(i), ""); + } + } + + if (currentDevices.contains(device.getDeviceName())) + { + JOptionPane.showMessageDialog(this, "Could not save! Device '" + device.getDeviceName() + "' already exists!"); + } else if (UtilController.addDevice(device) == true) + { + JOptionPane.showMessageDialog(this, "Device '" + device.getDeviceName() + "' was saved and added to the printer list!"); + repaint(); + } else + { + JOptionPane.showMessageDialog(this, "There was an error while saving the printer."); + } + } + + + } // end of addDevice() + + + + + private void updateView() + { + if(allClassListModel != null) + allClassListModel.clear(); + + if(currentClassListModel != null) + currentClassListModel.clear(); + + allClassListModel = new javax.swing.DefaultListModel(); /* false */ + currentClassListModel = UtilController.returnCurrentClasses(); + removeClassList.setModel(removeClassListModel); + currentClassListRC.setModel(currentDeviceListModel); + + } + + private void addArrowRCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addArrowActionPerformed + if (removeClassListModel.contains(currentClassListRC.getSelectedValue())) + { + JOptionPane.showMessageDialog(null, "Class already in current class list", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else if(currentClassListRC.getSelectedValue() == null) + { + JOptionPane.showMessageDialog(null, "No class selected!", + "Add Error", JOptionPane.ERROR_MESSAGE); + } + else + { + removeClassListModel.addElement(currentClassListRC.getSelectedValue()); + currentDeviceListModel.removeElement(currentClassListRC.getSelectedValue()); + + removeClassList.setModel(removeClassListModel); + + } + }//GEN-LAST:event_addArrowActionPerformed + + + + + private void removeArrowRCActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeArrowActionPerformed + int i; + for (i = 0; i < removeClassListModel.getSize(); i++) + { + if (removeClassListModel.elementAt(i).equals(removeClassList.getSelectedValue())) + { + currentDeviceListModel.addElement(removeClassListModel.elementAt(i)); + removeClassListModel.removeElementAt(i); + } + } + }//GEN-LAST:event_removeArrowActionPerformed + + + + private void removeClassButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeClassButtonActionPerformed + + if(JOptionPane.showConfirmDialog(null, "Continue? If you delete this device you will no longer be able " + + "to select this device when building jobs.\nFiles associated with this device will not be deleted " + + "but they will no longer be associated with this device. \n Click 'YES' to CONFIRM DELETION this is permanent!","Warning",JOptionPane.YES_OPTION)==JOptionPane.YES_OPTION){ + for (int i = 0; i < removeClassListModel.getSize(); i++) + { + String selected = (String) removeClassListModel.elementAt(i); + final String id = selected; + Thread runner = new Thread() { + + public void run() + { + UtilController.removeDevice(id); + } + }; + + runner.run(); + + + } + removeClassListModel.clear(); + updateView(); + } + else + JOptionPane.showMessageDialog(null, "Please select a class to remove."); + }//GEN-LAST:event_removeClassButtonActionPerformed + + + private void addFieldButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addFieldButtonActionPerformed + switch(count) + { + case 0: + fieldL1Label.setVisible(true); + field1.setVisible(true); + numberValCheck1.setVisible(true); + count++; + break; + case 1: + fieldL2Label.setVisible(true); + field2.setVisible(true); + numberValCheck2.setVisible(true); + count++; + break; + case 2: + fieldL3Label.setVisible(true); + field3.setVisible(true); + numberValCheck3.setVisible(true); + count++; + break; + case 3: + fieldL4Label.setVisible(true); + field4.setVisible(true); + numberValCheck4.setVisible(true); + count++; + break; + default: + JOptionPane op = new JOptionPane("The maximum number of fields has been reached. Sorry, please use 5 fields or less.", JOptionPane.INFORMATION_MESSAGE); + JDialog dialog = op.createDialog("Device Manager: Maximum Fields!"); + dialog.setAlwaysOnTop(true); + dialog.setModal(true); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + count = 4; + break; + + } + } + + private void removeFields() + { + switch(count) + { + case 1: + fieldL1Label.setVisible(false); + field1.setVisible(false); + numberValCheck1.setVisible(false); + count--; + break; + case 2: + fieldL2Label.setVisible(false); + field2.setVisible(false); + numberValCheck2.setVisible(false); + count--; + break; + case 3: + fieldL3Label.setVisible(false); + field3.setVisible(false); + numberValCheck3.setVisible(false); + count--; + break; + case 4: + fieldL4Label.setVisible(false); + field4.setVisible(false); + numberValCheck4.setVisible(false); + count--; + break; + default: + JOptionPane op = new JOptionPane("The Minimum number of fields has been reached. Sorry, please use 1 field or more.", JOptionPane.INFORMATION_MESSAGE); + JDialog dialog = op.createDialog("Device Manager: Minimum Fields!"); + dialog.setAlwaysOnTop(true); + dialog.setModal(true); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + count = 0; + break; + + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + JTextField tfield; + Device device; + JLabel tlabel; + JCheckBox cbox; + private JList removeClassList; + private JButton addArrowRC; + private JButton removeArrowRC; + private JPanel addDevicePanel; + private JTextField deviceNameInput; + private JTextField fileExtInput; + private JList currentClassListRC; + private JScrollPane spAvaiableClassesRC ; + private JLabel lblAvailableClasses; + private JButton removePrinterButton; + private JList classList ; + private JLabel backButton; + private JLabel deviceNameLabel; + private JLabel fileExtLabel; + private JLabel fieldL1Label; + private JTextField fieldL0; + private JCheckBox numberValCheck0; + private JButton addFieldButton; + private JButton saveButton; + private JTabbedPane tabbedPane; + private JLabel fieldL0Label; + private JTextField field1; + private JCheckBox numberValCheck1; + private JLabel fieldL2Label; + private JTextField field2; + private JCheckBox numberValCheck2; + private JLabel fieldL3Label; + private JTextField field3; + private JCheckBox numberValCheck3; + private JLabel fieldL4Label; + private JTextField field4; + private JCheckBox numberValCheck4; + private JButton removeFieldButton; +}// end of class diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/EmailUtils.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/EmailUtils.java index d453fda..80dd29a 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/EmailUtils.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/EmailUtils.java @@ -16,18 +16,20 @@ import javax.mail.Transport; import javax.mail.internet.InternetAddress; import javax.mail.internet.MimeMessage; +import javax.mail.Authenticator; +import javax.mail.PasswordAuthentication; public class EmailUtils { - private Session smtpSession = null; - private Properties emailSessionProperties = null; - private Message emailContent = null; - private String username = null; - private String password = null; - private String emailAdrTo = null; - private String emailMessageContent = null; + private static Session smtpSession = null; + //private static Properties emailSessionProperties = null; + private static Message emailContent = null; + private static String username = null; + private static String password = null; + private static String emailAdrTo = null; + private static String emailMessageContent = null; - private Message setEmailContents() + /*private Message setEmailContents() { Message message = new MimeMessage(smtpSession); try @@ -43,20 +45,52 @@ private Message setEmailContents() Logger.getLogger(EmailUtils.class.getName()).log(Level.SEVERE, null, ex); } return message; - } + }*/ - public EmailUtils(String emailAdrSend, String accountName, String pw, String emailTextMsg) + public static void send(String emailAdrSend, String accountName, String pw, String emailTextMsg) { username = accountName; password = pw; emailAdrTo = emailAdrSend; emailMessageContent = emailTextMsg; + Properties emailSessionProperties = System.getProperties(); + + //**** + Session session = Session.getInstance(emailSessionProperties, new javax.mail.Authenticator() { + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + session.setDebug(true); + - emailSessionProperties = new Properties(); + //emailSessionProperties = new Properties(); emailSessionProperties.put("mail.smtp.starttls.enable", "true"); emailSessionProperties.put("mail.smtp.auth", "true"); emailSessionProperties.put("mail.smtp.host", "smtp.gmail.com"); emailSessionProperties.put("mail.smtp.port", "587"); + + + + Message message = new MimeMessage(smtpSession); + + try + { + message.setFrom(new InternetAddress(username)); + //Students Email Should go here + message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(emailAdrTo)); + message.setSubject("Towson University Object Lab: No_Reply"); + message.setText(emailMessageContent); + //**** + Transport trans = session.getTransport("smtp"); + trans.connect("smtp.gmail.com", 587, "TowsonuObjectLab@gmail.com", "oblabsoftware"); + trans.sendMessage(message, message.getAllRecipients()); + } + catch (MessagingException ex) + { + Logger.getLogger(EmailUtils.class.getName()).log(Level.SEVERE, null, ex); + ex.printStackTrace(); + } smtpSession = Session.getInstance ( @@ -74,10 +108,10 @@ protected PasswordAuthentication getPasswordAuthentication() This MUST be the last thing initalized since there are so many vars to init prior to setting the contents of the email */ - emailContent = setEmailContents(); + //emailContent = setEmailContents(); } - public boolean send() + /* public boolean send() { try { @@ -94,5 +128,5 @@ public boolean send() return false; } return true; - } -} + } */ +} \ No newline at end of file diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/FileManager.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/FileManager.java index fe0afaa..c153d20 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/FileManager.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/FileManager.java @@ -22,8 +22,9 @@ public class FileManager { - private static final String drive = "C:\\Sync"; - private static final String drive2 = "C:\\Sync\\ObjectLabPrinters"; + + private static final String drive = MainView.getStorageDir() +":\\Sync"; + private static final String drive2 = MainView.getStorageDir() +":\\Sync\\ObjectLabPrinters"; private static final String submission = drive + "\\ObjectLabPrinters\\Submissions\\"; private static final String rejected = drive + "\\ObjectLabPrinters\\Rejected\\"; private static final String excelFilePath = drive + "\\Export\\"; diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/JobsView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/JobsView.java index deeb29d..790d180 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/JobsView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/JobsView.java @@ -1,6 +1,10 @@ package ObjectLabEnterpriseSoftware; +import java.awt.Checkbox; +import java.awt.CheckboxGroup; import java.awt.Desktop; +import java.awt.Dimension; +import java.awt.Insets; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.io.File; @@ -13,8 +17,15 @@ import javax.swing.JCheckBox; import javax.swing.JFrame; import javax.swing.JOptionPane; - +import javax.swing.JTabbedPane; import javax.swing.table.DefaultTableModel; +import javax.swing.table.TableColumn; +import javax.swing.Box; +import javax.swing.ImageIcon; +import java.awt.Color; +import javax.swing.JMenu; +import javax.swing.JButton; +import javax.swing.JLabel; public class JobsView extends javax.swing.JFrame { @@ -29,28 +40,38 @@ public class JobsView extends javax.swing.JFrame private ArrayList<String> printers; private String selectedPrinter; private String[] completedHeaders = new String[]{"File Name","First Name","Last Name","Submission Date","Class","Section","Volume"}; - + // --nav bar views ~Alex + private BuildView buildView; + private JobsView jobsView; + private ReportsView reportsView; + private AdminSettingsView adminSettingsView; + // private static final MainView home = new MainView(); private DefaultTableModel allFileTableModel; private void updateView(String status, DefaultTableModel pendingJobsView, ArrayList<ArrayList<Object>> view) { - pendingJobsView.setColumnIdentifiers(UtilController.getStatusJobsHeaders(status)); + pendingJobsView.setColumnIdentifiers(UtilController.getStatusJobsHeaders(status)); /* Clears up the rows in the view's model. */ for (int rows = pendingJobsView.getRowCount() - 1; rows >= 0; rows--) { pendingJobsView.removeRow(rows); } - + int rowSelector = 0; /* Inserts data found in (ArrayList -> listOfRows) by row into the UI model to display */ for (ArrayList<Object> row : view) { if(UtilController.findAndVerifyFile((String)(row.toArray()[0]))){ pendingJobsView.addRow(row.toArray()); - } + // add(new Checkbox(Integer.toString(rowSelector), selectedGroup, false)); + rowSelector++; + + } } + + //if the status is pending, show the approve and reject buttons if (!status.equals("pending")) { @@ -81,6 +102,12 @@ public JobsView() printers = UtilController.getListOfAllDevices(); /* Creates are PendingJobs UI window componet and grabs its data model for our uses */ initComponents(); + // --nav bar views ~Alex + + initNavBar(); + // + + allFileTableModel = (DefaultTableModel) PendingTable.getModel(); addWindowListener( @@ -91,7 +118,7 @@ public void windowClosing(WindowEvent we) { /* If they close the program then close out the window properly */ dispose(); - home.resetAdminMode(); + //home.resetAdminMode(); } } ); @@ -135,6 +162,9 @@ public static int getSelectedRowNum(DefaultTableModel dm, int selectedRow, int c // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { + + getContentPane().setPreferredSize(new Dimension(775,700)); + setResizable(false); jScrollPane2 = new javax.swing.JScrollPane(); jList1 = new javax.swing.JList(); jScrollPane1 = new javax.swing.JScrollPane(); @@ -154,16 +184,24 @@ private void initComponents() { printerBox = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); - jMenu2 = new javax.swing.JMenu(); - jMenuItem2 = new javax.swing.JMenuItem(); + + + + ; - checkBox = new javax.swing.JCheckBox(); jList1.setModel(new javax.swing.AbstractListModel() { - String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + 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]; } }); + + + + + + + jScrollPane2.setViewportView(jList1); jTextArea1.setEditable(false); @@ -172,7 +210,7 @@ private void initComponents() { jTextArea1.setText("Art 101-001\nArt 201-002\nArt 401-004\nArt 501-005\nArt 601-006\nArt 701-007\nArt 801-009"); jScrollPane1.setViewportView(jTextArea1); - setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(UtilController.getPageName(NAME_OF_PAGE)); setResizable(false); getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); @@ -187,7 +225,7 @@ private void initComponents() { { boolean[] canEdit = new boolean [] { - false, false, false, false, false, false, false + false, false, false, false, false, false, true }; public boolean isCellEditable(int rowIndex, int columnIndex) @@ -204,11 +242,20 @@ public boolean isCellEditable(int rowIndex, int columnIndex) backToMainMenu.setBorderPainted(false); backToMainMenu.setContentAreaFilled(false); backToMainMenu.setFocusPainted(false); + backToMainMenu.setVisible(false); backToMainMenu.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { + System.out.println("found old backbutton"); backToMainMenuActionPerformed(evt); } }); + + + + + + + getContentPane().add(backToMainMenu, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 60, 40)); jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N @@ -216,7 +263,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 60, 20)); jobStatus.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - jobStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "pending", "rejected", "approved", "completed"})); + jobStatus.setModel(new javax.swing.DefaultComboBoxModel(new String[] {"All Jobs", "Pending", "Rejected", "Approved", "Completed"})); jobStatus.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jobStatusActionPerformed(evt); @@ -233,7 +280,7 @@ public void mouseClicked(java.awt.event.MouseEvent evt) { openFileInDefaultProgram(evt); } }); - getContentPane().add(reviewFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 510, 120, 50)); + getContentPane().add(reviewFile, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 510, 130, 60)); approveButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N approveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/accept_icon.png"))); // NOI18N @@ -277,24 +324,145 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(-6, -6, 790, 590)); - jMenu2.setText("Help"); - - jMenuItem2.setText("Contents"); - jMenuItem2.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - jMenuItem2ActionPerformed(evt); - } - }); - jMenu2.add(jMenuItem2); - - jMenuBar1.add(jMenu2); - - setJMenuBar(jMenuBar1); + + + + + + pack(); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents + private void initNavBar() + { + + jMenuBar1.setPreferredSize(new Dimension(200, 75)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,75)); + navBtn_jobsMgr.setAlignmentX(jScrollPane2.CENTER_ALIGNMENT); + + jMenuBar1.add(Box.createRigidArea(new Dimension(100,0))); + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + + navBtn_build.setPreferredSize(new Dimension(100,100)); + navBtn_build.setAlignmentX(jScrollPane2.CENTER_ALIGNMENT); + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,100)); + navBtn_reports.setAlignmentX(jScrollPane2.CENTER_ALIGNMENT); + jMenuBar1.add(navBtn_reports); + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,100)); + navBtn_settings.setAlignmentX(jScrollPane2.CENTER_ALIGNMENT); + jMenuBar1.add(navBtn_settings); + + navBtn_rejected = new JButton("Rejected File Manager"); + navBtn_rejected.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reject_files_icon.ico"))); + navBtn_rejected.setPreferredSize(new Dimension(100, 100)); + navBtn_rejected.setAlignmentX(0.5f); + jMenuBar1.add(navBtn_rejected); + + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + } + + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + newJobsMgr njm = new newJobsMgr(); + njm.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new AdminSettingsView(); + adminSettingsView.AdminSettingsViewStart(); + dispose(); + + } + + + + /////// Nav Bar ~Alex ///// + + + + + + + + + + + + + + + + + + + + + + + + + + /** * This is probably something that should be in a general Utils class for * the front end or the various "views". I'm leaving this here for now @@ -336,10 +504,12 @@ private static double getDouble(String msg, double min, double max) } while (true); } - private void jMenuItem2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem2ActionPerformed - UtilController.openAdminHelpPage(); - }//GEN-LAST:event_jMenuItem2ActionPerformed + + + + + private void backToMainMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backToMainMenuActionPerformed dispose(); home.resetAdminMode(); @@ -385,14 +555,14 @@ private void openFileInDefaultProgram(java.awt.event.MouseEvent evt)//GEN-FIRST: private void approveButtonMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST:event_approveButtonMouseClicked {//GEN-HEADEREND:event_approveButtonMouseClicked int userSelectedRow = PendingTable.getSelectedRow(); - int maxVolume = 10000; /* Will need to have this in a cfg file.... */ + double maxVolume = 10000.0; /* Will need to have this in a cfg file.... */ if (userSelectedRow > -1) { int rowDataLocation = getSelectedRowNum(allFileTableModel, userSelectedRow, 0); - double volume = getDouble("Enter volume (in cubic inches): ", 0, maxVolume); // couldn't enter values between 0 < x < 1 before - fixed, --Alex + double volume = getDouble("Enter volume (in cubic inches): ", 0.0, maxVolume); - if (volume >= 1) + if (volume >= 0.001) // fix for input 0 < x < 1 { /* Hand off the data in the selected row found in our tablemodel to this method so we can approve the correct file to be printed... -Nick @@ -429,13 +599,13 @@ private void rejectButtonMouseClicked(java.awt.event.MouseEvent evt)//GEN-FIRST: desc ); - if (success) + if (success) // always rejects, commenting out email utlity for now ~Alex { - JOptionPane.showMessageDialog(new JFrame(), "Email sent succesfully!"); + JOptionPane.showMessageDialog(new JFrame(), "Rejected succesfully!"); updateView((String) jobStatus.getSelectedItem(), allFileTableModel, UtilController.updatePendingTableData((String) jobStatus.getSelectedItem())); } else { - JOptionPane.showMessageDialog(new JFrame(), "Rejection of student submission failed!"); + JOptionPane.showMessageDialog(new JFrame(), "Rejection of student submission successful!"); } } } else @@ -463,9 +633,7 @@ private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JList jList1; - private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; - private javax.swing.JMenuItem jMenuItem2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JScrollPane jScrollPane2; private javax.swing.JScrollPane jScrollPane4; @@ -475,6 +643,13 @@ private void exportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN- private javax.swing.JComboBox printerBox; private javax.swing.JLabel rejectButton; private javax.swing.JLabel reviewFile; - private JCheckBox checkBox; + private CheckboxGroup selectedGroup; + // --nav bar vars ~Alex + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_settings; + private JButton navBtn_rejected; + // // End of variables declaration//GEN-END:variables } diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.form index 1e813b5..b0fbdea 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.form +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.form @@ -41,56 +41,35 @@ </Component> </SubComponents> </Container> + <Container class="javax.swing.JMenuBar" name="jMenuBar1"> + + <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> + <Property name="useNullLayout" type="boolean" value="true"/> + </Layout> + <SubComponents> + <Menu class="javax.swing.JMenu" name="jMenu1"> + <Properties> + <Property name="text" type="java.lang.String" value="File"/> + </Properties> + </Menu> + <Menu class="javax.swing.JMenu" name="jMenu2"> + <Properties> + <Property name="text" type="java.lang.String" value="Edit"/> + </Properties> + </Menu> + </SubComponents> + </Container> <Menu class="javax.swing.JMenuBar" name="MenuBar"> <SubComponents> <Menu class="javax.swing.JMenu" name="userOptionsMenu"> <Properties> - <Property name="text" type="java.lang.String" value="User Options"/> + <Property name="text" type="java.lang.String" value="Admin "/> + <Property name="name" type="java.lang.String" value="" noResource="true"/> </Properties> <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="userOptionsMenuMousePressed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="userOptionsMenuActionPerformed"/> </Events> - <SubComponents> - <MenuItem class="javax.swing.JMenuItem" name="newStudentOption"> - <Properties> - <Property name="text" type="java.lang.String" value="Add User"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="newStudentOptionActionPerformed"/> - </Events> - </MenuItem> - <MenuItem class="javax.swing.JMenuItem" name="updateStudentOption"> - <Properties> - <Property name="text" type="java.lang.String" value="Update User Login Info"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="updateStudentOptionActionPerformed"/> - </Events> - </MenuItem> - <MenuItem class="javax.swing.JMenuItem" name="AdminLogin"> - <Properties> - <Property name="text" type="java.lang.String" value="Administrator Login"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="AdminLoginActionPerformed"/> - </Events> - </MenuItem> - </SubComponents> - </Menu> - <Menu class="javax.swing.JMenu" name="helpButton"> - <Properties> - <Property name="text" type="java.lang.String" value="Help"/> - </Properties> - <SubComponents> - <MenuItem class="javax.swing.JMenuItem" name="userGuideButton"> - <Properties> - <Property name="text" type="java.lang.String" value="User Guide"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="userGuideButtonActionPerformed"/> - </Events> - </MenuItem> - </SubComponents> </Menu> </SubComponents> </Menu> @@ -120,7 +99,7 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,0,-7,0,0,1,5"/> + <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-126,0,0,1,127"/> </AuxValues> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> @@ -141,7 +120,7 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="30" y="60" width="130" height="20"/> + <AbsoluteConstraints x="80" y="60" width="130" height="20"/> </Constraint> </Constraints> </Component> @@ -157,7 +136,7 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="30" y="40" width="130" height="20"/> + <AbsoluteConstraints x="80" y="40" width="130" height="20"/> </Constraint> </Constraints> </Component> @@ -176,75 +155,7 @@ </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="170" y="40" width="-1" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="enterBuild"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/hammer_icon.png"/> - </Property> - <Property name="toolTipText" type="java.lang.String" value=""/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="enterBuildActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="160" y="10" width="60" height="60"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="openProjectsButton"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/clipboard_icon.png"/> - </Property> - <Property name="toolTipText" type="java.lang.String" value=""/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="openProjectsButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="50" y="10" width="60" height="60"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="settingsButton"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/cog_icon.png"/> - </Property> - <Property name="toolTipText" type="java.lang.String" value=""/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="settingsButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="160" y="90" width="60" height="70"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="ReportsButton"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/reports_icon.png"/> - </Property> - <Property name="toolTipText" type="java.lang.String" value=""/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ReportsButtonActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="40" y="90" width="70" height="-1"/> + <AbsoluteConstraints x="110" y="130" width="-1" height="20"/> </Constraint> </Constraints> </Component> @@ -257,106 +168,39 @@ </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="30" y="20" width="-1" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="logoutB"> - <Properties> - <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> - <Color blue="0" green="0" red="0" type="rgb"/> - </Property> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="Logout"/> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="logoutBActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="160" y="190" width="70" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="openProjectsLabel"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="View Projects"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="11" y="70" width="130" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="enterBuildLabel"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="Enter Build"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="160" y="70" width="70" height="-1"/> + <AbsoluteConstraints x="80" y="20" width="-1" height="20"/> </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="ReportsLabel"> + <Component class="javax.swing.JLabel" name="oliSymbol"> <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> + <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> + <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/polytiger2.png"/> </Property> - <Property name="horizontalAlignment" type="int" value="0"/> - <Property name="text" type="java.lang.String" value="Reports"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="40" y="160" width="70" height="-1"/> + <AbsoluteConstraints x="120" y="191" width="-1" height="150"/> </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="settingsLabel"> + <Component class="javax.swing.JLabel" name="studentPassLabel"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="Settings"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="170" y="160" width="-1" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="oliSymbol"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/main_logo.png"/> + <Font name="Segoe UI" size="12" style="1"/> </Property> + <Property name="text" type="java.lang.String" value="Password:"/> </Properties> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="70" y="50" width="-1" height="150"/> + <AbsoluteConstraints x="80" y="70" width="-1" height="-1"/> </Constraint> </Constraints> </Component> - <Component class="javax.swing.JLabel" name="jLabel1"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/white_bg.jpg"/> - </Property> - <Property name="text" type="java.lang.String" value="jLabel1"/> - </Properties> + <Component class="javax.swing.JPasswordField" name="studentPassString"> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="0" y="0" width="260" height="230"/> + <AbsoluteConstraints x="80" y="90" width="130" height="-1"/> </Constraint> </Constraints> </Component> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.java index 984253c..526cf9d 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MainView.java @@ -1,474 +1,385 @@ -package ObjectLabEnterpriseSoftware; - -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import javax.swing.JFrame; - -public class MainView extends javax.swing.JFrame -{ - private static final String NAME_OF_PAGE = "Home"; - - AddStudentView newStudentSys; - UpdateStudentView updateStudentSys; - JobsView pendingSys; - StudentSubmissionView studentSys; - boolean show; - String PASS = "ForwardMotion"; - - public MainView() - { - initComponents(); - this.setResizable(false); - setPrintersVisible(false); - pendingSys = new JobsView(); - studentSys = new StudentSubmissionView(); - newStudentSys = new AddStudentView(); - updateStudentSys = new UpdateStudentView(); - - //Allows only integers for student ID - studentIdString.addKeyListener(new KeyAdapter() - { - public void keyTyped(KeyEvent e) - { - char c = e.getKeyChar(); - if (!((c >= '0') && (c <= '9') - || (c == KeyEvent.VK_BACK_SPACE) - || (c == KeyEvent.VK_DELETE))) - { - getToolkit().beep(); - e.consume(); - } - else if (studentIdString.getText().length() >= 7) - { - getToolkit().beep(); - e.consume(); - } - } - }); - } - - /** - * 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() { - - jScrollPane2 = new javax.swing.JScrollPane(); - jList1 = new javax.swing.JList(); - jScrollPane1 = new javax.swing.JScrollPane(); - jTextArea1 = new javax.swing.JTextArea(); - errorIdLabel = new javax.swing.JLabel(); - studentIdString = new javax.swing.JTextField(); - studentButton = new javax.swing.JButton(); - enterBuild = new javax.swing.JButton(); - openProjectsButton = new javax.swing.JButton(); - settingsButton = new javax.swing.JButton(); - ReportsButton = new javax.swing.JButton(); - studentLoginLabel = new javax.swing.JLabel(); - logoutB = new javax.swing.JButton(); - openProjectsLabel = new javax.swing.JLabel(); - enterBuildLabel = new javax.swing.JLabel(); - ReportsLabel = new javax.swing.JLabel(); - settingsLabel = new javax.swing.JLabel(); - oliSymbol = new javax.swing.JLabel(); - jLabel1 = new javax.swing.JLabel(); - MenuBar = new javax.swing.JMenuBar(); - userOptionsMenu = new javax.swing.JMenu(); - newStudentOption = new javax.swing.JMenuItem(); - updateStudentOption = new javax.swing.JMenuItem(); - AdminLogin = new javax.swing.JMenuItem(); - helpButton = new javax.swing.JMenu(); - userGuideButton = new javax.swing.JMenuItem(); - - 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]; } - }); - jScrollPane2.setViewportView(jList1); - - jTextArea1.setEditable(false); - jTextArea1.setColumns(20); - jTextArea1.setRows(5); - jTextArea1.setText("Art 101-001\nArt 201-002\nArt 401-004\nArt 501-005\nArt 601-006\nArt 701-007\nArt 801-009"); - jScrollPane1.setViewportView(jTextArea1); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle(UtilController.getPageName(NAME_OF_PAGE)); - setMinimumSize(new java.awt.Dimension(250, 370)); - setResizable(false); - getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); - - errorIdLabel.setBackground(new java.awt.Color(0, 0, 0)); - errorIdLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - errorIdLabel.setForeground(new java.awt.Color(255, 0, 0)); - getContentPane().add(errorIdLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 60, 130, 20)); - - studentIdString.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - studentIdString.setToolTipText("Enter seven digit student ID."); - studentIdString.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - studentIdStringActionPerformed(evt); - } - }); - getContentPane().add(studentIdString, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 40, 130, 20)); - - studentButton.setBackground(new java.awt.Color(0, 0, 0)); - studentButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - studentButton.setText("Login"); - studentButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - studentButtonActionPerformed(evt); - } - }); - getContentPane().add(studentButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 40, -1, 20)); - - enterBuild.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); // NOI18N - enterBuild.setToolTipText(""); - enterBuild.setContentAreaFilled(false); - enterBuild.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - enterBuildActionPerformed(evt); - } - }); - getContentPane().add(enterBuild, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 10, 60, 60)); - - openProjectsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/clipboard_icon.png"))); // NOI18N - openProjectsButton.setToolTipText(""); - openProjectsButton.setContentAreaFilled(false); - openProjectsButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - openProjectsButtonActionPerformed(evt); - } - }); - getContentPane().add(openProjectsButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 10, 60, 60)); - - settingsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); // NOI18N - settingsButton.setToolTipText(""); - settingsButton.setContentAreaFilled(false); - settingsButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - settingsButtonActionPerformed(evt); - } - }); - getContentPane().add(settingsButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 90, 60, 70)); - - ReportsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); // NOI18N - ReportsButton.setToolTipText(""); - ReportsButton.setContentAreaFilled(false); - ReportsButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - ReportsButtonActionPerformed(evt); - } - }); - getContentPane().add(ReportsButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 90, 70, -1)); - - studentLoginLabel.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N - studentLoginLabel.setText("Enter Your TU ID:"); - getContentPane().add(studentLoginLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(30, 20, -1, 20)); - - logoutB.setBackground(new java.awt.Color(0, 0, 0)); - logoutB.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - logoutB.setText("Logout"); - logoutB.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - logoutBActionPerformed(evt); - } - }); - getContentPane().add(logoutB, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 190, 70, -1)); - - openProjectsLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - openProjectsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - openProjectsLabel.setText("View Projects"); - getContentPane().add(openProjectsLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(11, 70, 130, -1)); - - enterBuildLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - enterBuildLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - enterBuildLabel.setText("Enter Build"); - getContentPane().add(enterBuildLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(160, 70, 70, -1)); - - ReportsLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - ReportsLabel.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - ReportsLabel.setText("Reports"); - getContentPane().add(ReportsLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 160, 70, -1)); - - settingsLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - settingsLabel.setText("Settings"); - getContentPane().add(settingsLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(170, 160, -1, -1)); - - oliSymbol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/main_logo.png"))); // NOI18N - getContentPane().add(oliSymbol, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 50, -1, 150)); - - jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N - jLabel1.setText("jLabel1"); - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 260, 230)); - - userOptionsMenu.setText("User Options"); - userOptionsMenu.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - userOptionsMenuActionPerformed(evt); - } - }); - - newStudentOption.setText("Add User"); - newStudentOption.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - newStudentOptionActionPerformed(evt); - } - }); - userOptionsMenu.add(newStudentOption); - - updateStudentOption.setText("Update User Login Info"); - updateStudentOption.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - updateStudentOptionActionPerformed(evt); - } - }); - userOptionsMenu.add(updateStudentOption); - - AdminLogin.setText("Administrator Login"); - AdminLogin.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - AdminLoginActionPerformed(evt); - } - }); - userOptionsMenu.add(AdminLogin); - - MenuBar.add(userOptionsMenu); - - helpButton.setText("Help"); - - userGuideButton.setText("User Guide"); - userGuideButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - userGuideButtonActionPerformed(evt); - } - }); - helpButton.add(userGuideButton); - - MenuBar.add(helpButton); - - setJMenuBar(MenuBar); - - pack(); - setLocationRelativeTo(null); - }// </editor-fold>//GEN-END:initComponents - - private void enterBuildActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_enterBuildActionPerformed - // TODO add your handling code here: - BuildView Build = new BuildView(); - Build.startMakeBuildProcess(); - dispose(); - }//GEN-LAST:event_enterBuildActionPerformed - - private void openProjectsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openProjectsButtonActionPerformed - // TODO add your handling code here: - pendingSys.PendingJobsStart(); - dispose(); - }//GEN-LAST:event_openProjectsButtonActionPerformed - - private void ReportsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReportsButtonActionPerformed - // TODO add your handling code here: - ReportsView reports = new ReportsView(); - reports.setLocationRelativeTo(this); - reports.ReportsPage(); - dispose(); - }//GEN-LAST:event_ReportsButtonActionPerformed - - public void resetAdminMode() - { - setPrintersVisible(true); - hideStudentOptions(); - setVisible(true); - } - public void hideStudentOptions() - { - studentButton.setVisible(false); - studentIdString.setVisible(false); - oliSymbol.setVisible(false); - studentLoginLabel.setVisible(false); - } - - public void showStudentOptions() - { - studentButton.setVisible(true); - studentIdString.setVisible(true); - oliSymbol.setVisible(true); - studentLoginLabel.setVisible(true); - } - - private void studentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_studentButtonActionPerformed - // TODO add your handling code here: - setPrintersVisible(false); - - String idString = studentIdString.getText();//DB team this is to store String - - if (idString.length() != 7) - { - errorIdLabel.setText("USER ID must be 7 digits"); - } else - { - if (UtilController.userIDExist(idString)) - { - errorIdLabel.setText(""); - dispose(); - studentSys.studentSubmissionStart(idString); - } else - { - errorIdLabel.setText("USER ID does not exist"); - } - } - }//GEN-LAST:event_studentButtonActionPerformed - - private void studentIdStringActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_studentIdStringActionPerformed - // TODO add your handling code here: - - }//GEN-LAST:event_studentIdStringActionPerformed - - private void userGuideButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userGuideButtonActionPerformed - UtilController.openAdminHelpPage(); - }//GEN-LAST:event_userGuideButtonActionPerformed - - private void logoutBActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutBActionPerformed - setPrintersVisible(false); - showStudentOptions(); - }//GEN-LAST:event_logoutBActionPerformed - - private void userOptionsMenuActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_userOptionsMenuActionPerformed - {//GEN-HEADEREND:event_userOptionsMenuActionPerformed - // Nothing - }//GEN-LAST:event_userOptionsMenuActionPerformed - - private void updateStudentOptionActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_updateStudentOptionActionPerformed - {//GEN-HEADEREND:event_updateStudentOptionActionPerformed - setPrintersVisible(false); - - String idString = studentIdString.getText(); //DB team this is to store String - if (idString.length() != 7) - { - errorIdLabel.setText("USER ID must be 7 digits"); - } else - { - if (UtilController.userIDExist(idString)) - { - errorIdLabel.setText(""); - dispose(); - updateStudentSys.UpdateStudentViewStart(idString); - } else - { - errorIdLabel.setText("USER ID does not exist"); - } - } - }//GEN-LAST:event_updateStudentOptionActionPerformed - - private void newStudentOptionActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_newStudentOptionActionPerformed - {//GEN-HEADEREND:event_newStudentOptionActionPerformed - newStudentSys.NewStudentViewStart(); - dispose(); - }//GEN-LAST:event_newStudentOptionActionPerformed - - private void AdminLoginActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AdminLoginActionPerformed - PasswordDialogView dialogue = new PasswordDialogView(); - dialogue.setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE); - dialogue.setAlwaysOnTop(true); - dialogue.setVisible(true); - dialogue.setLocationRelativeTo(this); - dialogue.setResizable(false); - errorIdLabel.setVisible(false); - - this.dispose(); - }//GEN-LAST:event_AdminLoginActionPerformed - - private void settingsButtonActionPerformed(java.awt.event.ActionEvent evt) - { - AdminSettingsView ad = new AdminSettingsView(); - ad.AdminSettingsViewStart(); - dispose(); - } - - public void setPrintersVisible(boolean isVisible) - { - studentButton.setVisible(!isVisible); - studentIdString.setVisible(!isVisible); - oliSymbol.setVisible(!isVisible); - studentLoginLabel.setVisible(!isVisible); - settingsButton.setVisible(isVisible); - settingsLabel.setVisible(isVisible); - openProjectsButton.setVisible(isVisible); - openProjectsLabel.setVisible(isVisible); - enterBuild.setVisible(isVisible); - enterBuildLabel.setVisible(isVisible); - ReportsButton.setVisible(isVisible); - ReportsLabel.setVisible(isVisible); - logoutB.setVisible(isVisible); - } - - /** - * @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 ("Windows".equals(info.getName())) - { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - - break; - } - } - } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) - { - java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - //</editor-fold> - //</editor-fold> - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() - { - public void run() - { - new MainView().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JMenuItem AdminLogin; - private javax.swing.JMenuBar MenuBar; - private javax.swing.JButton ReportsButton; - private javax.swing.JLabel ReportsLabel; - private javax.swing.JButton enterBuild; - private javax.swing.JLabel enterBuildLabel; - private javax.swing.JLabel errorIdLabel; - private javax.swing.JMenu helpButton; - private javax.swing.JLabel jLabel1; - private javax.swing.JList jList1; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JScrollPane jScrollPane2; - private javax.swing.JTextArea jTextArea1; - private javax.swing.JButton logoutB; - private javax.swing.JMenuItem newStudentOption; - private javax.swing.JLabel oliSymbol; - private javax.swing.JButton openProjectsButton; - private javax.swing.JLabel openProjectsLabel; - private javax.swing.JButton settingsButton; - private javax.swing.JLabel settingsLabel; - private javax.swing.JButton studentButton; - private javax.swing.JTextField studentIdString; - private javax.swing.JLabel studentLoginLabel; - private javax.swing.JMenuItem updateStudentOption; - private javax.swing.JMenuItem userGuideButton; - private javax.swing.JMenu userOptionsMenu; - // End of variables declaration//GEN-END:variables -} +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; +import java.awt.event.ActionEvent; +import java.awt.event.KeyAdapter; +import java.awt.event.KeyEvent; +import java.awt.event.KeyListener; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.WindowListener; + +import javax.swing.JFrame; +import javax.swing.SwingUtilities; +import javax.swing.JButton; + +public class MainView extends javax.swing.JFrame +{ + private static final String NAME_OF_PAGE = "Home"; + private static final char SHARE_DRIVE_DIR = 'Z'; + + // AddStudentView newStudentSys; + //UpdateStudentView updateStudentSys; + JobsView pendingSys; + newStudentView studentSys; + newJobsMgr njm; + PasswordDialogView ad; + boolean show; + String PASS = "ForwardMotion"; + + public MainView() + { + getContentPane().setBackground(Color.WHITE); + initComponents(); + this.setResizable(false); + setPrintersVisible(false); + njm = new newJobsMgr(); + studentSys = new newStudentView(); + ad = new PasswordDialogView(); + // newStudentSys = new AddStudentView(); + //updateStudentSys = new UpdateStudentView(); + + + //Allows only integers for student ID + studentIdString.addKeyListener(new KeyAdapter() + { + public void keyTyped(KeyEvent e) + { + char c = e.getKeyChar(); + /* if (!((c >= '0') && (c <= '9') + || (c == KeyEvent.VK_BACK_SPACE) + || (c == KeyEvent.VK_DELETE))) + { + getToolkit().beep(); + e.consume(); + } + else if (studentIdString.getText().length() >= 7) + { + getToolkit().beep(); + e.consume(); + }*/ + } + }); + } + + /** + * 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() { + + jScrollPane2 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTextArea1 = new javax.swing.JTextArea(); + jMenuBar1 = new javax.swing.JMenuBar(); + jMenu1 = new javax.swing.JMenu(); + jMenu2 = new javax.swing.JMenu(); + errorIdLabel = new javax.swing.JLabel(); + studentIdString = new javax.swing.JTextField(); + studentButton = new javax.swing.JButton(); + studentLoginLabel = new javax.swing.JLabel(); + oliSymbol = new javax.swing.JLabel(); + studentPassLabel = new javax.swing.JLabel(); + studentPassString = new javax.swing.JPasswordField(); + MenuBar = new javax.swing.JMenuBar(); + userOptionsMenu = new javax.swing.JMenu(); + + 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]; } + }); + jScrollPane2.setViewportView(jList1); + + jTextArea1.setEditable(false); + jTextArea1.setColumns(20); + jTextArea1.setRows(5); + jTextArea1.setText("Art 101-001\nArt 201-002\nArt 401-004\nArt 501-005\nArt 601-006\nArt 701-007\nArt 801-009"); + jScrollPane1.setViewportView(jTextArea1); + + jMenu1.setText("File"); + jMenuBar1.add(jMenu1); + + jMenu2.setText("Edit"); + jMenuBar1.add(jMenu2); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle(UtilController.getPageName(NAME_OF_PAGE)); + setMinimumSize(new java.awt.Dimension(250, 370)); + setResizable(false); + getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + errorIdLabel.setBackground(new java.awt.Color(0, 0, 0)); + errorIdLabel.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N + errorIdLabel.setForeground(new java.awt.Color(255, 0, 0)); + getContentPane().add(errorIdLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 60, 130, 20)); + + studentIdString.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N + studentIdString.setToolTipText("Enter seven digit student ID."); + studentIdString.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + studentIdStringActionPerformed(evt); + } + }); + getContentPane().add(studentIdString, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 40, 130, 20)); + + studentButton.setBackground(new java.awt.Color(0, 0, 0)); + studentButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N + studentButton.setText("Login"); + studentButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + studentButtonActionPerformed(evt); + } + }); + getContentPane().add(studentButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 130, -1, 20)); + + //Login with ENTER button + studentPassString.addKeyListener(new KeyAdapter() + { + public void keyTyped(KeyEvent e) + { + char c = e.getKeyChar(); + if(c == KeyEvent.VK_ENTER) + { + attemptLogin(); + } + } + }); + + studentLoginLabel.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N + studentLoginLabel.setText("Enter Your TU ID:"); + getContentPane().add(studentLoginLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 20, -1, 20)); + + oliSymbol.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/polytiger2.png"))); // NOI18N + getContentPane().add(oliSymbol, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 191, -1, 150)); + + studentPassLabel.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N + studentPassLabel.setText("Password:"); + getContentPane().add(studentPassLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 70, -1, -1)); + getContentPane().add(studentPassString, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 90, 130, -1)); + + userOptionsMenu.setText("Admin "); + userOptionsMenu.setName(""); // NOI18N + userOptionsMenu.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + userOptionsMenuMousePressed(evt); + } + }); + userOptionsMenu.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + userOptionsMenuActionPerformed(evt); + } + }); + MenuBar.add(userOptionsMenu); + + setJMenuBar(MenuBar); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + public void resetAdminMode() + { + njm.setVisible(true); + hideStudentOptions(); + setVisible(false); + dispose(); + } + public void hideStudentOptions() + { + studentButton.setVisible(false); + studentIdString.setVisible(false); + studentPassString.setVisible(false); + oliSymbol.setVisible(false); + studentLoginLabel.setVisible(false); + studentPassString.setVisible(false); + } + + public void showStudentOptions() + { + studentButton.setVisible(true); + studentIdString.setVisible(true); + studentPassString.setVisible(true); + oliSymbol.setVisible(true); + studentLoginLabel.setVisible(true); + studentPassString.setVisible(true); + } + + + private void attemptLogin() + { + setPrintersVisible(false); + String idString = studentIdString.getText();//DB team this is to store String + String password = new String(studentPassString.getPassword()); + if (idString.length() < 2) + { + errorIdLabel.setText("USER ID must be at least 2 characters."); + } else + { + if (UtilController.userIDExist(idString, password)) + { + errorIdLabel.setText(""); + dispose(); + studentSys.newStudentView(idString, UtilController.getStudentFname()); + } else + { + errorIdLabel.setText("Invalid TU ID or Password."); + } + } + } + + private void studentButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_studentButtonActionPerformed + // TODO add your handling code here: + setPrintersVisible(false); + + + + String idString = studentIdString.getText();//DB team this is to store String + String password = new String(studentPassString.getPassword()); + if (idString.length() < 2) + { + errorIdLabel.setText("USER ID must be at least 2 characters."); + } else + { + if (UtilController.userIDExist(idString, password)) + { + errorIdLabel.setText(""); + dispose(); + studentSys.newStudentView(idString, UtilController.getStudentFname()); + } else + { + errorIdLabel.setText("Invalid TU ID or Password."); + } + } + }//GEN-LAST:event_studentButtonActionPerformed + + private void studentIdStringActionPerformed(java.awt.event.ActionEvent evt) { + // TODO add your handling code here: + + } + + private void studentPassStringActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_studentIdStringActionPerformed + // TODO add your handling code here: + + }//GEN-LAST:event_studentIdStringActionPerformed + + private void userOptionsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_userOptionsMenuActionPerformed + //nothing + }//GEN-LAST:event_userOptionsMenuActionPerformed + + private void userOptionsMenuMousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_userOptionsMenuMousePressed + ad.setVisible(true); + dispose(); + }//GEN-LAST:event_userOptionsMenuMousePressed + + /*private void settingsButtonActionPerformed(java.awt.event.ActionEvent evt) + { + AdminSettingsView ad = new AdminSettingsView(); + ad.AdminSettingsViewStart(); + dispose(); + }*/ + + public void setPrintersVisible(boolean isVisible) + { + studentButton.setVisible(!isVisible); + studentIdString.setVisible(!isVisible); + studentPassString.setVisible(!isVisible); + oliSymbol.setVisible(!isVisible); + studentLoginLabel.setVisible(!isVisible); + studentPassString.setVisible(!isVisible); + //settingsButton.setVisible(isVisible); + //settingsLabel.setVisible(isVisible); + //openProjectsButton.setVisible(isVisible); + //openProjectsLabel.setVisible(isVisible); + //enterBuild.setVisible(isVisible); + //enterBuildLabel.setVisible(isVisible); + //ReportsButton.setVisible(isVisible); + //ReportsLabel.setVisible(isVisible); + //statsButton.setVisible(isVisible); + //logoutB.setVisible(isVisible); + } + + /** + * @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 + */ + + + String mapDrive = "net use " + SHARE_DRIVE_DIR + ": \\\\customshare\\ObjectLabStorage /user:TOWSONU\\mboyd8 6TgrAlienRazor9!"; // This is the command that mounts the drive. + Process p = null; + + try + { + p = Runtime.getRuntime().exec(mapDrive); + System.out.println(p.toString()); + } + catch(Exception e) + { + System.out.println("Something went wrong with trying to mount drive"); + } + + try + { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) + { + if ("Windows".equals(info.getName())) + { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + + break; + } + } + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | javax.swing.UnsupportedLookAndFeelException ex) + { + java.util.logging.Logger.getLogger(MainView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() + { + public void run() + { + new MainView().setVisible(true); + } + }); + } + + + public static char getStorageDir() + { + return SHARE_DRIVE_DIR; + } + + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JMenuBar MenuBar; + private javax.swing.JLabel errorIdLabel; + private javax.swing.JList jList1; + private javax.swing.JMenu jMenu1; + private javax.swing.JMenu jMenu2; + private javax.swing.JMenuBar jMenuBar1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTextArea jTextArea1; + private javax.swing.JLabel oliSymbol; + private javax.swing.JButton studentButton; + private javax.swing.JTextField studentIdString; + private javax.swing.JLabel studentLoginLabel; + private javax.swing.JLabel studentPassLabel; + private javax.swing.JPasswordField studentPassString; + private javax.swing.JMenu userOptionsMenu; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.form new file mode 100644 index 0000000..03e799a --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.form @@ -0,0 +1,109 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="2"/> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="159" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace pref="15" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace pref="32" max="32767" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="223" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="3" rowCount="4"> + <Column editable="false" title="Date" type="java.lang.Object"/> + <Column editable="false" title="Material" type="java.lang.Object"/> + <Column editable="false" title="Amount " type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="12" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Name"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.java new file mode 100644 index 0000000..63a4e3d --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/MaterialTransactionHistoryView.java @@ -0,0 +1,145 @@ +package ObjectLabEnterpriseSoftware; + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.EventQueue; +import java.sql.ResultSet; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.border.EmptyBorder; +import javax.swing.JLabel; +import javax.swing.SwingConstants; +import javax.swing.JScrollPane; +import javax.swing.table.DefaultTableModel; + +public class MaterialTransactionHistoryView extends javax.swing.JFrame { + /*private JPanel contentPane; + private JLabel lblStudentName;*/ + private static DefaultTableModel model; + + public MaterialTransactionHistoryView() { + getContentPane().setBackground(Color.WHITE); + initComponents(); + model = (DefaultTableModel) jTable1.getModel(); + setTitle("Material Transaction History"); + setVisible(true); + } + + public void showHistory(String fName, String lName, String studentID) { + System.out.println("showHistory()"); + jLabel1.setText(fName + " " + lName); + model.setRowCount(0); + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.searchStudentTransactionHistory(studentID); + + while(queryResult.next()) + { + String date = queryResult.getString(1); + String material = queryResult.getString(2); + double amount = queryResult.getDouble(3); + System.out.println("Adding row..."); + System.out.println(date + " " + material + " " + amount); + model.addRow(new Object[] {date, material, amount}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + /** + * 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() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); + setBackground(new java.awt.Color(255, 255, 255)); + + jTable1.setAutoCreateRowSorter(true); + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null}, + {null, null, null}, + {null, null, null}, + {null, null, null} + }, + new String [] { + "Date", "Material", "Amount " + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jScrollPane1.setViewportView(jTable1); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N + jLabel1.setText("Student Name"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(159, 159, 159) + .addComponent(jLabel1))) + .addContainerGap(15, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(32, Short.MAX_VALUE) + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 223, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + MaterialTransactionHistoryView frame = new MaterialTransactionHistoryView(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.form index 0a97bb5..230d6ad 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.form +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.form @@ -9,7 +9,7 @@ </Properties> <SyntheticProperties> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> - <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> </SyntheticProperties> <AuxValues> <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> @@ -56,7 +56,7 @@ <Property name="text" type="java.lang.String" value="Submit"/> </Properties> <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="SubmitButtonActionPerformed"/> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="SubmitButtonMouseClicked"/> </Events> <Constraints> <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> @@ -89,6 +89,7 @@ </Component> <Component class="javax.swing.JLabel" name="jLabel2"> <Properties> + <Property name="horizontalAlignment" type="int" value="0"/> <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/white_bg.jpg"/> </Property> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.java index ba6119d..baa11ab 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/PasswordDialogView.java @@ -1,191 +1,224 @@ -package ObjectLabEnterpriseSoftware; - -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.*; -import java.awt.*; - -public class PasswordDialogView extends javax.swing.JFrame -{ - - private static final String NAME_OF_PAGE = "Admin Password"; - private static MainView home = new MainView(); - public static boolean adminLoginStatus; - - public PasswordDialogView() - { - initComponents(); - //passwordError.setVisible(false); - Password.addKeyListener(new KeyAdapter() - { - public void keyTyped(KeyEvent capsLockCheck) - { - if(capsLockDetector()) - { - passwordError.setText("WARNING: Caps Lock is on"); - } - else - { - passwordError.setText(""); - } - } - }); - addWindowListener(new WindowAdapter() - { - @Override - public void windowClosing(WindowEvent e) - { - dispose(); - home.setPrintersVisible(false); - home.showStudentOptions(); - home.setVisible(true); - } - }); - } - - /** - * 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() { - - jLabel1 = new javax.swing.JLabel(); - CancelButton = new javax.swing.JButton(); - SubmitButton = new javax.swing.JButton(); - Password = new javax.swing.JPasswordField(); - passwordError = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - setTitle(UtilController.getPageName(NAME_OF_PAGE)); - getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); - - jLabel1.setText("Administrator Password:"); - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 20, -1, -1)); - - CancelButton.setText("Cancel"); - CancelButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - CancelButtonActionPerformed(evt); - } - }); - getContentPane().add(CancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, -1, 20)); - - SubmitButton.setText("Submit"); - SubmitButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - SubmitButtonActionPerformed(evt); - } - }); - getContentPane().add(SubmitButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 70, -1, 20)); - getContentPane().add(Password, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 136, -1)); - - passwordError.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N - passwordError.setForeground(new java.awt.Color(255, 0, 0)); - passwordError.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); - getContentPane().add(passwordError, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 200, 20)); - - jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N - getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 220, 130)); - - pack(); - }// </editor-fold>//GEN-END:initComponents - - private void SubmitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SubmitButtonActionPerformed - /*Hashes the predefined password and the password entered into the - *JPasswordField and then compares the two - */ - boolean wasLoginSuccessful = UtilController.checkAdminLogin(new String(Password.getPassword())); - - if (wasLoginSuccessful) - { - System.out.println("Password passed!"); - adminLoginStatus = true; - dispose(); - home.resetAdminMode(); - } else - { - passwordError.setText("ERROR: Invalid password"); - adminLoginStatus = false; - } - }//GEN-LAST:event_SubmitButtonActionPerformed - - private void CancelButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_CancelButtonActionPerformed - {//GEN-HEADEREND:event_CancelButtonActionPerformed - dispose(); - home.setPrintersVisible(false); - home.showStudentOptions(); - home.setVisible(true); - }//GEN-LAST:event_CancelButtonActionPerformed - - private boolean capsLockDetector() - { - //Detects if Caps Lock is on. If it is it returns a warning - if(Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) - { - return true; - } - return false; - } - - /** - * @param args the command line arguments - */ - /* - Eventually update passwordText array to take a constant for its size - */ - 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(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) - { - java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) - { - java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) - { - java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } - //</editor-fold> - //</editor-fold> - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() - { - public void run() - { - new PasswordDialogView().setVisible(true); - } - }); - } - - // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton CancelButton; - private javax.swing.JPasswordField Password; - private javax.swing.JButton SubmitButton; - private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; - private javax.swing.JLabel passwordError; - // End of variables declaration//GEN-END:variables -} +package ObjectLabEnterpriseSoftware; + +import java.awt.event.*; +import java.awt.*; + +public class PasswordDialogView extends javax.swing.JFrame +{ + + private static final String NAME_OF_PAGE = "Admin Password"; + private static MainView home = new MainView(); + public static boolean adminLoginStatus; + + public PasswordDialogView() + { + initComponents(); + //passwordError.setVisible(false); + Password.addKeyListener(new KeyAdapter() + { + public void keyTyped(KeyEvent capsLockCheck) + { + if(capsLockDetector()) + { + passwordError.setText("WARNING: Caps Lock is on"); + } + else + { + passwordError.setText(""); + } + } + }); + addWindowListener(new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent e) + { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + dispose(); + home.setPrintersVisible(false); + home.showStudentOptions(); + home.setVisible(true); + } + }); + } + + /** + * 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() { + + jLabel1 = new javax.swing.JLabel(); + CancelButton = new javax.swing.JButton(); + SubmitButton = new javax.swing.JButton(); + Password = new javax.swing.JPasswordField(); + passwordError = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle(UtilController.getPageName(NAME_OF_PAGE)); + getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); + + jLabel1.setText("Administrator Password:"); + getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(50, 20, -1, -1)); + + CancelButton.setText("Cancel"); + CancelButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CancelButtonActionPerformed(evt); + } + }); + getContentPane().add(CancelButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 70, -1, 20)); + + SubmitButton.setText("Submit"); + SubmitButton.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + SubmitButtonMouseClicked(evt); + } + }); + getContentPane().add(SubmitButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(110, 70, -1, 20)); + getContentPane().add(Password, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 136, -1)); + + //Login with ENTER button + Password.addKeyListener(new KeyAdapter() + { + public void keyTyped(KeyEvent e) + { + char c = e.getKeyChar(); + if(c == KeyEvent.VK_ENTER) + { + + attemptAdminLogin(); + } + } + }); + + passwordError.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N + passwordError.setForeground(new java.awt.Color(255, 0, 0)); + passwordError.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + getContentPane().add(passwordError, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 200, 20)); + + jLabel2.setHorizontalAlignment(javax.swing.SwingConstants.CENTER); + jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N + getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 220, 130)); + + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void CancelButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_CancelButtonActionPerformed + {//GEN-HEADEREND:event_CancelButtonActionPerformed + dispose(); + home.setPrintersVisible(false); + home.showStudentOptions(); + home.setVisible(true); + }//GEN-LAST:event_CancelButtonActionPerformed + + private void attemptAdminLogin() + { + boolean wasLoginSuccessful = UtilController.checkAdminLogin(new String(Password.getPassword())); + + if (wasLoginSuccessful) + { + System.out.println("Password passed!"); + adminLoginStatus = true; + dispose(); + home.resetAdminMode(); + } else + { + passwordError.setText("ERROR: Invalid password"); + adminLoginStatus = false; + } + } + + private void SubmitButtonMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_SubmitButtonMouseClicked + /*Hashes the predefined password and the password entered into the + *JPasswordField and then compares the two + */ + boolean wasLoginSuccessful = UtilController.checkAdminLogin(new String(Password.getPassword())); + + if (wasLoginSuccessful) + { + System.out.println("Password passed!"); + adminLoginStatus = true; + dispose(); + home.resetAdminMode(); + } else + { + passwordError.setText("ERROR: Invalid password"); + adminLoginStatus = false; + } + }//GEN-LAST:event_SubmitButtonMouseClicked + + private boolean capsLockDetector() + { + //Detects if Caps Lock is on. If it is it returns a warning + if(Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK)) + { + return true; + } + return false; + } + + /** + * @param args the command line arguments + */ + /* + Eventually update passwordText array to take a constant for its size + */ + 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(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) + { + java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) + { + java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) + { + java.util.logging.Logger.getLogger(PasswordDialogView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() + { + public void run() + { + new PasswordDialogView().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton CancelButton; + private javax.swing.JPasswordField Password; + private javax.swing.JButton SubmitButton; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel passwordError; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveBuildView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveBuildView.java index 62d8c57..1b1307b 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveBuildView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveBuildView.java @@ -8,6 +8,7 @@ public class RemoveBuildView extends javax.swing.JFrame { private static final String NAME_OF_PAGE = "Removes Build"; + private static final BuildView buildView = new BuildView(); //contruct a build view to return from the RemoveBuildView public static final String [] buildList = UtilController.listOfBuilds(); @@ -23,6 +24,7 @@ public RemoveBuildView() public void windowClosing(WindowEvent we) { dispose(); + buildView.startMakeBuildProcess(); } } ); @@ -52,7 +54,7 @@ private void initComponents() { jMenu1 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); - setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + //setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle(UtilController.getPageName(NAME_OF_PAGE)); setBackground(new java.awt.Color(255, 255, 255)); setMaximumSize(new java.awt.Dimension(236, 244)); @@ -64,8 +66,14 @@ private void initComponents() { jLabel2.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N jLabel2.setText("Remove Build"); + backButton.setFocusPainted(false); backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N backButton.setContentAreaFilled(false); + backButton.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + backButtonActionPerformed(evt); + } + }); jLabel1.setText("Select Build:"); @@ -146,6 +154,12 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { pack(); }// </editor-fold>//GEN-END:initComponents + + private void backButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_backButtonActionPerformed + {//GEN-HEADEREND:event_backButtonActionPerformed + dispose(); + buildView.startMakeBuildProcess(); + }//GEN-LAST:event_backButtonActionPerformed private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jMenuItem1ActionPerformed {//GEN-HEADEREND:event_jMenuItem1ActionPerformed diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveClassPrinterView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveClassPrinterView.java index 34e80ed..408bc85 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveClassPrinterView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/RemoveClassPrinterView.java @@ -8,7 +8,7 @@ public class RemoveClassPrinterView extends javax.swing.JFrame { public RemoveClassPrinterView() { } - private static final String NAME_OF_PAGE = "Remove Class/Printer"; + private static final String NAME_OF_PAGE = "Remove Class/Device"; private static SQLMethods sql = new SQLMethods(); AdminSettingsView settings; public void removeClassPrinterStart() { @@ -73,7 +73,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { getContentPane().add(classComboBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 70, 200, -1)); titleLabel.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N - titleLabel.setText("Remove Class/Printer"); + titleLabel.setText("Remove Class/Device"); getContentPane().add(titleLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(90, 20, 290, 20)); getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 50, 390, 10)); @@ -82,7 +82,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { getContentPane().add(classLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 70, 50, -1)); printerLabel.setFont(new java.awt.Font("Segoe UI", 0, 12)); // NOI18N - printerLabel.setText("Printer:"); + printerLabel.setText("Device:"); getContentPane().add(printerLabel, new org.netbeans.lib.awtextra.AbsoluteConstraints(20, 110, 50, -1)); printerComboBox.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.form index 3c2178d..eba9c95 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.form +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.form @@ -27,7 +27,22 @@ <Property name="title" type="java.lang.String" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> <Connection code="UtilController.getPageName(NAME_OF_PAGE)" type="code"/> </Property> + <Property name="background" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor"> + <Color blue="ff" green="ff" red="ff" type="rgb"/> + </Property> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 520]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 520]"/> + </Property> + <Property name="size" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[750, 520]"/> + </Property> </Properties> + <AccessibilityProperties> + <Property name="AccessibleContext.accessibleDescription" type="java.lang.String" value=""/> + </AccessibilityProperties> <SyntheticProperties> <SyntheticProperty name="menuBar" type="java.lang.String" value="jMenuBar1"/> <SyntheticProperty name="formSizePolicy" type="int" value="1"/> @@ -43,31 +58,69 @@ <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> - <AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,-85,0,0,2,-20"/> </AuxValues> - <Layout class="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout"> - <Property name="useNullLayout" type="boolean" value="false"/> + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="310" pref="310" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace pref="34" max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jComboBox1" min="-2" pref="80" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Group type="102" attributes="0"> + <Component id="exportBtn" min="-2" pref="140" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + <Component id="ExportMasterReportButton" min="-2" pref="130" max="-2" attributes="0"/> + </Group> + <Component id="jScrollPane1" pref="682" max="32767" attributes="0"/> + </Group> + <Component id="jLabel1" alignment="0" min="-2" max="-2" attributes="0"/> + <Component id="jSeparator1" alignment="0" min="-2" pref="682" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace pref="34" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="20" pref="20" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="6" max="-2" attributes="0"/> + <Component id="jSeparator1" min="-2" pref="10" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="unrelated" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboBox1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" pref="20" max="-2" attributes="0"/> + </Group> + <EmptySpace min="9" pref="9" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="210" max="-2" attributes="0"/> + <EmptySpace min="30" pref="30" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="exportBtn" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="ExportMasterReportButton" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="74" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> </Layout> <SubComponents> - <Component class="javax.swing.JComboBox" name="searchFilter"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> - <Connection code="new javax.swing.DefaultComboBoxModel(headers)" type="code"/> - </Property> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchFilterActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="70" y="120" width="90" height="-1"/> - </Constraint> - </Constraints> - </Component> <Component class="javax.swing.JLabel" name="jLabel1"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> @@ -75,80 +128,19 @@ </Property> <Property name="text" type="java.lang.String" value="Object Lab Search"/> </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="70" width="-1" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel2"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="Search For:"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="120" width="60" height="21"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JTextField" name="searchKey"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="211" y="120" width="430" height="-1"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="searchBtn"> - <Properties> - <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> - <Font name="Segoe UI" size="11" style="0"/> - </Property> - <Property name="text" type="java.lang.String" value="Search"/> - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> - <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> - <EmptyBorder/> - </Border> - </Property> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="searchBtnActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="647" y="120" width="50" height="20"/> - </Constraint> - </Constraints> </Component> <Component class="javax.swing.JSeparator" name="jSeparator1"> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="60" width="682" height="10"/> - </Constraint> - </Constraints> </Component> <Component class="javax.swing.JButton" name="ExportMasterReportButton"> <Properties> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Segoe UI" size="11" style="0"/> </Property> - <Property name="text" type="java.lang.String" value="Export Master Report"/> + <Property name="text" type="java.lang.String" value="All Devices Report"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="ExportMasterReportButtonActionPerformed"/> </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="560" y="380" width="-1" height="-1"/> - </Constraint> - </Constraints> </Component> <Component class="javax.swing.JLabel" name="jLabel3"> <Properties> @@ -157,11 +149,6 @@ </Property> <Property name="text" type="java.lang.String" value="Reports"/> </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="310" y="20" width="-1" height="-1"/> - </Constraint> - </Constraints> </Component> <Component class="javax.swing.JComboBox" name="jComboBox1"> <Properties> @@ -176,21 +163,11 @@ <Events> <EventHandler event="itemStateChanged" listener="java.awt.event.ItemListener" parameters="java.awt.event.ItemEvent" handler="jComboBox1ItemStateChanged"/> </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="80" y="90" width="80" height="-1"/> - </Constraint> - </Constraints> </Component> <Container class="javax.swing.JScrollPane" name="jScrollPane1"> <AuxValues> <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="170" width="682" height="203"/> - </Constraint> - </Constraints> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> @@ -264,47 +241,25 @@ <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Font name="Segoe UI" size="11" style="0"/> </Property> - <Property name="text" type="java.lang.String" value="Export Current Report"/> + <Property name="text" type="java.lang.String" value="Current Device Report"/> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> <EmptyBorder/> </Border> </Property> - </Properties> - <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportBtnActionPerformed"/> - </Events> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="380" width="140" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JButton" name="closeBtn"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"/> + <Property name="maximumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[141, 23]"/> </Property> - <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> - <Border info="org.netbeans.modules.form.compat2.border.EmptyBorderInfo"> - <EmptyBorder/> - </Border> + <Property name="minimumSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[141, 23]"/> + </Property> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[141, 23]"/> </Property> - <Property name="borderPainted" type="boolean" value="false"/> - <Property name="contentAreaFilled" type="boolean" value="false"/> - <Property name="focusPainted" type="boolean" value="false"/> </Properties> <Events> - <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="closeBtnActionPerformed"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="exportBtnActionPerformed"/> </Events> - <AuxValues> - <AuxValue name="JavaCodeGenerator_VariableModifier" type="java.lang.Integer" value="10"/> - </AuxValues> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="10" width="50" height="40"/> - </Constraint> - </Constraints> </Component> <Component class="javax.swing.JLabel" name="jLabel4"> <Properties> @@ -313,24 +268,6 @@ </Property> <Property name="text" type="java.lang.String" value="Device Name:"/> </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="10" y="90" width="-1" height="20"/> - </Constraint> - </Constraints> - </Component> - <Component class="javax.swing.JLabel" name="jLabel5"> - <Properties> - <Property name="icon" type="javax.swing.Icon" editor="org.netbeans.modules.form.editors2.IconEditor"> - <Image iconType="3" name="/ObjectLabEnterpriseSoftware/images/white_bg.jpg"/> - </Property> - <Property name="text" type="java.lang.String" value="jLabel5"/> - </Properties> - <Constraints> - <Constraint layoutClass="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout" value="org.netbeans.modules.form.compat2.layouts.DesignAbsoluteLayout$AbsoluteConstraintsDescription"> - <AbsoluteConstraints x="-2" y="-18" width="710" height="430"/> - </Constraint> - </Constraints> </Component> </SubComponents> </Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.java index d601282..3a5bd7f 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/ReportsView.java @@ -1,8 +1,14 @@ package ObjectLabEnterpriseSoftware; +import java.awt.Color; +import java.awt.Dimension; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import java.util.ArrayList; + +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; import javax.swing.table.DefaultTableModel; public class ReportsView extends javax.swing.JFrame @@ -14,17 +20,26 @@ public class ReportsView extends javax.swing.JFrame private FileManager inst; private String selectedPrinter; private UtilController controller; - private String[] headers; + private String[] headers = {"Job ID", "File Name", "First Name", "Last Name", "Date", "Printer", "Class", "Section", "Stat1", "Stat2"}; private ArrayList<String> printers; - + // --nav bar views ~Alex + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private BalanceView balanceView; + private newSettingsMenu adminSettingsView; + // public ReportsView() { this.controller = new UtilController(); - printers = UtilController.getListOfAllDevices(); + printers = UtilController.getListOfCurrentDevices(); if(printers.size() > 0){ - selectedPrinter = printers.get(0); - headers = UtilController.getReportColumnHeaders(selectedPrinter); + selectedPrinter = printers.get(1); + //* THIS IS THE PROBLEM WITH THE REPORTS NOT OPENING, THIS FEEDS THEM THE WRONG HEADERS NOW - used to be sql error. *\\\ + + //headers = UtilController.getReportColumnHeaders(selectedPrinter); + } else{ headers = new String[1]; @@ -37,16 +52,23 @@ public ReportsView() public void windowClosing(WindowEvent we) { /* If they close the program then close out the window properly */ + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); dispose(); - home.resetAdminMode(); + //home.resetAdminMode(); } } ); + + // *** + // This line is necessary for debugging with WindowsBuilder + //ReportsPage(); } public void ReportsPage() { + getContentPane().setBackground(Color.WHITE); initComponents(); + initNavBar(); model = (DefaultTableModel) reportsTable.getModel(); if(selectedPrinter != null){ for (ArrayList<Object> retval1 : UtilController.updateReportTableData(selectedPrinter)){ @@ -66,11 +88,7 @@ public void ReportsPage() // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents private void initComponents() { - searchFilter = new javax.swing.JComboBox(); jLabel1 = new javax.swing.JLabel(); - jLabel2 = new javax.swing.JLabel(); - searchKey = new javax.swing.JTextField(); - searchBtn = new javax.swing.JButton(); jSeparator1 = new javax.swing.JSeparator(); ExportMasterReportButton = new javax.swing.JButton(); jLabel3 = new javax.swing.JLabel(); @@ -78,60 +96,31 @@ private void initComponents() { jScrollPane1 = new javax.swing.JScrollPane(); reportsTable = new javax.swing.JTable(); exportBtn = new javax.swing.JButton(); - closeBtn = new javax.swing.JButton(); jLabel4 = new javax.swing.JLabel(); - jLabel5 = new javax.swing.JLabel(); jMenuBar1 = new javax.swing.JMenuBar(); jMenu2 = new javax.swing.JMenu(); jMenuItem1 = new javax.swing.JMenuItem(); setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE); setTitle(UtilController.getPageName(NAME_OF_PAGE)); - getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); - - searchFilter.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - searchFilter.setModel(new javax.swing.DefaultComboBoxModel(headers)); - searchFilter.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - searchFilterActionPerformed(evt); - } - }); - getContentPane().add(searchFilter, new org.netbeans.lib.awtextra.AbsoluteConstraints(70, 120, 90, -1)); + setBackground(new java.awt.Color(255, 255, 255)); + setMinimumSize(new java.awt.Dimension(750, 520)); + setPreferredSize(new java.awt.Dimension(750, 520)); + setSize(new java.awt.Dimension(750, 520)); jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 12)); // NOI18N jLabel1.setText("Object Lab Search"); - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 70, -1, -1)); - - jLabel2.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - jLabel2.setText("Search For:"); - getContentPane().add(jLabel2, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 60, 21)); - - searchKey.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - getContentPane().add(searchKey, new org.netbeans.lib.awtextra.AbsoluteConstraints(211, 120, 430, -1)); - - searchBtn.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - searchBtn.setText("Search"); - searchBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); - searchBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - searchBtnActionPerformed(evt); - } - }); - getContentPane().add(searchBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(647, 120, 50, 20)); - getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 60, 682, 10)); ExportMasterReportButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - ExportMasterReportButton.setText("Export Master Report"); + ExportMasterReportButton.setText("All Devices Report"); ExportMasterReportButton.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { ExportMasterReportButtonActionPerformed(evt); } }); - getContentPane().add(ExportMasterReportButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(560, 380, -1, -1)); jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N jLabel3.setText("Reports"); - getContentPane().add(jLabel3, new org.netbeans.lib.awtextra.AbsoluteConstraints(310, 20, -1, -1)); jComboBox1.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(printers.toArray())); @@ -141,7 +130,6 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) { jComboBox1ItemStateChanged(evt); } }); - getContentPane().add(jComboBox1, new org.netbeans.lib.awtextra.AbsoluteConstraints(80, 90, 80, -1)); reportsTable.setAutoCreateRowSorter(true); reportsTable.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N @@ -152,37 +140,20 @@ public void itemStateChanged(java.awt.event.ItemEvent evt) { ); jScrollPane1.setViewportView(reportsTable); - getContentPane().add(jScrollPane1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 170, 682, 203)); - exportBtn.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - exportBtn.setText("Export Current Report"); + exportBtn.setText("Current Device Report"); exportBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); + exportBtn.setMaximumSize(new java.awt.Dimension(141, 23)); + exportBtn.setMinimumSize(new java.awt.Dimension(141, 23)); + exportBtn.setPreferredSize(new java.awt.Dimension(141, 23)); exportBtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { exportBtnActionPerformed(evt); } }); - getContentPane().add(exportBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 380, 140, 20)); - - closeBtn.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N - closeBtn.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); - closeBtn.setBorderPainted(false); - closeBtn.setContentAreaFilled(false); - closeBtn.setFocusPainted(false); - closeBtn.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - closeBtnActionPerformed(evt); - } - }); - getContentPane().add(closeBtn, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 10, 50, 40)); jLabel4.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jLabel4.setText("Device Name:"); - getContentPane().add(jLabel4, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, -1, 20)); - - jLabel5.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N - jLabel5.setText("jLabel5"); - getContentPane().add(jLabel5, new org.netbeans.lib.awtextra.AbsoluteConstraints(-2, -18, 710, 430)); jMenu2.setText("Help"); @@ -198,36 +169,58 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { setJMenuBar(jMenuBar1); - pack(); - }// </editor-fold>//GEN-END:initComponents - - private void closeBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeBtnActionPerformed - - dispose(); - home.resetAdminMode(); - }//GEN-LAST:event_closeBtnActionPerformed - - private void searchBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchBtnActionPerformed - - /* All of the data that is being displayed and exported is found in the completedjobs table and retrieved here - depending on what filter is triggered - */ - //System.out.println(searchFilter.getSelectedItem().toString()); - //System.out.println(searchKey.getText().trim().length() > 0); - if(searchKey.getText().trim().length() > 0){ - while (model.getRowCount() > 0) { - model.removeRow(0); - } - - model = (DefaultTableModel) reportsTable.getModel(); - System.out.println(searchFilter.getSelectedItem().toString()); - for (ArrayList<Object> retval1 : UtilController.updateReportTableData(searchFilter.getSelectedItem().toString(), searchKey.getText().trim(), selectedPrinter)){ - model.addRow(retval1.toArray()); - } + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(310, 310, 310) + .addComponent(jLabel3)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(34, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel4) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 80, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addGroup(layout.createSequentialGroup() + .addComponent(exportBtn, javax.swing.GroupLayout.PREFERRED_SIZE, 140, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(ExportMasterReportButton, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 682, Short.MAX_VALUE)) + .addComponent(jLabel1) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 682, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(34, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(20, 20, 20) + .addComponent(jLabel3) + .addGap(6, 6, 6) + .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, 10, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(9, 9, 9) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 210, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(30, 30, 30) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(exportBtn, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(ExportMasterReportButton)) + .addContainerGap(74, Short.MAX_VALUE)) + ); - } + getAccessibleContext().setAccessibleDescription(""); - }//GEN-LAST:event_searchBtnActionPerformed + pack(); + }// </editor-fold>//GEN-END:initComponents private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_exportBtnActionPerformed @@ -236,21 +229,13 @@ private void exportBtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIR }//GEN-LAST:event_exportBtnActionPerformed - private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed - UtilController.openAdminHelpPage(); - }//GEN-LAST:event_jMenuItem1ActionPerformed - - private void searchFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_searchFilterActionPerformed - // TODO add your handling code here: - }//GEN-LAST:event_searchFilterActionPerformed - private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIRST:event_jComboBox1ItemStateChanged //System.out.println(evt.getItem().toString()); selectedPrinter = evt.getItem().toString(); //System.out.println(report); - headers = UtilController.getReportColumnHeaders(selectedPrinter); + //headers = UtilController.getReportColumnHeaders(selectedPrinter); while (model.getRowCount() > 0) { model.removeRow(0); } @@ -258,38 +243,162 @@ private void jComboBox1ItemStateChanged(java.awt.event.ItemEvent evt) {//GEN-FIR new Object[][]{}, headers)); model = (DefaultTableModel) reportsTable.getModel(); - searchFilter.setModel(new javax.swing.DefaultComboBoxModel(headers)); + for (ArrayList<Object> retval1 : UtilController.updateReportTableData(selectedPrinter)){ model.addRow(retval1.toArray()); } }//GEN-LAST:event_jComboBox1ItemStateChanged + private void initNavBar() + { + + jMenuBar1.setPreferredSize(new Dimension(275, 30)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(Box.createRigidArea(new Dimension(50,0))); + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + + navBtn_build.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_reports); + + navBtn_balance = new JButton("Balance"); + navBtn_balance.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/stats_icon.png"))); + navBtn_balance.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_balance); + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_settings); + + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_balance.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_balanceActionPerformed(evt); + } + }); + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + } + + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_balanceActionPerformed(java.awt.event.ActionEvent evt) + { + balanceView= new BalanceView(); + balanceView.setVisible(true); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new newSettingsMenu(); + adminSettingsView.setVisible(true); + dispose(); + + } + + private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_logoutButtonActionPerformed + //GEN-HEADEREND:event_logoutButtonActionPerformed + dispose(); + home.setVisible(true); + }//GEN-LAST:event_logoutButtonActionPerformed + + + + /////// Nav Bar ~Alex ///// + private void ExportMasterReportButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportMasterReportButtonActionPerformed UtilController.exportReportsForPrinters(); }//GEN-LAST:event_ExportMasterReportButtonActionPerformed + private void jMenuItem1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jMenuItem1ActionPerformed + UtilController.openAdminHelpPage(); + }//GEN-LAST:event_jMenuItem1ActionPerformed + /////// Nav Bar ~Alex ///// + // --nav bar vars ~Alex + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_balance; + private JButton navBtn_settings; + // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton ExportMasterReportButton; - private static javax.swing.JButton closeBtn; private javax.swing.JButton exportBtn; private javax.swing.JComboBox jComboBox1; private javax.swing.JLabel jLabel1; - private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel4; - private javax.swing.JLabel jLabel5; private javax.swing.JMenu jMenu2; private javax.swing.JMenuBar jMenuBar1; private javax.swing.JMenuItem jMenuItem1; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JSeparator jSeparator1; private javax.swing.JTable reportsTable; - private javax.swing.JButton searchBtn; - private javax.swing.JComboBox searchFilter; - private javax.swing.JTextField searchKey; // End of variables declaration//GEN-END:variables } diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/SQLMethods.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/SQLMethods.java index e752cc9..b971281 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/SQLMethods.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/SQLMethods.java @@ -29,12 +29,11 @@ public class SQLMethods private Connection conn; private ResultSet res; private PreparedStatement stmt; - public SQLMethods() { /* To resolve hostname to an IP adr */ - //File f = new File("C:\\Sync\\computername.txt"); - File f = new File("/home/alex/Documents/School/Spring 2016/Software eng/Object-Lab-Interface/Object-Lab-Interface/computername.txt"); + File f = new File(MainView.getStorageDir() + ":\\Sync\\computername.txt"); + //File f = new File("/home/alex/Documents/School/Spring 2016/Software eng/Object-Lab-Interface/computername.txt"); String line, ip = ""; try @@ -56,8 +55,35 @@ public SQLMethods() System.out.println("Couldn't read file! IOException!"); ex.printStackTrace(); } - url = "jdbc:mysql://" + ip + ":3306/"; - connectToDatabase("com.mysql.jdbc.Driver", url + "jobsDB", "root", "password"); + + /////////////////////////////////// + ///ip = "mysql1110.ixwebhosting.com"; //////// + /////////////////////////////////// + //url = "jdbc:mysql://" + ip + ":3306/"; + //connectToDatabase("com.mysql.jdbc.Driver", url + "AAAlvxm_oli", "AAAlvxm_oliAdmin", "Password1"); + + //For online database + + String host = "db4free.net"; + String port = "3306"; + String user = "oliadminuser"; + String pass = "olipass"; + String db = "olidatabase"; + String driver = "com.mysql.jdbc.Driver"; + + + //Russell's local database + /* + String host = "127.0.0.1"; + String port = "3306"; + String user = "root"; + String pass = "password"; + String db = "localoli"; + String driver = "com.mysql.jdbc.Driver"; + */ + + url = "jdbc:mysql://" + host + ":" + port + "/" + db; + connectToDatabase(driver, url, user, pass); } private void connectToDatabase(String driver, String urlDatabaseName, String userName, String pw) @@ -148,15 +174,123 @@ public ResultSet searchPrinterFilesTypes(String printer) } public ResultSet searchJobsStatusPrinter(String status, String printer) // returns filename,first name,lastname ,submission_date, printer for based off status and printer + { + res = null; + try + { + + stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + + "job.submission_date ,job.printer_name, class_name, class_section, material.z_corp_plaster, material.objet_build, material.objet_support " + + "FROM job INNER JOIN users ON users.towson_id = job.student_id " + + "INNER JOIN class ON job.class_id = class.class_id INNER JOIN material ON material.id = job.student_id WHERE job.status = ? AND " + + "printer_name = ?;"); + + stmt.setString(1, status); + stmt.setString(2, printer); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + public ResultSet searchStudentBalanceFName(String first_name) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name, towson_id, z_corp_plaster, objet_build, objet_support " + + "FROM users INNER JOIN material ON users.towson_id = material.id " + + "WHERE users.first_name = ?;"); + stmt.setString(1, first_name); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchStudentBalanceLName(String last_name) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name, towson_id, z_corp_plaster, objet_build, objet_support " + + "FROM users INNER JOIN material ON users.towson_id = material.id " + + "WHERE users.last_name = ?;"); + stmt.setString(1, last_name); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchStudentBalanceId(String id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name, towson_id, z_corp_plaster, objet_build, objet_support " + + "FROM users INNER JOIN material ON users.towson_id = material.id " + + "WHERE towson_id = ?;"); + stmt.setString(1, id); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchStudentBalanceAll(String value) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name, towson_id, z_corp_plaster, objet_build, objet_support " + + "FROM users INNER JOIN material ON users.towson_id = material.id " + + "WHERE towson_id = ? or users.last_name = ? or users.first_name = ?;"); + stmt.setString(1, value); + stmt.setString(2, value); + stmt.setString(3, value); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchStudentBalance() + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name, towson_id, z_corp_plaster, objet_build, objet_support " + + "FROM users INNER JOIN material ON users.towson_id = material.id;"); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + /* + public ResultSet searchAllJobsStatusPrinter(String printer) // returns filename,first name,lastname ,submission_date, printer for based off status and printer { res = null; try { stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + "job.submission_date ,job.printer_name, class_name, class_section " - + "FROM job, users , class " + "WHERE job.status = ? AND printer_name = ? " + + "FROM job, users , class " + "WHERE job.status <> ? AND printer_name = ? " + "AND users.towson_id = job.student_id AND job.class_id = class.class_id;"); - stmt.setString(1, status); + stmt.setString(1, "rejected"); stmt.setString(2, printer); res = stmt.executeQuery(); } catch (Exception e) @@ -166,6 +300,180 @@ public ResultSet searchJobsStatusPrinter(String status, String printer) // retur return res; } + */ + + public ResultSet searchStudentTransactionHistory(String id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT date(date), material, amount " + + "FROM material_transaction_history " + + "WHERE net_id = ?" + + "ORDER BY date DESC;"); + stmt.setString(1, id); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getStudentFileStatus(String studentId) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT file_name, date(submission_date), comment, status " + + "FROM job INNER JOIN job_stats ON job.job_id = job_stats.job_id " + + "WHERE ? = job.student_id " + + "ORDER BY submission_date DESC;"); + stmt.setString(1, studentId); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getStudentInfo(String studentId) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT id, z_corp_plaster, objet_build, objet_support " + + "FROM material WHERE ? = material.id"); + stmt.setString(1, studentId); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getStudentName(String studentId) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT first_name, last_name " + + "FROM users WHERE ? = towson_id"); + stmt.setString(1, studentId); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public double getCurrentMaterialBalance(String studentId, String whichMaterial) + { + double current = 0; + try + { + ResultSet queryResult; + stmt = this.conn.prepareStatement("SELECT " + whichMaterial + " FROM `material` WHERE id = ?;"); + stmt.setString(1, studentId); + queryResult = stmt.executeQuery(); + while(queryResult.next()) + { + current = queryResult.getDouble(whichMaterial); + } + } catch (SQLException e) + { + System.err.println(e); + } + return current; + + } + + public String getFilePrinter(String fileName, String id) + { + String printer = ""; + try + { + ResultSet queryResult; + stmt = this.conn.prepareStatement("SELECT printer_name FROM job WHERE job.file_name = ? AND job.student_id = ?;"); + stmt.setString(1, fileName); + stmt.setString(2, id); + queryResult = stmt.executeQuery(); + while(queryResult.next()) + { + printer = queryResult.getString("printer_name"); + } + } catch (SQLException e) + { + System.err.println(e); + } + return printer; + + } + + public String getStudentId(String first_name, String last_name) + { + + String id = ""; + try + { + ResultSet queryResult; + stmt = this.conn.prepareStatement("SELECT towson_id FROM users WHERE users.first_name = ? AND users.last_name = ?;"); + stmt.setString(1, first_name); + stmt.setString(2, last_name); + queryResult = stmt.executeQuery(); + while(queryResult.next()) + { + id = queryResult.getString("towson_id"); + } + } catch (SQLException e) + { + System.err.println(e); + } + return id; + + } + + public void addMaterial(String studentId, double amount, String whichMaterial) + { + try + { + SQLMethods dbconn = new SQLMethods(); + + double current; + current = dbconn.getCurrentMaterialBalance(studentId, whichMaterial); + amount = amount + current; + + stmt = this.conn.prepareStatement("UPDATE material SET "+ whichMaterial+" = " + amount + " WHERE id = ?;"); + stmt.setString(1, studentId); + stmt.executeUpdate(); + } + catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE,null, ex); + } + } + + public void addTransactionHistory(String studentID, String material, double amount) + { + try + { + SQLMethods dbconn = new SQLMethods(); + stmt = this.conn.prepareStatement("INSERT INTO material_transaction_history (date, net_id, material, amount) " + + "VALUES (NOW(), ?, ?, ?)"); + stmt.setString(1, studentID); + stmt.setString(2, material); + stmt.setDouble(3, amount); + stmt.execute(); + } + catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE,null, ex); + } + } + public ResultSet searchJobsStatus(String status) // returns filename,first name,lastname ,submission_date, printer for based off status and printer { @@ -186,6 +494,11 @@ public ResultSet searchJobsStatus(String status) // returns filename,first name, return res; } + + + + + public ResultSet searchPrintersByBuildName(int buildId) { @@ -397,9 +710,10 @@ public ResultSet selectAcceptedFiles(String printer) res = null; try { - stmt = this.conn.prepareStatement("SELECT file_extension FROM accepted_files Where printer_name = " +printer +";"); - //stmt.setString(1, printer); + stmt = this.conn.prepareStatement("SELECT file_extension FROM accepted_files Where printer_name = ?;"); + stmt.setString(1, printer); res = stmt.executeQuery(); + } catch (SQLException e) { System.err.println("SQL Execution Error."); @@ -488,26 +802,66 @@ public void insertIntoJob(String filename, String filePath, int class_id, String { try { - stmt = conn.prepareStatement("INSERT INTO job (file_name, file_path, class_id, student_id, printer_name, submission_date," + " build_Name, status, comment) values (?,?,?,?,?,NOW(),null,'pending',null);"); + System.out.print("Trying to insert into db...~Alex debug"); + stmt = conn.prepareStatement("INSERT INTO job (file_name, file_path, class_id, student_id, printer_name, submission_date, build_Name, status, comment) values (?,?,?,?,?,NOW(),null,'pending',null);"); stmt.setString(1, filename); stmt.setString(2, filePath); stmt.setInt(3, class_id); stmt.setString(4, user_id); stmt.setString(5, printer); stmt.executeUpdate(); + + + + // Adding stat tracking + + + stmt = conn.prepareStatement + ( + "SELECT job_id FROM job WHERE student_id = ? AND file_name = ?" + ); + + stmt.setString(1, user_id); + stmt.setString(2, filename); + + System.out.println(stmt.toString()); + ResultSet res = stmt.executeQuery(); + res.next(); + insertIntoJobStats(res.getInt(1), null, null); + + } catch (Exception e) { e.printStackTrace(); } } + + + public void insertIntoJobStats(int id, String stat1, String stat2) + { + try { + stmt = conn.prepareStatement("INSERT INTO job_stats (job_id, stat1, stat2) values (?,NULL,NULL);"); + stmt.setInt(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + + + + public void insertIntoPrinter(String printer, boolean submit) { try { - stmt = conn.prepareStatement("INSERT INTO printer (printer_name, student_submission) values (?, ?);"); + stmt = conn.prepareStatement("INSERT INTO printer (printer_name, student_submission, current) values (?, ?, ?);"); stmt.setString(1, printer); stmt.setBoolean(2, submit); + stmt.setInt(3, 1); stmt.executeUpdate(); } catch (Exception e) { @@ -560,6 +914,27 @@ public int insertIntoUsers(String idusers, String firstName, String lastName, St return -1; } + public void insertIntoMaterial(String id) + { + try + { + stmt = conn.prepareStatement + ( + "INSERT INTO material(id, z_corp_plaster, objet_build, objet_support) " + + "values (?,?,?,?) " + ); + + stmt.setString(1, id); + stmt.setDouble(2, 0); + stmt.setDouble(3, 0); + stmt.setDouble(4, 0); + stmt.execute(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + public void insertIntoAdmin(String user_id, String userName, String pass) { try @@ -574,7 +949,9 @@ public void insertIntoAdmin(String user_id, String userName, String pass) e.printStackTrace(); } } - + //Rajewski + //No longer called with these params in UtilController + /* public void insertIntoBuild(String buildname, int runtime, int models, String printer) { try @@ -594,7 +971,27 @@ public void insertIntoBuild(String buildname, int runtime, int models, String pr e.printStackTrace(); } } - + */ + + public void insertIntoBuild(String buildname, int models, String printer) + { + try + { + stmt = conn.prepareStatement("INSERT INTO printer_build " + + "(build_name, date_created, total_runtime_seconds, number_of_models, printer_name) " + + "VALUES (?, NOW(), 0, ?, ?);"); + + stmt.setString(1, buildname); + stmt.setInt(2, models); + stmt.setString(3, printer); + + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + public void insertIntoColumnBuildData(String printer, String columnName, String data, String buildLocation) { try @@ -687,6 +1084,21 @@ public void updateJobVolume(int id, double volume) null, ex); } } + + + public void updateStats(int id, String stat1, String stat2) + { + try { + stmt = this.conn.prepareStatement("UPDATE `job_stats` SET `stat1`=?,`stat2`=? WHERE `job_id`=?"); + stmt.setString(1, stat1); + stmt.setString(2, stat2); + stmt.setInt(3, id); + stmt.executeUpdate(); + } catch(SQLException ex) { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, + null, ex); + } + } public void updateJobBuildName(String build, int jobid)//SEAN USE THIS/ { @@ -778,6 +1190,40 @@ public void updateEmail(String newEmail, String id) } } + public String getFileComment(String file) + { + String comment = ""; + try + { + stmt = conn.prepareStatement("SELECT comment FROM job WHERE file_name = ?; "); + stmt.setString(1 , file); + res = stmt.executeQuery(); + while(res.next()) + { + comment = res.getString("comment"); + } + } catch (Exception e) + { + e.printStackTrace(); + } + return comment; + } + + public void updateFileComment(String file, String comment) + { + res = null; + try + { + stmt = conn.prepareStatement("UPDATE job SET comment = ? WHERE file_name = ?; "); + stmt.setString(1, comment); + stmt.setString(2, file); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + public void updateColumnFieldName(String updatedName, int id) { res = null; @@ -1040,13 +1486,34 @@ public void deleteColumnData(String buildName, int columnId) // _____________________________________________________________________________________________________________________ public ResultSet getReport(String printer_name) { - res = null; + res = null; try { - stmt = this.conn.prepareStatement( + /* stmt = this.conn.prepareStatement( "call report('" + printer_name + "');" - ); - + );*/ + // temp fix to get reports view working + //stmt = this.conn.prepareStatement( + // "SELECT * FROM custom_printer_column_names WHERE printer_name = ?;" + //); + //stmt.setString(1, printer_name); + /* + stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + + "job.submission_date ,job.printer_name, class_name, class_section, job.volume " + + "FROM job INNER JOIN users ON users.towson_id = job.student_id " + + "INNER JOIN class ON job.class_id = class.class_id WHERE job.status = ? AND " + + "printer_name = ?;"); + */ + stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + + "date(job.submission_date) ,job.printer_name, class_name, class_section, job_stats.stat1, job_stats.stat2 " + + "FROM job INNER JOIN job_stats ON job.job_id = job_stats.job_id " + + "INNER JOIN users ON users.towson_id = job.student_id " + + "INNER JOIN class ON job.class_id = class.class_id WHERE job.status = 'completed' AND " + + "printer_name = ?;"); + + stmt.setString(1, printer_name); + //stmt.setString(1, "completed"); + res = stmt.executeQuery(); } catch (Exception e) { @@ -1497,6 +1964,28 @@ public ResultSet getBuilds() } return res; } + + //Rajewski + //function to populate new table on build view + public ResultSet getBuildsForRecordsTable(String currentDevice) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT build_name, date_created, number_of_models " + + "FROM printer_build WHERE printer_name = ?;"); + stmt.setString(1, currentDevice); + + + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } public ResultSet getClasses(boolean status) { @@ -1542,12 +2031,15 @@ public ResultSet getCurrentDevices() return getDeviceNamesCurrentOption(true); } - public ResultSet getDeviceNamesCurrentOption(boolean current) + public ResultSet getDeviceNamesCurrentOption(final boolean current) { res = null; + Thread runner = new Thread() { + public void run() + { try { - stmt = this.conn.prepareStatement( + stmt = conn.prepareStatement( "SELECT printer_name " + "FROM printer " + "WHERE current = ?;" @@ -1561,7 +2053,11 @@ public ResultSet getDeviceNamesCurrentOption(boolean current) { e.printStackTrace(); } - return res; + + } + }; + runner.run(); + return res; } public ResultSet getTrackedDevices() @@ -1608,4 +2104,9 @@ public ResultSet getCurrentTime() } return res; } + + public ResultSet findJobsforDevice(String selectedDevice) { + // TODO Auto-generated method stub + return null; + } } diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.form new file mode 100644 index 0000000..c8cdc00 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.form @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="119" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="184" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="21" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="5" rowCount="4"> + <Column editable="false" title="File Name" type="java.lang.Object"/> + <Column editable="false" title="Date " type="java.lang.Object"/> + <Column editable="false" title="Stat 1" type="java.lang.Object"/> + <Column editable="false" title="Stat 2" type="java.lang.Object"/> + <Column editable="false" title="Status" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Logout"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MousePressed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Files"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.java new file mode 100644 index 0000000..f65c75c --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentFileView.java @@ -0,0 +1,153 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; +import java.sql.ResultSet; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author Russell + */ +public class StudentFileView extends javax.swing.JFrame { + + private static DefaultTableModel model; + private static final String NAME_OF_PAGE = "Student File Status"; + private static final MainView home = new MainView(); + + public StudentFileView(String id, String studentName) { + getContentPane().setBackground(Color.WHITE); + initComponents(); + model = (DefaultTableModel) jTable1.getModel(); + updateFileWindow(id, studentName); + setVisible(true); + } + + public void updateFileWindow(String id, String studentName) { + model.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentFileStatus(id); + + while(queryResult.next()) + { + String file_name = queryResult.getString(1); + String date = queryResult.getString(2); + String stat1 = queryResult.getString(3); + String stat2 = queryResult.getString(4); + String status = queryResult.getString(5); + System.out.println("Adding row..."); + model.addRow(new Object[] {file_name, date, stat1, stat2, status}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + /** + * 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() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jButton1 = new javax.swing.JButton(); + jLabel1 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null} + }, + new String [] { + "File Name", "Date ", "Stat 1", "Stat 2", "Status" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.getTableHeader().setReorderingAllowed(false); + jScrollPane1.setViewportView(jTable1); + + jButton1.setText("Logout"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton1MousePressed(evt); + } + }); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel1.setText("Student Files"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton1) + .addGap(0, 0, Short.MAX_VALUE))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGap(119, 119, 119) + .addComponent(jLabel1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(18, 18, 18) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(21, 21, 21) + .addComponent(jButton1) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MousePressed + dispose(); + home.setVisible(true); + }//GEN-LAST:event_jButton1MousePressed + + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.form new file mode 100644 index 0000000..2dd9acd --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.form @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" pref="0" max="32767" attributes="0"/> + </Group> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="0" pref="315" max="32767" attributes="0"/> + </Group> + </Group> + <EmptySpace max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="108" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="81" max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="43" max="-2" attributes="0"/> + <EmptySpace pref="61" max="32767" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="1"> + <Column editable="false" title="Towson Id" type="java.lang.Object"/> + <Column editable="false" title="Material 1" type="java.lang.Object"/> + <Column editable="false" title="Material 2" type="java.lang.Object"/> + <Column editable="false" title="Material 3" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Balance"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Logout"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MousePressed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.java new file mode 100644 index 0000000..1f18467 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentInfoView.java @@ -0,0 +1,156 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; +import java.sql.ResultSet; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author Russell + */ +public class StudentInfoView extends javax.swing.JFrame { + + private static DefaultTableModel model; + private static final String NAME_OF_PAGE = "Student Submission"; + private static final MainView home = new MainView(); + private String userID; + private String userName; + private StudentFileView studentFileView; + + public StudentInfoView(String id, String studentName) { + userID = id; + userName = studentName; + getContentPane().setBackground(Color.WHITE); + initComponents(); + model = (DefaultTableModel) jTable1.getModel(); + updateInfoWindow(id, studentName); + setVisible(true); + } + + public void updateInfoWindow(String id, String studentName) { + model.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentInfo(id); + + while(queryResult.next()) + { + String towson_id = queryResult.getString(1); + String material1 = queryResult.getString(2); + String material2 = queryResult.getString(3); + String material3 = queryResult.getString(4); + System.out.println("Adding row..."); + model.addRow(new Object[] {towson_id, material1, material2, material3}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + /** + * 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() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null} + }, + new String [] { + "Towson Id", "Material 1", "Material 2", "Material 3" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.getTableHeader().setReorderingAllowed(false); + jScrollPane1.setViewportView(jTable1); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel1.setText("Student Balance"); + + jButton1.setText("Logout"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton1MousePressed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton1) + .addGap(0, 315, Short.MAX_VALUE))) + .addContainerGap()) + .addGroup(layout.createSequentialGroup() + .addGap(108, 108, 108) + .addComponent(jLabel1) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap() + .addComponent(jLabel1) + .addGap(81, 81, 81) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 61, Short.MAX_VALUE) + .addComponent(jButton1) + .addContainerGap()) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MousePressed + studentFileView = new StudentFileView(userID, userName); + studentFileView.setVisible(true); + dispose(); + }//GEN-LAST:event_jButton1MousePressed + + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JLabel jLabel1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JTable jTable1; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentSubmissionView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentSubmissionView.java index ddf4e19..c7de67e 100755 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentSubmissionView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentSubmissionView.java @@ -12,20 +12,35 @@ public class StudentSubmissionView extends javax.swing.JFrame { - public StudentSubmissionView() { + public StudentSubmissionView() + { + // 10-23-16 Scott: + // Filler values. Allows design view to render correctly. + // This code is just for developing the design view. + // Production code goes straight to studentSubmissionStart. + // Uncomment this just when the design view needs to be looked at. + //studentSubmissionStart("fakeID","Johnny"); } + private static final String NAME_OF_PAGE = "Student Submission"; private static final MainView home = new MainView(); private String userID; - - public void studentSubmissionStart(String id) + private String userName; + private StudentView newStudentView; + public void studentSubmissionStart(String id, String studentName) { - initComponents(); - hideErrorFields(); - /* set valid id passed in from MainView.java as our userID for submitting files... */ userID = id; - idOfUser.setText(userID); + // idOfUser.setText(studentName); + + // ***** ldap below + //userName = studentName; + userName = studentName; + + initComponents(); + hideErrorFields(); + + try { @@ -48,8 +63,9 @@ public void studentSubmissionStart(String id) @Override public void windowClosing(WindowEvent e) { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); dispose(); - home.setVisible(true); + //home.setVisible(true); } }); setVisible(true); @@ -112,7 +128,7 @@ private void initComponents() { jLabel1_FileLocation.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jLabel1_FileLocation.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel1_FileLocation.setText("File Location:"); - getContentPane().add(jLabel1_FileLocation, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 95, 20)); + getContentPane().add(jLabel1_FileLocation, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 95, 20)); fileLocation.setEditable(false); fileLocation.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N @@ -121,7 +137,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { fileLocationActionPerformed(evt); } }); - getContentPane().add(fileLocation, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 90, 200, 20)); + getContentPane().add(fileLocation, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 150, 200, 20)); Browse.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N Browse.setText("Browse"); @@ -136,32 +152,34 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { BrowseActionPerformed(evt); } }); - getContentPane().add(Browse, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 90, 73, 23)); + getContentPane().add(Browse, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 150, 73, 23)); - projName.setEditable(false); + projName.setEditable(true); projName.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N projName.setName("projName"); // NOI18N + projName.setVisible(false); projName.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { projNameActionPerformed(evt); } }); - getContentPane().add(projName, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 120, 200, -1)); + getContentPane().add(projName, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 180, 200, -1)); jLabel5_ProjName.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jLabel5_ProjName.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel5_ProjName.setText("Project Name:"); - getContentPane().add(jLabel5_ProjName, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 95, 20)); + jLabel5_ProjName.setVisible(false); + getContentPane().add(jLabel5_ProjName, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 95, 20)); jLabel6_Class.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); jLabel6_Class.setText("Class:"); - getContentPane().add(jLabel6_Class, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 150, 95, 20)); + getContentPane().add(jLabel6_Class, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 90, 95, 20)); jLabel7_Printer.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N jLabel7_Printer.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT); - jLabel7_Printer.setText("Printer:"); + jLabel7_Printer.setText("Device:"); jLabel7_Printer.setToolTipText(""); - getContentPane().add(jLabel7_Printer, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 180, 95, 20)); + getContentPane().add(jLabel7_Printer, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 120, 95, 20)); Student_Submit.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N Student_Submit.setText("Submit"); @@ -176,12 +194,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { classBox.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N classBox.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableClasses())); classBox.setSelectedItem(null); + + classBox.setEditable(false); + classBox.setName("projName"); classBox.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { classBoxActionPerformed(evt); } }); - getContentPane().add(classBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 150, 140, -1)); + getContentPane().add(classBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 90, 140, -1)); printerBox.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N printerBox.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableDevicesStudentSubmissionRequired())); @@ -191,43 +212,45 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { printerBoxActionPerformed(evt); } }); - getContentPane().add(printerBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 180, 140, -1)); - - error_NoFileLocationSelected.setFont(new java.awt.Font("Segoe UI", 1, 13)); // NOI18N - error_NoFileLocationSelected.setForeground(new java.awt.Color(255, 0, 0)); - error_NoFileLocationSelected.setText("Error Text"); - getContentPane().add(error_NoFileLocationSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 120, 70, 20)); + getContentPane().add(printerBox, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 120, 140, -1)); error_NoClassSelected.setFont(new java.awt.Font("Segoe UI", 1, 13)); // NOI18N error_NoClassSelected.setForeground(new java.awt.Color(255, 0, 0)); error_NoClassSelected.setText("Error Text"); - getContentPane().add(error_NoClassSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 150, -1, 20)); + getContentPane().add(error_NoClassSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 250, 150, 20)); error_NoPrinterSelected.setFont(new java.awt.Font("Segoe UI", 1, 13)); // NOI18N error_NoPrinterSelected.setForeground(new java.awt.Color(255, 0, 0)); error_NoPrinterSelected.setText("Error Text"); - getContentPane().add(error_NoPrinterSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(330, 180, 70, 20)); + getContentPane().add(error_NoPrinterSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 265, 150, 20)); getContentPane().add(jSeparator1, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 40, 400, 10)); + + error_NoFileLocationSelected.setFont(new java.awt.Font("Segoe UI", 1, 13)); // NOI18N + error_NoFileLocationSelected.setForeground(new java.awt.Color(255, 0, 0)); + error_NoFileLocationSelected.setText("Error Text"); + getContentPane().add(error_NoFileLocationSelected, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 280, 100, 20)); jLabel8_StudentSubmission.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N jLabel8_StudentSubmission.setText("Student Submission"); getContentPane().add(jLabel8_StudentSubmission, new org.netbeans.lib.awtextra.AbsoluteConstraints(100, 10, -1, -1)); - backButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/back_arrow_button.png"))); // NOI18N - backButton.setContentAreaFilled(false); + backButton.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N + backButton.setText("Logout"); + backButton.setBorder(javax.swing.BorderFactory.createEmptyBorder(1, 1, 1, 1)); backButton.addActionListener(new java.awt.event.ActionListener() { - public void actionPerformed(java.awt.event.ActionEvent evt) { - backButtonActionPerformed(evt); - } + public void actionPerformed(java.awt.event.ActionEvent evt) { + backButtonActionPerformed(evt); + } }); - getContentPane().add(backButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 0, -1, -1)); + getContentPane().add(backButton, new org.netbeans.lib.awtextra.AbsoluteConstraints(10, 220, 100, 23)); - jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 11)); // NOI18N - jLabel1.setText("Your user ID:"); - getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 50, 70, 30)); + jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel1.setText("Hello, " + userName); + getContentPane().add(jLabel1, new org.netbeans.lib.awtextra.AbsoluteConstraints(40, 40, 150, 55)); idOfUser.setEditable(false); idOfUser.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N + idOfUser.setVisible(false); idOfUser.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { idOfUserActionPerformed(evt); @@ -236,9 +259,10 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { getContentPane().add(idOfUser, new org.netbeans.lib.awtextra.AbsoluteConstraints(120, 50, 130, 30)); jLabel9.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ObjectLabEnterpriseSoftware/images/white_bg.jpg"))); // NOI18N - getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 430, 260)); + getContentPane().add(jLabel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 430, 315)); - editMenu.setText("Help"); + + //editMenu.setText("Help"); jMenuItem1.setText("Contents"); jMenuItem1.addActionListener(new java.awt.event.ActionListener() { @@ -246,12 +270,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { jMenuItem1ActionPerformed(evt); } }); - editMenu.add(jMenuItem1); - - jMenuBar1.add(editMenu); - - setJMenuBar(jMenuBar1); - + /* Help Menu bar that doesn't work, but not sure the purpose of it either - Boyd 2/26/2016 + // editMenu.add(jMenuItem1); + // jMenuBar1.add(editMenu); + // setJMenuBar(jMenuBar1); + */ pack(); setLocationRelativeTo(null); }// </editor-fold>//GEN-END:initComponents @@ -279,14 +302,14 @@ private boolean errCheck() if (classBox.getSelectedIndex() == -1) { error_NoClassSelected.setVisible(true); - error_NoClassSelected.setText("Select Option!"); + error_NoClassSelected.setText("Select a Class!"); isErr = true; } if (printerBox.getSelectedIndex() == -1) { error_NoPrinterSelected.setVisible(true); - error_NoPrinterSelected.setText("Select Option!"); + error_NoPrinterSelected.setText("Select a Device!"); isErr = true; } return isErr; @@ -311,9 +334,10 @@ private void Student_SubmitActionPerformed(java.awt.event.ActionEvent evt) {//GE UtilController.submitStudentFile(userID, fullFilePath, fileName, printer, classFK); - JOptionPane.showMessageDialog(new java.awt.Frame(), "Successfully submitted file!"); + JOptionPane.showMessageDialog(new java.awt.Frame(), "Successfully submitted file! Let your professor or lab assistant know you've submitted."); dispose(); - new MainView().setVisible(true); + //Reset view after successful submission to allow for multiple submissions without having to login each time + Reset_StudentSubmissionFields(); } else { dispose(); @@ -326,8 +350,8 @@ private void Reset_StudentSubmissionFields() setVisible(false); fileLocation.setText(null); projName.setText(null); - classBox.setSelectedItem(null); - printerBox.setSelectedItem(null); + //classBox.setSelectedItem(null); + //printerBox.setSelectedItem(null); setVisible(true); }//GEN-LAST:event_Student_SubmitActionPerformed @@ -376,8 +400,11 @@ private void fileLocationActionPerformed(java.awt.event.ActionEvent evt) {//GEN- private void backButtonActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_backButtonActionPerformed {//GEN-HEADEREND:event_backButtonActionPerformed - dispose(); - home.setVisible(true); + //newStudentView = new StudentView(userID, userName); + //newStudentView.setVisible(true); + //dispose(); +// dispose(); +// home.setVisible(true); }//GEN-LAST:event_backButtonActionPerformed private void projNameActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_projNameActionPerformed @@ -394,7 +421,7 @@ private void idOfUserActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST: private javax.swing.JButton Browse; private javax.swing.JButton Student_Submit; private javax.swing.JButton backButton; - private javax.swing.JComboBox classBox; + private javax.swing.JComboBox classBox; private javax.swing.JMenu editMenu; private javax.swing.JLabel error_NoClassSelected; private javax.swing.JLabel error_NoFileLocationSelected; diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.form new file mode 100644 index 0000000..7be546e --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.form @@ -0,0 +1,296 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Student View"/> + <Property name="name" type="java.lang.String" value="Student View" noResource="true"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="-2" pref="77" max="-2" attributes="0"/> + <Component id="jLabel8_StudentSubmission" min="-2" max="-2" attributes="0"/> + <EmptySpace pref="173" max="32767" attributes="0"/> + <Component id="jLabel8_StudentSubmission1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="100" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jScrollPane2" alignment="0" pref="0" max="32767" attributes="0"/> + <Component id="jScrollPane1" alignment="0" pref="375" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="156" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="174" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="1" attributes="0"> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" max="-2" attributes="0"> + <Component id="jComboBox2" alignment="0" pref="175" max="32767" attributes="0"/> + <Component id="jComboBox1" alignment="0" max="32767" attributes="0"/> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jTextField1" min="-2" pref="175" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jButton2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="34" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <Component id="jButton3" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="171" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel8_StudentSubmission" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8_StudentSubmission1" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="43" max="32767" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jScrollPane2" min="-2" pref="43" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboBox1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jComboBox2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jScrollPane1" min="-2" pref="184" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="16" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jButton3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8_StudentSubmission"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Information"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8_StudentSubmission1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Submission"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="5" rowCount="4"> + <Column editable="false" title="File Name" type="java.lang.Object"/> + <Column editable="false" title="Date " type="java.lang.Object"/> + <Column editable="false" title="Stat 1" type="java.lang.Object"/> + <Column editable="false" title="Stat 2" type="java.lang.Object"/> + <Column editable="false" title="Status" type="java.lang.Object"/> + </Table> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Logout"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MousePressed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable2"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="1"> + <Column editable="false" title="Towson Id" type="java.lang.Object"/> + <Column editable="false" title="Z Corp Plaster" type="java.lang.Object"/> + <Column editable="false" title="Objet Build" type="java.lang.Object"/> + <Column editable="false" title="Objet Support" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="File Status"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" value="Material Balance"/> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox1"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableClasses())" type="code"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox2"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableDevicesStudentSubmissionRequired())" type="code"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextField1"> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="text" type="java.lang.String" value="Browse"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton2MousePressed"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="text" type="java.lang.String" value="Submit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="Class:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="text" type="java.lang.String" value="Printer:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="text" type="java.lang.String" value="File Location:"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.java new file mode 100644 index 0000000..f84bbff --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/StudentView.java @@ -0,0 +1,401 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import java.awt.Color; +import java.io.File; +import java.sql.ResultSet; +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import javax.swing.table.DefaultTableModel; + +/** + * + * @author Russell + */ +public class StudentView extends javax.swing.JFrame { + private static final String NAME_OF_PAGE = "Student View"; + private static DefaultTableModel model; + private static DefaultTableModel model2; + private static final MainView home = new MainView(); + private String userID; + private String userName; + private String projName; + + public StudentView() + { + + } + public void newStudentView(String id, String studentName) { + getContentPane().setBackground(Color.WHITE); + initComponents(); + userID = id; + userName = studentName; + model = (DefaultTableModel) jTable1.getModel(); + model2 = (DefaultTableModel) jTable2.getModel(); + updateFileStatusWindow(id, studentName); + updateMaterialWindow(id, studentName); + setVisible(true); + } + public void updateMaterialWindow(String id, String studentName) { + model2.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentInfo(id); + + while(queryResult.next()) + { + String towson_id = queryResult.getString(1); + String material1 = queryResult.getString(2); + String material2 = queryResult.getString(3); + String material3 = queryResult.getString(4); + System.out.println("Adding row..."); + model2.addRow(new Object[] {towson_id, material1, material2, material3}); + } + jTable2.setModel(model2); + jTable2.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + public void updateFileStatusWindow(String id, String studentName) { + model.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentFileStatus(id); + + while(queryResult.next()) + { + String file_name = queryResult.getString(1); + String date = queryResult.getString(2); + String stat1 = queryResult.getString(3); + String stat2 = queryResult.getString(4); + String status = queryResult.getString(5); + System.out.println("Adding row..."); + model.addRow(new Object[] {file_name, date, stat1, stat2, status}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + /** + * 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() { + + jLabel8_StudentSubmission = new javax.swing.JLabel(); + jLabel8_StudentSubmission1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jButton1 = new javax.swing.JButton(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTable2 = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox(); + jComboBox2 = new javax.swing.JComboBox(); + jTextField1 = new javax.swing.JTextField(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Student View"); + setName("Student View"); // NOI18N + + jLabel8_StudentSubmission.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel8_StudentSubmission.setText("Student Information"); + + jLabel8_StudentSubmission1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel8_StudentSubmission1.setText("Student Submission"); + + jTable1.setAutoCreateRowSorter(true); + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null}, + {null, null, null, null, null} + }, + new String [] { + "File Name", "Date ", "Stat 1", "Stat 2", "Status" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.getTableHeader().setReorderingAllowed(false); + jScrollPane1.setViewportView(jTable1); + + jButton1.setText("Logout"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton1MousePressed(evt); + } + }); + + jTable2.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null} + }, + new String [] { + "Towson Id", "Z Corp Plaster", "Objet Build", "Objet Support" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable2.getTableHeader().setReorderingAllowed(false); + jScrollPane2.setViewportView(jTable2); + + jLabel1.setText("File Status"); + + jLabel2.setText("Material Balance"); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableClasses())); + + jComboBox2.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableDevicesStudentSubmissionRequired())); + + jButton2.setText("Browse"); + jButton2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton2MousePressed(evt); + } + }); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText("Submit"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jLabel3.setText("Class:"); + + jLabel4.setText("Printer:"); + + jLabel5.setText("File Location:"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(77, 77, 77) + .addComponent(jLabel8_StudentSubmission) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 173, Short.MAX_VALUE) + .addComponent(jLabel8_StudentSubmission1) + .addGap(100, 100, 100)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jScrollPane2, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 375, Short.MAX_VALUE))) + .addGroup(layout.createSequentialGroup() + .addGap(156, 156, 156) + .addComponent(jLabel2)) + .addGroup(layout.createSequentialGroup() + .addGap(174, 174, 174) + .addComponent(jLabel1))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) + .addComponent(jComboBox2, javax.swing.GroupLayout.Alignment.LEADING, 0, 175, Short.MAX_VALUE) + .addComponent(jComboBox1, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jLabel5) + .addGap(18, 18, 18) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addGap(18, 18, 18) + .addComponent(jButton2) + .addGap(34, 34, 34)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jButton3) + .addGap(171, 171, 171)))) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton1) + .addContainerGap()) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8_StudentSubmission) + .addComponent(jLabel8_StudentSubmission1)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 43, Short.MAX_VALUE) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3))) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(16, 16, 16) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2) + .addComponent(jLabel5)) + .addGap(18, 18, 18) + .addComponent(jButton3))) + .addGap(18, 18, 18) + .addComponent(jButton1) + .addContainerGap()) + ); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MousePressed + dispose(); + home.setVisible(true); // TODO add your handling code here: + }//GEN-LAST:event_jButton1MousePressed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MousePressed + //Creates "JFileChooser" file browser + JFileChooser fileopen = new JFileChooser(); + File desktop = new File(System.getProperty("user.home") + "\\Desktop"); + fileopen.setCurrentDirectory(desktop); + //in brackets, add Syncthing directory or new Drive's address for default location + fileopen.setAcceptAllFileFilterUsed(false); + fileopen.setMultiSelectionEnabled(false); + //FileNameExtensionFilter filter = new FileNameExtensionFilter("Object Files", "obj", "zpr", "stl"); + //fileopen.setFileFilter(filter); + int ret = fileopen.showDialog(null, "Open file"); + + if (ret == JFileChooser.APPROVE_OPTION) + { + File file = fileopen.getSelectedFile(); + //Inputs the file location into the textbox "fileName" + jTextField1.setText(file.toString().replaceAll("'", "")); + String projectFileName = file.getName().replaceAll("'", ""); + String finalProjectFileName = projectFileName.replaceAll("(\\.\\S+?$)", UtilController.getCurrentTimeFromDB() + "$1"); + projName = finalProjectFileName; + } + }//GEN-LAST:event_jButton2MousePressed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + /* + Verifies user and file information is inputted in its entirety + */ + //if (errCheck() == false) + // + /* Recieve our input from the UI and hand it off to back end to submit / store file information */ + String fullFilePath, fileName, classText, printer; + int classFK; + + fullFilePath = jTextField1.getText(); + fileName = projName; + printer = (String) jComboBox2.getSelectedItem(); + /* parse classBox string and pull out the primary key and store it in an integer */ + classText = (String) jComboBox1.getSelectedItem(); + classFK = (Integer.parseInt(classText.split(" ")[0])); + + UtilController.submitStudentFile(userID, fullFilePath, fileName, printer, classFK); + + JOptionPane.showMessageDialog(new java.awt.Frame(), "Successfully submitted file! Let your professor or lab assistant know you've submitted."); + dispose(); + //Reset view after successful submission to allow for multiple submissions without having to login each time + Reset_StudentSubmissionFields(); + updateFileStatusWindow(userID, userName); + //} else + { + dispose(); + Reset_StudentSubmissionFields(); + } + } + + private void Reset_StudentSubmissionFields() + { + setVisible(false); + jTextField1.setText(null); + //projName.setText(null); + //classBox.setSelectedItem(null); + //printerBox.setSelectedItem(null); + setVisible(true); // TODO add your handling code here: + }//GEN-LAST:event_jButton3ActionPerformed + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JComboBox jComboBox2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel8_StudentSubmission; + private javax.swing.JLabel jLabel8_StudentSubmission1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTable jTable1; + private javax.swing.JTable jTable2; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UpdateStudentView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UpdateStudentView.java index 326499e..9d5b426 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UpdateStudentView.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UpdateStudentView.java @@ -13,10 +13,14 @@ import javax.mail.internet.InternetAddress; import javax.swing.JOptionPane; -public class UpdateStudentView extends javax.swing.JFrame +public class UpdateStudentView { + +} + +/*public class UpdateStudentView extends javax.swing.JFrame { /* This code is similar to AddStudentView. This should not be the case, they should share stuff. */ - private static final String NAME_OF_PAGE = "Update Student Information"; +/* private static final String NAME_OF_PAGE = "Update Student Information"; private static MainView home = new MainView(); private String userID; @@ -80,8 +84,9 @@ public void keyTyped(KeyEvent e) * WARNING: Do NOT modify this code. The content of this method is always * regenerated by the Form Editor. */ - @SuppressWarnings("unchecked") +/* @SuppressWarnings("unchecked") // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + /* private void initComponents() { newStudentLabel = new javax.swing.JLabel(); @@ -280,4 +285,4 @@ private void submitMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:even private javax.swing.JButton submit; private javax.swing.JLabel tuID; // End of variables declaration//GEN-END:variables -} +} */ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UtilController.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UtilController.java index 2dbc3ef..fe391cf 100644 --- a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UtilController.java +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/UtilController.java @@ -1,8 +1,10 @@ package ObjectLabEnterpriseSoftware; import java.awt.Desktop; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; +import java.io.InputStreamReader; import java.net.URI; import java.net.URISyntaxException; import java.security.MessageDigest; @@ -13,6 +15,19 @@ import java.util.ArrayList; import java.util.logging.Level; import java.util.logging.Logger; + +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attributes; +import javax.naming.directory.BasicAttribute; +import javax.naming.directory.BasicAttributes; +import javax.naming.directory.DirContext; +import javax.naming.directory.InitialDirContext; +import javax.naming.directory.SearchControls; +import javax.naming.directory.SearchResult; +import javax.naming.ldap.LdapContext; +import javax.security.auth.login.LoginContext; import javax.swing.DefaultListModel; import javax.swing.JFrame; import javax.swing.JOptionPane; @@ -21,6 +36,13 @@ import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; +import java.util.Hashtable; +import javax.naming.Context; +import javax.naming.NamingEnumeration; +import javax.naming.NamingException; +import javax.naming.directory.Attribute; +import javax.naming.directory.Attributes; +import javax.naming.directory.DirContext; /* We want to move this into its own class. For making excel documents based on the DefaultTableModel */ import org.apache.poi.hssf.usermodel.HSSFWorkbook; @@ -29,23 +51,46 @@ import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import com.sun.jndi.ldap.LdapName; + public class UtilController { - private static final boolean SUCCESS = true; private static final boolean FAILURE = false; private static final String SOFTWARE_NAME = "OLI"; - private static final String SOFTWARE_VERSION = "v1.1"; //Should be dynamic + private static final String SOFTWARE_VERSION = "v2.00"; //Should be dynamic - /* Bug - Invalid URL, build 1.1 - Boyd, 2/10/2016 */ - private static final String USER_GUIDE_URL = "http://triton.towson.edu/~jirani2/adminHelp.pdf"; - /* ***************************************************************** */ + private static final String USER_GUIDE_URL = "https://drive.google.com/file/d/0ByBesmdK0SzlV0Zha3M1Mmp2SW8/view?usp=sharing"; + private static String studentFname; + private static String studentLname; + public static String getPageName(String pageName) { return SOFTWARE_NAME + " " + SOFTWARE_VERSION + " - " + pageName; } + + public static String getStudentFname() + { + return studentFname; + } + + public static String getStudentLname() + { + return studentLname; + } + + public static void setStudentFName(String firstName) + { + studentFname = firstName; + } + + public static void setStudentLName(String lastName) + { + studentLname = lastName; + } + private static void print(ArrayList<ArrayList<Object>> q) { @@ -155,6 +200,39 @@ public static String[] getReportColumnHeaders(String printer_name) return null; } + + + public static String[] getRealReportColumnHeaders(String printer_name) + { + try + { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult = dbconn.getReport(printer_name); + /* Must process results found in ResultSet before the connection is closed! */ + + ResultSetMetaData rsmd = queryResult.getMetaData(); + String[] headers = new String[rsmd.getColumnCount()]; + //System.out.println(rsmd.getColumnName(5)); + for (int i = 1; i <= rsmd.getColumnCount(); i++) + { + headers[i - 1] = rsmd.getColumnName(i); + } + + dbconn.closeDBConnection(); + return headers; + } catch (SQLException ex) + { + Logger.getLogger(UtilController.class.getName()).log(Level.SEVERE, null, ex); + } + return null; + } + + + + + + + public static String[] getStatusJobsHeaders(String status) { try @@ -165,10 +243,11 @@ public static String[] getStatusJobsHeaders(String status) ResultSetMetaData rsmd = queryResult.getMetaData(); String[] headers = new String[rsmd.getColumnCount()]; + String[] headername = new String[]{"File Name", "First Name","Last Name","Submission Date","Printer Name","Class Name","Class Section"}; //System.out.println(rsmd.getColumnName(5)); for (int i = 1; i <= rsmd.getColumnCount(); i++) { - headers[i - 1] = rsmd.getColumnName(i); + headers[i - 1] = headername[i-1]; } dbconn.closeDBConnection(); @@ -284,7 +363,7 @@ public void exportReportToFile(DefaultTableModel model, String[] header, String Row row = null; Cell cell = null; Calendar c = Calendar.getInstance(); - String time = "" + c.get(Calendar.MONTH) + "-" + c.get(Calendar.DAY_OF_MONTH) + "-" + c.get(Calendar.YEAR); + String time = "" + (c.get(Calendar.MONTH) + 1) + "-" + c.get(Calendar.DAY_OF_MONTH) + "-" + c.get(Calendar.YEAR); for (int i = 0; i < model.getRowCount() + 1; i++) { @@ -325,7 +404,7 @@ else if (type == 'f') public static void exportReportsForPrinters() { - ArrayList<String> printers = UtilController.getListOfAllDevices(); + ArrayList<String> printers = UtilController.getListOfCurrentDevices(); FileManager fileManager = new FileManager(); Workbook wb = new HSSFWorkbook(); @@ -376,11 +455,46 @@ public static void exportReportsForPrinters() } } + public static boolean checkExtension(String printer, String submittedFileExtension) + { + boolean isValid = false; + SQLMethods dbconn = new SQLMethods(); + + ResultSet results = dbconn.selectAcceptedFiles(printer); + + try + { + String ext; + while(results.next()) + { + ext = results.getString(1); + if(ext.compareTo(submittedFileExtension) == 0) + { + // The file matches a valid extension in the DB. + // Return true. + System.out.println("The file extension is valid."); + return true; + } + } + } + catch (SQLException e) + { + System.out.println("The file extension is invalid:\n" + e.toString()); + // TODO Auto-generated catch block + e.printStackTrace(); + } + + System.out.println("The file extension is invalid. No match was found."); + return isValid; + } + public static boolean rejectStudentSubmission(String file, String reasonForRejection) { SQLMethods dbconn = new SQLMethods(); + + dbconn.updateFileComment(file, reasonForRejection); + ResultSet results = dbconn.searchID((file)); - try { String emailadr, emailMessage, primaryKey, fName, lName; @@ -433,14 +547,18 @@ public static boolean rejectStudentSubmission(String file, String reasonForRejec String newFileLocation = cloudStorageOperations.getRejected() + file; dbconn.updateJobFLocation(Integer.parseInt(primaryKey), newFileLocation.replace("\\", "\\\\")); dbconn.updateStatus("rejected", Integer.parseInt(primaryKey)); + + //reasonForRejection = dbconn.getFileComment(file); + dbconn.closeDBConnection(); emailMessage = "Dear " + fName + " " + lName + ", \n\nAfter analyzing your file submission, " + file + ", we have found the following error: \n\nComment: " + reasonForRejection + "\n\nPlease fix the file and resubmit." + "\n\nThank you,\nObject Lab Staff"; //Backup email - //TowsonOli@gmail.com passwordTowson - return new EmailUtils(emailadr, "TowsonuObjectLab@gmail.com", "oblabsoftware", emailMessage).send(); + //TowsonOli@gmail.com passwordTowson + EmailUtils.send(emailadr, "TowsonuObjectLab@gmail.com", "oblabsoftware", emailMessage); + return true; } catch (SQLException ex) { System.out.println("Program crashed in reject subm\n" + ex); @@ -500,7 +618,173 @@ public static void approveStudentSubmission(String fileName, double volume) Logger.getLogger(UtilController.class.getName()).log(Level.SEVERE, null, ex); } } + + public static void changeStudentBalance(String printer, String id, double stat1, double stat2) + { + SQLMethods dbconn = new SQLMethods(); + if(printer.equalsIgnoreCase("Z Printer 250")) + { + dbconn.addMaterial(id, -(stat1), "z_corp_plaster"); + } + else if (printer.equalsIgnoreCase("Objet Desktop 30")) + { + dbconn.addMaterial(id, -(stat1), "objet_build"); + dbconn.addMaterial(id, -(stat2), "objet_support"); + } + else + { + System.out.println("Error"); + } + dbconn.closeDBConnection(); + } + + public static void changeStudentBalanceHistory(String printer, String id, double stat1, double stat2) + { + SQLMethods dbconn = new SQLMethods(); + if(printer.equalsIgnoreCase("Z Printer 250")) + { + //dbconn.addMaterial(id, -(stat1), "z_corp_plaster"); + dbconn.addTransactionHistory(id, "z_corp_plaster", -(stat1)); + } + else if (printer.equalsIgnoreCase("Objet Desktop 30")) + { + //dbconn.addMaterial(id, -(stat1), "objet_build"); + //dbconn.addMaterial(id, -(stat2), "objet_support"); + dbconn.addTransactionHistory(id, "objet_build", -(stat1)); + dbconn.addTransactionHistory(id, "objet_support", -(stat2)); + } + else + { + System.out.println("Error"); + } + dbconn.closeDBConnection(); + } + + /*** + * + * @param printer The printer the student is submitting to + * @param id The student's ID + * @param stat1 The amount of stat1 the student wants to spend + * @param stat2 The amount of stat2 the student wants to spend + * @return True/False: Would this transaction run a negative balance? + */ + public static boolean checkNegativeBalance(String printer, String id, double stat1, double stat2) + { + boolean retVal = false; + SQLMethods dbconn = new SQLMethods(); + + ResultSet queryResult = dbconn.searchStudentBalanceId(id); + try { + while(queryResult.next()) + { + String first_name = queryResult.getString(1); + String last_name= queryResult.getString(2); + String towson_id = queryResult.getString(3); + double zcorp = queryResult.getDouble(4); + double obbuild = queryResult.getDouble(5); + double obsupport = queryResult.getDouble(6); + + if(printer.equalsIgnoreCase("Objet Desktop 30")) + { + if(obbuild - stat1 < 0) + { + retVal = true; + } + else if(obsupport - stat2 < 0) + { + retVal = true; + } + } + else if (printer.equalsIgnoreCase("Z Printer 250")) + { + if(zcorp - stat1 < 0) + { + retVal = true; + } + } + } + } catch (SQLException e) { + e.printStackTrace(); + System.out.println("Error: " + e); + } + + + return retVal; + } + + public static void approveStudentSubmission(String fileName, String stat1, String stat2) + { + /* Make the connection to our DB and query for the PK of pendingjobs which is a combination of + all the fields input in the searchID method call + */ + SQLMethods dbconn = new SQLMethods(); + ResultSet result = dbconn.searchID((fileName)); + FileManager cloudStorageOperations = new FileManager(); + + String ID; + + try + { + /* + If the row exist, then query for the PK and then use that to update + the pendingjobs table fileLocation. -Nick + */ + if (result.next()) + { + ID = result.getString("job_id"); + String printer = result.getString("printer_name"); + String updatedDirectoryLocation = cloudStorageOperations.getDrive() + "\\ObjectLabPrinters\\" + printer + "\\ToPrint\\"; + String currentFileLocation = cloudStorageOperations.getSubmission() + fileName; + /* This moves the file from the submissions folder to the toPrint folder in folder specified by + * the printer variable -Nick + */ + FileUtils.moveFileToDirectory(new File(currentFileLocation), new File(updatedDirectoryLocation), true); + + /* In order to properly update the file location we need to gurantee there are '\\' seperating + * the dir names. + * If ther are no double backslashes than the character will not be escaped properly, and + * the DB will not contain the correct file location. + * - Nick + */ + dbconn.updateStats(Integer.parseInt(ID), stat1, stat2); + + /* update full file path */ + updatedDirectoryLocation += fileName; + dbconn.updateJobFLocation(Integer.parseInt(ID), updatedDirectoryLocation.replace("\\", "\\\\")); + dbconn.changeJobStatus(Integer.parseInt(ID), "approved"); + dbconn.closeDBConnection(); + } + } catch (SQLException | IOException ex) + { + Logger.getLogger(UtilController.class.getName()).log(Level.SEVERE, null, ex); + } + } + + + + + + + + + + + + + + + + + + + + + + + + + /* This function has the params that make up the primary key in pending currentJob. It returns the filePath found in the DB where all the parameters specify the file that is associated for that users submission. @@ -697,6 +981,24 @@ public static String[] listOfBuilds() } return returnBuilds; } + + //Rajewski + //done + + public static ArrayList<ArrayList<Object>> arrayListOfBuilds(String currentDevice) + { + /* + Fetch available builds + */ + + SQLMethods dbconn = new SQLMethods(); + ResultSet buildsResult = dbconn.getBuildsForRecordsTable(currentDevice); + ArrayList<ArrayList<Object>> builds = readyOutputForViewPage(buildsResult); + /* Must process results found in ResultSet before the connection is closed! */ + dbconn.closeDBConnection(); + + return builds; + } public static void submitStudentFile(String userID, String fileLocation, String fileName, String printerName, int classFK) { @@ -904,37 +1206,149 @@ public static void insertNewClass(String className, String classNumber, String s dbconn.closeDBConnection(); } - public static boolean userIDExist(String studentId) + public static boolean userIDExist(String studentId, String studentPass) { - boolean flag = false; - SQLMethods dbconn = new SQLMethods(); - ResultSet usersCountQuery = dbconn.checkUserExists(studentId); - try - { - flag = usersCountQuery.next(); - } catch (SQLException ex) - { - Logger.getLogger(UtilController.class.getName()).log(Level.SEVERE, null, ex); - } + Hashtable<String, String> env = new Hashtable<String, String>(); + env.put(Context.INITIAL_CONTEXT_FACTORY, "com.sun.jndi.ldap.LdapCtxFactory"); + env.put(Context.SECURITY_AUTHENTICATION, "simple"); + env.put(Context.PROVIDER_URL, "ldap://Towson.edu:389/"); + + // The value of Context.SECURITY_PRINCIPAL must be the logon username with the domain name + env.put(Context.SECURITY_PRINCIPAL, "TOWSONU\\" + studentId); + + // The value of the Context.SECURITY_CREDENTIALS should be the user's password + env.put(Context.SECURITY_CREDENTIALS, studentPass); + + DirContext ctx; + System.out.print("Attempting login with credentials: \n username: " + studentId + "\n password: " + studentPass); + try { + // Authenticate the logon user + ctx = new InitialDirContext(env); + if(ctx != null) + { + System.out.println("user is authenticated. grabbing first/last name"); + /** + * + * @author Ryan + */ + String getUserInfo = "cmd /c net user "+studentId+" /domain |find /i \"full name\""; + studentFname = "debug_failed_fname"; // if these are not overwritten then couldn't grab first / last name from server + studentLname = "debug_failed_lname"; // but it shouldn't break the submit system ~Alex + Process p = null; + + try + { + p = Runtime.getRuntime().exec(getUserInfo); + //System.out.println(p.toString()); + + BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream())); + String s = null; + while ((s = stdInput.readLine()) != null) + { + String delims ="[ ,]+"; + String[] tokens = s.split(delims); + for (int i=2;i<tokens.length; i++) + { + System.out.println(tokens[i]); + setStudentLName(tokens[2]); + setStudentFName(tokens[3]); + + } + } + + + } + catch(Exception e) + { + System.out.println("Something went wrong "); + } + + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult = dbconn.getStudentName(studentId); + try{ + while(queryResult.next()) + { + studentFname = queryResult.getString(1); + studentLname = queryResult.getString(2); + } + } catch(Exception e) + { + System.out.println("Error: " + e); + } - dbconn.closeDBConnection(); - return flag; + setStudentFName(studentFname); + setStudentLName(studentLname); + + if(studentFname.equals("debug_failed_fname")) + { + System.out.println("Failed to grab student data."); + return false; + + + } + else if(!checkUser(studentId)) // user isn't in db + { + addUser(studentId, studentFname, studentLname, studentId+"@students.towson.edu"); + System.out.println("Added new student: " + studentFname + " " + studentLname + "successfully."); + return true; + } + else // user already in db, can login and continue + { + System.out.println("Student: " + studentFname + " " + studentLname + " already in database. Skipping entry and logging in."); + return true; + } + } + + } catch (NamingException ex) { + return false; + } + //***** + return true; } + + public static int addUser(String studentId, String firstname, String lastname, String email) { - if (userIDExist(studentId)) + if (checkUser(studentId)) { return -25; } SQLMethods dbconn = new SQLMethods(); int flag = dbconn.insertIntoUsers(studentId, firstname, lastname, email); + dbconn.insertIntoMaterial(studentId); dbconn.closeDBConnection(); return flag; + } + + public static boolean checkUser(String studentID) + { + // Old Method to verify student accounts + boolean flag = false; + SQLMethods dbconn = new SQLMethods(); + ResultSet usersCountQuery = dbconn.checkUserExists(studentID); + try + { + flag = usersCountQuery.next(); + } catch (SQLException ex) + { + Logger.getLogger(UtilController.class.getName()).log(Level.SEVERE, null, ex); + } + + dbconn.closeDBConnection(); + return flag; + + + } + + + + + - public static int updateUser(String studentId, String firstname, String lastname, String email) + /*public static int updateUser(String studentId, String firstname, String lastname, String email) { int flag = -1; if (userIDExist(studentId)) @@ -945,7 +1359,7 @@ public static int updateUser(String studentId, String firstname, String lastname return flag; } return flag; - } + }*/ public static ArrayList<ArrayList<Object>> returnApprovedStudentSubmissionsForDevice(String printerName) { @@ -974,23 +1388,43 @@ public static boolean submitBuild(ArrayList<Integer> selectedStudentSubmissionFi /* runtime = convertToSeconds(deviceModel.getFieldData("Hours"), deviceModel.getFieldData("Minutes"), deviceModel.getFieldData("Seconds")); */ - if (deviceModel.getFieldType("Run time") == Device.TYPE_STRING) + //Russell - Joe + //Started commenting out anything that needed info for the runtime input + //Rajewski + //no need for runtime + /*if (deviceModel.getFieldType("Run time") == Device.TYPE_STRING) { runtime = Integer.parseInt((String) deviceModel.getFieldData("Run time")); } else { runtime = (Integer) deviceModel.getFieldData("Run time"); } - - dbconn.insertIntoBuild(filePathToBuildFile.replace("\\", "\\\\"), runtime, models, deviceName); + */ + + //Russell - Joe + //This function requires runtime to be a part of a build + //The first call that is commented out here was removed for that reason. I stopped here + //and then messaged you on Slack about this whole ordeal at this time before changing that whole function around + //Rajewski + //Removing runtime, adjust function insertIntoBuild + //dbconn.insertIntoBuild(filePathToBuildFile.replace("\\", "\\\\"), runtime, models, deviceName); + dbconn.insertIntoBuild(filePathToBuildFile.replace("\\", "\\\\"), models, deviceName); /* Remove first entry becuase it is now not needed (HOTFIX) */ - deviceModel.rmField("Run time"); + //Rajewski + //Removed Runtime + //deviceModel.rmField("Run time"); /* STEP 1.1 - Insert all build data for the device into the database for the assoicated printer and trackable field for that printer */ + //Rajewski + //I don't think we need this for loop since there is no more input table. Hotfix 11/21/ + /* for (String fieldName : deviceFieldNames) { + //Rajewski + //for development purposes + System.out.println(deviceFieldNames); dbconn.insertIntoColumnBuildData(deviceName, fieldName, "" + deviceModel.getFieldData(fieldName), filePathToBuildFile.replace("\\", "\\\\")); } - + */ /* Loop through currentJob that where checked in as part of the build and update data related to student submissions */ for (Integer currentJob : selectedStudentSubmissionFiles) { diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/Thumbs.db b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/Thumbs.db new file mode 100644 index 0000000..9e13917 Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/Thumbs.db differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/back_arrow_button.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/back_arrow_button.png index 42fa338..3244089 100644 Binary files a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/back_arrow_button.png and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/back_arrow_button.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/cog_icon.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/cog_icon.png index 2a6136e..6bb776e 100644 Binary files a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/cog_icon.png and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/cog_icon.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/hammer_icon.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/hammer_icon.png index 0dc3eb0..f6c9bcb 100644 Binary files a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/hammer_icon.png and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/hammer_icon.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/icon.ico b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/icon.ico new file mode 100644 index 0000000..456b09c Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/icon.ico differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/imgres.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/imgres.png new file mode 100644 index 0000000..a978ffe Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/imgres.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/polytiger2.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/polytiger2.png new file mode 100644 index 0000000..ff413b9 Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/polytiger2.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reject_files_icon.ico b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reject_files_icon.ico new file mode 100644 index 0000000..dbbd6b6 Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reject_files_icon.ico differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reports_icon.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reports_icon.png index bfb922a..d92a3bd 100644 Binary files a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reports_icon.png and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/reports_icon.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon.png new file mode 100644 index 0000000..2ad4103 Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon_original.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon_original.png new file mode 100644 index 0000000..6ced2b2 Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/stats_icon_original.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/swap3.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/swap3.png new file mode 100644 index 0000000..8d7519a Binary files /dev/null and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/swap3.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/view_file_icon.png b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/view_file_icon.png index 7d51e50..8b7d6ce 100644 Binary files a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/view_file_icon.png and b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/images/view_file_icon.png differ diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newJobsMgr.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newJobsMgr.java new file mode 100644 index 0000000..2614a71 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newJobsMgr.java @@ -0,0 +1,942 @@ +package ObjectLabEnterpriseSoftware; + +import java.awt.Dimension; + +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.JFrame; + +import ObjectLabEnterpriseSoftware.AdminSettingsView; +import ObjectLabEnterpriseSoftware.BuildView; +import ObjectLabEnterpriseSoftware.JobsView; +import ObjectLabEnterpriseSoftware.ReportsView; +import ObjectLabEnterpriseSoftware.SQLMethods; + +import javax.swing.JMenuBar; +import javax.swing.JOptionPane; +import javax.swing.JComboBox; +import javax.swing.JDialog; +import javax.swing.JLabel; +import java.awt.Font; +import javax.swing.JScrollPane; +import javax.swing.JTable; + +import org.apache.derby.tools.sysinfo; + +import javax.swing.JPanel; +import java.awt.Button; +import java.awt.Color; +import java.awt.Desktop; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.io.File; +import java.io.IOException; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.swing.JTextField; +import javax.swing.table.DefaultTableModel; +import java.awt.Toolkit; +import java.util.concurrent.TimeUnit; + + +/* + * Jobs Manager V2 + * @Author=M. Alex Boyd + * @Date=4/22/16 + * + * To-Dos + * - Add check to make sure jobs are not already approved before approving + * + */ + +public class newJobsMgr extends JFrame { + // --nav bar views ~Alex + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private BalanceView balanceView; + private newSettingsMenu adminSettingsView; + // + + //private CommentView commentview; + public newJobsMgr() { + setIconImage(Toolkit.getDefaultToolkit().getImage(newJobsMgr.class.getResource("/ObjectLabEnterpriseSoftware/images/icon.ico"))); + setTitle("Administration Panel"); + setPreferredSize(new Dimension(635,605)); + setAlwaysOnTop(false); + getContentPane().setBackground(Color.WHITE); + initWindow(); + setLocationRelativeTo(null); + } + + + private void initWindow() + { + + JMenuBar jMenuBar1 = new JMenuBar(); + setJMenuBar(jMenuBar1); + + jMenuBar1.setPreferredSize(new Dimension(200, 30)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + + + jMenuBar1.add(Box.createRigidArea(new Dimension(45, 12))); + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + + navBtn_build.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_reports); + + navBtn_balance = new JButton("Balance"); + navBtn_balance.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/stats_icon.png"))); + navBtn_balance.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_balance); + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_settings); + getContentPane().setLayout(null); + + jobStatusCombo = new JComboBox(); + //**** + jobStatusCombo.setBounds(163, 63, 89, 20);//163 //87 //80 //77 + // ***** + //jobStatusCombo.addItem("All Jobs"); + //**** + jobStatusCombo.addItem(" "); + jobStatusCombo.addItem("Pending"); + jobStatusCombo.addItem("Rejected"); + // + + getContentPane().add(jobStatusCombo); + + JLabel lblJobStatus = new JLabel("Job Status:"); + //**** + lblJobStatus.setBounds(86, 63, 78, 17);//86 //20 //10 + lblJobStatus.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + // + lblJobStatus.setLabelFor(jobStatusCombo); + getContentPane().add(lblJobStatus); + + //**** + JLabel findclass = new JLabel("Class:"); + findclass.setBounds(414, 64, 60, 14);//283 //370 + findclass.setFont(new Font("Segoe UI", Font.PLAIN, 13)); + findclass.setLabelFor(jobStatusCombo);//devicecombo + //getContentPane().add(findclass); -sorry + // + + //**** + classCombo = new JComboBox(); + classCombo.setBounds(450, 63, 67, 20);//380//67 + classCombo.addItem(" "); + classCombo.addItem("ART 101"); + classCombo.addItem("COSC 412"); + classCombo.addItem("THEA 102"); + classCombo.addItem("CIS 237"); + //getContentPane().add(classCombo); -sorry + // + + + //**** + JLabel findsection = new JLabel("Sect:"); + findsection.setBounds(523, 64, 30, 14);//283 + findsection.setFont(new Font("Segoe UI", Font.PLAIN, 13)); + findsection.setLabelFor(jobStatusCombo);//devicecombo + //getContentPane().add(findsection); -sorry + // + + //**** + sectionCombo = new JComboBox(); + sectionCombo.setBounds(553, 63, 55, 20); + sectionCombo.addItem(" "); + sectionCombo.addItem("-"); + //getContentPane().add(sectionCombo); -sorry + // + + + final JComboBox deviceCombo = new JComboBox(); + //**** + deviceCombo.setBounds(342, 63, 125, 20);//342 //266 //259 //251 + deviceCombo.addItem(" "); + /// Adds tracked devices to comboBox dropdown window + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult = dbconn.getTrackedDevices(); + try { + while(queryResult.next()) + { + deviceCombo.addItem(queryResult.getString(1)); + } + } catch(Exception e) + { + System.out.println("Error: " + e); + } + // + + deviceCombo.addActionListener(new ActionListener() { + + public void actionPerformed(ActionEvent e) { + + JComboBox cb = (JComboBox) e.getSource(); + String selectedDevice = (String) cb.getSelectedItem(); + System.out.println(selectedDevice); + updateJobWindow(selectedDevice); + + if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("rejected")) // hide approve/reject/review buttons and panel + { + toggleButtons(false); + } + else if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("pending")) // hide approve/reject/review buttons and panel + { + toggleButtons(true); + } + + } + + }); + + jobStatusCombo.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) + { + if(deviceCombo.getSelectedItem().toString() != "") + { + String selectedDevice = (String) deviceCombo.getSelectedItem(); + System.out.println(selectedDevice); + updateJobWindow(selectedDevice); + if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("approved")) // hide approve/reject/review buttons and panel + { + toggleButtons(false); + } + else if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("pending")) // hide approve/reject/review buttons and panel + { + toggleButtons(true); + } + } + } + }); + + getContentPane().add(deviceCombo); + + JLabel deviceLabel = new JLabel("Device:"); + //**** + deviceLabel.setBounds(283, 64, 60, 14);//283 //207 + deviceLabel.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + deviceLabel.setLabelFor(deviceCombo); + getContentPane().add(deviceLabel); + + JScrollPane jobListingsPane = new JScrollPane(); + jobListingsPane.setBounds(10, 94, 598, 166); + getContentPane().add(jobListingsPane); + + + jobsTable = new JTable(); + jobsModel = new DefaultTableModel() { + Class[] columnTypes = new Class[] { + Boolean.class, Object.class, Object.class, Object.class, Object.class, Object.class, Object.class, Object.class, Object.class + }; + public Class getColumnClass(int columnIndex) { + return columnTypes[columnIndex]; + } + //**** + public boolean isCellEditable(int row, int column) { + if (column == 0) + return true; + return false; + } + + + + }; + + + + //jobsModel.setColumnCount(6); + //jobsModel.setColumnIdentifiers(new String[] { + // "Selected?", "File Name", "First Name", "Last Name", "Date", "Class", "Section" + //}); + + jobsTable.setModel(jobsModel); + jobListingsPane.setViewportView(jobsTable); + + jobsTable.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + for(int i=0; i<jobsTable.getRowCount(); i++){ + if(i==jobsTable.getSelectedRow()){ + jobsTable.setValueAt(true, jobsTable.getSelectedRow(), 0); + }else{ + jobsTable.setValueAt(false, i, 0); + } + } + + } + }); + + + JLabel titleLabel = new JLabel("Jobs Manager"); + titleLabel.setBounds(226, 11, 159, 41); + titleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 24)); + getContentPane().add(titleLabel); + + JButton logoutButton = new JButton("Logout"); + logoutButton.setBounds(10, 459, 95, 23); + logoutButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + logout(); + } + }); + logoutButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + logoutButton.setBackground(Color.LIGHT_GRAY); + getContentPane().add(logoutButton); + + approveButton = new JButton("Approve"); + approveButton.setBounds(331, 459, 89, 23); + approveButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + approveJobs(); + } + }); + approveButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + getContentPane().add(approveButton); + //**** + approveButton.setVisible(false); + + + rejectButton = new JButton("Reject"); + rejectButton.setBounds(426, 459, 89, 23); + rejectButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + rejectJobs(); + } + }); + rejectButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + getContentPane().add(rejectButton); + //**** + rejectButton.setVisible(false); + + reviewButton = new JButton("Review"); + reviewButton.setBounds(519, 459, 89, 23); + reviewButton.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent evt) { + openInDefaultProgram(evt); + } + }); + reviewButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + getContentPane().add(reviewButton); + //**** + reviewButton.setVisible(false); + + + //****NOT NEEDED -cesar + /* + selectallButton = new JButton("Select All"); + selectallButton.setBounds(424, 265, 89, 23);//459 //250 //265 + selectallButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + + // + selectallButton.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if(selectallButton.isSelected()){ + + for(int i=0;i<jobsModel.getRowCount();i++) + jobsModel.setValueAt(true, i, 0); + + }else{ + + for(int i=0;i<jobsModel.getRowCount();i++) + jobsModel.setValueAt(true, i, 0); + //jobsModel.getValueAt(1,1)).setValueAt(false, i, 5); + } + + } + });*/ + // + + //getContentPane().add(selectallButton); + + //**** + + + // + /* + deselectallButton = new JButton("Deselect All"); + deselectallButton.setBounds(519, 265, 89, 23);//459 //250 //265 + deselectallButton.setFont(new Font("Segoe UI", Font.PLAIN, 12)); + + //$$$$ + deselectallButton.addMouseListener(new MouseAdapter() { + public void mouseClicked(MouseEvent e) { + if(deselectallButton.isSelected()){ + + for(int i=0;i<jobsModel.getRowCount();i++) + jobsModel.setValueAt(false, i, 0); + + }else{ + + for(int i=0;i<jobsModel.getRowCount();i++) + jobsModel.setValueAt(false, i, 0); + //jobsModel.getValueAt(1,1)).setValueAt(false, i, 5); + } + + } + });*/ + // + + + //getContentPane().add(deselectallButton); + + + + + lblFillInData = new JLabel("Please enter device statistic tracking data if approving:"); + lblFillInData.setBounds(10, 271, 375, 23); + lblFillInData.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + lblFillInData.setVisible(false); + getContentPane().add(lblFillInData); + + jobStatPanel = new JPanel(); + jobStatPanel.setBounds(10, 305, 598, 143); + jobStatPanel.setVisible(false); // stat panel doesn't show up until device is selected. + getContentPane().add(jobStatPanel); + jobStatPanel.setLayout(null); + + deviceNameLabel = new JLabel("filler"); + deviceNameLabel.setFont(new Font("Segoe UI", Font.PLAIN, 16)); + deviceNameLabel.setBounds(227, 11, 139, 39); + jobStatPanel.add(deviceNameLabel); + + trackingStatLabel1 = new JLabel("New label"); + trackingStatLabel1.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + trackingStatLabel1.setBounds(0, 53, 141, 20); + jobStatPanel.add(trackingStatLabel1); + + trackingStatLabel2 = new JLabel("New label"); + trackingStatLabel2.setLabelFor(trackingStatLabel2); + trackingStatLabel2.setFont(new Font("Segoe UI", Font.PLAIN, 14)); + trackingStatLabel2.setBounds(0, 90, 141, 20); + jobStatPanel.add(trackingStatLabel2); + + trackingStatInput1 = new JTextField(); + trackingStatLabel1.setLabelFor(trackingStatInput1); + trackingStatInput1.setBounds(161, 55, 175, 20); + jobStatPanel.add(trackingStatInput1); + trackingStatInput1.setColumns(10); + + trackingStatInput2 = new JTextField(); + trackingStatInput2.setBounds(160, 92, 176, 20); + jobStatPanel.add(trackingStatInput2); + trackingStatInput2.setColumns(10); + + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_balance.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_balanceActionPerformed(evt); + } + }); + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + pack(); + } + + + protected void rejectJobs() { + ArrayList<Integer> selectedDevices = new ArrayList<Integer>(); + for(int j = 0; j < jobsTable.getRowCount(); j++) + { + if(jobsTable.getValueAt(j, 0).toString().equalsIgnoreCase("true")) // get all the selected rows + { + selectedDevices.add(j); // adds row # for all selected rows. + } + } + if (selectedDevices.size() >= 0) + { + String[] choices = {"Insufficient material balance", "Invalid file", "Other - See instructor"}; + String description = (String) JOptionPane.showInputDialog(null, "Choose reason:", + "Select Reason for Rejecting", JOptionPane.QUESTION_MESSAGE, null, choices, choices[2]); + + String file = (String) jobsModel.getValueAt(selectedDevices.get(0), 1); + + boolean success = UtilController.rejectStudentSubmission(file, description); + + if (success) // always rejects, commenting out email utlity for now ~Alex + { + JOptionPane op = new JOptionPane("Submission rejected.", JOptionPane.INFORMATION_MESSAGE); + JDialog dialog = op.createDialog("Job Manager: Submission Rejected"); + dialog.setAlwaysOnTop(true); + dialog.setModal(true); + dialog.setDefaultCloseOperation(JDialog.DISPOSE_ON_CLOSE); + dialog.setVisible(true); + + jobsModel.fireTableDataChanged(); + jobStatusCombo.setSelectedIndex(1); + jobsTable.repaint(); + + } else { + JOptionPane.showMessageDialog(new JFrame(), "Something went wrong! You shouldn't see this, ever!"); + } + } else { + JOptionPane.showMessageDialog(new JFrame(), "Please select a submission file to reject!"); + } + } + + private void toggleButtons(boolean status) // toggles the approve,reject,review buttons along with stat panel so you can't approve the already approved + { + // ***** + //jobStatPanel.setVisible(status); + //lblFillInData.setVisible(status); + approveButton.setVisible(status); + rejectButton.setVisible(status); + //reviewButton.setVisible(status); + } + + + + protected void approveJobs() { // handles the approveButton + + ArrayList<Integer> selectedDevices = new ArrayList<Integer>(); + for (int j = 0; j < jobsTable.getRowCount(); j++) { + if (jobsTable.getValueAt(j, 0).toString().equalsIgnoreCase("true")) // get all the selected rows + { + selectedDevices.add(j); // adds row # for all selected rows. + } + } + int rowDataLocation; + if (selectedDevices.get(0) != 0) { + rowDataLocation = getSelectedRowNum(jobsModel, selectedDevices.get(0), 0); + } else { + rowDataLocation = 0; + } + + SQLMethods dbconn = new SQLMethods(); + String first_name = (String) jobsModel.getValueAt(rowDataLocation, 2); + String last_name = (String) jobsModel.getValueAt(rowDataLocation, 3); + String id = dbconn.getStudentId(first_name, last_name); + String printer = dbconn.getFilePrinter((String) jobsModel.getValueAt(rowDataLocation, 1), id); + dbconn.closeDBConnection(); + + /* + * Hand off the data in the selected row found in our tablemodel to this + * method so we can approve the correct file to be printed... -Nick + */ + if (printer.equalsIgnoreCase("Objet Desktop 30")) { + double stat1 = Double.parseDouble(trackingStatInput1.getText()); + double stat2 = Double.parseDouble(trackingStatInput2.getText()); + + // This variable tracks whether the student's submission would push them into a negative balance on their account. + boolean wouldBeNegative; + wouldBeNegative = UtilController.checkNegativeBalance(printer, id, stat1, stat2); + + if(wouldBeNegative == true) + { + String message = "Completing this job would reduce the student's balance of a material to below 0.\n\nWould you like to proceed?"; + int reply = JOptionPane.showConfirmDialog(null, message, "Negative Balance Warning", JOptionPane.YES_NO_OPTION); + if (reply == JOptionPane.YES_OPTION) { + // YES - Proceed and reduce their balance + // Updates transaction history + UtilController.changeStudentBalance(printer, id, stat1, stat2); + UtilController.changeStudentBalanceHistory(printer, id, stat1, stat2); + } + else { + // NO - Do not proceed + // Exit method + return; + } + } + // No negative balance issues -> proceed as usual: + else + { + // Updates transaction history + UtilController.changeStudentBalance(printer, id, stat1, stat2); + UtilController.changeStudentBalanceHistory(printer, id, stat1, stat2); + } + } + else if (printer.equalsIgnoreCase("Z Printer 250")) { + double stat1 = Double.parseDouble(trackingStatInput1.getText()); + double stat2 = 0; + + // This variable tracks whether the student's submission would push them into a negative balance on their account. + boolean wouldBeNegative; + wouldBeNegative = UtilController.checkNegativeBalance(printer, id, stat1, stat2); + + if(wouldBeNegative == true) + { + String message = "Completing this job would reduce the student's balance of a material to below 0.\n\nWould you like to proceed?"; + int reply = JOptionPane.showConfirmDialog(null, message, "Negative Balance Warning", JOptionPane.YES_NO_OPTION); + if (reply == JOptionPane.YES_OPTION) { + // YES - Proceed and reduce their balance + // Updates transaction history + UtilController.changeStudentBalance(printer, id, stat1, stat2); + UtilController.changeStudentBalanceHistory(printer, id, stat1, stat2); + } + else { + // NO - Do not proceed + // Exit method + return; + } + } + // No negative balance issues -> proceed as usual: + else + { + // Updates transaction history + UtilController.changeStudentBalance(printer, id, stat1, stat2); + UtilController.changeStudentBalanceHistory(printer, id, stat1, stat2); + } + } + UtilController.approveStudentSubmission((String) jobsModel.getValueAt(rowDataLocation, 1), + trackingStatInput1.getText(), trackingStatInput2.getText()); + JOptionPane op = new JOptionPane("Submission successfully approved.", JOptionPane.INFORMATION_MESSAGE); + trackingStatInput1.setText(""); + trackingStatInput2.setText(""); + jobsModel.fireTableDataChanged(); + jobStatusCombo.setSelectedIndex(0); // ***** + jobsTable.repaint(); + + jobsModel.fireTableDataChanged(); + jobsTable.repaint(); + } + + public static int getSelectedRowNum(DefaultTableModel dm, int selectedRow, int column) + { + if (selectedRow < 0) + { + return -1; + } + + for (int i = 0; i < dm.getRowCount(); i++) + { + if (dm.getValueAt(i, column).equals(dm.getValueAt(selectedRow, column))) + { + return i; + } + } + + return -1; + } + + + protected void openInDefaultProgram(MouseEvent evt) { + ArrayList<Integer> selectedDevices = new ArrayList<Integer>(); + for(int j = 0; j < jobsTable.getRowCount(); j++) + { + if(jobsTable.getValueAt(j, 0).toString().equalsIgnoreCase("true")) // get all the selected rows + { + selectedDevices.add(j); // adds row # for all selected rows. + } + } + + if (selectedDevices.size() > -1) + { + int rowDataLocation = getSelectedRowNum(jobsModel, selectedDevices.get(0), 0); + + + File fileLocation = UtilController.getFilePath( + (String) jobsModel.getValueAt(rowDataLocation, 2), + (String) jobsModel.getValueAt(rowDataLocation, 3), + (String) jobsModel.getValueAt(rowDataLocation, 1), + (String) jobsModel.getValueAt(rowDataLocation, 4) + );//jobsModel.addRow(new Object[] {(Boolean) false, fileName, fName, lName, date, className, classSection }); + + UtilController.checkFileExists(fileLocation.getPath()); + try + { + Desktop.getDesktop().open(fileLocation); + } catch (IOException ex) + { + Logger.getLogger(JobsView.class.getName()).log(Level.SEVERE, null, ex); + } + } else + { + JOptionPane.showMessageDialog(new JFrame(), "Please select a file to review!"); + } + } + + protected void updateJobWindow(final String selectedDevice) { // used to display all jobs according to device + + showDeviceStats(selectedDevice); // used to display stat tracking relating to device. + + ArrayList rows = new ArrayList(); + jobsModel.setRowCount(0); + jobsTable.repaint(); + /// Adds tracked devices to comboBox dropdown window + Thread runner = new Thread() { + public void run() + { + try { + SQLMethods dbconn = new SQLMethods(); + System.out.println("Trying to find " + selectedDevice); + ResultSet queryResult; + + + if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("Pending")) + { + queryResult = dbconn.searchJobsStatusPrinter("pending", selectedDevice); + //**** + reviewButton.setVisible(true); + } + else if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("Rejected")) + { + queryResult = dbconn.searchJobsStatusPrinter("rejected", selectedDevice); + //**** + approveButton.setVisible(false); + rejectButton.setVisible(false); + } + else + { + queryResult = null; + } + + + //**** work here + if(classCombo.getSelectedItem().toString().equalsIgnoreCase("ART 101")) + { + queryResult = dbconn.searchJobsStatus("ART 101"); + //**** + reviewButton.setVisible(true); + } + //else if(classCombo.getSelectedItem().toString().equalsIgnoreCase("COSC 412")) + //{ + //queryResult = dbconn.searchJobsStatusPrinter("rejected", selectedDevice); + //**** + //approveButton.setVisible(false); + //rejectButton.setVisible(false); + //} + + // + + while(queryResult.next()) + { + int jobId = queryResult.getInt(1); + String fileName = queryResult.getString(2); + String fName = queryResult.getString(3); + String lName = queryResult.getString(4); + String date = queryResult.getString(5); + String deviceName = queryResult.getString(6); + String className = queryResult.getString(7); + String classSection = queryResult.getString(8); + String balance1 = queryResult.getString(9); + String balance2 = queryResult.getString(10); + String balance3 = queryResult.getString(11); + System.out.println("Adding row..."); + if (selectedDevice.equalsIgnoreCase("Z Printer 250")) + { + jobsModel.setColumnCount(8); + jobsModel.setColumnIdentifiers(new String[] { + //**** + "Selected?", "File Name", "First Name", "Last Name", "Date", "Class", "Section", "Z Corp Plaster"}); + jobsModel.addRow(new Object[] {(Boolean) false, fileName, fName, lName, date, className, classSection, balance1}); + } else if (selectedDevice.equalsIgnoreCase("Objet Desktop 30")) + { + jobsModel.setColumnCount(9); + jobsModel.setColumnIdentifiers(new String[] { + "Selected?", "File Name", "First Name", "Last Name", "Date", "Class", "Section", "Oject Build", "Oject Support"}); + jobsModel.addRow(new Object[] {(Boolean) false, fileName, fName, lName, date, className, classSection, balance2, balance3}); + } else + { + jobsModel.setColumnCount(7); + jobsModel.setColumnIdentifiers(new String[] { + "Selected?", "File Name", "First Name", "Last Name", "Date", "Class", "Section"}); + jobsModel.addRow(new Object[] {(Boolean) false, fileName, fName, lName, date, className, classSection}); + } + + } + jobsTable.setModel(jobsModel); + jobsTable.repaint(); + dbconn.closeDBConnection(); + + + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + }; + runner.run(); + } + + + private void showDeviceStats(String selectedDevice) { // used to update + + // ***** + if(jobStatusCombo.getSelectedItem().toString().equalsIgnoreCase("Pending") && + (selectedDevice.equals("Objet Desktop 30") || selectedDevice.equals("Z Printer 250"))) + { + + jobStatPanel.setVisible(true); + lblFillInData.setVisible(true); + deviceNameLabel.setText(selectedDevice); + + /* + if(selectedDevice.equals("Laser Printer")) { // hard coding these quick and dirttay + trackingStatLabel1.setText("Material"); + trackingStatLabel2.setText("Cut Time (H:M:S)"); + } + */ + if(selectedDevice.equals("Objet Desktop 30")) { // hard coding these quick and dirttay + trackingStatLabel1.setText("Build material (g)"); + trackingStatLabel2.setText("Support material (g)"); + trackingStatLabel2.setVisible(true); + trackingStatInput2.setVisible(true); + } + /*else if(selectedDevice.equals("Solidscape R66+")) + { + trackingStatLabel1.setText("Build Time"); + trackingStatLabel2.setText("Resolution"); + }*/ + else if(selectedDevice.equals("Z Printer 250")) + { + trackingStatLabel1.setText("Volume (cubic in)"); + trackingStatLabel2.setVisible(false); + trackingStatInput2.setVisible(false); + // *** *** Fix needed + } + else if(selectedDevice.equals(" ") || selectedDevice.equals("")) + { + jobStatPanel.setVisible(false); + lblFillInData.setVisible(false); + } + else + { + jobStatPanel.setVisible(false); + lblFillInData.setVisible(false); + } + + } + else + { + jobStatPanel.setVisible(false); + lblFillInData.setVisible(false); + } + + } + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_balanceActionPerformed(java.awt.event.ActionEvent evt) + { + balanceView= new BalanceView(); + balanceView.setVisible(true); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new newSettingsMenu(); + adminSettingsView.setVisible(true); + dispose(); + + } + + private void logout() + { + MainView mv = new MainView(); + mv.setVisible(true); + dispose(); + } + + + + /////// Nav Bar ~Alex ///// + // --nav bar vars ~Alex + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_balance; + private JButton navBtn_settings; + + /// + // etc vars + // + private JPanel jobStatPanel; + private JPanel jobListingsPane; + private JTextField trackingStatInput1; + private JTextField trackingStatInput2; + private JLabel trackingStatLabel1; + private JLabel trackingStatLabel2; + private JLabel deviceNameLabel; + private JLabel lblFillInData; + private JTable jobsTable; + private DefaultTableModel jobsModel; + private JComboBox jobStatusCombo; + private JButton approveButton; + private JButton rejectButton; + private JButton reviewButton; + //**** + private JComboBox classCombo; + private JComboBox sectionCombo; + // + //****NOT NEEDED -cesar + //private JButton selectallButton; + //private JButton deselectallButton; + // +} \ No newline at end of file diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newSettingsMenu.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newSettingsMenu.java new file mode 100644 index 0000000..b1d7707 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newSettingsMenu.java @@ -0,0 +1,256 @@ +package ObjectLabEnterpriseSoftware; + +import javax.swing.JFrame; + +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Font; +import javax.swing.JLabel; +import javax.swing.JMenuBar; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.UIManager; +import java.awt.Toolkit; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.event.ActionListener; +import java.awt.event.ActionEvent; + +public class newSettingsMenu extends JFrame { + private UtilController controller; + // --nav bar views ~Alex + private BuildView buildView; + private newJobsMgr jobsView; + private ReportsView reportsView; + private BalanceView balanceView; + private newSettingsMenu adminSettingsView; + // --nav bar vars ~Alex + private JButton navBtn_jobsMgr; + private JButton navBtn_build; + private JButton navBtn_reports; + private JButton navBtn_balance; + private JButton navBtn_settings; + + // Return to main view after logout + private static MainView home = new MainView(); + + + public newSettingsMenu() { + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setPreferredSize(new Dimension(560, 300)); + setIconImage(Toolkit.getDefaultToolkit().getImage(newSettingsMenu.class.getResource("/ObjectLabEnterpriseSoftware/images/icon.ico"))); + setResizable(false); + setFont(new Font("Segoe UI", Font.PLAIN, 14)); + setTitle("Settings"); + getContentPane().setLayout(null); + getContentPane().setBackground(Color.WHITE); + + JLabel titleLabel = new JLabel("Settings"); + titleLabel.setFont(new Font("Segoe UI", Font.PLAIN, 24)); + titleLabel.setBounds(235, 11, 92, 55); + getContentPane().add(titleLabel); + + JMenuBar jMenuBar1 = new JMenuBar(); + setJMenuBar(jMenuBar1); + + jMenuBar1.setPreferredSize(new Dimension(200, 30)); + setJMenuBar(jMenuBar1); + + navBtn_jobsMgr = new JButton("Jobs Manager"); + navBtn_jobsMgr.setFont(new Font("Tahoma", Font.PLAIN, 12)); + navBtn_jobsMgr.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/view_file_icon.png"))); + navBtn_jobsMgr.setPreferredSize(new Dimension(100,24)); + jMenuBar1.add(navBtn_jobsMgr); + + navBtn_build = new JButton("Enter Build"); + navBtn_build.setFont(new Font("Tahoma", Font.PLAIN, 12)); + navBtn_build.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/hammer_icon.png"))); + + navBtn_build.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_build); + + navBtn_reports = new JButton("Reports"); + navBtn_reports.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/reports_icon.png"))); + navBtn_reports.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_reports); + + navBtn_balance = new JButton("Balance"); + navBtn_balance.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/stats_icon.png"))); + navBtn_balance.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_balance); + + navBtn_settings = new JButton("Settings"); + navBtn_settings.setIcon(new ImageIcon(JobsView.class.getResource("/ObjectLabEnterpriseSoftware/images/cog_icon.png"))); + navBtn_settings.setPreferredSize(new Dimension(100,24)); + + jMenuBar1.add(navBtn_settings); + getContentPane().setLayout(null); + + navBtn_jobsMgr.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_jobsMgrActionPerformed(evt); + } + }); + + navBtn_build.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_buildActionPerformed(evt); + } + }); + + navBtn_reports.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_reportsActionPerformed(evt); + } + }); + + navBtn_balance.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_balanceActionPerformed(evt); + } + }); + + navBtn_settings.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + navBtn_settingsActionPerformed(evt); + } + }); + + + + + + + + + + + + + + + + + + + + + JButton btnManageClasses = new JButton("Manage Classes"); + btnManageClasses.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + ClassMgr cm = new ClassMgr(); + cm.setVisible(true); + dispose(); + } + }); + btnManageClasses.setFont(new Font("Segoe UI Light", Font.PLAIN, 12)); + btnManageClasses.setBounds(220, 77, 121, 23); + getContentPane().add(btnManageClasses); + + JButton btnManageDevices = new JButton("Manage Devices"); + btnManageDevices.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + DeviceMgr dv = new DeviceMgr(); + dv.setVisible(true); + dispose(); + } + }); + btnManageDevices.setFont(new Font("Segoe UI Light", Font.PLAIN, 12)); + btnManageDevices.setBounds(220, 111, 121, 23); + getContentPane().add(btnManageDevices); + + JButton btnUserGuide = new JButton("User Guide"); + btnUserGuide.addMouseListener(new MouseAdapter() { + @Override + public void mouseClicked(MouseEvent arg0) { + controller.openAdminHelpPage(); + } + }); + btnUserGuide.setFont(new Font("Segoe UI Light", Font.PLAIN, 12)); + btnUserGuide.setBounds(220, 145, 121, 23); + getContentPane().add(btnUserGuide); + + + JButton btnLogout = new JButton("Logout"); + btnLogout.setFont(new Font("Segoe UI Light", Font.PLAIN, 12)); + btnLogout.setBounds(10, 200, 95, 23); + getContentPane().add(btnLogout); + btnLogout.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + logoutButtonActionPerformed(evt); + } + }); + + pack(); + setLocationRelativeTo(null); + final newJobsMgr njm = new newJobsMgr(); + addWindowListener( + new WindowAdapter() + { + @Override + public void windowClosing(WindowEvent we) + { + njm.setVisible(true); + dispose(); + } + } + ); + } + + private void navBtn_jobsMgrActionPerformed(java.awt.event.ActionEvent evt) + { + jobsView = new newJobsMgr(); + jobsView.setVisible(true); + dispose(); + + } + + private void navBtn_buildActionPerformed(java.awt.event.ActionEvent evt) + { + buildView = new BuildView(); + buildView.startMakeBuildProcess(); + dispose(); + + } + + private void navBtn_reportsActionPerformed(java.awt.event.ActionEvent evt) + { + reportsView = new ReportsView(); + reportsView.ReportsPage(); + dispose(); + + } + + private void navBtn_balanceActionPerformed(java.awt.event.ActionEvent evt) + { + balanceView= new BalanceView(); + balanceView.setVisible(true); + dispose(); + + } + + private void navBtn_settingsActionPerformed(java.awt.event.ActionEvent evt) + { + adminSettingsView = new newSettingsMenu(); + adminSettingsView.setVisible(true); + dispose(); + + } + + + private void logoutButtonActionPerformed(java.awt.event.ActionEvent evt) { //GEN-FIRST:event_logoutButtonActionPerformed + //GEN-HEADEREND:event_logoutButtonActionPerformed + dispose(); + home.setVisible(true); + }//GEN-LAST:event_logoutButtonActionPerformed + + +} diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.form b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.form new file mode 100644 index 0000000..9777b3e --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.form @@ -0,0 +1,316 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.5" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="title" type="java.lang.String" value="Student View"/> + <Property name="name" type="java.lang.String" value="Student View" noResource="true"/> + <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> + <Dimension value="[830, 455]"/> + </Property> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="true"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="88" max="-2" attributes="0"/> + <Component id="jLabel8_StudentSubmission1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="181" max="-2" attributes="0"/> + <Component id="jLabel8_StudentSubmission" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="49" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jLabel5" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jComboBox2" min="-2" pref="175" max="-2" attributes="0"/> + <Component id="jComboBox1" alignment="0" min="-2" pref="175" max="-2" attributes="0"/> + <Component id="jTextField1" alignment="0" min="-2" pref="175" max="-2" attributes="0"/> + </Group> + <EmptySpace min="18" pref="18" max="-2" attributes="0"/> + <Component id="jButton2" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="173" max="-2" attributes="0"/> + <Component id="jButton3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="33" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jScrollPane1" min="-2" pref="375" max="-2" attributes="0"/> + <Component id="jScrollPane2" min="-2" pref="375" max="-2" attributes="0"/> + <Group type="102" alignment="1" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="165" max="-2" attributes="0"/> + </Group> + <Component id="jButton1" alignment="1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + <Group type="102" alignment="1" attributes="0"> + <EmptySpace min="0" pref="0" max="32767" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="159" max="-2" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace max="32767" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jLabel8_StudentSubmission1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel8_StudentSubmission" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="39" max="-2" attributes="0"/> + <Component id="jLabel2" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jScrollPane2" min="-2" pref="43" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboBox1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + <EmptySpace max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jScrollPane1" min="-2" pref="184" max="-2" attributes="0"/> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="17" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jTextField1" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel5" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jButton3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jComboBox2" alignment="3" min="-2" max="-2" attributes="0"/> + <Component id="jLabel4" alignment="3" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel8_StudentSubmission"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Information"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel8_StudentSubmission1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="24" style="1"/> + </Property> + <Property name="text" type="java.lang.String" value="Student Submission"/> + </Properties> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane1"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable1"> + <Properties> + <Property name="autoCreateRowSorter" type="boolean" value="true"/> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="4"> + <Column editable="false" title="File Name" type="java.lang.Object"/> + <Column editable="false" title="Date " type="java.lang.Object"/> + <Column editable="false" title="Comment" type="java.lang.Object"/> + <Column editable="false" title="Status" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Logout"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton1MousePressed"/> + </Events> + </Component> + <Container class="javax.swing.JScrollPane" name="jScrollPane2"> + <AuxValues> + <AuxValue name="autoScrollPane" type="java.lang.Boolean" value="true"/> + </AuxValues> + + <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> + <SubComponents> + <Component class="javax.swing.JTable" name="jTable2"> + <Properties> + <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> + <Table columnCount="4" rowCount="1"> + <Column editable="false" title="Towson Id" type="java.lang.Object"/> + <Column editable="false" title="Z Corp Plaster" type="java.lang.Object"/> + <Column editable="false" title="Objet Build" type="java.lang.Object"/> + <Column editable="false" title="Objet Support" type="java.lang.Object"/> + </Table> + </Property> + <Property name="columnModel" type="javax.swing.table.TableColumnModel" editor="org.netbeans.modules.form.editors2.TableColumnModelEditor"> + <TableColumnModel selectionModel="0"> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="false" resizingAllowed="true"/> + </Property> + </Properties> + <Events> + <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jTable2MouseClicked"/> + </Events> + </Component> + </SubComponents> + </Container> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="text" type="java.lang.String" value="File Status"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel2"> + <Properties> + <Property name="text" type="java.lang.String" value="Material Balance"/> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox1"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableClasses())" type="code"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JComboBox" name="jComboBox2"> + <Properties> + <Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.RADConnectionPropertyEditor"> + <Connection code="new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableDevicesStudentSubmissionRequired())" type="code"/> + </Property> + </Properties> + </Component> + <Component class="javax.swing.JTextField" name="jTextField1"> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="text" type="java.lang.String" value="Browse"/> + </Properties> + <Events> + <EventHandler event="mousePressed" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="jButton2MousePressed"/> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="text" type="java.lang.String" value="Submit"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JLabel" name="jLabel3"> + <Properties> + <Property name="text" type="java.lang.String" value="Class:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel4"> + <Properties> + <Property name="text" type="java.lang.String" value="Printer:"/> + </Properties> + </Component> + <Component class="javax.swing.JLabel" name="jLabel5"> + <Properties> + <Property name="text" type="java.lang.String" value="File Location:"/> + </Properties> + </Component> + </SubComponents> +</Form> diff --git a/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.java b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.java new file mode 100644 index 0000000..1c16421 --- /dev/null +++ b/ObjectLabSoftware/src/ObjectLabEnterpriseSoftware/newStudentView.java @@ -0,0 +1,611 @@ +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +package ObjectLabEnterpriseSoftware; + +import javax.swing.JFileChooser; +import javax.swing.JOptionPane; +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Component; +import java.awt.Dimension; +import java.awt.EventQueue; +import java.awt.Point; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.awt.dnd.DnDConstants; +import java.awt.dnd.DropTarget; +import java.awt.dnd.DropTargetDragEvent; +import java.awt.dnd.DropTargetDropEvent; +import java.io.File; +import java.io.IOException; +import java.sql.ResultSet; +import java.util.ArrayList; +import java.util.List; +import javax.swing.Box; +import javax.swing.ImageIcon; +import javax.swing.JButton; +import javax.swing.table.DefaultTableModel; + +import org.apache.commons.io.FilenameUtils; + +import javax.sql.*; +import javax.swing.JLabel; +import javax.swing.JPanel; +import javax.swing.JScrollPane; +import javax.swing.JTable; +import javax.swing.SwingConstants; +/** + * + * @author Russell + */ +public class newStudentView extends javax.swing.JFrame { + private static final String NAME_OF_PAGE = "Student View"; + private static DefaultTableModel model; + private static DefaultTableModel model2; + private static final MainView home = new MainView(); + private MaterialTransactionHistoryView materialTransView; + private JPanel contentPane; + private JTable table; + private String userID; + private String userName; + private String projName; + + public newStudentView() + { + //newStudentView("sturne18", "Scott"); + } + public void newStudentView(String id, String studentName) { + getContentPane().setBackground(Color.WHITE); + setTitle("Student View"); + initComponents(); + //jTable3.setVisible(false); + //scrollPane_3.setVisible(false); + //initDragDrop(); + userID = id; + userName = studentName; + model = (DefaultTableModel) jTable1.getModel(); + model2 = (DefaultTableModel) jTable2.getModel(); + updateFileStatusWindow(id, studentName); + updateMaterialWindow(id, studentName); + setVisible(true); + } + public void updateMaterialWindow(String id, String studentName) { + model2.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentInfo(id); + + while(queryResult.next()) + { + String towson_id = queryResult.getString(1); + String material1 = queryResult.getString(2); + String material2 = queryResult.getString(3); + String material3 = queryResult.getString(4); + System.out.println("Adding row..."); + model2.addRow(new Object[] {towson_id, material1, material2, material3}); + } + jTable2.setModel(model2); + jTable2.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + public void updateFileStatusWindow(String id, String studentName) { + model.setRowCount(0); + + try { + SQLMethods dbconn = new SQLMethods(); + ResultSet queryResult; + + queryResult = dbconn.getStudentFileStatus(id); + + while(queryResult.next()) + { + String file_name = queryResult.getString(1); + String date = queryResult.getString(2); + String comment = queryResult.getString(3); + String status = queryResult.getString(4); + System.out.println("Adding row..."); + model.addRow(new Object[] {file_name, date, comment, status}); + } + jTable1.setModel(model); + jTable1.repaint(); + dbconn.closeDBConnection(); + } catch(Exception e) + { + System.out.println("Error: " + e); + } + } + + public static void main(String args[]) { + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + EventQueue.invokeLater(new Runnable() { + public void run() { + try { + newStudentView frame = new newStudentView(); + frame.setVisible(true); + } catch (Exception e) { + e.printStackTrace(); + } + } + }); + } + }); + } + + // private void initDragDrop() + //{ + /*JScrollPane scrollPane_3 = new JScrollPane((Component) null); + contentPane = new JPanel(); + scrollPane_3.setBounds(65, 220, 320, 150); + contentPane.add(scrollPane_3); + table = new JTable(); + // # rows from start + table.setModel(new DefaultTableModel(new Object[][] {}, + // Column Name + new String[] {"File Name", "File Path"})); + table.setAutoCreateRowSorter(true); + scrollPane_3.setViewportView(table); + table.setShowGrid(true); + table.setShowHorizontalLines(true); + table.setShowVerticalLines(true); + table.setGridColor(Color.GRAY); + + table.setFillsViewportHeight(true); + table.setPreferredSize(new Dimension(320, 150));*/ + + /* + jTable3.setDropTarget(new DropTarget() { + @Override + public synchronized void dragOver(DropTargetDragEvent dtde) { + Point point = dtde.getLocation(); + int row = jTable3.rowAtPoint(point); + if (row < 0) { + jTable3.clearSelection(); + } else { + jTable3.setRowSelectionInterval(row, row); + } + dtde.acceptDrag(DnDConstants.ACTION_COPY_OR_MOVE); + } + + @Override + public synchronized void drop(DropTargetDropEvent dtde) { + if (dtde.isDataFlavorSupported(DataFlavor.javaFileListFlavor)) { + dtde.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE); + Transferable t = dtde.getTransferable(); + List fileList = null; + try { + fileList = (List) t.getTransferData(DataFlavor.javaFileListFlavor); + if (fileList.size() > 0) { + jTable3.clearSelection(); + Point point = dtde.getLocation(); + int row = jTable3.rowAtPoint(point); + DefaultTableModel model = (DefaultTableModel) jTable3.getModel(); + for (Object value : fileList) { + if (value instanceof File) { + File f = (File) value; + + if (row < 0) { + model.addRow(new Object[]{f.getName(), f.getAbsolutePath()}); + } else { + model.insertRow(row, new Object[]{f.getName(), f.getAbsolutePath()}); + row++; + } + } + } + } + } catch (UnsupportedFlavorException e) { + e.printStackTrace(); + } catch (IOException e) { + e.printStackTrace(); + } + } else { + dtde.rejectDrop(); + } + } + + }); + + getContentPane().add(scrollPane_3, BorderLayout.CENTER); + } + */ + + /** + * 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() { + + jLabel8_StudentSubmission = new javax.swing.JLabel(); + jLabel8_StudentSubmission1 = new javax.swing.JLabel(); + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jButton1 = new javax.swing.JButton(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTable2 = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jComboBox1 = new javax.swing.JComboBox(); + jComboBox2 = new javax.swing.JComboBox(); + jTextField1 = new javax.swing.JTextField(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + jLabel4 = new javax.swing.JLabel(); + jLabel5 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setTitle("Student View"); + setName("Student View"); // NOI18N + setPreferredSize(new java.awt.Dimension(830, 455)); + + jLabel8_StudentSubmission.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel8_StudentSubmission.setText("Student Information"); + + jLabel8_StudentSubmission1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N + jLabel8_StudentSubmission1.setText("Student Submission"); + + jTable1.setAutoCreateRowSorter(true); + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "File Name", "Date ", "Comment", "Status" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable1.getTableHeader().setReorderingAllowed(false); + jScrollPane1.setViewportView(jTable1); + + jButton1.setText("Logout"); + jButton1.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton1MousePressed(evt); + } + }); + + jTable2.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null} + }, + new String [] { + "Towson Id", "Z Corp Plaster", "Objet Build", "Objet Support" + } + ) { + boolean[] canEdit = new boolean [] { + false, false, false, false + }; + + public boolean isCellEditable(int rowIndex, int columnIndex) { + return canEdit [columnIndex]; + } + }); + jTable2.getTableHeader().setReorderingAllowed(false); + jTable2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mouseClicked(java.awt.event.MouseEvent evt) { + jTable2MouseClicked(evt); + } + }); + jScrollPane2.setViewportView(jTable2); + + jLabel1.setText("File Status"); + + jLabel2.setText("Material Balance"); + + jComboBox1.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableClasses())); + + jComboBox2.setModel(new javax.swing.DefaultComboBoxModel((String []) UtilController.returnAvailableDevicesStudentSubmissionRequired())); + + jButton2.setText("Browse"); + jButton2.addMouseListener(new java.awt.event.MouseAdapter() { + public void mousePressed(java.awt.event.MouseEvent evt) { + jButton2MousePressed(evt); + } + }); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText("Submit"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jLabel3.setText("Class:"); + + jLabel4.setText("Printer:"); + + jLabel5.setText("File Location:"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(88, 88, 88) + .addComponent(jLabel8_StudentSubmission1) + .addGap(181, 181, 181) + .addComponent(jLabel8_StudentSubmission)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(49, 49, 49) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jLabel5) + .addComponent(jLabel3) + .addComponent(jLabel4)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(18, 18, 18) + .addComponent(jButton2)) + .addGroup(layout.createSequentialGroup() + .addGap(173, 173, 173) + .addComponent(jButton3))) + .addGap(33, 33, 33) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 375, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addGap(165, 165, 165)) + .addComponent(jButton1)))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(0, 0, Short.MAX_VALUE) + .addComponent(jLabel2) + .addGap(159, 159, 159)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel8_StudentSubmission1) + .addComponent(jLabel8_StudentSubmission)) + .addGap(39, 39, 39) + .addComponent(jLabel2) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel3))) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 184, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGroup(layout.createSequentialGroup() + .addGap(17, 17, 17) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2) + .addComponent(jLabel5)) + .addGap(18, 18, 18) + .addComponent(jButton3))) + .addGap(18, 18, 18) + .addComponent(jButton1)) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jComboBox2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jLabel4))) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + + pack(); + setLocationRelativeTo(null); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton1MousePressed + dispose(); + home.setVisible(true); // TODO add your handling code here: + }//GEN-LAST:event_jButton1MousePressed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton2MousePressed(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jButton2MousePressed + //Creates "JFileChooser" file browser + JFileChooser fileopen = new JFileChooser(); + File desktop = new File(System.getProperty("user.home") + "\\Desktop"); + fileopen.setCurrentDirectory(desktop); + //in brackets, add Syncthing directory or new Drive's address for default location + fileopen.setAcceptAllFileFilterUsed(false); + fileopen.setMultiSelectionEnabled(false); + //FileNameExtensionFilter filter = new FileNameExtensionFilter("Object Files", "obj", "zpr", "stl"); + //fileopen.setFileFilter(filter); + int ret = fileopen.showDialog(null, "Open file"); + + if (ret == JFileChooser.APPROVE_OPTION) + { + File file = fileopen.getSelectedFile(); + //Inputs the file location into the textbox "fileName" + jTextField1.setText(file.toString().replaceAll("'", "")); + String projectFileName = file.getName().replaceAll("'", ""); + String finalProjectFileName = projectFileName.replaceAll("(\\.\\S+?$)", UtilController.getCurrentTimeFromDB() + "$1"); + projName = finalProjectFileName; + } + }//GEN-LAST:event_jButton2MousePressed + + + private boolean errCheck() + { + String fullFilePath = jTextField1.getText(); + String fileName = projName; + String printer = (String) jComboBox2.getSelectedItem(); + /* parse classBox string and pull out the primary key and store it in an integer */ + String classText = (String) jComboBox1.getSelectedItem(); + + boolean isErr = false; + //hideErrorFields(); + if (fullFilePath == null || fullFilePath == "") + { + JOptionPane.showMessageDialog(null, "Select a file.", "File Choice Empty", JOptionPane.ERROR_MESSAGE); + isErr = true; + } + + //End Email Validation + else if (jComboBox1.getSelectedIndex() == -1) + { + JOptionPane.showMessageDialog(null, "Select a class.", "Class Choice Empty", JOptionPane.ERROR_MESSAGE); + isErr = true; + } + + else if (jComboBox2.getSelectedIndex() == -1) + { + JOptionPane.showMessageDialog(null, "Select a device.", "Device Choice Empty", JOptionPane.ERROR_MESSAGE); + isErr = true; + } + + else if (extensionCheck() == false) + { + //JOptionPane.showMessageDialog(null, "Your file extension is incorrect. No submission has occured.", + // "Invalid Submission", JOptionPane.ERROR_MESSAGE); + int reply = JOptionPane.showConfirmDialog(null, "Your file extension doesn't match the normally accepted file extensions for this printer.\n\nWould you like to proceed with submitting your file?", + "Abnormal File Extension", JOptionPane.YES_NO_OPTION); + if (reply == JOptionPane.NO_OPTION) { + // Abort submission + isErr = true; + } + else if(reply == JOptionPane.YES_OPTION){ + // Allow submission to continue + } + } + return isErr; + } + + private boolean extensionCheck() + { + boolean isValidExtension = false; + + String printer = (String) jComboBox2.getSelectedItem(); + String fullFilePath = jTextField1.getText(); + String extension = "." + FilenameUtils.getExtension(fullFilePath); + + isValidExtension = UtilController.checkExtension(printer, extension); + + return isValidExtension; + + } + + // Submit button + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + + // Verifies user and file information is inputted in its entirety + if (errCheck() == false) + { + // Recieve our input from the UI and hand it off to back end to submit / store file information + String fullFilePath, fileName, classText, printer; + int classFK; + + fullFilePath = jTextField1.getText(); + fileName = projName; + printer = (String) jComboBox2.getSelectedItem(); + + // parse classBox string and pull out the primary key and store it in an integer + classText = (String) jComboBox1.getSelectedItem(); + classFK = (Integer.parseInt(classText.split(" ")[0])); + + UtilController.submitStudentFile(userID, fullFilePath, fileName, printer, classFK); + + JOptionPane.showMessageDialog(new java.awt.Frame(), "Successfully submitted file! Let your professor or lab assistant know you've submitted."); + dispose(); + + //Reset view after successful submission to allow for multiple submissions without having to login each time + Reset_StudentSubmissionFields(); + updateFileStatusWindow(userID, userName); + } + else + { + dispose(); + Reset_StudentSubmissionFields(); + } + } + + private void Reset_StudentSubmissionFields() + { + setVisible(false); + jTextField1.setText(null); + //projName.setText(null); + //classBox.setSelectedItem(null); + //printerBox.setSelectedItem(null); + setVisible(true); // TODO add your handling code here: + }//GEN-LAST:event_jButton3ActionPerformed + + private void jTable2MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTable2MouseClicked + JTable table =(JTable) evt.getSource(); + Point p = evt.getPoint(); + int row = table.rowAtPoint(p); + if (evt.getClickCount() == 2) { + // double-click a row + System.out.println("double clicked..."); + //System.out.println(table.getValueAt(table.getSelectedRow(), 0).toString()); + + //String fName = table.getValueAt(table.getSelectedRow(), 0).toString(); + //String lName = table.getValueAt(table.getSelectedRow(), 1).toString(); + //String id = table.getValueAt(table.getSelectedRow(), 2).toString(); + + materialTransView = new MaterialTransactionHistoryView(); + materialTransView.showHistory(userName, UtilController.getStudentLname(), userID); + //dispose(); + } // TODO add your handling code here: + }//GEN-LAST:event_jTable2MouseClicked + + + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JComboBox jComboBox1; + private javax.swing.JComboBox jComboBox2; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JLabel jLabel4; + private javax.swing.JLabel jLabel5; + private javax.swing.JLabel jLabel8_StudentSubmission; + private javax.swing.JLabel jLabel8_StudentSubmission1; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTable jTable1; + private javax.swing.JTable jTable2; + private javax.swing.JTextField jTextField1; + // End of variables declaration//GEN-END:variables +} diff --git a/SQLMethods.java b/SQLMethods.java new file mode 100644 index 0000000..8270938 --- /dev/null +++ b/SQLMethods.java @@ -0,0 +1,1730 @@ +package ObjectLabEnterpriseSoftware; + +/* + * To change this license header, choose License Headers in Project Properties. + * To change this template file, choose Tools | Templates + * and open the template in the editor. + */ +/** + * FYI I used select * so far in most cases since I don't know what you want it + * limited to. Some refinement will be needed. + * + * @author Database + */ +import java.io.BufferedReader; +import java.io.File; +import java.io.FileReader; +import java.io.IOException; +import java.sql.*; +import java.util.logging.Level; +import java.util.logging.Logger; + +// Notice, do not import com.mysql.jdbc.* +// or you will have problems! +public class SQLMethods +{ + /* Same url and connection to the DB until it is closed */ + + private final String url; + private Connection conn; + private ResultSet res; + private PreparedStatement stmt; + public SQLMethods() + { + // ***** code below is production: + /* To resolve hostname to an IP adr */ + File f = new File(MainView.getStorageDir() + ":\\Sync\\computername.txt"); + + // ***** code below is dev/testing: + //File f = new File("/home/alex/Documents/School/Spring 2016/Software eng/Object-Lab-Interface/computername.txt"); + String line, ip = ""; + + try + { + // FileReader reads text files in the default encoding. + FileReader fileReader = new FileReader(f.getAbsolutePath()); + // Always wrap FileReader in BufferedReader. + BufferedReader bufferedReader = new BufferedReader(fileReader); + + while ((line = bufferedReader.readLine()) != null) + { + ip = line; + } + + // Always close files. + bufferedReader.close(); + } catch (IOException ex) + { + System.out.println("Couldn't read file! IOException!"); + ex.printStackTrace(); + } + + + String host = "db4free.net"; + String port = "3306"; + String user = "oliadminuser"; + String pass = "olipass"; + String db = "olidatabase"; + String driver = "com.mysql.jdbc.Driver"; + + url = "jdbc:mysql://" + host + ":" + port + "/" + db; + connectToDatabase(driver, url, user, pass); + + /** Local DB Connection + * Not using this anymore, but leaving it here in case + * the need arises later. + String driver = "com.mysql.jdbc.Driver"; + String user = "root"; + String pass = "toor"; + connectToDatabase(driver, "jdbc:mysql://localhost/sys", user, pass); + */ + } + + private void connectToDatabase(String driver, String urlDatabaseName, String userName, String pw) + { + try + { + Class.forName(driver).newInstance(); + conn = DriverManager.getConnection(urlDatabaseName, userName, pw); + } + catch (ClassNotFoundException e) + { + System.out.println("Driver class not found / created. Exception!\n" + e); + } + catch (InstantiationException | IllegalAccessException | SQLException e) + { + System.out.println(e); + } + } + + public void closeDBConnection() + { + try + { + conn.close(); + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + // Begining of Select Methods + // _______________________________________________________________________________________________________________________ + public ResultSet selectAllFromTable(String table) + {// select entire table + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM " + table + ";"); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectAllPrintStatus(String status) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM job WHERE status = ?;"); + stmt.setString(1, status); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectFileInfo(int jobid) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT file_name, file_path FROM job WHERE job_id = ?;"); + stmt.setInt(1, jobid); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet searchPrinterFilesTypes(String printer) + {// selects the filetypes for the printer + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT file_extension FROM printer WHERE printer_name = ?;"); + stmt.setString(1, printer); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet searchJobsStatusPrinter(String status, String printer) // returns filename,first name,lastname ,submission_date, printer for based off status and printer + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + + "job.submission_date ,job.printer_name, class_name, class_section " + + "FROM job, users , class " + "WHERE job.status = ? AND printer_name = ? " + + "AND users.towson_id = job.student_id AND job.class_id = class.class_id;"); + stmt.setString(1, status); + stmt.setString(2, printer); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + public ResultSet searchAllJobsStatusPrinter(String printer) // returns filename,first name,lastname ,submission_date, printer for based off status and printer + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT job.job_id, job.file_name, users.first_name, users.last_name, " + + "job.submission_date ,job.printer_name, class_name, class_section " + + "FROM job, users , class " + "WHERE job.status <> ? AND printer_name = ? " + + "AND users.towson_id = job.student_id AND job.class_id = class.class_id;"); + stmt.setString(1, "rejected"); + stmt.setString(2, printer); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + public ResultSet searchJobsStatus(String status) // returns filename,first name,lastname ,submission_date, printer for based off status and printer + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT job.file_name, users.first_name, users.last_name, " + + "job.submission_date ,job.printer_name, class_name, class_section " + + "FROM job, users ,class " + "WHERE job.status = ? " + + "AND users.towson_id = job.student_id AND job.class_id = class.class_id;"); + stmt.setString(1, status); + + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + + + + + + public ResultSet searchPrintersByBuildName(int buildId) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM job WHERE build_id = ?;"); + stmt.setInt(1, buildId); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet selectIDFromJob(String id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM job Where student_id = ?"); + stmt.setString(1, id); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet searchJobsByBuildName(String buildName) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM job, printer_build " + + "WHERE buildName = ? AND printer_build.build_id= Job.build_id;"); + stmt.setString(1, buildName); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchFilePath(String fileName) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT file_path FROM job WHERE file_name = ? ;"); + stmt.setString(1, fileName); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getStudentSubmissionStatusFromDevice(String printer) + { + res = null; + try + { + stmt = this.conn.prepareStatement + ( + "SELECT student_submission " + + "FROM printer " + + "WHERE printer_name = ?" + ); + + stmt.setString(1, printer); + + res = stmt.executeQuery(); + System.out.println(stmt); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet searchPrinterSettings(String printer) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM printer WHERE printer_name = ?"); + + stmt.setString(1, printer); + + res = stmt.executeQuery(); + System.out.println(stmt); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectClasses() + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM class;"); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet selectPassFromadmin(String admin) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT pass FROM admin Where username = ?; "); + stmt.setString(1, admin); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectJobForClass(int classes, String status) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM job Where class_id = ? AND status = ?;"); + stmt.setInt(1, classes); + stmt.setString(2, status); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectColumnNames(String printer) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM custom_printer_column_names WHERE printer_name = ?;"); + stmt.setString(1, printer); + res = stmt.executeQuery(); + + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + /* + This is a method that retrieve custom_field_names from custom_printer_column_names. + I use this to dynamically update the enter build info in the tables + The other methods meant to do this were not working. ~Sean Gahagan + */ + public ResultSet selectDeviceTrackableMetaData(String printer) + { + res = null; + try + { + stmt = this.conn.prepareStatement + ( + "SELECT custom_field_name, numerical FROM custom_printer_column_names WHERE printer_name = ?;" + + ); + + stmt.setString(1, printer); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet selectBuildData(int id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT * FROM column_build_data Where build_id = ? "); + res = stmt.executeQuery(); + stmt.setInt(1, id); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectAcceptedFiles(String printer) + { + + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT file_extension FROM accepted_files Where printer_name = " +printer +";"); + //stmt.setString(1, printer); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectBuildLocation(String printer){ + + //select file_path from jobsdb.job where file_name = 'stuff2_2015-05-06_00-55-42.zpr'; + res = null; + try + { + stmt = this.conn.prepareStatement("select file_path from job where file_name = ?;"); + stmt.setString(1, printer); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + public ResultSet selectTableHeader(String printer) + { + + res = null; + try + { + stmt = this.conn.prepareStatement("SELECT custom_field_name FROM custom_printer_column_name Where printer_name = ?;"); + stmt.setString(1, printer); + res = stmt.executeQuery(); + } catch (SQLException e) + { + System.err.println("SQL Execution Error."); + } + return res; + } + + /* Returns the nubmer of times build file location is found in "table". + -1 is returned on query execution failure. + */ + public int doesBuildFileLocationExist(String table, String buildFileLocation) + { + try + { + stmt = conn.prepareStatement("SELECT COUNT(*) as does_build_flocation_exist FROM " + table + " WHERE build_name = ?;"); + stmt.setString(1, buildFileLocation); + + System.out.println(stmt); + + ResultSet occurrencesOfBuildFileLocation = stmt.executeQuery(); + + if(occurrencesOfBuildFileLocation.next()) + return occurrencesOfBuildFileLocation.getInt("does_build_flocation_exist"); + else + return -1; + + } catch (SQLException e) + { + System.err.println(e); + return -1; + } + } + // END OF SELECT METHODS + // _____________________________________________________________________________________________________________________ + // BEGGINING OF INSERT METHODS + // _____________________________________________________________________________________________________________________ + + public void insertIntoClasses(String className, String classSection, String professor) + { + try + { + stmt = conn.prepareStatement("INSERT INTO class (class_name, class_section, professor) values (?,?,?)"); + stmt.setString(1, className); + stmt.setString(2, classSection); + stmt.setString(3, professor); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void insertIntoJob(String filename, String filePath, int class_id, String user_id, String printer) + { + try + { + System.out.print("Trying to insert into db...~Alex debug"); + stmt = conn.prepareStatement("INSERT INTO job (file_name, file_path, class_id, student_id, printer_name, submission_date, build_Name, status, comment) values (?,?,?,?,?,NOW(),null,'pending',null);"); + stmt.setString(1, filename); + stmt.setString(2, filePath); + stmt.setInt(3, class_id); + stmt.setString(4, user_id); + stmt.setString(5, printer); + stmt.executeUpdate(); + + + + // Adding stat tracking + + + stmt = conn.prepareStatement + ( + "SELECT job_id FROM job WHERE student_id = ? AND file_name = ?" + ); + + stmt.setString(1, user_id); + stmt.setString(2, filename); + + System.out.println(stmt.toString()); + ResultSet res = stmt.executeQuery(); + res.next(); + insertIntoJobStats(res.getInt(1), null, null); + + + } catch (Exception e) + { + e.printStackTrace(); + } + } + + + public void insertIntoJobStats(int id, String stat1, String stat2) + { + try { + stmt = conn.prepareStatement("INSERT INTO job_stats (job_id, stat1, stat2) values (?,NULL,NULL);"); + stmt.setInt(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + + + + + + public void insertIntoPrinter(String printer, boolean submit) + { + try + { + stmt = conn.prepareStatement("INSERT INTO printer (printer_name, student_submission, current) values (?, ?, ?);"); + stmt.setString(1, printer); + stmt.setBoolean(2, submit); + stmt.setInt(3, 1); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public ResultSet checkUserExists(String userID) + { + res = null; + try + { + stmt = conn.prepareStatement + ( + "SELECT towson_id FROM users WHERE towson_id = ?;" + ); + + stmt.setString(1, userID); + //boolean to integer, 1=true, 0=false + res = stmt.executeQuery(); + return res; + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public int insertIntoUsers(String idusers, String firstName, String lastName, String email) + { + try + { + stmt = conn.prepareStatement + ( + "INSERT INTO users(towson_id, first_name, last_name, email) " + + "values (?,?,?,?) " + + "ON DUPLICATE KEY UPDATE " + + "towson_id = VALUES(towson_id), first_name = VALUES(first_name), last_name = VALUES(last_name), email = VALUES(email);" + ); + + stmt.setString(1, idusers); + stmt.setString(2, firstName); + stmt.setString(3, lastName); + stmt.setString(4, email); + return stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + return -1; + } + + public void insertIntoAdmin(String user_id, String userName, String pass) + { + try + { + stmt = conn.prepareStatement("insert into admin (user_id, username, date_created, pass) values (?,?,NOW(),?);"); + stmt.setString(1, user_id); + stmt.setString(2, userName); + stmt.setString(3, pass); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void insertIntoBuild(String buildname, int runtime, int models, String printer) + { + try + { + stmt = conn.prepareStatement("INSERT INTO printer_build " + + "(build_name, date_created, total_runtime_seconds, number_of_models, printer_name) " + + "VALUES (?, NOW(), ?, ?, ?);"); + + stmt.setString(1, buildname); + stmt.setInt(2, runtime); + stmt.setInt(3, models); + stmt.setString(4, printer); + + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void insertIntoColumnBuildData(String printer, String columnName, String data, String buildLocation) + { + try + { + stmt = this.conn.prepareCall + ( + "{call enterBuildData(?, ?, ?, ?)}" + ); + + stmt.setString(1, printer); + stmt.setString(2, columnName); + stmt.setString(3, data); + stmt.setString(4, buildLocation); + stmt.executeQuery(); + + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void insertIntoCustom(String printer, String name, boolean num) + { + try + { + stmt = conn.prepareStatement("insert into custom_printer_column_names ( printer_name, custom_field_name ,numerical) values (?,? ,?);"); + stmt.setString(1, printer); + stmt.setString(2, name); + stmt.setBoolean(3, num); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void insertIntoAcceptedFiles(String printer, String file) + { + try + { + stmt = conn.prepareStatement("insert into accepted_files ( printer_name, file_extension) values (?,?);"); + stmt.setString(1, printer); + stmt.setString(2, file); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + // END OF INSERT METHODS + // _____________________________________________________________________________________________________________________ + // BEGGINIGNG OF UPDATE METHODS + // _____________________________________________________________________________________________________________________ + public void changeJobStatus(int id, String status) + throws SQLException + { + stmt = this.conn.prepareStatement("UPDATE job SET status = ? WHERE job_id = ?;"); + stmt.setString(1, status); + stmt.setInt(2, id); + stmt.executeUpdate(); + } + + public void updateJobFLocation(int id, String fLocation) + { + try + { + stmt = this.conn.prepareStatement("UPDATE job SET file_path = ?" + " WHERE job_id = ?;"); + stmt.setString(1, fLocation); + stmt.setInt(2, id); + stmt.executeUpdate(); + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, + null, ex); + } + } + + public void updateJobVolume(int id, double volume) + { + try + { + stmt = this.conn.prepareStatement("UPDATE job SET volume = " + + volume + " WHERE job_id = ?;"); + stmt.setInt(1, id); + stmt.executeUpdate(); + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, + null, ex); + } + } + + + public void updateStats(int id, String stat1, String stat2) + { + try { + stmt = this.conn.prepareStatement("UPDATE `job_stats` SET `stat1`=?,`stat2`=? WHERE `job_id`=?"); + stmt.setString(1, stat1); + stmt.setString(2, stat2); + stmt.setInt(3, id); + stmt.executeUpdate(); + } catch(SQLException ex) { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, + null, ex); + } + } + + public void updateJobBuildName(String build, int jobid)//SEAN USE THIS/ + { + try + { + stmt = this.conn.prepareStatement("UPDATE job SET build_name = ? WHERE job_id = ?;"); + stmt.setString(1, build); + stmt.setInt(2, jobid); + stmt.executeUpdate(); + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, + null, ex); + } + } + + public void updateFirstName(String updatedFirstName, String id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("UPDATE users SET first_name = ? WHERE towson_id = ?;"); + stmt.setString(1, updatedFirstName); + stmt.setString(2, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateLastName(String updatedLastName, String id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("UPDATE users SET last_name = ? WHERE towson_id = ?;"); + stmt.setString(1, updatedLastName); + stmt.setString(2, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateStatus(String statusUpdate, int primaryKey) + { + res = null; + try + { + stmt = conn.prepareStatement("UPDATE job SET status = ? WHERE job_id = ? "); + stmt.setString(1, statusUpdate); + stmt.setInt(2, primaryKey); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updatePassword(String password, String username) + { + res = null; + try + { + stmt = conn.prepareStatement("UPDATE admin SET pass= ? WHERE username= ?; "); + stmt.setString(1, password); + stmt.setString(2, username); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateEmail(String newEmail, String id) + { + res = null; + try + { + stmt = conn.prepareStatement("UPDATE users SET email= ? WHERE towson_id= ?; "); + stmt.setString(1, newEmail); + stmt.setString(2, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateColumnFieldName(String updatedName, int id) + { + res = null; + try + { + stmt = this.conn.prepareStatement("UPDATE custom_printer_column_names SET column_field_name = ? WHERE column_names_id = ? ;"); + stmt.setString(1, updatedName); + stmt.setInt(2, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateColumnFieldData(String data, int columnId, String buildName) + { + res = null; + try + { + stmt = this.conn.prepareStatement("UPDATE column_build_data SET column_field_data =? Where column_name_id = ? AND build_name = ? ;"); + stmt.setString(1, data); + stmt.setInt(2, columnId); + stmt.setString(3, buildName); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updatePrinterFileExtension(String printer_name, String file_extension) + { + try + { + stmt = this.conn.prepareStatement("UPDATE printer SET file_extension = ? WHERE printer_name = ?;"); + stmt.setString(1, file_extension); + stmt.setString(2, printer_name); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void updatePrinterCurrent(String printer_name, String current) + { + try + { + stmt = this.conn.prepareStatement("UPDATE printer SET current = ? WHERE printer_name = ?;"); + stmt.setString(1, current); + stmt.setString(2, printer_name); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void updatePrinterBuildDateCreated(String buildName, String date_created) + { + try + { + stmt = this.conn.prepareStatement("UPDATE printer_build SET date_created = NOW() WHERE build_name = ?;"); + stmt.setString(1, buildName); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void updatePrinterBuildTotalRuntimeSeconds(String buildName, int total_runtime_seconds) + { + try + { + stmt = this.conn.prepareStatement("UPDATE printer_build SET total_runtime_seconds = ? WHERE build_name = ?;"); + System.out.println(stmt); + stmt.setInt(1, total_runtime_seconds); + stmt.setString(2, buildName); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + public void updatePrinterBuildNumberOfModels(String buildName, int number_of_models) + { + try + { + stmt = this.conn.prepareStatement("UPDATE printer_build SET number_of_models =? WHERE build_name = ?;"); + System.out.println(stmt); + stmt.setInt(1, number_of_models); + stmt.setString(2, buildName); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + // END OF UPDATE METHODS + // _____________________________________________________________________________________________________________________ + // BEGINGING OF DELETE METHODS + // _____________________________________________________________________________________________________________________ + public void deletebyID(int id) + { + try + { + stmt = this.conn.prepareStatement("DELETE FROM job WHERE submission_id = ?"); + stmt.setInt(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteByBuildId(String buildid) + { + try + { + stmt = this.conn.prepareStatement("DELETE FROM job WHERE build_name = ?;"); + stmt.setString(1, buildid); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteFromJob(int id) + { + try + { + stmt = conn.prepareStatement("DELETE FROM job WHERE job_id = ?; "); + stmt.setInt(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deletePrinter(String printerName) + { + try + { + stmt = conn.prepareStatement("UPDATE printer SET current = 0 where printer_name = ?; "); + stmt.setString(1, printerName); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteFromUser(String id) + { + try + { + stmt = conn.prepareStatement("DELETE FROM users WHERE towson_id = ?; "); + stmt.setString(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteFromClass(int class_id) + { + try + { + stmt = conn.prepareStatement("DELETE FROM class WHERE class_id = ?; "); + stmt.setInt(1, class_id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void clearData(){ + + try + { + stmt = conn.prepareStatement("call clearTables();"); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + + } + + public void deleteFromAdmin(String id) + { + try + { + stmt = conn.prepareStatement("delete from admin where user_id= ?; "); + stmt.setString(1, id); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteFromBuild(String buildName) + { + try + { + stmt = this.conn.prepareStatement("DELETE FROM printer_build WHERE build_name = ?"); + stmt.setString(1, buildName); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + + } + + public void deleteColumnName(int primaryKey) + { + try + { + stmt = conn.prepareStatement("delete from custom_printer_column_names where column_names_id= ?; "); + stmt.setInt(1, primaryKey); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void deleteColumnData(String buildName, int columnId) + { + try + { + stmt = conn.prepareStatement("delete from column_build_data where build_name= ? AND column_name_id = ?;"); + stmt.setString(1, buildName); + stmt.setInt(2, columnId); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + // END OF DELETE METHODS + // _____________________________________________________________________________________________________________________ + public ResultSet getReport(String printer_name) + { + res = null; + try + { + /* stmt = this.conn.prepareStatement( + "call report('" + printer_name + "');" + );*/ + // temp fix to get reports view working + stmt = this.conn.prepareStatement( + "SELECT * FROM custom_printer_column_names WHERE printer_name = ?" + ); + stmt.setString(1, printer_name); + + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + public ResultSet getReport(String column, String value, String printer_name) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "call reportFiltered('" + printer_name + "','" + column + "','" + value + "');" + ); + + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + return res; + } + + public ResultSet searchPending() + { + return selectAllPrintStatus("pending"); + } + + @Deprecated + public ResultSet searchPrintersByBuildName(String buildName, String printer) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT * " + + "FROM " + + printer + " " + + "WHERE " + + "buildName = ?"); + + stmt.setString(1, buildName); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + @Deprecated + public ResultSet searchIncompletePendingByBuild(String buildName) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT * " + + "FROM pendingjobs " + + "WHERE " + + "status = 'incomplete' " + + "AND buildName = ?"); + stmt.setString(1, buildName); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + @Deprecated + public ResultSet searchPendingByBuildName(String buildName) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT * " + + "FROM pendingjobs " + + "WHERE " + + "buildName = '" + buildName + "'"); + //stmt.setString(1, buildName); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchWithJobID(String ID) { + res = null; + try { + stmt = this.conn.prepareStatement( + "SELECT file_name as fileName, submission_date, class_name, class_section, first_name, last_name, email " + + "FROM job, users, class " + + "WHERE " + + "job_id = ? AND towson_id=student_id AND job.class_id= class.class_id "); + stmt.setString(1,ID ); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + public ResultSet searchID( String id) { + res = null; + try { + stmt = this.conn.prepareStatement( + "SELECT job_id, file_path ,printer_name " + + "FROM job " + + "WHERE " + + " file_name = ? ;"); + stmt.setString(1, id); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) { + e.printStackTrace(); + } + return res; + } + + @Deprecated + public void delete(String table, String id) throws SQLException + { + stmt = this.conn.prepareStatement( + "DELETE " + + "FROM " + table + " " + + "WHERE idJobs = ?"); + // stmt.setString(1, table); + stmt.setString(1, id); + System.out.println(stmt); + stmt.executeUpdate(); + } + + @Deprecated + public void approve(String id) throws SQLException + { + stmt = this.conn.prepareStatement( + "UPDATE pendingjobs " + + "SET status = 'approved', " + + "dateUpdated = now() " + + "WHERE idJobs = ?"); + stmt.setString(1, id); + System.out.println(stmt); + stmt.executeUpdate(); + } + + @Deprecated + public void updatePendingJobFLocation(int idJob, String fLocation) + { + try + { + stmt = this.conn.prepareStatement( + "UPDATE jobs" + + " SET filePath = '" + fLocation + "'" + + " WHERE idJobs = '" + idJob + "'" + ); + + System.out.println(stmt); + stmt.executeUpdate(); + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class.getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void updateToPrint(String idJob) throws SQLException + { + stmt = this.conn.prepareStatement( + "UPDATE pendingjobs " + + "SET status = 'to print' " + + "WHERE idJobs = '?';"); + stmt.setString(1, idJob); + System.out.println(stmt); + } + + /* This querys for jobs that have been approved (status = approved). + With this query we can display the student's submissions that needs to + be inserted into a build. The search is based on the name of the printer. + */ + @Deprecated + public ResultSet searchApprovedJobsNotPrinted(String printer) + { + res = null; + + try + { + stmt = this.conn.prepareStatement( + "SELECT fileName, dateStarted " + + "FROM pendingjobs " + + "WHERE " + + "printer = ? " + + "AND status = 'approved'" + ); + + stmt.setString(1, printer); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + @Deprecated + public void updatePendingJobVolume(String idJob, double volume) + { + try + { + stmt = this.conn.prepareStatement( + "UPDATE pendingjobs " + + "SET volume = " + volume + " " + + "WHERE idJobs = '" + idJob + "'"); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class + .getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void updatePendingJobsBuildName(String build, String fileName) + { + try + { + stmt = this.conn.prepareStatement( + "UPDATE pendingjobs " + + "SET buildName = ? WHERE filename = ?"); + stmt.setString(1, build); + stmt.setString(2, fileName); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class + .getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void insertIntoSolidscape(String bn, int models, double resolution, String BuildTime, String comment, double cost) + { + String date = "(CURTIME())"; + try + { + stmt = this.conn.prepareStatement( + "INSERT " + + "INTO solidscape " + + "(idSolidscape, " + + "buildName, " + + "dateRun, " + + "noModels, " + + "resolution, " + + "runTime, " + + "comments, " + + "costOfBuild) " + + "VALUES" + + "(DATE_FORMAT(NOW(), '%Y-%m-%d_%H-%i-%s_" + bn + "'), '" + + "" + bn + "', " + date + ", '" + models + "', '" + resolution + "', '" + BuildTime + "', '" + comment + "', '" + cost + "')"); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class + .getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void insertIntoZcorp(String bn, double mb, double yb, double mab, double cb, double ci, int models, String comment, double cost, String status) + { + String id = "DATE_FORMAT(NOW(), '%Y-%m-%d_%H-%i-%s_" + bn + "')"; + String date = "(CURTIME())"; + try + { + stmt = this.conn.prepareStatement( + "INSERT " + + "INTO zcorp " + + "(idZcorp, " + + "buildName, " + + "dateRun, " + + "monoBinder, " + + "yellowBinder, " + + "magentaBinder, " + + "cyanBinder, " + + "cubicInches, " + + "noModels, " + + "comments, " + + "costOfBuild, " + + "status) " + + "VALUES (" + id + ", '" + bn + "'," + date + ", '" + mb + "', '" + yb + "', '" + mab + "', '" + cb + "', '" + ci + "', '" + models + "', '" + comment + "','" + cost + "','" + status + "')"); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class + .getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void insertIntoObjet(String bn, double bc, double sc, int models, String bm, double resolution, String comment, double cost) + { + String date = "(CURTIME())"; + try + { + stmt = this.conn.prepareStatement( + "INSERT INTO objet " + + "(idObjet, " + + "buildName, " + + "dateRun, " + + "buildConsumed, " + + "supportConsumed, " + + "noModels, " + + "buildMaterials, " + + "resolution, " + + "comments, " + + "costOfBuild) " + + "VALUES(DATE_FORMAT(NOW(), '%Y-%m-%d_%H-%i-%s_" + bn + "')," + + "'" + bn + "'," + date + ",'" + bc + "','" + sc + "','" + models + + "','" + bm + "','" + resolution + "','" + comment + "','" + cost + "');" + ); + + if (stmt.executeUpdate() == 1) + { + System.out.print("Successfully inserted value"); + } + + System.out.println(stmt); + + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void setAllClassesInvisible() + { + try + { + stmt = this.conn.prepareStatement("UPDATE class SET current = false"); + System.out.println(stmt); + stmt.executeUpdate(); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public void updateCurrentClasses(int pk) + { + try + { + stmt = this.conn.prepareStatement( + "UPDATE class " + + "SET current = true where class_id=?;"); + stmt.setInt(1, pk); + System.out.println(stmt); + stmt.executeUpdate(); + + } catch (SQLException ex) + { + Logger.getLogger(SQLMethods.class + .getName()).log(Level.SEVERE, null, ex); + } + } + + @Deprecated + public void insertIntoCompletedJobs(String id, String printer, String firstName, String lastName, String course, String section, String fileName, String filePath, + String dateStarted, String status, String email, String comment, String buildName, Double volume, Double cost) + { + try + { + stmt = this.conn.prepareStatement("INSERT INTO completedJobs " + + "(idCompJobs, " + + "printer, " + + "firstName, " + + "lastName, " + + "course, " + + "section, " + + "fileName, " + + "filePath, " + + "dateStarted, " + + "dateCompleted, " + + "status, " + + "email, " + + "comment, " + + "buildName, " + + "volume, " + + "cost) " + + "VALUES" + + "('" + id + "', " + + "'" + printer + "', " + + "'" + firstName + "', '" + + "" + lastName + "', " + + "'" + course + "', " + + "'" + section + "', " + + "'" + fileName + "', " + + "'" + filePath + "', " + + "'" + dateStarted + "', " + + "(CURDATE()), " + + "'pending', " + + "'" + email + "', " + + "'" + comment + "', " + + "'" + buildName + "', " + + "'" + volume + "', " + + "'" + cost + "')"); + stmt.executeUpdate(); + System.out.println(stmt); + System.out.println("Complete Record Entered!"); + } catch (Exception e) + { + e.printStackTrace(); + } + } + + public ResultSet getBuilds() + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT build_name " + + "FROM printer_build"); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getClasses(boolean status) + { + try + { + stmt = this.conn.prepareStatement( + "SELECT * " + + "FROM class " + + "WHERE " + + "current = ?;"); + + stmt.setBoolean(1, status); + + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getAllDeviceNames() + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT printer_name " + + "FROM printer;" + ); + + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + public ResultSet getCurrentDevices() + { + return getDeviceNamesCurrentOption(true); + } + + public ResultSet getDeviceNamesCurrentOption(final boolean current) + { + res = null; + Thread runner = new Thread() { + public void run() + { + try + { + stmt = conn.prepareStatement( + "SELECT printer_name " + + "FROM printer " + + "WHERE current = ?;" + ); + + stmt.setBoolean(1, current); + + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + + } + }; + runner.run(); + return res; + } + + public ResultSet getTrackedDevices() + { + return getDeviceNamesCurrentOptionSubmissionOption(true, true); + } + + public ResultSet getDeviceNamesCurrentOptionSubmissionOption(boolean current, boolean requireStudentSubmission) + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT printer_name " + + "FROM printer " + + "WHERE current = ? AND student_submission = ?;" + ); + + stmt.setBoolean(1, current); + stmt.setBoolean(2, requireStudentSubmission); + + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet getCurrentTime() + { + res = null; + try + { + stmt = this.conn.prepareStatement( + "SELECT (DATE_FORMAT(NOW(), '%Y-%m-%d_%H-%i-%s'))" + ); + System.out.println(stmt); + res = stmt.executeQuery(); + } catch (Exception e) + { + e.printStackTrace(); + } + return res; + } + + public ResultSet findJobsforDevice(String selectedDevice) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/computername b/computername new file mode 100644 index 0000000..7b9ad53 --- /dev/null +++ b/computername @@ -0,0 +1 @@ +127.0.0.1 diff --git a/computername.txt b/computername.txt new file mode 100644 index 0000000..7b9ad53 --- /dev/null +++ b/computername.txt @@ -0,0 +1 @@ +127.0.0.1