Kategorie: Programmieren

Set workspace location for RCP application

In my Eclipse / RCP application the .metadata directory was always created in the working directory. This worked fine when I was opening the application normally. However, I needed file associations, so the user can just double click on file somewhere on his computer and open the file. If you do this, the working directory …

weiterlesen »

Eclipse / RCP: Remove Quick Access from toolbar

After updating my RCP application from Eclipse 3.7 to Eclipse 4.x the toolbar always showed the quick access toolbar:   How to get rid of that? The workaround is to hide the item with some CSS code. First create a CSS file in your plugins root folder, for example "default.css": #SearchField { visibility: hidden; } …

weiterlesen »

Android Studio: Nach Update lässt sich das Projekt nicht starten

Heute wurde mir ein Update für Android Studio angezeigt. Also Update heruntergeladen und installiert. Wie immer erwartet man da natürlich Probleme mit bestehenden Projekten. 🙂 War natürlich der Fall:  Gradle: <br></br>FAILURE: Could not determine which tasks to execute.<br></br>* What went wrong:<br></br>Task ‚assemble‘ not found in root project ‚SomeProject‘.<br></br>* Try:<br></br>Run gradle tasks to get a list …

weiterlesen »

Java: Convert String to InputStream

Some methods want an InputStream, converting a String into an InputStream is very easy: /** * Converts a string into an inputstream * @param s * @return */ private InputStream convertStringToInputStream(String s) { ByteArrayInputStream in = new ByteArrayInputStream(s.getBytes()); return in; }

weiterlesen »

RCP: Problems when generating PDF files with RCP

Recently I ran into a problem in my RCP application during the generation of a PDF file from a BIRT report. This only happened when trying to run the export from the exported product: The first problem was an "Error.OutputFormatNotSupported". This was a little bit strange, since I would have expected some syntax errors in …

weiterlesen »

Easy logging for RCP applications

A small class for easy logging in RCP applications by using the Activators logging functions. This class mainly wraps the need of creating an IStatus object each time we want to log something. import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; public class LoggerUtil { public static void info(String message){ IStatus status = new Status(IStatus.INFO,Activator.PLUGIN_ID, message); Activator.getDefault().getLog().log(status); } public …

weiterlesen »

RCP: Switch to perspective via code

A small snippet which switches to a certain perspective via code: IPerspectiveDescriptor[] perspectives = PlatformUI.getWorkbench().getPerspectiveRegistry().getPerspectives(); IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); if(page != null) { for (IPerspectiveDescriptor des : perspectives) { if (des.getId().equals("my.perspective.id")) { page.setPerspective(des); break; } } } return null;

weiterlesen »

RCP: Remove unwanted preference pages

In my RCP application some unwanted sections in the preferences showed up: How to get rid of them? Thats easy, in the "ApplicationWorkbenchAdvisor" class, override the "postStartup" method: @Override public void postStartup(){ PreferenceManager pm = PlatformUI.getWorkbench().getPreferenceManager(); pm.remove("org.eclipse.help.ui.browsersPreferencePage"); //$NON-NLS-1$ pm.remove("org.eclipse.help.ui.contentPreferencePage"); //$NON-NLS-1$ } What if you don’t know the id of the preference page? No problem, you …

weiterlesen »