Implement Linkhelper
In the last example, after extending all kinds of extension points in plugin.xml, we can actually do some of the things that project Explorer has done with this com.example.test view, such as creating projects, folders , files, etc., which are implemented through reuse of navigatorcontent.
Another area to note is that, in this view of our implementation, Iresource acts as a direct interface to CNF and also acts as a model for the business Scenario "project/Folder/file". (This is why the new structedselection (file) in Linkhelper can navigate directly to the node in the Navigator)
But in the actual project development process, not every business model is as easy to show as the file system. For example, the Package concept in Java needs to be presented in a way that combines multiple folders into a single tree node (in the middle with a "." Partition), and the jar package also needs to be internally decompressed to present its internal tree structure.
So typically, the business model has a separate abstract representation and serves as a direct interface to the CNF. Its advantages are:
All changes to the model on the Eclipse UI are first passed to the domain model itself and then persisted to the operating system through Iresource. Changes to the model and the transfer of changes are more direct. As shown in Figure 6.
Figure 6. Resource Management in Eclipse
The same set of resource files, through different perspectives need to have different presentation, operation and storage. For example, a Java project is presented and manipulated in Package Explorer in a way that is closer to Java development, while Resource Explorer displays all folders and files in an operating system perspective. The point of view of resources here is the things to consider when building a business model.
Next, we will add our own business model layer on the basis of the previous example. Although in the case of files and folders, the existence of this layer is of little significance, but it can be used for reference by readers in solving specific work.
We modeled a Custom.linkwitheditor.sample plug-in project on the previous example, but this time we will implement most of our functionality and join a specific business model layer.
First change the view ID to Custom.linkwitheditor.view.myCustomNavigatorView and add an icon.
Delete the vieweractionbindin--under Org.eclipse.ui.navigator.viewer extension This means that in this example we do not extend any action,context menus etc.
Delete the viewercontentbinding--in the org.eclipse.ui.navigator.viewer extension for a while we will create our own implementation of navigatorcontent and Linkhelper.