From 174ff192a46531591a6c1d4b041a2c2f3c3cf00a Mon Sep 17 00:00:00 2001 From: Carlos Ruiz Date: Tue, 25 Feb 2020 17:51:19 +0100 Subject: [PATCH] IDEMPIERE-3545 Add plugin information in About window / fix index out of bounds issue - and avoid starting a fragment --- org.adempiere.ui.zk/META-INF/MANIFEST.MF | 1 + .../adempiere/webui/window/AboutWindow.java | 33 ++++++++++++++++--- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/org.adempiere.ui.zk/META-INF/MANIFEST.MF b/org.adempiere.ui.zk/META-INF/MANIFEST.MF index 753d50b479..3573bd2a46 100644 --- a/org.adempiere.ui.zk/META-INF/MANIFEST.MF +++ b/org.adempiere.ui.zk/META-INF/MANIFEST.MF @@ -48,6 +48,7 @@ Import-Package: groovy.transform.stc;version="2.4.7", org.jfree.data.time, org.jfree.util, org.osgi.framework;version="1.7.0", + org.osgi.framework.wiring;version="1.2.0", org.osgi.service.component.annotations;version="1.3.0", org.osgi.service.event;version="1.3.0", org.osgi.util.tracker;version="1.5.0", diff --git a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java index 93ad881d7b..86e876bf91 100644 --- a/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java +++ b/org.adempiere.ui.zk/WEB-INF/src/org/adempiere/webui/window/AboutWindow.java @@ -65,6 +65,7 @@ import org.compiere.util.Util; import org.osgi.framework.Bundle; import org.osgi.framework.BundleContext; import org.osgi.framework.BundleException; +import org.osgi.framework.wiring.BundleRevision; import org.zkoss.util.media.AMedia; import org.zkoss.zhtml.Pre; import org.zkoss.zhtml.Text; @@ -445,16 +446,37 @@ public class AboutWindow extends Window implements EventListener { if (bundle == null) return; int state = bundle.getState(); + boolean isFragment = false; + BundleRevision rev = bundle.adapt(BundleRevision.class); + if (rev != null) { + isFragment = (rev.getTypes() & BundleRevision.TYPE_FRAGMENT) != 0; + } + /* + boolean hasFragments = false; + if (!isFragment) { + if (rev.getWiring() != null) { + if (rev.getWiring().getProvidedWires(BundleRevision.HOST_NAMESPACE).size() > 0) { + hasFragments = true; + } + } + } + */ if (bundle.getBundleId() == 0) { // bundle 0 cannot be stopped } else if (state == Bundle.ACTIVE) { pluginActions.getItemAtIndex(PLUGIN_ACTION_STOP).setVisible(true); } else if (state == Bundle.RESOLVED) { - pluginActions.getItemAtIndex(PLUGIN_ACTION_START).setVisible(true); + if (!isFragment) { + pluginActions.getItemAtIndex(PLUGIN_ACTION_START).setVisible(true); + } } else if (state == Bundle.INSTALLED) { - // no options yet for installed + if (!isFragment) { + pluginActions.getItemAtIndex(PLUGIN_ACTION_START).setVisible(true); + } } else if (state == Bundle.STARTING) { - // no options yet for starting + if (!isFragment) { + pluginActions.getItemAtIndex(PLUGIN_ACTION_START).setVisible(true); + } } else if (state == Bundle.STOPPING) { // no options yet for stopping } else if (state == Bundle.UNINSTALLED) { @@ -466,8 +488,7 @@ public class AboutWindow extends Window implements EventListener { Bundle retValue = null; int idx = pluginsTable.getSelectedIndex(); if (idx >= 0) { - Integer selectedPlugin = (Integer) pluginsTable.getModel().getDataAt(idx, 1); - Vector pluginVector = pluginData.get(selectedPlugin); + Vector pluginVector = pluginData.get(idx); int pluginId = ((IDColumn)pluginVector.get(0)).getRecord_ID(); BundleContext bundleCtx = WebUIActivator.getBundleContext(); retValue = bundleCtx.getBundle(pluginId); @@ -505,6 +526,7 @@ public class AboutWindow extends Window implements EventListener { } private void refreshPluginTable() { + int idx = pluginsTable.getSelectedIndex(); pluginsTable.getModel().removeAll(pluginData); pluginData.removeAllElements(); @@ -521,6 +543,7 @@ public class AboutWindow extends Window implements EventListener { } ListModelTable model = new ListModelTable(pluginData); pluginsTable.setData(model, pluginColumnNames); + pluginsTable.setSelectedIndex(idx); } protected Tabpanel createInfo() {