Back to index

wims  3.65+svn20090927
ReorderTool.java
Go to the documentation of this file.
00001 package rene.zirkel.tools;
00002 
00003 // file: Hider.java
00004 
00005 import java.awt.*;
00006 import java.awt.event.*;
00007 
00008 import rene.gui.*;
00009 import rene.zirkel.Zirkel;
00010 import rene.zirkel.ZirkelCanvas;
00011 import rene.zirkel.constructors.*;
00012 import rene.zirkel.objects.ConstructionObject;
00013 
00014 class ReorderDialog extends CloseDialog
00015 {      String Name="";
00016        boolean Abort=true;
00017        TextField Input;
00018        
00019        public ReorderDialog (ZirkelCanvas zc, ConstructionObject o)
00020        {      super(zc.getFrame(),Zirkel.name("reorder.title"),true);
00021               setLayout(new BorderLayout());
00022               Panel north=new MyPanel();
00023               north.setLayout(new GridLayout(1,0));
00024               north.add(new MyLabel(o.getName()+" : "+Zirkel.name("reorder.message")));
00025               ConstructionObject ol=zc.getConstruction().lastDep(o);
00026               String s="";
00027               if (ol!=null) s=ol.getName();
00028               north.add(Input=new TextFieldAction(this,"Reorder",s));
00029               add("North",new Panel3D(north));
00030               Panel south=new MyPanel();
00031               south.add(new ButtonAction(this,Zirkel.name("ok"),"OK"));
00032               south.add(new ButtonAction(this,Zirkel.name("abort"),"Close"));
00033               add("South",south);
00034               pack();
00035               center(zc.getFrame());
00036               setVisible(true);
00037        }
00038        public void doAction (String o)
00039        {      if (o.equals("OK"))
00040               {      Abort=false;
00041                      Name=Input.getText();
00042                      doclose();
00043               }
00044               else super.doAction(o);
00045        }
00046        public String getResult ()
00047        {      return Name;
00048        }
00049        public boolean isAborted ()
00050        {      return Abort;
00051        }
00052 }
00053 
00054 public class ReorderTool extends ObjectConstructor
00055 {      public void mousePressed (MouseEvent e, ZirkelCanvas zc)
00056        {      double x=zc.x(e.getX()),y=zc.y(e.getY());
00057               ConstructionObject o=zc.selectObject(e.getX(),e.getY());
00058               if (o==null) return;
00059               ReorderDialog d=new ReorderDialog(zc,o);
00060               if (!d.isAborted())
00061               {      String name=d.getResult();
00062                      if (!name.equals(""))
00063                      {      ConstructionObject u=zc.getConstruction().find(name);
00064                             if (u==null)
00065                             {      zc.warning(Zirkel.name("reorder.notfound"));
00066                                    return;
00067                             }
00068                             if (!zc.getConstruction().reorder(o,u))
00069                                    zc.warning(Zirkel.name("reorder.warning"));
00070                      }
00071                      else
00072                             if (!zc.getConstruction().reorder(o,null))
00073                                    zc.warning(Zirkel.name("reorder.warning"));
00074               }
00075               zc.repaint();
00076        }
00077        public void mouseMoved (MouseEvent e, ZirkelCanvas zc, boolean simple)
00078        {      zc.indicateObjects(e.getX(),e.getY());
00079        }
00080 
00081        public void showStatus (ZirkelCanvas zc)
00082        {      zc.showStatus(
00083                      Zirkel.name("message.reorder","Reorder: Select an object!"));
00084        }
00085        public boolean useSmartBoard ()
00086        {      return false;
00087        }
00088 }