1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166
|
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/*
* Slot.java
*
* Created on 13 mai 2011, 12:24:08
*/
package GuiPhysique;
import com.mysql.jdbc.Connection;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ProgressMonitor;
public class Slot extends javax.swing.JPanel {
Connection conn = (Connection) ConnectDatabaseDAO.getInstance("root", "azerty" , "project_v2.1");
public Boolean TestB = false;
/** Creates new form Slot */
public Slot() {
initComponents();
}
public Slot(String SlotNum, String MASGName) {
initComponents();
this.SlotNum = SlotNum;
this.MASGName = MASGName;
}
public Slot(String SlotNum, String MASGName, String PTN_type) {
initComponents();
this.SlotNum = SlotNum;
this.MASGName = MASGName;
this.PTN_type = PTN_type;
}
public final void setBusySlot (){
StandardWorker worker = new StandardWorker<Void>(new ProgressMonitor(this,"Operation in progress...","", 0, 100)){
@Override
public Void doInBackground() {
lockItems();
publish("Starting Task.");
setProgress(0);
try {
BoardDao b_dao = new BoardDao();
Masg_csgDao m_dao = new Masg_csgDao();
if (b_dao.getObject(conn, m_dao.getObject(conn, MASGName), Integer.parseInt(SlotNum)) != null) {
setBackground(Color.red);
}
} catch (NotFoundException ex) {
Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
}
publish("Task Finished.");
setProgress(100);
return null;
}
};
worker.execute();
}
/** 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">
private void initComponents() {
internalText = new javax.swing.JLabel();
setBackground(new java.awt.Color(255, 255, 255));
setMaximumSize(new java.awt.Dimension(19, 217));
setMinimumSize(new java.awt.Dimension(19, 217));
setPreferredSize(new java.awt.Dimension(19, 217));
addMouseListener(new java.awt.event.MouseAdapter() {
public void mouseClicked(java.awt.event.MouseEvent evt) {
formMouseClicked(evt);
}
});
setLayout(new java.awt.CardLayout());
internalText.setText("<html>S<br> L<br>O<br>T<br> <br>N</html>");
internalText.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
add(internalText, "card2");
}// </editor-fold>
private void formMouseClicked(java.awt.event.MouseEvent evt) {
TestDialog tf = new TestDialog(null,true);
if( this.getBackground() != Color.red){
BoardAddGui bf = new BoardAddGui(SlotNum, MASGName, PTN_type, this);
tf.jTabbedPane1.add(bf);
bf.setBackground(Color.white);
tf.jTabbedPane1.setTitleAt(0, "Board : Add");
tf.setSize(new Dimension(700,500));
tf.setVisible(true);
} else{
try {
BoardDao b_dao = new BoardDao();
Masg_csgDao m_dao = new Masg_csgDao();
PortAddGui bf = new PortAddGui(b_dao.getObject(conn, m_dao.getObject(conn, MASGName), Integer.parseInt(SlotNum)).getBoard_Name());
tf.jTabbedPane1.add(bf);
bf.setBackground(Color.white);
tf.jTabbedPane1.setTitleAt(0, "Port : Add");
tf.setSize(new Dimension(700, 500));
tf.setVisible(true);
} catch (NotFoundException ex) {
Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
} catch (SQLException ex) {
Logger.getLogger(Slot.class.getName()).log(Level.SEVERE, null, ex);
}
}
}
public String getInternalText() {
return internalText.getText();
}
public void setInternalText(String internalText) {
this.internalText.setText(internalText);
}
public String getMASGName() {
return MASGName;
}
public void setMASGName(String MASGName) {
this.MASGName = MASGName;
}
public String getSlotNum() {
return SlotNum;
}
public void setSlotNum(String SlotNum) {
this.SlotNum = SlotNum;
}
private String SlotNum;// à changer en int
private String MASGName;// à changer soit en ID soit en MASG_CSG
private String PTN_type;
// Variables declaration - do not modify
public javax.swing.JLabel internalText;
// End of variables declaration
} |
Partager