MCPcopy Create free account
hub / github.com/GateNLP/gate-core / run

Method run

src/main/java/gate/gui/MainFrame.java:4065–4199  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4063 public void actionPerformed(ActionEvent e) {
4064 Runnable runnable = new Runnable() {
4065 @Override
4066 public void run() {
4067 // save the options
4068 OptionsMap userConfig = Gate.getUserConfig();
4069 try {
4070 if(userConfig.getBoolean(GateConstants.SAVE_OPTIONS_ON_EXIT)) {
4071 // save the window size
4072 Integer width = MainFrame.this.getWidth();
4073 Integer height = MainFrame.this.getHeight();
4074 userConfig.put(GateConstants.MAIN_FRAME_WIDTH, width);
4075 userConfig.put(GateConstants.MAIN_FRAME_HEIGHT, height);
4076 userConfig.put(GateConstants.MAIN_FRAME_MAXIMIZED, MainFrame.this.getExtendedState() == JFrame.MAXIMIZED_BOTH);
4077 Gate.writeUserConfig();
4078 }
4079 else {
4080 // don't save options on close
4081 // save the option not to save the options, but only if it was
4082 // changed in this session
4083 OptionsMap originalUserConfig = Gate.getOriginalUserConfig();
4084 // if the original value of this was true, it has been changed, so
4085 // save the config file, otherwise leave the options file untouched.
4086 if(originalUserConfig.getBoolean(GateConstants.SAVE_OPTIONS_ON_EXIT)) {
4087 originalUserConfig.put(GateConstants.SAVE_OPTIONS_ON_EXIT, false);
4088 // restore the original options, with only the save options value modified
4089 userConfig.clear();
4090 userConfig.putAll(originalUserConfig);
4091 Gate.writeUserConfig();
4092 }
4093 }
4094 }
4095 catch(GateException error) {
4096 String message = "Failed to save config data.";
4097 log.error(message, error);
4098 }
4099
4100 // save the session;
4101 //TODO better handling of this by moving session out of the API into developer
4102 File sessionFile = Gate.getUserSessionFile();
4103 if(sessionFile != null && userConfig.getBoolean(GateConstants.SAVE_SESSION_ON_EXIT)) {
4104 // save all the open applications
4105 try {
4106 List<Resource> appList = new ArrayList<Resource>(
4107 Gate.getCreoleRegister().getAllInstances("gate.Controller"));
4108 // remove all hidden instances
4109 Iterator<Resource> appIter = appList.iterator();
4110 while(appIter.hasNext()) {
4111 if(Gate.getHiddenAttribute(((Controller)appIter.next())
4112 .getFeatures())) { appIter.remove(); }
4113 }
4114 // When saving the session file, save URLs relative to GATE home
4115 // but do not warn about them
4116 gate.util.persistence.PersistenceManager.saveObjectToFile(
4117 appList, sessionFile, true, false);
4118 }
4119 catch(Exception error) {
4120 String message = "Failed to save session data.";
4121 log.error(message, error);
4122 }

Callers

nothing calls this directly

Calls 15

getUserConfigMethod · 0.95
getBooleanMethod · 0.95
putMethod · 0.95
writeUserConfigMethod · 0.95
getOriginalUserConfigMethod · 0.95
getUserSessionFileMethod · 0.95
getCreoleRegisterMethod · 0.95
getHiddenAttributeMethod · 0.95
deleteResourceMethod · 0.95
getDataStoreRegisterMethod · 0.95
saveObjectToFileMethod · 0.80
getGuiRootsMethod · 0.80

Tested by

no test coverage detected