/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package clips.main;
import cli_fmw.main.ClipsException;
import clips.dicom.dicomdataimpl.DICOMServiceOptions;
import cli_fmw.utils.ConfigGui;
import cli_fmw.utils.MessageBox;
import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.annotations.XStreamAlias;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;
import org.jdom.JDOMException;
/**
*
* @author finder
*/
@XStreamAlias("IntelConfig")
public class ClipsConfig extends ConfigGui {
private int lastLoginGroup = -1;
private int lastLoginUserID = -1;
private DICOMServiceOptions dicomService = DICOMServiceOptions.newServiceOptions();
private File lastDBFImportPath;
private File lastRegisterExportPath;
private File openOfficePath;
private int sicklistLeftMarign = 47;
private int sicklistTopMarign = 9;
private static final Class[] XML_STREAM_CLASS = new Class[]{
ClipsConfig.class, DICOMServiceOptions.class
};
private ClipsConfig() {
}
@Override
protected Class[] getClassList() {
return XML_STREAM_CLASS;
}
@Override
protected XStream createSerializer() {
XStream target = super.createSerializer();
target.omitField(ClipsConfig.class, "lastLoginUserSpec");
return target;
}
@Override
public String getProgramNormalName(){
return "Intel Clinic";
}
@Override
public String getProgramSampleName(){
return "intelclinic";
}
public static void init(){
new ClipsConfig().load();
}
public static ClipsConfig getInstance() {
return (ClipsConfig) ConfigGui.getInstance();
}
public DICOMServiceOptions getDicomService() {
return dicomService;
}
public int getLastLoginUserID() {
return lastLoginUserID;
}
public void setLastLoginUserID(int lastLoginUserID) {
this.lastLoginUserID = lastLoginUserID;
save();
}
public int getLastLoginGroup() {
return lastLoginGroup;
}
public void setLastLoginGroup(int lastLoginGroup) {
this.lastLoginGroup = lastLoginGroup;
save();
}
public File getDicomDumpDir() {
return new File(getProgramHome(), "DICOMCache" + File.separator);
}
@Override
protected void load() {
try {
loadInstance();
} catch (FileNotFoundException ex) {
MessageBox.showExceptionOnly(ex);
} catch (JDOMException ex) {
MessageBox.showExceptionOnly(ex);
} catch (IOException ex) {
MessageBox.showExceptionOnly(ex);
} catch (Exception ex) {
MessageBox.showExceptionAndHalt(new ClipsException("Ошибка при чтении настрек программы", ex));
}
save();
}
@Override
public void save() {
try {
saveInstance();
} catch (IOException ex) {
MessageBox.showException(new ClipsException("Ошибка при сохранении настрек программы", ex));
} catch (Exception ex) {
MessageBox.showException(new ClipsException("Ошибка при сохранении настрек программы", ex));
}
}
public File getLastDBFImportPath() {
if (lastDBFImportPath == null){
return getLastOpenDialogPath();
}
else{
return lastDBFImportPath;
}
}
public void setLastDBFImportPath(File lastDBFImportPath) {
this.lastDBFImportPath = lastDBFImportPath;
save();
}
public File getRegisterExportPath() {
if (lastRegisterExportPath == null){
return getLastOpenDialogPath();
}
else{
return lastRegisterExportPath;
}
}
public void setRegisterExportPath(File lastRegisterExportPath) {
this.lastRegisterExportPath = lastRegisterExportPath;
save();
}
public File getOpenOfficePath() {
return openOfficePath;
}
public void setOpenOfficePath(File openOfficePath) {
this.openOfficePath = openOfficePath;
save();
}
@Override
public boolean haltOnMessageBox() {
return false;
}
public int getSicklistLeftMarign() {
return sicklistLeftMarign;
}
public void setSicklistLeftMarign(int sicklistLeftMarign) {
this.sicklistLeftMarign = sicklistLeftMarign;
}
public int getSicklistTopMarign() {
return sicklistTopMarign;
}
public void setSicklistTopMarign(int sicklistTopMarign) {
this.sicklistTopMarign = sicklistTopMarign;
}
}