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 java.awt.event.*;
00023 import java.io.*;
00024
00032 public class GDSParserController
00033 extends AbstractAppController {
00035 private GDSParserI18NFactory i18n;
00036
00046 public GDSParserController(AbstractAppModel model, AbstractAppView view,
00047 AppOption options[])
00048 throws AppException{super(model, view, options);}
00049
00059 public ActionEvent processEvent(java.awt.event.ActionEvent evt) {
00060 if(evt != null) {
00061 if(evt.getSource() == model){notifyViews(evt);}
00062 else{notifyModel(evt);}
00063 if(evt.getID() == GDSParserEvents.INFO_EVENT) {
00064 System.out.println(
00065 i18n.getString(i18n.i18n_INFO) + evt.getActionCommand());
00066 }
00067 if(evt.getID() == GDSParserEvents.ERROR_EVENT) {
00068 System.out.println(
00069 i18n.getString(i18n.i18n_ERROR) + evt.getActionCommand());
00070 }
00071 if(evt.getID() == GDSParserEvents.APPEXIT_EVENT){exitApp();}
00072 }
00073
00074 return null;
00075 }
00076
00084 public void startController() {
00085 AppOption option;
00086 if(AppOption.findOption(GDSParserUtil.VERSION_FLAG, options) != null) {
00087 System.out.println(GDSParserUtil.getVersion());
00088 System.exit(0);
00089 }
00090 if(AppOption.findOption(GDSParserUtil.HELP_FLAG, options) != null) {
00091 System.out.println(GDSParserUtil.getUsage());
00092 System.exit(0);
00093 }
00094 System.out.println(GDSParserUtil.getVersion());
00095 System.out.println(GDSParserUtil.getCopyright());
00096 if((option = AppOption.findOption(GDSParserUtil.LOG_FLAG, options)) !=
00097 null) {
00098 System.out.println(
00099 i18n.getString(i18n.i18n_INFO_LOG_SET_TO) + option.getValue());
00100 notifyViews(new ActionEvent(this,
00101 GDSParserEvents.SETLOG_EVENT, option.getValue()));
00102 }
00103 if((option = AppOption.findOption(GDSParserUtil.GDSIN_FLAG, options)) !=
00104 null) {
00105 System.out.println(
00106 i18n.getString(i18n.i18n_INFO_GDS_SET_TO) + option.getValue());
00107 notifyViews(new ActionEvent(this,
00108 GDSParserEvents.SETGDS_EVENT, option.getValue()));
00109 }
00110 if(AppOption.findOption(GDSParserUtil.NOGUI_FLAG, options) != null) {
00111 notifyViews(new ActionEvent(this,
00112 GDSParserEvents.PARSE_EVENT, null));
00113 } else{((GDSParserView)views.get(0)).show();}
00114 }
00115
00121 public String toString(){return super.toString();}
00122
00124 private void exitApp() {
00125 System.out.println(i18n.getString(i18n.i18n_INFO_DONE));
00126 System.exit(0);
00127 }
00128 }
00129
00130
00131
00132