I have a model in an Eclipse RCP application. Sometimes a new model version is created, so the existing model gets migrated. This can be done by implementing the CustomMigration class. This migration takes place when opening the model file with a editor implementation.
If this migration fails for some reason, the model can not be migrated. The problem is, in this case the editor is still being opened, but this will not work because there is no valid model. This will cause a mess like a broken editor window and exceptions.
How can this mess be avoided? Is there a reason to abort the opening process of the editor? Or is it possible to do the migration before the window is opened?
Related
In eclipse, I have disabled the reporting of problems as I type. Because I found all the editor activity too distracting.
When I am finished making the changes, I want to have it checked/validated by eclipse. I do this by saving the file: problems get reported then.
My question: is there a way to make eclipse check the code without saving?
We all know that by default eclipse saves application state in workbench.xmi and then recreates perspective only if this file is absent. However, I've got a project on e4 which ignores this file even though it exists and -clearPersistentState is NOT specified in arguments. I think there should be some piece of code somewhere responsible for this but the project is too big I don't know how to track it down. My goal is to make this app to use workbench.xmi once again to restore perspective.
To investigate why this happens I want to know which eclipse method is responsible for perspective restoration so I could make sure that this project at least launches this method. That's the main question.
The less main and the less clear question is how this default restoration behavior can be avoided? I mean where should I look for the possible source of this problem? Could there be some option in some .xml which makes the project forget about workbench.xmi? Could it be some sort of startup handler which manually restores default perspective? Maybe some hint about which methods are possibly should be involved in this so I could search for them. Any help is appreciated. Thanks in advance.
-UPDATE-
So it turned out that the problem arises because the project UI is defined in fragments rather than in main Application.e4xmi and eclipse has a bug due to which fragments UI merge with main application after previous state restoration thus replacing restored settings with predefined ones. This bug is discussed in this thread.
This useful article describes how one can manually save and load various application components. Another useful source of inspiration is the source code of ResourceHandler itself.
The main E4Application class controls loading and saving the application model.
E4Application calls a class implementing IModelResourceHandler to load and save the model and the persisted state. It is possible for an application to use its own version of IModelResourceHandler but normally the default org.eclipse.e4.ui.internal.workbench.ResourceHandler is used.
ResourceHandler uses the clearPersistedState, persistState and the deprecated deltaRestore options to control loading the persisted state. These values can be set by command line options.
Add apply="initial" to fragment tag in your plugin.xml to restore stored perspective from workbench.xmi
Example:
<fragment
uri="fragment.e4xmi"
apply="initial">
</fragment>
I am working on a project in Drools6. I have defined a few custom tasks using workitemhandler. When I create a new process file(*.bpmn file) and model it by adding my custom tasks and other inbuilt blocks, everything works fine in the beginning. But, if the complexity of the .bpmn flow diagram increase i.e, I add about 4-5 custom tasks, create sub-processes, add a few gateways etc, the program crashes and I will not be able to open my flow diagram again. It says there is a parse error.
I have tried reinstalling eclipse, but it still gives me the same error. I have not used exception handling in the java class of my custom tasks. Could this be why my program is crashing.
please guys, if anyone has come across a similar issue, let me know how you resolved it.
Thank you
it seems that for some reason your business process is corrupted and it cannot be opened by the editor. Do you have a previous version of your process? Try opening another process.
You can also try the web designer, which is usually more powerful than the eclipse one.
Regards
This is not another of many "how do I have Eclipse auto refresh" questions. My problem is that it does but not entirely.
In a workspace with multiple projects the compilation of one causes source code to be generated in other(s) (that exist purely for this purpose - no manually written source code there). Source code is generated during the main compilation itself (i.e. not a custom builder, but a plugin for the Scala compiler, but that should be irrelevant).
What I've done so far is:
Add a dummy custom (ant) builder AFTER the standard one and set it to "refresh selected resources" - the source folder of those generated projects.
Also add a dummy custom (ant) builder BEFORE the standard (Java) builder of generated projects that refresh the same thing. Actually I tried various versions - just the source folder, the entire project, or the entire workspace with the same outcome. Note that those generated projects are set to depend on the project whose compilation generates their source code.
In Window -> Preferences -> General -> Workspace enabled "Refresh using native hooks or polling" in addition to "Refresh on access". I also tried disabling "Refresh on access" (leaving only the other one). Same outcome.
Tried with Eclipse Indigo (3.7 SR2 20120216-1857) and Juno (4.2.2 M20130204-1200), both 64-bit Windows versions. Additional plugins are installed, most notably Scala IDE (multiple different versions both for Scala 2.9 and 2.10 ending with Scala IDE 3.0.0). Same outcome.
... and that outcome is that Eclipse does indeed notice the files that have been modified. In whatever was the best combination of settings of the above (forgot) I was even able to get it to notice that some files that used to be generated no longer are and have them disappear (although I still had to collapse the tree and re-expand it, but no F5 was needed).
However, I never got to have it automatically discover that a brand new file that did not exist before was created. In my case that also yields compilation errors (since the modified files that it does discover have changed refer to the code in new files it does not notice).
Simple F5 solves the problem, but it is killing me, as I am trying to roll this environment to other developers and I'd hate having to tell them "You know, you have to (keep) push(ing) F5 every time you...".
Is it possible that this is still impossible in Eclipse? Does anyone know of a plugin (if not a direct solution) that can help?
As I noted in comments, discovering new folders (Java packages) also does not seem to be a problem. Just new files in existing folders.
Thanks!
UPDATE
With all the refresh things I did in place I noticed something I did not before.
I make the change in the project that causes code generation (was trying to test if it is the re-appearance of previously disappearing file is an issue or otherwise). This time I was just renaming one method which caused a name of the generated source file (Java class) to be changed as well.
As "Build automatically" is enabled, Eclipse begins the build. Very quickly it discovers an error and complains about it - one generated class that was modified now refers to a class Eclipse does not see yet (because refresh is incomplete - saw the modified file, but still believed that the file that no longer exists is there and did not see the new file).
Build actually continues. Progress goes up and down, appears and disappears a number of times, building other dependent projects. All the time the error is listed and marked in the Package Explorer on the modified class.
After the build seemingly completes (with that error in it, some minutes later), the refresh completes (!!!). Package Explorer is updated, the old file disappears, the new file appears, the error disappears, etc. I initially attributed this to me switching windows and triggering the refresh that way but I made sure I touched nothing the last time - just made the change and pushed Ctrl+S to save it.
This may mean that the 'condition' is not so bad (one just has to be very patient and have nerves of steel). Investigating further. Thanks to all who are or may be doing the same! The question is still why are there two refreshes with the first one being incomplete?
I have recently come across the LESS Leaner CSS a template engine for CSS based on ruby. The idea sounded neat, but in practice we need to compile the program to get CSS. This is cumbersome as we make too many changes while working on CSS and for every edit we don't want to compile.
In Eclipse, there are "Save-Actions" but it handles only formatting changes.
Is there a way on saving the file in Eclipse, to call or trigger the compilation?
Its easy to do this in Vi or Emacs.
I think all you need is to define a custom Builder for your project. That way, you can run a program or an ant script whenever certain files change.
Right click on the project -> Properties -> Builders -> New
While the Builders are a good solution, keep in mind they only work when a build is issued - either using auto-build or using a manual build which is invoked, well, manually. If you are looking for something that will operate after a save, regardless of the auto-build state you will need to write a plugin which listens to resource changes in Eclipse.
You do that by creating a workspace change listener and installing it like that:
ResourcesPlugin.getWorkspace().addResourceChangeListener(
..., IResourceChangeEvent.POST_CHANGE);
I'm sure you can take it from here :-)