So first things first. How does the new multi-instance Property View looks like? Well, just like the old one except for the two new buttons in the tool bar:
The first button is to toggle the pin property and the second one is to open up a new instance of the property view. Once you click on the second one, you will get another instance of the view. The first instance is pinned to the selection for your convenience (if its not already pinned). You can move around the new instance to other place and change the selection to a different object and you can compare the properties. I've pinned the first instance to MyFile1.txt and the current selection is MyFile2.txt. Now I can compare the properties of these two files side-by-side:
You can create any number of instances and arrange them in any place in your perspective and use them. If you change any preferences like pinning of selection or column widths or hide categories, etc, all those changes are isolated to the particular instance which you are changing. The rest will stay unaffected. You can close any/all of the instances. When the workbench is closed and restarted, all the secondary instances will be gone. You will start only one view.
This is all good, so that the user wants to manipulate. As a plug-in developer how can we manipulate this? Opening a new instance is implemented as a Command. So if you want to create a new instance, then all you need to do is to call the command programmatically:
1: try {2: IHandlerService handlerService = (IHandlerService) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getService(IHandlerService.class);
3: handlerService.executeCommand("org.eclipse.ui.views.properties.NewPropertySheetCommand", null);4: } catch (Exception e) {
5: // handle exception
6: }Had the command taken a parameter for the secondary id, it would be easier for you to find the newly created instance. But the command neither had option for that. We still can iterate thru the view references in the window and get hold of the views. With the views, you can get/set the pinned property on them:
1: IViewReference[] viewReferences = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().getViewReferences(); 2: for (int i = 0; i < viewReferences.length; i++) {3: if("org.eclipse.ui.views.PropertySheet".equals(viewReferences[i].getId())){4:
5: // this is one of the property view instance
6: PropertySheet propertyView = (PropertySheet) viewReferences[i].getView(true);
7: 8: // just toggle the pinned property
9: boolean pinned = propertyView.isPinned(); 10: propertyView.setPinned(!pinned); 11: } 12: }As I mentioned, all these info is subject to change, and I'll add more info to this tip as the bug gets updated.
2 comments: