I am currently developing a RCP application in Eclipse. Right now it is very minimalistic and consists of only one part containing a Text object as such:
public class MainPart {
private Text txtInput;
#PostConstruct
public void createComposite(Composite parent) {
parent.setLayout(new GridLayout(1, false));
txtInput = new Text(parent, SWT.BORDER);
txtInput.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
}
}
I would like to add an auto-completion functionality to this minimalistic RCP, so that it works in the Text object. How do I approach this problem?
The auto-completion should, at least hopefully when it is finished, be able to auto-complete java code. So basically I want to copy the auto-completion that already exists in Eclipse, and put it in my minimalistic RCP. Just a poke in the right direction of where to begin when constructing an auto-completion functionality would also be much appriciated indeed.
Please note that I am new to the subject of RCP, and I have been searching a lot in different forums for answers, but i cannot really seem to find the core ingredients that are necessary to make an auto-completion functionality.
Related
I am working on Graphical Editor i.e (GEF Editor). Files having .graph extensions opens in Graphical Editor and on save action of editor it generates some xml and properties files. Now, my use-case is to achieve the same functionality to generate ".graph" related xml and properties files even if anyone edits ".graph" file using eclipse default text or xml editor.
Is there any way to achieve it?
You can use ResourceChangeListener
IResourceChangeListener listener = new IResourceChangeListener() {
#Override
public void resourceChanged(IResourceChangeEvent arg0) {
System.out.println("Text changed");
}
};
ResourcesPlugin.getWorkspace().addResourceChangeListener(listener);
We have a large RCP based on Eclipse 3.7 that we want to migrate to Eclipse 4. We were able to build the system successfully using the compatibility layer.
The Problem: We use our own WorkbenchPresentationFactory-Implementation that in turn uses a specialStackPresentation:
public class PresentationFactory extends WorkbenchPresentationFactory {
public PresentationFactory() {}
#Override
public StackPresentation createEditorPresentation(Composite parent, IStackPresentationSite site) {
return new SimpleStackPresentation(parent, site);
}
}
This SimpleStackPresentation is basically a copy of the original Eclipse 3.7 StackPresentation and accompanying "helper" classes altered so that there is always only one editor visible at a time, editors are never closed but hidden.
Now, the use of a PresentationFactory is deprecated officially in Eclipse 4, see:https://www.eclipse.org/eclipse/development/porting/4.2/incompatibilities.php#presentationAPI
Were do I start to implement the same behavior with Eclipse 4 in conjunction with the compatibility layer?
Any help is very much appreciated!
Regards
sascha
I want to open a text editor in eclipse 4.4 programmatically. I've tried it using IDE class but it is not accessible in eclipse 4.4. How can I do this?
e4 only has parts, not editors and views. It also doesn't have any predefined text editors.
Assuming you want to have several editor parts open at the same time you need to define a 'Part Descriptor' in the application model for the editor.
You then create a part from the descriptor using:
#Inject
EPartService partService;
MPart part = partService.createPart("descriptor id");
You now need to add this to the application model. Usually this will be a child of an 'MPartStack':
#Inject
EModelService modelService;
#Inject
MApplication app;
MPartStack editorStack = (MPartStack)modelService.find("part stack id", app);
editorStack.getChildren().add(part);
Finally show the part:
partService.showPart(part, PartState.ACTIVATE);
The class you specify in the part descriptor for the editor will have to implement the text editor. You can use the JFace text editor classes but not the 'org.eclipse.ui.xxx' editor classes.
For a very simple text editor the TextViewer and Document classes are enough.
I have a question regarding e4 rcp applications.
I am creating an Eclipse e4 RCP project which uses the compatibilty layer.
Basically I created an 3.x RCP project, a product and an Application.e4xmi to use e4 features in my 3.x RCP project. I did this to be able to use the compatibilty layer for stuff like the project explorer, the console etc....
I started with that tutorial: http://dirksmetric.wordpress.com/2012/08/01/tutorial-eclipse-rcp-e4-with-3-x-views-like-project-explorer-properties-etc/
and now I'm migrating my own plugins from 3.x to e4.
Till now that worked out pretty well. I can still use a multiparteditor from 3.x but also dependency injection for some parts. Now I'm facing a rather odd problem.
My Application has a Trimmed Window with a Main menu some parts and then there are the TrimBars...my problem.
The toolbar I create there is not shown if I choose the 'top' side...every other side is working.
In a pure e4 Application that is working fine. I'm not sure why...maybe you have an idea.
Thx.
After you have created your RCP application, you should have class ApplicationWorkbenchWindowAdvisor (extends WorkbenchWindowAdvisor) created for you. It has preWindowOpen() method overridden with IWorkbenchWindowConfigurer.setShowCoolBar(false). Change it to true:
public void preWindowOpen() {
IWorkbenchWindowConfigurer configurer = getWindowConfigurer();
configurer.setInitialSize(new Point(400, 300));
configurer.setShowCoolBar(true);
configurer.setShowStatusLine(false);
configurer.setTitle("RCP Application");
}
Make sure that your XMI file defines the 'TOP' TrimBar with the id 'org.eclipse.ui.main.menu', there's currently some dependency on the handling code that requires this (i.e. it finds the trim bar by ID rather than position).
I have created an editor plug-in for eclipse that is associated with the file extension .eap
I have also created a perspective that contains views for this data.
I would like to add the following behaviour: When I double click on the .eap file I'd like the EAP Perspective to be opened.
Just like what happens when you click on a Java file for the first time.
Any help appreciated!
Will
try {
IWorkbench workbench = PlatformUI.getWorkbench();
workbench.showPerspective(EapPerspective.ID,
workbench.getActiveWorkbenchWindow());
} catch (WorkbenchException e) {
e.printStackTrace();
}
As far as I know, clicking on or opening a Java file for the first time will not open the Java perspective. However, perhaps you are thinking about how after using the New Java Class Wizard, you are prompted to change to the Java perspective.
Regardless, there are several things that you can do:
In the org.eclipse.ui.newWizards extension point, specify the finalPerspective as well as preferredPerspectives
Assuming that you have sub-classed AbstractTextEditor, then override the setFocus() method and add some logic to change to the appropriate perspective, something like this (but be careful to add specific null checks):
getEditorSite().getWorkbenchWindow().getWorkbench().showPerspective(desc.getId(),
getWindow(), pageInput);
The first solution is recommended, although it will not cover all the cases that you are asking for, and the second is a bit naughty as it goes against Eclipse conventions.