home *** CD-ROM | disk | FTP | other *** search
- import java.awt.Button;
- import java.awt.Choice;
- import java.awt.Color;
- import java.awt.Component;
- import java.awt.Container;
- import java.awt.Event;
- import java.awt.Font;
- import java.awt.FontMetrics;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.awt.LayoutManager;
- import java.awt.Panel;
- import java.awt.Rectangle;
- import java.awt.image.ImageObserver;
- import java.util.Date;
- import java.util.Vector;
-
- public class JDPDragItem extends Panel {
- JDPUser user;
- Panel targetPanel;
- Image offscreen;
- Rectangle offscreensize;
- // $FF: renamed from: gr java.awt.Graphics
- Graphics field_0;
- Panel parent;
- Image thisImage;
- Component thisDrawComponent;
- Rectangle thisRectangle;
- Object thisDropKey;
- Rectangle Bounds;
- Vector dropRects;
- int[] widths;
- Font lastFont;
- // $FF: renamed from: fm java.awt.FontMetrics
- FontMetrics field_1;
- int maxXwidth;
- Vector activeAreas;
- String prevMessage;
- String popupMessage;
- String statusBarMessage;
- boolean alreadyDragging;
- Event thisEvent;
- int startElement = -1;
- int endElement = -1;
- Rectangle startRectangle;
- Rectangle endRectangle;
- Component startComponent;
- Component endComponent;
- boolean firstDrag = true;
- int xoffset;
- int yoffset;
- Panel lastParent;
- JDPTreePicker lastDropTree;
- JDPTreeBranch lastSelectedBranch;
- Color textHighlight;
- Color backColor;
-
- void position(int var1, int var2) {
- ((Component)this).reshape(var1, var2, this.thisRectangle.width + 1, this.thisRectangle.height + 1);
- }
-
- public void removeDropComponents(Component var1) {
- for(int var2 = 0; var2 < this.activeAreas.size(); ++var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- Component var4 = (Component)var3.elementAt(2);
- String var5 = (String)var3.elementAt(3);
- if (var4 == var1 && var5.equals("Drop")) {
- this.activeAreas.removeElementAt(var2);
- Object var6 = null;
- --var2;
- }
- }
-
- }
-
- public void setTarget(Panel var1) {
- this.targetPanel = var1;
- }
-
- public void addDropComponent(Component var1, Container var2, Object var3, String var4) {
- this.addComponent(var1, var2, "Drop", var3, var4);
- }
-
- public void addDropComponent(Component var1, Panel var2, Object var3, String var4) {
- this.addComponent(var1, (Container)var2, "Drop", var3, var4);
- }
-
- void addComponent(Component var1, Container var2, String var3, Object var4, String var5) {
- Vector var6 = new Vector();
- var6.addElement(var1);
- if (var1 instanceof JDPButton) {
- JDPButton var7 = new JDPButton(((JDPButton)var1).getLabel());
- var6.addElement(var7);
- } else if (var1 instanceof Button) {
- Button var8 = new Button(((Button)var1).getLabel());
- var6.addElement(var8);
- } else if (var1 instanceof Choice) {
- Choice var9 = new Choice();
- var9.addItem(((Choice)var1).getSelectedItem());
- var6.addElement(var9);
- } else if (var1 instanceof JDPChoice) {
- Choice var10 = new Choice();
- var10.addItem(((Choice)var1).getSelectedItem());
- var6.addElement(var10);
- } else {
- var6.addElement(var1);
- }
-
- var6.addElement(var2);
- var6.addElement(var3);
- var6.addElement(var4);
- var6.addElement((Object)null);
- var6.addElement(var5);
- this.activeAreas.addElement(var6);
- }
-
- public void paint(Graphics var1) {
- this.update(var1);
- }
-
- public void addDragRectangle(Rectangle var1, Image var2, Panel var3, Object var4) {
- this.addRectangle(var1, var2, var3, "Drag", var4, (String)null, (JDPTreeBranch)null);
- }
-
- public void addDragRectangle(Rectangle var1, Image var2, Panel var3, Object var4, JDPTreeBranch var5) {
- this.addRectangle(var1, var2, var3, "Drag", var4, (String)null, var5);
- }
-
- public JDPTreeBranch[] getDraggedBranch(JDPTreePicker var1) {
- Rectangle var2 = this.getDragRectangle();
- if (var2 == null) {
- return null;
- } else {
- Rectangle var3 = new Rectangle(var2.x, var2.y, var2.width, var2.height);
- var3.x -= var1.xOffset - var1.dragXoffset;
- var3.y -= var1.yOffset - var1.dragYoffset;
- return var1.getTreeBranch(var3);
- }
- }
-
- public JDPTreeBranch[] getDroppedBranch(JDPTreePicker var1) {
- return var1.getTreeBranch(this.getDropRectangle());
- }
-
- public void update(Graphics var1) {
- Rectangle var2 = ((Component)this).bounds();
- if (this.offscreen != null && var2.width == this.offscreensize.width && var2.height == this.offscreensize.height) {
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- } else {
- if (var2.width < 10) {
- var2.width = 10;
- }
-
- if (var2.height < 10) {
- var2.height = 10;
- }
-
- this.offscreen = ((Component)this).createImage(var2.width, var2.height);
- this.offscreensize = var2;
- this.field_0 = this.offscreen.getGraphics();
- this.Bounds = ((Component)this).bounds();
- if (this.thisImage != null) {
- this.field_0.drawImage(this.thisImage, 0, 0, (ImageObserver)null);
- this.field_0.setColor(Color.black);
- this.field_0.drawRect(0, 0, this.Bounds.width - 3, this.Bounds.height - 3);
- this.field_0.setColor(this.backColor);
- this.field_0.drawLine(0, this.Bounds.height - 2, 0, this.Bounds.height - 2);
- this.field_0.drawLine(0, this.Bounds.height - 1, 1, this.Bounds.height - 2);
- this.field_0.drawLine(this.Bounds.width - 2, 0, this.Bounds.width - 2, 0);
- this.field_0.drawLine(this.Bounds.width - 1, 0, this.Bounds.width - 1, 1);
- this.field_0.setColor(JDPUtils.darker(JDPUtils.darker(this.backColor)));
- this.field_0.drawLine(1, this.Bounds.height - 2, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.drawLine(this.Bounds.width - 2, 1, this.Bounds.width - 2, this.Bounds.height - 2);
- this.field_0.setColor(JDPUtils.darker(this.backColor));
- this.field_0.drawLine(2, this.Bounds.height - 1, this.Bounds.width - 1, this.Bounds.height - 1);
- this.field_0.drawLine(this.Bounds.width - 1, 2, this.Bounds.width - 1, this.Bounds.height - 1);
- }
-
- var1.drawImage(this.offscreen, 0, 0, (ImageObserver)null);
- }
- }
-
- public JDPDragItem(JDPUser var1, Panel var2) {
- this.user = var1;
- this.targetPanel = var2;
- this.textHighlight = JDPUtils.getTextHighlight();
- this.backColor = JDPUtils.getControlColor();
- ((Component)this).setFont(var1.plainFont);
- ((Container)this).setLayout((LayoutManager)null);
- ((Component)this).setBackground(Color.white);
- if (!JDPUser.classactivated) {
- System.out.println("Software Violation - this class may only be used in conjunction with JDesignerPro.");
- } else {
- this.removeAllComponents();
- ((Component)this).hide();
- this.offscreen = ((Component)this).createImage(10, 10);
- }
- }
-
- public void addDropRectangle(Rectangle var1, Panel var2, Object var3, String var4) {
- this.addRectangle(var1, (Image)null, var2, "Drop", var3, var4, (JDPTreeBranch)null);
- }
-
- public void addDropRectangle(Rectangle var1, Panel var2, Object var3, String var4, JDPTreeBranch var5) {
- this.addRectangle(var1, (Image)null, var2, "Drop", var3, var4, var5);
- }
-
- void addRectangle(Rectangle var1, Image var2, Panel var3, String var4, Object var5, String var6, JDPTreeBranch var7) {
- Rectangle var8 = new Rectangle(var1.x, var1.y, var1.width, var1.height);
- Object var9 = (Component)var3;
- Rectangle var10 = ((Component)var9).bounds();
-
- while(var9 != null && !var9.equals(this.targetPanel)) {
- var10 = ((Component)var9).bounds();
- var8.x += var10.x;
- var8.y += var10.y;
- var9 = ((Component)var9).getParent();
- if (var9 == null) {
- var8.x += 2000;
- }
- }
-
- Vector var11 = new Vector();
- var11.addElement(var8);
- var11.addElement(var2);
- var11.addElement(var3);
- var11.addElement(var4);
- var11.addElement(var5);
- var11.addElement(var1);
- var11.addElement(var6);
- var11.addElement(var7);
- this.activeAreas.addElement(var11);
- }
-
- public void removeAllComponents() {
- this.activeAreas = null;
- this.activeAreas = new Vector();
- }
-
- public void removeAllComponents(Component var1) {
- for(int var2 = 0; var2 < this.activeAreas.size(); ++var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- Component var4 = (Component)var3.elementAt(2);
- if (var4.equals(var1)) {
- this.activeAreas.removeElementAt(var2);
- Object var5 = null;
- --var2;
- }
- }
-
- }
-
- public void addDragComponent(Component var1, Panel var2, Object var3) {
- this.addComponent(var1, var2, "Drag", var3, (String)null);
- }
-
- public void removeComponent(Component var1) {
- for(int var2 = 0; var2 < this.activeAreas.size(); ++var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- if (var1.equals((Component)var3.elementAt(0))) {
- this.activeAreas.removeElementAt(var2);
- return;
- }
- }
-
- }
-
- public Component getDraggedComponent() {
- return this.startComponent;
- }
-
- public Component getDroppedComponent() {
- return this.endComponent;
- }
-
- void display(int var1, int var2) {
- this.startElement = -1;
- this.endElement = -1;
- this.startRectangle = null;
- this.endRectangle = null;
- this.startComponent = null;
- this.endComponent = null;
- ((Container)this).removeAll();
- this.position(var1, var2);
- if (this.thisDrawComponent != null) {
- ((Container)this).add(this.thisDrawComponent);
- this.thisDrawComponent.reshape(0, 0, ((Component)this).bounds().width, ((Component)this).bounds().height);
- } else {
- ((Component)this).repaint();
- }
-
- if (!this.alreadyDragging) {
- ((Component)this).show();
- }
-
- if (!this.alreadyDragging && System.getProperty("java.vendor").startsWith("Netscape") && System.getProperty("os.name").equals("SunOS")) {
- Container var3 = ((Component)this).getParent();
- var3.remove(this);
- var3.add(this);
- ((Component)this).show();
- }
-
- this.alreadyDragging = true;
- ((Component)this).requestFocus();
- }
-
- public void layout() {
- ((Component)this).repaint();
- }
-
- public boolean handleEvent(Event var1) {
- this.endElement = -1;
- switch (var1.id) {
- case 501:
- this.alreadyDragging = false;
- this.dropRects = null;
- this.firstDrag = true;
- return true;
- case 502:
- if (this.dropRects != null) {
- for(int var12 = this.dropRects.size() - 1; var12 >= 0; --var12) {
- Vector var16 = (Vector)this.dropRects.elementAt(var12);
- Rectangle var19 = (Rectangle)var16.elementAt(0);
- Object var22 = var16.elementAt(2);
- if (var22 instanceof JDPTreePicker && var19.intersects(this.Bounds)) {
- Rectangle var26 = (Rectangle)var16.elementAt(4);
- this.endElement = var12;
- this.endRectangle = new Rectangle(var26.x, var26.y, var26.width, var26.height);
- break;
- }
- }
-
- if (this.endElement < 0) {
- for(int var13 = 0; var13 < this.dropRects.size(); ++var13) {
- Vector var17 = (Vector)this.dropRects.elementAt(var13);
- Rectangle var20 = (Rectangle)var17.elementAt(0);
- Object var23 = var17.elementAt(3);
- if (var23 instanceof Component && var20.inside(var1.x, var1.y)) {
- this.endElement = var13;
- this.endComponent = (Component)var23;
- break;
- }
- }
- }
- }
-
- this.alreadyDragging = false;
- this.firstDrag = true;
- this.dropRects = null;
- ((Component)this).hide();
- this.offscreen = null;
- if (this.endElement >= 0) {
- Event var14 = new Event(this, (new Date()).getTime(), 1001, var1.x, var1.y, var1.key, var1.modifiers, "JDPDragItem");
- var14.modifiers = var1.modifiers;
- var14.target = this;
- if (this.lastParent != null) {
- this.lastParent.postEvent(var14);
- }
-
- this.targetPanel.postEvent(var14);
- }
-
- return true;
- case 503:
- case 504:
- return true;
- case 505:
- default:
- this.firstDrag = true;
- return false;
- case 506:
- this.lastParent = null;
- if (((Component)this).isVisible() && !this.firstDrag) {
- this.alreadyDragging = true;
- }
-
- if (this.alreadyDragging && var1.id == 506) {
- ((Component)this).move(var1.x - this.xoffset, var1.y - this.yoffset);
- this.Bounds = ((Component)this).bounds();
- if (this.dropRects != null) {
- for(int var11 = this.dropRects.size() - 1; var11 >= 0; --var11) {
- Vector var15 = (Vector)this.dropRects.elementAt(var11);
- Rectangle var18 = (Rectangle)var15.elementAt(0);
- if (var18.intersects(this.Bounds)) {
- Object var21 = var15.elementAt(2);
- if (var21 instanceof JDPTreePicker) {
- JDPTreePicker var25 = (JDPTreePicker)var21;
- this.lastDropTree = var25;
- if (!var25.allowChangeOrder) {
- JDPTreeBranch var28 = (JDPTreeBranch)var15.elementAt(3);
- if (!var28.selected) {
- if (this.lastSelectedBranch == null) {
- var25.resetSelections();
- } else {
- this.lastSelectedBranch.selected = false;
- }
-
- var28.selected = true;
- this.lastSelectedBranch = var28;
- ((Component)var25).requestFocus();
- var25.reDraw();
- String var30 = (String)var15.elementAt(1);
- this.user.mainmsg.setStatusMsg(var30, 0, 0, (Component)null);
- return true;
- }
- }
-
- return true;
- }
- }
- }
-
- if (this.lastDropTree != null) {
- if (this.lastSelectedBranch == null) {
- this.lastDropTree.resetSelections();
- } else {
- this.lastSelectedBranch.selected = false;
- this.lastDropTree.reDraw();
- }
-
- this.lastDropTree = null;
- this.lastSelectedBranch = null;
- }
-
- if (this.user.mainmsg.isStatusMsg()) {
- this.user.mainmsg.clearPopupMsg();
- }
-
- return true;
- }
- }
-
- this.Bounds = ((Component)this).bounds();
- this.user.mainmsg.clearPopupMsg();
- if (this.firstDrag && var1.id == 506) {
- this.firstDrag = false;
- return true;
- } else {
- if (this.dropRects == null && var1.id == 506) {
- this.dropRects = new Vector();
- }
-
- if (!var1.target.equals(this) && this.targetPanel != null && this.activeAreas != null && this.activeAreas.size() > 0 && var1.id == 506) {
- for(int var2 = this.activeAreas.size() - 1; var2 >= 0; --var2) {
- Vector var3 = (Vector)this.activeAreas.elementAt(var2);
- String var4 = (String)var3.elementAt(3);
- Object var5 = var3.elementAt(4);
- if (var4.equals("Drag") && !this.alreadyDragging || var4.equals("Drop") && this.alreadyDragging && this.thisDropKey.equals(var5)) {
- if (var3.elementAt(0) instanceof Rectangle) {
- Rectangle var24 = (Rectangle)var3.elementAt(0);
- Rectangle var27 = (Rectangle)var3.elementAt(5);
- Panel var29 = (Panel)var3.elementAt(2);
- this.lastParent = var29;
- if (((Component)var29).isShowing() && this.alreadyDragging && var4.equals("Drop")) {
- Vector var33 = new Vector();
- var33.addElement(var24);
- var33.addElement(var3.elementAt(6));
- var33.addElement(var3.elementAt(2));
- var33.addElement(var3.elementAt(7));
- var33.addElement(var3.elementAt(5));
- this.dropRects.addElement(var33);
- } else if (var24.inside(var1.x, var1.y) && ((Component)var29).isShowing()) {
- if (!this.alreadyDragging && var1.target.equals(var29)) {
- this.thisRectangle = new Rectangle(var27.x - 2, var27.y - 2, var27.width + 2, var27.height + 2);
- Image var32 = (Image)var3.elementAt(1);
- this.thisImage = ((Component)this).createImage(var27.width + 4, var27.height + 4);
- Graphics var34 = this.thisImage.getGraphics();
- var34.drawImage(var32, -var27.x - 100, -var27.y, (ImageObserver)null);
- this.thisDrawComponent = null;
- this.xoffset = var1.x - var24.x;
- this.yoffset = var1.y - var24.y;
- this.display(var1.x - this.xoffset, var1.y - this.yoffset);
- this.startElement = var2;
- this.thisDropKey = var3.elementAt(4);
- this.startRectangle = new Rectangle(var27.x, var27.y, var27.width, var27.height);
- this.dropRects = null;
- return true;
- }
-
- this.endElement = var2;
- this.endRectangle = new Rectangle(var27.x, var27.y, var27.width, var27.height);
- break;
- }
- } else if (var3.elementAt(0) instanceof Component) {
- Component var6 = (Component)var3.elementAt(0);
- if (var6 != null && var6.isVisible()) {
- Rectangle var7 = var6.bounds();
- Container var8 = var6.getParent();
- if (var8 != null && ((Component)var8).isVisible()) {
- Rectangle var9 = ((Component)var8).bounds();
-
- while(var8 != null && !var8.equals(this.targetPanel)) {
- var9 = ((Component)var8).bounds();
- var7.x += var9.x;
- var7.y += var9.y;
- var8 = ((Component)var8).getParent();
- if (var8 == null || !((Component)var8).isVisible()) {
- var7.x += 1000;
- }
- }
-
- if (this.alreadyDragging && var4.equals("Drop")) {
- Vector var10 = new Vector();
- var10.addElement(var7);
- var10.addElement(var3.elementAt(6));
- var10.addElement(var3.elementAt(2));
- var10.addElement(var3.elementAt(0));
- this.dropRects.addElement(var10);
- } else if (var7.inside(var1.x, var1.y)) {
- if (!this.alreadyDragging) {
- this.thisDrawComponent = (Component)var3.elementAt(1);
- this.thisImage = null;
- this.thisRectangle = var7;
- this.xoffset = var1.x - var7.x;
- this.yoffset = var1.y - var7.y;
- this.display(var1.x - this.xoffset, var1.y - this.yoffset);
- this.startElement = var2;
- this.thisDropKey = var3.elementAt(4);
- this.startComponent = var6;
- this.dropRects = null;
- return true;
- }
-
- this.endElement = var2;
- this.endComponent = var6;
- return true;
- }
- }
- }
- }
- }
- }
- }
-
- return true;
- }
- }
- }
-
- public Rectangle getDragRectangle() {
- return this.startRectangle;
- }
-
- public Rectangle getDropRectangle() {
- return this.endRectangle;
- }
- }
-