Child nodes of eclipse rcp tree viewer is not shown - eclipse

I have a tree viewer in the project explorer view of my RCP application. My product completely deals with loading, value retrieval and updating values in resource ("org.eclipse.emf.ecore.resource.Resource"). I am having a create project menu item, which is used for creation of new project. After the project creation operation, a new file is created in the project folder. I am having a standard file, which I need to be loaded while creating the project itself. So, in the entire application, I deal with 2 files(standard file and the file created during project creation operation). When I am running the rcp product in eclipse, its working fine and after the completion of project creation process, the project node appears in the tree and when i try to expand the project node, it shows the child nodes.
I tried to export it as an rcp product in the eclipse product file. And when I tried to create project, the project node is shown in the tree viewer, but when I try to expand the project node, nothing is shown under it. Why is it not showing the child nodes of the project node. The child nodes should be taken from the file created during the project creation process. Th file is created perfectly in the project folder. I think, this happens due to some issues related with resources. Is there something which we should care about resources, while exporting the product.

I've had the same issue and although ugly got around it with this class.
package com.mycomp
import java.net.URL;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.internal.ide.model.WorkbenchAdapterBuilder;
import org.osgi.framework.Bundle;
public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor
{
/**
* Declares all IDE-specific workbench images. This includes both "shared"
* images (named in {#link IDE.SharedImages}) and internal images (named in
* {#link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
*
* #see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
*/
protected void declareWorkbenchImages()
{
final String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
final String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled
// //$NON-NLS-1$
// toolbar
// icons.
final String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled
// //$NON-NLS-1$
// //$NON-NLS-1$
// toolbar
// icons.
final String PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons.
final String PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons.
final String PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons
final String PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC,
PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER,
PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED,
PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC,
PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER,
PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED,
PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL
+ "next_nav.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV,
PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ,
PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ,
PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ,
PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ,
PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ,
PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ,
PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ,
PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle,
IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN
+ "workset_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG,
PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG,
PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT
+ "prj_obj.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT
+ "cprj_obj.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL
+ "gotoobj_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED,
PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED,
PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
// task objects
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
// PATH_OBJECT+"hprio_tsk.gif");
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
// PATH_OBJECT+"mprio_tsk.gif");
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
// PATH_OBJECT+"lprio_tsk.gif");
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT
+ "taskmrk_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT
+ "bkmrk_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK,
PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK,
PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM,
PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER,
PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH,
PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH,
PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT
+ "info_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT,
PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT,
PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY,
PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
/* declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_LINKTO_HELP,
PATH_ELOCALTOOL + "linkto_help.gif", false); //$NON-NLS-1$
*/ }
/**
* Declares an IDE-specific workbench image.
*
* #param symbolicName
* the symbolic name of the image
* #param path
* the path of the image file; this path is relative to the base
* of the IDE plug-in
* #param shared
* <code>true</code> if this is a shared image, and
* <code>false</code> if this is not a shared image
* #see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
*/
private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path,
boolean shared)
{
URL url = FileLocator.find(ideBundle, new Path(path), null);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
}
#Override
public void initialize(IWorkbenchConfigurer configurer)
{
//configurer.setSaveAndRestore(true);
declareWorkbenchImages();
}
#Override
public IAdaptable getDefaultPageInput()
{
return ResourcesPlugin.getWorkspace().getRoot();
}
#SuppressWarnings("restriction")
#Override
public void preStartup()
{
WorkbenchAdapterBuilder.registerAdapters();
}
}
It is an issue of ui resources not getting set also you need this extension point "org.eclipse.ui.navigator.viewer" to create a viewer with the view id of your project explorer. Hope that helps.

Related

The Navigator in my RCP app is always empty

I was switching from Eclipse Kepler to Eclipse 2018-09. All is OK so far except on thing: The Navigator is now always empty.
I have the popup menu and I am able to create a project. The project is created and I can use it intern in my code with no problems. But the navigator shows nothing except an empty menu Item. if I right click on it I have the popupmenue for the project. I can close the project for example and all other. But the menu item diesn't show any text.
If I refresh the Navigator then the menu item disappears and also does not show up anymore when I restart my app.
Any idea? Thanks
edit:
I created a new project and used the mail-demo application. Then I added the navigator plugin and navigator resources. Same problem. Then I added java support and now there is the same problem in the "save and launch" dialog.
edit2:
I had nor error of missing plugins. But as test I added every single plugin to the app but the navigator was still empty. Then I remember that I had to add an Hack in Kepler. As test I took the hack out and the Navigation was empty in Kepler as well.
The problem now is that WorkbenchAdapterBuilder.registerAdapters(); in preStartup() is not available anymore and if I take it out the Navigation is empty again.
import java.net.URL;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.core.runtime.Path;
import org.eclipse.core.runtime.Platform;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.ui.application.IWorkbenchConfigurer;
import org.eclipse.ui.application.WorkbenchAdvisor;
import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages;
import org.eclipse.ui.internal.ide.IDEWorkbenchPlugin;
import org.eclipse.ui.internal.ide.model.WorkbenchAdapterFactory;
import org.osgi.framework.Bundle;
/**
* Methods copied from {#link org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor}
*/
#SuppressWarnings("restriction")
public abstract class WorkbenchAdvisorHack extends WorkbenchAdvisor {
/**
* Declares all IDE-specific workbench images. This includes both "shared"
* images (named in {#link IDE.SharedImages}) and internal images (named in
* {#link org.eclipse.ui.internal.ide.IDEInternalWorkbenchImages}).
*
* #see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
*/
protected void declareWorkbenchImages() {
final String ICONS_PATH = "$nl$/icons/full/";//$NON-NLS-1$
final String PATH_ELOCALTOOL = ICONS_PATH + "elcl16/"; // Enabled
// //$NON-NLS-1$
// toolbar
// icons.
final String PATH_DLOCALTOOL = ICONS_PATH + "dlcl16/"; // Disabled
// //$NON-NLS-1$
// //$NON-NLS-1$
// toolbar
// icons.
final String PATH_ETOOL = ICONS_PATH + "etool16/"; // Enabled toolbar
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons.
final String PATH_DTOOL = ICONS_PATH + "dtool16/"; // Disabled toolbar
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons.
final String PATH_OBJECT = ICONS_PATH + "obj16/"; // Model object
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons
final String PATH_WIZBAN = ICONS_PATH + "wizban/"; // Wizard
// //$NON-NLS-1$
// //$NON-NLS-1$
// icons
Bundle ideBundle = Platform.getBundle(IDEWorkbenchPlugin.IDE_WORKBENCH);
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC, PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_HOVER, PATH_ETOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_BUILD_EXEC_DISABLED, PATH_DTOOL + "build_exec.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC, PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_HOVER, PATH_ETOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_SEARCH_SRC_DISABLED, PATH_DTOOL + "search_src.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_NEXT_NAV, PATH_ETOOL + "next_nav.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PREVIOUS_NAV, PATH_ETOOL + "prev_nav.gif", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWPRJ_WIZ, PATH_WIZBAN + "newprj_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFOLDER_WIZ, PATH_WIZBAN + "newfolder_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_NEWFILE_WIZ, PATH_WIZBAN + "newfile_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTDIR_WIZ, PATH_WIZBAN + "importdir_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_IMPORTZIP_WIZ, PATH_WIZBAN + "importzip_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTDIR_WIZ, PATH_WIZBAN + "exportdir_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_EXPORTZIP_WIZ, PATH_WIZBAN + "exportzip_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_WIZBAN_RESOURCEWORKINGSET_WIZ, PATH_WIZBAN + "workset_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_SAVEAS_DLG, PATH_WIZBAN + "saveas_wiz.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLGBAN_QUICKFIX_DLG, PATH_WIZBAN + "quick_fix.png", false); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT, PATH_OBJECT + "prj_obj.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJ_PROJECT_CLOSED, PATH_OBJECT + "cprj_obj.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OPEN_MARKER, PATH_ELOCALTOOL + "gotoobj_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ELCL_QUICK_FIX_ENABLED, PATH_ELOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_DLCL_QUICK_FIX_DISABLED, PATH_DLOCALTOOL + "smartmode_co.gif", true); //$NON-NLS-1$
// task objects
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_HPRIO_TSK,
// PATH_OBJECT+"hprio_tsk.gif");
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_MPRIO_TSK,
// PATH_OBJECT+"mprio_tsk.gif");
// declareRegistryImage(IDEInternalWorkbenchImages.IMG_OBJS_LPRIO_TSK,
// PATH_OBJECT+"lprio_tsk.gif");
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_TASK_TSK, PATH_OBJECT + "taskmrk_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDE.SharedImages.IMG_OBJS_BKMRK_TSK, PATH_OBJECT + "bkmrk_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_COMPLETE_TSK, PATH_OBJECT + "complete_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INCOMPLETE_TSK, PATH_OBJECT + "incomplete_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_ITEM, PATH_OBJECT + "welcome_item.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WELCOME_BANNER, PATH_OBJECT + "welcome_banner.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_ERROR_PATH, PATH_OBJECT + "error_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_WARNING_PATH, PATH_OBJECT + "warn_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_OBJS_INFO_PATH, PATH_OBJECT + "info_tsk.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_FLAT_LAYOUT, PATH_ELOCALTOOL + "flatLayout.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_HIERARCHICAL_LAYOUT, PATH_ELOCALTOOL + "hierarchicalLayout.gif", true); //$NON-NLS-1$
declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_ETOOL_PROBLEM_CATEGORY, PATH_ETOOL + "problem_category.gif", true); //$NON-NLS-1$
//declareWorkbenchImage(ideBundle, IDEInternalWorkbenchImages.IMG_LCL_LINKTO_HELP, PATH_ELOCALTOOL + "linkto_help.gif", false); //$NON-NLS-1$
}
/**
* Declares an IDE-specific workbench image.
*
* #param symbolicName
* the symbolic name of the image
* #param path
* the path of the image file; this path is relative to the base of
* the IDE plug-in
* #param shared
* <code>true</code> if this is a shared image, and
* <code>false</code> if this is not a shared image
* #see org.eclipse.ui.internal.ide.IDEWorkbenchAdvisor#declareImage
*/
private void declareWorkbenchImage(Bundle ideBundle, String symbolicName, String path, boolean shared) {
URL url = FileLocator.find(ideBundle, new Path(path), null);
ImageDescriptor desc = ImageDescriptor.createFromURL(url);
getWorkbenchConfigurer().declareImage(symbolicName, desc, shared);
}
#Override
public void initialize(IWorkbenchConfigurer configurer) {
configurer.setSaveAndRestore(true);
declareWorkbenchImages();
}
#Override
public IAdaptable getDefaultPageInput() {
return new NavigatorRoot();
}
#SuppressWarnings("restriction")
#Override
public void preStartup() {
WorkbenchAdapterBuilder.registerAdapters();
}
}
in ApplicationWorkbenchAdvisor add
#Override
public void initialize(IWorkbenchConfigurer configurer) {
configurer.setSaveAndRestore(true);
IDE.registerAdapters();
}

How to import Drools Decision table present in multiple sheets of same excel file, using Drools 6?

I am not getting any specific way to do it using Drools 6.
I had tried to do it using the following sample code :
`
private static KieBase readBase(String strFilePath) throws IOException, BiffException {
DecisionTableConfiguration dtconf = KnowledgeBuilderFactory.newDecisionTableConfiguration();
dtconf.setInputType(DecisionTableInputType.XLS);
KnowledgeBuilder kbuilder = KnowledgeBuilderFactory.newKnowledgeBuilder();
File xls = new File(strFilePath);
SpreadsheetCompiler compiler = new SpreadsheetCompiler();
Workbook w;
String sheetName = "";
FileInputStream in = null;
try {
w = Workbook.getWorkbook(xls);
for (Sheet sheet : w.getSheets()) {
sheetName = sheet.getName();
in = new FileInputStream(xls);
System.out.println("The sheet name is : " + sheetName);
compileSheet(kbuilder, xls, compiler, sheetName, in);
}
} catch (DecisionTableParseException e) {
System.out.println("Failed to parse spreadsheet " + sheetName + " "
+ e);
}
KieBase k = KnowledgeBaseFactory.newKnowledgeBase();
// kContainer.
KnowledgeBase kb = KnowledgeBaseFactory.newKnowledgeBase();
kb.addKnowledgePackages(kbuilder.getKnowledgePackages());
return kb;
}
private static KnowledgeBuilder compileSheet(KnowledgeBuilder kbuilder, File xls, SpreadsheetCompiler compiler, String sheetName, FileInputStream in) {
try {
String compiled = compiler.compile(in, sheetName);
kbuilder.add(ResourceFactory.newReaderResource(new StringReader(compiled)), ResourceType.DRL);
System.out.println("***************************************drl**************************************");
System.out.println(compiled);
} catch (DecisionTableParseException dtpe) {
if (dtpe.getMessage().equals("No RuleTable's were found in spreadsheet.")) {
System.out.println("No rule tables found in sheet {}" + sheetName);
} else {
throw dtpe;
}
}
return kbuilder;
}
`
Problem here is Drools 6 uses KIEBase not KnowledgeBase, so I am not getting appropriate way for to load compiled sheets in KieBase. Is there any other way to do it in Drools 6?
KieServices kieServices = KieServices.Factory.get();
KieFileSystem kfs = kieServices.newKieFileSystem();
FileInputStream fis = new FileInputStream( "dir/some.drl" );
kfs.write( "src/main/resources/simple.drl",
kieServices.getResources().newInputStreamResource( fis ) );
KieBuilder kieBuilder = kieServices.newKieBuilder( kfs ).buildAll();
Results results = kieBuilder.getResults();
if( results.hasMessages( Message.Level.ERROR ) ){
System.out.println( results.getMessages() );
throw new IllegalStateException( "### errors ###" );
}
KieContainer kieContainer =
kieServices.newKieContainer( kieServices.getRepository().getDefaultReleaseId() );
KieBase kieBase = kieContainer.getKieBase();
You can use this with dsl, dslr and xls files as well.

How to load Asset bundle scene in unity 4

I have made asset bundle of a scene like this
[MenuItem("MFKJ/BuildSceneAsset")]
static void myBuild() {
string[] levels = { "Assets/Scene/Scene2.unity" };
string v = BuildPipeline.BuildStreamedSceneAssetBundle(levels, "Assets/AssetBundles/Streamed-Level2.unity3d", BuildTarget.StandaloneWindows);
Debug.Log(v);
//"Streamed-Level1.unity3d"
//BuildPipeline.BuildStreamedSceneAssetBundle(levels, "Streamed-Level1.unity3d", BuildTarget.StandaloneWindows64);
}
This has made a .unity3d assetbundle file in specified folder.
Now on run time i am loading the scene from asset bundle form another scene using this code.
public string url;
// Use this for initialization
void Start () {
url = "file://" + Application.dataPath + "/AssetBundles/Streamed-Level2.unity3d";
Debug.Log("scene load url : " + url);
StartCoroutine(LoadSceneBundle());
}
// Update is called once per frame
void Update () {
}
public IEnumerator LoadSceneBundle() {
using (WWW www = WWW.LoadFromCacheOrDownload(url,1)){
yield return www;
if (www.error != null) {
throw new Exception("WWW donwload had an error : " + url + " " + www.error);
//Debug.Log("");
}
AssetBundle ab = www.assetBundle;
Debug.Log(www.assetBundle.mainAsset);
//GameObject gm = ab.mainAsset as GameObject;
//Debug.Log("Scene2PassValue : " + gm.name);
//Instantiate(gm);
//ab.LoadAll(typeof(GameObject));
ab.LoadAll();
ab.Unload(false);
}
}
but unfortunately this is not loading the streamed scene or any asset of streamed scene from asset bundle. what i am missing?

Eclipse Plugin change Language programmatically

I am trying to change the language of my RCP plugin programmatically. I had no luck so far. The Approach below is not working for me. After restart the language does not change. I populate a Menu dynamically with listet Translation files in a specific folder. The method LanguageSelectedListener.widgetSelected when a MenuItem is selected. Tried this with an exported product and also running from eclipse.
private void setMenuLanguages(Menu menu){
File dir = new File(this.getClass().getProtectionDomain().getCodeSource().getLocation().getFile() + language_directory);
String[] dirList = dir.list();
String currentLocale = System.getProperty("user.language");
Locale current = new Locale(currentLocale, "", "");
Locale[] locales = new Locale[dirList.length];
LanguageSelectedListener listener = new LanguageSelectedListener();
for(int i=0; i<dirList.length; i++){
String file = dirList[i].split(".properties")[0];
String locShort;
if(file.equals("messages"))locShort = "en"; //default english
else locShort = file.split("_")[1];
locales[i] = new Locale(locShort);
MenuItem menuItem = new MenuItem(menu, SWT.RADIO, i);
menuItem.setText(locales[i].getDisplayName());
menuItem.setData("locale", locales[i]);
menuItem.addSelectionListener(listener);
if(locales[i].getLanguage().equals(current.getLanguage()))
menuItem.setSelection(true);
}
return;
}
private class LanguageSelectedListener extends SelectionAdapter{
#Override
public void widgetSelected(SelectionEvent e) {
MenuItem item = (MenuItem) e.widget;
if(!item.getSelection() || !MessageDialog.openQuestion(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), "Info", "Programm wird neu gestartet. Möchten Sie fortfahren?")){
item.setSelection(false);
return;
}
Locale locale = (Locale) item.getData("locale");
StringBuffer arguments = new StringBuffer();
arguments.append("${eclipse.vm}\n"); //$NON-NLS-1$
arguments.append("-nl\n").append(locale.getLanguage()).append("\n"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
System.setProperty("eclipse.exitcode", Integer.toString(IApplication.EXIT_RELAUNCH)); //$NON-NLS-1$
System.getProperties().setProperty(IApplicationContext.EXIT_DATA_PROPERTY, arguments.toString());
PlatformUI.getWorkbench().restart();
}
}
so I implemented the hacky solution by manipulating the ini file of the product (not the config.ini file). Works pretty well for me.
String installLoc = Platform.getInstallLocation().getURL().getPath();
String oldIniLocation = installLoc + "decoder.ini";
String content = null;
File oldIni = null;
try {
oldIni = new File(oldIniLocation);
content = FileUtils.readFileToString(oldIni, "UTF-8");
} catch (IOException e1) {
throw new RuntimeException("reading from file failed!", e1);
}
Locale locale = (Locale) item.getData("locale");
if(content.contains("-nl")){
content = content.replaceFirst("-nl\r\n..", "-nl\r\n" + locale.getLanguage());
}
else{
StringBuilder newContent = new StringBuilder("-nl\r\n" + locale.getLanguage() +"\r\n");
content = newContent.append(content).toString();
}
File newIni = new File(installLoc + "rename.ini");
try {
FileUtils.writeStringToFile(newIni, content, "UTF-8");
} catch (IOException e1) {
throw new RuntimeException("writing to file failed!", e1);
}
oldIni.delete();
//renaming newIni by moving it
oldIni = new File(installLoc + "decoder.ini");
try {
FileUtils.moveFile(newIni, oldIni);
} catch (IOException e1) {
throw new RuntimeException("renaming/moving file failed!", e1);
}
System.setProperty("eclipse.exitcode", Integer.toString(IApplication.EXIT_RESTART)); //$NON-NLS-1$
PlatformUI.getWorkbench().restart();

Can't place Marker in GWT Maps with Lat & Lng - Null Pointer Exception in map.addOverlay(Marker)

I'm trying to add multiple markers to my GWT-Map. If I do it with the geocoder, it works just fine... But I also get the values from a database, so I can place them via Lat Lng.
That's the code:
public static void markerSetzen(final double lat, final double lon) {
/* Markeroptionen setzen */
MarkerOptions markeroptions = MarkerOptions.newInstance();
markeroptions.setBouncy(true);
markeroptions.setBounceGravity(0.3);
final Marker marker = new Marker(LatLng.newInstance(lat, lon),
markeroptions);
map.addOverlay(marker);
marker.addMarkerClickHandler(new MarkerClickHandler() {
#Override
public void onClick(MarkerClickEvent event) {
// popup- Fenster erstellen
map.getInfoWindow().open(
LatLng.newInstance(lat, lon),
new InfoWindowContent(image + name + "<br>" + ort
+ "<br>" + kategorie + "<br><br>"
+ beschreibung + "<br>" + web));
}
});
}
The exception is always thrown at map.addOverlay(). I check the returned doubles from the db
via syso and they're just fine...
I hope someone can help,
thanks in advance
EDIT: that is the code of the geocoder method, which does what I want:
public static void koordSuchen(final double lat, final double lon,
final String ort, final String image, final String name,
final String kategorie, final String beschreibung,
final String web, final int zoomlevel) {
// Geokodierung von Adressen herausbekommen
Geocoder geocoder = new Geocoder();
geocoder.getLatLng(ort, new LatLngCallback() {
#Override
public void onSuccess(LatLng point) {
final LatLng ortKoord = LatLng.newInstance(lat, lon);
// neuen Marker erstellen
Marker marker = new Marker(ortKoord);
// neues Marker- Overlay erstellen
map.addOverlay(marker);
// Marker Klickhandler erstellen (Bei klick auf Marker oeffnet
// sich ein Popup)
marker.addMarkerClickHandler(new MarkerClickHandler() {
#Override
public void onClick(MarkerClickEvent event) {
// popup- Fenster erstellen
map.getInfoWindow().open(
ortKoord,
new InfoWindowContent(image + name + "<br>"
+ ort + "<br>" + kategorie + "<br><br>"
+ beschreibung + "<br>" + web));
}
});
}
#Override
public void onFailure() {
}
});
}
map.addOverlay() is the first instance of the variable map in your sample code. Are you sure map is initialized?