home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Label;
- import java.awt.Panel;
- import java.awt.TextArea;
- import java.util.Vector;
-
- public class JDPSQLDelete extends JDPClassLayout {
- JDPUser user;
- JDPJagg jaggSQL;
- JDPPopupMessage popuppanel;
- JDPMaskEdit JDPMaskEditMain;
- String moduleParameter;
- Panel Main;
- Panel Panel1;
- TextArea completeSQL;
- Label Label4;
- Panel Panel6;
- Panel Panel3;
- JDPList tables;
- Label Label1;
- Panel Panel2;
- Panel Panel4;
- JDPList whereColumns;
- Label Label2;
- Panel Panel5;
- Label Label3;
- JDPComboBox whereSettings;
- Vector valuewhereSettings;
- boolean SQLOnly = false;
-
- public void InitClass(JDPUser var1, Panel var2, String var3) {
- this.user = var1;
- this.moduleParameter = var3;
- super.targetPanel = var2;
- this.jaggSQL = new JDPJagg(var1.jaggPath);
- ((Container)this).setLayout(new BorderLayout());
- this.popuppanel = new JDPPopupMessage(var1, this);
- ((Container)this).add(this.popuppanel);
- this.JDPMaskEditMain = new JDPMaskEdit();
- this.Main = new Panel();
- this.Panel1 = new Panel();
- this.completeSQL = new TextArea("", 3, 20);
- this.Label4 = new Label("SQL", 0);
- this.Panel6 = new Panel();
- this.Panel3 = new Panel();
- this.tablesMain();
- this.Label1 = new Label("Delete From", 0);
- this.Panel2 = new Panel();
- this.Panel4 = new Panel();
- this.whereColumnsMain();
- this.Label2 = new Label("Where", 0);
- this.Panel5 = new Panel();
- this.Label3 = new Label("Equals", 0);
- this.whereSettingsMain();
- this.Main.setLayout(new BorderLayout());
- ((Container)this).add("Center", this.Main);
- this.Main.add("Center", this.Panel1);
- this.Panel1.setLayout(new BorderLayout());
- this.Panel1.add("Center", this.completeSQL);
- this.Panel1.add("North", this.Label4);
- this.Main.add("North", this.Panel6);
- this.Panel6.setLayout(new JDPRowLayout());
- this.Panel6.add("Left", this.Panel3);
- this.Panel3.setLayout(new BorderLayout());
- this.Panel3.add("Center", this.tables);
- this.Panel3.add("North", this.Label1);
- this.Panel6.add("Left", this.Panel2);
- this.Panel2.setLayout(new JDPLineLayout());
- this.Panel2.add("Left", this.Panel4);
- this.Panel4.setLayout(new BorderLayout());
- this.Panel4.add("Center", this.whereColumns);
- this.Panel4.add("North", this.Label2);
- this.Panel2.add("Left", this.Panel5);
- this.Panel5.setLayout(new JDPRowLayout());
- this.Panel5.add("Left", this.Label3);
- this.Panel5.add("Left", this.whereSettings);
- this.tables.setBackground(var1.u._cvtcolor("White"));
- this.tables.setMinHeight(60);
- this.tables.setMinWidth(285);
- this.whereColumns.setBackground(var1.u._cvtcolor("White"));
- this.whereColumns.setMinHeight(60);
- this.whereColumns.setMultipleSelections(true);
- this.whereColumns.setSelectionsCheckboxes(true);
- this.whereSettings.setMinimumWidth(140);
- this.InitComponents();
- var1.gParm.addElement(this);
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 402:
- if (var1.target.equals(this.whereSettings)) {
- String var9 = this.whereColumns.getSelectedKey();
- String var11 = var9.substring(var9.indexOf(":"));
- this.whereColumns.replaceItemKey(this.whereColumns.getSelectedIndex(), this.whereSettings.getText() + var11);
- this.constructSQL();
- return true;
- }
-
- return false;
- case 503:
- case 504:
- case 505:
- this.popuppanel.postEvent(var1);
- return false;
- case 701:
- if (var1.target.equals(this.tables)) {
- Event var8 = new Event(this, 1001, this.tables.getSelectedItem());
- ((Container)this).deliverEvent(var8);
- this.constructSQL();
- return true;
- } else {
- if (var1.target.equals(this.whereColumns)) {
- if (this.whereColumns.getSelectedIndex() >= 0) {
- String var5 = this.whereColumns.getSelectedKey();
- var5 = var5.substring(0, var5.indexOf(":"));
- this.whereSettings.setText(var5);
- } else {
- this.whereSettings.setText("");
- }
-
- this.constructSQL();
- Event var7 = new Event(this, 701, this.whereSettings.getSelectedItem());
- ((Container)this).deliverEvent(var7);
- return true;
- }
-
- return false;
- }
- case 702:
- if (var1.target.equals(this.whereColumns)) {
- this.constructSQL();
- return true;
- }
-
- return false;
- case 1001:
- if (var1.target.equals(this.whereColumns)) {
- this.constructSQL();
- return true;
- } else {
- if (var1.target.equals(this.whereSettings)) {
- String var4 = this.whereColumns.getSelectedKey();
- String var10 = var4.substring(var4.indexOf(":"));
- this.whereColumns.replaceItemKey(this.whereColumns.getSelectedIndex(), this.whereSettings.getText() + var10);
- this.constructSQL();
- return true;
- }
-
- return false;
- }
- case 1005:
- if (var1.target.equals(this.whereSettings)) {
- String var2 = this.whereColumns.getSelectedKey();
- String var3 = var2.substring(var2.indexOf(":"));
- this.whereColumns.replaceItemKey(this.whereColumns.getSelectedIndex(), this.whereSettings.getText() + var3);
- this.constructSQL();
- return true;
- }
-
- return false;
- default:
- return false;
- }
- }
-
- public void InitComponents() {
- this.jaggSQL.setKeepConnectionOpen(false);
- }
-
- public void MainMethod() {
- }
-
- public JDPList getTableHandle() {
- return this.tables;
- }
-
- public JDPList getWhereColumnsHandle() {
- return this.whereColumns;
- }
-
- public JDPComboBox getWhereSettingsHandle() {
- return this.whereSettings;
- }
-
- public String constructSQL() {
- String var1 = this.constructCompleteSQL(this.SQLOnly);
- this.completeSQL.setText(var1);
- return var1;
- }
-
- public void setSQLOnly(boolean var1) {
- this.SQLOnly = var1;
- }
-
- public String constructCompleteSQL(boolean var1) {
- StringBuffer var2 = new StringBuffer();
- if (this.tables.getSelectedIndex() == -1) {
- return "";
- } else {
- String var4 = "\"";
- String var5 = "+";
- if (var1) {
- var4 = "";
- var5 = "";
- }
-
- var2.append(var4 + "DELETE FROM ");
- var2.append(this.tables.getSelectedItem());
- var2.append(" " + var4);
- if (this.whereColumns.getSelectedIndexes().length > 0) {
- String var6 = " " + var5 + "\n" + var4 + "WHERE ";
- int[] var7 = this.whereColumns.getSelectedIndexes();
-
- for(int var8 = 0; var8 < var7.length; ++var8) {
- var2.append(var6);
- var6 = " " + var5 + "\n" + var4 + "AND ";
- var2.append(this.whereColumns.getItem(var7[var8]));
- var2.append(" = ");
- String var3 = this.whereColumns.getItemKey(var7[var8]);
- var3 = var3.substring(0, var3.indexOf(":"));
- var2.append(var3);
- var2.append(" " + var4);
- }
- }
-
- return var2.toString();
- }
- }
-
- public String getSQL() {
- return this.SQLOnly ? this.completeSQL.getText() : this.constructCompleteSQL(true);
- }
-
- public void clear() {
- this.tables.clear();
- this.whereColumns.clear();
- this.whereSettings.clear();
- this.whereSettings.setText("");
- this.completeSQL.setText("");
- }
-
- public void tablesMain() {
- if (this.tables == null) {
- this.tables = new JDPList(this.user);
- }
-
- }
-
- public void whereColumnsMain() {
- if (this.whereColumns == null) {
- this.whereColumns = new JDPList(this.user);
- }
-
- }
-
- public void whereSettingsMain() {
- if (this.whereSettings == null) {
- this.whereSettings = new JDPComboBox(this.user);
- }
-
- }
- }
-