--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/.classpath Fri May 14 14:08:20 2010 -0500
@@ -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/JavaSE-1.6"/>
+ <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry kind="output" path="bin"/>
+</classpath>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/.project Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>com.nokia.carbide.discovery.ui</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>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/.settings/org.eclipse.jdt.core.prefs Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,8 @@
+#Mon Mar 22 09:12:01 CDT 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
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/META-INF/MANIFEST.MF Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,15 @@
+Manifest-Version: 1.0
+Bundle-ManifestVersion: 2
+Bundle-Name: DiscoveryUI
+Bundle-SymbolicName: com.nokia.carbide.discovery.ui;singleton:=true
+Bundle-Version: 1.0.0.qualifier
+Bundle-Activator: com.nokia.carbide.discovery.ui.Activator
+Require-Bundle: org.eclipse.ui,
+ org.eclipse.core.runtime,
+ org.eclipse.equinox.p2.discovery;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.discovery.compatibility;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.ui.discovery;bundle-version="1.0.0",
+ org.eclipse.equinox.p2.ui;bundle-version="2.0.0"
+Bundle-ActivationPolicy: lazy
+Bundle-RequiredExecutionEnvironment: JavaSE-1.6
+Bundle-Vendor: Nokia
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/build.properties Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,7 @@
+source.. = src/
+output.. = bin/
+bin.includes = plugin.xml,\
+ META-INF/,\
+ .,\
+ icons/,\
+ contexts.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/contexts.xml Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,12 @@
+<contexts>
+ <context id="viewer" title="Sample View">
+ <description>This is the context help for the sample view with a table viewer. It was generated by a PDE template.</description>
+ <topic href="/PLUGINS_ROOT/org.eclipse.platform.doc.isv/guide/ua_help_context.htm" label="Context-sensitive help">
+ <enablement>
+ <with variable="platform">
+ <test property="org.eclipse.core.runtime.isBundleInstalled" args="org.eclipse.platform.doc.isv"/>
+ </with>
+ </enablement>
+ </topic>
+ </context>
+</contexts>
Binary file core/com.nokia.carbide.discovery.ui/icons/banner-discovery.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/icon-discovery.png has changed
Binary file core/com.nokia.carbide.discovery.ui/icons/refresh.gif has changed
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/plugin.xml Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<?eclipse version="3.4"?>
+<plugin>
+
+ <extension
+ point="org.eclipse.ui.views">
+ <category
+ id="com.nokia.carbide.discovery.category"
+ name="Discovery">
+ </category>
+ <view
+ name="Install View"
+ icon="icons/icon-discovery.png"
+ category="com.nokia.carbide.discovery.category"
+ class="com.nokia.carbide.discovery.ui.view.DiscoveryView"
+ id="com.nokia.carbide.discovery.view">
+ </view>
+ </extension>
+ <extension
+ point="org.eclipse.ui.perspectiveExtensions">
+ <perspectiveExtension
+ targetID="*">
+ <view
+ id="com.nokia.carbide.discovery.view"
+ relationship="stack"
+ relative="org.eclipse.ui.internal.introview">
+ </view>
+ </perspectiveExtension>
+ </extension>
+ <extension
+ point="org.eclipse.help.contexts">
+ <contexts
+ file="contexts.xml">
+ </contexts>
+ </extension>
+
+</plugin>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/Activator.java Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,60 @@
+package com.nokia.carbide.discovery.ui;
+
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.ui.plugin.AbstractUIPlugin;
+import org.osgi.framework.BundleContext;
+
+/**
+ * The activator class controls the plug-in life cycle
+ */
+public class Activator extends AbstractUIPlugin {
+ // The plug-in ID
+ public static final String PLUGIN_ID = "com.nokia.carbide.discovery.ui"; //$NON-NLS-1$
+
+ // The shared instance
+ private static Activator plugin;
+
+ /**
+ * The constructor
+ */
+ public Activator() {
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.ui.plugin.AbstractUIPlugin#start(org.osgi.framework.BundleContext)
+ */
+ public void start(BundleContext context) throws Exception {
+ super.start(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;
+ super.stop(context);
+ }
+
+ /**
+ * Returns the shared instance
+ *
+ * @return the shared instance
+ */
+ public static Activator getDefault() {
+ return plugin;
+ }
+
+ /**
+ * Returns an image descriptor for the image file at the given
+ * plug-in relative path
+ *
+ * @param path the path
+ * @return the image descriptor
+ */
+ public static ImageDescriptor getImageDescriptor(String path) {
+ return imageDescriptorFromPlugin(PLUGIN_ID, path);
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/core/com.nokia.carbide.discovery.ui/src/com/nokia/carbide/discovery/ui/view/DiscoveryView.java Fri May 14 14:08:20 2010 -0500
@@ -0,0 +1,234 @@
+package com.nokia.carbide.discovery.ui.view;
+
+
+import java.io.File;
+import java.net.MalformedURLException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.eclipse.equinox.internal.p2.discovery.Catalog;
+import org.eclipse.equinox.internal.p2.discovery.DiscoveryCore;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.BundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.compatibility.RemoteBundleDiscoveryStrategy;
+import org.eclipse.equinox.internal.p2.discovery.model.CatalogItem;
+import org.eclipse.equinox.internal.p2.ui.discovery.DiscoveryUi;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogConfiguration;
+import org.eclipse.equinox.internal.p2.ui.discovery.wizards.CatalogViewer;
+import org.eclipse.jface.action.Action;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.layout.GridDataFactory;
+import org.eclipse.jface.layout.GridLayoutFactory;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.jface.viewers.ISelectionChangedListener;
+import org.eclipse.jface.viewers.IStructuredContentProvider;
+import org.eclipse.jface.viewers.IStructuredSelection;
+import org.eclipse.jface.viewers.SelectionChangedEvent;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.ui.IActionBars;
+import org.eclipse.ui.PlatformUI;
+import org.eclipse.ui.actions.BaseSelectionListenerAction;
+import org.eclipse.ui.part.ViewPart;
+
+import com.nokia.carbide.discovery.ui.Activator;
+
+
+
+/**
+ * This sample class demonstrates how to plug-in a new
+ * workbench view. The view shows data obtained from the
+ * model. The sample creates a dummy model on the fly,
+ * but a real implementation would connect to the model
+ * available either in this or another plug-in (e.g. the workspace).
+ * The view is connected to the model using a content provider.
+ * <p>
+ * The view uses a label provider to define how model
+ * objects should be presented in the view. Each
+ * view can present the same model objects using
+ * different labels and icons, if needed. Alternatively,
+ * a single label provider can be shared between views
+ * in order to ensure that objects of the same type are
+ * presented in the same way everywhere.
+ * <p>
+ */
+
+@SuppressWarnings("restriction")
+public class DiscoveryView extends ViewPart implements ISelectionChangedListener {
+
+ /**
+ * The ID of the view as specified by the extension.
+ */
+ public static final String ID = "testdiscovery.views.TestView";
+
+ private CatalogViewer viewer;
+ private Action refreshAction;
+ private BaseSelectionListenerAction selectAllAction;
+ private BaseSelectionListenerAction selectNoneAction;
+
+ private boolean updated;
+
+ private Button installButton;
+
+ public DiscoveryView() {
+ }
+
+ /**
+ * This is a callback that will allow us
+ * to create the viewer and initialize it.
+ */
+ public void createPartControl(Composite parent) {
+ Composite c = new Composite(parent, SWT.NONE);
+ GridLayoutFactory.fillDefaults().applyTo(c);
+ viewer = new CatalogViewer(getCatalog(), getSite(), getSite().getWorkbenchWindow(), getConfiguration());
+ viewer.createControl(c);
+ GridDataFactory.fillDefaults().grab(true, true).applyTo(viewer.getControl());
+
+ installButton = new Button(c, SWT.PUSH);
+ installButton.setText("Install Checked Items...");
+ ImageDescriptor imgDesc = Activator.getImageDescriptor("icons/icon-discovery.png");
+ installButton.setImage(imgDesc.createImage());
+ installButton.addSelectionListener(new SelectionAdapter() {
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ DiscoveryUi.install(viewer.getCheckedItems(), getSite().getWorkbenchWindow());
+ }
+ });
+ viewer.addSelectionChangedListener(this);
+
+ // Create the help context id for the viewer's control
+ PlatformUI.getWorkbench().getHelpSystem().setHelp(viewer.getControl(), "TestDiscovery.viewer");
+ makeActions();
+ contributeToActionBars();
+ }
+
+ @Override
+ public void selectionChanged(SelectionChangedEvent event) {
+ installButton.setEnabled(!event.getSelection().isEmpty());
+ }
+
+ private CatalogConfiguration getConfiguration() {
+ CatalogConfiguration configuration = new CatalogConfiguration();
+ configuration.setShowTagFilter(false);
+ return configuration;
+ }
+
+ private Catalog getCatalog() {
+ Catalog catalog = new Catalog();
+ catalog.setEnvironment(DiscoveryCore.createEnvironment());
+ catalog.setVerifyUpdateSiteAvailability(false);
+
+ // look for descriptors from installed bundles
+ catalog.getDiscoveryStrategies().add(new BundleDiscoveryStrategy());
+
+ // look for remote descriptor
+ RemoteBundleDiscoveryStrategy remoteDiscoveryStrategy = new RemoteBundleDiscoveryStrategy();
+ File f = new File("D:\\Users\\Discovery\\discovery.xml");
+ try {
+ remoteDiscoveryStrategy.setDirectoryUrl(f.toURI().toURL().toExternalForm());
+ } catch (MalformedURLException e) {
+ throw new IllegalArgumentException(e);
+ }
+// catalog.getDiscoveryStrategies().add(remoteDiscoveryStrategy);
+
+ return catalog;
+ }
+
+ private void contributeToActionBars() {
+ IActionBars bars = getViewSite().getActionBars();
+ fillLocalPullDown(bars.getMenuManager());
+ fillLocalToolBar(bars.getToolBarManager());
+ }
+
+ private void fillLocalPullDown(IMenuManager manager) {
+ manager.add(selectAllAction);
+ manager.add(selectNoneAction);
+ }
+
+ private void fillLocalToolBar(IToolBarManager manager) {
+ manager.add(refreshAction);
+ }
+
+ private void makeActions() {
+ refreshAction = new Action() {
+ public void run() {
+ viewer.refresh();
+ }
+ };
+ refreshAction.setText("Refresh");
+ refreshAction.setImageDescriptor(Activator.getImageDescriptor("icons/refresh.gif"));
+ selectAllAction = new BaseSelectionListenerAction("Select All Items") {
+ public void run() {
+ viewer.setSelection(getAllItemsSelection());
+ viewer.refresh();
+ }
+
+ private IStructuredSelection getAllItemsSelection() {
+ Object[] elements = getAllCatalogItems();
+ IStructuredSelection allItemsSelection = new StructuredSelection(elements);
+ return allItemsSelection;
+ }
+
+ private Object[] getAllCatalogItems() {
+ List<Object> catalogItems = new ArrayList<Object>();
+ IStructuredContentProvider provider =
+ (IStructuredContentProvider) viewer.getViewer().getContentProvider();
+ Object[] elements = provider.getElements(viewer.getViewer().getInput());
+ for (Object item : elements) {
+ if (item instanceof CatalogItem)
+ catalogItems.add(item);
+ }
+ return catalogItems.toArray();
+ };
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return !getAllItemsSelection().equals(selection);
+ };
+ };
+ selectNoneAction = new BaseSelectionListenerAction("Deselect All Items") {
+ public void run() {
+ viewer.setSelection(StructuredSelection.EMPTY);
+ viewer.refresh();
+ };
+
+ protected boolean updateSelection(IStructuredSelection selection) {
+ return !selection.isEmpty();
+ };
+ };
+ viewer.addSelectionChangedListener(selectAllAction);
+ viewer.addSelectionChangedListener(selectNoneAction);
+ }
+
+ @Override
+ public void dispose() {
+ viewer.removeSelectionChangedListener(selectAllAction);
+ viewer.removeSelectionChangedListener(selectNoneAction);
+ viewer.removeSelectionChangedListener(this);
+ super.dispose();
+ }
+
+ /**
+ * Passing the focus request to the viewer's control.
+ */
+ public void setFocus() {
+ updateCatalog();
+ }
+
+ private void updateCatalog() {
+ if (!updated) {
+ updated = true;
+ Display.getDefault().asyncExec(new Runnable() {
+ @Override
+ public void run() {
+ viewer.updateCatalog();
+ }
+ });
+ }
+ }
+
+}
\ No newline at end of file