Posts

Showing posts with the label Eclipse

How to automate the installation of Eclipse plugins with ant task

In this blog post I suggest a simple way to automate the installation of Eclipse plugins with ant task and maven-antrun-plugin. ${project.basedir}/target/eclipse = eclipse dir (extract using maven dependency plugin) ${project.basedir}/target/p2-repo = p2 dir of plugins  (extract using maven dependency plugin) sample1.feature.group, sample2.feature.group,.... = sample feature group names a snippet of my code follows. <plugin>  <artifactid>maven-antrun-plugin</artifactid>          <executions>      <execution>      <id>install-eclipse</id>      <phase>package</phase>      <goals>       <goal>run</goal>      </goals>      <configuration>      <tasks>       <java classname="org.eclipse.equino...

How to change the mouse icon/feedback when we drag a node to the canvas from the tool palette in a GEF/GMF based editor

In this blog post I suggest a simple way to change the drag icon/feedback to indicate to the user that it is to drop or illegal to drop what they are dragging at the current location in a GEF or GMF based editor. You can do it simply by implementing custom DragDropEditPolicy and installing to your EditPart. a snippet of my code follows. import java.awt.MouseInfo; import java.awt.Point; import org.eclipse.draw2d.FigureCanvas; import org.eclipse.draw2d.IFigure; import org.eclipse.draw2d.ImageFigure; import org.eclipse.draw2d.geometry.Rectangle; import org.eclipse.gef.Request; import org.eclipse.gef.commands.Command; import org.eclipse.gef.requests.ChangeBoundsRequest; import org.eclipse.gmf.runtime.diagram.ui.editparts.ShapeCompartmentEditPart; import org.eclipse.gmf.runtime.diagram.ui.editpolicies.DragDropEditPolicy; import org.eclipse.gmf.runtime.diagram.ui.requests.CreateUnspecifiedTypeRequest; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.widgets.Control; import...

How to register an eclipse editor by file content

Sometimes you may want to register an eclipse editor by reading file content. As an example if we need to open Maven POM file with specificity packing type with your editor or if you need to use different files without file extension, so we have to write a custom ContentDescriber to handle it.  We can write custom ContentDescriber by extending or implementing following classes/ interfaces. ITextContentDescriber XMLContentDescriber IContentDescriber BinarySignatureDescriber   So let's write a custom ContentDescriber by extending XMLContentDescriber package org.my.editor.describer; import java.io.IOException; import java.io.InputStream; import org.eclipse.core.runtime.content.IContentDescription; import org.eclipse.core.runtime.content.XMLContentDescriber; public class MyDescriber extends XMLContentDescriber { public int describe(InputStream input, IContentDescription description) throws IOException { /** Implement logics to validate content by reading input ...