How to create customise property page for custom navigator - eclipse

Hi friends I m new to eclipse plugin. I need to create a new custom navigator and depending on the selection of the elements in the navigator i want to display the corresponding property sheet for it. I had gone through various tutorials but m not finding how to do it. Thanks.

Basically, you have to provide an Adapter for the model objects added into the custom navigator. The simplest way to do that is to register an Adapter factory extension point something like that:
<extension
point="org.eclipse.core.runtime.adapters">
<factory
adaptableType="the type from the model navigator"
class="«your adapter factory class»">
<adapter
type="org.eclipse.ui.views.properties.IPropertySource">
</adapter>
</factory>
</extension>
If you have the adaptable factory, you could follow the article Take control of your properties.

Related

Filtering contents in Eclipse Common Navigator Framework view

I am developing a 3.x based Eclipse RCP application. In the part of application, I am implementing Common-navigator plugin of Eclipse itself, in order to display resources in the workspace. I'have created the navigator view shown below:
But I would like display only one tree child element. More specifically, I only want clause folder and its elements to be shown.
What is the accurate way to do it?
Add dependecy of org.eclipse.ui.navigator if not exists in plugin.xml.
Add extension point org.eclipse.ui.navigator.navigatorContent in extension tab.
Create CommonFilter under that and provide your values to the properties on the right.
Create a class which extends 'org.eclipse.jface.viewers.ViewerFilter' and implement you logic in overridden public boolean select(Viewer viewer, Object parentElement, Object element) (Note : return true would retain the resource in Navigator otherwise it will be hidden).
Configure this extended class in extension for class property in CommonFilter.
And you are good to go for testing.
BTW, this way is adding common filter to across all the Navigator. If you need to configure for particular navigator then you need to get its view and then get viewer out of it and attach your filter to viewer. To achieve this you may need a trigger point e.g., a menu/button/startup extension!

Catel Mvvm Plugins PropertyGrid

I would like to know. How I can dynamically choose view? I would like to make the PropertyGrid in my application. The PropertyGrid should must change when user selects object. As I understand for this task I have to use a DataTemplate but how I can dynamically create DataTemplate in code? The fact is that I use plug-ins and View and ViewModel for each plugin located in separate dll and so I can't directly write DataTemplate in PropertyesViewModel.
How can I make the edit properties for each plugin using the Propertygrid if I can't use a DataTemplate?
For Catel it doesn't matter in which assemblies the views / view models are located since it uses relative naming conventions. However, if you want to show a custom view based on logic that might reside inside a plugin, I think this is out of scope for Catel.
To solve this issue, you must implement a custom service that can communicate with the plugins and resolve the right view for a selected object. One solution might be naming conventions (if it's a PersonModel, you might want to show the PersonPropertiesView and PersonPropertiesViewModel). However, this must be a custom service.

Toolbar items dynamically

I need to create dynamically buttons in main toolbar. I found a solution, but I can create just one button (dynamic contribution item - class extending ContributionItem). But I need to create more than one button, but I cannot find the solution.
I'm fighting with task to create plugin, which parses a XML file containing structure of menu and toolbars. We've already done this plugin for Visual Studio. Its quite easy in principle, but I found swiftly, that not for Eclipse. There is one small but critical otherness. Plugins are implemented declaratively in Eclipse. The file plugin.xml is the gist of plugin's infrastructure, Java code is just ancillary.
The customer wants to refresh the menu and toolbar whenever the selected project is changed. Eclipse lacks several features needed to get the task done. Main menu and main toolbar are cteated at Eclipse's start-up and then they can be hardly rebuilt.
In the most cases the conditions defined at enabledWhen/visibleWhen elements are sufficient to filter contributions according to the context (active part, selected object, whatever else).
If you need to have more freedom, please try E4 ToolControl that allows you to implement your own UI elements:
#PostConstruct
public void createControls(Composite parent) {
//your custom code here
}
More details here https://www.vogella.com/tutorials/EclipseRCP/article.html#toolcontrols
From my understanding you want to have different buttons on the main toolbar depending on the selection of the project explorer (eg. 1 project is java project, the other is javascript etc.). First you will have to contribute to the main toolbar. I think there are some tutorial available so google will help.
The main steps are:
1. create a command (org.eclipse.ui.commmands)
2. create a handler (org.eclipse.ui.handlers) with the previously declared command id
3. contribute to the main toolbar (org.eclipse.ui.menus) with menucontribution and commandId with the following locationURI: toolbar:org.eclipse.ui.main.toolbar?after=misc
showing/hiding, enabling/disabling a menu item/button also can be done declaratively or "mixed". Declaratively means eg. using enabledWhen/visibleWhen...
Mixed means using property tester (org.eclipse.core.expressions.propertyTester). With this you can define your "enablement logic" in Java code.
In Eclipse e4 the UI is generated from a, EMF based, model. The Application.e4xmi serves as a base for that model. Contributions to the model can be done via fragments, which are again XML, or via processors. Processors are written in Java and use e4 services, like the part service, to modify the model at runtime.
I think you want to write a processor that parses your custom XML and modifies the eclipse e4 model accordingly.

Eclipse Properties View without IAdaptable

I tried to create a properties view for a graph model in an Eclipse RCP Application. The graph elements are from a non-eclipse library and so don't implement IAdaptable or even IPropertySource.
The Tabbed Properties View, explained here:
http://www.eclipse.org/articles/Article-Tabbed-Properties/tabbed_properties_view.html
seems to be a simple possibility - but only for inputs that implement IAdaptable.
I've thought about implementing my own IPropertySheetPage but the only implementations I found are the built-in PropertySheetPage and TabbedPropertySheetPage which are very complex.
Is there another way to create a properties view for input elements that don't implement IAdaptable? Can I use Tabbed Properties View in a way I don't see yet? Are there any other less complex implementations of IPropertySheetPage, I can look at?
Thank you!
Kristina
Actually, you can write an IAdapterFactory for objects which don't implement IAdaptable and register it in plugin.xml or in your plugin activator. See http://www.eclipsezone.com/eclipse/forums/t61666.html.
Are there any other less complex implementations of IPropertySheetPage, I can look at?
Short answer: No.
But why don't you wrap the non-adaptable object into your own object that implements IAdaptable or IPropertySource or whatever, so that the property-page can work with your wrapper which holds the object you want to make editable through the property-page. And instead of providing this "library" object to global adapter-mechanism, create the wrapper, set the object and provide it to your global selection-service or whatever.

Opening IProject properties when another (adaptable to IProject) object is selected

I have a custom view displaying a hierarchy model of the current project. The root element is of class MyProject which is my own class, but it represents one Eclipse IProject, and it's adaptable to IProject.
I have a "properties" menu option in the popup menu for that view, and I'd like to open up IProject's properties when a MyProject object is selected. PropertyDialogAction only looks for property pages registered for MyProject and doesn't give me a chance to offer an adapter -- or, at least, I don't know how to offer one.
What's the proper solution for this?
In the meantime, I've overridden PropertyDialogAction to handle my class in the special way I require, but that seems like quite a kludge to get this done.
How did you add the Properties in the Popup menu? Ideally its functionality is to show up the property pages of the current selection - not to show up the properties of the project in which the current selection resides. If you want that, you need to use the menu item Project->Properties - which uses the ProjectPropertyDialogAction instead of the PropertyDialogAction