home *** CD-ROM | disk | FTP | other *** search
- import java.awt.BorderLayout;
- import java.awt.Button;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.GridLayout;
- import java.awt.List;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.TextField;
- import java.util.Vector;
-
- public class JDPWhereClause extends Panel {
- JDPUser user;
- JDPComboBox chooseFrom;
- JDPComboBox matchUsing;
- JDPComboBox matchTo;
- TextField matchConstant;
- List whereClauses;
- String whereClauseName;
- String fromWhereClause;
- boolean smallConfig;
- String[] pchooseFrom;
- String[][] pmatchUsing;
- String[][] pmatchTo;
- String[] pactualchooseFrom;
- String[][] pactualmatchUsing;
- String[][] pactualmatchTo;
- int[] dataType;
- String dsnType = "";
- int currentChooseFrom;
- int[] constantLength;
- boolean[] constantIsString;
- Vector vmatchUsing;
- Vector vactualmatchUsing;
- String whereClause;
- // $FF: renamed from: p1 java.awt.Panel
- Panel field_0;
- // $FF: renamed from: p2 java.awt.Panel
- Panel field_1;
- // $FF: renamed from: p3 java.awt.Panel
- Panel field_2;
- // $FF: renamed from: p4 java.awt.Panel
- Panel field_3;
- Panel mainPanel;
- Panel topPanel;
- JDPPopupMessage popuppanel;
- Panel targetPanel;
- // $FF: renamed from: b1 JDPButton
- JDPButton field_4;
- // $FF: renamed from: b2 JDPButton
- JDPButton field_5;
- // $FF: renamed from: b3 JDPButton
- JDPButton field_6;
- int numpanels = 1;
- boolean upperCaseEntry;
- Font currentFont;
-
- public void setDataType(int var1, int var2) {
- this.dataType[var1] = var2;
- }
-
- public void setHorizontalLayout(boolean var1) {
- this.smallConfig = !var1;
- this.layoutPanel();
- ((Container)this).layout();
- ((Component)this).paintAll(((Component)this).getGraphics());
- }
-
- public boolean getHorizontalLayout() {
- return !this.smallConfig;
- }
-
- String getQuote(int var1) {
- return JDPUtils.getFieldQuote(var1, this.dsnType);
- }
-
- public void setMatchConstant(String var1) {
- this.matchConstant.setText(var1);
- }
-
- public String getMatchConstant() {
- return this.matchConstant.getText();
- }
-
- public void setBackground(Color var1) {
- if (this.chooseFrom != null) {
- this.chooseFrom.setBackground(var1);
- }
-
- if (this.matchUsing != null) {
- this.matchUsing.setBackground(var1);
- }
-
- if (this.matchTo != null) {
- this.matchTo.setBackground(var1);
- }
-
- if (this.matchConstant != null) {
- this.matchConstant.setBackground(var1);
- }
-
- if (this.field_4 != null) {
- this.field_4.setBackground(var1);
- }
-
- if (this.field_5 != null) {
- this.field_5.setBackground(var1);
- }
-
- if (this.field_6 != null) {
- this.field_6.setBackground(var1);
- }
-
- }
-
- void reloadMatchChoices() {
- this.currentChooseFrom = this.chooseFrom.getSelectedIndex();
- if (this.field_1 != null) {
- this.matchUsing.clear();
- if (this.pmatchUsing != null && this.pmatchUsing[this.currentChooseFrom][0] != null) {
- for(int var1 = 0; var1 < this.pmatchUsing[this.currentChooseFrom].length; ++var1) {
- if (this.pmatchUsing[this.currentChooseFrom][var1] != null) {
- this.matchUsing.addItem(this.pmatchUsing[this.currentChooseFrom][var1]);
- this.matchUsing.select(0);
- }
- }
- }
-
- if (this.vmatchUsing != null && this.vmatchUsing.elementAt(this.currentChooseFrom) != null) {
- Vector var3 = (Vector)this.vmatchUsing.elementAt(this.currentChooseFrom);
-
- for(int var2 = 0; var2 < var3.size(); ++var2) {
- if (var3.elementAt(var2) != null) {
- this.matchUsing.addItem((String)var3.elementAt(var2));
- this.matchUsing.select(0);
- }
- }
- }
- }
-
- if (this.field_2 != null) {
- this.matchTo.clear();
- if (this.pmatchTo[this.currentChooseFrom][0] != null) {
- for(int var4 = 0; var4 < this.pmatchTo[this.currentChooseFrom].length; ++var4) {
- if (this.pmatchTo[this.currentChooseFrom][var4] != null) {
- this.matchTo.addItem(this.pmatchTo[this.currentChooseFrom][var4]);
- this.matchTo.select(0);
- }
- }
- }
- }
-
- if (this.field_3 != null) {
- if (this.constantLength[this.currentChooseFrom] > 0) {
- this.field_3.show();
- } else {
- this.field_3.hide();
- }
- }
-
- if (this.topPanel != null) {
- this.topPanel.layout();
- this.topPanel.paintAll(this.topPanel.getGraphics());
- }
-
- if (this.mainPanel != null) {
- this.mainPanel.layout();
- this.mainPanel.paintAll(this.mainPanel.getGraphics());
- }
-
- if (this.targetPanel != null) {
- this.targetPanel.layout();
- this.targetPanel.paintAll(this.targetPanel.getGraphics());
- }
-
- ((Container)this).layout();
- ((Component)this).paintAll(((Component)this).getGraphics());
- this.matchUsing.layoutChoice();
- }
-
- public JDPWhereClause(JDPUser var1, Panel var2, String var3, boolean var4, String var5, String[] var6, String[] var7, Vector var8, Vector var9, String[][] var10, String[][] var11, int[] var12, boolean[] var13, String var14) {
- this.showWhereClause(var1, var2, var3, var4, var5, var6, var7, (String[][])null, (String[][])null, var10, var11, var12, var13, var8, var9, var14);
- }
-
- public JDPWhereClause(JDPUser var1, Panel var2, String var3, boolean var4, String var5, String[] var6, String[] var7, Vector var8, Vector var9, String[][] var10, String[][] var11, int[] var12, boolean[] var13) {
- this.showWhereClause(var1, var2, var3, var4, var5, var6, var7, (String[][])null, (String[][])null, var10, var11, var12, var13, var8, var9, (String)null);
- }
-
- public JDPWhereClause(JDPUser var1, Panel var2, String var3, boolean var4, String var5, String[] var6, String[] var7, String[][] var8, String[][] var9, String[][] var10, String[][] var11, int[] var12, boolean[] var13) {
- this.showWhereClause(var1, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, var13, (Vector)null, (Vector)null, (String)null);
- }
-
- public JDPWhereClause(JDPUser var1, String var2, boolean var3, String var4, String[] var5, String[] var6, String[][] var7, String[][] var8, String[][] var9, String[][] var10, int[] var11, boolean[] var12) {
- this.showWhereClause(var1, (Panel)null, var2, var3, var4, var5, var6, var7, var8, var9, var10, var11, var12, (Vector)null, (Vector)null, (String)null);
- }
-
- public JDPWhereClause(JDPUser var1) {
- this.currentFont = var1.plainFont;
- }
-
- void showWhereClause(JDPUser var1, Panel var2, String var3, boolean var4, String var5, String[] var6, String[] var7, String[][] var8, String[][] var9, String[][] var10, String[][] var11, int[] var12, boolean[] var13, Vector var14, Vector var15, String var16) {
- this.user = var1;
- this.targetPanel = var2;
- this.whereClauseName = var3;
- this.smallConfig = var4;
- this.pchooseFrom = var6;
- this.pmatchUsing = var8;
- this.pmatchTo = var10;
- this.pactualchooseFrom = var7;
- this.pactualmatchUsing = var9;
- this.pactualmatchTo = var11;
- this.constantLength = var12;
- this.constantIsString = var13;
- this.vmatchUsing = var14;
- this.vactualmatchUsing = var15;
- this.fromWhereClause = var16;
- ((Container)this).setLayout(new BorderLayout());
- this.currentFont = var1.plainFont;
- this.dataType = new int[var7.length];
- this.field_1 = null;
- this.field_2 = null;
- this.field_3 = null;
- this.popuppanel = new JDPPopupMessage(var1, var2);
- this.chooseFrom = new JDPComboBox(var1, "", 20);
- this.chooseFrom.setEditable(false);
-
- for(int var17 = 0; var17 < var6.length; ++var17) {
- this.chooseFrom.addItem(var6[var17]);
- this.chooseFrom.select(var5);
- }
-
- this.currentChooseFrom = this.chooseFrom.getSelectedIndex();
- this.field_0 = new Panel();
- this.field_0.setLayout(new BorderLayout());
- this.field_0.add("Center", this.chooseFrom);
- this.popuppanel.addComponent(this.chooseFrom, "Search by", "Search for entries with a set value");
- if (var8 != null && var8[this.currentChooseFrom][0] != null) {
- this.matchUsing = new JDPComboBox(var1, "", 20);
- this.matchUsing.setEditable(false);
-
- for(int var19 = 0; var19 < var8[this.currentChooseFrom].length; ++var19) {
- if (var8[this.currentChooseFrom][var19] != null) {
- this.matchUsing.addItem(var8[this.currentChooseFrom][var19]);
- }
-
- this.matchUsing.select(0);
- }
-
- this.field_1 = new Panel();
- this.field_1.setLayout(new BorderLayout());
- this.field_1.add("Center", this.matchUsing);
- ++this.numpanels;
- this.popuppanel.addComponent(this.matchUsing, "Match using", "Find entries with this criteria");
- }
-
- if (var14 != null && var14.elementAt(this.currentChooseFrom) != null) {
- this.matchUsing = new JDPComboBox(var1, "", 20);
- this.matchUsing.setEditable(false);
- Vector var20 = (Vector)var14.elementAt(this.currentChooseFrom);
-
- for(int var18 = 0; var18 < var20.size(); ++var18) {
- if (var20.elementAt(var18) != null) {
- this.matchUsing.addItem((String)var20.elementAt(var18));
- this.matchUsing.select(0);
- }
- }
-
- this.field_1 = new Panel();
- this.field_1.setLayout(new BorderLayout());
- this.field_1.add("Center", this.matchUsing);
- ++this.numpanels;
- this.popuppanel.addComponent(this.matchUsing, "Match using", "Find entries with this criteria");
- }
-
- if (var10 != null && var10[this.currentChooseFrom][0] != null) {
- this.matchTo = new JDPComboBox(var1, "", 20);
- this.matchTo.setEditable(false);
-
- for(int var21 = 0; var21 < var10[this.currentChooseFrom].length; ++var21) {
- if (var10[this.currentChooseFrom][var21] != null) {
- this.matchTo.addItem(var10[this.currentChooseFrom][var21]);
- this.matchTo.select(0);
- }
- }
-
- this.field_2 = new Panel();
- this.field_2.setLayout(new BorderLayout());
- this.field_2.add("Center", this.matchTo);
- ++this.numpanels;
- }
-
- this.matchConstant = new TextField("", 20);
- this.field_3 = new Panel();
- this.field_3.setLayout(new BorderLayout());
- this.field_3.add("Center", this.matchConstant);
- ++this.numpanels;
- this.popuppanel.addComponent(this.matchConstant, "Enter a value", "Entries with this value will be selected");
- this.field_4 = new JDPButton(4, "Search", 0);
- this.field_5 = new JDPButton("And", 4, 0);
- this.field_6 = new JDPButton("Or", 4, 0);
- ((Container)this).setLayout(new BorderLayout());
- this.layoutPanel();
- this.popuppanel.addComponent(this.field_4, "Search", "Search for entries matching this criteria");
- this.popuppanel.addComponent(this.field_5, "And", "Continue the search for entries that also match this criteria");
- this.popuppanel.addComponent(this.field_6, "Or", "Continue the search for entries that match prior search OR this search");
- if (var2 != null) {
- ((Container)var2).add(this.popuppanel);
- }
-
- this.buildWhereClause();
- if (var12[this.currentChooseFrom] == 0) {
- this.field_3.hide();
- }
-
- ((Component)this).paintAll(((Component)this).getGraphics());
- }
-
- public void buildWhereClause() {
- if (this.upperCaseEntry) {
- this.matchConstant.setText(this.matchConstant.getText().toUpperCase());
- }
-
- this.currentChooseFrom = this.chooseFrom.getSelectedIndex();
- this.whereClause = this.pactualchooseFrom[this.currentChooseFrom];
- if (this.matchUsing != null) {
- if (this.pactualmatchUsing != null) {
- this.whereClause = this.whereClause + " " + this.pactualmatchUsing[this.currentChooseFrom][this.matchUsing.getSelectedIndex()];
- } else if (this.vactualmatchUsing != null && this.vactualmatchUsing.size() > 0 && this.currentChooseFrom >= 0 && this.matchUsing.getSelectedIndex() >= 0) {
- this.whereClause = this.whereClause + " " + (String)((Vector)this.vactualmatchUsing.elementAt(this.currentChooseFrom)).elementAt(this.matchUsing.getSelectedIndex());
- }
- }
-
- if (this.matchTo != null) {
- this.whereClause = this.whereClause + " " + this.pactualmatchTo[this.currentChooseFrom][this.matchTo.getSelectedIndex()];
- }
-
- if (this.constantLength[this.currentChooseFrom] > 0) {
- String var1 = this.user.u.replace(this.matchConstant.getText(), "'", "''");
- if (this.constantIsString[this.chooseFrom.getSelectedIndex()]) {
- String var2 = "";
- if (this.pmatchUsing != null) {
- var2 = this.pmatchUsing[this.currentChooseFrom][this.matchUsing.getSelectedIndex()];
- }
-
- if (this.vmatchUsing != null && this.currentChooseFrom >= 0 && this.matchUsing.getSelectedIndex() >= 0) {
- var2 = (String)((Vector)this.vmatchUsing.elementAt(this.currentChooseFrom)).elementAt(this.matchUsing.getSelectedIndex());
- }
-
- var1 = this.cvtConstant(var1, this.dataType[this.currentChooseFrom]);
- if (var2.indexOf("ontains") > 0) {
- this.whereClause = this.whereClause + " '%" + var1 + "%'";
- } else if (var2.indexOf("egins") > 0) {
- this.whereClause = this.whereClause + " '" + var1 + "%'";
- } else {
- String var3 = this.getQuote(this.dataType[this.currentChooseFrom]);
- this.whereClause = this.whereClause + " " + var3 + var1 + var3;
- }
- } else if (this.matchConstant.getText().length() == 0) {
- this.whereClause = this.whereClause + " 0";
- } else {
- this.whereClause = this.whereClause + " " + var1;
- }
- }
-
- if (this.user.DEBUG) {
- System.out.println("JDPWhereClause/buildWhereClause whereClause: " + this.whereClause);
- }
-
- }
-
- String cvtConstant(String var1, int var2) {
- return JDPUtils.isOdbcDate(var2) ? JDPDate.format(var1) : var1;
- }
-
- void layoutPanel() {
- ((Container)this).removeAll();
- if (this.smallConfig) {
- this.topPanel = new Panel();
- this.topPanel.setLayout(new GridLayout(this.numpanels + 1, 1));
- this.topPanel.add(this.field_0);
- if (this.field_1 != null) {
- this.topPanel.add(this.field_1);
- }
-
- if (this.field_2 != null) {
- this.topPanel.add(this.field_2);
- }
-
- if (this.field_3 != null) {
- this.topPanel.add(this.field_3);
- }
-
- Panel var2 = new Panel();
- ((Container)var2).setLayout(new GridLayout(1, 3));
- if (this.field_4 != null) {
- ((Container)var2).add(this.field_4);
- }
-
- if (this.field_5 != null) {
- ((Container)var2).add(this.field_5);
- }
-
- if (this.field_6 != null) {
- ((Container)var2).add(this.field_6);
- }
-
- this.topPanel.add(var2);
- ((Container)this).add("North", this.topPanel);
- } else {
- this.mainPanel = new Panel();
- this.mainPanel.setLayout(new JDPLineLayout(1));
- if (this.field_0 != null) {
- this.mainPanel.add("Left", this.field_0);
- }
-
- if (this.field_1 != null) {
- this.mainPanel.add("Left", this.field_1);
- }
-
- if (this.field_3 != null) {
- this.mainPanel.add("Left", this.field_3);
- }
-
- Panel var1 = new Panel();
- ((Container)var1).setLayout(new GridLayout(1, 3));
- if (this.field_4 != null) {
- ((Container)var1).add(this.field_4);
- }
-
- if (this.field_5 != null) {
- ((Container)var1).add(this.field_5);
- }
-
- if (this.field_6 != null) {
- ((Container)var1).add(this.field_6);
- }
-
- this.mainPanel.add("Left", var1);
- ((Container)this).add("North", this.mainPanel);
- }
- }
-
- public void setChooseFrom(String var1) {
- this.chooseFrom.select(var1);
- this.reloadMatchChoices();
- }
-
- public String getChooseFrom() {
- return this.chooseFrom.getSelectedItem();
- }
-
- public String getFromWhereClause() {
- return this.fromWhereClause + " AND " + this.whereClause;
- }
-
- public void setFont(Font var1) {
- if (this.chooseFrom != null) {
- this.chooseFrom.setFont(var1);
- }
-
- if (this.matchUsing != null) {
- this.matchUsing.setFont(var1);
- }
-
- if (this.matchTo != null) {
- this.matchTo.setFont(var1);
- }
-
- if (this.matchConstant != null) {
- this.matchConstant.setFont(var1);
- }
-
- if (this.field_4 != null) {
- this.field_4.setFont(var1);
- }
-
- if (this.field_5 != null) {
- this.field_5.setFont(var1);
- }
-
- if (this.field_6 != null) {
- this.field_6.setFont(var1);
- }
-
- this.currentFont = var1;
- }
-
- public Font getFont() {
- return this.currentFont;
- }
-
- public boolean handleEvent(Event var1) {
- switch (var1.id) {
- case 503:
- case 504:
- case 505:
- if (this.targetPanel == null && ((Component)this).getParent() instanceof Panel) {
- for(this.targetPanel = (Panel)((Component)this).getParent(); !(this.targetPanel instanceof JDPPanelLoader) && this.targetPanel.getParent() instanceof Panel; this.targetPanel = (Panel)this.targetPanel.getParent()) {
- }
-
- if (this.popuppanel != null && this.targetPanel != null) {
- this.popuppanel.setTarget(this.targetPanel);
- if (this.targetPanel != null) {
- this.targetPanel.add(this.popuppanel);
- }
- }
- }
-
- Object var5 = this;
- if (this != null) {
- Rectangle var8 = ((Component)this).bounds();
-
- while(var5 != null && !var5.equals(this.targetPanel)) {
- var1.x += var8.x;
- var1.y += var8.y;
- var5 = ((Component)var5).getParent();
- if (var5 != null) {
- var8 = ((Component)var5).bounds();
- }
- }
- }
-
- if (this.popuppanel != null) {
- this.popuppanel.postEvent(var1);
- }
-
- return false;
- case 1001:
- if (var1.target instanceof JDPComboBox) {
- if (var1.target.equals(this.chooseFrom)) {
- this.reloadMatchChoices();
- }
-
- return false;
- }
-
- if (var1.target instanceof Button) {
- String var2 = (String)var1.arg;
- if (var2.trim().compareTo("Search") == 0) {
- this.buildWhereClause();
- }
-
- if (var2.trim().compareTo("And") == 0) {
- String var3 = this.whereClause;
- this.buildWhereClause();
- this.whereClause = this.whereClause + " AND " + var3;
- var1.arg = "Search";
- }
-
- if (var2.trim().compareTo("Or") == 0) {
- String var6 = this.whereClause;
- this.buildWhereClause();
- this.whereClause = "(" + this.whereClause + " OR " + var6 + ")";
- var1.arg = "Search";
- }
-
- Event var7 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers);
- super.postEvent(var7);
- }
-
- if (var1.target instanceof TextField) {
- this.buildWhereClause();
- var1.arg = "Search";
- Event var4 = new Event(this, var1.when, var1.id, var1.x, var1.y, var1.key, var1.modifiers);
- super.postEvent(var4);
- }
-
- return false;
- default:
- return false;
- }
- }
-
- public void setForeground(Color var1) {
- if (this.chooseFrom != null) {
- this.chooseFrom.setForeground(var1);
- }
-
- if (this.matchUsing != null) {
- this.matchUsing.setForeground(var1);
- }
-
- if (this.matchTo != null) {
- this.matchTo.setForeground(var1);
- }
-
- if (this.matchConstant != null) {
- this.matchConstant.setForeground(var1);
- }
-
- if (this.field_4 != null) {
- this.field_4.setForeground(var1);
- }
-
- if (this.field_5 != null) {
- this.field_5.setForeground(var1);
- }
-
- if (this.field_6 != null) {
- this.field_6.setForeground(var1);
- }
-
- }
-
- public void setMatchUsing(String var1) {
- this.matchUsing.select(var1);
- }
-
- public String getMatchUsing() {
- return this.matchUsing.getSelectedItem();
- }
-
- public void setUpperCaseEntry(boolean var1) {
- this.upperCaseEntry = var1;
- }
-
- public boolean getUpperCaseEntry() {
- return this.upperCaseEntry;
- }
-
- public void setDSNType(String var1) {
- this.dsnType = var1;
- }
- }
-