IDEMPIERE-3545 Add plugin information in About window / fix index out of bounds issue - and avoid starting a fragment

This commit is contained in:
Carlos Ruiz 2020-02-25 17:51:19 +01:00
parent 71138cdef9
commit 174ff192a4
2 changed files with 29 additions and 5 deletions

View File

@ -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",

View File

@ -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<Event> {
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<Event> {
Bundle retValue = null;
int idx = pluginsTable.getSelectedIndex();
if (idx >= 0) {
Integer selectedPlugin = (Integer) pluginsTable.getModel().getDataAt(idx, 1);
Vector<Object> pluginVector = pluginData.get(selectedPlugin);
Vector<Object> 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<Event> {
}
private void refreshPluginTable() {
int idx = pluginsTable.getSelectedIndex();
pluginsTable.getModel().removeAll(pluginData);
pluginData.removeAllElements();
@ -521,6 +543,7 @@ public class AboutWindow extends Window implements EventListener<Event> {
}
ListModelTable model = new ListModelTable(pluginData);
pluginsTable.setData(model, pluginColumnNames);
pluginsTable.setSelectedIndex(idx);
}
protected Tabpanel createInfo() {