Back to index

wims  3.65+svn20090927
EditTool.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: Hider.java
00004 
00005 import java.awt.event.*;
00006 import java.util.*;
00007 
00008 import rene.zirkel.*;
00009 import rene.zirkel.constructors.*;
00010 import rene.zirkel.dialogs.*;
00011 import rene.zirkel.objects.ConstructionObject;
00012 
00013 public class EditTool extends ObjectConstructor
00014 {      boolean Other;
00015        Vector V;
00016        
00017        public void mousePressed (MouseEvent e, ConstructionObject o, 
00018               ZirkelCanvas zc)
00019        {      double x=zc.x(e.getX()),y=zc.y(e.getY());
00020               Other=(e.isShiftDown() && o==null);
00021               if (o==null)
00022               {      o=zc.selectObject(e.getX(),e.getY());
00023                      if (o==null) return;
00024               }
00025               if (o.isKeep()) return;
00026               if (Other)
00027               {      if (V==null) V=new Vector();
00028                      V.addElement(o);
00029                      o.setSelected(true);
00030                      zc.repaint();
00031                      return;
00032               }
00033               if (V!=null)
00034               {      V.addElement(o);
00035                      o.setSelected(true);
00036                      if (e.isControlDown())
00037                      {      EditConditionals d=new EditConditionals(zc.getFrame(),V);
00038                             zc.clearSelected();
00039                             zc.repaint();
00040                      }
00041                      else
00042                      {      ObjectsEditDialog d=new ObjectsEditDialog(zc.getFrame(),V);
00043                             zc.clearSelected();
00044                             d.setVisible(true);
00045                      }
00046               }
00047               else if(e.isControlDown())
00048               {      new EditConditionals(zc.getFrame(),o);
00049                      zc.validate();
00050                      zc.repaint();
00051               }
00052               else
00053               {      String oldname=o.getName();
00054                      o.edit(zc);
00055                      if (!oldname.equals(o.getName())) zc.updateTexts(o,oldname);
00056               }
00057               V=null; Other=false;
00058               zc.validate();
00059               zc.repaint();
00060        }
00061        
00062        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00063        {      zc.indicateObjects(e.getX(),e.getY(),true);
00064        }
00065 
00066        public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00067        {      mousePressed(e,null,zc);
00068        }
00069        
00070        public void showStatus (ZirkelCanvas zc)
00071        {      zc.showStatus(Zirkel.name("message.edit"));
00072        }
00073        
00074        public void reset (ZirkelCanvas zc)
00075        {      zc.clearSelected();
00076               V=null; Other=false;
00077        }
00078 }