/Users/detro/workspace-nb/JAEBI-SwingClient/src/clientswing/UI/InsertUpdatePanel.java

Vai alla documentazione di questo file.
00001 package clientswing.UI;
00002 
00003 import java.awt.*;
00004 import java.awt.event.*;
00005 import javax.swing.*;
00006 
00007 import clientswing.model.*;
00008 
00019 public class InsertUpdatePanel
00020     extends JPanel
00021     implements RequestPanel {
00022 
00023   // OGGETTI SWING UTILIZZATI
00025   JLabel columnNum = new JLabel();
00026 
00028   JTextField columnNumSet = new JTextField();
00029 
00031   JLabel tableName = new JLabel();
00033   JTextField tableList = new JTextField();
00034 
00036   JLabel whereClause = new JLabel();
00037 
00039     JTextField columnNumSetWhere = new JTextField();
00040 
00041 
00043   JButton ok = new JButton();
00045   JButton okWhere = new JButton();
00046 
00048   OptionPanelInsertUpdate optionPanel;
00050   OptionPanelInsertUpdate optionPanelWhere;
00051 
00053   boolean services;
00058   String service;
00061   public InsertUpdatePanel(boolean services) {
00062     columnNum.setText("Inserisci il numero di colonne");
00063     columnNum.setBounds(new Rectangle(10, 30, 180, 20));
00064     columnNum.setForeground(Color.black);
00065 
00066     columnNumSet.setBounds(new Rectangle(200, 30, 20, 20));
00067 
00068     tableName.setText("Inserisci la Tabella");
00069     tableName.setBounds(new Rectangle(10, 60, 130, 20));
00070     tableName.setForeground(Color.black);
00071 
00072     tableList.setBounds(new Rectangle(200, 60, 75, 20));
00073 
00074     whereClause.setText("Inserisci i campi della where:");
00075     whereClause.setBounds(new Rectangle(10, 90, 180, 20));
00076     whereClause.setForeground(Color.black);
00077     columnNumSetWhere.setBounds(new Rectangle(200, 90, 20, 20));
00078     okWhere.setBounds(new Rectangle(230, 90, 45, 20));
00079     okWhere.setText("ok");
00080     okWhere.setFont(new java.awt.Font("Dialog", 0, 11));
00081 
00082     ok.setBounds(new Rectangle(230, 30, 45, 20));
00083     ok.setText("ok");
00084     ok.setFont(new java.awt.Font("Dialog", 0, 11));
00085 
00086     //catturo l'evento
00087     ok.addMouseListener(new InsertUpdatePanel_ok_mouseAdapter(this));
00088     //catturo l'evento
00089     okWhere.addMouseListener(new InsertUpdatePanel_okWhere_mouseAdapter(this));
00090 
00091     //aggiungo i componenti SWING al frame di Login
00092     this.add(columnNum, null);
00093     this.add(columnNumSet, null);
00094 
00095     this.add(tableName, null);
00096     this.add(tableList, null);
00097 
00098     if (services == true) {
00099       service="update";
00100       this.add(whereClause, null);
00101       this.add(columnNumSetWhere, null);
00102       this.add(okWhere, null);
00103     }
00104     else
00105       service="insert";
00106     this.add(ok, null);
00107 
00108     init(this);
00109   }
00110 
00111   public String getTableList(JTextField tableList) {
00112     return tableList.getText();
00113 
00114   }
00115 
00116   public boolean getServices() {
00117     return services;
00118 
00119   }
00121   public void init(JPanel pannello) {
00122     pannello.setBounds(new Rectangle(30, 20, 280, 150));
00123     pannello.setLayout(null);
00124     pannello.setBackground(Color.lightGray);
00125 
00126   }
00127 
00128   public XRequestQuery getXRequest(String service) {
00129 
00130     XRequestQuery request = new XRequestQuery();
00131     Column[] columnsWhere ;
00132     request.setService(service);
00133     request.setTableName(tableList.getText());
00134 
00135     if (service=="update") {
00136       columnsWhere = null;
00137       if (optionPanelWhere != null)
00138       {
00139         if (optionPanelWhere.getColumns().length > 0)
00140           columnsWhere = optionPanelWhere.getColumns();
00141 
00142           for (int i = 0; i < columnsWhere.length; i++) {
00143             request.addColumnWhere(columnsWhere[i]);
00144             System.out.println("\n" + columnsWhere[i] + "\n");
00145           }
00146       }
00147 
00148     }
00149     if (optionPanel == null)return request;
00150 
00151     Column[] columns = optionPanel.getColumns();
00152     for (int i = 0; i < columns.length; i++)
00153       request.addColumn(columns[i]);
00154 
00155     return request;
00156   }
00157 
00158   void ok_mouseClicked(MouseEvent e) {
00159 
00160     optionPanel = new OptionPanelInsertUpdate(columnNumSet);
00161     if (optionPanel.getIsError() == false)
00162       optionPanel.show();
00163   }
00164   void okWhere_mouseClicked(MouseEvent e) {
00165 
00166     optionPanelWhere = new OptionPanelInsertUpdate(columnNumSetWhere);
00167     if (optionPanelWhere.getIsError() == false)
00168       optionPanelWhere.show();
00169   }
00170 
00176   public String getService() {
00177     return service;
00178   }
00179 }
00180 
00181 class InsertUpdatePanel_ok_mouseAdapter
00182     extends java.awt.event.MouseAdapter {
00183   InsertUpdatePanel adaptee;
00184 
00185   InsertUpdatePanel_ok_mouseAdapter(InsertUpdatePanel adaptee) {
00186     this.adaptee = adaptee;
00187   }
00188 
00189   public void mouseClicked(MouseEvent e) {
00190     adaptee.ok_mouseClicked(e);
00191   }
00192 }
00193 class InsertUpdatePanel_okWhere_mouseAdapter
00194     extends java.awt.event.MouseAdapter {
00195   InsertUpdatePanel adaptee;
00196 
00197   InsertUpdatePanel_okWhere_mouseAdapter(InsertUpdatePanel adaptee) {
00198     this.adaptee = adaptee;
00199   }
00200 
00201   public void mouseClicked(MouseEvent e) {
00202     adaptee.okWhere_mouseClicked(e);
00203   }
00204 }

Generato il Wed Jun 22 16:42:58 2005 per JAEBI - Swing Client da  doxygen 1.4.3