我找到了这个示例代码:
<div id="popover"> content </div>
#popover{
position: absolute;
// left: <x>px;
// top: <y>px;
display: inline-block;
height: 100px;
width: 100px;
}
当我运行我的插件时,eclipse报告IWorkbenchPage页面为空。
我以这种方式实现我的代码:
File fileToOpen = new File("externalfile.xml");
if (fileToOpen.exists() && fileToOpen.isFile()) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditorOnFileStore( page, fileStore );
} catch ( PartInitException e ) {
//Put your exception handler here if you wish to
}
} else {
//Do something if the file does not exist
}
方法openFile是从同一个类中的另一个方法调用的。
这是我的SampleHandlers(我自己不写):
public void openFile(Path filepath) throws Exception
{
File fileToOpen = new File(filepath.toString());
if (fileToOpen.exists() && fileToOpen.isFile()) {
IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileToOpen.toURI());
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
try {
IDE.openEditorOnFileStore( page, fileStore );
} catch ( PartInitException e ) {
//Put your exception handler here if you wish to
}
} else {
//Do something if the file does not exist
}
}