Back to index

wims  3.65+svn20090927
ExportTemplateDialog.java
Go to the documentation of this file.
00001 package rene.zirkel.dialogs;
00002 
00003 import java.awt.*;
00004 
00005 import rene.gui.*;
00006 import rene.util.*;
00007 import rene.zirkel.Zirkel;
00008 import rene.zirkel.ZirkelFrame;
00009 import rene.zirkel.construction.Construction;
00010 
00011 public class ExportTemplateDialog extends HelpCloseDialog
00012 {      ZirkelFrame ZF;
00013        Construction C;
00014        TextField PageTitle,CFile,Codebase;
00015        Checkbox Job;
00016        Panel CP;
00017        Choice Style;
00018        boolean OK=false;
00019        IconBar IBa,IBb;
00020        boolean SaveDimensions=true;
00021        boolean Restrict;
00022 
00023        static String ISb[]={"back","delete","undo","showcolor","showname","showvalue",
00024               "color","hidden","macro0","replay","arrow","obtuse","solid","grid",
00025               "thickness0","type0","partial","plines",
00026               "twolines","macrobar","qintersection","qpointon","qchoice","indicate",
00027               "draw","rename","function"};
00028        static String ISb0[]={"back","delete","undo","showcolor","showname","showvalue",
00029               "color","hidden","macro","replay","arrow","obtuse","solid","grid",
00030               "thickness","type","partial","plines",
00031               "twolines","macrobar","qintersection","qpointon","qchoice","indicate",
00032               "draw","rename","function"};
00033        
00034        static String ST[]={"plain","3D","icons","full","nonvisual","breaks"};
00035        
00036        public ExportTemplateDialog (ZirkelFrame zf, Construction c, boolean restrict)
00037        {      super(zf,Zirkel.name("export.title"),true);
00038               ZF=zf; C=c; Restrict=restrict;
00039               setLayout(new BorderLayout());
00040               
00041               Panel p=new MyPanel();
00042               p.setLayout(new GridLayout(0,2));
00043 
00044               p.add(new MyLabel(Zirkel.name("export.pagetitle")));
00045               p.add(PageTitle=new TextFieldAction(this,"export.pagetitle",32));
00046               PageTitle.setText(FileName.purefilename(zf.Filename));
00047 
00048               p.add(new MyLabel(Zirkel.name("export.codebase")));
00049               p.add(Codebase=new TextFieldAction(this,"export.codebase",32));
00050               Codebase.setText(Global.getParameter("export.codebase","."));
00051 
00052               p.add(new MyLabel(Zirkel.name("export.file")));
00053               p.add(CFile=new TextFieldAction(this,"export.file",32));
00054               CFile.setText(Global.getParameter("export.path","")+
00055                      FileName.filename(zf.Filename));
00056 
00057               if (zf.ZC.isJob())
00058               {      p.add(new MyLabel(""));
00059                      p.add(Job=
00060                             new CheckboxAction(this,Zirkel.name("export.job")));
00061                      Job.setState(true);
00062               }
00063               
00064               Style=new MyChoice();
00065               for (int i=0; i<ST.length; i++)
00066                      Style.add(Global.name("export."+ST[i]));
00067               int style=Global.getParameter("export.style",0);
00068               if (style<=1 && ZF.ZC.isJob()) style=3;
00069               Style.select(style);
00070               p.add(new MyLabel(Zirkel.name("export.style")));
00071               p.add(Style);
00072               
00073               add("North",new Panel3D(p));
00074               
00075               Panel icons=new MyPanel();
00076               icons.setLayout(new GridLayout(0,1));
00077               IBa=new IconBar(ZF);
00078               String ica;
00079               if (restrict)
00080                      ica=Global.getParameter("restrictedicons",
00081                             "point line segment ray circle circle3 fixedcircle fixedangle intersection");              
00082               else
00083                      ica=Global.getParameter("export.icons",
00084                             "point line segment ray circle circle3 fixedcircle fixedangle intersection");
00085               for (int i=0; i<ZirkelFrame.IconNumber; i++)
00086               {      String s=ZirkelFrame.ObjectStrings[i];
00087                      IBa.addToggleLeft(s);       
00088                      if (ica.equals("full") || ica.indexOf(s)>=0)
00089                             IBa.setState(s,true);
00090               }
00091               icons.add(new Panel3D(IBa));
00092               IBb=new IconBar(ZF);
00093               String icb;
00094               if (restrict)
00095                      icb=Global.getParameter("restrictedicons",
00096                             "back hidden color twolines ");
00097               else
00098                      icb=Global.getParameter("export.tools",
00099                             "back hidden color twolines ");
00100               for (int i=0; i<ISb.length; i++)
00101               {      String s=ISb[i];
00102                      if (s.equals("qintersection")) IBb.addSeparatorLeft();
00103                      if (s.equals("twolines")) IBb.addSeparatorLeft();
00104                      if (s.equals("draw")) IBb.addSeparatorLeft();
00105                      IBb.addToggleLeft(s);
00106                      if (icb.equals("full") || icb.indexOf(ISb0[i])>=0)
00107                             IBb.setState(s,true);
00108               }
00109               icons.add(new Panel3D(IBb));
00110               IBb.setState("qchoice",Global.getParameter("options.choice",false));
00111               IBb.setState("qintersection",Global.getParameter("options.intersection",false));
00112               IBb.setState("qpointon",Global.getParameter("options.pointon",false));
00113               IBb.setState("indicate",!Global.getParameter("options.indicate.simple",false));
00114               add("Center",icons);
00115               
00116               Panel buttons=new MyPanel();
00117               buttons.add(new ButtonAction(this,Zirkel.name("ok"),"OK"));
00118               buttons.add(new ButtonAction(this,Zirkel.name("abort"),"Close"));
00119               addHelp(buttons,"htmlexporttemplate");
00120               add("South",buttons);
00121               
00122               pack();
00123               if (getSize().width>750) setSize(750,getSize().height);
00124        }
00125 
00126        public void doAction (String o)
00127        {      OK=false;
00128               if (o.equals("OK"))
00129               {      OK=true;
00130                      int i=Style.getSelectedIndex();
00131                      if (i>=0) Global.setParameter("export.style",i);
00132                      getIcons();
00133                      getTools();
00134                      doclose();
00135               }
00136               else super.doAction(o);
00137        }
00138        
00139        public boolean isAborted ()
00140        {      return !OK;
00141        }
00142        
00143        public String getPageTitle () { return PageTitle.getText(); }
00144        
00145        public String getIcons ()
00146        {      StringBuffer b=new StringBuffer();
00147               boolean first=true;
00148               for (int i=0; i<ZirkelFrame.IconNumber; i++)
00149               {      String s=ZirkelFrame.ObjectStrings[i];
00150                      if (IBa.getState(s))
00151                      {      if (!first) b.append(' ');
00152                             b.append(s);
00153                             first=false;
00154                      }
00155               }
00156               if (!Restrict)
00157                      Global.setParameter("export.icons",b.toString());
00158               return b.toString();
00159        }
00160 
00161        public String getTools ()
00162        {      StringBuffer b=new StringBuffer();
00163               boolean first=true;
00164               for (int i=0; i<ISb.length; i++)
00165               {      String s=ISb[i];
00166                      if (s.equals("indicate") && !IBb.getState(s))
00167                      {      if (!first) b.append(' ');
00168                             b.append("noindicate");
00169                             first=false;
00170                      }
00171                      else if (IBb.getState(s))
00172                      {      if (!first) b.append(' ');
00173                             b.append(ISb0[i]);
00174                             first=false;
00175                      }
00176               }
00177               if (!Restrict)
00178                      Global.setParameter("export.tools",b.toString());
00179               return b.toString();
00180        }
00181        
00182        public String getStyle ()
00183        {      int n=Style.getSelectedIndex();
00184               if (n>=0) Global.setParameter("export.style",n);
00185               if (n<0) return ST[0];
00186               else return ST[n];
00187        }
00188        
00189        public String getFile ()
00190        {      String path=FileName.pathAndSeparator(CFile.getText());
00191               Global.setParameter("export.path",path);
00192               return CFile.getText(); 
00193        }
00194        
00195        public String getCodebase ()
00196        {      Global.setParameter("export.codebase",Codebase.getText());
00197               return Codebase.getText();
00198        }
00199 
00200        public boolean isJob()
00201        {      if (Job==null) return false;
00202               return Job.getState(); 
00203        }
00204        
00205 }