Csdn-Blog <script language="javascript" src="http://www.023rcsc.com/count/count2.asp"></script>
file.createNewFile();
else{
file.delete();
file.createNewFile();
}
StringReaderin=newStringReader(s);
OutputStreamWriterout=
newOutputStreamWriter(
newBufferedOutputStream(
newFileOutputStream(file)),"UTF8");
intc;
while((c=in.read())!=-1)
out.write((char)c);
out.close();
}catch(Exceptione){
e.printStackTrace();
}
returnStatus.OK_STATUS;
}
};
//因为无论保存数据要多少时间,我都要响应用户操作,所以schedule()后不管了.
saveFile.schedule();
setTableViewSave();
}
} //打开文件
publicvoidopenFile(){
openDialog=newFileDialog(getShell(),SWT.OPEN);
openDialog.setFilterNames(FILTER_NAMES);
openDialog.setFilterExtensions(FILTER_EXTS);
finalStringfileName=openDialog.open();
JobopenFile=newJob("OpenFile"){
publicIStatusrun(IProgressMonitormonitor){
if(fileName!=null){
//Openthefile
//Filefile=newFile(fileName);
Departments.getInstance().initSelf();
XmlHandler.getHandler().hand(fileName);
}
returnStatus.OK_STATUS;
}
};
openFile.schedule();
try{
//因为是打开文件,我必须等该操作完后才继续
//所以用了join()方法
openFile.join();
if(openFile.getResult().isOK())
ProjectList.getInstance().updateProject();
}catch(InterruptedExceptione){
e.printStackTrace();
}
}
上面两点只是我的一点点看法,一定有不对的地方,还望指点. 参考资料:
http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html
http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/runtime_jobs.htm
RCP里响应资源改变以及操作资源(下) src="http://www.023rcsc.com/count/iframe2.asp" frameborder="0" width="650" scrolling="no" height="160">
RCP里响应资源改变以及操作资源(下)
exists())file.createNewFile();
else{
file.delete();
file.createNewFile();
}
StringReaderin=newStringReader(s);
OutputStreamWriterout=
newOutputStreamWriter(
newBufferedOutputStream(
newFileOutputStream(file)),"UTF8");
intc;
while((c=in.read())!=-1)
out.write((char)c);
out.close();
}catch(Exceptione){
e.printStackTrace();
}
returnStatus.OK_STATUS;
}
};
//因为无论保存数据要多少时间,我都要响应用户操作,所以schedule()后不管了.
saveFile.schedule();
setTableViewSave();
}
} //打开文件
publicvoidopenFile(){
openDialog=newFileDialog(getShell(),SWT.OPEN);
openDialog.setFilterNames(FILTER_NAMES);
openDialog.setFilterExtensions(FILTER_EXTS);
finalStringfileName=openDialog.open();
JobopenFile=newJob("OpenFile"){
publicIStatusrun(IProgressMonitormonitor){
if(fileName!=null){
//Openthefile
//Filefile=newFile(fileName);
Departments.getInstance().initSelf();
XmlHandler.getHandler().hand(fileName);
}
returnStatus.OK_STATUS;
}
};
openFile.schedule();
try{
//因为是打开文件,我必须等该操作完后才继续
//所以用了join()方法
openFile.join();
if(openFile.getResult().isOK())
ProjectList.getInstance().updateProject();
}catch(InterruptedExceptione){
e.printStackTrace();
}
}
上面两点只是我的一点点看法,一定有不对的地方,还望指点. 参考资料:
http://www.eclipse.org/articles/Article-Resource-deltas/resource-deltas.html
http://help.eclipse.org/help30/index.jsp?topic=/org.eclipse.platform.doc.isv/guide/runtime_jobs.htm
RCP里响应资源改变以及操作资源(下) src="http://www.023rcsc.com/count/iframe2.asp" frameborder="0" width="650" scrolling="no" height="160">