Integrating EMF and view in plugin project - eclipse

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.

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!

create Property view rcp

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.

Creating a Theme / Template for iOS application?

I am creating an application where there are some views i want to be available in each and every UIView Controller just like a master page in Web Development. i have created those views but how to add them to all the view controllers in the application automatically?
You should add them to mainWindow if you need to display them in all viewcontrollers.
Hope it helps you.
You need to convert the project and all the views that you created to a template first and then create a new project and use that template. Here is a guide I have used:
This guide explains how to create new project templates in Xcode. Project templates appear in the list of project types in the New Project dialog.
1.Create a new project and setup everything as you'd like (NIB files, graphics, sounds, settings, code etc)
Optionally, build and make sure the project works
Use Finder and locate the project folder for your project you created in step 1
Open another Finder window and navigate to /Library/Application Support/Apple/Developer Tools/Project Templates/. You have two options here:
Create a new folder for your custom project templates - this will appear as a category when creating a new project in XCode
Choose an already existing folder (eg Application) - this will place the project template in that category
5.Open the new/chosen category folder and create a new folder inside. You can name this new folder whatever you like and it will appear as the project template name.
6.Copy all files from the project folder in step 3 to the new template folder created in step 5.
7.Try to create a new project in Xcode. You should see your project template in one of the original categories or in the category you created, whichever you decided.
Note: If you built the project, delete the build folder from the template folder.
Hope this would help you out.
Create a base view controller class which will have all these UIViews added in its view. Additionally, you can also implement the events of these particular views in the controller. Other controllers that you create need to extend from this base view controller class.

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.

How to use GWT designer with Eclipse GWT plugin?

Sorry but I see no way to use it at all!
If I create GWT project with sample code, then SDK is generating a page with a HTML table where positions for sample TextBox-es and Button are already marked. So, if I open sample file with GWT designer and move button slightly down-right, I will get errors during run.
If I create GWT project without sample code, then GWT designer appears to be unable to open file with empty GUI.
Is there any way to design GUI from scratch or to see GWT designer usage sample?
Thanks
The problem is when you want GWT to create sample code for you, it puts the container parts of layout hard-coded in your projects html file. The generated sample uses RootPanel.get("someId").add(someWidget); to access these containers. When you open designer and move these widgets around, designer generates RootPanel.get("someId").add(someWidget,left,top); which doesn't work with this method.
On another note, when you want to create a class from scratch and open it with designer, you can simply add a reference to RootPanel to get around "this is not a gui class issue" such as :
public class SimpleClass {
RootPanel r = RootPanel.get();
public SimpleClass() {}
}