简体   繁体   中英

Open Editor in an Eclipse PDE View programmatically

I am creating an eclipse plugin with a view, called DataView. I want the Java Hex Editor to open in my DataView that I created. I followed this vogella post, which stated that getViewSite().getPage(), would force the editor to open in the DataView. However, when I test the code, the DataView opens separately from the editor. Note: I am using Java 8 by company requirements.

Is there anyway to fix this? I have attached my code and my current output below:

@Override
    public void createPartControl(Composite parent) {
    
        Text text = new Text(parent, SWT.WRAP | SWT.READ_ONLY | SWT.V_SCROLL | SWT.H_SCROLL);
        Font font = new Font(text.getDisplay(), new FontData("Courier", 12 , SWT.NONE));
        text.setFont(font);
         
        File file = FileData.getDataFile();
        URI fileURI = file.toURI();
        
        //String workspacePath = ResourcesPlugin.getWorkspace().getRoot().getLocation().toString();

        IFileStore fileStore = EFS.getLocalFileSystem().getStore(fileURI);
        if (!fileStore.fetchInfo().isDirectory() && fileStore.fetchInfo().exists()) {
            IWorkbenchPage page = getViewSite().getPage();
            try {
                IDE.openEditor(page, fileURI, "net.sourceforge.javahexeditor", true);
            } catch (PartInitException e) {
                
            }
        }
    }

在此处输入图像描述

The link does not say that the editor will open in the view, it is just telling you how to open an editor from a view. Editors always open separately in the editor area.

You can't have an editor in a view. You can use the core editor classes such as TextViewer and SourceViewer in a view but that means you can't reuse code from an existing editor unless it is designed to allow this.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM