Posts Tagged ‘eclipse’
Wednesday, February 6th, 2008
After long long time since the bug #149890 was reported on 2006-07-06 has been finally resolved on 2008-02-03. I wonder if my comment on javalobby a couple of days ago has something to do with this. Now it seems that is possible to have a dynamic MenuManager as a submenu of the parent MenuManager.
Tags: bug, dynamic, eclipse, menumanager, submenu
Posted in eclipse | No Comments »
Thursday, September 6th, 2007
I’ve submitted a patch (Attachment #77777 and a couple of screenshots ( Attachment #77774 y Attachment #77776) to Bug #201116. It’s only a preliminary work but it enables the user to select with contentMergeViewer to use with each FileType/ContentType. Now it’s only useful if you use my java formatting compare plugin. Currently the org.eclipse.compare subsystem will allow only one contentMergeViewer per fileType or contentType and you cannot tell which one it will be as Szymon Brandys comments. With this patch the user can select/switch which one he wants to use among all viewer registered for a given file extension/content type.


Tags: bug, compare, contentMergeViewer, eclipse, formatting, java, patch, screenshot, viewer
Posted in eclipse, java | No Comments »
Friday, August 31st, 2007
I filled
Bug 201116 – Compare will silently discard additional contentMergeViewers associated with the same file extension a couple of days ago. As Szymon Brandys says eclipse should allow the user to switch between the differente merge viewer available for a given extension. He proposes two solutions:
1) Having a mechanishm inside the compare view to do the switch
2) or having a preference page to do the same
I feel more inclined towards the second solution, as I’m used to change the defautl editor for .xml, etc though the preference page General -> Editors -> File Associations. Having a similar preference page would fit me. I’m trying to figure out how to integrate a preference page to org.eclipse.compare and send it back to eclipse.org to include it in the next release.
Tags: bug, compare, contentMergeViewer, eclipse, enhancement, page, preference, preferencepage
Posted in eclipse, java | No Comments »
Thursday, August 23rd, 2007
I received some comments about my java compare plugin about my plugin ignoring preferences for text font and formatter settings. I didn’t address those at the beginning because I didn’t notice so as soon as I realized that was missing I put my hands at work.
The java formatter settings was easy just modifying the old
final Properties options = new Properties();
final CodeFormatter codeFormatter = ToolFactory .createCodeFormatter(options);
with
final Map options = JavaCore.getOptions();
final CodeFormatter codeFormatter = ToolFactory.createCodeFormatter(options);
That’s easy. The font issue was also easy, just adding the following snippet to the plugin.xml did the trick:
<extension
point="org.eclipse.ui.themes">
<fontDefinition
categoryId="org.eclipse.compare.contentmergeviewer.TextMergeViewer"
defaultsTo="org.eclipse.jdt.internal.ui.compare.JavaMergeViewer"
id="com.rubenlaguna.eclipse.javacompare.JavaFormattingMergeViewer"
label="Java compare text font (ignore formatting changes)">
<description>
The Java compare text font is used by Java compare/merge tools when the ignore formatting changes plugin is loaded.
</description>
</fontDefinition>
</extension>
Because JavaFormattingMergeViewer extends JavaMergeViewer whick in turns extends TextMergeViewer the code to manager fonts, etc is already in place it’s just a matter of setting it properly in the plugin.xml.
Tags: eclipse, font, fontdefinition, formatter, java, plugin
Posted in eclipse, java | No Comments »
Saturday, August 18th, 2007
I met some difficulties dealing with the default eclipse java compare. I got involved on a project where everybody likes to commit code to CVS formatted their way, so comparing between CVS revisions is almost impossible.
So I decided to start investigating about Eclipse plugin development to make a Java Compare Viewer that not only ignores whitespace but also all java formatting changes. The result is the following
Before ignore java formatting plugin:

After ignore java formatting plugin:

The plugin honors the text font preferences set in General -> Appearance -> Colors and fonts -> Text Compare -> Java compare text font. Also honors the Java Formatter preferences in Java -> Code Style -> Formatter
You can download the plugin and source code tested in Eclipse 3.3 Europa release from here. (The source code is in src folder inside the .jar)
Or you can use Update Manager:
http://rubenlaguna.com/javacompare/update-site.

To activate/deactivate the plugin all you have to do is press the new icon in the java compare view

UPDATE: Depending on your current set of plugins this plugin may or may not work. There is an issue in Eclipse when it comes to registering contentMergeViewers, It seems that when you register more that one contentMergeViewer for a particular file extension (in this case the Eclipse JDT registers org.eclipse.jdt.internal.ui.compare.JavaContentViewerCreator and my plugin registers com.rubenlaguna.eclipse.javacompare.JavaContentViewerCreator) then the CompareUIPlugin.registerExtensions() will only record the last one. I’m trying to figure out how can I force my plugin to register last because right now depending on your configuration my plugin can register before JDT and then JDT will override my contentMergeViewer with his own. I have filed a bug report on eclipse bugzilla about this issue
Tags: code, comments, compare, decided, eclipse, formatting, ignore, java, revisions, whitespace
Posted in eclipse, java | 26 Comments »
Wednesday, July 25th, 2007
I’m working with Eclipse 3.2.2 RCP right now and I’m getting an exception that I want to display on screen. I found in the eclipsepedia that we must use ErrorDialog to report errors:
try {
// ...
} catch (InvocationTargetException e) {
IStatus status = new Status(IStatus.ERROR, Application.ID, 1, "Exception found.", e.getCause());
ErrorDialog.openError(window.getShell(),"Error while loading file", null,status);
}
But using this code snippet will only print the e.getLocalizedMessage() in the Details pane of the ErrorDialog. See screenshot

If you want to see the full stacktrace of the exception in the Details pane you have to implement your own ErrorDialog. Thus taking ErrorDialog as a base and modifiying it a little bit with the guidance found here I created ExceptionDetailsErrorDialog.java. Using ExceptionDetailsErrorDialog instead of ErrorDialog shows the following dialog:

Tags: details, eclipse, error, errordialog, exception, reporting, stacktrace
Posted in eclipse, java | 1 Comment »
Friday, June 29th, 2007
Today I tried to add a Preference Page to an RCP application that I’m working on with no luck. After executing the Extension -> Add -> Extension Wizards -> Preference Page I end up with 3 new classes. But 2 of then have compilation errors, they refer to an unexisting PreferenceClass. After googling a bit I found this message in a mailing list describing the same exact problem:
Hello,
I ‘ve added preference page in my application using plugin.xml extensions
template.
Then, in a new package, Eclipse created 3 classes (Template preferences page
extending
FieldEditorPreferencePage, a preference constants class and a preference
initializer class).
The template preferences page uses a PreferenceClass which doesn’t already
exists…
I suppose this class has to initialize the preference store, in the
preference template class
constructor, unsing the plugin instance of the product :
“setPreferenceStore(PreferenceClass.getDefault().getPreferenceStore());”
I’ve tried to extend the AbstractUIPlugin (I’ve read in differents articles
from eclipse.org) to catch the
plugin instance when it is created, but without succes (when to catch this
single instance during startup of eclispe
core runtime ?). Then I’ve found the existance of the WorkBenchPlugin class
which holds this static instance,
I used it, discarding PreferenceClass , but Eclispe tells me that the use of
this class is discouraged.
Why ? How is it possible to store the plugin instance at startup ?
Thanks a lot for your help,
frank
Then I found the solution, if you haven’t defined an Activator for the plugin yet it will not work. After creating an Activator for the plugin and rerunning the wizard all went fine.
Tags: activator, eclipse, fix, page, preference, preferenceclass, rcp, template, troubleshoot, wizard
Posted in eclipse, java | No Comments »
Monday, April 23rd, 2007
If you add a new view to an Eclipse RCP and when launch it the new view is not there you probably hit the problem described in this
CT Arrington’s Weblog post.
The IWorkbenchConfigurer.setSaveAndRestore(true) called from your WorkbenchAdvisor can be the source of the problem. The Eclipse RCP platform is trying to restore the perspective from the serialized version stored on disk so it fails to load you new changes. You have several solutions [from the CT Arrington's Weblog post].
- Delete the target platform workspace data. tipically
...runtime-EclipseApplication\.metadata\.plugins\org.eclipse.ui.workbench\workbench.xml
- Set the Clear workspace data before launching in the run configuration. Run -> Run… -> Eclipse Application -> Main -> Workspace Data -> Clear workspace data before launching
Tags: eclipse, problems, rcp, setSaveAndRestore, troubleshoot, view, workspace.xml
Posted in eclipse, java | No Comments »
Friday, April 13th, 2007
Or
java.lang.NoClassDefFoundError: javax/servlet/ServletContextListener
for that matter.
NoClassDefFoundError on HttpSessionListener , ServletListener , ServletContextListener, etc. can be caused by a custom classloader like Sysdeo DevLoader (I use it with Eclipse) in you Context definition in the Tomcat’s server.xml file.
the solution: add
useSystemClassLoaderAsParent="false"
to the Loader
This should do the trick more information here and here
Tags: classloader, devloader, eclipse, HttpSessionListener, loader, NoClassDefFoundError, ServletContextListener, sysdeo, tomcat
Posted in eclipse, java | 2 Comments »
Monday, September 25th, 2006
I’ve been playing with GroovyMonkey that is more or less a patch to EclipseMonkey that allows to run other languages besides Javascript.
With this Eclipse plugin you can run javacript, groovy, etc. scripts that interacts with the Eclipse API. To get an impression of what you can do with GroovyMonkey take a look to these posts (1, 2, 3, 4 ). Following those post you can make a script to download all eclipse icons from the eclipse repository .My first GroovyMonkey scripts generates a webpage with all eclipse icons (previosly downloaded with the example scripts) to easily spot the icons.
/*
* Menu: Get Eclipse Icons > Make web page
* Script-Path: /EclipseIcons/monkey/make_web_page.gm
* Kudos: ecerulm
* License: EPL 1.0
*/
def findFilesinFolder(folder) {
def toReturn = new ArrayList();
folder.members().each {
if (it instanceof org.eclipse.core.resources.IFolder) {
toReturn.addAll(findFilesinFolder(it));
} else {
toReturn.add(it);
}
}
return toReturn;
}
def targetProject = workspace.getRoot().getProject( 'EclipseIcons' )
def iconsFolder = targetProject.getFolder("icons");
def buf = new StringBuffer();
buf.append "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\" \"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n";
buf.append "<html><head><title>Eclipse Icons</title></head><body>";
def members = iconsFolder.members();
members.each { plugin ->
if (plugin instanceof org.eclipse.core.resources.IFolder) {
def name = plugin.getName();
// buf.append "\n<h1>"+name+"</h1>\n";
// buf.append "<p>";
findFilesinFolder(plugin).each {arg ->
def location = arg.getLocation().toString();
def l = iconsFolder.getLocation().toString().length()+1;
location = location.substring(l);
buf.append "<a href=\""+location+"\" title=\""+location+"\"> <img src=\""+location+"\" alt=\"location\"/></a>\n";
}
// buf.append "</p>\n";
}
}
buf.append "</body></html>";
contents = buf.toString();
def indexHtml = iconsFolder.getFile("index.html");
if (indexHtml.exists()) {
indexHtml.delete(false, true, null);
}
fileStream = new ByteArrayInputStream(contents.getBytes("UTF-8"));
indexHtml.create(fileStream, false, null);
If you have trouble seeing the script code try this link
Tags: eclipse, eclipsemonkey, groovy, groovymonkey, icons
Posted in eclipse, java | No Comments »