* @param file
* @param filter
*/
private IEditor openFile(File file, int filter) {
IEditor editor = null;
final PNMLImport pr;
getMediator().getUi().getComponent().setCursor(Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR));
if (filter == FileFilterImpl.PNMLFilter || filter == FileFilterImpl.SAMPLEFilter) {
IViewController[] iVC = getMediator().findViewController(IStatusBar.TYPE);
IStatusBar[] iSB = new IStatusBar[iVC.length];
for (int i = 0; i < iSB.length; i++) {
iSB[i] = (IStatusBar) iVC[i];
}
pr = new PNMLImport((ApplicationMediator) getMediator());
} else
if (filter == FileFilterImpl.OLDPNMLFilter) {
pr = new OLDPNMLImport2((ApplicationMediator) getMediator());
} else {
pr = null;
}
if (pr != null) {
boolean loadSuccess = false;
InputStream is;
// TODO Generate Thread
try {
is = new FileInputStream(file.getAbsolutePath());
loadSuccess = pr.run(is);
} catch (FileNotFoundException e) {
String jarPath = file.getPath().replace('\\', '/');
is = this.getClass().getResourceAsStream(jarPath);
loadSuccess = pr.run(is);
/*
* if (!loadSuccess) LoggerManager.error(Constants.FILE_LOGGER, "Could not open InputStream. " + file.getAbsolutePath());
*/
// }
}
if (loadSuccess) {
editor = pr.getEditor()[pr.getEditor().length - 1];
for (int i = 0; i < pr.getEditor().length; i++) {
if (editor instanceof EditorVC) {
((EditorVC) pr.getEditor()[i]).setDefaultFileType(filter);
((EditorVC) pr.getEditor()[i]).setName(file.getName());
((EditorVC) pr.getEditor()[i]).setFilePath(file.getAbsolutePath());
}
// add recent
String abspath = file.getAbsolutePath();
if (filter == FileFilterImpl.PNMLFilter) {
ConfigurationManager.getConfiguration().addRecentFile(file.getName(), file.getAbsolutePath());