Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial commiot

  • Loading branch information...
commit 448b61c48060ca7f2c745b982ea257f0faed0630 0 parents
@atoulme atoulme authored
7 .classpath
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+ <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src/main/java"/>
+ <classpathentry kind="output" path="target/classes"/>
+</classpath>
28 .project
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.intalio.eclipse.bundle.doctor</name>
+ <comment></comment>
+ <projects>
+ </projects>
+ <buildSpec>
+ <buildCommand>
+ <name>org.eclipse.jdt.core.javabuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.ManifestBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ <buildCommand>
+ <name>org.eclipse.pde.SchemaBuilder</name>
+ <arguments>
+ </arguments>
+ </buildCommand>
+ </buildSpec>
+ <natures>
+ <nature>org.eclipse.pde.PluginNature</nature>
+ <nature>org.eclipse.jdt.core.javanature</nature>
+ </natures>
+</projectDescription>
7 .settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,7 @@
+#Mon Feb 16 15:39:39 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5
+org.eclipse.jdt.core.compiler.compliance=1.5
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.5
4 .settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,4 @@
+#Tue Feb 17 19:10:24 CET 2009
+eclipse.preferences.version=1
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\n * @return the ${bare_field_name}\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\n * @param ${param} the ${bare_field_name} to set\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/******************************************************************************\n * Copyright (c) ${year}, Intalio Inc.\n * All rights reserved. This program and the accompanying materials\n * are made available under the terms of the Eclipse Public License v1.0\n * which accompanies this distribution, and is available at\n * http\://www.eclipse.org/legal/epl-v10.html\n * \n * Contributors\:\n * Intalio Inc. - initial API and implementation\n *******************************************************************************/</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\n * ${tags}\n *\n *\n * @author &lt;a href\="http\://www.intalio.com"&gt;Intalio Inc.&lt;/a&gt;\n * @author &lt;a href\="mailto\:atoulme@intalio.com"&gt;Antoine Toulme&lt;/a&gt;\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\n * \n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\n * ${tags}\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"></template><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\n * ${tags}\n * ${see_to_target}\n */</template><template autoinsert\="true" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">${filecomment}\n${package_declaration}\n\n${typecomment}\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
13 META-INF/MANIFEST.MF
@@ -0,0 +1,13 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: Bundle Monitor Plug-in
+Bundle-SymbolicName: org.intalio.eclipse.bundle.doctor;singleton:=true
+Bundle-Version: 1.0.0
+Bundle-Activator: com.intalio.bpms.designer.bundle.BundlePlugin
+Bundle-Vendor: Intalio, Inc.
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.ui.forms,
+ org.eclipse.equinox.frameworkadmin;bundle-version="1.0.2"
+Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Bundle-ActivationPolicy: lazy
5 build.properties
@@ -0,0 +1,5 @@
+source.. = src/main/java/
+output.. = target/classes/
+bin.includes = META-INF/,\
+ .,\
+ plugin.xml
BIN  icons/obj16/ext_plugin_obj.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  icons/obj16/frgmt_obj.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN  icons/obj16/plugin_obj.gif
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 plugin.xml
@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.2"?>
+<plugin>
+ <extension
+ point="org.eclipse.ui.views">
+ <view
+ class="com.intalio.bpms.designer.bundle.view.BundleView"
+ id="com.intalio.bpms.designer.bundle.view"
+ name="Bundle Monitor"
+ restorable="true">
+ </view>
+ </extension>
+
+</plugin>
91 src/main/java/com/intalio/bpms/designer/bundle/BundlePlugin.java
@@ -0,0 +1,91 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ *
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle;
+
+
+import org.eclipse.jface.resource.ImageRegistry;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+import com.intalio.bpms.designer.bundle.internal.BundleManager;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class BundlePlugin extends AbstractUIPlugin {
+
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.intalio.bpms.designer.bundle"; //$NON-NLS-1$
+
+ // The shared instance
+ private static BundlePlugin plugin;
+
+ private BundleManager _bundleManager;
+
+ /**
+ * The constructor
+ */
+ public BundlePlugin() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(context);
+ _bundleManager = new BundleManager(context);
+ plugin = this;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#stop(org.osgi.framework.BundleContext)
+ */
+ public void stop(BundleContext context) throws Exception {
+ plugin = null;
+ _bundleManager.close();
+ _bundleManager = null;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static BundlePlugin getDefault() {
+ return plugin;
+ }
+
+ /**
+ * @return the bundle manager hooked to the framework to manipulate it.
+ */
+ public IBundleManager getBundleManager() {
+ return _bundleManager;
+ }
+
+ @Override
+ protected void initializeImageRegistry(ImageRegistry reg) {
+ super.initializeImageRegistry(reg);
+ reg.put("icons/obj16/ext_plugin_obj.gif",
+ imageDescriptorFromPlugin(PLUGIN_ID, "icons/obj16/ext_plugin_obj.gif"));
+ reg.put("icons/obj16/frgmt_obj.gif",
+ imageDescriptorFromPlugin(PLUGIN_ID, "icons/obj16/frgmt_obj.gif"));
+ reg.put("icons/obj16/plugin_obj.gif",
+ imageDescriptorFromPlugin(PLUGIN_ID, "icons/obj16/plugin_obj.gif"));
+ }
+
+}
65 src/main/java/com/intalio/bpms/designer/bundle/IBundleManager.java
@@ -0,0 +1,65 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ *
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle;
+
+import java.util.Collection;
+
+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+/**
+ * An interface to manage bundles.
+ * It deals with the underlying framework.
+ *
+ * The implementation of this object is expected to manage the lifecycle
+ * of the platform.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public interface IBundleManager {
+
+ /**
+ * @return all the bundles currently installed in this instance.
+ */
+ public Collection<RequiredBundle> getAllBundles();
+
+ /**
+ * @param bundle the host bundle
+ * @return the fragments for the bundle
+ */
+ public Collection<Bundle> getFragments(Bundle bundle);
+
+ /**
+ * @param bundle the bundle that requires the bundles returned
+ * @return the bundles that the bundle passed as parameter depends on.
+ */
+ public Collection<Bundle> getRequiringBundles(RequiredBundle bundle);
+
+ /**
+ * @param bundle installs a bundle in the current framework.
+ * @throws BundleException
+ */
+ public void install(BundleInfo bundle) throws BundleException;
+
+ /**
+ * @param location installs the bundle located at the location passed as argument.
+ * @throws BundleException
+ */
+ public void install(String location) throws BundleException;
+}
118 src/main/java/com/intalio/bpms/designer/bundle/internal/BundleManager.java
@@ -0,0 +1,118 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ *
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.internal;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.List;
+
+import org.eclipse.core.runtime.Platform;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundleInfo;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.BundlesState;
+import org.eclipse.equinox.internal.provisional.frameworkadmin.FrameworkAdmin;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.service.packageadmin.PackageAdmin;
+import org.osgi.service.packageadmin.RequiredBundle;
+import org.osgi.util.tracker.ServiceTracker;
+
+import com.intalio.bpms.designer.bundle.IBundleManager;
+
+/**
+ * The BundleInfo is the object that contains the bundles.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class BundleManager implements IBundleManager {
+
+ private ServiceTracker _bundleTracker;
+ private ServiceTracker _framework;
+
+ public BundleManager(BundleContext context) {
+ _bundleTracker = new ServiceTracker(context, PackageAdmin.class.getName(), null);
+ _bundleTracker.open();
+ _framework = new ServiceTracker(context, FrameworkAdmin.class.getName(), null);
+ _framework.open();
+ }
+
+ public void close() {
+ _bundleTracker.close();
+ _framework.close();
+ }
+
+ public Collection<RequiredBundle> getAllBundles() {
+ PackageAdmin packageAdmin = (PackageAdmin) _bundleTracker.getService();
+ List<RequiredBundle> required = new ArrayList<RequiredBundle>();
+ for (RequiredBundle r : packageAdmin.getRequiredBundles(null)) {
+ required.add(r);
+ }
+ Collections.sort(required, new Comparator<RequiredBundle>() {
+ public int compare(RequiredBundle o1, RequiredBundle o2) {
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
+ }
+ });
+ return required;
+ }
+
+ public Collection<Bundle> getFragments(Bundle bundle) {
+ PackageAdmin packageAdmin = (PackageAdmin) _bundleTracker.getService();
+ List<Bundle> bundles = new ArrayList<Bundle>();
+ Bundle[] fragments = packageAdmin.getFragments(bundle);
+ if (fragments != null) {
+ bundles.addAll(Arrays.asList(fragments));
+ }
+ Collections.sort(bundles, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
+ }
+ });
+ return bundles;
+ }
+
+ public Collection<Bundle> getRequiringBundles(RequiredBundle bundle) {
+ List<Bundle> bundles = new ArrayList<Bundle>();
+ Bundle[] dependencies = bundle.getRequiringBundles();
+ if (dependencies != null) {
+ bundles.addAll(Arrays.asList(dependencies));
+ }
+ Collections.sort(bundles, new Comparator<Bundle>() {
+ public int compare(Bundle o1, Bundle o2) {
+ return o1.getSymbolicName().compareTo(o2.getSymbolicName());
+ }
+ });
+ return bundles;
+ }
+
+ @SuppressWarnings("restriction")
+ public void install(BundleInfo bundle) throws BundleException {
+ FrameworkAdmin framework = (FrameworkAdmin) _framework.getService();
+ BundlesState state = framework.getRunningManipulator().getBundlesState();
+ state.installBundle(bundle);
+ state.resolve(true);
+ }
+
+ public void install(String location) throws BundleException {
+ install(new BundleInfo(location));
+ }
+
+
+}
63 src/main/java/com/intalio/bpms/designer/bundle/view/BundleContentProvider.java
@@ -0,0 +1,63 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ *
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.view;
+
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.Viewer;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+import com.intalio.bpms.designer.bundle.IBundleManager;
+
+/**
+ * A content provider to provide a list of the current bundles.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class BundleContentProvider implements ITreeContentProvider {
+
+ public Object[] getChildren(Object parentElement) {
+ if (parentElement instanceof IBundleManager) {
+ return ((IBundleManager) parentElement).getAllBundles().toArray();
+ } else if (parentElement instanceof TreeNode) {
+ return ((TreeNode) parentElement).getChildren();
+ } else if (parentElement instanceof RequiredBundle) {
+ return new Object[] {new TreeNode(TreeNode.DEPENDENCIES, (RequiredBundle) parentElement),
+ new TreeNode(TreeNode.FRAGMENTS, (RequiredBundle) parentElement)};
+ }
+ return null;
+ }
+
+ public Object getParent(Object element) {
+ return null;
+ }
+
+ public boolean hasChildren(Object element) {
+ Object[] children = getChildren(element);
+ return children != null && children.length > 0;
+ }
+
+ public Object[] getElements(Object inputElement) {
+ return getChildren(inputElement);
+ }
+
+ public void dispose() {
+ }
+
+ public void inputChanged(Viewer viewer, Object oldInput, Object newInput) {
+ }
+
+}
85 src/main/java/com/intalio/bpms/designer/bundle/view/BundleLabelProvider.java
@@ -0,0 +1,85 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ *
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.view;
+
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.jface.viewers.LabelProvider;
+import org.eclipse.osgi.framework.internal.core.AbstractBundle;
+import org.eclipse.osgi.framework.internal.core.BundleFragment;
+import org.eclipse.osgi.util.NLS;
+import org.eclipse.swt.graphics.Image;
+import org.osgi.framework.Bundle;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+import com.intalio.bpms.designer.bundle.BundlePlugin;
+
+/**
+ * the label provider for bundles.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class BundleLabelProvider extends LabelProvider implements
+ ILabelProvider {
+
+ @Override
+ public String getText(Object element) {
+ if (element instanceof RequiredBundle) {
+ return getText(((RequiredBundle) element).getBundle());
+ } else if (element instanceof Bundle) {
+ return NLS.bind("{0} ({1})", ((Bundle) element).getSymbolicName(),
+ ((AbstractBundle) element).getVersion());
+ } else if (element instanceof TreeNode) {
+ switch(((TreeNode) element).getType()) {
+ case TreeNode.DEPENDENCIES:
+ return "Dependencies";
+ case TreeNode.FRAGMENTS:
+ return "Fragments";
+ default:
+ throw new IllegalArgumentException(
+ "Don't know what text show for " +
+ ((TreeNode) element).getType());
+ }
+ }
+ return super.getText(element);
+ }
+
+ @Override
+ public Image getImage(Object element) {
+ if (element instanceof RequiredBundle) {
+ return getImage(((RequiredBundle) element).getBundle());
+ } else if (element instanceof Bundle) {
+ switch (((Bundle) element).getState()) {
+ case Bundle.ACTIVE:
+ case Bundle.INSTALLED:
+ case Bundle.RESOLVED:
+ if (element instanceof BundleFragment) {
+ return BundlePlugin.getDefault().getImageRegistry().
+ get("icons/obj16/frgmt_obj.gif");
+ }
+ return BundlePlugin.getDefault().getImageRegistry().
+ get("icons/obj16/plugin_obj.gif");
+ case Bundle.STARTING:
+ case Bundle.STOPPING:
+
+ case Bundle.UNINSTALLED:
+ return BundlePlugin.getDefault().getImageRegistry().
+ get("icons/obj16/ext_plugin_obj.gif");
+ }
+ }
+ return super.getImage(element);
+ }
+}
157 src/main/java/com/intalio/bpms/designer/bundle/view/BundleView.java
@@ -0,0 +1,157 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ * Date Author Changes
+ * Feb 16, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.view;
+
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.MenuManager;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.jface.viewers.Viewer;
+import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.jface.wizard.WizardDialog;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.ModifyEvent;
+import org.eclipse.swt.events.ModifyListener;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.swt.widgets.Text;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.internal.misc.StringMatcher;
+import org.eclipse.ui.part.ViewPart;
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleException;
+import org.osgi.service.packageadmin.RequiredBundle;
+
+import com.intalio.bpms.designer.bundle.BundlePlugin;
+import com.intalio.bpms.designer.bundle.IBundleManager;
+import com.intalio.bpms.designer.bundle.wizard.InstallWizard;
+
+/**
+ * A view showing the bundles of the running instance.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class BundleView extends ViewPart {
+
+ private class ActivateAction extends Action {
+
+ @Override
+ public String getText() {
+ return "Activate";
+ }
+
+ @Override
+ public void run() {
+ Object elt = ((IStructuredSelection) _viewer.getSelection()).getFirstElement();
+ if (elt instanceof RequiredBundle) {
+ elt = ((RequiredBundle) elt).getBundle();
+ }
+ if (elt instanceof Bundle) {
+ try {
+ ((Bundle) elt).start();
+ MessageDialog.openInformation(PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getShell(),
+ "Bundle started", ((Bundle) elt).getSymbolicName() +
+ " was started successfully");
+ } catch (BundleException e) {
+ MessageDialog.openError(PlatformUI.getWorkbench().
+ getActiveWorkbenchWindow().getShell(),
+ "Error starting a bundle", ((Bundle) elt).getSymbolicName() +
+ " could not be started:\n" + e.getMessage());
+ }
+ }
+ _viewer.refresh();
+ }
+ }
+
+ private class InstallAction extends Action {
+
+ @Override
+ public String getText() {
+ return "Install...";
+ }
+
+ @Override
+ public void run() {
+
+ WizardDialog dialog = new WizardDialog(getSite().getShell(), new InstallWizard());
+ dialog.open();
+ }
+ }
+
+ private TreeViewer _viewer;
+ private Text _filterText;
+
+ @Override
+ public void createPartControl(Composite parent) {
+ parent.setLayout(new GridLayout());
+ Group filterGroup = new Group(parent, SWT.NONE);
+ filterGroup.setLayout(new FillLayout());
+ filterGroup.setText("(Filter the bundles by name)");
+ _filterText = new Text(filterGroup, SWT.NONE);
+ _filterText.addModifyListener(new ModifyListener() {
+ public void modifyText(ModifyEvent e) {
+ if (_viewer != null && !_viewer.getTree().isDisposed()) {
+ _viewer.refresh();
+ }
+ }
+ });
+ filterGroup.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ _viewer = new TreeViewer(parent);
+ _viewer.getTree().setLayoutData(new GridData(GridData.FILL_BOTH));
+ _viewer.setContentProvider(new BundleContentProvider());
+ _viewer.setLabelProvider(new BundleLabelProvider());
+ _viewer.setInput(BundlePlugin.getDefault().getBundleManager());
+
+ MenuManager manager = createMenuManager();
+ _viewer.getTree().setMenu(manager.createContextMenu(_viewer.getTree()));
+ _viewer.addFilter(new ViewerFilter() {
+ @Override
+ public boolean select(Viewer viewer, Object parentElement,
+ Object element) {
+ if (parentElement instanceof IBundleManager) {
+ if (_filterText.getText().length() == 0) {
+ return true;
+ }
+ StringMatcher matcher = new StringMatcher(
+ _filterText.getText(), true, false);
+ return matcher.match(((RequiredBundle) element).getSymbolicName());
+ }
+ return true;
+ }
+ });
+ }
+
+ private MenuManager createMenuManager() {
+ MenuManager mgr = new MenuManager();
+ mgr.add(new ActivateAction());
+ mgr.add(new InstallAction());
+ return mgr;
+ }
+
+
+ @Override
+ public void setFocus() {
+ if (_viewer != null && !_viewer.getTree().isDisposed()) {
+ _viewer.getTree().setFocus();
+ }
+ }
+
+}
60 src/main/java/com/intalio/bpms/designer/bundle/view/TreeNode.java
@@ -0,0 +1,60 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ * Date Author Changes
+ * Feb 17, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.view;
+
+import org.osgi.service.packageadmin.RequiredBundle;
+
+import com.intalio.bpms.designer.bundle.BundlePlugin;
+
+/**
+ * A tree node to represent intermediate nodes, currently the fragments
+ * and the dependencies.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class TreeNode {
+ public static final int FRAGMENTS = 0, DEPENDENCIES = 1;
+
+ private int _type;
+
+ private RequiredBundle _bundle;
+
+ public TreeNode(int type, RequiredBundle bundle) {
+ _type = type;
+ _bundle = bundle;
+ }
+
+ /**
+ * @return its children depending on its type.
+ */
+ public Object[] getChildren() {
+ switch(_type) {
+ case FRAGMENTS:
+ return BundlePlugin.getDefault().getBundleManager().getFragments(_bundle.getBundle()).toArray();
+ case DEPENDENCIES:
+ return BundlePlugin.getDefault().getBundleManager().getRequiringBundles(_bundle).toArray();
+ default:
+ throw new IllegalArgumentException("Invalid node type");
+ }
+ }
+
+ /**
+ * @return the node type
+ */
+ public int getType() {
+ return _type;
+ }
+}
55 src/main/java/com/intalio/bpms/designer/bundle/wizard/InstallWizard.java
@@ -0,0 +1,55 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ * Date Author Changes
+ * Feb 17, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.wizard;
+
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.wizard.Wizard;
+import org.eclipse.ui.IWorkbench;
+import org.eclipse.ui.IWorkbenchWizard;
+
+/**
+ * A wizard to install one or more bundles.
+ * It's really just a prototype at this point.
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class InstallWizard extends Wizard implements IWorkbenchWizard {
+
+ /**
+ * Add one page: the installation page.
+ */
+ @Override
+ public void addPages() {
+ addPage(new InstallWizardPage());
+ }
+
+ /**
+ * No particular step for initializing the wizard just now
+ */
+ public void init(IWorkbench workbench, IStructuredSelection selection) {
+ }
+
+ /**
+ * Most of the action takes place when clicking on install.
+ *
+ */
+ @Override
+ public boolean performFinish() {
+ return true;
+ }
+
+
+
+}
113 src/main/java/com/intalio/bpms/designer/bundle/wizard/InstallWizardPage.java
@@ -0,0 +1,113 @@
+/******************************************************************************
+ * Copyright (c) 2009, Intalio Inc.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Intalio Inc. - initial API and implementation
+ *******************************************************************************
+ * Date Author Changes
+ * Feb 17, 2009 Antoine Toulme Created
+ */
+package com.intalio.bpms.designer.bundle.wizard;
+
+import java.net.URL;
+
+import org.eclipse.jface.wizard.WizardPage;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.custom.StyledText;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.layout.GridLayout;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.FileDialog;
+import org.eclipse.swt.widgets.Group;
+import org.eclipse.ui.forms.ManagedForm;
+import org.eclipse.ui.forms.widgets.FormToolkit;
+import org.eclipse.ui.forms.widgets.TableWrapData;
+import org.eclipse.ui.forms.widgets.TableWrapLayout;
+
+import com.intalio.bpms.designer.bundle.BundlePlugin;
+
+/**
+ * The first page of the installation wizard.
+ *
+ *
+ * @author <a href="http://www.intalio.com">Intalio Inc.</a>
+ * @author <a href="mailto:atoulme@intalio.com">Antoine Toulme</a>
+ */
+public class InstallWizardPage extends WizardPage {
+
+ private StyledText _directoryBrowseText;
+ private String _exportPath;
+ private StyledText _feedbackText;
+
+ public InstallWizardPage() {
+ super("installWizardPage", "Install a new plugin", null);
+ }
+
+ public void createControl(Composite parent) {
+ ManagedForm form = new ManagedForm(parent);
+ FormToolkit toolkit = form.getToolkit();
+ form.getForm().getBody().setLayout(new GridLayout());
+ Group grp = new Group(form.getForm().getBody(), SWT.NONE);
+ grp.setLayoutData(new GridData(GridData.FILL_HORIZONTAL));
+ grp.setText("Plugin location");
+ TableWrapLayout layout = new TableWrapLayout();
+ layout.numColumns = 3;
+ grp.setLayout(layout);
+ _directoryBrowseText = new StyledText(grp, SWT.READ_ONLY);
+ _directoryBrowseText.setEditable(false);
+ _directoryBrowseText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ Button browseButton = toolkit.createButton(grp, "Browse", SWT.PUSH);
+ browseButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ FileDialog dialog = new FileDialog(getShell(),
+ SWT.OPEN | SWT.MULTI);
+ dialog.setFilterPath(_exportPath);
+ dialog.setText("Choose a .jar or a directory representing a plugin");
+ String res = dialog.open();
+ if (res != null) {
+ _exportPath = res;
+ _directoryBrowseText.setText(res);
+ }
+ }
+ });
+
+ Button installButton = toolkit.createButton(grp, "Install", SWT.PUSH);
+ installButton.addSelectionListener(new SelectionAdapter() {
+
+ @Override
+ public void widgetSelected(SelectionEvent e1) {
+ if (_exportPath == null || _exportPath.length() == 0) {
+ _feedbackText.setText("Please enter a path to a plugin");
+ } else {
+ try {
+ BundlePlugin.getDefault().getBundleManager().
+ install(new URL("file", "", _exportPath).toString());
+ _feedbackText.setText("Plugin installed successfully!");
+ } catch(Exception e) {
+ e.printStackTrace();
+ _feedbackText.setText(e.getMessage() == null ? e.getClass().getName() : e.getMessage());
+ }
+ }
+ }
+ });
+
+ Group feedbackGroup = new Group(form.getForm().getBody(), SWT.NONE);
+ feedbackGroup.setText("Feedback");
+ feedbackGroup.setLayout(new FillLayout());
+ feedbackGroup.setLayoutData(new GridData(GridData.FILL_BOTH));
+ _feedbackText = new StyledText(feedbackGroup, SWT.MULTI | SWT.WRAP | SWT.READ_ONLY);
+// _feedbackText.setLayoutData(new TableWrapData(TableWrapData.FILL_GRAB));
+ setControl(form.getForm());
+ }
+
+}
Please sign in to comment.
Something went wrong with that request. Please try again.