diff --git a/plugins/pluginList/.classpath b/plugins/pluginList/.classpath new file mode 100644 index 0000000000..ad32c83a78 --- /dev/null +++ b/plugins/pluginList/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/plugins/pluginList/.project b/plugins/pluginList/.project new file mode 100644 index 0000000000..9a8e142dee --- /dev/null +++ b/plugins/pluginList/.project @@ -0,0 +1,28 @@ + + + pluginList + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/plugins/pluginList/.settings/org.eclipse.jdt.core.prefs b/plugins/pluginList/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..a9df5ee2a9 --- /dev/null +++ b/plugins/pluginList/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Mar 15 20:45:28 CET 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/plugins/pluginList/.settings/org.eclipse.pde.core.prefs b/plugins/pluginList/.settings/org.eclipse.pde.core.prefs new file mode 100644 index 0000000000..b83250f900 --- /dev/null +++ b/plugins/pluginList/.settings/org.eclipse.pde.core.prefs @@ -0,0 +1,4 @@ +#Wed Mar 17 17:21:50 CET 2010 +eclipse.preferences.version=1 +pluginProject.extensions=true +resolve.requirebundle=false diff --git a/plugins/pluginList/META-INF/MANIFEST.MF b/plugins/pluginList/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..0153c951bb --- /dev/null +++ b/plugins/pluginList/META-INF/MANIFEST.MF @@ -0,0 +1,13 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: PluginList +Bundle-SymbolicName: org.adempiere.plugin.list;singleton:=true +Bundle-Version: 0.0.0.2 +Bundle-Activator: org.adempiere.plugin.list.Activator +Bundle-ActivationPolicy: lazy +Bundle-RequiredExecutionEnvironment: JavaSE-1.6 +Eclipse-LazyStart: true +Import-Package: org.osgi.framework;version="1.3.0" +Require-Bundle: org.adempiere.pluginUtils;bundle-version="0.0.0", + org.adempiere.base;bundle-version="0.0.0", + org.adempiere.client;bundle-version="0.0.0" diff --git a/plugins/pluginList/META-INF/PackOut.xml b/plugins/pluginList/META-INF/PackOut.xml new file mode 100644 index 0000000000..333bcac9c3 --- /dev/null +++ b/plugins/pluginList/META-INF/PackOut.xml @@ -0,0 +1,13 @@ + + + +
+
+
diff --git a/plugins/pluginList/build.properties b/plugins/pluginList/build.properties new file mode 100644 index 0000000000..e9863e281e --- /dev/null +++ b/plugins/pluginList/build.properties @@ -0,0 +1,5 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + .,\ + plugin.xml diff --git a/plugins/pluginList/plugin.xml b/plugins/pluginList/plugin.xml new file mode 100644 index 0000000000..802aa740db --- /dev/null +++ b/plugins/pluginList/plugin.xml @@ -0,0 +1,11 @@ + + + + + + + + + diff --git a/plugins/pluginList/src/org/adempiere/plugin/list/Activator.java b/plugins/pluginList/src/org/adempiere/plugin/list/Activator.java new file mode 100644 index 0000000000..0ccbe00ba0 --- /dev/null +++ b/plugins/pluginList/src/org/adempiere/plugin/list/Activator.java @@ -0,0 +1,19 @@ +package org.adempiere.plugin.list; + +import org.adempiere.plugin.utils.AdempiereActivator; +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; + +public class Activator extends AdempiereActivator implements BundleActivator { + + static private BundleContext ctx; + + @Override + public void start() { + ctx = getContext(); + } + + public static BundleContext getPluginContext() { + return ctx; + } +} diff --git a/plugins/pluginList/src/org/adempiere/plugin/list/PluginList.java b/plugins/pluginList/src/org/adempiere/plugin/list/PluginList.java new file mode 100644 index 0000000000..7c521f93c8 --- /dev/null +++ b/plugins/pluginList/src/org/adempiere/plugin/list/PluginList.java @@ -0,0 +1,142 @@ +package org.adempiere.plugin.list; + +import java.awt.BorderLayout; +import java.awt.Component; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.util.Vector; +import java.util.logging.Level; + +import javax.swing.JButton; +import javax.swing.JScrollPane; +import javax.swing.table.DefaultTableModel; + +import org.compiere.apps.form.FormFrame; +import org.compiere.apps.form.FormPanel; +import org.compiere.apps.form.VFileImport; +import org.compiere.minigrid.MiniTable; +import org.compiere.swing.CPanel; +import org.compiere.util.CLogger; +import org.osgi.framework.Bundle; +import org.osgi.framework.BundleContext; +import org.osgi.framework.BundleException; + +public class PluginList implements FormPanel, ActionListener { + + private static CLogger log = CLogger.getCLogger(PluginList.class); + private int m_WindowNo; + private FormFrame m_frame; + private CPanel northPanel = new CPanel(); + private CPanel centerPanel = new CPanel(); + private CPanel confirmPanel = new CPanel(); + private MiniTable pluginTable = new MiniTable(); + private JScrollPane centerScrollPane = new JScrollPane(); + private JButton refreshButton = new JButton(); + + @Override + public void dispose() { + if (m_frame != null) + m_frame.dispose(); + m_frame = null; + } + + @Override + public void init(int WindowNo, FormFrame frame) { + log.info(""); + m_WindowNo = WindowNo; + m_frame = frame; + try + { + jbInit(); + frame.getContentPane().add(northPanel, BorderLayout.NORTH); + frame.getContentPane().add(centerPanel, BorderLayout.CENTER); + frame.getContentPane().add(confirmPanel, BorderLayout.SOUTH); + } + catch(Exception e) + { + log.log(Level.SEVERE, "init", e); + } + } + + private void jbInit() { + centerPanel.add(centerScrollPane, BorderLayout.CENTER); + centerScrollPane.getViewport().add(pluginTable, null); + updatePlugins(); + + refreshButton.setText("Refresh"); + refreshButton.addActionListener(this); + confirmPanel.add(refreshButton); + } + + private void updatePlugins() { + DefaultTableModel dataModel = new DefaultTableModel(getData(), getColumnNames()); + pluginTable.setModel(dataModel); + pluginTable.autoSize(); + } + + private Vector> getData() { + BundleContext ctx = getContext(); + Vector> result = new Vector>(); + for (Bundle bundle : ctx.getBundles()) { + Vector col = new Vector(); + col.add(bundle.getBundleId()); + col.add(state(bundle.getState())); + col.add(bundle.getSymbolicName()); + col.add(bundle.getVersion()); + result.add(col); + } + return result; + } + + private BundleContext getContext() { + return Activator.getPluginContext(); + } + + private String state(int state) { + switch (state) { + case Bundle.ACTIVE: + return "ACTIVE"; + case Bundle.INSTALLED: + return "INSTALLED"; + case Bundle.RESOLVED: + return "RESOLVED"; + case Bundle.STARTING: + return "STARTING"; + case Bundle.STOPPING: + return "STOPPING"; + case Bundle.UNINSTALLED: + return "UNINSTALLED"; + default: + return "UNKNOWN"; + } + } + + private Vector getColumnNames() { + Vector result = new Vector(); + result.add("Id"); + result.add("State"); + result.add("Name"); + result.add("Version"); + return result; + } + + @Override + public void actionPerformed(ActionEvent e) { + if (e.getSource().equals(refreshButton)) + refreshClicked(e); + } + + private void refreshClicked(ActionEvent e) { + int row = pluginTable.getSelectedRow(); + if (row==-1) + return; + long id = (Long) pluginTable.getValueAt(row, 0); + Bundle bundle = getContext().getBundle(id); + try { + bundle.update(); + } catch (BundleException ex) { + log.log(Level.SEVERE, "refresh", ex); + } + } + +}