Archive for the ‘Eclipse’ Category

Export Eclipse Plugin, Assert Errors

Wednesday, July 23rd, 2008

Here is my scenario:
I import Eclipse RSE( Remote System Explorer) plug-ins into my workspace and I want to build and test it myself. There are no errors in the workspace and running and debugging is all OK. And I want to export these plug-ins out: Export->Plug-in Development->Deployable plug-ins and fragements -> … An error dialog tells me that “Error occurred during the operation. A zip file containing the build logs has been generated and placed at …”. And exact that *.zip file and there is a @dot.bin.log, saying something like:
4. WARNING in D:\eclipse\workspace\org.eclipse.rse.core \src\org\eclipse\rse\core\ SystemTypeMatcher.java (at line 31)
assert pattern != null;
^^^^^^
'assert' should not be used as an identifier, since it is a reserved keyword from source level 1.4 on
----------
5. ERROR in D:\eclipse\workspace\org.eclipse.rse.core \src\org\eclipse\rse\core\ SystemTypeMatcher.java (at line 31)
assert pattern != null;
^^
Syntax error on token "!=", = expected

I know this error. But I already set the Compiler Compliance Level to 1.5 already, and in the workspace there is no errors complaining about this.

Googling all over the net and there is no clear solution to solve this problem. Someone says that modifying ANT script build.xml by adding source=”1.4″ will solve this problem. But the problem is that using Export->… the build.xml will always be regenerated.

After reading the source of plug-in org.eclipse.pde.build, I found that there is an option for the script generator to specify javacSource in build.xml. You can just add two lines in build.properties file like the following:
javacSource = 1.4
javacTarget = 1.4

And exporting plug-ins won’t have errors any more.

It feels great to have sources in hand when solving problems. :D

Eclipse Freezing on Start

Wednesday, November 7th, 2007

After an incorrect shutdown, Eclipse can not start, freezing on splash window.

I opened file
workspace\.metadata\.log
there was a line saying:

The workspace exited with unsaved changes in the previous session; refreshing workspace to recover changes

After taking many tries, I found a solution for this bug. Just remove folder
workspace\.metadata\.plugins\org.eclipse.core.resources\.root\.indexes
and restart Eclipse. Everything will be fine again.

Subversive Sucks

Monday, June 11th, 2007

There are many bugs in Subversive besides the known bug “Can not compare with old deleted repository resources“.

And yesterday, one of my colleague used Subversive’s “Check out as” to a different location resulted in deleting all her one-week modifications. I think it was a bug that Subversive did not warn her that it was going to delete modified sources in “Check out as” mode!

In my experience, I found Subclipse is a much better plugin. So Subversive sucks.

Get Projects List in Eclipse Workbench

Friday, June 8th, 2007

http://dev.eclipse.org/newslists/news.eclipse.newcomer/msg13300.html

Add
org.eclipse.core.resources
in the Require-Bundle section in your plugin MANIFEST.MF file
and invoke code:

ResourcesPlugin.getWorkspace().getRoot().getProjects()

Clean Eclipse Plugins’ Build Path Errors

Thursday, June 7th, 2007

Sometimes, Eclipse may have errors in calculating build paths, which may result in that some projects are marked as red cross error icons and further building is interrupted. The common error message for this would be “Project … is missing required project …”.

Try to check out and make sure that there are no errors. But try to clean and rebuilt the project do not clean out that error mark? Please try to close the project, and then re-open it, clean and rebuilt the project. It may help.

Enablement Expression and Property Tester

Thursday, June 7th, 2007

Source: http://www.eclipse.org/webtools/wst/components/server/runOnServer.html

Enablement Expression Performance

Enablement expressions allow you to create arbitrarily complex expressions using ands, ors, nots, and Java code. For performance reasons, it’s always better to use the expression support instead of using Java code, which is slower or may be in plugins that aren’t loaded yet. However, simple Java tests can provide much better flexibility and do not need to cause large delays.

The best practice is to use enablement expressions as much as possible to filter down the number and types of objects that are applicable. As a final check, a property tester can then be used. However, it is still important to use expressions first, even if you know you’ll be using a property tester for the last check - this will keep the performance up for all the objects that are filtered out.

Adding a Property Tester

To add a property tester to an enablement expression, try using the following example. In your plugin.xml, add the propertyTesters extension point:

<extension point="org.eclipse.core.expressions.propertyTesters">
<propertyTester
id="org.eclipse.myplugin.propertyTester"
namespace="org.eclipse.myplugin"
properties="someProperty"
type="java.lang.Object"
class="org.eclipse.myplugin.internal.MyPropertyTester">
</propertyTester>
</extension>

Inside your plugin, add and implement the property tester code:

package org.eclipse.myplugin.internal;
import org.eclipse.core.expressions.PropertyTester;

public class MyPropertyTester extends PropertyTester {
public boolean test(Object receiver, String property, Object[] args, Object expectedValue) {
// cast receiver and/or expectedValue
// if (xx) // check some dynamic property
return true;
// else
//return false;
}
}

You can now use a property expression within the enablement:

&lttest property="org.eclipse.myplugin.someProperty" value="true"/>

RSE Sucks

Wednesday, May 30th, 2007

I do think that Remote System Explorer (RSE)? sucks for its plugin management. Too many small size (about 10k - 20k) plugins, about 42 plugins (about 30 core plugins), while all Eclipse SDK plugins number is 141.

Snippet: Open Editor a Local File in Eclipse

Thursday, May 24th, 2007

Here is codes to open editor a local file in Eclipse:

IFileStore fileStore = EFS.getLocalFileSystem()
.getStore(new Path(file.getParent()));
fileStore= fileStore.getChild(file.getName());
if (!fileStore.fetchInfo().isDirectory()
&& fileStore.fetchInfo().exists()) {
IWorkbenchWindow fWindow = Java2ScriptUIPlugin.getDefault()
.getWorkbench().getActiveWorkbenchWindow();
IWorkbenchPage page = fWindow.getActivePage();
try {
IDE.openEditorOnFileStore(page, fileStore);
} catch (PartInitException e) {
String msg = NLS.bind(IDEWorkbenchMessages
.OpenLocalFileAction_message_errorOnOpen,
fileStore.getName());
IDEWorkbenchPlugin.log(msg,e.getStatus());
MessageDialog.openError(fWindow.getShell(),
IDEWorkbenchMessages.OpenLocalFileAction_title, msg);
}
}

For more, please read org.eclipse.ui.internal.ide.actions.OpenLocalFileAction in org.eclipse.ui.ide_….jar