Hi I am new to Eclipse rcp. I am developing a small application. In this application I want to show property view corressponding to the selected file.
I referred to this article : http://www.eclipse.org/articles/article.php?file=Article-Adapters/index.html
However, I am unable to find how to create property view and show it in my application perspective. Like shown here: http://www.eclipsepluginsite.com/properties-2.html
So, instead of eclipse application , it should be my application , my navigator view and my property view.
The Properties view has the id org.eclipse.ui.views.PropertySheet, there is a constant for this value IPageLayout.ID_PROP_SHEET.
So if you are using a Perspective factory for your RCP then you need to do an addView for IPageLayout.ID_PROP_SHEET to the main IPageLayout or an IFolderLayout.
Related
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!
I created an EMF project and tested using <>.editor project generated by .genmodel file by creating a new project and a file through "Example EMF Model Creation Wizards". Is there any way that a view (in plugin project) can be created directly (probably project & file are automatically created when user runs the application)? I dont want the user to create these things. It should be automated and presented in a view.
In the .genmodel file, set .genmodel --> All ---> Runtime Platform to RCP. This creates an RCP app that does not use all the plugins of the IDE. If you want, you can generate your app to run in the IDE... However, for this answer I will simplify and assume you generated an RCP app. Go into the XXX.editor generated plugin, and into the .plugin file --> extensions. Add a new (org.eclipse.ui.views) View by declaring a new View extension -- see the Sample View for a template. Make sure to keep track of the ID you give this new View extension. Similarly add a new PerspectiveExtension extension. Add a reference to this new PerspectiveExtension with your unique View ID. In the View extension, click on the class link, this will create a skeleton ViewPart class. It is a good idea to put a public static final String YOUR_VIEW_ID = "com.yourplugin.ViewID" in that class.
This will get you started and if you added your new view to your perspective, it should be visible when running your EMF based RCP app.
How to add a fast view to my eclipse rcp applicatio?
You can add the right button, as in this thread:
that can be done by adding a button to fast view bar and by opening a standard view in button event
Button button =
new Button ((Composite)((WorkbenchWindow) window).getFastViewBar ().getControl (), SWT.PUSH);
to avoid overlapping in button event first create folder layout for this view with reference to initial view and then call the action to add view.
IFolderLayout ViewLayout1 = layout.createFolder ( "ViewLayout1",
IPageLayout.BOTTOM,
0.50f, initalView.ID);
OpenViewAction ov = new OpenViewAction (window, "label", secondview.ID);
ov.run ();
Showing and minimizing a fast view programmatically should be done through command "org.eclipse.ui.views.showView" with the parameter "org.eclipse.ui.views.showView.makeFast".
See Eclipse RCP: open a view via standard command org.eclipse.ui.handlers.ShowViewHandler:
Eclipse provides the standard command org.eclipse.ui.views.showView to open an arbitrary view.
The default handler is org.eclipse.ui.handlers.ShowViewHandler. This handler is a nice example how you could add your own command with arguments. It takes two parameters:
The first has the ID org.eclipse.ui.views.showView.viewId and identifies the view ID which should be opened,
the next one has the ID org.eclipse.ui.views.showView.makeFast and determines if the view should be open as a fast view.
Without parameters the command will let the user choose which view to open.
See Parameter for commands for some examples
Lets see the real world example: "Show View" command. The command is generic and can show any view. The view id is given to the command as a parameter:
<command
name="%command.showView.name"
description="%command.showView.description"
categoryId="org.eclipse.ui.category.views"
id="org.eclipse.ui.views.showView"
defaultHandler="org.eclipse.ui.handlers.ShowViewHandler">
<commandParameter
id="org.eclipse.ui.views.showView.viewId"
name="%command.showView.viewIdParameter"
values="org.eclipse.ui.internal.registry.ViewParameterValues" />
<commandParameter
id="org.eclipse.ui.views.showView.makeFast"
name="%command.showView.makeFastParameter"
optional="true"/>
</command>
The list of all possible values of the parameter is given by the class ViewParameterValues. The class would iterate through the view registry and return it.
Note: just to be complete, in theory (this thread)
RCP apps can disable fast views by calling WorkbenchWindowConfigurer.setShowFastViewBar(false) from their
WorkbenchAdvisor's preWindowOpen() method.
This not only hides the fast view bar, but also hides the Fast View menu item on views.
The simple way to add a fast view to an Eclipse RCP or RAP application begins with creating a normal view. In the plugins xml, add a new extension for the view (I'll call it fast.view), with the correct attributes.
<view
closable="true"
id="fast.view"
minimized="true"
ratio=".30f"
relationship="fast" <--- This attribute tells the view to be a fast view.
relative="other.view"
</view>
After adding this extension, we must also show the fast view bar in the workspace. To do this, edit the ApplicationWorkbenhWindowAdvisor (or other advisor that launches your workbench window), and add the following lines to your preWindowOpen() method:
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setShowFastViewBars(true);
If you already have an IWorkbenchWindowsConfigurer, you don't need to make a new one. This method tells the workbench to display the fast bar, and your new fast view perspective extension should be there when it starts.
I got this information from an Eclipse Papercuts article written by Lars Vogel: http://www.vogella.de/blog/2009/09/15/fastview-eclipse-rcp/
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
I have a plugin which contains class A that brings up a view defined in class B via the following line of code:
(VideoLogView) PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("Videolog.VideoLogView");
What I need to do in the createPartControl() method of the view (class B object) is access a method in the class A object.
How can this be done?
Thanks.
Look like you are facing the classic issue of "how do I pass arguments to my view" ?
This thread illustrates it best:
I was facing the same problem at the beggining of my RCP project. I was getting weird about the fact that there was no way to pass an argument to a view as the viewed model.
Why? Because (emphasis mine):
You are on an opened, pluggable platform.
You contribute to existing developments, others should be able to contribute to yours.
Therefore you will not "pass" arguments to a view, this would lock the whole thing into a non-opened design.
Instead, your view will ask the platform (or will listen to the platform) to determine which information to manage.
Other views (from other plugins that don't yet exist) might also want to manage the same information on the same event.
What you should do then is to ask the workbench for the current selection. I guess your view is opening on a double click action or simple selection so the object you want to manage in your view will be currently selected.
This is how you could retrieve the workbench selection from your view :
ISelection s = this.getSite().getWorkbenchWindow().getSelectionService().getSelection();
where "this" is a ViewPart.
Then you have to make your initial view (the one initiating the view creation from a given event like DoubleClick) a selection provider. A JFace viewer is a selection provider, so you can use it if you're using jface, or you can implement the ISelectionProvider interface when you're using custom SWT controls (that was my case).
The article "Eclipse Workbench: Using the Selection Service" can also give you some pointers.