Eclipse – Bar54 http://www.bar54.de Software Engineering, Web Technologies, eCommerce and some more Fri, 27 Oct 2017 08:03:41 +0000 en-US hourly 1 https://wordpress.org/?v=5.9.4 Eclipse font size change made easy http://www.bar54.de/2015/02/eclipse-font-size-change-made-easy/ Sat, 28 Feb 2015 14:14:19 +0000 http://www.bar54.de/?p=773 Have you ever asked yourself why it is so complicated to change the font size of your eclipse working environment? Easpecially when you are working with a notebook and switching between the build in display and different external displays it make sense to adapt your font size to the different screen resolutions.

Note: Since Eclipse Neon (4.6) this is a build in feature. By default, you can use Ctrl+”+” or Ctrl + “-” to increase or decrease the font size of your active text editor or view.
Today, I found a simple plugin making life easier and saving time during your everday work. Just checkout the plugin Eclipse Font available on google code: https://code.google.com/p/eclipse-fonts/

Just install the plugin from the according update site: http://eclipse-fonts.googlecode.com/svn/trunk/FontsUpdate/
and use Ctrl+- or Ctrl++ to decrease or increase your font size.

Note: If you manually changed your editors’ font size before, you might need to reset this to make the plugin effect your settings.

Enjoy adapting your font size to your current screen resolution!

eclipse-font

]]>
Bold Font in Eclipse JFace Viewer http://www.bar54.de/2014/06/bold-font-eclipse-jface-viewer/ Sun, 15 Jun 2014 09:53:16 +0000 http://www.bar54.de/?p=723 Working with fonts in Eclipse ui plugins is sometimes a bit indirectly.
For example, if you want to set an element’s font to bold, you can not simply set item.setBold() or item.getFont().setBold().

The best way to get around this, is to :

  1. get a default font from any element
  2. create a font descriptor from it,
  3. set the style of the font descriptor to bold,
  4. get a new font instance from this descriptor, and
  5. set this font to your element of choice.

Doing this, you can cache the font instance to reuse it later one.

The method getFont() allows to get a styled font based on the font of an swt control element:

    private Font getFont(Control control, int style) {
        Display display = Display.getCurrent();
        FontDescriptor fontDescriptor = FontDescriptor.createFrom(control.getFont());
        return fontDescriptor.setStyle(style).createFont(display);
    }

For example, this can be used to get a bold font to be set for tree items based on the font of the enclosing tree:

Control control = treeViewer.getTree();
Font fontBold = getFont(control, SWT.BOLD);
...
treeItem.setFont(fontBold);

This more a reminder for myself, but perhaps, someone will find this usefull as well…

]]>
Eclipse JFace ViewerFilter http://www.bar54.de/2014/04/eclipse-jface-viewerfilter/ Sun, 20 Apr 2014 22:37:14 +0000 http://www.bar54.de/?p=698 Eclipse JFace infrastructure provides a powerful infrastructure called ViewerFilter, to allow the user to filter content presented in a viewer.
Especially TreeViewers as extensively used by common navigator framework (CNF) based viewers such as the Project Explorer or Package Explorer make use of them.Eclipse Viewer Filter Configuration

Providing as Extension or Programmatically

To provide such a filter one can either programmatically add it to a filter enabled viewer such as to FilteredTreeViewers

PatternFilter filter = new PatternFilter();
FilteredTree tree = new FilteredTree(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL, filter, true);

To use an Eclipse extension point declare it this way:

<?xml version="1.0" encoding="UTF-8"?>
<?eclipse version="3.4"?>
<plugin>
  <extension
      point="org.eclipse.ui.navigator.navigatorContent">
    <commonFilter
      class="org.splevo.jamopp.ui.vpexplorer.filter.ImportOnlyVPFilter"
      description="Show only VariationPoints which are about variying imports"
      id="org.splevo.jamopp.ui.vpexplorer.filter.Imports"
      name="VariationPoints: Imports Only">
    </commonFilter>
  ...
  </extension>
  <extension
      point="org.eclipse.ui.navigator.viewer">
    <viewerContentBinding
        viewerId="org.splevo.ui.vpexplorer">
      <includes>
        <contentExtension
          pattern="org.splevo.jamopp.ui.vpexplorer.filter.*">
        </contentExtension>
      </includes>
    </viewerContentBinding>
  </extension>
</plugin>

Filtering Empty Parent Folders

If you have implemented a filter for specific elements explicitly and to filter parent elements if they do not include any sub element.


public abstract class MyFilter extends ViewerFilter {

@Override
public boolean select(Viewer viewer, Object parentElement, Object element) {

if (isChildElement(element)) {
return handleChild(element);

} else {
// manipulate tree viewer based on select
// decision for the sub elements
StructuredViewer sviewer = (StructuredViewer) viewer;
ITreeContentProvider provider = (ITreeContentProvider) sviewer.getContentProvider();
for (Object child : provider.getChildren(element)) {
if (select(viewer, element, child)) {
return true;
}
}
return false;
}
}
]]>
Eclipse Icon Resources http://www.bar54.de/2014/04/eclipse-icon-resources/ Sun, 06 Apr 2014 10:16:14 +0000 http://www.bar54.de/?p=682 Online Resources for Eclipse standard and compatible Icons

In addition to using Eclipse build in image/icon access API (see my previous Post ), there are reasonable websites to access Eclipse icons or free ones that are compatible with them.

 

Icons in EMF Edit Plugin

To customize the image returned for an EMF model element you need to either replace the default icons generated in icons/full/obj16/ or to adapt the getImage() method in the appropriate ItemProvider.
For the latter, you can modify the following statement. Note, that the path to the icon is relative to the icons/ directory and without any file extension at the end.

return overlayImage(object, getResourceLocator().getImage("full/obj16/JaMoPPSoftwareElement"));
]]>
Accessing Eclipse Standard Icon Images http://www.bar54.de/2014/03/accessing-eclipse-standard-icon-images/ Thu, 27 Mar 2014 10:53:31 +0000 http://www.bar54.de/?p=677 When developing Eclipse plugins that should contribute to the UI, it is reasonable to align with the Eclipse UI design.

For example, within tree representations or in other UI elements, you might want to include the standard icons used in Eclipse.
To do this, Eclipse provides infrastructure that makes it an absolute no-brainer.

Standard Eclipse Icons

To access the standard Eclipse Icons, add a dependency on org.eclipse.ui to your plugin and use this code to access an icon as Image:

import org.eclipse.ui.ISharedImages;
import org.eclipse.ui.PlatformUI;
import org.eclipse.swt.graphics.Image;
...
Image image = PlatformUI.getWorkbench().getSharedImages().getImage(ISharedImages.IMG_OBJ_FOLDER);

Note that the interface ISharedImages provides constants for all standard icons you can access.

JDT Eclipse Icons

The JDT provides a similar infrastructure hat could be accessed in an even more compact form:

import org.eclipse.jdt.ui.JavaUI;
import org.eclipse.jdt.ui.ISharedImages;
import org.eclipse.swt.graphics.Image;
...
ISharedImages images = JavaUI.getSharedImages();
Image image = images.getImage(ISharedImages.IMG_WHATEVER);

Again the JDT specific ISharedImages interface provides constants for the standard icons.
Using the same name for the interface makes it intuitive to find and use, but you need to use full qualified names if you want to use the standard and the JDT icons within the same compilation unit.

]]>
Eclipse CBI Build Problems with Maven 3 http://www.bar54.de/2013/12/eclipse-cbi-uild-problems-with-maven-3/ http://www.bar54.de/2013/12/eclipse-cbi-uild-problems-with-maven-3/#respond Sun, 29 Dec 2013 07:51:35 +0000 http://www.bar54.de/blog/?p=540 Since september 2013 a couple of eclipse project builds fail with a maven infrastructure exception such as
Error injecting: org.hudsonci.maven.eventspy_30.DelegatingEventSpy

Eclipse Common Build Infrsatructure (CBI) Hudson Server: https://hudson.eclipse.org/hudson/

The reason for this, was a general infrastructure change on the environment. The default settings for jobs were switched to JDK 7 and Maven 3.1.0 which are not working fine with Tycho 0.19.0 / 0.18.0. In the threads referenced at the end of this post, some people talk about required changes in Hudson to support the new maven release. However, the CBI still stucks with an old version of the Hudson CI server (hopefully they will update soon).

To fix this issue for the EMF Feature Model project, we changed our Hudson build job’s configuration to explictly to use a JDK 6

JDK 6  Configuration
JDK 6 Configuration

and Maven 3.0.5
Maven 3.0.5
Maven 3.0.5

Links for further information:

David Williams described a similar issue on the CBI Dev mailing list:
http://comments.gmane.org/gmane.comp.ide.eclipse.cbi.devel/981

Some further notice can be found in the eclipse hudson forum
http://www.eclipse.org/forums/index.php/t/521849/

]]>
http://www.bar54.de/2013/12/eclipse-cbi-uild-problems-with-maven-3/feed/ 0
CSS/JS Compression in Eclipse with the Spket IDE http://www.bar54.de/2013/10/cssjs-compression-in-eclipse-with-the-spket-ide/ http://www.bar54.de/2013/10/cssjs-compression-in-eclipse-with-the-spket-ide/#respond Thu, 03 Oct 2013 14:18:00 +0000 http://www.bar54.de/blog/?p=497 When developing websites or hybrid mobile apps, it a good practice to compress your JavaScript and CSS stylesheets to reduce the download and loading effort / time. The Yahoo User Interface project YUI provides the YUI compressor, a good infrastructure to perform such a compression and obfuscation as well (if needed).

If you develop your application/website using Eclipse, there is no support provided by Yahoo or the Eclipse web development platform. But, the Spket provides a good extension to fill this gap.

The Spket project has developed an environment for text editor development called AgPad (“Another General Purpose Text Editor”). Based on this editor, they have build the Spket Studio providing editors for JavaScript, XML,… AND an integration for the YUI compressor infrastructure.

Their website: http://www.spket.com/ does not mention this feature, but it is smoothly integrated and very intuitive to be used.

Just right-click your css file to open the context menu and select YUI Compressor…

A Wizard is opened to browse for the target file. You can make some additional configuration and clicking OK, the minified file will be produced. Notice: You can select multiple source files and compress them into single one as well.

image image

 

For JavaScript files, it works the same way when performing those steps on a JavaScript file.

 

Please note: The Spket studio is free for non-commercial use. To support the project, the commercial use requires a usage fee of 29$ for a single user which is is a fair price.

Unfortunately, there have been no updates nor any other activity for some time. Hopefully, this will change some time again.

]]>
http://www.bar54.de/2013/10/cssjs-compression-in-eclipse-with-the-spket-ide/feed/ 0
Eclipse Subversive Connectors for SVN 1.8 http://www.bar54.de/2013/10/eclipse-subversive-connectors-for-svn-1-8/ http://www.bar54.de/2013/10/eclipse-subversive-connectors-for-svn-1-8/#respond Thu, 03 Oct 2013 06:31:00 +0000 http://www.bar54.de/blog/?p=484 The new SVN Version 1.8 comes with a new svn meta file format. For example, if you are using Tortoise SVN you might be asked to upgrade your svn directory to version 1.8.

In your Eclipse IDE, a wide spread svn support is the default Subversion feature available on the Eclipse Update site. The subversive SVN support has a connector infrastructure to choose from different implementations of the svn protocol.

If you did upgraded your SVN resources to SVN Version 1.8, you might notice your Eclipse SVN support does not like it anymore. Checking the Eclipse update site, even the Kepler one does not provide an SVN 1.8 compatible connector.

The good news: Polarion already provides 1.8 compatible connectors but they did not fit into the Kepler release train timing. To install the new 1.8 compatible connectors, download the latest connectors zip archive from  http://community.polarion.com/projects/subversive/download/eclipse/3.0/builds/ (Version 3.0.3 at the time of writing the article).

Next, open your Eclipse IDE, choose Help > Install new Software …
Choose the connectors local file as update site archive:

svn-connectors-local-update-site

and install the SVN 1.8 supporting connectors. If possible, you should also update your main connector feature.

connector-feature-selection

At the end of the installation you should restart your Eclipse IDE. If the subversion support for your SVN 1.8 projects does not work out of the box, you might need to activate the new connector as the default one. Go to Window > Preferences, switch to the svn preference section and select the 1.8 compatible svn connector:

svn-connector-preferences

You might to restart again and there you go …

]]>
http://www.bar54.de/2013/10/eclipse-subversive-connectors-for-svn-1-8/feed/ 0
Eclipse Static Import Code Completion http://www.bar54.de/2013/08/eclipse-static-import-code-completion/ http://www.bar54.de/2013/08/eclipse-static-import-code-completion/#respond Sun, 18 Aug 2013 19:38:55 +0000 http://www.bar54.de/blog/?p=399 Many popular framework provide facilities requiring static imports in your code.
Other than with regular Types, the Eclipse Java Development Tools (JDT) code completion does not work out-of-the-box for statically imported methods.

For example, when writing JUnit Test Cases, you often need to write assert*() methods, matchers, or even fail() methods which must be statically improted. The same applies for the mock up framework Mockito and a lot others.

To enable code completion for those static imports, the Eclipse JDT tooling provides a configuration within the preferences, called Favorites.
You can find them in the workspace preferences following the path:
Window -> Preferences -> Java -> Editor -> Content Assist -> Favorites

Eclipse Code Assistent Favorites Preferences

Adding the following new types is a good set to start with for JUnit Tests:

  • org.junit.Assert
  • org.hamcrest.CoreMatchers
]]>
http://www.bar54.de/2013/08/eclipse-static-import-code-completion/feed/ 0
Android ADB Device Offline http://www.bar54.de/2013/08/android-adb-device-offline/ http://www.bar54.de/2013/08/android-adb-device-offline/#respond Mon, 12 Aug 2013 19:49:45 +0000 http://www.bar54.de/blog/?p=393 When you are developing for an Android APP with a real hardware device connected, you might face a situation where the device is detected, but looses the connection after a couple of seconds or minutes, but never reproducable.

Your device is still connected as media device (MTP mode) or digital camera (PTP mode) and you are able to transfer data to and from the device.
When your run adb devices on your command line right after connecting the device, you can see it in status “device”. After some time, it is still registered but the status is “offline”.

In your eclipse, when you perform a “Run as -> Android Application”, the device manager shows your device but the target is “unknown”.

On the web, you find many hints like,

  • Install the naked device drivers
  • Install the Nexus Root Toolkit and the raw drivers (If you got a Nexus device)
  • De-Activate and activate USB-Debugging of your device
  • Reboot your device
  • Update your Android SDK
  • ….

However, while all of them might be right, at the I found a small hint in a StackOverflow discussion, that it might be an issue of your USB cable.
And there we go: I had a valid development environment working fine for over a month, without any problems with my different nexus devices as well as older test devices. But then I grapped the cable of a new ASUS device of a collegeue and the day was lost.
It might not be a problem of Asus cables in general, and other vendors might produce weak cables as well. But, the first thing you should do when having connection problems during your android development, is to try a different cable before uninstalling and installing drivers and toolkits for a lot of hours.

]]>
http://www.bar54.de/2013/08/android-adb-device-offline/feed/ 0