home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Event;
- import java.awt.Panel;
- import java.util.Date;
-
- public class JDPMethodTree extends JDPTreePicker {
- JDPSourceItem classHeader;
- JDPTreeBranch globalBranch;
- JDPTreeBranch constructorBranch;
- JDPTreeBranch accessorBranch;
- JDPTreeBranch generalBranch;
- JDPTreeBranch publicBranch;
- JDPTreeBranch privateBranch;
- boolean displayParmTypes = true;
- boolean displayParmNames = true;
-
- public boolean saveSource(String var1, String var2) {
- boolean var3 = super.user.u.writeToFile(var1, this.getCompleteSource(var2), "w+");
- if (var3) {
- super.user.mainmsg.setStatusMsg("Source file successfully saved.", 10);
- } else {
- super.user.mainmsg.setStatusMsg("Write to source file failed.", 10);
- }
-
- return var3;
- }
-
- public void setSource(String var1) {
- JDPTreeBranch var2 = ((JDPTreePicker)this).getCurrentBranch();
- if (var2 != null && var2.thisObject != null) {
- JDPSourceItem var3 = (JDPSourceItem)var2.thisObject;
- var3.actualSource = var1;
- }
- }
-
- public void selectItemWithSourceLine(int var1) {
- JDPSourceItem var5 = null;
- JDPTreeBranch var2 = super.treeRoot;
- if (var2 != null) {
- JDPSourceItem var6 = (JDPSourceItem)var2.thisObject;
-
- for(int var7 = 0; var7 < var2.leaves.size(); ++var7) {
- JDPTreeBranch var3 = (JDPTreeBranch)var2.leaves.elementAt(var7);
-
- for(int var8 = 0; var8 < var3.leaves.size(); ++var8) {
- JDPTreeBranch var4 = (JDPTreeBranch)var3.leaves.elementAt(var8);
- var6 = (JDPSourceItem)var4.thisObject;
- if (var6.startingLineNumber > var1) {
- if (var5 != null) {
- this.select(var5);
- }
-
- return;
- }
-
- var5 = var6;
- }
- }
-
- if (var5 != null) {
- this.select(var5);
- }
-
- }
- }
-
- public void setClassDescriptor(JDPSourceItem var1) {
- this.classHeader = var1;
- ((JDPTreePicker)this).setRoot(var1.name, true, 9);
- super.treeRoot.thisObject = var1;
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Global Variables", 4);
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Constructors", 7);
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Accessors", 1);
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Public", 1);
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Methods", 0);
- ((JDPTreePicker)this).addBranch(super.treeRoot, "Private", 2);
- this.globalBranch = ((JDPTreePicker)this).getBranch("Global Variables");
- this.constructorBranch = ((JDPTreePicker)this).getBranch("Constructors");
- this.accessorBranch = ((JDPTreePicker)this).getBranch("Accessors");
- this.generalBranch = ((JDPTreePicker)this).getBranch("Methods");
- this.publicBranch = ((JDPTreePicker)this).getBranch("Public");
- this.privateBranch = ((JDPTreePicker)this).getBranch("Private");
-
- for(int var3 = 0; var3 < var1.components.size(); ++var3) {
- JDPSourceItem var2 = (JDPSourceItem)var1.components.elementAt(var3);
- this.addItem(var2);
- }
-
- ((JDPTreePicker)this).sortTree(this.globalBranch);
- ((JDPTreePicker)this).sortTree(this.constructorBranch);
- ((JDPTreePicker)this).sortTree(this.accessorBranch);
- ((JDPTreePicker)this).sortTree(this.generalBranch);
- ((JDPTreePicker)this).sortTree(this.publicBranch);
- ((JDPTreePicker)this).sortTree(this.privateBranch);
- ((JDPTreePicker)this).select(super.treeRoot);
- ((JDPTreePicker)this).reDraw();
- }
-
- void moveItem(JDPTreeBranch var1, JDPTreeBranch var2, JDPTreeBranch var3) {
- var1.leaves.removeElement(var3);
- ((JDPTreePicker)this).addBranch(var2, this.constructName((JDPSourceItem)var3.thisObject), this.chooseIcon((JDPSourceItem)var3.thisObject));
- JDPTreeBranch var4 = ((JDPTreePicker)this).getLastAddedBranch();
- var4.thisObject = var3.thisObject;
- var3.thisObject = null;
- Object var5 = null;
- ((JDPTreePicker)this).sortTree(var1);
- ((JDPTreePicker)this).sortTree(var2);
- ((JDPTreePicker)this).select(var4);
- }
-
- String constructName(JDPSourceItem var1) {
- String var2 = var1.name;
- if (var1.type == 3) {
- var2 = var2 + "(" + var1.varType + ")";
- } else if (var1.type == 1 || var1.type == 2) {
- var2 = var2 + "(";
- if (var1.parmTypes != null) {
- for(int var3 = 0; var3 < var1.parmTypes.size(); ++var3) {
- if (var3 > 0) {
- var2 = var2 + ", ";
- }
-
- if (this.displayParmTypes) {
- var2 = var2 + (String)var1.parmTypes.elementAt(var3);
- }
-
- if (this.displayParmNames && this.displayParmTypes) {
- var2 = var2 + " ";
- }
-
- if (this.displayParmNames && var1.parmNames.size() > var3) {
- var2 = var2 + (String)var1.parmNames.elementAt(var3);
- }
- }
- }
-
- var2 = var2 + ")";
- }
-
- return var2;
- }
-
- int chooseIcon(JDPSourceItem var1) {
- int var2 = 0;
- if (var1.isprivate) {
- var2 += 2;
- } else if (var1.ispublic) {
- ++var2;
- }
-
- if (var1.type == 3) {
- var2 += 3;
- }
-
- if (var1.type == 1) {
- var2 += 6;
- }
-
- if (var1.type == 0) {
- var2 = 9;
- }
-
- return var2;
- }
-
- public void select(JDPSourceItem var1) {
- JDPTreeBranch var2 = ((JDPTreePicker)this).getBranch((Object)var1);
- if (var2 != null) {
- ((JDPTreePicker)this).select(var2);
- }
-
- ((JDPTreePicker)this).reDraw();
- }
-
- public void changeAppName(String var1) {
- JDPSourceItem var2 = (JDPSourceItem)super.treeRoot.thisObject;
- var2.name = var1;
- JDPSourceParser.reCreateHeader(var2);
- this.refreshBranchFromItem(var2);
-
- for(int var4 = 0; var4 < var2.components.size(); ++var4) {
- JDPSourceItem var3 = (JDPSourceItem)var2.components.elementAt(var4);
- if (var3.type == 1) {
- var3.name = var1;
- JDPSourceParser.reCreateHeader(var3);
- this.refreshBranchFromItem(var3);
- }
- }
-
- }
-
- public String getCompleteSource(String var1) {
- StringBuffer var7 = new StringBuffer();
- int var8 = 0;
- JDPTreeBranch var2 = super.treeRoot;
- if (var2 == null) {
- return "";
- } else {
- JDPSourceItem var5 = (JDPSourceItem)var2.thisObject;
- var5.name = var1;
- var5.lastModified = new Date();
- JDPSourceParser.reCreateHeader(var5);
- this.refreshBranchFromItem(var5);
-
- for(int var9 = 0; var9 < var5.components.size(); ++var9) {
- JDPSourceItem var6 = (JDPSourceItem)var5.components.elementAt(var9);
- if (var6.type == 1) {
- var6.name = var1;
- JDPSourceParser.reCreateHeader(var6);
- this.refreshBranchFromItem(var6);
- }
- }
-
- if (var5 != null && var5.actualSource != null) {
- var7.append(var5.actualSource);
- var7.append("\n");
- var8 += this.countSourceLines(var5.actualSource) + 1;
- }
-
- var5.startingLineNumber = 0;
- int var14 = var5.type;
-
- for(int var10 = 0; var10 < var2.leaves.size(); ++var10) {
- JDPTreeBranch var3 = (JDPTreeBranch)var2.leaves.elementAt(var10);
-
- for(int var11 = 0; var11 < var3.leaves.size(); ++var11) {
- JDPTreeBranch var4 = (JDPTreeBranch)var3.leaves.elementAt(var11);
- var5 = (JDPSourceItem)var4.thisObject;
- if (var5.type != var14) {
- var7.append("\n");
- ++var8;
- }
-
- var14 = var5.type;
- if (var5 != null && var5.actualSource != null) {
- var7.append(var5.actualSource);
- var7.append("\n");
- ++var8;
- var5.startingLineNumber = var8;
- var8 += this.countSourceLines(var5.actualSource);
- }
- }
- }
-
- var7.append("}\n");
- super.treeRoot.name = var1;
- ((JDPTreePicker)this).reDraw();
- return var7.toString();
- }
- }
-
- public JDPMethodTree(JDPUser var1) {
- super.showCompPosition = true;
- ((JDPTreePicker)this).createTree(var1, (Panel)null, (JDPDragItem)null);
- ((JDPTreePicker)this).setIconImagePath("Images/JDPSRCE.gif");
- ((JDPTreePicker)this).setMinWidth(200);
- }
-
- public JDPMethodTree(JDPUser var1, Panel var2) {
- super.showCompPosition = true;
- ((JDPTreePicker)this).createTree(var1, var2, (JDPDragItem)null);
- ((JDPTreePicker)this).setIconImagePath("Images/JDPSRCE.gif");
- ((JDPTreePicker)this).setMinWidth(200);
- }
-
- public JDPMethodTree(JDPUser var1, Panel var2, JDPDragItem var3) {
- super.showCompPosition = true;
- ((JDPTreePicker)this).createTree(var1, var2, var3);
- ((JDPTreePicker)this).setIconImagePath("Images/JDPSRCE.gif");
- ((JDPTreePicker)this).setMinWidth(200);
- }
-
- boolean addItem(JDPSourceItem var1) {
- boolean var2 = false;
- if (var1.type == 3) {
- var2 = this.addItem(this.globalBranch, var1);
- } else if (var1.type == 1) {
- var2 = this.addItem(this.constructorBranch, var1);
- } else if (var1.type == 2) {
- if (var1.ispublic) {
- if (!var1.name.startsWith("get") && !var1.name.startsWith("set") && !var1.name.startsWith("is")) {
- var2 = this.addItem(this.publicBranch, var1);
- } else {
- var2 = this.addItem(this.accessorBranch, var1);
- }
- } else if (var1.isprivate) {
- var2 = this.addItem(this.privateBranch, var1);
- } else {
- var2 = this.addItem(this.generalBranch, var1);
- }
- }
-
- this.checkIfUnsed();
- return var2;
- }
-
- boolean addItem(JDPTreeBranch var1, JDPSourceItem var2) {
- if (((JDPTreePicker)this).getBranch(this.constructName(var2)) != null) {
- return false;
- } else {
- ((JDPTreePicker)this).addBranch(var1, this.constructName(var2), this.chooseIcon(var2));
- ((JDPTreePicker)this).getLastAddedBranch().thisObject = var2;
- return true;
- }
- }
-
- void checkIfUnsed() {
- JDPTreeBranch var1 = ((JDPTreePicker)this).getLastAddedBranch();
- JDPSourceItem var2 = (JDPSourceItem)var1.thisObject;
- var1.compPosition = "";
- if (var2 != null) {
- if (var2.node == null || var2.node.leftNodes == null) {
- if (var2.type == 3 || var2.type == 2 && var2.isprivate) {
- var1.compPosition = "UNUSED";
- }
-
- }
- }
- }
-
- int countSourceLines(String var1) {
- int var2 = 0;
-
- for(int var3 = var1.indexOf("\n"); var3 >= 0; var3 = var1.indexOf("\n", var3 + 1)) {
- ++var2;
- }
-
- return var2;
- }
-
- public void setShowParmTypes(boolean var1) {
- this.displayParmTypes = var1;
- ((JDPTreePicker)this).reDraw();
- }
-
- public boolean getShowParmTypes() {
- return this.displayParmTypes;
- }
-
- public void clear() {
- ((JDPTreePicker)this).setRoot("", false, 9);
- }
-
- public void setShowParmNames(boolean var1) {
- this.displayParmNames = var1;
- ((JDPTreePicker)this).reDraw();
- }
-
- void recalcSourceLines() {
- int var1 = 0;
- JDPTreeBranch var2 = super.treeRoot;
- JDPSourceItem var5 = (JDPSourceItem)var2.thisObject;
- if (var5 != null && var5.actualSource != null) {
- var1 += this.countSourceLines(var5.actualSource) + 1;
- }
-
- var5.startingLineNumber = 0;
- int var6 = var5.type;
-
- for(int var7 = 0; var7 < var2.leaves.size(); ++var7) {
- JDPTreeBranch var3 = (JDPTreeBranch)var2.leaves.elementAt(var7);
-
- for(int var8 = 0; var8 < var3.leaves.size(); ++var8) {
- JDPTreeBranch var4 = (JDPTreeBranch)var3.leaves.elementAt(var8);
- var5 = (JDPSourceItem)var4.thisObject;
- if (var5.type != var6) {
- ++var1;
- }
-
- var6 = var5.type;
- if (var5 != null && var5.actualSource != null) {
- ++var1;
- var5.startingLineNumber = var1;
- var1 += this.countSourceLines(var5.actualSource);
- }
- }
- }
-
- }
-
- public boolean getShowParmNames() {
- return this.displayParmNames;
- }
-
- public boolean handleEvent(Event var1) {
- return super.handleEvent(var1);
- }
-
- public JDPSourceItem getSelectedSourceItem() {
- JDPTreeBranch var1 = ((JDPTreePicker)this).getCurrentBranch();
- return var1 != null ? (JDPSourceItem)var1.thisObject : null;
- }
-
- public void refreshBranchFromItem(JDPSourceItem var1) {
- JDPTreeBranch var2 = ((JDPTreePicker)this).getBranch((Object)var1);
- if (var2 != null) {
- var2.name = this.constructName(var1);
- var2.icon = this.chooseIcon(var1);
- this.checkItemPosition(var1);
- ((JDPTreePicker)this).reDraw();
- }
-
- }
-
- public void remove(JDPSourceItem var1) {
- JDPTreeBranch var2 = ((JDPTreePicker)this).getBranch((Object)var1);
- if (var2 != null) {
- ((JDPTreePicker)this).removeTreeBranch(var2);
- ((JDPTreePicker)this).reDraw();
- }
-
- }
-
- void checkItemPosition(JDPSourceItem var1) {
- if (var1.type == 2) {
- JDPTreeBranch[] var2 = ((JDPTreePicker)this).getTreeBranch(var1);
- if (var2 != null) {
- int var3 = var2.length - 2;
- if (var1.ispublic) {
- if (!var1.name.startsWith("get") && !var1.name.startsWith("set") && !var1.name.startsWith("is")) {
- if (!var2[var3].equals(this.publicBranch)) {
- this.moveItem(var2[var3], this.publicBranch, var2[var3 + 1]);
- return;
- }
- } else if (!var2[var3].equals(this.accessorBranch)) {
- this.moveItem(var2[var3], this.accessorBranch, var2[var3 + 1]);
- return;
- }
- } else {
- if (var1.isprivate) {
- if (!var2[var3].equals(this.privateBranch)) {
- this.moveItem(var2[var3], this.privateBranch, var2[var3 + 1]);
- }
-
- this.checkIfUnsed();
- return;
- }
-
- if (!var2[var3].equals(this.generalBranch)) {
- this.moveItem(var2[var3], this.generalBranch, var2[var3 + 1]);
- }
- }
- }
- }
-
- }
- }
-