Posts Tagged ‘Eclipse’

Eclipse Community Awards voting open. Please vote

Thursday, February 2nd, 2012

Just a small reminder, the Eclipse Community Awards is currently open for voting. Please vote: http://eclipse.org/org/press-release/20120130_awardsvote.php

I’m also nominated, as Eclipse Top Newcomer Evangelist :)

Eclipse 4 Application Tutorial available (for Eclipse 4.2 M5)

Monday, January 30th, 2012

A while ago I published an Eclipse e4 tutorial. Things have been moving quite a bit in Eclipse 4 since then.

I’m pretty excited about the capabilities of Eclipse 4, therefore I re-wrote my tutorial to show the capabilities of Eclipse 4.

This tutorial focuses on the application model and the dependency injection capabilities.

Eclipse 4 Tutorial.

More Eclipse 4 tutorials are available on http://www.vogella.de/eclipse.html in the category Eclipse 4 Development but I have not yet spend sufficient time to polish their content.

I hope you like it. It was a significant amount of work I invested into the description. Please let me know if you find errors.

I also would like to thank Brian de Alwis, Tom Schindl, Remy Suen, Paul Webster, John Arthorne and Eric Moffatt for answering my questions.

Eclipse IDE 3.7 Book available for the Kindle

Tuesday, December 20th, 2011

Today I released my new Eclipse IDE 3.7 book for the Kindle device.


Eclipse IDE 3.7
Fundamentals of Java Programming, Debugging, JUnit Testing and Mylyn Tasks with Eclipse

This book demonstrates how you can develop Java applications, how you can debug them and how to write JUnit tests for your applications. It also explains how you can work with local Mylyn tasks to organize your work efficiently.

It also includes important Eclipse configuration tips which make programming with Eclipse more effective.

After finishing this book you should feel comfortable with using the Eclipse IDE for standard Java development tasks and you should be equipped to explore Eclipse further.

You find the book in all Amazon stores:

Eclipse IDE 3.7 in Amazon USA
Eclipse IDE 3.7in Amazon Germany
Eclipse IDE 3.7 in Amazon UK
Eclipse IDE 3.7 in Amazon France
Eclipse IDE 3.7 in Amazon IT
Eclipse IDE 3.7 in Amazon ES

This book summerizes several tutorials I publish on my website. It includes the Eclipse IDE introduction tutorial, the JUnit tutorial, Debugging with Eclipse, my Mylyn Tutorial and my favorite Eclipse shortcuts. The full content of the book is still available online on my website.

I would especially thank Elias Volanakis for his thorough spell checking and feedback on the content.

I also am very grateful to Wayne Beaton for writing the foreword and providing feedback on the content.

In addition I would like to thank the Eclipse Foundation and Ian Skerrett for the permission to use the Eclipse logo and Matthew Nuzum for the permission to use his svg version of the Eclipse logo.

I got many suggestions or corrections from countless readers of my website and I would like to express my deepest gratitude for their contributions.

I have plans to add an EGit chapter over the next months. If you buy this book now you will get the update with EGit for free. I have confirmed twice with the Amazon customer support that if I publish an update to this book that buyers of the book will get notified and that they can download the updated book with EGit for free.

I’m again surprised how much work it is to convert my website content into a book format. I hope you like this book and if you new to Eclipse I hope you enjoy your learning experience.

Eclipse SWT – Creating an email in the default email client

Tuesday, August 30th, 2011

As many of you properly know SWT has the nice Program.launch() method which allows to start programs associated with an URI.

Example:

// This works for Windows
	public void openMailWindows(String to, String subject,String body, List<File> attachments) {
		String mailto = "mailto:" + enc(to) + "?subject=" + enc(subject) + "&body=" + enc(body);
		for (File f : attachments) {
			mailto += "&attach=" + f.getAbsolutePath();
		}
		Program.launch(mailto);
	}

	private String enc(String p) {
		if (p == null)
			p = "";
		try {
			return URLEncoder.encode(p, "UTF-8").replace("+", "%20");
		} catch (UnsupportedEncodingException e) {
			throw new RuntimeException();
		}
	}

Unfortunately this does not seem to be working on Linux. So if you are working under Linux you have to use the Java runtime directly. Unfortunately this requires you in my humble opinion to code against a a specific application.

// This works for Linux with Thunderbird
	public void openMailLinux(String to, String subject,String body, List<File> attachments) {
		String mailto = "mailto:" + enc(to) + "?subject=" + enc(subject) + "&body=" + enc(body);
		for (File f : attachments) {
			mailto += "&attach=" + f.getAbsolutePath();
		}
		Program.launch(mailto);
		try {
			// For using the parameters check the following description
			// http://kb.mozillazine.org/Command_line_arguments_%28Thunderbird%29
			Runtime.getRuntime().exec("thunderbird -compose");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

I hope this helps.

You find me also on Twitter and Google+.

Eclipse e4 Renderer – Google Maps

Tuesday, November 9th, 2010

As you might know Eclipse e4 decouples the application model from the rendering engines. For example you have a MPart model element which describes that the application should display a certain UI element (view) in your application. How this model element is drawn is determined by the renderer.

Another very nice thing about the renderer framework and the model is that the e4 application model can get extended and that you can define your own renderer for your own model element.

For example you can define a model element “GoogleMap” which will be renderered via your own renderer as a Google Map (using the SWT Browser widget).

Please find a complete description how to set this up in my Eclipse e4 renderer tutorial. You can also follow me on Twitter here if you want.

Joining Eclipse IRC

Friday, April 2nd, 2010

I recently became aware that the Eclipse developer community also uses IRC for their communication.

See http://wiki.eclipse.org/IRC for details.

A nice firefox IRC plugin is chatzilla. In case you cannot use a IRC client directly you can use this webclient: http://webchat.freenode.net/.

Join for example #eclipse, #eclipse-dev or #eclipse-e4 to discuss Eclipse development issues.

Eclipse RCP – Removing the minimize and maximize buttons from Views

Friday, November 13th, 2009

I got the question how someone could remove the maximize and minimize buttons from a view in an Eclipse RCP application.

To archive this I know two ways.

Either set the layout to fixed in initialLayout() in Perspective.java


package de.vogella.intro.rcp.fixedview;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();
		layout.setEditorAreaVisible(false);
		layout.setFixed(true);

//		layout.addStandaloneView(View.ID,  false, IPageLayout.LEFT, 1.0f, editorArea);
	}

}

Or use the Perspective.java to add a standalone view.


package de.vogella.intro.rcp.fixedview;

import org.eclipse.ui.IPageLayout;
import org.eclipse.ui.IPerspectiveFactory;

public class Perspective implements IPerspectiveFactory {

	public void createInitialLayout(IPageLayout layout) {
		String editorArea = layout.getEditorArea();
		layout.setEditorAreaVisible(false);
//		layout.setFixed(true);

		layout.addStandaloneView(View.ID,  false, IPageLayout.LEFT, 1.0f, editorArea);
	}

}

If I add a standalone view via the extension “org.eclipse.ui.perspectiveExtensions” then the minimize and maximize buttons are still there.

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>

   <extension
         id="application"
         point="org.eclipse.core.runtime.applications">
      <application>
         <run
               class="de.vogella.intro.rcp.fixedview.Application">
         </run>
      </application>
   </extension>
   <extension
         point="org.eclipse.ui.perspectives">
      <perspective
            name="Perspective"
            class="de.vogella.intro.rcp.fixedview.Perspective"
            id="de.vogella.intro.rcp.fixedview.perspective">
      </perspective>
   </extension>
   <extension
         point="org.eclipse.ui.views">
      <view
            name="View"
            class="de.vogella.intro.rcp.fixedview.View"
            id="de.vogella.intro.rcp.fixedview.view">
      </view>
   </extension>
   <extension
         point="org.eclipse.ui.perspectiveExtensions">
      <perspectiveExtension
            targetID="*">
         <view
               id="de.vogella.intro.rcp.fixedview.view"
               minimized="false"
               ratio="1.0f"
               relationship="left"
               relative="org.eclipse.ui.editorss"
               standalone="true"
               visible="true">
         </view>
      </perspectiveExtension>
   </extension>

</plugin>

The behavior seems inconsistent. If I use coding to add a standalone view the minimize / maximize buttons are not there, if I use extension points they are still there.

Does anymore know if I’m missing something? Or is this a bug? If you know please comment on this blog post or contact me via twitter.

Update: Projekt attached.

FixedView.zip

JavaScript in the SWT Browser widget

Thursday, October 29th, 2009

At the Eclipse Summit Europe I listened to a talk of Boris Bokowski about Eclipse and the Web.

Among other things I learned that you can execute JavaScript directly on the SWT Browser Widget and I wanted to give a tiny example for this.

This Eclipse view will for example load my webpage and then execute a tiny JavaScript (alert(“1″);) in the browser.


package de.vogella.swtbrowser;

import org.eclipse.swt.SWT;
import org.eclipse.swt.browser.Browser;
import org.eclipse.swt.browser.ProgressEvent;
import org.eclipse.swt.browser.ProgressListener;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.ui.part.ViewPart;

public class View extends ViewPart {

	public static final String ID = "de.vogella.swtbrowser.view";

	public void createPartControl(Composite parent) {
		final Browser b = new Browser(parent, SWT.NONE);
		b.setUrl("www.vogella.de");
		b.addProgressListener(new ProgressListener() {
			@Override
			public void completed(ProgressEvent event) {
				System.out.println("Page loaded");
				System.out.println(b.execute("alert(\"1\");"));
			}
			@Override
			public void changed(ProgressEvent event) {
			}
		});
	}

	/**
	 * Passing the focus request to the viewer's control.
	 */
	public void setFocus() {
	}
}

Thanks to Boris for the great talk.

API for reading Eclipse plugin dependencies

Monday, October 19th, 2009

The Eclipse platform provides an API to allows that you can access in information of the MANIFEST.MF. For example you could read the dependencies of your plugin.

For this example create a plugin “de.vogella.pde.dependencies”. See Eclipse Plugin development for examples on how to develop plugins. Use the “Hello, World Command” template.

Define dependendies to the following plugins:
– org.eclipse.ui
– org.eclipse.core.runtime

Change the command to the following.


package de.vogella.pde.dependencies.handlers;

import org.eclipse.core.commands.AbstractHandler;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.osgi.util.ManifestElement;
import org.osgi.framework.BundleException;
import org.osgi.framework.Constants;

public class PrintDependencies extends AbstractHandler {
	public Object execute(ExecutionEvent event) throws ExecutionException {
		String requireBundle = (String)Platform.getBundle("de.vogella.pde.dependencies").getHeaders().get(
				Constants.REQUIRE_BUNDLE);
				try {
					ManifestElement[] elements = ManifestElement.parseHeader(
					Constants.BUNDLE_CLASSPATH, requireBundle);
					for (ManifestElement manifestElement : elements) {
						System.out.println( manifestElement.getValue());
					}
				} catch (BundleException e) {
					e.printStackTrace();
				}
		return null;
	}
}

If you now run your new plugin it and select your command it will print out the dependencies of your plugin.

Eclipse Papercut #5 – Getting external libraries as bundles

Monday, September 21st, 2009

In this episode of Eclipse Papercuts I explain how you get bundles for popolar Java libraries for your Eclipse plugin development.

I believe it has advantages to work with plugin projects instead of pure Java projects even if the plan is not to create Eclipse plugins / RCP applications.

The core strength of OSGi for this scenario is in my opinion the encapsalation and protection of your inner classes. With OSGi bundles you decide which packages of your project are exported and therefore visible to other projects (via the tab Runtime in the editor for the file plugin.xml).

This leaves only one problem: If you are using externally libraries you have to convert them into bundles / plugins.

I would be nicer to consume pre-packages bundles. As I created a bug iText should be OSGi and tweeted about it Chris Aniszczyk pointed me to Eclipse Orbit.

Eclipse Orbit provides lots of standard libraries already pre-packaged as bundles / plugins.

Lets see how you could get the iText version from Orbit. Check the Orbit FAQ to find out more.

You need to connect via cvs to the Eclipse cvs repository. CVS URL is :pserver:anonymous@dev.eclipse.org/cvsroot/tools

Navigate to “org.eclipse.orbit”. Select “com.lowagie.text” and check it out.

orbit10

Orbit keeps the different version of the library as cvs branches. Select your project and select Replace With -> Another Branch or Version…
orbit20

orbit30

After selecting the branch and pressing ok the system will download the library and you can start using the library.

In addition to Orbit you can also use the Springsource bundle repository. On this website you can search for bundles and download then directly. You can then import them as plugin projects into your workspace.


Switch to our mobile site