Fixed loading of image resource for web ui.

This commit is contained in:
Heng Sin Low 2010-12-17 11:49:05 +08:00
parent 8fa9544e4c
commit eb657e8e63
6 changed files with 95 additions and 46 deletions

View File

@ -294,8 +294,7 @@ public final class Adempiere
if (s_image16 == null)
{
Toolkit tk = Toolkit.getDefaultToolkit();
URL url = org.compiere.Adempiere.class.getResource(s_File16x16);
// System.out.println(url);
URL url = Core.getResourceFinder().getResource(s_File16x16);
if (url == null)
return null;
s_image16 = tk.getImage(url);
@ -315,10 +314,9 @@ public final class Adempiere
Toolkit tk = Toolkit.getDefaultToolkit();
URL url = null;
if (hr)
url = org.compiere.Adempiere.class.getResource(s_file48x15HR);
url = Core.getResourceFinder().getResource(s_file48x15HR);
else
url = org.compiere.Adempiere.class.getResource(s_file48x15);
// System.out.println(url);
url = Core.getResourceFinder().getResource(s_file48x15);
if (url == null)
return null;
s_image48x15 = tk.getImage(url);
@ -336,8 +334,6 @@ public final class Adempiere
{
Toolkit tk = Toolkit.getDefaultToolkit();
URL url = Core.getResourceFinder().getResource(s_file100x30);
// URL url = org.compiere.Adempiere.class.getResource(s_file100x30);
// System.out.println(url);
if (url == null)
return null;
s_imageLogo = tk.getImage(url);
@ -353,8 +349,7 @@ public final class Adempiere
{
if (s_imageIcon32 == null)
{
URL url = org.compiere.Adempiere.class.getResource(s_file32x32);
// System.out.println(url);
URL url = Core.getResourceFinder().getResource(s_file32x32);
if (url == null)
return null;
s_imageIcon32 = new ImageIcon(url);
@ -370,8 +365,7 @@ public final class Adempiere
{
if (s_imageIconLogo == null)
{
URL url = org.compiere.Adempiere.class.getResource(s_file100x30);
// System.out.println(url);
URL url = Core.getResourceFinder().getResource(s_file100x30);
if (url == null)
return null;
s_imageIconLogo = new ImageIcon(url);
@ -581,37 +575,4 @@ public final class Adempiere
return Core.getResourceFinder().getResource(name);
}
/**
* Main Method
*
* @param args optional start class
*/
// public static void main (String[] args)
// {
// Splash.getSplash();
// startup(true); // error exit and initUI
//
// // Start with class as argument - or if nothing provided with Client
// String className = "org.compiere.apps.AMenu";
// for (int i = 0; i < args.length; i++)
// {
// if (!args[i].equals("-debug")) // ignore -debug
// {
// className = args[i];
// break;
// }
// }
// //
// try
// {
// Class<?> startClass = Class.forName(className);
// startClass.newInstance();
// }
// catch (Exception e)
// {
// System.err.println("ADempiere starting: " + className + " - " + e.toString());
// e.printStackTrace();
// }
// } // main
} // Adempiere

View File

@ -374,4 +374,7 @@ Import-Package: javax.servlet;version="2.5.0",
javax.servlet.http;version="2.5.0",
org.apache.commons.codec.binary,
org.apache.ecs,
org.apache.ecs.xhtml
org.apache.ecs.xhtml,
org.osgi.framework;version="1.5.0"
Bundle-ActivationPolicy: lazy
Bundle-Activator: org.adempiere.webui.WebUIActivator

View File

@ -1 +0,0 @@
syntax: regexp

View File

@ -0,0 +1,46 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui;
import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
/**
* @author hengsin
*
*/
public class WebUIActivator implements BundleActivator {
private static BundleContext bundleContext = null;
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext)
*/
@Override
public void start(BundleContext context) throws Exception {
bundleContext = context;
}
/* (non-Javadoc)
* @see org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
*/
@Override
public void stop(BundleContext context) throws Exception {
bundleContext = null;
}
public static BundleContext getBundleContext() {
return bundleContext;
}
}

View File

@ -0,0 +1,33 @@
/******************************************************************************
* Product: Adempiere ERP & CRM Smart Business Solution *
* Copyright (C) 2010 Heng Sin Low *
* This program is free software; you can redistribute it and/or modify it *
* under the terms version 2 of the GNU General Public License as published *
* by the Free Software Foundation. This program is distributed in the hope *
* that it will be useful, but WITHOUT ANY WARRANTY; without even the implied *
* warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* See the GNU General Public License for more details. *
* You should have received a copy of the GNU General Public License along *
* with this program; if not, write to the Free Software Foundation, Inc., *
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. *
*****************************************************************************/
package org.adempiere.webui.util;
import java.net.URL;
import org.adempiere.base.IResourceFinder;
import org.adempiere.webui.WebUIActivator;
/**
*
* @author hengsin
*
*/
public class WebUIResourceFinder implements IResourceFinder {
@Override
public URL getResource(String name) {
return WebUIActivator.getBundleContext().getBundle().getEntry(name);
}
}

View File

@ -46,5 +46,12 @@
priority="0">
</factory>
</extension>
<extension
id="org.adempiere.ui.zk.WebUIResourceFinder"
point="org.adempiere.base.IResourceFinder">
<finder
class="org.adempiere.webui.util.WebUIResourceFinder">
</finder>
</extension>
</plugin>