Back to index

wims  3.65+svn20090927
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | Package Attributes
rene.dialogs.InfoDialog Class Reference

Info class. More...

Inheritance diagram for rene.dialogs.InfoDialog:
Inheritance graph
[legend]
Collaboration diagram for rene.dialogs.InfoDialog:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 InfoDialog (Frame f)
 Sets up the dialog with title, search bar and text area.
void fill (String language)
 A complicated function, that scans the current help file for topics, related to the current subject.
void fill ()
void doAction (String o)
void itemStateChanged (ItemEvent e)
void doclose ()
 Closes the dialog.
void windowActivated (WindowEvent e)
void windowClosed (WindowEvent e)
void windowClosing (WindowEvent e)
void windowDeactivated (WindowEvent e)
void windowDeiconified (WindowEvent e)
void windowIconified (WindowEvent e)
void windowOpened (WindowEvent e)
boolean close ()
boolean escape ()
 Calls close(), when the escape key is pressed.
void actionPerformed (ActionEvent e)
void showHelp ()
void itemAction (String o, boolean flag)
void keyPressed (KeyEvent e)
void keyReleased (KeyEvent e)
void keyTyped (KeyEvent e)
void center (Frame f)
void center ()
void centerOut (Frame f)
void notePosition (String name)
 Note window position in Global.
void setPosition (String name)
 Set window position and size.
void focusGained (FocusEvent e)
 Override to set the focus somewhere.
void focusLost (FocusEvent e)
void noteSize (String name)
 Note window size in Global.
void setSize (String name)
 Set window size.
void setDispose (boolean flag)
 This inihibits dispose(), when the dialog is closed.
boolean isAborted ()
void addHelp (Panel p, String subject)
 To add a help button to children.

Static Public Member Functions

static void center (Frame f, Dialog dialog)

Public Attributes

boolean Aborted = false
ActionEvent E

Static Public Attributes

static String Subject = "start"
static String Base = ""

Package Attributes

ExtendedViewer V
Button Close
Button Back
String Search = null
MyChoice L
Vector Other = null
Vector History = new Vector()
Frame F
boolean Dispose = true

Detailed Description

Info class.

Reads a file "info.txt" or "de_info.txt" etc. in its Base directory. This file has the structure

.subject1 substitute1 substitute2 ... .related subject subject ... Header ...

.subject2 ...

and displays the text, starting from header, searching for a subject or any of its substitutes. The headers of the related subjects are presented in a choice list. The user can switch to any of it.

There is a history and a back button.

Moroever, there is a search button, that displays the first subject containing a string and presents all other subjects containing the string in the choice list.

This class is used in CloseDialog to provide help in dialogs. It is a CloseDialog itself.

See also:
: rene.gui.CloseDialog

Definition at line 41 of file InfoDialog.java.


Constructor & Destructor Documentation

rene.dialogs.InfoDialog.InfoDialog ( Frame  f) [inline]

Sets up the dialog with title, search bar and text area.

The size will be remembered with "info" in the configuration (see: Global). The dialog will be centered on its frame.

Parameters:
f

Definition at line 61 of file InfoDialog.java.

       {      super(f,Global.name("info.title"),true);
              F=f;
              V=new ExtendedViewer();
              if (Global.Background!=null) V.setBackground(Global.Background);
              V.setFont(Global.NormalFont);
              setLayout(new BorderLayout());
              Panel north=new MyPanel();
              north.setLayout(new GridLayout(0,2));
              north.add(new MyLabel(Global.name("info.related")));
              L=new MyChoice();
              fill();
              north.add(L);
              add("North",north);
              add("Center",V);
              Panel p=new MyPanel();
              p.add(new ButtonAction(this,Global.name("info.start"),"Start"));
              p.add(new ButtonAction(this,Global.name("info.search"),"Search"));
              p.add(new ButtonAction(this,Global.name("info.back"),"Back"));
              p.add(new MyLabel(""));
              p.add(new ButtonAction(this,Global.name("close","Close"),"Close"));
              add("South",new Panel3D(p));
              L.addItemListener(this);
              pack();
              setSize("info");
              center(f);
              setVisible(true);
       }

Here is the call graph for this function:


Member Function Documentation

void rene.gui.CloseDialog.actionPerformed ( ActionEvent  e) [inline, inherited]
void rene.gui.CloseDialog.addHelp ( Panel  p,
String  subject 
) [inline, inherited]

To add a help button to children.

Parameters:
p
subject

Definition at line 231 of file CloseDialog.java.

       {      p.add(new MyLabel(""));
              p.add(new ButtonAction(this,Global.name("help"),"Help"));
              Subject=subject;
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.gui.CloseDialog.center ( Frame  f) [inline, inherited]

Reimplemented in rene.dialogs.MyFileDialog.

Definition at line 104 of file CloseDialog.java.

       {      Dimension 
                     si=f.getSize(),
                     d=getSize(),
                     dscreen=getToolkit().getScreenSize();
              Point lo=f.getLocation();
              int x=lo.x+si.width/2-d.width/2;
              int y=lo.y+si.height/2-d.height/2;
              if (x+d.width>dscreen.width) x=dscreen.width-d.width-10;
              if (x<10) x=10;
              if (y+d.height>dscreen.height) y=dscreen.height-d.height-10;
              if (y<10) y=10;
              setLocation(x,y);
       }

Here is the caller graph for this function:

static void rene.gui.CloseDialog.center ( Frame  f,
Dialog  dialog 
) [inline, static, inherited]

Definition at line 118 of file CloseDialog.java.

       {      Dimension 
                     si=f.getSize(),
                     d=dialog.getSize(),
                     dscreen=f.getToolkit().getScreenSize();
              Point lo=f.getLocation();
              int x=lo.x+si.width/2-d.width/2;
              int y=lo.y+si.height/2-d.height/2;
              if (x+d.width>dscreen.width) x=dscreen.width-d.width-10;
              if (x<10) x=10;
              if (y+d.height>dscreen.height) y=dscreen.height-d.height-10;
              if (y<10) y=10;
              dialog.setLocation(x,y);
       }
void rene.gui.CloseDialog.center ( ) [inline, inherited]

Definition at line 144 of file CloseDialog.java.

       {      Dimension d=getSize(),dscreen=getToolkit().getScreenSize();
              setLocation((dscreen.width-d.width)/2,
                     (dscreen.height-d.height)/2);
       }

Here is the caller graph for this function:

void rene.gui.CloseDialog.centerOut ( Frame  f) [inline, inherited]

Definition at line 132 of file CloseDialog.java.

       {      Dimension si=f.getSize(),d=getSize(),
                     dscreen=getToolkit().getScreenSize();
              Point lo=f.getLocation();
              int x=lo.x+si.width-getSize().width+20;
              int y=lo.y+si.height/2+40;
              if (x+d.width>dscreen.width) x=dscreen.width-d.width-10;
              if (x<10) x=10;
              if (y+d.height>dscreen.height) y=dscreen.height-d.height-10;
              if (y<10) y=10;
              setLocation(x,y);
       }
boolean rene.gui.CloseDialog.close ( ) [inline, inherited]
Returns:
true if the dialog is closed.

Reimplemented in rene.dialogs.SearchFileDialog.

Definition at line 47 of file CloseDialog.java.

       {      return true;
       }

Here is the caller graph for this function:

void rene.dialogs.InfoDialog.doAction ( String  o) [inline]

Reimplemented from rene.gui.CloseDialog.

Definition at line 282 of file InfoDialog.java.

       {      if (o.equals("Close"))
              {      super.doAction("Close");
              }
              else if (o.equals("Back"))
              {      int n=History.size();
                     if (n<2) return;
                     History.removeElementAt(n-1);
                     Subject=(String)History.elementAt(n-2);
                     History.removeElementAt(n-2);
                     fill();
              }
              else if (o.equals("Start"))
              {      Subject="start";
                     fill();
              }
              else if (o.equals("Search"))
              {      GetParameter.InputLength=50;
                     GetParameter g=new GetParameter(F,
                            Global.name("info.title"),
                            Global.name("info.search"),
                            Global.name("info.search","ok"));
                     g.center(F);
                     g.setVisible(true);
                     if (!g.aborted())
                            Search=g.getResult();
                     fill();
                     Search=null;
              }
              else super.doAction(o);
       }

Here is the call graph for this function:

Closes the dialog.

This may be used in subclasses to do some action. Then call super.doclose()

Reimplemented from rene.gui.CloseDialog.

Definition at line 327 of file InfoDialog.java.

       {      noteSize("info");
              super.doclose();
       }

Here is the call graph for this function:

boolean rene.gui.CloseDialog.escape ( ) [inline, inherited]

Calls close(), when the escape key is pressed.

Returns:
true if the dialog may close.

Reimplemented in rene.zirkel.dialogs.CommentDialog.

Definition at line 55 of file CloseDialog.java.

       {      return close();
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.dialogs.InfoDialog.fill ( String  language) [inline]

A complicated function, that scans the current help file for topics, related to the current subject.

The proper language (e.g. "de_") are read from the language property in Global. E.g., the file file is read from "de_info.txt". The proper encoding of the file (e.g. "CP1552) is read from the "condepage.help" property in Global.

Definition at line 98 of file InfoDialog.java.

       {      L.removeAll();
              V.setText("");
              V.setVisible(false);
              boolean Found=false,Appending=false;
              Vector Related=null;
              Other=new Vector();
              String pair[]=null,lastpair[]=null;
              String lang=language;
              Vector SearchResults=new Vector();
              String SearchResult="";
              String FoundTopic=null;
              boolean FirstRun=true,FoundHeader=false;

              String Search1=Search;
              if (Search!=null && Search.length()>0)
              {      Search1=Search.substring(0,1).toUpperCase()+Search.substring(1);
              }

              read: while (true)
              {      try
                     {      // open the info file in the proper language and encoding.
                            String cp=Global.name("codepage.help",""); // get encoding.
                            BufferedReader in=null;
                            if (cp.equals(""))
                                   in=new BufferedReader(new InputStreamReader(
                                          getClass().getResourceAsStream(Base+lang+"info.txt")));
                            else
                            {      try
                                   {      in=new BufferedReader(new InputStreamReader(
                                                 getClass().getResourceAsStream(Base+lang+"info.txt"),cp));
                                   }
                                   catch (Exception ex)
                                   {      in=new BufferedReader(new InputStreamReader(
                                                 getClass().getResourceAsStream(Base+lang+"info.txt")));
                                   }
                            }
                            // read through the file line by line:
                            newline: while (true)
                            {      String s=in.readLine();
                                   if (s==null) break newline;
                                   if (!s.startsWith(".") && Search!=null && 
                                          (s.indexOf(Search)>=0 || s.indexOf(Search1)>=0))
                                   {      if (lastpair!=null && pair==null &&
                                                 !SearchResult.equals(lastpair[0]))
                                          {      SearchResults.addElement(lastpair);
                                                 SearchResult=lastpair[0];
                                                 if (FoundTopic==null) FoundTopic=lastpair[0];
                                          }
                                   }
                                   interpret: while (true)
                                   {      if (!Appending && s.startsWith(".") && 
                                                 !s.startsWith(".related"))
                                          {      if (!Found)
                                                 {      if (s.startsWith("."+Subject))
                                                        {      Found=true; Appending=true;
                                                               continue newline;
                                                        }
                                                        StringTokenizer t=new StringTokenizer(s);
                                                        while (t.hasMoreElements())
                                                        {      String name=t.nextToken();
                                                               if (name.equals(Subject))
                                                               {      Found=true; Appending=true;
                                                                      continue newline;
                                                               }
                                                        }
                                                 }
                                                 pair=new String[2];
                                                 s=s.substring(1);
                                                 int n=s.indexOf(' ');
                                                 if (n>0) s=s.substring(0,n);
                                                 pair[0]=s;
                                                 continue newline;
                                          }
                                          if (Appending)
                                          {      if (s.startsWith(".related"))
                                                 {      s=s.substring(".related".length());
                                                        Related=new Vector();
                                                        StringTokenizer t=new StringTokenizer(s);
                                                        while (t.hasMoreElements())
                                                        {      Related.addElement(t.nextToken());
                                                        }
                                                        continue newline;
                                                 }
                                                 if (s.startsWith("."))
                                                 {      Appending=false; 
                                                        continue interpret;
                                                 }
                                                 if (s.trim().equals(""))
                                                 {      V.newLine();
                                                        V.appendLine("");
                                                 }
                                                 else 
                                                 {      if (s.startsWith(" "))
                                                               V.newLine();
                                                        V.append(s+" ");
                                                 }
                                          }
                                          else if (pair!=null && !s.startsWith("."))
                                          {      pair[1]=s;
                                                 Other.addElement(pair);
                                                 lastpair=pair;
                                                 pair=null;
                                                 if (Search!=null && 
                                                        (s.indexOf(Search)>=0 || s.indexOf(Search1)>=0))
                                                 {      if (!SearchResult.equals(lastpair[0]))
                                                        {      SearchResults.addElement(lastpair);
                                                               SearchResult=lastpair[0];
                                                               if (!FoundHeader) FoundTopic=lastpair[0];
                                                               FoundHeader=true;
                                                        }
                                                 }
                                          }
                                          continue newline;
                                   }
                            }
                            V.newLine();
                            in.close();
                     }
                     catch (Exception e)
                     {      if (!lang.equals(""))
                            {      lang=""; continue read;
                            }
                            else
                            {      V.appendLine(
                                          Global.name("help.error","Could not find the help file!"));
                            }
                     }
                     if (FoundTopic!=null && FirstRun)
                     {      Subject=FoundTopic;
                            SearchResults=new Vector();
                            SearchResult="";
                            pair=null; lastpair=null;
                            Found=false;
                            V.setText("");
                            FirstRun=false;
                            continue read;
                     }
                     else break read;
              }

              if (!Found)
              {      V.appendLine(Global.name("info.notfound","Topic not found!"));
                     fill("en"); return;
              }

              if (Search!=null)
              {      if (SearchResults.size()>0) L.add(Global.name("info.searchresults"));
                     else L.add(Global.name("info.noresults"));
              }
              else L.add(Global.name("info.select"));

              if (Search==null && Related!=null)
              {      Enumeration e=Related.elements();
                     while (e.hasMoreElements())
                     {      String topic=(String)e.nextElement();
                            Enumeration ev=Other.elements();
                            while (ev.hasMoreElements())
                            {      String s[]=(String[])ev.nextElement();
                                   if (s[0].equals(topic)) 
                                   {      L.add(s[1]); break;
                                   }
                            }
                     }
              }
              
              if (Search!=null)
              {      Enumeration e=SearchResults.elements();
                     while (e.hasMoreElements())
                     {      String s[]=(String[])e.nextElement();
                            L.add(s[1]);
                     }
              }
              
              History.addElement(Subject);
              V.update();
              V.setVisible(true);
              V.showFirst();
       }

Here is the call graph for this function:

void rene.dialogs.InfoDialog.fill ( ) [inline]

Definition at line 278 of file InfoDialog.java.

       {      fill(Global.name("language",""));
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.gui.CloseDialog.focusGained ( FocusEvent  e) [inline, inherited]
void rene.gui.CloseDialog.focusLost ( FocusEvent  e) [inline, inherited]

Definition at line 191 of file CloseDialog.java.

{}
boolean rene.gui.CloseDialog.isAborted ( ) [inline, inherited]
void rene.gui.CloseDialog.itemAction ( String  o,
boolean  flag 
) [inline, inherited]
void rene.dialogs.InfoDialog.itemStateChanged ( ItemEvent  e) [inline]

Definition at line 314 of file InfoDialog.java.

       {      String s=L.getSelectedItem();
              Enumeration ev=Other.elements();
              while (ev.hasMoreElements())
              {      String p[]=(String[])ev.nextElement();
                     if (p[1].equals(s))
                     {      Subject=p[0];
                            fill();
                            break;
                     }
              }
       }

Here is the call graph for this function:

void rene.gui.CloseDialog.keyPressed ( KeyEvent  e) [inline, inherited]

Definition at line 82 of file CloseDialog.java.

       {      if (e.getKeyCode()==KeyEvent.VK_ESCAPE && escape()) doclose();
       }

Here is the call graph for this function:

void rene.gui.CloseDialog.keyReleased ( KeyEvent  e) [inline, inherited]

Definition at line 85 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.keyTyped ( KeyEvent  e) [inline, inherited]

Definition at line 86 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.notePosition ( String  name) [inline, inherited]

Note window position in Global.

Definition at line 153 of file CloseDialog.java.

       {      Point l=getLocation();
              Dimension d=getSize();
              Global.setParameter(name+".x",l.x);
              Global.setParameter(name+".y",l.y);
              Global.setParameter(name+".w",d.width);
              if (d.height-Global.getParameter(name+".h",0)!=19)
                     // works around a bug in Windows
                     Global.setParameter(name+".h",d.height);
              boolean maximized=false;
       }

Here is the call graph for this function:

void rene.gui.CloseDialog.noteSize ( String  name) [inline, inherited]

Note window size in Global.

Definition at line 196 of file CloseDialog.java.

       {      Dimension d=getSize();
              Global.setParameter(name+".w",d.width);
              Global.setParameter(name+".h",d.height);
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.gui.CloseDialog.setDispose ( boolean  flag) [inline, inherited]

This inihibits dispose(), when the dialog is closed.

Definition at line 218 of file CloseDialog.java.

       {      Dispose=flag;
       }
void rene.gui.CloseDialog.setPosition ( String  name) [inline, inherited]

Set window position and size.

Definition at line 168 of file CloseDialog.java.

       {      Point l=getLocation();
              Dimension d=getSize();
              Dimension dscreen=getToolkit().getScreenSize();
              int x=Global.getParameter(name+".x",l.x);
              int y=Global.getParameter(name+".y",l.y);
              int w=Global.getParameter(name+".w",d.width);
              int h=Global.getParameter(name+".h",d.height);
              if (w>dscreen.width) w=dscreen.width;
              if (h>dscreen.height) h=dscreen.height;
              if (x<0) x=0;
              if (x+w>dscreen.width) x=dscreen.width-w;
              if (y<0) y=0;
              if (y+h>dscreen.height) y=dscreen.height-h;
              setLocation(x,y);
              setSize(w,h);
       }

Here is the call graph for this function:

void rene.gui.CloseDialog.setSize ( String  name) [inline, inherited]

Set window size.

Definition at line 205 of file CloseDialog.java.

       {      if (!Global.haveParameter(name+".w")) pack();
              else
              {      Dimension d=getSize();
                     int w=Global.getParameter(name+".w",d.width);
                     int h=Global.getParameter(name+".h",d.height);
                     setSize(w,h);
              }
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.gui.CloseDialog.showHelp ( ) [inline, inherited]

Reimplemented in rene.zirkel.dialogs.HelpCloseDialog.

Definition at line 75 of file CloseDialog.java.

       {      InfoDialog.Subject=Subject;
              InfoDialog id=new InfoDialog(F);
       }

Here is the caller graph for this function:

void rene.gui.CloseDialog.windowActivated ( WindowEvent  e) [inline, inherited]

Definition at line 34 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.windowClosed ( WindowEvent  e) [inline, inherited]

Definition at line 35 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.windowClosing ( WindowEvent  e) [inline, inherited]

Definition at line 36 of file CloseDialog.java.

       {   if (close()) doclose();
       }

Here is the call graph for this function:

Here is the caller graph for this function:

void rene.gui.CloseDialog.windowDeactivated ( WindowEvent  e) [inline, inherited]

Definition at line 39 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.windowDeiconified ( WindowEvent  e) [inline, inherited]

Definition at line 40 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.windowIconified ( WindowEvent  e) [inline, inherited]

Definition at line 41 of file CloseDialog.java.

{}
void rene.gui.CloseDialog.windowOpened ( WindowEvent  e) [inline, inherited]

Reimplemented in rene.zirkel.dialogs.DefineMacro.

Definition at line 42 of file CloseDialog.java.

{}

Member Data Documentation

Button rene.dialogs.InfoDialog.Back [package]

Definition at line 44 of file InfoDialog.java.

String rene.dialogs.InfoDialog.Base = "" [static]

Definition at line 51 of file InfoDialog.java.

Definition at line 44 of file InfoDialog.java.

boolean rene.gui.CloseDialog.Dispose = true [package, inherited]

Definition at line 19 of file CloseDialog.java.

ActionEvent rene.gui.CloseDialog.E [inherited]

Reimplemented in rene.dialogs.FontEditor.

Definition at line 59 of file CloseDialog.java.

Frame rene.dialogs.InfoDialog.F [package]

Reimplemented from rene.gui.CloseDialog.

Definition at line 53 of file InfoDialog.java.

Vector rene.dialogs.InfoDialog.History = new Vector() [package]

Definition at line 50 of file InfoDialog.java.

MyChoice rene.dialogs.InfoDialog.L [package]

Definition at line 48 of file InfoDialog.java.

Vector rene.dialogs.InfoDialog.Other = null [package]

Definition at line 49 of file InfoDialog.java.

String rene.dialogs.InfoDialog.Search = null [package]

Definition at line 46 of file InfoDialog.java.

String rene.dialogs.InfoDialog.Subject = "start" [static]

Reimplemented from rene.gui.CloseDialog.

Definition at line 45 of file InfoDialog.java.

ExtendedViewer rene.dialogs.InfoDialog.V [package]

Definition at line 43 of file InfoDialog.java.


The documentation for this class was generated from the following file: