In Eclipse RCP 3.7.x I use
PlatformUI.getWorkbench().close();
to close the workbench
in E4 there any Method to close Workbench (without button click) or how to get Workbench reference in my code
If you are doing a 'pure' e4 application you cannot use the 3.x org.eclipse.ui.IWorkbench.
However there is a org.eclipse.e4.ui.workbench.IWorkbench class which has a close() method.
You use direct injection to inject this workbench class in to your code.
For example in a command handler you might do:
#Execute
public void execute(IWorkbench workbench)
{
workbench.close();
}
Related
I just added 2 perspectives in my RCP App. I can switch from one to another without problems.
But I didn't find a way to reset perspective, for example if I close a Part excidently I need to reset my perspective.
PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage().resetPerspective();
this didn't work because I use E4.
-clearPersistedState -persistState false
is not a solution cause I need to reset without restart my App.
Use the resetPerspective method of EModelService:
public void resetPerspectiveModel(MPerspective persp, MWindow window)
Note that PlatformUI and associated APIs can't be used in a pure e4 application.
i am working with eclipse oxygen, i download pydev 6.3.2 and this was added to eclipse.
Now i want add Pydev in my custom rcp application, i read vogella book but i can't figure out how do this.
If anyone have the tip of the iceberg where i can start i will be thankful.
I have a e3 rcp application with Pydev Perspective already working but i want updated the technologies that i am working now that is i why start with e4.
In e3 i add the pydev plugins trougth Windows, Preferences, Plug-in Development, Target Platform.
Then i added in Dependence Tab in plugin.xml the "com.python.pydev.*"
Last step was create an button and in the handler put the next code
public class ShowPydevPerspective extends AbstractHandler
{
#Override
public Object execute(ExecutionEvent event) throws ExecutionException
{
ViewUtility.OpenPerspective("org.python.pydev.ui.PythonPerspective");
return null;
}
}
When the app run and click on the button the pydev perspective appears with all the context.
I try to do the same steps in e4 but is not working.
I added in my plugin.xml , dependece tab all
org.python.pyedev.*
org.eclipse.ui.*
I added too a button with the code that i mentioned after.
I have the following error, has you see in the image attached.
pydev integration error
Regards
PyDev is written for e3 and won't run in a pure e4 app. If you want to use this stick to an e3 RCP.
You can't just include org.eclipse.ui.xxx plugins in an e4 app {with one or two exceptions) - these are 3.x compatibility mode code and require a lot of setup that e4 doesn't do.
I recently installed Java 8 64 bit version on my machine and installed Eclipse Luna version 4.4.2 64 bit.However when I programme a java application,the IDE not showing auto suggestions to use Java 8 features like use lambda expressions instead of anonymous inner class.The code I have used is given below.As my reputation is low I am not able to post images.
public static void main(String[] args) {
Thread t=new Thread(new Runnable() {
#Override
public void run() {
System.out.println("Run method called");
}
});
t.start();
}
Works fine for me in Eclipse Luna 4.4.2. I press Ctrl+1 when staying on new Runnable:
Seems that there's no way to mark it as warning (yellow lightbulb). However you can switch on a save action for lambda. Go to Preferences -> Java -> Editor -> Save Actions, check "Additional actions", press "Configure", go to "Code style" tab and check the "Convert functional interface instances":
This way all the anonymous classes which can be converted to lambdas will be converted automatically upon you press Ctrl+S. You can also make this conversion for the whole project at once: select the project in Package explorer, right-click, Source, Clean up, Use custom profile, configure and check the same checkbox.
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 am developing an interpreter for a visual programming language that I am implementing using Eclipse, EMF and GEF. I am currently creating an interpreter for the diagrams.
To execute a diagram, I decided to implement a launcher configuration. When the configuration is executed I want to read the EMF model from the active editor and interpret it. The problem I have is that the active editor can only be accessed from the UI thread, and I don't want the interpreter to execute in the UI tread since it may be a long process. This is the code that works but should not be used:
#Override
public void launch(ILaunchConfiguration configuration, String mode, ILaunch launch, IProgressMonitor monitor)
throws CoreException {
final IWorkbench workbench = PlatformUI.getWorkbench();
workbench.getDisplay().asyncExec(new Runnable() {
#Override
public void run() {
IEditorPart activeEditor = workbench.getActiveWorkbenchWindow().getActivePage().getActiveEditor();
OPMGraphicalEditor editor = (OPMGraphicalEditor) activeEditor;
OPMObjectProcessDiagram opd = editor.getOPD();
Interpreter.INSTANCE.interpret(opd);
}
});
}
I'm sure there is a proper way to do this, but I haven't found it. The examples for launch configurations that I found in the internet use external programs, but I am (currently) implementing my interpreter as part of the workbench.
Thanks for the help.
You can use the above code with a ...getDisplay().syncExec(...) instead and then store the pointer to the editor into some enclosing object.
If you're launching your configuration from the editor directly (right-click, run as..) then you can just use an ILaunchShortcut and overwrite its void launch(IEditorPart editor, String mode) method to access the editor where the file is launched from.