home *** CD-ROM | disk | FTP | other *** search
Java Source | 1999-02-11 | 6.3 KB | 210 lines |
- /* ****************************************************************
- ** @(#)searchPop.java 1.2 0
- **
- ** Copyright 1997 Sun Microsystems, Inc. All Rights Reserved
- **
- ** ****************************************************************
- */
-
- import java.awt.*;
- import java.awt.event.*;
- import java.util.Vector;
- import java.util.StringTokenizer;
- import gjt.*;
-
- public class searchPop extends Frame implements ActionListener {
- private Vector search;
- private Vector foundindex;
-
- private String labels[];
-
- private namedb parent;
-
- public Label field_label;
- public Choice field_choice;
- public Label param_label;
- public TextField param_text;
- public Label result_label;
- public List result_list;
- public OpenlookButton search_button;
- public OpenlookButton view_button;
- public OpenlookButton exit_button;
- public Panel bpanel,mpanel,spanel;
-
- public void init() {
-
- setTitle(parent.strings.searchPop());
- setBackground(Color.lightGray);
- if (parent.UseSetName)
- this.setName("searchPop");
-
- labels=new String[7];
- labels[0]="all";
- labels[1]="name";
- labels[2]="address1";
- labels[3]="address2";
- labels[4]="phone";
- labels[5]="title";
- labels[6]="salary";
-
- mpanel=new Panel();
- add(mpanel);
-
- bpanel=new Panel();
- bpanel.setLayout(new GridLayout(1,3));
- Box box1=new Box(bpanel,"");
- mpanel.add(box1);
-
- // main panel
- GridBagLayout grid = new GridBagLayout();
- GridBagLayout bgrid = new GridBagLayout();
-
- field_label=new Label(parent.strings.fieldl());
- if (parent.UseSetName)
- field_label.setName("field_label");
- field_label.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(field_label);
-
- field_choice=new Choice();
- if (parent.UseSetName)
- field_choice.setName("field_choice");
- field_choice.setBackground(Color.lightGray);
- field_choice.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(field_choice);
-
- param_label=new Label(parent.strings.paraml());
- if (parent.UseSetName)
- param_label.setName("param_label");
- param_label.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(param_label);
-
- param_text=new TextField(30);
- if (parent.UseSetName)
- param_text.setName("param_text");
- param_text.setBackground(Color.lightGray);
- param_text.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(param_text);
-
- result_label=new Label(parent.strings.fieldl());
- if (parent.UseSetName)
- result_label.setName("result_label");
- result_label.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(result_label);
-
- result_list=new List(5);
- if (parent.UseSetName)
- result_list.setName("result_list");
- result_list.setBackground(Color.lightGray);
- result_list.setFont(new Font("Serif",Font.ITALIC,16));
- mpanel.add(result_list);
-
- search_button=new OpenlookButton(parent.strings.dosearchb());
- if (parent.UseSetName)
- search_button.setName("dosearch_button");
- search_button.setFont(new Font("Serif",Font.ITALIC,16));
- search_button.addActionListener(this);
- bpanel.add(search_button,new Point(0,1));
-
- view_button=new OpenlookButton(parent.strings.searchviewb());
- if (parent.UseSetName)
- view_button.setName("searchview_button");
- view_button.setFont(new Font("Serif",Font.ITALIC,16));
- view_button.addActionListener(this);
- bpanel.add(view_button,new Point(0,2));
-
- exit_button=new OpenlookButton(parent.strings.searchcloseb());
- if (parent.UseSetName)
- exit_button.setName("searchclose_button");
- exit_button.setFont(new Font("Serif",Font.ITALIC,16));
- exit_button.addActionListener(this);
- bpanel.add(exit_button,new Point(0,3));
-
- constrain(grid,field_label,0,0,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,field_choice,1,0,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,param_label,0,1,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,param_text,1,1,2,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,result_label,0,2,1,1,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,result_list,1,2,1,4,GridBagConstraints.WEST,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
- constrain(grid,box1,0,6,3,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,0,0,0,0,0,0);
-
- mpanel.setLayout(grid);
-
- GridBagLayout mgrid=new GridBagLayout();
- constrain(mgrid,mpanel,0,0,1,1,GridBagConstraints.CENTER,GridBagConstraints.NONE,0,0,10,30,10,30,0,0);
- setLayout(mgrid);
-
- for(int i=0;i<labels.length;i++) {
- field_choice.add(labels[i]);
- }
- field_choice.select(0);
- }
-
- public void actionPerformed(ActionEvent event) {
- Component comp=(Component)event.getSource();
- if (comp == exit_button) {
- hide();
- }
- if (comp == view_button) {
- viewit();
- }
- if (comp == search_button) {
- search();
- }
- }
-
- public void search() {
- foundindex=parent.getApi().searchIt( field_choice.getSelectedIndex(),
- param_text.getText() );
- result_list.removeAll();
- RoloEntry re;
- for (int i=0;i<foundindex.size();i++) {
- re=parent.getApi().getEntry(((Integer)foundindex.elementAt(i)).intValue());
- result_list.add( re.name );
- }
- }
-
- public void clearsearch() {
- field_choice.select(0);
- param_text.setText("");
- result_list.removeAll();
- }
-
- public void viewit() {
- int item=result_list.getSelectedIndex();
- if (item== -1)
- return;
- int view=((Integer)foundindex.elementAt(item)).intValue();
- parent.getApi().showEntry(view);
- parent.updateScreen();
- }
- public void showit() {
- pack();
- show();
- }
- public void setParent(namedb caller) {
- parent = caller;
- }
-
- public void constrain(GridBagLayout grid,Component comp,int gridx,int gridy,int gridwidth,int gridheight,int anchor,int fill,int ipadx,int ipady,int top,int left,int bottom,int right,double weightx,double weighty) {
- GridBagConstraints con=new GridBagConstraints();
- con.gridx = gridx;
- con.gridy = gridy;
- con.gridwidth = gridwidth;
- con.gridheight = gridheight;
- con.anchor = anchor;
- con.fill = fill;
- con.ipadx = ipadx;
- con.ipady = ipady;
- con.weightx=weightx;
- con.weighty=weighty;
- con.insets = new Insets(top,left,bottom,right);
- grid.setConstraints(comp,con);
- }
- }
-
-
-
-
-
-
-