GitBucket
4.21.2
Toggle navigation
Snippets
Sign in
Files
Branches
1
Releases
Issues
4
Pull requests
Labels
Priorities
Milestones
Wiki
Forks
mark.george
/
marking
Browse code
Added "copy to clipboard" feature. Added some comments.
master
1 parent
5b6fc0e
commit
824ec81b248040e98c1de563339c0d1fc9c86a84
Mark
authored
on 26 Aug 2014
Patch
Showing
2 changed files
src/ui/SubmissionDialog.form
src/ui/SubmissionDialog.java
Ignore Space
Show notes
View
src/ui/SubmissionDialog.form
<?xml version="1.0" encoding="UTF-8" ?> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="2"/> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Dimension value="[300, 800]"/> </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"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="scrollPane" pref="376" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="btnQuit" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="btnMark" max="32767" attributes="0"/> </Group> </Group> <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 min="-2" max="-2" attributes="0"/> <Component id="scrollPane" pref="251" max="32767" attributes="0"/> <EmptySpace type="separate" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="btnMark" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnQuit" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JScrollPane" name="scrollPane"> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTable" name="table"> <Properties> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> <Table columnCount="2" rowCount="4"> <Column editable="false" title="Submission" type="java.lang.String"/> <Column editable="false" title="Raw Mark" type="java.lang.Double"/> </Table> </Property> </Properties> <Events> <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tableMouseClicked"/> <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="tableKeyPressed"/> </Events> </Component> </SubComponents> </Container> <Component class="javax.swing.JButton" name="btnMark"> <Properties> <Property name="text" type="java.lang.String" value="Mark Selected Student"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnMarkActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="btnQuit"> <Properties> <Property name="text" type="java.lang.String" value="Quit"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuitActionPerformed"/> </Events> </Component> </SubComponents> </Form>
<?xml version="1.0" encoding="UTF-8" ?> <Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JDialogFormInfo"> <Properties> <Property name="defaultCloseOperation" type="int" value="2"/> <Property name="preferredSize" type="java.awt.Dimension" editor="org.netbeans.beaninfo.editors.DimensionEditor"> <Dimension value="[300, 800]"/> </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"> <EmptySpace max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0"> <Component id="jScrollPane1" pref="376" max="32767" attributes="0"/> <Group type="102" attributes="0"> <Component id="jButton2" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/> <Component id="jButton1" max="32767" attributes="0"/> </Group> </Group> <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 min="-2" max="-2" attributes="0"/> <Component id="jScrollPane1" pref="251" max="32767" attributes="0"/> <EmptySpace type="separate" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0"> <Component id="jButton1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jButton2" alignment="3" min="-2" max="-2" attributes="0"/> </Group> <EmptySpace min="-2" max="-2" attributes="0"/> </Group> </Group> </DimensionLayout> </Layout> <SubComponents> <Container class="javax.swing.JScrollPane" name="jScrollPane1"> <Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/> <SubComponents> <Component class="javax.swing.JTable" name="table"> <Properties> <Property name="model" type="javax.swing.table.TableModel" editor="org.netbeans.modules.form.editors2.TableModelEditor"> <Table columnCount="2" rowCount="4"> <Column editable="false" title="Submission" type="java.lang.String"/> <Column editable="false" title="Raw Mark" type="java.lang.Double"/> </Table> </Property> </Properties> <Events> <EventHandler event="mouseClicked" listener="java.awt.event.MouseListener" parameters="java.awt.event.MouseEvent" handler="tableMouseClicked"/> <EventHandler event="keyPressed" listener="java.awt.event.KeyListener" parameters="java.awt.event.KeyEvent" handler="tableKeyPressed"/> </Events> </Component> </SubComponents> </Container> <Component class="javax.swing.JButton" name="jButton1"> <Properties> <Property name="text" type="java.lang.String" value="Mark Selected Student"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> </Events> </Component> <Component class="javax.swing.JButton" name="jButton2"> <Properties> <Property name="text" type="java.lang.String" value="Quit"/> </Properties> <Events> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton2ActionPerformed"/> </Events> </Component> </SubComponents> </Form>
Ignore Space
Show notes
View
src/ui/SubmissionDialog.java
/* * 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 ui; import dao.ResultDAO; import dao.ScheduleDAO; import java.awt.Toolkit; import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.StringSelection; import java.awt.event.KeyEvent; /** * * @author mark */ public class SubmissionDialog extends javax.swing.JDialog { /** * Creates new form SubmissionDialog */ public SubmissionDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); table.setModel(new ResultDAO().getSubmissions()); } /** * 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() { scrollPane = new javax.swing.JScrollPane(); table = new javax.swing.JTable(); btnMark = new javax.swing.JButton(); btnQuit = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setPreferredSize(new java.awt.Dimension(300, 800)); table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null}, {null, null}, {null, null}, {null, null} }, new String [] { "Submission", "Raw Mark" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.Double.class }; boolean[] canEdit = new boolean [] { false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); table.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tableMouseClicked(evt); } }); table.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { tableKeyPressed(evt); } }); scrollPane.setViewportView(table); btnMark.setText("Mark Selected Student"); btnMark.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnMarkActionPerformed(evt); } }); btnQuit.setText("Quit"); btnQuit.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnQuitActionPerformed(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() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(btnQuit) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnMark, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(scrollPane, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnMark) .addComponent(btnQuit)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void btnQuitActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuitActionPerformed System.exit(0); }//GEN-LAST:event_btnQuitActionPerformed private void btnMarkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnMarkActionPerformed markSelected(); }//GEN-LAST:event_btnMarkActionPerformed private void tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseClicked if (evt.getClickCount() >= 2) { markSelected(); } }//GEN-LAST:event_tableMouseClicked private void tableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { markSelected(); } }//GEN-LAST:event_tableKeyPressed private void markSelected() { // get selected ID from table int row = table.getSelectedRow(); String student = (String) table.getModel().getValueAt(row, 0); // copy selected ID to clipboard StringSelection stringSelection = new StringSelection(student); Clipboard clpbrd = Toolkit.getDefaultToolkit().getSystemClipboard(); clpbrd.setContents(stringSelection, null); MarkingFrame frame = new MarkingFrame(this); // load data into frame ScheduleDAO dao = new ScheduleDAO(); for (String cat : dao.getCategories()) { frame.addCategory(cat, dao.getCriteria(cat)); } frame.load(student); frame.display(); // blocking call (modal dialog) // refresh table to display new mark table.setModel(new ResultDAO().getSubmissions()); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton btnMark; private javax.swing.JButton btnQuit; private javax.swing.JScrollPane scrollPane; private javax.swing.JTable table; // End of variables declaration//GEN-END:variables }
/* * 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 ui; import dao.ResultDAO; import dao.ScheduleDAO; import java.awt.event.KeyAdapter; import java.awt.event.KeyEvent; import javax.swing.table.TableModel; /** * * @author mark */ public class SubmissionDialog extends javax.swing.JDialog { /** * Creates new form SubmissionDialog */ public SubmissionDialog(java.awt.Frame parent, boolean modal) { super(parent, modal); initComponents(); table.setModel(new ResultDAO().getSubmissions()); } /** * 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(); table = new javax.swing.JTable(); jButton1 = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE); setPreferredSize(new java.awt.Dimension(300, 800)); table.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null}, {null, null}, {null, null}, {null, null} }, new String [] { "Submission", "Raw Mark" } ) { Class[] types = new Class [] { java.lang.String.class, java.lang.Double.class }; boolean[] canEdit = new boolean [] { false, false }; public Class getColumnClass(int columnIndex) { return types [columnIndex]; } public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit [columnIndex]; } }); table.addMouseListener(new java.awt.event.MouseAdapter() { public void mouseClicked(java.awt.event.MouseEvent evt) { tableMouseClicked(evt); } }); table.addKeyListener(new java.awt.event.KeyAdapter() { public void keyPressed(java.awt.event.KeyEvent evt) { tableKeyPressed(evt); } }); jScrollPane1.setViewportView(table); jButton1.setText("Mark Selected Student"); jButton1.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton1ActionPerformed(evt); } }); jButton2.setText("Quit"); jButton2.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { jButton2ActionPerformed(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() .addContainerGap() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 376, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup() .addComponent(jButton2) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addContainerGap()) ); layout.setVerticalGroup( layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createSequentialGroup() .addContainerGap() .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 251, Short.MAX_VALUE) .addGap(18, 18, 18) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jButton1) .addComponent(jButton2)) .addContainerGap()) ); pack(); }// </editor-fold>//GEN-END:initComponents private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed System.exit(0); }//GEN-LAST:event_jButton2ActionPerformed private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed markSelected(); }//GEN-LAST:event_jButton1ActionPerformed private void tableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_tableMouseClicked if (evt.getClickCount() >= 2) { markSelected(); } }//GEN-LAST:event_tableMouseClicked private void tableKeyPressed(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_tableKeyPressed if (evt.getKeyCode() == KeyEvent.VK_ENTER) { markSelected(); } }//GEN-LAST:event_tableKeyPressed private void markSelected() { int row = table.getSelectedRow(); String student = (String) table.getModel().getValueAt(row, 0); MarkingFrame frame = new MarkingFrame(this); ScheduleDAO dao = new ScheduleDAO(); for (String cat : dao.getCategories()) { frame.addCategory(cat, dao.getCriteria(cat)); } frame.load(student); frame.display(); table.setModel(new ResultDAO().getSubmissions()); } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton jButton1; private javax.swing.JButton jButton2; private javax.swing.JScrollPane jScrollPane1; private javax.swing.JTable table; // End of variables declaration//GEN-END:variables }
Show line notes below