RSS

Search Engine

Monday, June 14, 2010

Tips and Tricks

17.1. Save users layout

To remember the user's layout and window size for the next time you start your application, add configurer.setSaveAndRestore(true); to the initialize method of ApplicationWorkbenchAdvisor.

    
package addactiontoview;

import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.IWorkbenchWindowConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.application.WorkbenchWindowAdvisor;

public class ApplicationWorkbenchAdvisor extends WorkbenchAdvisor {

private static final String PERSPECTIVE_ID = "AddActiontoView.perspective";

public WorkbenchWindowAdvisor createWorkbenchWindowAdvisor(
IWorkbenchWindowConfigurer configurer) {
return new ApplicationWorkbenchWindowAdvisor(configurer);
}

public String getInitialWindowPerspectiveId() {
return PERSPECTIVE_ID;
}

@Override
public void initialize(IWorkbenchConfigurer configurer) {
super.initialize(configurer);
configurer.setSaveAndRestore(true);
}

}

Eclipse has a pre-defined command to reset the perspective. See Eclipse Commands .

17.2. Plugin ID in application

The plugin ID is usually needed in several places, so it is a good idea to declare it as static in Application.java. This ID must be the same as defined in the field "ID" of the overview tab of plugin.xml. The ID is case sensitive.

In our example if the RCP application is called "de.vogella.rcp.intro.first" therefore add the following statement to Application.java.

    
public static final String PLUGIN_ID = "de.vogella.rcp.intro.first";

17.3. Finding unused dependencies

In the file plugin.xml (tab dependencies) you define on which plugins your plugin depends. Of course you should only define the required plugins here. You can check if you have any dependency maintained which is actually not used, by selecting Dependency Analysis -> Find unused dependencies.

17.4. Deploy your own JRE with your RCP application

YOu can also deploy your own RCP application to make sure that a certain JRE is used. An Eclipse RCP application first checks in the installation directory for a folder "jre" and for a contained Java-VM. If it find one then this JRE is used to start the Eclipse RCP application.

17.5. Multi-User settings

Eclipse RCP applications save configuration files in the folder ".metadata". In the standard settings the Eclipse RCP installation directory will be used for this folder. If several users are using the same installation folder, then you should supply the parameter "-data" to specify an alternative location. If you specify the value "@user.home/applicationname" the configuration will be saved in a user specific folder.

0 comments:

Post a Comment