Kategorie: Programmieren

RCP: Perspectives and Perspective Contributions

Note: I put the example project in a ZIP file, you can use that to have a look to the actual code, Download. Start In the first step, we create a sample plugin project (Mail project): Make the perspective bar visible This needs to be done in the ApplicationWorkbenchWindowAdvisor.java class, in the preWindowOpen method: IWorkbenchWindowConfigurer …

weiterlesen »

Remove unwanted preference pages from your RCP app

In my recent RCP app some unwanted preferences, contributed from other plugins showed up: To remove them, just add the following code to your WorkbenchAdvisor class: public void postStartup(){   PreferenceManagerpm=PlatformUI.getWorkbench().getPreferenceManager();   pm.remove( "org.eclipse.help.ui.browsersPreferencePage" ); //remove single contribution   pm.removeAll(); //just remove all }

weiterlesen »

How to add files recursively to InnoSetup

Especially with my current RCP applications I had the problem how to add all these files to the installer. Here is an example how to add a complete folder recursively to your InnoSetup: [Files] DestDir: {app}; Source: ..\files*; Flags: recursesubdirs Another hint, if you want to delete the application folder after uninstall (even if there …

weiterlesen »

EclipseCON 2011

Vom 2.11. bis 4.11. fand in diesem Jahr wieder die EclipseCON Europe statt. Im letzten Jahr nahm ich zum ersten Mal teil. Seit etwa dieser Zeit beschäftige ich mich beruflich und privat mit der Java/Eclipse/RCP Programmierung. Java selbst hatte ich zwar im Studium vor einigen Jahren mehr als ausführlich behandelt, Eclipse und RCP sind aber …

weiterlesen »

Java: Reading output from the Console/StdOut

Today I had a small problem. I wanted to start an external C++ console programm with some parameters and get the output back to my Java program. Here is a code snippet that reads the output from a console program: import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) …

weiterlesen »

JFace: Set selection index in TableViewer

Selecting a row by index in a table viewer isn’t very straightforward. There is no method like tableViewer.setSelectionIndex. Here is a snippet how its done: int selection = 5; //row we want to select tableViewer.setSelection(new StructuredSelection(tableViewer.getElementAt(selection)),true);

weiterlesen »

Eclipse RCP: Remove tab folder from View

If you create a new RCP application a view gets a tab like this: To remove the tab, use the “addStandaloneView” method in your perspective. Here is an example: public class Perspective implements IPerspectiveFactory { public void createInitialLayout(IPageLayout layout) { String editorArea = layout.getEditorArea(); layout.setEditorAreaVisible(false); layout.addStandaloneView(View.ID, false, IPageLayout.LEFT, 1.0f, editorArea); } } The result:

weiterlesen »

EMF: Setting an empty string as default value

If you create a string in an EMF model, its null by default: If you want to have an empty string, instead of null, you have to enter a “Default Value Literal”. For an empty string, just click on the value and hit enter (very obvious): To get the null value back, just click on …

weiterlesen »

Java: Open an URL in the standard browser

Here is short code snippet to open an URL with the systems standard browser: public void openUrl(String url) throws IOException, URISyntaxException { if(java.awt.Desktop.isDesktopSupported() ) { java.awt.Desktop desktop = java.awt.Desktop.getDesktop(); if(desktop.isSupported(java.awt.Desktop.Action.BROWSE) ) { java.net.URI uri = new java.net.URI(url); desktop.browse(uri); } } } java.awt.Desktop is supported as of Java 6.

weiterlesen »