Code:
- public void saveSubSystem(SubSystem _subsystem) throws Exception {
- super.saveSubSystem(_subsystem);
-
- ImplementerSubSystem subsystem = (ImplementerSubSystem)_subsystem;
-
- Properties generalProperties = subsystem.getGeneralProperties();
-
- propertyFile = getPropertiesFile(_subsystem);
-
- saveProperties(generalProperties, propertyFile,
- "General Properties");
-
- }
-
- protected SubSystem restoreSubSystem(SystemConnection arg0, String arg1)
- throws Exception {
- ImplementerSubSystem subsystem =
- (ImplementerSubSystem)super.restoreSubSystem(arg0, arg1);
-
- propertyFile = getPropertiesFile(subsystem);
-
- Properties general = getProperties(propertyFile);
-
- subsystem.setGeneralProperties(general);
-
- return subsystem;
- }
-
- private void saveProperties(Properties props, IFile file,
- String comment)
- throws CoreException, IOException {
-
- if (file.exists()) {
- file.delete(true, null);
- }
-
- ByteArrayOutputStream os = new ByteArrayOutputStream();
-
- props.storeToXML(os, comment);
-
- ByteArrayInputStream is =
- new ByteArrayInputStream(os.toByteArray());
-
- file.create(is, true, null);
- }
-
- private Properties getProperties(IFile file) throws CoreException, IOException {
-
- Properties props = new Properties();
-
- if (file.exists()) {
- InputStream is = file.getContents();
- props.loadFromXML(is);
- }
-
- return props;
- }
-
- private IFile getPropertiesFile(SubSystem subsystem) {
-
- IFolder connectionFolder =
- getSubSystemsFolder(subsystem.getSystemConnection());
-
- return connectionFolder.getFile("general.props");
-
- }
|
|