Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members

com/ohrasys/app/gdsparser/GDSParserView.java

Go to the documentation of this file.
00001 /* Copyright (C) 2004 Thomas N. Valine
00002  * tvaline@users.sourceforge.net
00003  *
00004  * This program is free software; you can redistribute it and/or
00005  * modify it under the terms of the GNU General Public License
00006  * as published by the Free Software Foundation; either version 2
00007  * of the License, or (at your option) any later version.
00008  *
00009  * This program is distributed in the hope that it will be useful,
00010  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  * GNU General Public License for more details.
00013  *
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
00017  * 02111-1307, USA. */
00018 
00019 package com.ohrasys.app.gdsparser;
00020 import com.ohrasys.app.*;
00021 
00022 import com.ohrasys.cad.gds.*;
00023 import com.ohrasys.cad.gds.swing.*;
00024 
00025 import java.awt.*;
00026 import java.awt.event.*;
00027 import java.io.*;
00028 import javax.swing.*;
00029 import javax.swing.filechooser.*;
00030 
00037 public class GDSParserView
00038 extends com.ohrasys.app.AbstractAppView
00039 implements ActionListener {
00041   private JFrame frame;
00042 
00044   private GDSParserI18NFactory i18n;
00045 
00047   private JGDSParser parser;
00048 
00052   public GDSParserView() {
00053     frame = new JFrame(
00054         i18n.getString(i18n.i18n_APP_TITLE));
00055     frame.setDefaultCloseOperation(frame.DO_NOTHING_ON_CLOSE);
00056     frame.addWindowListener(new WindowAdapter() {
00057         public void windowClosing(WindowEvent evt) {
00058           frame.setVisible(false);
00059           notifyController(new ActionEvent(this,
00060               GDSParserEvents.APPEXIT_EVENT, null));
00061         }
00062       });
00063     initComponents();
00064   }
00065 
00076   public ActionEvent processEvent(ActionEvent evt) {
00077     if(evt != null) {
00078       if(evt.getID() == GDSParserEvents.ERROR_EVENT) {
00079         displayError(evt.getActionCommand());
00080       } else if(evt.getID() == GDSParserEvents.INFO_EVENT) {
00081         displayInfo(evt.getActionCommand());
00082       } else if(evt.getID() == GDSParserEvents.SETLOG_EVENT) {
00083         parser.setLog(evt.getActionCommand());
00084       } else if(evt.getID() == GDSParserEvents.SETGDS_EVENT) {
00085         parser.setGds(evt.getActionCommand());
00086       } else if(evt.getID() == GDSParserEvents.PARSE_EVENT) {
00087         if(frame.isVisible()){parser.parseDesign();}
00088         else {
00089           GDSParser    batchParser = new GDSParser();
00090           OutputStream out         = System.out;
00091           if(parser.getLog().trim().length() > 0) {
00092             try {
00093               out = new BufferedOutputStream(new FileOutputStream(
00094                     parser.getLog()));
00095             } catch(IOException ex) {
00096               /* default to System.out */
00097             }
00098           }
00099           batchParser.parseDesign(new File(parser.getGds()), out);
00100           notifyController(new ActionEvent(this, GDSParserEvents.APPEXIT_EVENT,
00101               null));
00102         }
00103       }
00104     } // end if
00105 
00106     return null;
00107   } // end method processEvent
00108 
00110   public void show(){frame.setVisible(true);}
00111 
00117   public String toString(){return super.toString();}
00118 
00124   private void displayError(String error) {
00125     if(frame.isVisible()) {
00126       JOptionPane.showMessageDialog((Component)null, error,
00127         i18n.getString(i18n.i18n_ERROR_TITLE),
00128         JOptionPane.ERROR_MESSAGE);
00129     }
00130   }
00131 
00137   private void displayInfo(String info) {
00138     if(frame.isVisible()) {
00139       JOptionPane.showMessageDialog((Component)null, info);
00140     }
00141   }
00142 
00144   private void initComponents() {
00145     parser = new JGDSParser(JGDSParser.EXPLICIT_CONTROL);
00146     parser.addActionListener(this);
00147     parser.setSize(800, 640);
00148     frame.getContentPane().add(parser);
00149     frame.setSize(800, 640);
00150   }
00151 
00157   private void setGDS(String gds) {
00158     if(parser.getGds() == gds){return;}
00159     parser.setGds(gds);
00160   }
00161 
00167   private void setLog(String log) {
00168     if(parser.getLog() == log){return;}
00169     parser.setLog(log);
00170   }
00171 } // end class GDSParserView
00172 
00173 
00174 /* This material is distributed under the GNU General Public License.
00175  * For more information please go to http://www.gnu.org/copyleft/gpl.html */

Generated on Mon May 23 13:48:55 2005 for Java GDS Parser (JGDSParser) by  doxygen 1.4.2