00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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
00097 }
00098 }
00099 batchParser.parseDesign(new File(parser.getGds()), out);
00100 notifyController(new ActionEvent(this, GDSParserEvents.APPEXIT_EVENT,
00101 null));
00102 }
00103 }
00104 }
00105
00106 return null;
00107 }
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 }
00172
00173
00174
00175